var Kn0 = Object.create;
var { getPrototypeOf: Gn0, defineProperty: yc, getOwnPropertyNames: Hn0 } = Object;
var Nn0 = Object.prototype.hasOwnProperty;
var t2 = (Z, J, $) => {
  $ = Z != null ? Kn0(Gn0(Z)) : {};
  let X = J || !Z || !Z.__esModule ? yc($, "default", { value: Z, enumerable: !0 }) : $;
  for (let Y of Hn0(Z))
    if (!Nn0.call(X, Y))
      yc(X, Y, {
        get: () => Z[Y],
        enumerable: !0
      });
  return X;
};
var SX = (Z, J) => () => (J || Z((J = { exports: {} }).exports, J), J.exports);
var y9 = (Z, J) => {
  for (var $ in J)
    yc(Z, $, {
      get: J[$],
      enumerable: !0,
      configurable: !0,
      set: (X) => J[$] = () => X
    });
};

// node_modules/react/cjs/react.development.js
var J7 = SX((qn0, ck) => {
  (function() {
    if (typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== "undefined" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart === "function")
      __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error);
    var Z = "18.3.1", J = Symbol.for("react.element"), $ = Symbol.for("react.portal"), X = Symbol.for("react.fragment"), Y = Symbol.for("react.strict_mode"), Q = Symbol.for("react.profiler"), W = Symbol.for("react.provider"), K = Symbol.for("react.context"), G = Symbol.for("react.forward_ref"), H = Symbol.for("react.suspense"), N = Symbol.for("react.suspense_list"), q = Symbol.for("react.memo"), U = Symbol.for("react.lazy"), F = Symbol.for("react.offscreen"), E = Symbol.iterator, R = "@@iterator";
    function z(B0) {
      if (B0 === null || typeof B0 !== "object")
        return null;
      var J1 = E && B0[E] || B0[R];
      if (typeof J1 === "function")
        return J1;
      return null;
    }
    var D = {
      current: null
    }, A = {
      transition: null
    }, B = {
      current: null,
      isBatchingLegacy: !1,
      didScheduleLegacyUpdate: !1
    }, T = {
      current: null
    }, w = {}, V = null;
    function P(B0) {
      V = B0;
    }
    w.setExtraStackFrame = function(B0) {
      V = B0;
    }, w.getCurrentStack = null, w.getStackAddendum = function() {
      var B0 = "";
      if (V)
        B0 += V;
      var J1 = w.getCurrentStack;
      if (J1)
        B0 += J1() || "";
      return B0;
    };
    var I = !1, S = !1, f = !1, v = !1, h = !1, x = {
      ReactCurrentDispatcher: D,
      ReactCurrentBatchConfig: A,
      ReactCurrentOwner: T
    };
    x.ReactDebugCurrentFrame = w, x.ReactCurrentActQueue = B;
    function b(B0) {
      {
        for (var J1 = arguments.length, b1 = new Array(J1 > 1 ? J1 - 1 : 0), X2 = 1;X2 < J1; X2++)
          b1[X2 - 1] = arguments[X2];
        m("warn", B0, b1);
      }
    }
    function g(B0) {
      {
        for (var J1 = arguments.length, b1 = new Array(J1 > 1 ? J1 - 1 : 0), X2 = 1;X2 < J1; X2++)
          b1[X2 - 1] = arguments[X2];
        m("error", B0, b1);
      }
    }
    function m(B0, J1, b1) {
      {
        var X2 = x.ReactDebugCurrentFrame, i2 = X2.getStackAddendum();
        if (i2 !== "")
          J1 += "%s", b1 = b1.concat([i2]);
        var V6 = b1.map(function(h8) {
          return String(h8);
        });
        V6.unshift("Warning: " + J1), Function.prototype.apply.call(console[B0], console, V6);
      }
    }
    var i = {};
    function r(B0, J1) {
      {
        var b1 = B0.constructor, X2 = b1 && (b1.displayName || b1.name) || "ReactClass", i2 = X2 + "." + J1;
        if (i[i2])
          return;
        g("Can't call %s on a component that is not yet mounted. This is a no-op, but it might indicate a bug in your application. Instead, assign to `this.state` directly or define a `state = {};` class property with the desired state in the %s component.", J1, X2), i[i2] = !0;
      }
    }
    var Y0 = {
      isMounted: function(B0) {
        return !1;
      },
      enqueueForceUpdate: function(B0, J1, b1) {
        r(B0, "forceUpdate");
      },
      enqueueReplaceState: function(B0, J1, b1, X2) {
        r(B0, "replaceState");
      },
      enqueueSetState: function(B0, J1, b1, X2) {
        r(B0, "setState");
      }
    }, c = Object.assign, n = {};
    Object.freeze(n);
    function l(B0, J1, b1) {
      this.props = B0, this.context = J1, this.refs = n, this.updater = b1 || Y0;
    }
    l.prototype.isReactComponent = {}, l.prototype.setState = function(B0, J1) {
      if (typeof B0 !== "object" && typeof B0 !== "function" && B0 != null)
        throw new Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");
      this.updater.enqueueSetState(this, B0, J1, "setState");
    }, l.prototype.forceUpdate = function(B0) {
      this.updater.enqueueForceUpdate(this, B0, "forceUpdate");
    };
    {
      var u = {
        isMounted: ["isMounted", "Instead, make sure to clean up subscriptions and pending requests in componentWillUnmount to prevent memory leaks."],
        replaceState: ["replaceState", "Refactor your code to use setState instead (see https://github.com/facebook/react/issues/3236)."]
      }, G0 = function(B0, J1) {
        Object.defineProperty(l.prototype, B0, {
          get: function() {
            b("%s(...) is deprecated in plain JavaScript React classes. %s", J1[0], J1[1]);
            return;
          }
        });
      };
      for (var F0 in u)
        if (u.hasOwnProperty(F0))
          G0(F0, u[F0]);
    }
    function t() {}
    t.prototype = l.prototype;
    function Z0(B0, J1, b1) {
      this.props = B0, this.context = J1, this.refs = n, this.updater = b1 || Y0;
    }
    var U0 = Z0.prototype = new t;
    U0.constructor = Z0, c(U0, l.prototype), U0.isPureReactComponent = !0;
    function a() {
      var B0 = {
        current: null
      };
      return Object.seal(B0), B0;
    }
    var Q0 = Array.isArray;
    function $0(B0) {
      return Q0(B0);
    }
    function R0(B0) {
      {
        var J1 = typeof Symbol === "function" && Symbol.toStringTag, b1 = J1 && B0[Symbol.toStringTag] || B0.constructor.name || "Object";
        return b1;
      }
    }
    function X0(B0) {
      try {
        return E0(B0), !1;
      } catch (J1) {
        return !0;
      }
    }
    function E0(B0) {
      return "" + B0;
    }
    function V0(B0) {
      if (X0(B0))
        return g("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.", R0(B0)), E0(B0);
    }
    function u0(B0, J1, b1) {
      var X2 = B0.displayName;
      if (X2)
        return X2;
      var i2 = J1.displayName || J1.name || "";
      return i2 !== "" ? b1 + "(" + i2 + ")" : b1;
    }
    function N0(B0) {
      return B0.displayName || "Context";
    }
    function q0(B0) {
      if (B0 == null)
        return null;
      if (typeof B0.tag === "number")
        g("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue.");
      if (typeof B0 === "function")
        return B0.displayName || B0.name || null;
      if (typeof B0 === "string")
        return B0;
      switch (B0) {
        case X:
          return "Fragment";
        case $:
          return "Portal";
        case Q:
          return "Profiler";
        case Y:
          return "StrictMode";
        case H:
          return "Suspense";
        case N:
          return "SuspenseList";
      }
      if (typeof B0 === "object")
        switch (B0.$$typeof) {
          case K:
            var J1 = B0;
            return N0(J1) + ".Consumer";
          case W:
            var b1 = B0;
            return N0(b1._context) + ".Provider";
          case G:
            return u0(B0, B0.render, "ForwardRef");
          case q:
            var X2 = B0.displayName || null;
            if (X2 !== null)
              return X2;
            return q0(B0.type) || "Memo";
          case U: {
            var i2 = B0, V6 = i2._payload, h8 = i2._init;
            try {
              return q0(h8(V6));
            } catch (l6) {
              return null;
            }
          }
        }
      return null;
    }
    var A0 = Object.prototype.hasOwnProperty, S0 = {
      key: !0,
      ref: !0,
      __self: !0,
      __source: !0
    }, a0, D1, Y1;
    Y1 = {};
    function u1(B0) {
      if (A0.call(B0, "ref")) {
        var J1 = Object.getOwnPropertyDescriptor(B0, "ref").get;
        if (J1 && J1.isReactWarning)
          return !1;
      }
      return B0.ref !== void 0;
    }
    function b0(B0) {
      if (A0.call(B0, "key")) {
        var J1 = Object.getOwnPropertyDescriptor(B0, "key").get;
        if (J1 && J1.isReactWarning)
          return !1;
      }
      return B0.key !== void 0;
    }
    function x0(B0, J1) {
      var b1 = function() {
        if (!a0)
          a0 = !0, g("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)", J1);
      };
      b1.isReactWarning = !0, Object.defineProperty(B0, "key", {
        get: b1,
        configurable: !0
      });
    }
    function m0(B0, J1) {
      var b1 = function() {
        if (!D1)
          D1 = !0, g("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)", J1);
      };
      b1.isReactWarning = !0, Object.defineProperty(B0, "ref", {
        get: b1,
        configurable: !0
      });
    }
    function e0(B0) {
      if (typeof B0.ref === "string" && T.current && B0.__self && T.current.stateNode !== B0.__self) {
        var J1 = q0(T.current.type);
        if (!Y1[J1])
          g('Component "%s" contains the string ref "%s". Support for string refs will be removed in a future major release. This case cannot be automatically converted to an arrow function. We ask you to manually fix this case by using useRef() or createRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref', J1, B0.ref), Y1[J1] = !0;
      }
    }
    var p = function(B0, J1, b1, X2, i2, V6, h8) {
      var l6 = {
        $$typeof: J,
        type: B0,
        key: J1,
        ref: b1,
        props: h8,
        _owner: V6
      };
      if (l6._store = {}, Object.defineProperty(l6._store, "validated", {
        configurable: !1,
        enumerable: !1,
        writable: !0,
        value: !1
      }), Object.defineProperty(l6, "_self", {
        configurable: !1,
        enumerable: !1,
        writable: !1,
        value: X2
      }), Object.defineProperty(l6, "_source", {
        configurable: !1,
        enumerable: !1,
        writable: !1,
        value: i2
      }), Object.freeze)
        Object.freeze(l6.props), Object.freeze(l6);
      return l6;
    };
    function J0(B0, J1, b1) {
      var X2, i2 = {}, V6 = null, h8 = null, l6 = null, Q9 = null;
      if (J1 != null) {
        if (u1(J1))
          h8 = J1.ref, e0(J1);
        if (b0(J1))
          V0(J1.key), V6 = "" + J1.key;
        l6 = J1.__self === void 0 ? null : J1.__self, Q9 = J1.__source === void 0 ? null : J1.__source;
        for (X2 in J1)
          if (A0.call(J1, X2) && !S0.hasOwnProperty(X2))
            i2[X2] = J1[X2];
      }
      var F7 = arguments.length - 2;
      if (F7 === 1)
        i2.children = b1;
      else if (F7 > 1) {
        var S7 = Array(F7);
        for (var f7 = 0;f7 < F7; f7++)
          S7[f7] = arguments[f7 + 2];
        if (Object.freeze)
          Object.freeze(S7);
        i2.children = S7;
      }
      if (B0 && B0.defaultProps) {
        var GJ = B0.defaultProps;
        for (X2 in GJ)
          if (i2[X2] === void 0)
            i2[X2] = GJ[X2];
      }
      if (V6 || h8) {
        var X$ = typeof B0 === "function" ? B0.displayName || B0.name || "Unknown" : B0;
        if (V6)
          x0(i2, X$);
        if (h8)
          m0(i2, X$);
      }
      return p(B0, V6, h8, l6, Q9, T.current, i2);
    }
    function T0(B0, J1) {
      var b1 = p(B0.type, J1, B0.ref, B0._self, B0._source, B0._owner, B0.props);
      return b1;
    }
    function o0(B0, J1, b1) {
      if (B0 === null || B0 === void 0)
        throw new Error("React.cloneElement(...): The argument must be a React element, but you passed " + B0 + ".");
      var X2, i2 = c({}, B0.props), V6 = B0.key, h8 = B0.ref, l6 = B0._self, Q9 = B0._source, F7 = B0._owner;
      if (J1 != null) {
        if (u1(J1))
          h8 = J1.ref, F7 = T.current;
        if (b0(J1))
          V0(J1.key), V6 = "" + J1.key;
        var S7;
        if (B0.type && B0.type.defaultProps)
          S7 = B0.type.defaultProps;
        for (X2 in J1)
          if (A0.call(J1, X2) && !S0.hasOwnProperty(X2))
            if (J1[X2] === void 0 && S7 !== void 0)
              i2[X2] = S7[X2];
            else
              i2[X2] = J1[X2];
      }
      var f7 = arguments.length - 2;
      if (f7 === 1)
        i2.children = b1;
      else if (f7 > 1) {
        var GJ = Array(f7);
        for (var X$ = 0;X$ < f7; X$++)
          GJ[X$] = arguments[X$ + 2];
        i2.children = GJ;
      }
      return p(B0.type, V6, h8, l6, Q9, F7, i2);
    }
    function y0(B0) {
      return typeof B0 === "object" && B0 !== null && B0.$$typeof === J;
    }
    var $1 = ".", F1 = ":";
    function A1(B0) {
      var J1 = /[=:]/g, b1 = {
        "=": "=0",
        ":": "=2"
      }, X2 = B0.replace(J1, function(i2) {
        return b1[i2];
      });
      return "$" + X2;
    }
    var P1 = !1, S1 = /\/+/g;
    function _1(B0) {
      return B0.replace(S1, "$&/");
    }
    function a1(B0, J1) {
      if (typeof B0 === "object" && B0 !== null && B0.key != null)
        return V0(B0.key), A1("" + B0.key);
      return J1.toString(36);
    }
    function U2(B0, J1, b1, X2, i2) {
      var V6 = typeof B0;
      if (V6 === "undefined" || V6 === "boolean")
        B0 = null;
      var h8 = !1;
      if (B0 === null)
        h8 = !0;
      else
        switch (V6) {
          case "string":
          case "number":
            h8 = !0;
            break;
          case "object":
            switch (B0.$$typeof) {
              case J:
              case $:
                h8 = !0;
            }
        }
      if (h8) {
        var l6 = B0, Q9 = i2(l6), F7 = X2 === "" ? $1 + a1(l6, 0) : X2;
        if ($0(Q9)) {
          var S7 = "";
          if (F7 != null)
            S7 = _1(F7) + "/";
          U2(Q9, J1, S7, "", function(hm) {
            return hm;
          });
        } else if (Q9 != null) {
          if (y0(Q9)) {
            if (Q9.key && (!l6 || l6.key !== Q9.key))
              V0(Q9.key);
            Q9 = T0(Q9, b1 + (Q9.key && (!l6 || l6.key !== Q9.key) ? _1("" + Q9.key) + "/" : "") + F7);
          }
          J1.push(Q9);
        }
        return 1;
      }
      var f7, GJ, X$ = 0, b9 = X2 === "" ? $1 : X2 + F1;
      if ($0(B0))
        for (var lE = 0;lE < B0.length; lE++)
          f7 = B0[lE], GJ = b9 + a1(f7, lE), X$ += U2(f7, J1, b1, GJ, i2);
      else {
        var f4 = z(B0);
        if (typeof f4 === "function") {
          var hw = B0;
          if (f4 === hw.entries) {
            if (!P1)
              b("Using Maps as children is not supported. Use an array of keyed ReactElements instead.");
            P1 = !0;
          }
          var fm = f4.call(hw), oq, bw = 0;
          while (!(oq = fm.next()).done)
            f7 = oq.value, GJ = b9 + a1(f7, bw++), X$ += U2(f7, J1, b1, GJ, i2);
        } else if (V6 === "object") {
          var xw = String(B0);
          throw new Error("Objects are not valid as a React child (found: " + (xw === "[object Object]" ? "object with keys {" + Object.keys(B0).join(", ") + "}" : xw) + "). If you meant to render a collection of children, use an array instead.");
        }
      }
      return X$;
    }
    function G2(B0, J1, b1) {
      if (B0 == null)
        return B0;
      var X2 = [], i2 = 0;
      return U2(B0, X2, "", "", function(V6) {
        return J1.call(b1, V6, i2++);
      }), X2;
    }
    function P2(B0) {
      var J1 = 0;
      return G2(B0, function() {
        J1++;
      }), J1;
    }
    function v2(B0, J1, b1) {
      G2(B0, function() {
        J1.apply(this, arguments);
      }, b1);
    }
    function O8(B0) {
      return G2(B0, function(J1) {
        return J1;
      }) || [];
    }
    function n8(B0) {
      if (!y0(B0))
        throw new Error("React.Children.only expected to receive a single React element child.");
      return B0;
    }
    function z6(B0) {
      var J1 = {
        $$typeof: K,
        _currentValue: B0,
        _currentValue2: B0,
        _threadCount: 0,
        Provider: null,
        Consumer: null,
        _defaultValue: null,
        _globalName: null
      };
      J1.Provider = {
        $$typeof: W,
        _context: J1
      };
      var b1 = !1, X2 = !1, i2 = !1;
      {
        var V6 = {
          $$typeof: K,
          _context: J1
        };
        Object.defineProperties(V6, {
          Provider: {
            get: function() {
              if (!X2)
                X2 = !0, g("Rendering <Context.Consumer.Provider> is not supported and will be removed in a future major release. Did you mean to render <Context.Provider> instead?");
              return J1.Provider;
            },
            set: function(h8) {
              J1.Provider = h8;
            }
          },
          _currentValue: {
            get: function() {
              return J1._currentValue;
            },
            set: function(h8) {
              J1._currentValue = h8;
            }
          },
          _currentValue2: {
            get: function() {
              return J1._currentValue2;
            },
            set: function(h8) {
              J1._currentValue2 = h8;
            }
          },
          _threadCount: {
            get: function() {
              return J1._threadCount;
            },
            set: function(h8) {
              J1._threadCount = h8;
            }
          },
          Consumer: {
            get: function() {
              if (!b1)
                b1 = !0, g("Rendering <Context.Consumer.Consumer> is not supported and will be removed in a future major release. Did you mean to render <Context.Consumer> instead?");
              return J1.Consumer;
            }
          },
          displayName: {
            get: function() {
              return J1.displayName;
            },
            set: function(h8) {
              if (!i2)
                b("Setting `displayName` on Context.Consumer has no effect. You should set it directly on the context with Context.displayName = '%s'.", h8), i2 = !0;
            }
          }
        }), J1.Consumer = V6;
      }
      return J1._currentRenderer = null, J1._currentRenderer2 = null, J1;
    }
    var L8 = -1, R8 = 0, w0 = 1, P0 = 2;
    function l0(B0) {
      if (B0._status === L8) {
        var J1 = B0._result, b1 = J1();
        if (b1.then(function(V6) {
          if (B0._status === R8 || B0._status === L8) {
            var h8 = B0;
            h8._status = w0, h8._result = V6;
          }
        }, function(V6) {
          if (B0._status === R8 || B0._status === L8) {
            var h8 = B0;
            h8._status = P0, h8._result = V6;
          }
        }), B0._status === L8) {
          var X2 = B0;
          X2._status = R8, X2._result = b1;
        }
      }
      if (B0._status === w0) {
        var i2 = B0._result;
        if (i2 === void 0)
          g(`lazy: Expected the result of a dynamic import() call. Instead received: %s

Your code should look like: 
  const MyComponent = lazy(() => import('./MyComponent'))

Did you accidentally put curly braces around the import?`, i2);
        if (!("default" in i2))
          g(`lazy: Expected the result of a dynamic import() call. Instead received: %s

Your code should look like: 
  const MyComponent = lazy(() => import('./MyComponent'))`, i2);
        return i2.default;
      } else
        throw B0._result;
    }
    function z1(B0) {
      var J1 = {
        _status: L8,
        _result: B0
      }, b1 = {
        $$typeof: U,
        _payload: J1,
        _init: l0
      };
      {
        var X2, i2;
        Object.defineProperties(b1, {
          defaultProps: {
            configurable: !0,
            get: function() {
              return X2;
            },
            set: function(V6) {
              g("React.lazy(...): It is not supported to assign `defaultProps` to a lazy component import. Either specify them where the component is defined, or create a wrapping component around it."), X2 = V6, Object.defineProperty(b1, "defaultProps", {
                enumerable: !0
              });
            }
          },
          propTypes: {
            configurable: !0,
            get: function() {
              return i2;
            },
            set: function(V6) {
              g("React.lazy(...): It is not supported to assign `propTypes` to a lazy component import. Either specify them where the component is defined, or create a wrapping component around it."), i2 = V6, Object.defineProperty(b1, "propTypes", {
                enumerable: !0
              });
            }
          }
        });
      }
      return b1;
    }
    function J2(B0) {
      {
        if (B0 != null && B0.$$typeof === q)
          g("forwardRef requires a render function but received a `memo` component. Instead of forwardRef(memo(...)), use memo(forwardRef(...)).");
        else if (typeof B0 !== "function")
          g("forwardRef requires a render function but was given %s.", B0 === null ? "null" : typeof B0);
        else if (B0.length !== 0 && B0.length !== 2)
          g("forwardRef render functions accept exactly two parameters: props and ref. %s", B0.length === 1 ? "Did you forget to use the ref parameter?" : "Any additional parameter will be undefined.");
        if (B0 != null) {
          if (B0.defaultProps != null || B0.propTypes != null)
            g("forwardRef render functions do not support propTypes or defaultProps. Did you accidentally pass a React component?");
        }
      }
      var J1 = {
        $$typeof: G,
        render: B0
      };
      {
        var b1;
        Object.defineProperty(J1, "displayName", {
          enumerable: !1,
          configurable: !0,
          get: function() {
            return b1;
          },
          set: function(X2) {
            if (b1 = X2, !B0.name && !B0.displayName)
              B0.displayName = X2;
          }
        });
      }
      return J1;
    }
    var N2 = Symbol.for("react.module.reference");
    function X8(B0) {
      if (typeof B0 === "string" || typeof B0 === "function")
        return !0;
      if (B0 === X || B0 === Q || h || B0 === Y || B0 === H || B0 === N || v || B0 === F || I || S || f)
        return !0;
      if (typeof B0 === "object" && B0 !== null) {
        if (B0.$$typeof === U || B0.$$typeof === q || B0.$$typeof === W || B0.$$typeof === K || B0.$$typeof === G || B0.$$typeof === N2 || B0.getModuleId !== void 0)
          return !0;
      }
      return !1;
    }
    function c0(B0, J1) {
      if (!X8(B0))
        g("memo: The first argument must be a component. Instead received: %s", B0 === null ? "null" : typeof B0);
      var b1 = {
        $$typeof: q,
        type: B0,
        compare: J1 === void 0 ? null : J1
      };
      {
        var X2;
        Object.defineProperty(b1, "displayName", {
          enumerable: !1,
          configurable: !0,
          get: function() {
            return X2;
          },
          set: function(i2) {
            if (X2 = i2, !B0.name && !B0.displayName)
              B0.displayName = i2;
          }
        });
      }
      return b1;
    }
    function M1() {
      var B0 = D.current;
      if (B0 === null)
        g(`Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:
1. You might have mismatching versions of React and the renderer (such as React DOM)
2. You might be breaking the Rules of Hooks
3. You might have more than one copy of React in the same app
See https://reactjs.org/link/invalid-hook-call for tips about how to debug and fix this problem.`);
      return B0;
    }
    function g1(B0) {
      var J1 = M1();
      if (B0._context !== void 0) {
        var b1 = B0._context;
        if (b1.Consumer === B0)
          g("Calling useContext(Context.Consumer) is not supported, may cause bugs, and will be removed in a future major release. Did you mean to call useContext(Context) instead?");
        else if (b1.Provider === B0)
          g("Calling useContext(Context.Provider) is not supported. Did you mean to call useContext(Context) instead?");
      }
      return J1.useContext(B0);
    }
    function l2(B0) {
      var J1 = M1();
      return J1.useState(B0);
    }
    function d8(B0, J1, b1) {
      var X2 = M1();
      return X2.useReducer(B0, J1, b1);
    }
    function I1(B0) {
      var J1 = M1();
      return J1.useRef(B0);
    }
    function W2(B0, J1) {
      var b1 = M1();
      return b1.useEffect(B0, J1);
    }
    function z2(B0, J1) {
      var b1 = M1();
      return b1.useInsertionEffect(B0, J1);
    }
    function p8(B0, J1) {
      var b1 = M1();
      return b1.useLayoutEffect(B0, J1);
    }
    function W6(B0, J1) {
      var b1 = M1();
      return b1.useCallback(B0, J1);
    }
    function v6(B0, J1) {
      var b1 = M1();
      return b1.useMemo(B0, J1);
    }
    function AZ(B0, J1, b1) {
      var X2 = M1();
      return X2.useImperativeHandle(B0, J1, b1);
    }
    function L1(B0, J1) {
      {
        var b1 = M1();
        return b1.useDebugValue(B0, J1);
      }
    }
    function q2() {
      var B0 = M1();
      return B0.useTransition();
    }
    function s2(B0) {
      var J1 = M1();
      return J1.useDeferredValue(B0);
    }
    function d0() {
      var B0 = M1();
      return B0.useId();
    }
    function d1(B0, J1, b1) {
      var X2 = M1();
      return X2.useSyncExternalStore(B0, J1, b1);
    }
    var A2 = 0, B8, Z6, t6, D2, vZ, c6, HZ;
    function pY() {}
    pY.__reactDisabledLog = !0;
    function GW() {
      {
        if (A2 === 0) {
          B8 = console.log, Z6 = console.info, t6 = console.warn, D2 = console.error, vZ = console.group, c6 = console.groupCollapsed, HZ = console.groupEnd;
          var B0 = {
            configurable: !0,
            enumerable: !0,
            value: pY,
            writable: !0
          };
          Object.defineProperties(console, {
            info: B0,
            log: B0,
            warn: B0,
            error: B0,
            group: B0,
            groupCollapsed: B0,
            groupEnd: B0
          });
        }
        A2++;
      }
    }
    function lH() {
      {
        if (A2--, A2 === 0) {
          var B0 = {
            configurable: !0,
            enumerable: !0,
            writable: !0
          };
          Object.defineProperties(console, {
            log: c({}, B0, {
              value: B8
            }),
            info: c({}, B0, {
              value: Z6
            }),
            warn: c({}, B0, {
              value: t6
            }),
            error: c({}, B0, {
              value: D2
            }),
            group: c({}, B0, {
              value: vZ
            }),
            groupCollapsed: c({}, B0, {
              value: c6
            }),
            groupEnd: c({}, B0, {
              value: HZ
            })
          });
        }
        if (A2 < 0)
          g("disabledDepth fell below zero. This is a bug in React. Please file an issue.");
      }
    }
    var MJ = x.ReactCurrentDispatcher, q7;
    function BX(B0, J1, b1) {
      {
        if (q7 === void 0)
          try {
            throw Error();
          } catch (i2) {
            var X2 = i2.stack.trim().match(/\n( *(at )?)/);
            q7 = X2 && X2[1] || "";
          }
        return `
` + q7 + B0;
      }
    }
    var wX = !1, v7;
    {
      var v0 = typeof WeakMap === "function" ? WeakMap : Map;
      v7 = new v0;
    }
    function E1(B0, J1) {
      if (!B0 || wX)
        return "";
      {
        var b1 = v7.get(B0);
        if (b1 !== void 0)
          return b1;
      }
      var X2;
      wX = !0;
      var i2 = Error.prepareStackTrace;
      Error.prepareStackTrace = void 0;
      var V6;
      V6 = MJ.current, MJ.current = null, GW();
      try {
        if (J1) {
          var h8 = function() {
            throw Error();
          };
          if (Object.defineProperty(h8.prototype, "props", {
            set: function() {
              throw Error();
            }
          }), typeof Reflect === "object" && Reflect.construct) {
            try {
              Reflect.construct(h8, []);
            } catch (b9) {
              X2 = b9;
            }
            Reflect.construct(B0, [], h8);
          } else {
            try {
              h8.call();
            } catch (b9) {
              X2 = b9;
            }
            B0.call(h8.prototype);
          }
        } else {
          try {
            throw Error();
          } catch (b9) {
            X2 = b9;
          }
          B0();
        }
      } catch (b9) {
        if (b9 && X2 && typeof b9.stack === "string") {
          var l6 = b9.stack.split(`
`), Q9 = X2.stack.split(`
`), F7 = l6.length - 1, S7 = Q9.length - 1;
          while (F7 >= 1 && S7 >= 0 && l6[F7] !== Q9[S7])
            S7--;
          for (;F7 >= 1 && S7 >= 0; F7--, S7--)
            if (l6[F7] !== Q9[S7]) {
              if (F7 !== 1 || S7 !== 1)
                do
                  if (F7--, S7--, S7 < 0 || l6[F7] !== Q9[S7]) {
                    var f7 = `
` + l6[F7].replace(" at new ", " at ");
                    if (B0.displayName && f7.includes("<anonymous>"))
                      f7 = f7.replace("<anonymous>", B0.displayName);
                    if (typeof B0 === "function")
                      v7.set(B0, f7);
                    return f7;
                  }
                while (F7 >= 1 && S7 >= 0);
              break;
            }
        }
      } finally {
        wX = !1, MJ.current = V6, lH(), Error.prepareStackTrace = i2;
      }
      var GJ = B0 ? B0.displayName || B0.name : "", X$ = GJ ? BX(GJ) : "";
      if (typeof B0 === "function")
        v7.set(B0, X$);
      return X$;
    }
    function c1(B0, J1, b1) {
      return E1(B0, !1);
    }
    function L2(B0) {
      var J1 = B0.prototype;
      return !!(J1 && J1.isReactComponent);
    }
    function N8(B0, J1, b1) {
      if (B0 == null)
        return "";
      if (typeof B0 === "function")
        return E1(B0, L2(B0));
      if (typeof B0 === "string")
        return BX(B0);
      switch (B0) {
        case H:
          return BX("Suspense");
        case N:
          return BX("SuspenseList");
      }
      if (typeof B0 === "object")
        switch (B0.$$typeof) {
          case G:
            return c1(B0.render);
          case q:
            return N8(B0.type, J1, b1);
          case U: {
            var X2 = B0, i2 = X2._payload, V6 = X2._init;
            try {
              return N8(V6(i2), J1, b1);
            } catch (h8) {}
          }
        }
      return "";
    }
    var yZ = {}, _6 = x.ReactDebugCurrentFrame;
    function JZ(B0) {
      if (B0) {
        var J1 = B0._owner, b1 = N8(B0.type, B0._source, J1 ? J1.type : null);
        _6.setExtraStackFrame(b1);
      } else
        _6.setExtraStackFrame(null);
    }
    function gJ(B0, J1, b1, X2, i2) {
      {
        var V6 = Function.call.bind(A0);
        for (var h8 in B0)
          if (V6(B0, h8)) {
            var l6 = void 0;
            try {
              if (typeof B0[h8] !== "function") {
                var Q9 = Error((X2 || "React class") + ": " + b1 + " type `" + h8 + "` is invalid; it must be a function, usually from the `prop-types` package, but received `" + typeof B0[h8] + "`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");
                throw Q9.name = "Invariant Violation", Q9;
              }
              l6 = B0[h8](J1, h8, X2, b1, null, "SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED");
            } catch (F7) {
              l6 = F7;
            }
            if (l6 && !(l6 instanceof Error))
              JZ(i2), g("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).", X2 || "React class", b1, h8, typeof l6), JZ(null);
            if (l6 instanceof Error && !(l6.message in yZ))
              yZ[l6.message] = !0, JZ(i2), g("Failed %s type: %s", b1, l6.message), JZ(null);
          }
      }
    }
    function y6(B0) {
      if (B0) {
        var J1 = B0._owner, b1 = N8(B0.type, B0._source, J1 ? J1.type : null);
        P(b1);
      } else
        P(null);
    }
    var uY = !1;
    function jX() {
      if (T.current) {
        var B0 = q0(T.current.type);
        if (B0)
          return `

Check the render method of \`` + B0 + "`.";
      }
      return "";
    }
    function D6(B0) {
      if (B0 !== void 0) {
        var J1 = B0.fileName.replace(/^.*[\\\/]/, ""), b1 = B0.lineNumber;
        return `

Check your code at ` + J1 + ":" + b1 + ".";
      }
      return "";
    }
    function HW(B0) {
      if (B0 !== null && B0 !== void 0)
        return D6(B0.__source);
      return "";
    }
    var sX = {};
    function nH(B0) {
      var J1 = jX();
      if (!J1) {
        var b1 = typeof B0 === "string" ? B0 : B0.displayName || B0.name;
        if (b1)
          J1 = `

Check the top-level render call using <` + b1 + ">.";
      }
      return J1;
    }
    function TG(B0, J1) {
      if (!B0._store || B0._store.validated || B0.key != null)
        return;
      B0._store.validated = !0;
      var b1 = nH(J1);
      if (sX[b1])
        return;
      sX[b1] = !0;
      var X2 = "";
      if (B0 && B0._owner && B0._owner !== T.current)
        X2 = " It was passed a child from " + q0(B0._owner.type) + ".";
      y6(B0), g('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.', b1, X2), y6(null);
    }
    function SP(B0, J1) {
      if (typeof B0 !== "object")
        return;
      if ($0(B0))
        for (var b1 = 0;b1 < B0.length; b1++) {
          var X2 = B0[b1];
          if (y0(X2))
            TG(X2, J1);
        }
      else if (y0(B0)) {
        if (B0._store)
          B0._store.validated = !0;
      } else if (B0) {
        var i2 = z(B0);
        if (typeof i2 === "function") {
          if (i2 !== B0.entries) {
            var V6 = i2.call(B0), h8;
            while (!(h8 = V6.next()).done)
              if (y0(h8.value))
                TG(h8.value, J1);
          }
        }
      }
    }
    function aX(B0) {
      {
        var J1 = B0.type;
        if (J1 === null || J1 === void 0 || typeof J1 === "string")
          return;
        var b1;
        if (typeof J1 === "function")
          b1 = J1.propTypes;
        else if (typeof J1 === "object" && (J1.$$typeof === G || J1.$$typeof === q))
          b1 = J1.propTypes;
        else
          return;
        if (b1) {
          var X2 = q0(J1);
          gJ(b1, B0.props, "prop", X2, B0);
        } else if (J1.PropTypes !== void 0 && !uY) {
          uY = !0;
          var i2 = q0(J1);
          g("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?", i2 || "Unknown");
        }
        if (typeof J1.getDefaultProps === "function" && !J1.getDefaultProps.isReactClassApproved)
          g("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.");
      }
    }
    function mJ(B0) {
      {
        var J1 = Object.keys(B0.props);
        for (var b1 = 0;b1 < J1.length; b1++) {
          var X2 = J1[b1];
          if (X2 !== "children" && X2 !== "key") {
            y6(B0), g("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.", X2), y6(null);
            break;
          }
        }
        if (B0.ref !== null)
          y6(B0), g("Invalid attribute `ref` supplied to `React.Fragment`."), y6(null);
      }
    }
    function fP(B0, J1, b1) {
      var X2 = X8(B0);
      if (!X2) {
        var i2 = "";
        if (B0 === void 0 || typeof B0 === "object" && B0 !== null && Object.keys(B0).length === 0)
          i2 += " You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.";
        var V6 = HW(J1);
        if (V6)
          i2 += V6;
        else
          i2 += jX();
        var h8;
        if (B0 === null)
          h8 = "null";
        else if ($0(B0))
          h8 = "array";
        else if (B0 !== void 0 && B0.$$typeof === J)
          h8 = "<" + (q0(B0.type) || "Unknown") + " />", i2 = " Did you accidentally export a JSX literal instead of a component?";
        else
          h8 = typeof B0;
        g("React.createElement: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s", h8, i2);
      }
      var l6 = J0.apply(this, arguments);
      if (l6 == null)
        return l6;
      if (X2)
        for (var Q9 = 2;Q9 < arguments.length; Q9++)
          SP(arguments[Q9], B0);
      if (B0 === X)
        mJ(l6);
      else
        aX(l6);
      return l6;
    }
    var n5 = !1;
    function Z5(B0) {
      var J1 = fP.bind(null, B0);
      J1.type = B0;
      {
        if (!n5)
          n5 = !0, b("React.createFactory() is deprecated and will be removed in a future major release. Consider using JSX or use React.createElement() directly instead.");
        Object.defineProperty(J1, "type", {
          enumerable: !1,
          get: function() {
            return b("Factory.type is deprecated. Access the class directly before passing it to createFactory."), Object.defineProperty(this, "type", {
              value: B0
            }), B0;
          }
        });
      }
      return J1;
    }
    function iH(B0, J1, b1) {
      var X2 = o0.apply(this, arguments);
      for (var i2 = 2;i2 < arguments.length; i2++)
        SP(arguments[i2], X2.type);
      return aX(X2), X2;
    }
    function Sm(B0, J1) {
      var b1 = A.transition;
      A.transition = {};
      var X2 = A.transition;
      A.transition._updatedFibers = /* @__PURE__ */ new Set;
      try {
        B0();
      } finally {
        if (A.transition = b1, b1 === null && X2._updatedFibers) {
          var i2 = X2._updatedFibers.size;
          if (i2 > 10)
            b("Detected a large number of updates inside startTransition. If this is due to a subscription please re-write it to use React provided hooks. Otherwise concurrent mode guarantees are off the table.");
          X2._updatedFibers.clear();
        }
      }
    }
    var k4 = !1, cE = null;
    function hP(B0) {
      if (cE === null)
        try {
          var J1 = ("require" + Math.random()).slice(0, 7), b1 = ck && ck[J1];
          cE = b1.call(ck, "timers").setImmediate;
        } catch (X2) {
          cE = function(i2) {
            if (k4 === !1) {
              if (k4 = !0, typeof MessageChannel === "undefined")
                g("This browser does not have a MessageChannel implementation, so enqueuing tasks via await act(async () => ...) will fail. Please file an issue at https://github.com/facebook/react/issues if you encounter this warning.");
            }
            var V6 = new MessageChannel;
            V6.port1.onmessage = i2, V6.port2.postMessage(void 0);
          };
        }
      return cE(B0);
    }
    var yU = 0, bP = !1;
    function xP(B0) {
      {
        var J1 = yU;
        if (yU++, B.current === null)
          B.current = [];
        var b1 = B.isBatchingLegacy, X2;
        try {
          if (B.isBatchingLegacy = !0, X2 = B0(), !b1 && B.didScheduleLegacyUpdate) {
            var i2 = B.current;
            if (i2 !== null)
              B.didScheduleLegacyUpdate = !1, S4(i2);
          }
        } catch (GJ) {
          throw iq(J1), GJ;
        } finally {
          B.isBatchingLegacy = b1;
        }
        if (X2 !== null && typeof X2 === "object" && typeof X2.then === "function") {
          var V6 = X2, h8 = !1, l6 = {
            then: function(GJ, X$) {
              h8 = !0, V6.then(function(b9) {
                if (iq(J1), yU === 0)
                  v4(b9, GJ, X$);
                else
                  GJ(b9);
              }, function(b9) {
                iq(J1), X$(b9);
              });
            }
          };
          if (!bP && typeof Promise !== "undefined")
            Promise.resolve().then(function() {}).then(function() {
              if (!h8)
                bP = !0, g("You called act(async () => ...) without await. This could lead to unexpected testing behaviour, interleaving multiple act calls and mixing their scopes. You should - await act(async () => ...);");
            });
          return l6;
        } else {
          var Q9 = X2;
          if (iq(J1), yU === 0) {
            var F7 = B.current;
            if (F7 !== null)
              S4(F7), B.current = null;
            var S7 = {
              then: function(GJ, X$) {
                if (B.current === null)
                  B.current = [], v4(Q9, GJ, X$);
                else
                  GJ(Q9);
              }
            };
            return S7;
          } else {
            var f7 = {
              then: function(GJ, X$) {
                GJ(Q9);
              }
            };
            return f7;
          }
        }
      }
    }
    function iq(B0) {
      {
        if (B0 !== yU - 1)
          g("You seem to have overlapping act() calls, this is not supported. Be sure to await previous act() calls before making a new one. ");
        yU = B0;
      }
    }
    function v4(B0, J1, b1) {
      {
        var X2 = B.current;
        if (X2 !== null)
          try {
            S4(X2), hP(function() {
              if (X2.length === 0)
                B.current = null, J1(B0);
              else
                v4(B0, J1, b1);
            });
          } catch (i2) {
            b1(i2);
          }
        else
          J1(B0);
      }
    }
    var gU = !1;
    function S4(B0) {
      if (!gU) {
        gU = !0;
        var J1 = 0;
        try {
          for (;J1 < B0.length; J1++) {
            var b1 = B0[J1];
            do
              b1 = b1(!0);
            while (b1 !== null);
          }
          B0.length = 0;
        } catch (X2) {
          throw B0 = B0.slice(J1 + 1), X2;
        } finally {
          gU = !1;
        }
      }
    }
    var yP = fP, gP = iH, mP = Z5, dP = {
      map: G2,
      forEach: v2,
      count: P2,
      toArray: O8,
      only: n8
    };
    if (qn0.Children = dP, qn0.Component = l, qn0.Fragment = X, qn0.Profiler = Q, qn0.PureComponent = Z0, qn0.StrictMode = Y, qn0.Suspense = H, qn0.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = x, qn0.act = xP, qn0.cloneElement = gP, qn0.createContext = z6, qn0.createElement = yP, qn0.createFactory = mP, qn0.createRef = a, qn0.forwardRef = J2, qn0.isValidElement = y0, qn0.lazy = z1, qn0.memo = c0, qn0.startTransition = Sm, qn0.unstable_act = xP, qn0.useCallback = W6, qn0.useContext = g1, qn0.useDebugValue = L1, qn0.useDeferredValue = s2, qn0.useEffect = W2, qn0.useId = d0, qn0.useImperativeHandle = AZ, qn0.useInsertionEffect = z2, qn0.useLayoutEffect = p8, qn0.useMemo = v6, qn0.useReducer = d8, qn0.useRef = I1, qn0.useState = l2, qn0.useSyncExternalStore = d1, qn0.useTransition = q2, qn0.version = Z, typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== "undefined" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop === "function")
      __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error);
  })();
});

// node_modules/scheduler/cjs/scheduler.development.js
var ZY0 = SX((Fn0) => {
  (function() {
    if (typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== "undefined" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart === "function")
      __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error);
    var Z = !1, J = !1, $ = 5;
    function X(T0, o0) {
      var y0 = T0.length;
      T0.push(o0), W(T0, o0, y0);
    }
    function Y(T0) {
      return T0.length === 0 ? null : T0[0];
    }
    function Q(T0) {
      if (T0.length === 0)
        return null;
      var o0 = T0[0], y0 = T0.pop();
      if (y0 !== o0)
        T0[0] = y0, K(T0, y0, 0);
      return o0;
    }
    function W(T0, o0, y0) {
      var $1 = y0;
      while ($1 > 0) {
        var F1 = $1 - 1 >>> 1, A1 = T0[F1];
        if (G(A1, o0) > 0)
          T0[F1] = o0, T0[$1] = A1, $1 = F1;
        else
          return;
      }
    }
    function K(T0, o0, y0) {
      var $1 = y0, F1 = T0.length, A1 = F1 >>> 1;
      while ($1 < A1) {
        var P1 = ($1 + 1) * 2 - 1, S1 = T0[P1], _1 = P1 + 1, a1 = T0[_1];
        if (G(S1, o0) < 0)
          if (_1 < F1 && G(a1, S1) < 0)
            T0[$1] = a1, T0[_1] = o0, $1 = _1;
          else
            T0[$1] = S1, T0[P1] = o0, $1 = P1;
        else if (_1 < F1 && G(a1, o0) < 0)
          T0[$1] = a1, T0[_1] = o0, $1 = _1;
        else
          return;
      }
    }
    function G(T0, o0) {
      var y0 = T0.sortIndex - o0.sortIndex;
      return y0 !== 0 ? y0 : T0.id - o0.id;
    }
    var H = 1, N = 2, q = 3, U = 4, F = 5;
    function E(T0, o0) {}
    var R = typeof performance === "object" && typeof performance.now === "function";
    if (R) {
      var z = performance;
      Fn0.unstable_now = function() {
        return z.now();
      };
    } else {
      var D = Date, A = D.now();
      Fn0.unstable_now = function() {
        return D.now() - A;
      };
    }
    var B = 1073741823, T = -1, w = 250, V = 5000, P = 1e4, I = B, S = [], f = [], v = 1, h = null, x = q, b = !1, g = !1, m = !1, i = typeof setTimeout === "function" ? setTimeout : null, r = typeof clearTimeout === "function" ? clearTimeout : null, Y0 = typeof setImmediate !== "undefined" ? setImmediate : null, c = typeof navigator !== "undefined" && navigator.scheduling !== void 0 && navigator.scheduling.isInputPending !== void 0 ? navigator.scheduling.isInputPending.bind(navigator.scheduling) : null;
    function n(T0) {
      var o0 = Y(f);
      while (o0 !== null) {
        if (o0.callback === null)
          Q(f);
        else if (o0.startTime <= T0)
          Q(f), o0.sortIndex = o0.expirationTime, X(S, o0);
        else
          return;
        o0 = Y(f);
      }
    }
    function l(T0) {
      if (m = !1, n(T0), !g)
        if (Y(S) !== null)
          g = !0, x0(u);
        else {
          var o0 = Y(f);
          if (o0 !== null)
            m0(l, o0.startTime - T0);
        }
    }
    function u(T0, o0) {
      if (g = !1, m)
        m = !1, e0();
      b = !0;
      var y0 = x;
      try {
        if (J)
          try {
            return G0(T0, o0);
          } catch (F1) {
            if (h !== null) {
              var $1 = Fn0.unstable_now();
              E(h, $1), h.isQueued = !1;
            }
            throw F1;
          }
        else
          return G0(T0, o0);
      } finally {
        h = null, x = y0, b = !1;
      }
    }
    function G0(T0, o0) {
      var y0 = o0;
      n(y0), h = Y(S);
      while (h !== null && !Z) {
        if (h.expirationTime > y0 && (!T0 || A0()))
          break;
        var $1 = h.callback;
        if (typeof $1 === "function") {
          h.callback = null, x = h.priorityLevel;
          var F1 = h.expirationTime <= y0, A1 = $1(F1);
          if (y0 = Fn0.unstable_now(), typeof A1 === "function")
            h.callback = A1;
          else if (h === Y(S))
            Q(S);
          n(y0);
        } else
          Q(S);
        h = Y(S);
      }
      if (h !== null)
        return !0;
      else {
        var P1 = Y(f);
        if (P1 !== null)
          m0(l, P1.startTime - y0);
        return !1;
      }
    }
    function F0(T0, o0) {
      switch (T0) {
        case H:
        case N:
        case q:
        case U:
        case F:
          break;
        default:
          T0 = q;
      }
      var y0 = x;
      x = T0;
      try {
        return o0();
      } finally {
        x = y0;
      }
    }
    function t(T0) {
      var o0;
      switch (x) {
        case H:
        case N:
        case q:
          o0 = q;
          break;
        default:
          o0 = x;
          break;
      }
      var y0 = x;
      x = o0;
      try {
        return T0();
      } finally {
        x = y0;
      }
    }
    function Z0(T0) {
      var o0 = x;
      return function() {
        var y0 = x;
        x = o0;
        try {
          return T0.apply(this, arguments);
        } finally {
          x = y0;
        }
      };
    }
    function U0(T0, o0, y0) {
      var $1 = Fn0.unstable_now(), F1;
      if (typeof y0 === "object" && y0 !== null) {
        var A1 = y0.delay;
        if (typeof A1 === "number" && A1 > 0)
          F1 = $1 + A1;
        else
          F1 = $1;
      } else
        F1 = $1;
      var P1;
      switch (T0) {
        case H:
          P1 = T;
          break;
        case N:
          P1 = w;
          break;
        case F:
          P1 = I;
          break;
        case U:
          P1 = P;
          break;
        case q:
        default:
          P1 = V;
          break;
      }
      var S1 = F1 + P1, _1 = {
        id: v++,
        callback: o0,
        priorityLevel: T0,
        startTime: F1,
        expirationTime: S1,
        sortIndex: -1
      };
      if (F1 > $1) {
        if (_1.sortIndex = F1, X(f, _1), Y(S) === null && _1 === Y(f)) {
          if (m)
            e0();
          else
            m = !0;
          m0(l, F1 - $1);
        }
      } else if (_1.sortIndex = S1, X(S, _1), !g && !b)
        g = !0, x0(u);
      return _1;
    }
    function a() {}
    function Q0() {
      if (!g && !b)
        g = !0, x0(u);
    }
    function $0() {
      return Y(S);
    }
    function R0(T0) {
      T0.callback = null;
    }
    function X0() {
      return x;
    }
    var E0 = !1, V0 = null, u0 = -1, N0 = $, q0 = -1;
    function A0() {
      var T0 = Fn0.unstable_now() - q0;
      if (T0 < N0)
        return !1;
      return !0;
    }
    function S0() {}
    function a0(T0) {
      if (T0 < 0 || T0 > 125) {
        console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported");
        return;
      }
      if (T0 > 0)
        N0 = Math.floor(1000 / T0);
      else
        N0 = $;
    }
    var D1 = function() {
      if (V0 !== null) {
        var T0 = Fn0.unstable_now();
        q0 = T0;
        var o0 = !0, y0 = !0;
        try {
          y0 = V0(o0, T0);
        } finally {
          if (y0)
            Y1();
          else
            E0 = !1, V0 = null;
        }
      } else
        E0 = !1;
    }, Y1;
    if (typeof Y0 === "function")
      Y1 = function() {
        Y0(D1);
      };
    else if (typeof MessageChannel !== "undefined") {
      var u1 = new MessageChannel, b0 = u1.port2;
      u1.port1.onmessage = D1, Y1 = function() {
        b0.postMessage(null);
      };
    } else
      Y1 = function() {
        i(D1, 0);
      };
    function x0(T0) {
      if (V0 = T0, !E0)
        E0 = !0, Y1();
    }
    function m0(T0, o0) {
      u0 = i(function() {
        T0(Fn0.unstable_now());
      }, o0);
    }
    function e0() {
      r(u0), u0 = -1;
    }
    var p = S0, J0 = null;
    if (Fn0.unstable_IdlePriority = F, Fn0.unstable_ImmediatePriority = H, Fn0.unstable_LowPriority = U, Fn0.unstable_NormalPriority = q, Fn0.unstable_Profiling = J0, Fn0.unstable_UserBlockingPriority = N, Fn0.unstable_cancelCallback = R0, Fn0.unstable_continueExecution = Q0, Fn0.unstable_forceFrameRate = a0, Fn0.unstable_getCurrentPriorityLevel = X0, Fn0.unstable_getFirstCallbackNode = $0, Fn0.unstable_next = t, Fn0.unstable_pauseExecution = a, Fn0.unstable_requestPaint = p, Fn0.unstable_runWithPriority = F0, Fn0.unstable_scheduleCallback = U0, Fn0.unstable_shouldYield = A0, Fn0.unstable_wrapCallback = Z0, typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== "undefined" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop === "function")
      __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error);
  })();
});

// node_modules/react-dom/cjs/react-dom.development.js
var JY0 = SX((Un0) => {
  var UT = t2(J7(), 1), E7 = t2(ZY0(), 1);
  (function() {
    if (typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== "undefined" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart === "function")
      __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error);
    var Z = UT.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED, J = !1;
    function $(L) {
      J = L;
    }
    function X(L) {
      if (!J) {
        for (var O = arguments.length, _ = new Array(O > 1 ? O - 1 : 0), k = 1;k < O; k++)
          _[k - 1] = arguments[k];
        Q("warn", L, _);
      }
    }
    function Y(L) {
      if (!J) {
        for (var O = arguments.length, _ = new Array(O > 1 ? O - 1 : 0), k = 1;k < O; k++)
          _[k - 1] = arguments[k];
        Q("error", L, _);
      }
    }
    function Q(L, O, _) {
      {
        var k = Z.ReactDebugCurrentFrame, y = k.getStackAddendum();
        if (y !== "")
          O += "%s", _ = _.concat([y]);
        var d = _.map(function(o) {
          return String(o);
        });
        d.unshift("Warning: " + O), Function.prototype.apply.call(console[L], console, d);
      }
    }
    var W = 0, K = 1, G = 2, H = 3, N = 4, q = 5, U = 6, F = 7, E = 8, R = 9, z = 10, D = 11, A = 12, B = 13, T = 14, w = 15, V = 16, P = 17, I = 18, S = 19, f = 21, v = 22, h = 23, x = 24, b = 25, g = !0, m = !1, i = !1, r = !1, Y0 = !1, c = !0, n = !1, l = !0, u = !0, G0 = !0, F0 = !0, t = /* @__PURE__ */ new Set, Z0 = {}, U0 = {};
    function a(L, O) {
      Q0(L, O), Q0(L + "Capture", O);
    }
    function Q0(L, O) {
      if (Z0[L])
        Y("EventRegistry: More than one plugin attempted to publish the same registration name, `%s`.", L);
      Z0[L] = O;
      {
        var _ = L.toLowerCase();
        if (U0[_] = L, L === "onDoubleClick")
          U0.ondblclick = L;
      }
      for (var k = 0;k < O.length; k++)
        t.add(O[k]);
    }
    var $0 = typeof window !== "undefined" && typeof window.document !== "undefined" && typeof window.document.createElement !== "undefined", R0 = Object.prototype.hasOwnProperty;
    function X0(L) {
      {
        var O = typeof Symbol === "function" && Symbol.toStringTag, _ = O && L[Symbol.toStringTag] || L.constructor.name || "Object";
        return _;
      }
    }
    function E0(L) {
      try {
        return V0(L), !1;
      } catch (O) {
        return !0;
      }
    }
    function V0(L) {
      return "" + L;
    }
    function u0(L, O) {
      if (E0(L))
        return Y("The provided `%s` attribute is an unsupported type %s. This value must be coerced to a string before before using it here.", O, X0(L)), V0(L);
    }
    function N0(L) {
      if (E0(L))
        return Y("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.", X0(L)), V0(L);
    }
    function q0(L, O) {
      if (E0(L))
        return Y("The provided `%s` prop is an unsupported type %s. This value must be coerced to a string before before using it here.", O, X0(L)), V0(L);
    }
    function A0(L, O) {
      if (E0(L))
        return Y("The provided `%s` CSS property is an unsupported type %s. This value must be coerced to a string before before using it here.", O, X0(L)), V0(L);
    }
    function S0(L) {
      if (E0(L))
        return Y("The provided HTML markup uses a value of unsupported type %s. This value must be coerced to a string before before using it here.", X0(L)), V0(L);
    }
    function a0(L) {
      if (E0(L))
        return Y("Form field values (value, checked, defaultValue, or defaultChecked props) must be strings, not %s. This value must be coerced to a string before before using it here.", X0(L)), V0(L);
    }
    var D1 = 0, Y1 = 1, u1 = 2, b0 = 3, x0 = 4, m0 = 5, e0 = 6, p = ":A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD", J0 = p + "\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040", T0 = new RegExp("^[" + p + "][" + J0 + "]*$"), o0 = {}, y0 = {};
    function $1(L) {
      if (R0.call(y0, L))
        return !0;
      if (R0.call(o0, L))
        return !1;
      if (T0.test(L))
        return y0[L] = !0, !0;
      return o0[L] = !0, Y("Invalid attribute name: `%s`", L), !1;
    }
    function F1(L, O, _) {
      if (O !== null)
        return O.type === D1;
      if (_)
        return !1;
      if (L.length > 2 && (L[0] === "o" || L[0] === "O") && (L[1] === "n" || L[1] === "N"))
        return !0;
      return !1;
    }
    function A1(L, O, _, k) {
      if (_ !== null && _.type === D1)
        return !1;
      switch (typeof O) {
        case "function":
        case "symbol":
          return !0;
        case "boolean": {
          if (k)
            return !1;
          if (_ !== null)
            return !_.acceptsBooleans;
          else {
            var y = L.toLowerCase().slice(0, 5);
            return y !== "data-" && y !== "aria-";
          }
        }
        default:
          return !1;
      }
    }
    function P1(L, O, _, k) {
      if (O === null || typeof O === "undefined")
        return !0;
      if (A1(L, O, _, k))
        return !0;
      if (k)
        return !1;
      if (_ !== null)
        switch (_.type) {
          case b0:
            return !O;
          case x0:
            return O === !1;
          case m0:
            return isNaN(O);
          case e0:
            return isNaN(O) || O < 1;
        }
      return !1;
    }
    function S1(L) {
      return a1.hasOwnProperty(L) ? a1[L] : null;
    }
    function _1(L, O, _, k, y, d, o) {
      this.acceptsBooleans = O === u1 || O === b0 || O === x0, this.attributeName = k, this.attributeNamespace = y, this.mustUseProperty = _, this.propertyName = L, this.type = O, this.sanitizeURL = d, this.removeEmptyString = o;
    }
    var a1 = {}, U2 = [
      "children",
      "dangerouslySetInnerHTML",
      "defaultValue",
      "defaultChecked",
      "innerHTML",
      "suppressContentEditableWarning",
      "suppressHydrationWarning",
      "style"
    ];
    U2.forEach(function(L) {
      a1[L] = new _1(L, D1, !1, L, null, !1, !1);
    }), [["acceptCharset", "accept-charset"], ["className", "class"], ["htmlFor", "for"], ["httpEquiv", "http-equiv"]].forEach(function(L) {
      var O = L[0], _ = L[1];
      a1[O] = new _1(O, Y1, !1, _, null, !1, !1);
    }), ["contentEditable", "draggable", "spellCheck", "value"].forEach(function(L) {
      a1[L] = new _1(L, u1, !1, L.toLowerCase(), null, !1, !1);
    }), ["autoReverse", "externalResourcesRequired", "focusable", "preserveAlpha"].forEach(function(L) {
      a1[L] = new _1(L, u1, !1, L, null, !1, !1);
    }), [
      "allowFullScreen",
      "async",
      "autoFocus",
      "autoPlay",
      "controls",
      "default",
      "defer",
      "disabled",
      "disablePictureInPicture",
      "disableRemotePlayback",
      "formNoValidate",
      "hidden",
      "loop",
      "noModule",
      "noValidate",
      "open",
      "playsInline",
      "readOnly",
      "required",
      "reversed",
      "scoped",
      "seamless",
      "itemScope"
    ].forEach(function(L) {
      a1[L] = new _1(L, b0, !1, L.toLowerCase(), null, !1, !1);
    }), [
      "checked",
      "multiple",
      "muted",
      "selected"
    ].forEach(function(L) {
      a1[L] = new _1(L, b0, !0, L, null, !1, !1);
    }), [
      "capture",
      "download"
    ].forEach(function(L) {
      a1[L] = new _1(L, x0, !1, L, null, !1, !1);
    }), [
      "cols",
      "rows",
      "size",
      "span"
    ].forEach(function(L) {
      a1[L] = new _1(L, e0, !1, L, null, !1, !1);
    }), ["rowSpan", "start"].forEach(function(L) {
      a1[L] = new _1(L, m0, !1, L.toLowerCase(), null, !1, !1);
    });
    var G2 = /[\-\:]([a-z])/g, P2 = function(L) {
      return L[1].toUpperCase();
    };
    [
      "accent-height",
      "alignment-baseline",
      "arabic-form",
      "baseline-shift",
      "cap-height",
      "clip-path",
      "clip-rule",
      "color-interpolation",
      "color-interpolation-filters",
      "color-profile",
      "color-rendering",
      "dominant-baseline",
      "enable-background",
      "fill-opacity",
      "fill-rule",
      "flood-color",
      "flood-opacity",
      "font-family",
      "font-size",
      "font-size-adjust",
      "font-stretch",
      "font-style",
      "font-variant",
      "font-weight",
      "glyph-name",
      "glyph-orientation-horizontal",
      "glyph-orientation-vertical",
      "horiz-adv-x",
      "horiz-origin-x",
      "image-rendering",
      "letter-spacing",
      "lighting-color",
      "marker-end",
      "marker-mid",
      "marker-start",
      "overline-position",
      "overline-thickness",
      "paint-order",
      "panose-1",
      "pointer-events",
      "rendering-intent",
      "shape-rendering",
      "stop-color",
      "stop-opacity",
      "strikethrough-position",
      "strikethrough-thickness",
      "stroke-dasharray",
      "stroke-dashoffset",
      "stroke-linecap",
      "stroke-linejoin",
      "stroke-miterlimit",
      "stroke-opacity",
      "stroke-width",
      "text-anchor",
      "text-decoration",
      "text-rendering",
      "underline-position",
      "underline-thickness",
      "unicode-bidi",
      "unicode-range",
      "units-per-em",
      "v-alphabetic",
      "v-hanging",
      "v-ideographic",
      "v-mathematical",
      "vector-effect",
      "vert-adv-y",
      "vert-origin-x",
      "vert-origin-y",
      "word-spacing",
      "writing-mode",
      "xmlns:xlink",
      "x-height"
    ].forEach(function(L) {
      var O = L.replace(G2, P2);
      a1[O] = new _1(O, Y1, !1, L, null, !1, !1);
    }), [
      "xlink:actuate",
      "xlink:arcrole",
      "xlink:role",
      "xlink:show",
      "xlink:title",
      "xlink:type"
    ].forEach(function(L) {
      var O = L.replace(G2, P2);
      a1[O] = new _1(O, Y1, !1, L, "http://www.w3.org/1999/xlink", !1, !1);
    }), [
      "xml:base",
      "xml:lang",
      "xml:space"
    ].forEach(function(L) {
      var O = L.replace(G2, P2);
      a1[O] = new _1(O, Y1, !1, L, "http://www.w3.org/XML/1998/namespace", !1, !1);
    }), ["tabIndex", "crossOrigin"].forEach(function(L) {
      a1[L] = new _1(L, Y1, !1, L.toLowerCase(), null, !1, !1);
    });
    var v2 = "xlinkHref";
    a1[v2] = new _1("xlinkHref", Y1, !1, "xlink:href", "http://www.w3.org/1999/xlink", !0, !1), ["src", "href", "action", "formAction"].forEach(function(L) {
      a1[L] = new _1(L, Y1, !1, L.toLowerCase(), null, !0, !0);
    });
    var O8 = /^[\u0000-\u001F ]*j[\r\n\t]*a[\r\n\t]*v[\r\n\t]*a[\r\n\t]*s[\r\n\t]*c[\r\n\t]*r[\r\n\t]*i[\r\n\t]*p[\r\n\t]*t[\r\n\t]*\:/i, n8 = !1;
    function z6(L) {
      if (!n8 && O8.test(L))
        n8 = !0, Y("A future version of React will block javascript: URLs as a security precaution. Use event handlers instead if you can. If you need to generate unsafe HTML try using dangerouslySetInnerHTML instead. React was passed %s.", JSON.stringify(L));
    }
    function L8(L, O, _, k) {
      if (k.mustUseProperty) {
        var y = k.propertyName;
        return L[y];
      } else {
        if (u0(_, O), k.sanitizeURL)
          z6("" + _);
        var d = k.attributeName, o = null;
        if (k.type === x0) {
          if (L.hasAttribute(d)) {
            var H0 = L.getAttribute(d);
            if (H0 === "")
              return !0;
            if (P1(O, _, k, !1))
              return H0;
            if (H0 === "" + _)
              return _;
            return H0;
          }
        } else if (L.hasAttribute(d)) {
          if (P1(O, _, k, !1))
            return L.getAttribute(d);
          if (k.type === b0)
            return _;
          o = L.getAttribute(d);
        }
        if (P1(O, _, k, !1))
          return o === null ? _ : o;
        else if (o === "" + _)
          return _;
        else
          return o;
      }
    }
    function R8(L, O, _, k) {
      {
        if (!$1(O))
          return;
        if (!L.hasAttribute(O))
          return _ === void 0 ? void 0 : null;
        var y = L.getAttribute(O);
        if (u0(_, O), y === "" + _)
          return _;
        return y;
      }
    }
    function w0(L, O, _, k) {
      var y = S1(O);
      if (F1(O, y, k))
        return;
      if (P1(O, _, y, k))
        _ = null;
      if (k || y === null) {
        if ($1(O)) {
          var d = O;
          if (_ === null)
            L.removeAttribute(d);
          else
            u0(_, O), L.setAttribute(d, "" + _);
        }
        return;
      }
      var o = y.mustUseProperty;
      if (o) {
        var H0 = y.propertyName;
        if (_ === null) {
          var O0 = y.type;
          L[H0] = O0 === b0 ? !1 : "";
        } else
          L[H0] = _;
        return;
      }
      var { attributeName: I0, attributeNamespace: g0 } = y;
      if (_ === null)
        L.removeAttribute(I0);
      else {
        var R1 = y.type, U1;
        if (R1 === b0 || R1 === x0 && _ === !0)
          U1 = "";
        else if (u0(_, I0), U1 = "" + _, y.sanitizeURL)
          z6(U1.toString());
        if (g0)
          L.setAttributeNS(g0, I0, U1);
        else
          L.setAttribute(I0, U1);
      }
    }
    var P0 = Symbol.for("react.element"), l0 = Symbol.for("react.portal"), z1 = Symbol.for("react.fragment"), J2 = Symbol.for("react.strict_mode"), N2 = Symbol.for("react.profiler"), X8 = Symbol.for("react.provider"), c0 = Symbol.for("react.context"), M1 = Symbol.for("react.forward_ref"), g1 = Symbol.for("react.suspense"), l2 = Symbol.for("react.suspense_list"), d8 = Symbol.for("react.memo"), I1 = Symbol.for("react.lazy"), W2 = Symbol.for("react.scope"), z2 = Symbol.for("react.debug_trace_mode"), p8 = Symbol.for("react.offscreen"), W6 = Symbol.for("react.legacy_hidden"), v6 = Symbol.for("react.cache"), AZ = Symbol.for("react.tracing_marker"), L1 = Symbol.iterator, q2 = "@@iterator";
    function s2(L) {
      if (L === null || typeof L !== "object")
        return null;
      var O = L1 && L[L1] || L[q2];
      if (typeof O === "function")
        return O;
      return null;
    }
    var d0 = Object.assign, d1 = 0, A2, B8, Z6, t6, D2, vZ, c6;
    function HZ() {}
    HZ.__reactDisabledLog = !0;
    function pY() {
      {
        if (d1 === 0) {
          A2 = console.log, B8 = console.info, Z6 = console.warn, t6 = console.error, D2 = console.group, vZ = console.groupCollapsed, c6 = console.groupEnd;
          var L = {
            configurable: !0,
            enumerable: !0,
            value: HZ,
            writable: !0
          };
          Object.defineProperties(console, {
            info: L,
            log: L,
            warn: L,
            error: L,
            group: L,
            groupCollapsed: L,
            groupEnd: L
          });
        }
        d1++;
      }
    }
    function GW() {
      {
        if (d1--, d1 === 0) {
          var L = {
            configurable: !0,
            enumerable: !0,
            writable: !0
          };
          Object.defineProperties(console, {
            log: d0({}, L, {
              value: A2
            }),
            info: d0({}, L, {
              value: B8
            }),
            warn: d0({}, L, {
              value: Z6
            }),
            error: d0({}, L, {
              value: t6
            }),
            group: d0({}, L, {
              value: D2
            }),
            groupCollapsed: d0({}, L, {
              value: vZ
            }),
            groupEnd: d0({}, L, {
              value: c6
            })
          });
        }
        if (d1 < 0)
          Y("disabledDepth fell below zero. This is a bug in React. Please file an issue.");
      }
    }
    var lH = Z.ReactCurrentDispatcher, MJ;
    function q7(L, O, _) {
      {
        if (MJ === void 0)
          try {
            throw Error();
          } catch (y) {
            var k = y.stack.trim().match(/\n( *(at )?)/);
            MJ = k && k[1] || "";
          }
        return `
` + MJ + L;
      }
    }
    var BX = !1, wX;
    {
      var v7 = typeof WeakMap === "function" ? WeakMap : Map;
      wX = new v7;
    }
    function v0(L, O) {
      if (!L || BX)
        return "";
      {
        var _ = wX.get(L);
        if (_ !== void 0)
          return _;
      }
      var k;
      BX = !0;
      var y = Error.prepareStackTrace;
      Error.prepareStackTrace = void 0;
      var d;
      d = lH.current, lH.current = null, pY();
      try {
        if (O) {
          var o = function() {
            throw Error();
          };
          if (Object.defineProperty(o.prototype, "props", {
            set: function() {
              throw Error();
            }
          }), typeof Reflect === "object" && Reflect.construct) {
            try {
              Reflect.construct(o, []);
            } catch (y1) {
              k = y1;
            }
            Reflect.construct(L, [], o);
          } else {
            try {
              o.call();
            } catch (y1) {
              k = y1;
            }
            L.call(o.prototype);
          }
        } else {
          try {
            throw Error();
          } catch (y1) {
            k = y1;
          }
          L();
        }
      } catch (y1) {
        if (y1 && k && typeof y1.stack === "string") {
          var H0 = y1.stack.split(`
`), O0 = k.stack.split(`
`), I0 = H0.length - 1, g0 = O0.length - 1;
          while (I0 >= 1 && g0 >= 0 && H0[I0] !== O0[g0])
            g0--;
          for (;I0 >= 1 && g0 >= 0; I0--, g0--)
            if (H0[I0] !== O0[g0]) {
              if (I0 !== 1 || g0 !== 1)
                do
                  if (I0--, g0--, g0 < 0 || H0[I0] !== O0[g0]) {
                    var R1 = `
` + H0[I0].replace(" at new ", " at ");
                    if (L.displayName && R1.includes("<anonymous>"))
                      R1 = R1.replace("<anonymous>", L.displayName);
                    if (typeof L === "function")
                      wX.set(L, R1);
                    return R1;
                  }
                while (I0 >= 1 && g0 >= 0);
              break;
            }
        }
      } finally {
        BX = !1, lH.current = d, GW(), Error.prepareStackTrace = y;
      }
      var U1 = L ? L.displayName || L.name : "", x1 = U1 ? q7(U1) : "";
      if (typeof L === "function")
        wX.set(L, x1);
      return x1;
    }
    function E1(L, O, _) {
      return v0(L, !0);
    }
    function c1(L, O, _) {
      return v0(L, !1);
    }
    function L2(L) {
      var O = L.prototype;
      return !!(O && O.isReactComponent);
    }
    function N8(L, O, _) {
      if (L == null)
        return "";
      if (typeof L === "function")
        return v0(L, L2(L));
      if (typeof L === "string")
        return q7(L);
      switch (L) {
        case g1:
          return q7("Suspense");
        case l2:
          return q7("SuspenseList");
      }
      if (typeof L === "object")
        switch (L.$$typeof) {
          case M1:
            return c1(L.render);
          case d8:
            return N8(L.type, O, _);
          case I1: {
            var k = L, y = k._payload, d = k._init;
            try {
              return N8(d(y), O, _);
            } catch (o) {}
          }
        }
      return "";
    }
    function yZ(L) {
      var O = L._debugOwner ? L._debugOwner.type : null, _ = L._debugSource;
      switch (L.tag) {
        case q:
          return q7(L.type);
        case V:
          return q7("Lazy");
        case B:
          return q7("Suspense");
        case S:
          return q7("SuspenseList");
        case W:
        case G:
        case w:
          return c1(L.type);
        case D:
          return c1(L.type.render);
        case K:
          return E1(L.type);
        default:
          return "";
      }
    }
    function _6(L) {
      try {
        var O = "", _ = L;
        do
          O += yZ(_), _ = _.return;
        while (_);
        return O;
      } catch (k) {
        return `
Error generating stack: ` + k.message + `
` + k.stack;
      }
    }
    function JZ(L, O, _) {
      var k = L.displayName;
      if (k)
        return k;
      var y = O.displayName || O.name || "";
      return y !== "" ? _ + "(" + y + ")" : _;
    }
    function gJ(L) {
      return L.displayName || "Context";
    }
    function y6(L) {
      if (L == null)
        return null;
      if (typeof L.tag === "number")
        Y("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue.");
      if (typeof L === "function")
        return L.displayName || L.name || null;
      if (typeof L === "string")
        return L;
      switch (L) {
        case z1:
          return "Fragment";
        case l0:
          return "Portal";
        case N2:
          return "Profiler";
        case J2:
          return "StrictMode";
        case g1:
          return "Suspense";
        case l2:
          return "SuspenseList";
      }
      if (typeof L === "object")
        switch (L.$$typeof) {
          case c0:
            var O = L;
            return gJ(O) + ".Consumer";
          case X8:
            var _ = L;
            return gJ(_._context) + ".Provider";
          case M1:
            return JZ(L, L.render, "ForwardRef");
          case d8:
            var k = L.displayName || null;
            if (k !== null)
              return k;
            return y6(L.type) || "Memo";
          case I1: {
            var y = L, d = y._payload, o = y._init;
            try {
              return y6(o(d));
            } catch (H0) {
              return null;
            }
          }
        }
      return null;
    }
    function uY(L, O, _) {
      var k = O.displayName || O.name || "";
      return L.displayName || (k !== "" ? _ + "(" + k + ")" : _);
    }
    function jX(L) {
      return L.displayName || "Context";
    }
    function D6(L) {
      var { tag: O, type: _ } = L;
      switch (O) {
        case x:
          return "Cache";
        case R:
          var k = _;
          return jX(k) + ".Consumer";
        case z:
          var y = _;
          return jX(y._context) + ".Provider";
        case I:
          return "DehydratedFragment";
        case D:
          return uY(_, _.render, "ForwardRef");
        case F:
          return "Fragment";
        case q:
          return _;
        case N:
          return "Portal";
        case H:
          return "Root";
        case U:
          return "Text";
        case V:
          return y6(_);
        case E:
          if (_ === J2)
            return "StrictMode";
          return "Mode";
        case v:
          return "Offscreen";
        case A:
          return "Profiler";
        case f:
          return "Scope";
        case B:
          return "Suspense";
        case S:
          return "SuspenseList";
        case b:
          return "TracingMarker";
        case K:
        case W:
        case P:
        case G:
        case T:
        case w:
          if (typeof _ === "function")
            return _.displayName || _.name || null;
          if (typeof _ === "string")
            return _;
          break;
      }
      return null;
    }
    var HW = Z.ReactDebugCurrentFrame, sX = null, nH = !1;
    function TG() {
      {
        if (sX === null)
          return null;
        var L = sX._debugOwner;
        if (L !== null && typeof L !== "undefined")
          return D6(L);
      }
      return null;
    }
    function SP() {
      {
        if (sX === null)
          return "";
        return _6(sX);
      }
    }
    function aX() {
      HW.getCurrentStack = null, sX = null, nH = !1;
    }
    function mJ(L) {
      HW.getCurrentStack = L === null ? null : SP, sX = L, nH = !1;
    }
    function fP() {
      return sX;
    }
    function n5(L) {
      nH = L;
    }
    function Z5(L) {
      return "" + L;
    }
    function iH(L) {
      switch (typeof L) {
        case "boolean":
        case "number":
        case "string":
        case "undefined":
          return L;
        case "object":
          return a0(L), L;
        default:
          return "";
      }
    }
    var Sm = {
      button: !0,
      checkbox: !0,
      image: !0,
      hidden: !0,
      radio: !0,
      reset: !0,
      submit: !0
    };
    function k4(L, O) {
      {
        if (!(Sm[O.type] || O.onChange || O.onInput || O.readOnly || O.disabled || O.value == null))
          Y("You provided a `value` prop to a form field without an `onChange` handler. This will render a read-only field. If the field should be mutable use `defaultValue`. Otherwise, set either `onChange` or `readOnly`.");
        if (!(O.onChange || O.readOnly || O.disabled || O.checked == null))
          Y("You provided a `checked` prop to a form field without an `onChange` handler. This will render a read-only field. If the field should be mutable use `defaultChecked`. Otherwise, set either `onChange` or `readOnly`.");
      }
    }
    function cE(L) {
      var { type: O, nodeName: _ } = L;
      return _ && _.toLowerCase() === "input" && (O === "checkbox" || O === "radio");
    }
    function hP(L) {
      return L._valueTracker;
    }
    function yU(L) {
      L._valueTracker = null;
    }
    function bP(L) {
      var O = "";
      if (!L)
        return O;
      if (cE(L))
        O = L.checked ? "true" : "false";
      else
        O = L.value;
      return O;
    }
    function xP(L) {
      var O = cE(L) ? "checked" : "value", _ = Object.getOwnPropertyDescriptor(L.constructor.prototype, O);
      a0(L[O]);
      var k = "" + L[O];
      if (L.hasOwnProperty(O) || typeof _ === "undefined" || typeof _.get !== "function" || typeof _.set !== "function")
        return;
      var { get: y, set: d } = _;
      Object.defineProperty(L, O, {
        configurable: !0,
        get: function() {
          return y.call(this);
        },
        set: function(H0) {
          a0(H0), k = "" + H0, d.call(this, H0);
        }
      }), Object.defineProperty(L, O, {
        enumerable: _.enumerable
      });
      var o = {
        getValue: function() {
          return k;
        },
        setValue: function(H0) {
          a0(H0), k = "" + H0;
        },
        stopTracking: function() {
          yU(L), delete L[O];
        }
      };
      return o;
    }
    function iq(L) {
      if (hP(L))
        return;
      L._valueTracker = xP(L);
    }
    function v4(L) {
      if (!L)
        return !1;
      var O = hP(L);
      if (!O)
        return !0;
      var _ = O.getValue(), k = bP(L);
      if (k !== _)
        return O.setValue(k), !0;
      return !1;
    }
    function gU(L) {
      if (L = L || (typeof document !== "undefined" ? document : void 0), typeof L === "undefined")
        return null;
      try {
        return L.activeElement || L.body;
      } catch (O) {
        return L.body;
      }
    }
    var S4 = !1, yP = !1, gP = !1, mP = !1;
    function dP(L) {
      var O = L.type === "checkbox" || L.type === "radio";
      return O ? L.checked != null : L.value != null;
    }
    function B0(L, O) {
      var _ = L, k = O.checked, y = d0({}, O, {
        defaultChecked: void 0,
        defaultValue: void 0,
        value: void 0,
        checked: k != null ? k : _._wrapperState.initialChecked
      });
      return y;
    }
    function J1(L, O) {
      {
        if (k4("input", O), O.checked !== void 0 && O.defaultChecked !== void 0 && !yP)
          Y("%s contains an input of type %s with both checked and defaultChecked props. Input elements must be either controlled or uncontrolled (specify either the checked prop, or the defaultChecked prop, but not both). Decide between using a controlled or uncontrolled input element and remove one of these props. More info: https://reactjs.org/link/controlled-components", TG() || "A component", O.type), yP = !0;
        if (O.value !== void 0 && O.defaultValue !== void 0 && !S4)
          Y("%s contains an input of type %s with both value and defaultValue props. Input elements must be either controlled or uncontrolled (specify either the value prop, or the defaultValue prop, but not both). Decide between using a controlled or uncontrolled input element and remove one of these props. More info: https://reactjs.org/link/controlled-components", TG() || "A component", O.type), S4 = !0;
      }
      var _ = L, k = O.defaultValue == null ? "" : O.defaultValue;
      _._wrapperState = {
        initialChecked: O.checked != null ? O.checked : O.defaultChecked,
        initialValue: iH(O.value != null ? O.value : k),
        controlled: dP(O)
      };
    }
    function b1(L, O) {
      var _ = L, k = O.checked;
      if (k != null)
        w0(_, "checked", k, !1);
    }
    function X2(L, O) {
      var _ = L;
      {
        var k = dP(O);
        if (!_._wrapperState.controlled && k && !mP)
          Y("A component is changing an uncontrolled input to be controlled. This is likely caused by the value changing from undefined to a defined value, which should not happen. Decide between using a controlled or uncontrolled input element for the lifetime of the component. More info: https://reactjs.org/link/controlled-components"), mP = !0;
        if (_._wrapperState.controlled && !k && !gP)
          Y("A component is changing a controlled input to be uncontrolled. This is likely caused by the value changing from a defined to undefined, which should not happen. Decide between using a controlled or uncontrolled input element for the lifetime of the component. More info: https://reactjs.org/link/controlled-components"), gP = !0;
      }
      b1(L, O);
      var y = iH(O.value), d = O.type;
      if (y != null) {
        if (d === "number") {
          if (y === 0 && _.value === "" || _.value != y)
            _.value = Z5(y);
        } else if (_.value !== Z5(y))
          _.value = Z5(y);
      } else if (d === "submit" || d === "reset") {
        _.removeAttribute("value");
        return;
      }
      if (O.hasOwnProperty("value"))
        l6(_, O.type, y);
      else if (O.hasOwnProperty("defaultValue"))
        l6(_, O.type, iH(O.defaultValue));
      if (O.checked == null && O.defaultChecked != null)
        _.defaultChecked = !!O.defaultChecked;
    }
    function i2(L, O, _) {
      var k = L;
      if (O.hasOwnProperty("value") || O.hasOwnProperty("defaultValue")) {
        var y = O.type, d = y === "submit" || y === "reset";
        if (d && (O.value === void 0 || O.value === null))
          return;
        var o = Z5(k._wrapperState.initialValue);
        if (!_) {
          if (o !== k.value)
            k.value = o;
        }
        k.defaultValue = o;
      }
      var H0 = k.name;
      if (H0 !== "")
        k.name = "";
      if (k.defaultChecked = !k.defaultChecked, k.defaultChecked = !!k._wrapperState.initialChecked, H0 !== "")
        k.name = H0;
    }
    function V6(L, O) {
      var _ = L;
      X2(_, O), h8(_, O);
    }
    function h8(L, O) {
      var _ = O.name;
      if (O.type === "radio" && _ != null) {
        var k = L;
        while (k.parentNode)
          k = k.parentNode;
        u0(_, "name");
        var y = k.querySelectorAll("input[name=" + JSON.stringify("" + _) + '][type="radio"]');
        for (var d = 0;d < y.length; d++) {
          var o = y[d];
          if (o === L || o.form !== L.form)
            continue;
          var H0 = IC(o);
          if (!H0)
            throw new Error("ReactDOMInput: Mixing React and non-React radio inputs with the same `name` is not supported.");
          v4(o), X2(o, H0);
        }
      }
    }
    function l6(L, O, _) {
      if (O !== "number" || gU(L.ownerDocument) !== L) {
        if (_ == null)
          L.defaultValue = Z5(L._wrapperState.initialValue);
        else if (L.defaultValue !== Z5(_))
          L.defaultValue = Z5(_);
      }
    }
    var Q9 = !1, F7 = !1, S7 = !1;
    function f7(L, O) {
      {
        if (O.value == null) {
          if (typeof O.children === "object" && O.children !== null)
            UT.Children.forEach(O.children, function(_) {
              if (_ == null)
                return;
              if (typeof _ === "string" || typeof _ === "number")
                return;
              if (!F7)
                F7 = !0, Y("Cannot infer the option value of complex children. Pass a `value` prop or use a plain string as children to <option>.");
            });
          else if (O.dangerouslySetInnerHTML != null) {
            if (!S7)
              S7 = !0, Y("Pass a `value` prop if you set dangerouslyInnerHTML so React knows which value should be selected.");
          }
        }
        if (O.selected != null && !Q9)
          Y("Use the `defaultValue` or `value` props on <select> instead of setting `selected` on <option>."), Q9 = !0;
      }
    }
    function GJ(L, O) {
      if (O.value != null)
        L.setAttribute("value", Z5(iH(O.value)));
    }
    var X$ = Array.isArray;
    function b9(L) {
      return X$(L);
    }
    var lE = !1;
    function f4() {
      var L = TG();
      if (L)
        return `

Check the render method of \`` + L + "`.";
      return "";
    }
    var hw = ["value", "defaultValue"];
    function fm(L) {
      {
        k4("select", L);
        for (var O = 0;O < hw.length; O++) {
          var _ = hw[O];
          if (L[_] == null)
            continue;
          var k = b9(L[_]);
          if (L.multiple && !k)
            Y("The `%s` prop supplied to <select> must be an array if `multiple` is true.%s", _, f4());
          else if (!L.multiple && k)
            Y("The `%s` prop supplied to <select> must be a scalar value if `multiple` is false.%s", _, f4());
        }
      }
    }
    function oq(L, O, _, k) {
      var y = L.options;
      if (O) {
        var d = _, o = {};
        for (var H0 = 0;H0 < d.length; H0++)
          o["$" + d[H0]] = !0;
        for (var O0 = 0;O0 < y.length; O0++) {
          var I0 = o.hasOwnProperty("$" + y[O0].value);
          if (y[O0].selected !== I0)
            y[O0].selected = I0;
          if (I0 && k)
            y[O0].defaultSelected = !0;
        }
      } else {
        var g0 = Z5(iH(_)), R1 = null;
        for (var U1 = 0;U1 < y.length; U1++) {
          if (y[U1].value === g0) {
            if (y[U1].selected = !0, k)
              y[U1].defaultSelected = !0;
            return;
          }
          if (R1 === null && !y[U1].disabled)
            R1 = y[U1];
        }
        if (R1 !== null)
          R1.selected = !0;
      }
    }
    function bw(L, O) {
      return d0({}, O, {
        value: void 0
      });
    }
    function xw(L, O) {
      var _ = L;
      if (fm(O), _._wrapperState = {
        wasMultiple: !!O.multiple
      }, O.value !== void 0 && O.defaultValue !== void 0 && !lE)
        Y("Select elements must be either controlled or uncontrolled (specify either the value prop, or the defaultValue prop, but not both). Decide between using a controlled or uncontrolled select element and remove one of these props. More info: https://reactjs.org/link/controlled-components"), lE = !0;
    }
    function hm(L, O) {
      var _ = L;
      _.multiple = !!O.multiple;
      var k = O.value;
      if (k != null)
        oq(_, !!O.multiple, k, !1);
      else if (O.defaultValue != null)
        oq(_, !!O.multiple, O.defaultValue, !0);
    }
    function db0(L, O) {
      var _ = L, k = _._wrapperState.wasMultiple;
      _._wrapperState.wasMultiple = !!O.multiple;
      var y = O.value;
      if (y != null)
        oq(_, !!O.multiple, y, !1);
      else if (k !== !!O.multiple)
        if (O.defaultValue != null)
          oq(_, !!O.multiple, O.defaultValue, !0);
        else
          oq(_, !!O.multiple, O.multiple ? [] : "", !1);
    }
    function pb0(L, O) {
      var _ = L, k = O.value;
      if (k != null)
        oq(_, !!O.multiple, k, !1);
    }
    var lZ0 = !1;
    function bm(L, O) {
      var _ = L;
      if (O.dangerouslySetInnerHTML != null)
        throw new Error("`dangerouslySetInnerHTML` does not make sense on <textarea>.");
      var k = d0({}, O, {
        value: void 0,
        defaultValue: void 0,
        children: Z5(_._wrapperState.initialValue)
      });
      return k;
    }
    function nZ0(L, O) {
      var _ = L;
      if (k4("textarea", O), O.value !== void 0 && O.defaultValue !== void 0 && !lZ0)
        Y("%s contains a textarea with both value and defaultValue props. Textarea elements must be either controlled or uncontrolled (specify either the value prop, or the defaultValue prop, but not both). Decide between using a controlled or uncontrolled textarea and remove one of these props. More info: https://reactjs.org/link/controlled-components", TG() || "A component"), lZ0 = !0;
      var k = O.value;
      if (k == null) {
        var { children: y, defaultValue: d } = O;
        if (y != null) {
          Y("Use the `defaultValue` or `value` props instead of setting children on <textarea>.");
          {
            if (d != null)
              throw new Error("If you supply `defaultValue` on a <textarea>, do not pass children.");
            if (b9(y)) {
              if (y.length > 1)
                throw new Error("<textarea> can only have at most one child.");
              y = y[0];
            }
            d = y;
          }
        }
        if (d == null)
          d = "";
        k = d;
      }
      _._wrapperState = {
        initialValue: iH(k)
      };
    }
    function iZ0(L, O) {
      var _ = L, k = iH(O.value), y = iH(O.defaultValue);
      if (k != null) {
        var d = Z5(k);
        if (d !== _.value)
          _.value = d;
        if (O.defaultValue == null && _.defaultValue !== d)
          _.defaultValue = d;
      }
      if (y != null)
        _.defaultValue = Z5(y);
    }
    function oZ0(L, O) {
      var _ = L, k = _.textContent;
      if (k === _._wrapperState.initialValue) {
        if (k !== "" && k !== null)
          _.value = k;
      }
    }
    function ub0(L, O) {
      iZ0(L, O);
    }
    var sq = "http://www.w3.org/1999/xhtml", cb0 = "http://www.w3.org/1998/Math/MathML", xm = "http://www.w3.org/2000/svg";
    function ym(L) {
      switch (L) {
        case "svg":
          return xm;
        case "math":
          return cb0;
        default:
          return sq;
      }
    }
    function gm(L, O) {
      if (L == null || L === sq)
        return ym(O);
      if (L === xm && O === "foreignObject")
        return sq;
      return L;
    }
    var lb0 = function(L) {
      if (typeof MSApp !== "undefined" && MSApp.execUnsafeLocalFunction)
        return function(O, _, k, y) {
          MSApp.execUnsafeLocalFunction(function() {
            return L(O, _, k, y);
          });
        };
      else
        return L;
    }, pP, sZ0 = lb0(function(L, O) {
      if (L.namespaceURI === xm) {
        if (!("innerHTML" in L)) {
          pP = pP || document.createElement("div"), pP.innerHTML = "<svg>" + O.valueOf().toString() + "</svg>";
          var _ = pP.firstChild;
          while (L.firstChild)
            L.removeChild(L.firstChild);
          while (_.firstChild)
            L.appendChild(_.firstChild);
          return;
        }
      }
      L.innerHTML = O;
    }), J5 = 1, aq = 3, p$ = 8, rq = 9, mm = 11, uP = function(L, O) {
      if (O) {
        var _ = L.firstChild;
        if (_ && _ === L.lastChild && _.nodeType === aq) {
          _.nodeValue = O;
          return;
        }
      }
      L.textContent = O;
    }, nb0 = {
      animation: ["animationDelay", "animationDirection", "animationDuration", "animationFillMode", "animationIterationCount", "animationName", "animationPlayState", "animationTimingFunction"],
      background: ["backgroundAttachment", "backgroundClip", "backgroundColor", "backgroundImage", "backgroundOrigin", "backgroundPositionX", "backgroundPositionY", "backgroundRepeat", "backgroundSize"],
      backgroundPosition: ["backgroundPositionX", "backgroundPositionY"],
      border: ["borderBottomColor", "borderBottomStyle", "borderBottomWidth", "borderImageOutset", "borderImageRepeat", "borderImageSlice", "borderImageSource", "borderImageWidth", "borderLeftColor", "borderLeftStyle", "borderLeftWidth", "borderRightColor", "borderRightStyle", "borderRightWidth", "borderTopColor", "borderTopStyle", "borderTopWidth"],
      borderBlockEnd: ["borderBlockEndColor", "borderBlockEndStyle", "borderBlockEndWidth"],
      borderBlockStart: ["borderBlockStartColor", "borderBlockStartStyle", "borderBlockStartWidth"],
      borderBottom: ["borderBottomColor", "borderBottomStyle", "borderBottomWidth"],
      borderColor: ["borderBottomColor", "borderLeftColor", "borderRightColor", "borderTopColor"],
      borderImage: ["borderImageOutset", "borderImageRepeat", "borderImageSlice", "borderImageSource", "borderImageWidth"],
      borderInlineEnd: ["borderInlineEndColor", "borderInlineEndStyle", "borderInlineEndWidth"],
      borderInlineStart: ["borderInlineStartColor", "borderInlineStartStyle", "borderInlineStartWidth"],
      borderLeft: ["borderLeftColor", "borderLeftStyle", "borderLeftWidth"],
      borderRadius: ["borderBottomLeftRadius", "borderBottomRightRadius", "borderTopLeftRadius", "borderTopRightRadius"],
      borderRight: ["borderRightColor", "borderRightStyle", "borderRightWidth"],
      borderStyle: ["borderBottomStyle", "borderLeftStyle", "borderRightStyle", "borderTopStyle"],
      borderTop: ["borderTopColor", "borderTopStyle", "borderTopWidth"],
      borderWidth: ["borderBottomWidth", "borderLeftWidth", "borderRightWidth", "borderTopWidth"],
      columnRule: ["columnRuleColor", "columnRuleStyle", "columnRuleWidth"],
      columns: ["columnCount", "columnWidth"],
      flex: ["flexBasis", "flexGrow", "flexShrink"],
      flexFlow: ["flexDirection", "flexWrap"],
      font: ["fontFamily", "fontFeatureSettings", "fontKerning", "fontLanguageOverride", "fontSize", "fontSizeAdjust", "fontStretch", "fontStyle", "fontVariant", "fontVariantAlternates", "fontVariantCaps", "fontVariantEastAsian", "fontVariantLigatures", "fontVariantNumeric", "fontVariantPosition", "fontWeight", "lineHeight"],
      fontVariant: ["fontVariantAlternates", "fontVariantCaps", "fontVariantEastAsian", "fontVariantLigatures", "fontVariantNumeric", "fontVariantPosition"],
      gap: ["columnGap", "rowGap"],
      grid: ["gridAutoColumns", "gridAutoFlow", "gridAutoRows", "gridTemplateAreas", "gridTemplateColumns", "gridTemplateRows"],
      gridArea: ["gridColumnEnd", "gridColumnStart", "gridRowEnd", "gridRowStart"],
      gridColumn: ["gridColumnEnd", "gridColumnStart"],
      gridColumnGap: ["columnGap"],
      gridGap: ["columnGap", "rowGap"],
      gridRow: ["gridRowEnd", "gridRowStart"],
      gridRowGap: ["rowGap"],
      gridTemplate: ["gridTemplateAreas", "gridTemplateColumns", "gridTemplateRows"],
      listStyle: ["listStyleImage", "listStylePosition", "listStyleType"],
      margin: ["marginBottom", "marginLeft", "marginRight", "marginTop"],
      marker: ["markerEnd", "markerMid", "markerStart"],
      mask: ["maskClip", "maskComposite", "maskImage", "maskMode", "maskOrigin", "maskPositionX", "maskPositionY", "maskRepeat", "maskSize"],
      maskPosition: ["maskPositionX", "maskPositionY"],
      outline: ["outlineColor", "outlineStyle", "outlineWidth"],
      overflow: ["overflowX", "overflowY"],
      padding: ["paddingBottom", "paddingLeft", "paddingRight", "paddingTop"],
      placeContent: ["alignContent", "justifyContent"],
      placeItems: ["alignItems", "justifyItems"],
      placeSelf: ["alignSelf", "justifySelf"],
      textDecoration: ["textDecorationColor", "textDecorationLine", "textDecorationStyle"],
      textEmphasis: ["textEmphasisColor", "textEmphasisStyle"],
      transition: ["transitionDelay", "transitionDuration", "transitionProperty", "transitionTimingFunction"],
      wordWrap: ["overflowWrap"]
    }, yw = {
      animationIterationCount: !0,
      aspectRatio: !0,
      borderImageOutset: !0,
      borderImageSlice: !0,
      borderImageWidth: !0,
      boxFlex: !0,
      boxFlexGroup: !0,
      boxOrdinalGroup: !0,
      columnCount: !0,
      columns: !0,
      flex: !0,
      flexGrow: !0,
      flexPositive: !0,
      flexShrink: !0,
      flexNegative: !0,
      flexOrder: !0,
      gridArea: !0,
      gridRow: !0,
      gridRowEnd: !0,
      gridRowSpan: !0,
      gridRowStart: !0,
      gridColumn: !0,
      gridColumnEnd: !0,
      gridColumnSpan: !0,
      gridColumnStart: !0,
      fontWeight: !0,
      lineClamp: !0,
      lineHeight: !0,
      opacity: !0,
      order: !0,
      orphans: !0,
      tabSize: !0,
      widows: !0,
      zIndex: !0,
      zoom: !0,
      fillOpacity: !0,
      floodOpacity: !0,
      stopOpacity: !0,
      strokeDasharray: !0,
      strokeDashoffset: !0,
      strokeMiterlimit: !0,
      strokeOpacity: !0,
      strokeWidth: !0
    };
    function ib0(L, O) {
      return L + O.charAt(0).toUpperCase() + O.substring(1);
    }
    var ob0 = ["Webkit", "ms", "Moz", "O"];
    Object.keys(yw).forEach(function(L) {
      ob0.forEach(function(O) {
        yw[ib0(O, L)] = yw[L];
      });
    });
    function dm(L, O, _) {
      var k = O == null || typeof O === "boolean" || O === "";
      if (k)
        return "";
      if (!_ && typeof O === "number" && O !== 0 && !(yw.hasOwnProperty(L) && yw[L]))
        return O + "px";
      return A0(O, L), ("" + O).trim();
    }
    var sb0 = /([A-Z])/g, ab0 = /^ms-/;
    function rb0(L) {
      return L.replace(sb0, "-$1").toLowerCase().replace(ab0, "-ms-");
    }
    var aZ0 = function() {};
    {
      var tb0 = /^(?:webkit|moz|o)[A-Z]/, eb0 = /^-ms-/, Zx0 = /-(.)/g, rZ0 = /;\s*$/, h4 = {}, pm = {}, tZ0 = !1, eZ0 = !1, Jx0 = function(L) {
        return L.replace(Zx0, function(O, _) {
          return _.toUpperCase();
        });
      }, $x0 = function(L) {
        if (h4.hasOwnProperty(L) && h4[L])
          return;
        h4[L] = !0, Y("Unsupported style property %s. Did you mean %s?", L, Jx0(L.replace(eb0, "ms-")));
      }, Xx0 = function(L) {
        if (h4.hasOwnProperty(L) && h4[L])
          return;
        h4[L] = !0, Y("Unsupported vendor-prefixed style property %s. Did you mean %s?", L, L.charAt(0).toUpperCase() + L.slice(1));
      }, Yx0 = function(L, O) {
        if (pm.hasOwnProperty(O) && pm[O])
          return;
        pm[O] = !0, Y(`Style property values shouldn't contain a semicolon. Try "%s: %s" instead.`, L, O.replace(rZ0, ""));
      }, Qx0 = function(L, O) {
        if (tZ0)
          return;
        tZ0 = !0, Y("`NaN` is an invalid value for the `%s` css style property.", L);
      }, Wx0 = function(L, O) {
        if (eZ0)
          return;
        eZ0 = !0, Y("`Infinity` is an invalid value for the `%s` css style property.", L);
      };
      aZ0 = function(L, O) {
        if (L.indexOf("-") > -1)
          $x0(L);
        else if (tb0.test(L))
          Xx0(L);
        else if (rZ0.test(O))
          Yx0(L, O);
        if (typeof O === "number") {
          if (isNaN(O))
            Qx0(L, O);
          else if (!isFinite(O))
            Wx0(L, O);
        }
      };
    }
    var Kx0 = aZ0;
    function Gx0(L) {
      {
        var O = "", _ = "";
        for (var k in L) {
          if (!L.hasOwnProperty(k))
            continue;
          var y = L[k];
          if (y != null) {
            var d = k.indexOf("--") === 0;
            O += _ + (d ? k : rb0(k)) + ":", O += dm(k, y, d), _ = ";";
          }
        }
        return O || null;
      }
    }
    function Z90(L, O) {
      var _ = L.style;
      for (var k in O) {
        if (!O.hasOwnProperty(k))
          continue;
        var y = k.indexOf("--") === 0;
        if (!y)
          Kx0(k, O[k]);
        var d = dm(k, O[k], y);
        if (k === "float")
          k = "cssFloat";
        if (y)
          _.setProperty(k, d);
        else
          _[k] = d;
      }
    }
    function Hx0(L) {
      return L == null || typeof L === "boolean" || L === "";
    }
    function J90(L) {
      var O = {};
      for (var _ in L) {
        var k = nb0[_] || [_];
        for (var y = 0;y < k.length; y++)
          O[k[y]] = _;
      }
      return O;
    }
    function Nx0(L, O) {
      {
        if (!O)
          return;
        var _ = J90(L), k = J90(O), y = {};
        for (var d in _) {
          var o = _[d], H0 = k[d];
          if (H0 && o !== H0) {
            var O0 = o + "," + H0;
            if (y[O0])
              continue;
            y[O0] = !0, Y("%s a style property during rerender (%s) when a conflicting property is set (%s) can lead to styling bugs. To avoid this, don't mix shorthand and non-shorthand properties for the same value; instead, replace the shorthand with separate values.", Hx0(L[o]) ? "Removing" : "Updating", o, H0);
          }
        }
      }
    }
    var qx0 = {
      area: !0,
      base: !0,
      br: !0,
      col: !0,
      embed: !0,
      hr: !0,
      img: !0,
      input: !0,
      keygen: !0,
      link: !0,
      meta: !0,
      param: !0,
      source: !0,
      track: !0,
      wbr: !0
    }, Fx0 = d0({
      menuitem: !0
    }, qx0), Ux0 = "__html";
    function um(L, O) {
      if (!O)
        return;
      if (Fx0[L]) {
        if (O.children != null || O.dangerouslySetInnerHTML != null)
          throw new Error(L + " is a void element tag and must neither have `children` nor use `dangerouslySetInnerHTML`.");
      }
      if (O.dangerouslySetInnerHTML != null) {
        if (O.children != null)
          throw new Error("Can only set one of `children` or `props.dangerouslySetInnerHTML`.");
        if (typeof O.dangerouslySetInnerHTML !== "object" || !(Ux0 in O.dangerouslySetInnerHTML))
          throw new Error("`props.dangerouslySetInnerHTML` must be in the form `{__html: ...}`. Please visit https://reactjs.org/link/dangerously-set-inner-html for more information.");
      }
      if (!O.suppressContentEditableWarning && O.contentEditable && O.children != null)
        Y("A component is `contentEditable` and contains `children` managed by React. It is now your responsibility to guarantee that none of those nodes are unexpectedly modified or duplicated. This is probably not intentional.");
      if (O.style != null && typeof O.style !== "object")
        throw new Error("The `style` prop expects a mapping from style properties to values, not a string. For example, style={{marginRight: spacing + 'em'}} when using JSX.");
    }
    function nE(L, O) {
      if (L.indexOf("-") === -1)
        return typeof O.is === "string";
      switch (L) {
        case "annotation-xml":
        case "color-profile":
        case "font-face":
        case "font-face-src":
        case "font-face-uri":
        case "font-face-format":
        case "font-face-name":
        case "missing-glyph":
          return !1;
        default:
          return !0;
      }
    }
    var cP = {
      accept: "accept",
      acceptcharset: "acceptCharset",
      "accept-charset": "acceptCharset",
      accesskey: "accessKey",
      action: "action",
      allowfullscreen: "allowFullScreen",
      alt: "alt",
      as: "as",
      async: "async",
      autocapitalize: "autoCapitalize",
      autocomplete: "autoComplete",
      autocorrect: "autoCorrect",
      autofocus: "autoFocus",
      autoplay: "autoPlay",
      autosave: "autoSave",
      capture: "capture",
      cellpadding: "cellPadding",
      cellspacing: "cellSpacing",
      challenge: "challenge",
      charset: "charSet",
      checked: "checked",
      children: "children",
      cite: "cite",
      class: "className",
      classid: "classID",
      classname: "className",
      cols: "cols",
      colspan: "colSpan",
      content: "content",
      contenteditable: "contentEditable",
      contextmenu: "contextMenu",
      controls: "controls",
      controlslist: "controlsList",
      coords: "coords",
      crossorigin: "crossOrigin",
      dangerouslysetinnerhtml: "dangerouslySetInnerHTML",
      data: "data",
      datetime: "dateTime",
      default: "default",
      defaultchecked: "defaultChecked",
      defaultvalue: "defaultValue",
      defer: "defer",
      dir: "dir",
      disabled: "disabled",
      disablepictureinpicture: "disablePictureInPicture",
      disableremoteplayback: "disableRemotePlayback",
      download: "download",
      draggable: "draggable",
      enctype: "encType",
      enterkeyhint: "enterKeyHint",
      for: "htmlFor",
      form: "form",
      formmethod: "formMethod",
      formaction: "formAction",
      formenctype: "formEncType",
      formnovalidate: "formNoValidate",
      formtarget: "formTarget",
      frameborder: "frameBorder",
      headers: "headers",
      height: "height",
      hidden: "hidden",
      high: "high",
      href: "href",
      hreflang: "hrefLang",
      htmlfor: "htmlFor",
      httpequiv: "httpEquiv",
      "http-equiv": "httpEquiv",
      icon: "icon",
      id: "id",
      imagesizes: "imageSizes",
      imagesrcset: "imageSrcSet",
      innerhtml: "innerHTML",
      inputmode: "inputMode",
      integrity: "integrity",
      is: "is",
      itemid: "itemID",
      itemprop: "itemProp",
      itemref: "itemRef",
      itemscope: "itemScope",
      itemtype: "itemType",
      keyparams: "keyParams",
      keytype: "keyType",
      kind: "kind",
      label: "label",
      lang: "lang",
      list: "list",
      loop: "loop",
      low: "low",
      manifest: "manifest",
      marginwidth: "marginWidth",
      marginheight: "marginHeight",
      max: "max",
      maxlength: "maxLength",
      media: "media",
      mediagroup: "mediaGroup",
      method: "method",
      min: "min",
      minlength: "minLength",
      multiple: "multiple",
      muted: "muted",
      name: "name",
      nomodule: "noModule",
      nonce: "nonce",
      novalidate: "noValidate",
      open: "open",
      optimum: "optimum",
      pattern: "pattern",
      placeholder: "placeholder",
      playsinline: "playsInline",
      poster: "poster",
      preload: "preload",
      profile: "profile",
      radiogroup: "radioGroup",
      readonly: "readOnly",
      referrerpolicy: "referrerPolicy",
      rel: "rel",
      required: "required",
      reversed: "reversed",
      role: "role",
      rows: "rows",
      rowspan: "rowSpan",
      sandbox: "sandbox",
      scope: "scope",
      scoped: "scoped",
      scrolling: "scrolling",
      seamless: "seamless",
      selected: "selected",
      shape: "shape",
      size: "size",
      sizes: "sizes",
      span: "span",
      spellcheck: "spellCheck",
      src: "src",
      srcdoc: "srcDoc",
      srclang: "srcLang",
      srcset: "srcSet",
      start: "start",
      step: "step",
      style: "style",
      summary: "summary",
      tabindex: "tabIndex",
      target: "target",
      title: "title",
      type: "type",
      usemap: "useMap",
      value: "value",
      width: "width",
      wmode: "wmode",
      wrap: "wrap",
      about: "about",
      accentheight: "accentHeight",
      "accent-height": "accentHeight",
      accumulate: "accumulate",
      additive: "additive",
      alignmentbaseline: "alignmentBaseline",
      "alignment-baseline": "alignmentBaseline",
      allowreorder: "allowReorder",
      alphabetic: "alphabetic",
      amplitude: "amplitude",
      arabicform: "arabicForm",
      "arabic-form": "arabicForm",
      ascent: "ascent",
      attributename: "attributeName",
      attributetype: "attributeType",
      autoreverse: "autoReverse",
      azimuth: "azimuth",
      basefrequency: "baseFrequency",
      baselineshift: "baselineShift",
      "baseline-shift": "baselineShift",
      baseprofile: "baseProfile",
      bbox: "bbox",
      begin: "begin",
      bias: "bias",
      by: "by",
      calcmode: "calcMode",
      capheight: "capHeight",
      "cap-height": "capHeight",
      clip: "clip",
      clippath: "clipPath",
      "clip-path": "clipPath",
      clippathunits: "clipPathUnits",
      cliprule: "clipRule",
      "clip-rule": "clipRule",
      color: "color",
      colorinterpolation: "colorInterpolation",
      "color-interpolation": "colorInterpolation",
      colorinterpolationfilters: "colorInterpolationFilters",
      "color-interpolation-filters": "colorInterpolationFilters",
      colorprofile: "colorProfile",
      "color-profile": "colorProfile",
      colorrendering: "colorRendering",
      "color-rendering": "colorRendering",
      contentscripttype: "contentScriptType",
      contentstyletype: "contentStyleType",
      cursor: "cursor",
      cx: "cx",
      cy: "cy",
      d: "d",
      datatype: "datatype",
      decelerate: "decelerate",
      descent: "descent",
      diffuseconstant: "diffuseConstant",
      direction: "direction",
      display: "display",
      divisor: "divisor",
      dominantbaseline: "dominantBaseline",
      "dominant-baseline": "dominantBaseline",
      dur: "dur",
      dx: "dx",
      dy: "dy",
      edgemode: "edgeMode",
      elevation: "elevation",
      enablebackground: "enableBackground",
      "enable-background": "enableBackground",
      end: "end",
      exponent: "exponent",
      externalresourcesrequired: "externalResourcesRequired",
      fill: "fill",
      fillopacity: "fillOpacity",
      "fill-opacity": "fillOpacity",
      fillrule: "fillRule",
      "fill-rule": "fillRule",
      filter: "filter",
      filterres: "filterRes",
      filterunits: "filterUnits",
      floodopacity: "floodOpacity",
      "flood-opacity": "floodOpacity",
      floodcolor: "floodColor",
      "flood-color": "floodColor",
      focusable: "focusable",
      fontfamily: "fontFamily",
      "font-family": "fontFamily",
      fontsize: "fontSize",
      "font-size": "fontSize",
      fontsizeadjust: "fontSizeAdjust",
      "font-size-adjust": "fontSizeAdjust",
      fontstretch: "fontStretch",
      "font-stretch": "fontStretch",
      fontstyle: "fontStyle",
      "font-style": "fontStyle",
      fontvariant: "fontVariant",
      "font-variant": "fontVariant",
      fontweight: "fontWeight",
      "font-weight": "fontWeight",
      format: "format",
      from: "from",
      fx: "fx",
      fy: "fy",
      g1: "g1",
      g2: "g2",
      glyphname: "glyphName",
      "glyph-name": "glyphName",
      glyphorientationhorizontal: "glyphOrientationHorizontal",
      "glyph-orientation-horizontal": "glyphOrientationHorizontal",
      glyphorientationvertical: "glyphOrientationVertical",
      "glyph-orientation-vertical": "glyphOrientationVertical",
      glyphref: "glyphRef",
      gradienttransform: "gradientTransform",
      gradientunits: "gradientUnits",
      hanging: "hanging",
      horizadvx: "horizAdvX",
      "horiz-adv-x": "horizAdvX",
      horizoriginx: "horizOriginX",
      "horiz-origin-x": "horizOriginX",
      ideographic: "ideographic",
      imagerendering: "imageRendering",
      "image-rendering": "imageRendering",
      in2: "in2",
      in: "in",
      inlist: "inlist",
      intercept: "intercept",
      k1: "k1",
      k2: "k2",
      k3: "k3",
      k4: "k4",
      k: "k",
      kernelmatrix: "kernelMatrix",
      kernelunitlength: "kernelUnitLength",
      kerning: "kerning",
      keypoints: "keyPoints",
      keysplines: "keySplines",
      keytimes: "keyTimes",
      lengthadjust: "lengthAdjust",
      letterspacing: "letterSpacing",
      "letter-spacing": "letterSpacing",
      lightingcolor: "lightingColor",
      "lighting-color": "lightingColor",
      limitingconeangle: "limitingConeAngle",
      local: "local",
      markerend: "markerEnd",
      "marker-end": "markerEnd",
      markerheight: "markerHeight",
      markermid: "markerMid",
      "marker-mid": "markerMid",
      markerstart: "markerStart",
      "marker-start": "markerStart",
      markerunits: "markerUnits",
      markerwidth: "markerWidth",
      mask: "mask",
      maskcontentunits: "maskContentUnits",
      maskunits: "maskUnits",
      mathematical: "mathematical",
      mode: "mode",
      numoctaves: "numOctaves",
      offset: "offset",
      opacity: "opacity",
      operator: "operator",
      order: "order",
      orient: "orient",
      orientation: "orientation",
      origin: "origin",
      overflow: "overflow",
      overlineposition: "overlinePosition",
      "overline-position": "overlinePosition",
      overlinethickness: "overlineThickness",
      "overline-thickness": "overlineThickness",
      paintorder: "paintOrder",
      "paint-order": "paintOrder",
      panose1: "panose1",
      "panose-1": "panose1",
      pathlength: "pathLength",
      patterncontentunits: "patternContentUnits",
      patterntransform: "patternTransform",
      patternunits: "patternUnits",
      pointerevents: "pointerEvents",
      "pointer-events": "pointerEvents",
      points: "points",
      pointsatx: "pointsAtX",
      pointsaty: "pointsAtY",
      pointsatz: "pointsAtZ",
      prefix: "prefix",
      preservealpha: "preserveAlpha",
      preserveaspectratio: "preserveAspectRatio",
      primitiveunits: "primitiveUnits",
      property: "property",
      r: "r",
      radius: "radius",
      refx: "refX",
      refy: "refY",
      renderingintent: "renderingIntent",
      "rendering-intent": "renderingIntent",
      repeatcount: "repeatCount",
      repeatdur: "repeatDur",
      requiredextensions: "requiredExtensions",
      requiredfeatures: "requiredFeatures",
      resource: "resource",
      restart: "restart",
      result: "result",
      results: "results",
      rotate: "rotate",
      rx: "rx",
      ry: "ry",
      scale: "scale",
      security: "security",
      seed: "seed",
      shaperendering: "shapeRendering",
      "shape-rendering": "shapeRendering",
      slope: "slope",
      spacing: "spacing",
      specularconstant: "specularConstant",
      specularexponent: "specularExponent",
      speed: "speed",
      spreadmethod: "spreadMethod",
      startoffset: "startOffset",
      stddeviation: "stdDeviation",
      stemh: "stemh",
      stemv: "stemv",
      stitchtiles: "stitchTiles",
      stopcolor: "stopColor",
      "stop-color": "stopColor",
      stopopacity: "stopOpacity",
      "stop-opacity": "stopOpacity",
      strikethroughposition: "strikethroughPosition",
      "strikethrough-position": "strikethroughPosition",
      strikethroughthickness: "strikethroughThickness",
      "strikethrough-thickness": "strikethroughThickness",
      string: "string",
      stroke: "stroke",
      strokedasharray: "strokeDasharray",
      "stroke-dasharray": "strokeDasharray",
      strokedashoffset: "strokeDashoffset",
      "stroke-dashoffset": "strokeDashoffset",
      strokelinecap: "strokeLinecap",
      "stroke-linecap": "strokeLinecap",
      strokelinejoin: "strokeLinejoin",
      "stroke-linejoin": "strokeLinejoin",
      strokemiterlimit: "strokeMiterlimit",
      "stroke-miterlimit": "strokeMiterlimit",
      strokewidth: "strokeWidth",
      "stroke-width": "strokeWidth",
      strokeopacity: "strokeOpacity",
      "stroke-opacity": "strokeOpacity",
      suppresscontenteditablewarning: "suppressContentEditableWarning",
      suppresshydrationwarning: "suppressHydrationWarning",
      surfacescale: "surfaceScale",
      systemlanguage: "systemLanguage",
      tablevalues: "tableValues",
      targetx: "targetX",
      targety: "targetY",
      textanchor: "textAnchor",
      "text-anchor": "textAnchor",
      textdecoration: "textDecoration",
      "text-decoration": "textDecoration",
      textlength: "textLength",
      textrendering: "textRendering",
      "text-rendering": "textRendering",
      to: "to",
      transform: "transform",
      typeof: "typeof",
      u1: "u1",
      u2: "u2",
      underlineposition: "underlinePosition",
      "underline-position": "underlinePosition",
      underlinethickness: "underlineThickness",
      "underline-thickness": "underlineThickness",
      unicode: "unicode",
      unicodebidi: "unicodeBidi",
      "unicode-bidi": "unicodeBidi",
      unicoderange: "unicodeRange",
      "unicode-range": "unicodeRange",
      unitsperem: "unitsPerEm",
      "units-per-em": "unitsPerEm",
      unselectable: "unselectable",
      valphabetic: "vAlphabetic",
      "v-alphabetic": "vAlphabetic",
      values: "values",
      vectoreffect: "vectorEffect",
      "vector-effect": "vectorEffect",
      version: "version",
      vertadvy: "vertAdvY",
      "vert-adv-y": "vertAdvY",
      vertoriginx: "vertOriginX",
      "vert-origin-x": "vertOriginX",
      vertoriginy: "vertOriginY",
      "vert-origin-y": "vertOriginY",
      vhanging: "vHanging",
      "v-hanging": "vHanging",
      videographic: "vIdeographic",
      "v-ideographic": "vIdeographic",
      viewbox: "viewBox",
      viewtarget: "viewTarget",
      visibility: "visibility",
      vmathematical: "vMathematical",
      "v-mathematical": "vMathematical",
      vocab: "vocab",
      widths: "widths",
      wordspacing: "wordSpacing",
      "word-spacing": "wordSpacing",
      writingmode: "writingMode",
      "writing-mode": "writingMode",
      x1: "x1",
      x2: "x2",
      x: "x",
      xchannelselector: "xChannelSelector",
      xheight: "xHeight",
      "x-height": "xHeight",
      xlinkactuate: "xlinkActuate",
      "xlink:actuate": "xlinkActuate",
      xlinkarcrole: "xlinkArcrole",
      "xlink:arcrole": "xlinkArcrole",
      xlinkhref: "xlinkHref",
      "xlink:href": "xlinkHref",
      xlinkrole: "xlinkRole",
      "xlink:role": "xlinkRole",
      xlinkshow: "xlinkShow",
      "xlink:show": "xlinkShow",
      xlinktitle: "xlinkTitle",
      "xlink:title": "xlinkTitle",
      xlinktype: "xlinkType",
      "xlink:type": "xlinkType",
      xmlbase: "xmlBase",
      "xml:base": "xmlBase",
      xmllang: "xmlLang",
      "xml:lang": "xmlLang",
      xmlns: "xmlns",
      "xml:space": "xmlSpace",
      xmlnsxlink: "xmlnsXlink",
      "xmlns:xlink": "xmlnsXlink",
      xmlspace: "xmlSpace",
      y1: "y1",
      y2: "y2",
      y: "y",
      ychannelselector: "yChannelSelector",
      z: "z",
      zoomandpan: "zoomAndPan"
    }, $90 = {
      "aria-current": 0,
      "aria-description": 0,
      "aria-details": 0,
      "aria-disabled": 0,
      "aria-hidden": 0,
      "aria-invalid": 0,
      "aria-keyshortcuts": 0,
      "aria-label": 0,
      "aria-roledescription": 0,
      "aria-autocomplete": 0,
      "aria-checked": 0,
      "aria-expanded": 0,
      "aria-haspopup": 0,
      "aria-level": 0,
      "aria-modal": 0,
      "aria-multiline": 0,
      "aria-multiselectable": 0,
      "aria-orientation": 0,
      "aria-placeholder": 0,
      "aria-pressed": 0,
      "aria-readonly": 0,
      "aria-required": 0,
      "aria-selected": 0,
      "aria-sort": 0,
      "aria-valuemax": 0,
      "aria-valuemin": 0,
      "aria-valuenow": 0,
      "aria-valuetext": 0,
      "aria-atomic": 0,
      "aria-busy": 0,
      "aria-live": 0,
      "aria-relevant": 0,
      "aria-dropeffect": 0,
      "aria-grabbed": 0,
      "aria-activedescendant": 0,
      "aria-colcount": 0,
      "aria-colindex": 0,
      "aria-colspan": 0,
      "aria-controls": 0,
      "aria-describedby": 0,
      "aria-errormessage": 0,
      "aria-flowto": 0,
      "aria-labelledby": 0,
      "aria-owns": 0,
      "aria-posinset": 0,
      "aria-rowcount": 0,
      "aria-rowindex": 0,
      "aria-rowspan": 0,
      "aria-setsize": 0
    }, b4 = {}, Lx0 = new RegExp("^(aria)-[" + J0 + "]*$"), Rx0 = new RegExp("^(aria)[A-Z][" + J0 + "]*$");
    function Ex0(L, O) {
      {
        if (R0.call(b4, O) && b4[O])
          return !0;
        if (Rx0.test(O)) {
          var _ = "aria-" + O.slice(4).toLowerCase(), k = $90.hasOwnProperty(_) ? _ : null;
          if (k == null)
            return Y("Invalid ARIA attribute `%s`. ARIA attributes follow the pattern aria-* and must be lowercase.", O), b4[O] = !0, !0;
          if (O !== k)
            return Y("Invalid ARIA attribute `%s`. Did you mean `%s`?", O, k), b4[O] = !0, !0;
        }
        if (Lx0.test(O)) {
          var y = O.toLowerCase(), d = $90.hasOwnProperty(y) ? y : null;
          if (d == null)
            return b4[O] = !0, !1;
          if (O !== d)
            return Y("Unknown ARIA attribute `%s`. Did you mean `%s`?", O, d), b4[O] = !0, !0;
        }
      }
      return !0;
    }
    function Ox0(L, O) {
      {
        var _ = [];
        for (var k in O) {
          var y = Ex0(L, k);
          if (!y)
            _.push(k);
        }
        var d = _.map(function(o) {
          return "`" + o + "`";
        }).join(", ");
        if (_.length === 1)
          Y("Invalid aria prop %s on <%s> tag. For details, see https://reactjs.org/link/invalid-aria-props", d, L);
        else if (_.length > 1)
          Y("Invalid aria props %s on <%s> tag. For details, see https://reactjs.org/link/invalid-aria-props", d, L);
      }
    }
    function zx0(L, O) {
      if (nE(L, O))
        return;
      Ox0(L, O);
    }
    var X90 = !1;
    function Dx0(L, O) {
      {
        if (L !== "input" && L !== "textarea" && L !== "select")
          return;
        if (O != null && O.value === null && !X90)
          if (X90 = !0, L === "select" && O.multiple)
            Y("`value` prop on `%s` should not be null. Consider using an empty array when `multiple` is set to `true` to clear the component or `undefined` for uncontrolled components.", L);
          else
            Y("`value` prop on `%s` should not be null. Consider using an empty string to clear the component or `undefined` for uncontrolled components.", L);
      }
    }
    var Y90 = function() {};
    {
      var NW = {}, Q90 = /^on./, Mx0 = /^on[^A-Z]/, Ax0 = new RegExp("^(aria)-[" + J0 + "]*$"), Bx0 = new RegExp("^(aria)[A-Z][" + J0 + "]*$");
      Y90 = function(L, O, _, k) {
        if (R0.call(NW, O) && NW[O])
          return !0;
        var y = O.toLowerCase();
        if (y === "onfocusin" || y === "onfocusout")
          return Y("React uses onFocus and onBlur instead of onFocusIn and onFocusOut. All React events are normalized to bubble, so onFocusIn and onFocusOut are not needed/supported by React."), NW[O] = !0, !0;
        if (k != null) {
          var { registrationNameDependencies: d, possibleRegistrationNames: o } = k;
          if (d.hasOwnProperty(O))
            return !0;
          var H0 = o.hasOwnProperty(y) ? o[y] : null;
          if (H0 != null)
            return Y("Invalid event handler property `%s`. Did you mean `%s`?", O, H0), NW[O] = !0, !0;
          if (Q90.test(O))
            return Y("Unknown event handler property `%s`. It will be ignored.", O), NW[O] = !0, !0;
        } else if (Q90.test(O)) {
          if (Mx0.test(O))
            Y("Invalid event handler property `%s`. React events use the camelCase naming convention, for example `onClick`.", O);
          return NW[O] = !0, !0;
        }
        if (Ax0.test(O) || Bx0.test(O))
          return !0;
        if (y === "innerhtml")
          return Y("Directly setting property `innerHTML` is not permitted. For more information, lookup documentation on `dangerouslySetInnerHTML`."), NW[O] = !0, !0;
        if (y === "aria")
          return Y("The `aria` attribute is reserved for future use in React. Pass individual `aria-` attributes instead."), NW[O] = !0, !0;
        if (y === "is" && _ !== null && _ !== void 0 && typeof _ !== "string")
          return Y("Received a `%s` for a string attribute `is`. If this is expected, cast the value to a string.", typeof _), NW[O] = !0, !0;
        if (typeof _ === "number" && isNaN(_))
          return Y("Received NaN for the `%s` attribute. If this is expected, cast the value to a string.", O), NW[O] = !0, !0;
        var O0 = S1(O), I0 = O0 !== null && O0.type === D1;
        if (cP.hasOwnProperty(y)) {
          var g0 = cP[y];
          if (g0 !== O)
            return Y("Invalid DOM property `%s`. Did you mean `%s`?", O, g0), NW[O] = !0, !0;
        } else if (!I0 && O !== y)
          return Y("React does not recognize the `%s` prop on a DOM element. If you intentionally want it to appear in the DOM as a custom attribute, spell it as lowercase `%s` instead. If you accidentally passed it from a parent component, remove it from the DOM element.", O, y), NW[O] = !0, !0;
        if (typeof _ === "boolean" && A1(O, _, O0, !1)) {
          if (_)
            Y('Received `%s` for a non-boolean attribute `%s`.\n\nIf you want to write it to the DOM, pass a string instead: %s="%s" or %s={value.toString()}.', _, O, O, _, O);
          else
            Y('Received `%s` for a non-boolean attribute `%s`.\n\nIf you want to write it to the DOM, pass a string instead: %s="%s" or %s={value.toString()}.\n\nIf you used to conditionally omit it with %s={condition && value}, pass %s={condition ? value : undefined} instead.', _, O, O, _, O, O, O);
          return NW[O] = !0, !0;
        }
        if (I0)
          return !0;
        if (A1(O, _, O0, !1))
          return NW[O] = !0, !1;
        if ((_ === "false" || _ === "true") && O0 !== null && O0.type === b0)
          return Y("Received the string `%s` for the boolean attribute `%s`. %s Did you mean %s={%s}?", _, O, _ === "false" ? "The browser will interpret it as a truthy value." : 'Although this works, it will not work as expected if you pass the string "false".', O, _), NW[O] = !0, !0;
        return !0;
      };
    }
    var wx0 = function(L, O, _) {
      {
        var k = [];
        for (var y in O) {
          var d = Y90(L, y, O[y], _);
          if (!d)
            k.push(y);
        }
        var o = k.map(function(H0) {
          return "`" + H0 + "`";
        }).join(", ");
        if (k.length === 1)
          Y("Invalid value for prop %s on <%s> tag. Either remove it from the element, or pass a string or number value to keep it in the DOM. For details, see https://reactjs.org/link/attribute-behavior ", o, L);
        else if (k.length > 1)
          Y("Invalid values for props %s on <%s> tag. Either remove them from the element, or pass a string or number value to keep them in the DOM. For details, see https://reactjs.org/link/attribute-behavior ", o, L);
      }
    };
    function jx0(L, O, _) {
      if (nE(L, O))
        return;
      wx0(L, O, _);
    }
    var W90 = 1, cm = 2, gw = 4, Tx0 = W90 | cm | gw, mw = null;
    function _x0(L) {
      if (mw !== null)
        Y("Expected currently replaying event to be null. This error is likely caused by a bug in React. Please file an issue.");
      mw = L;
    }
    function Vx0() {
      if (mw === null)
        Y("Expected currently replaying event to not be null. This error is likely caused by a bug in React. Please file an issue.");
      mw = null;
    }
    function Ix0(L) {
      return L === mw;
    }
    function lm(L) {
      var O = L.target || L.srcElement || window;
      if (O.correspondingUseElement)
        O = O.correspondingUseElement;
      return O.nodeType === aq ? O.parentNode : O;
    }
    var nm = null, x4 = null, y4 = null;
    function K90(L) {
      var O = iU(L);
      if (!O)
        return;
      if (typeof nm !== "function")
        throw new Error("setRestoreImplementation() needs to be called to handle a target for controlled events. This error is likely caused by a bug in React. Please file an issue.");
      var _ = O.stateNode;
      if (_) {
        var k = IC(_);
        nm(O.stateNode, O.type, k);
      }
    }
    function Px0(L) {
      nm = L;
    }
    function G90(L) {
      if (x4)
        if (y4)
          y4.push(L);
        else
          y4 = [L];
      else
        x4 = L;
    }
    function Cx0() {
      return x4 !== null || y4 !== null;
    }
    function H90() {
      if (!x4)
        return;
      var L = x4, O = y4;
      if (x4 = null, y4 = null, K90(L), O)
        for (var _ = 0;_ < O.length; _++)
          K90(O[_]);
    }
    var N90 = function(L, O) {
      return L(O);
    }, q90 = function() {}, im = !1;
    function kx0() {
      var L = Cx0();
      if (L)
        q90(), H90();
    }
    function F90(L, O, _) {
      if (im)
        return L(O, _);
      im = !0;
      try {
        return N90(L, O, _);
      } finally {
        im = !1, kx0();
      }
    }
    function vx0(L, O, _) {
      N90 = L, q90 = _;
    }
    function Sx0(L) {
      return L === "button" || L === "input" || L === "select" || L === "textarea";
    }
    function fx0(L, O, _) {
      switch (L) {
        case "onClick":
        case "onClickCapture":
        case "onDoubleClick":
        case "onDoubleClickCapture":
        case "onMouseDown":
        case "onMouseDownCapture":
        case "onMouseMove":
        case "onMouseMoveCapture":
        case "onMouseUp":
        case "onMouseUpCapture":
        case "onMouseEnter":
          return !!(_.disabled && Sx0(O));
        default:
          return !1;
      }
    }
    function dw(L, O) {
      var _ = L.stateNode;
      if (_ === null)
        return null;
      var k = IC(_);
      if (k === null)
        return null;
      var y = k[O];
      if (fx0(O, L.type, k))
        return null;
      if (y && typeof y !== "function")
        throw new Error("Expected `" + O + "` listener to be a function, instead got a value of `" + typeof y + "` type.");
      return y;
    }
    var om = !1;
    if ($0)
      try {
        var pw = {};
        Object.defineProperty(pw, "passive", {
          get: function() {
            om = !0;
          }
        }), window.addEventListener("test", pw, pw), window.removeEventListener("test", pw, pw);
      } catch (L) {
        om = !1;
      }
    function U90(L, O, _, k, y, d, o, H0, O0) {
      var I0 = Array.prototype.slice.call(arguments, 3);
      try {
        O.apply(_, I0);
      } catch (g0) {
        this.onError(g0);
      }
    }
    var L90 = U90;
    if (typeof window !== "undefined" && typeof window.dispatchEvent === "function" && typeof document !== "undefined" && typeof document.createEvent === "function") {
      var sm = document.createElement("react");
      L90 = function L(O, _, k, y, d, o, H0, O0, I0) {
        if (typeof document === "undefined" || document === null)
          throw new Error("The `document` global was defined when React was initialized, but is not defined anymore. This can happen in a test environment if a component schedules an update from an asynchronous callback, but the test has already finished running. To solve this, you can either unmount the component at the end of your test (and ensure that any asynchronous operations get canceled in `componentWillUnmount`), or you can change the test itself to be asynchronous.");
        var g0 = document.createEvent("Event"), R1 = !1, U1 = !0, x1 = window.event, y1 = Object.getOwnPropertyDescriptor(window, "event");
        function r1() {
          if (sm.removeEventListener(Y2, J6, !1), typeof window.event !== "undefined" && window.hasOwnProperty("event"))
            window.event = x1;
        }
        var Q8 = Array.prototype.slice.call(arguments, 3);
        function J6() {
          R1 = !0, r1(), _.apply(k, Q8), U1 = !1;
        }
        var b8, oZ = !1, sZ = !1;
        function C1(k1) {
          if (b8 = k1.error, oZ = !0, b8 === null && k1.colno === 0 && k1.lineno === 0)
            sZ = !0;
          if (k1.defaultPrevented) {
            if (b8 != null && typeof b8 === "object")
              try {
                b8._suppressLogging = !0;
              } catch (k2) {}
          }
        }
        var Y2 = "react-" + (O ? O : "invokeguardedcallback");
        if (window.addEventListener("error", C1), sm.addEventListener(Y2, J6, !1), g0.initEvent(Y2, !1, !1), sm.dispatchEvent(g0), y1)
          Object.defineProperty(window, "event", y1);
        if (R1 && U1) {
          if (!oZ)
            b8 = new Error(`An error was thrown inside one of your components, but React doesn't know what it was. This is likely due to browser flakiness. React does its best to preserve the "Pause on exceptions" behavior of the DevTools, which requires some DEV-mode only tricks. It's possible that these don't work in your browser. Try triggering the error in production mode, or switching to a modern browser. If you suspect that this is actually an issue with React, please file an issue.`);
          else if (sZ)
            b8 = new Error("A cross-origin error was thrown. React doesn't have access to the actual error object in development. See https://reactjs.org/link/crossorigin-error for more information.");
          this.onError(b8);
        }
        if (window.removeEventListener("error", C1), !R1)
          return r1(), U90.apply(this, arguments);
      };
    }
    var hx0 = L90, g4 = !1, lP = null, nP = !1, am = null, bx0 = {
      onError: function(L) {
        g4 = !0, lP = L;
      }
    };
    function rm(L, O, _, k, y, d, o, H0, O0) {
      g4 = !1, lP = null, hx0.apply(bx0, arguments);
    }
    function xx0(L, O, _, k, y, d, o, H0, O0) {
      if (rm.apply(this, arguments), g4) {
        var I0 = tm();
        if (!nP)
          nP = !0, am = I0;
      }
    }
    function yx0() {
      if (nP) {
        var L = am;
        throw nP = !1, am = null, L;
      }
    }
    function gx0() {
      return g4;
    }
    function tm() {
      if (g4) {
        var L = lP;
        return g4 = !1, lP = null, L;
      } else
        throw new Error("clearCaughtError was called but no error was captured. This error is likely caused by a bug in React. Please file an issue.");
    }
    function m4(L) {
      return L._reactInternals;
    }
    function mx0(L) {
      return L._reactInternals !== void 0;
    }
    function dx0(L, O) {
      L._reactInternals = O;
    }
    var M6 = 0, d4 = 1, u$ = 2, F9 = 4, iE = 16, uw = 32, em = 64, x9 = 128, tq = 256, mU = 512, oE = 1024, _G = 2048, eq = 4096, sE = 8192, iP = 16384, px0 = _G | F9 | em | mU | oE | iP, ux0 = 32767, cw = 32768, qW = 65536, Zd = 131072, R90 = 1048576, Jd = 2097152, aE = 4194304, $d = 8388608, ZF = 16777216, oP = 33554432, Xd = F9 | oE | 0, Yd = u$ | F9 | iE | uw | mU | eq | sE, lw = F9 | em | mU | sE, p4 = _G | iE, JF = aE | $d | Jd, cx0 = Z.ReactCurrentOwner;
    function rE(L) {
      var O = L, _ = L;
      if (!L.alternate) {
        var k = O;
        do {
          if (O = k, (O.flags & (u$ | eq)) !== M6)
            _ = O.return;
          k = O.return;
        } while (k);
      } else
        while (O.return)
          O = O.return;
      if (O.tag === H)
        return _;
      return null;
    }
    function E90(L) {
      if (L.tag === B) {
        var O = L.memoizedState;
        if (O === null) {
          var _ = L.alternate;
          if (_ !== null)
            O = _.memoizedState;
        }
        if (O !== null)
          return O.dehydrated;
      }
      return null;
    }
    function O90(L) {
      return L.tag === H ? L.stateNode.containerInfo : null;
    }
    function lx0(L) {
      return rE(L) === L;
    }
    function nx0(L) {
      {
        var O = cx0.current;
        if (O !== null && O.tag === K) {
          var _ = O, k = _.stateNode;
          if (!k._warnedAboutRefsInRender)
            Y("%s is accessing isMounted inside its render() function. render() should be a pure function of props and state. It should never access something that requires stale data from the previous render, such as refs. Move this logic to componentDidMount and componentDidUpdate instead.", D6(_) || "A component");
          k._warnedAboutRefsInRender = !0;
        }
      }
      var y = m4(L);
      if (!y)
        return !1;
      return rE(y) === y;
    }
    function z90(L) {
      if (rE(L) !== L)
        throw new Error("Unable to find node on an unmounted component.");
    }
    function D90(L) {
      var O = L.alternate;
      if (!O) {
        var _ = rE(L);
        if (_ === null)
          throw new Error("Unable to find node on an unmounted component.");
        if (_ !== L)
          return null;
        return L;
      }
      var k = L, y = O;
      while (!0) {
        var d = k.return;
        if (d === null)
          break;
        var o = d.alternate;
        if (o === null) {
          var H0 = d.return;
          if (H0 !== null) {
            k = y = H0;
            continue;
          }
          break;
        }
        if (d.child === o.child) {
          var O0 = d.child;
          while (O0) {
            if (O0 === k)
              return z90(d), L;
            if (O0 === y)
              return z90(d), O;
            O0 = O0.sibling;
          }
          throw new Error("Unable to find node on an unmounted component.");
        }
        if (k.return !== y.return)
          k = d, y = o;
        else {
          var I0 = !1, g0 = d.child;
          while (g0) {
            if (g0 === k) {
              I0 = !0, k = d, y = o;
              break;
            }
            if (g0 === y) {
              I0 = !0, y = d, k = o;
              break;
            }
            g0 = g0.sibling;
          }
          if (!I0) {
            g0 = o.child;
            while (g0) {
              if (g0 === k) {
                I0 = !0, k = o, y = d;
                break;
              }
              if (g0 === y) {
                I0 = !0, y = o, k = d;
                break;
              }
              g0 = g0.sibling;
            }
            if (!I0)
              throw new Error("Child was not found in either parent set. This indicates a bug in React related to the return pointer. Please file an issue.");
          }
        }
        if (k.alternate !== y)
          throw new Error("Return fibers should always be each others' alternates. This error is likely caused by a bug in React. Please file an issue.");
      }
      if (k.tag !== H)
        throw new Error("Unable to find node on an unmounted component.");
      if (k.stateNode.current === k)
        return L;
      return O;
    }
    function M90(L) {
      var O = D90(L);
      return O !== null ? A90(O) : null;
    }
    function A90(L) {
      if (L.tag === q || L.tag === U)
        return L;
      var O = L.child;
      while (O !== null) {
        var _ = A90(O);
        if (_ !== null)
          return _;
        O = O.sibling;
      }
      return null;
    }
    function ix0(L) {
      var O = D90(L);
      return O !== null ? B90(O) : null;
    }
    function B90(L) {
      if (L.tag === q || L.tag === U)
        return L;
      var O = L.child;
      while (O !== null) {
        if (O.tag !== N) {
          var _ = B90(O);
          if (_ !== null)
            return _;
        }
        O = O.sibling;
      }
      return null;
    }
    var w90 = E7.unstable_scheduleCallback, ox0 = E7.unstable_cancelCallback, sx0 = E7.unstable_shouldYield, ax0 = E7.unstable_requestPaint, rX = E7.unstable_now, rx0 = E7.unstable_getCurrentPriorityLevel, sP = E7.unstable_ImmediatePriority, Qd = E7.unstable_UserBlockingPriority, tE = E7.unstable_NormalPriority, tx0 = E7.unstable_LowPriority, Wd = E7.unstable_IdlePriority, ex0 = E7.unstable_yieldValue, Zy0 = E7.unstable_setDisableYieldValue, eE = null, cY = null, F8 = null, oH = !1, VG = typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== "undefined";
    function Jy0(L) {
      if (typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ === "undefined")
        return !1;
      var O = __REACT_DEVTOOLS_GLOBAL_HOOK__;
      if (O.isDisabled)
        return !0;
      if (!O.supportsFiber)
        return Y("The installed version of React DevTools is too old and will not work with the current version of React. Please update React DevTools. https://reactjs.org/link/react-devtools"), !0;
      try {
        if (u)
          L = d0({}, L, {
            getLaneLabelMap: Ky0,
            injectProfilingHooks: Wy0
          });
        eE = O.inject(L), cY = O;
      } catch (_) {
        Y("React instrumentation encountered an error: %s.", _);
      }
      if (O.checkDCE)
        return !0;
      else
        return !1;
    }
    function $y0(L, O) {
      if (cY && typeof cY.onScheduleFiberRoot === "function")
        try {
          cY.onScheduleFiberRoot(eE, L, O);
        } catch (_) {
          if (!oH)
            oH = !0, Y("React instrumentation encountered an error: %s", _);
        }
    }
    function Xy0(L, O) {
      if (cY && typeof cY.onCommitFiberRoot === "function")
        try {
          var _ = (L.current.flags & x9) === x9;
          if (G0) {
            var k;
            switch (O) {
              case s5:
                k = sP;
                break;
              case XF:
                k = Qd;
                break;
              case YF:
                k = tE;
                break;
              case XC:
                k = Wd;
                break;
              default:
                k = tE;
                break;
            }
            cY.onCommitFiberRoot(eE, L, k, _);
          } else
            cY.onCommitFiberRoot(eE, L, void 0, _);
        } catch (y) {
          if (!oH)
            oH = !0, Y("React instrumentation encountered an error: %s", y);
        }
    }
    function Yy0(L) {
      if (cY && typeof cY.onPostCommitFiberRoot === "function")
        try {
          cY.onPostCommitFiberRoot(eE, L);
        } catch (O) {
          if (!oH)
            oH = !0, Y("React instrumentation encountered an error: %s", O);
        }
    }
    function Qy0(L) {
      if (cY && typeof cY.onCommitFiberUnmount === "function")
        try {
          cY.onCommitFiberUnmount(eE, L);
        } catch (O) {
          if (!oH)
            oH = !0, Y("React instrumentation encountered an error: %s", O);
        }
    }
    function tX(L) {
      {
        if (typeof ex0 === "function")
          Zy0(L), $(L);
        if (cY && typeof cY.setStrictMode === "function")
          try {
            cY.setStrictMode(eE, L);
          } catch (O) {
            if (!oH)
              oH = !0, Y("React instrumentation encountered an error: %s", O);
          }
      }
    }
    function Wy0(L) {
      F8 = L;
    }
    function Ky0() {
      {
        var L = /* @__PURE__ */ new Map, O = 1;
        for (var _ = 0;_ < Gd; _++) {
          var k = Vy0(O);
          L.set(O, k), O *= 2;
        }
        return L;
      }
    }
    function Gy0(L) {
      if (F8 !== null && typeof F8.markCommitStarted === "function")
        F8.markCommitStarted(L);
    }
    function j90() {
      if (F8 !== null && typeof F8.markCommitStopped === "function")
        F8.markCommitStopped();
    }
    function nw(L) {
      if (F8 !== null && typeof F8.markComponentRenderStarted === "function")
        F8.markComponentRenderStarted(L);
    }
    function u4() {
      if (F8 !== null && typeof F8.markComponentRenderStopped === "function")
        F8.markComponentRenderStopped();
    }
    function Hy0(L) {
      if (F8 !== null && typeof F8.markComponentPassiveEffectMountStarted === "function")
        F8.markComponentPassiveEffectMountStarted(L);
    }
    function Ny0() {
      if (F8 !== null && typeof F8.markComponentPassiveEffectMountStopped === "function")
        F8.markComponentPassiveEffectMountStopped();
    }
    function qy0(L) {
      if (F8 !== null && typeof F8.markComponentPassiveEffectUnmountStarted === "function")
        F8.markComponentPassiveEffectUnmountStarted(L);
    }
    function Fy0() {
      if (F8 !== null && typeof F8.markComponentPassiveEffectUnmountStopped === "function")
        F8.markComponentPassiveEffectUnmountStopped();
    }
    function Uy0(L) {
      if (F8 !== null && typeof F8.markComponentLayoutEffectMountStarted === "function")
        F8.markComponentLayoutEffectMountStarted(L);
    }
    function Ly0() {
      if (F8 !== null && typeof F8.markComponentLayoutEffectMountStopped === "function")
        F8.markComponentLayoutEffectMountStopped();
    }
    function T90(L) {
      if (F8 !== null && typeof F8.markComponentLayoutEffectUnmountStarted === "function")
        F8.markComponentLayoutEffectUnmountStarted(L);
    }
    function _90() {
      if (F8 !== null && typeof F8.markComponentLayoutEffectUnmountStopped === "function")
        F8.markComponentLayoutEffectUnmountStopped();
    }
    function Ry0(L, O, _) {
      if (F8 !== null && typeof F8.markComponentErrored === "function")
        F8.markComponentErrored(L, O, _);
    }
    function Ey0(L, O, _) {
      if (F8 !== null && typeof F8.markComponentSuspended === "function")
        F8.markComponentSuspended(L, O, _);
    }
    function Oy0(L) {
      if (F8 !== null && typeof F8.markLayoutEffectsStarted === "function")
        F8.markLayoutEffectsStarted(L);
    }
    function zy0() {
      if (F8 !== null && typeof F8.markLayoutEffectsStopped === "function")
        F8.markLayoutEffectsStopped();
    }
    function Dy0(L) {
      if (F8 !== null && typeof F8.markPassiveEffectsStarted === "function")
        F8.markPassiveEffectsStarted(L);
    }
    function My0() {
      if (F8 !== null && typeof F8.markPassiveEffectsStopped === "function")
        F8.markPassiveEffectsStopped();
    }
    function V90(L) {
      if (F8 !== null && typeof F8.markRenderStarted === "function")
        F8.markRenderStarted(L);
    }
    function Ay0() {
      if (F8 !== null && typeof F8.markRenderYielded === "function")
        F8.markRenderYielded();
    }
    function I90() {
      if (F8 !== null && typeof F8.markRenderStopped === "function")
        F8.markRenderStopped();
    }
    function By0(L) {
      if (F8 !== null && typeof F8.markRenderScheduled === "function")
        F8.markRenderScheduled(L);
    }
    function wy0(L, O) {
      if (F8 !== null && typeof F8.markForceUpdateScheduled === "function")
        F8.markForceUpdateScheduled(L, O);
    }
    function Kd(L, O) {
      if (F8 !== null && typeof F8.markStateUpdateScheduled === "function")
        F8.markStateUpdateScheduled(L, O);
    }
    var N6 = 0, W9 = 1, U7 = 2, Y$ = 8, sH = 16, P90 = Math.clz32 ? Math.clz32 : _y0, jy0 = Math.log, Ty0 = Math.LN2;
    function _y0(L) {
      var O = L >>> 0;
      if (O === 0)
        return 32;
      return 31 - (jy0(O) / Ty0 | 0) | 0;
    }
    var Gd = 31, T2 = 0, eX = 0, n6 = 1, c4 = 2, $F = 4, ZO = 8, aH = 16, iw = 32, l4 = 4194240, ow = 64, Hd = 128, Nd = 256, qd = 512, Fd = 1024, Ud = 2048, Ld = 4096, Rd = 8192, Ed = 16384, Od = 32768, zd = 65536, Dd = 131072, Md = 262144, Ad = 524288, Bd = 1048576, wd = 2097152, aP = 130023424, n4 = 4194304, jd = 8388608, Td = 16777216, _d = 33554432, Vd = 67108864, C90 = n4, sw = 134217728, k90 = 268435455, aw = 268435456, JO = 536870912, i5 = 1073741824;
    function Vy0(L) {
      {
        if (L & n6)
          return "Sync";
        if (L & c4)
          return "InputContinuousHydration";
        if (L & $F)
          return "InputContinuous";
        if (L & ZO)
          return "DefaultHydration";
        if (L & aH)
          return "Default";
        if (L & iw)
          return "TransitionHydration";
        if (L & l4)
          return "Transition";
        if (L & aP)
          return "Retry";
        if (L & sw)
          return "SelectiveHydration";
        if (L & aw)
          return "IdleHydration";
        if (L & JO)
          return "Idle";
        if (L & i5)
          return "Offscreen";
      }
    }
    var s7 = -1, rP = ow, tP = n4;
    function rw(L) {
      switch ($O(L)) {
        case n6:
          return n6;
        case c4:
          return c4;
        case $F:
          return $F;
        case ZO:
          return ZO;
        case aH:
          return aH;
        case iw:
          return iw;
        case ow:
        case Hd:
        case Nd:
        case qd:
        case Fd:
        case Ud:
        case Ld:
        case Rd:
        case Ed:
        case Od:
        case zd:
        case Dd:
        case Md:
        case Ad:
        case Bd:
        case wd:
          return L & l4;
        case n4:
        case jd:
        case Td:
        case _d:
        case Vd:
          return L & aP;
        case sw:
          return sw;
        case aw:
          return aw;
        case JO:
          return JO;
        case i5:
          return i5;
        default:
          return Y("Should have found matching lanes. This is a bug in React."), L;
      }
    }
    function eP(L, O) {
      var _ = L.pendingLanes;
      if (_ === T2)
        return T2;
      var k = T2, y = L.suspendedLanes, d = L.pingedLanes, o = _ & k90;
      if (o !== T2) {
        var H0 = o & ~y;
        if (H0 !== T2)
          k = rw(H0);
        else {
          var O0 = o & d;
          if (O0 !== T2)
            k = rw(O0);
        }
      } else {
        var I0 = _ & ~y;
        if (I0 !== T2)
          k = rw(I0);
        else if (d !== T2)
          k = rw(d);
      }
      if (k === T2)
        return T2;
      if (O !== T2 && O !== k && (O & y) === T2) {
        var g0 = $O(k), R1 = $O(O);
        if (g0 >= R1 || g0 === aH && (R1 & l4) !== T2)
          return O;
      }
      if ((k & $F) !== T2)
        k |= _ & aH;
      var U1 = L.entangledLanes;
      if (U1 !== T2) {
        var x1 = L.entanglements, y1 = k & U1;
        while (y1 > 0) {
          var r1 = XO(y1), Q8 = 1 << r1;
          k |= x1[r1], y1 &= ~Q8;
        }
      }
      return k;
    }
    function Iy0(L, O) {
      var _ = L.eventTimes, k = s7;
      while (O > 0) {
        var y = XO(O), d = 1 << y, o = _[y];
        if (o > k)
          k = o;
        O &= ~d;
      }
      return k;
    }
    function Py0(L, O) {
      switch (L) {
        case n6:
        case c4:
        case $F:
          return O + 250;
        case ZO:
        case aH:
        case iw:
        case ow:
        case Hd:
        case Nd:
        case qd:
        case Fd:
        case Ud:
        case Ld:
        case Rd:
        case Ed:
        case Od:
        case zd:
        case Dd:
        case Md:
        case Ad:
        case Bd:
        case wd:
          return O + 5000;
        case n4:
        case jd:
        case Td:
        case _d:
        case Vd:
          return s7;
        case sw:
        case aw:
        case JO:
        case i5:
          return s7;
        default:
          return Y("Should have found matching lanes. This is a bug in React."), s7;
      }
    }
    function Cy0(L, O) {
      var { pendingLanes: _, suspendedLanes: k, pingedLanes: y, expirationTimes: d } = L, o = _;
      while (o > 0) {
        var H0 = XO(o), O0 = 1 << H0, I0 = d[H0];
        if (I0 === s7) {
          if ((O0 & k) === T2 || (O0 & y) !== T2)
            d[H0] = Py0(O0, O);
        } else if (I0 <= O)
          L.expiredLanes |= O0;
        o &= ~O0;
      }
    }
    function ky0(L) {
      return rw(L.pendingLanes);
    }
    function Id(L) {
      var O = L.pendingLanes & ~i5;
      if (O !== T2)
        return O;
      if (O & i5)
        return i5;
      return T2;
    }
    function vy0(L) {
      return (L & n6) !== T2;
    }
    function Pd(L) {
      return (L & k90) !== T2;
    }
    function v90(L) {
      return (L & aP) === L;
    }
    function Sy0(L) {
      var O = n6 | $F | aH;
      return (L & O) === T2;
    }
    function fy0(L) {
      return (L & l4) === L;
    }
    function ZC(L, O) {
      var _ = c4 | $F | ZO | aH;
      return (O & _) !== T2;
    }
    function hy0(L, O) {
      return (O & L.expiredLanes) !== T2;
    }
    function S90(L) {
      return (L & l4) !== T2;
    }
    function f90() {
      var L = rP;
      if (rP <<= 1, (rP & l4) === T2)
        rP = ow;
      return L;
    }
    function by0() {
      var L = tP;
      if (tP <<= 1, (tP & aP) === T2)
        tP = n4;
      return L;
    }
    function $O(L) {
      return L & -L;
    }
    function tw(L) {
      return $O(L);
    }
    function XO(L) {
      return 31 - P90(L);
    }
    function Cd(L) {
      return XO(L);
    }
    function o5(L, O) {
      return (L & O) !== T2;
    }
    function i4(L, O) {
      return (L & O) === O;
    }
    function BZ(L, O) {
      return L | O;
    }
    function JC(L, O) {
      return L & ~O;
    }
    function h90(L, O) {
      return L & O;
    }
    function $C(L) {
      return L;
    }
    function xy0(L, O) {
      return L !== eX && L < O ? L : O;
    }
    function kd(L) {
      var O = [];
      for (var _ = 0;_ < Gd; _++)
        O.push(L);
      return O;
    }
    function ew(L, O, _) {
      if (L.pendingLanes |= O, O !== JO)
        L.suspendedLanes = T2, L.pingedLanes = T2;
      var k = L.eventTimes, y = Cd(O);
      k[y] = _;
    }
    function yy0(L, O) {
      L.suspendedLanes |= O, L.pingedLanes &= ~O;
      var _ = L.expirationTimes, k = O;
      while (k > 0) {
        var y = XO(k), d = 1 << y;
        _[y] = s7, k &= ~d;
      }
    }
    function b90(L, O, _) {
      L.pingedLanes |= L.suspendedLanes & O;
    }
    function gy0(L, O) {
      var _ = L.pendingLanes & ~O;
      L.pendingLanes = O, L.suspendedLanes = T2, L.pingedLanes = T2, L.expiredLanes &= O, L.mutableReadLanes &= O, L.entangledLanes &= O;
      var { entanglements: k, eventTimes: y, expirationTimes: d } = L, o = _;
      while (o > 0) {
        var H0 = XO(o), O0 = 1 << H0;
        k[H0] = T2, y[H0] = s7, d[H0] = s7, o &= ~O0;
      }
    }
    function vd(L, O) {
      var _ = L.entangledLanes |= O, k = L.entanglements, y = _;
      while (y) {
        var d = XO(y), o = 1 << d;
        if (o & O | k[d] & O)
          k[d] |= O;
        y &= ~o;
      }
    }
    function my0(L, O) {
      var _ = $O(O), k;
      switch (_) {
        case $F:
          k = c4;
          break;
        case aH:
          k = ZO;
          break;
        case ow:
        case Hd:
        case Nd:
        case qd:
        case Fd:
        case Ud:
        case Ld:
        case Rd:
        case Ed:
        case Od:
        case zd:
        case Dd:
        case Md:
        case Ad:
        case Bd:
        case wd:
        case n4:
        case jd:
        case Td:
        case _d:
        case Vd:
          k = iw;
          break;
        case JO:
          k = aw;
          break;
        default:
          k = eX;
          break;
      }
      if ((k & (L.suspendedLanes | O)) !== eX)
        return eX;
      return k;
    }
    function x90(L, O, _) {
      if (!VG)
        return;
      var k = L.pendingUpdatersLaneMap;
      while (_ > 0) {
        var y = Cd(_), d = 1 << y, o = k[y];
        o.add(O), _ &= ~d;
      }
    }
    function y90(L, O) {
      if (!VG)
        return;
      var { pendingUpdatersLaneMap: _, memoizedUpdaters: k } = L;
      while (O > 0) {
        var y = Cd(O), d = 1 << y, o = _[y];
        if (o.size > 0)
          o.forEach(function(H0) {
            var O0 = H0.alternate;
            if (O0 === null || !k.has(O0))
              k.add(H0);
          }), o.clear();
        O &= ~d;
      }
    }
    function g90(L, O) {
      return null;
    }
    var s5 = n6, XF = $F, YF = aH, XC = JO, Zj = eX;
    function IG() {
      return Zj;
    }
    function ZY(L) {
      Zj = L;
    }
    function dy0(L, O) {
      var _ = Zj;
      try {
        return Zj = L, O();
      } finally {
        Zj = _;
      }
    }
    function py0(L, O) {
      return L !== 0 && L < O ? L : O;
    }
    function uy0(L, O) {
      return L === 0 || L > O ? L : O;
    }
    function Sd(L, O) {
      return L !== 0 && L < O;
    }
    function m90(L) {
      var O = $O(L);
      if (!Sd(s5, O))
        return s5;
      if (!Sd(XF, O))
        return XF;
      if (Pd(O))
        return YF;
      return XC;
    }
    function YC(L) {
      var O = L.current.memoizedState;
      return O.isDehydrated;
    }
    var d90;
    function cy0(L) {
      d90 = L;
    }
    function ly0(L) {
      d90(L);
    }
    var fd;
    function ny0(L) {
      fd = L;
    }
    var p90;
    function iy0(L) {
      p90 = L;
    }
    var u90;
    function oy0(L) {
      u90 = L;
    }
    var c90;
    function sy0(L) {
      c90 = L;
    }
    var hd = !1, QC = [], dU = null, pU = null, uU = null, Jj = /* @__PURE__ */ new Map, $j = /* @__PURE__ */ new Map, cU = [], ay0 = [
      "mousedown",
      "mouseup",
      "touchcancel",
      "touchend",
      "touchstart",
      "auxclick",
      "dblclick",
      "pointercancel",
      "pointerdown",
      "pointerup",
      "dragend",
      "dragstart",
      "drop",
      "compositionend",
      "compositionstart",
      "keydown",
      "keypress",
      "keyup",
      "input",
      "textInput",
      "copy",
      "cut",
      "paste",
      "click",
      "change",
      "contextmenu",
      "reset",
      "submit"
    ];
    function ry0(L) {
      return ay0.indexOf(L) > -1;
    }
    function ty0(L, O, _, k, y) {
      return {
        blockedOn: L,
        domEventName: O,
        eventSystemFlags: _,
        nativeEvent: y,
        targetContainers: [k]
      };
    }
    function l90(L, O) {
      switch (L) {
        case "focusin":
        case "focusout":
          dU = null;
          break;
        case "dragenter":
        case "dragleave":
          pU = null;
          break;
        case "mouseover":
        case "mouseout":
          uU = null;
          break;
        case "pointerover":
        case "pointerout": {
          var _ = O.pointerId;
          Jj.delete(_);
          break;
        }
        case "gotpointercapture":
        case "lostpointercapture": {
          var k = O.pointerId;
          $j.delete(k);
          break;
        }
      }
    }
    function Xj(L, O, _, k, y, d) {
      if (L === null || L.nativeEvent !== d) {
        var o = ty0(O, _, k, y, d);
        if (O !== null) {
          var H0 = iU(O);
          if (H0 !== null)
            fd(H0);
        }
        return o;
      }
      L.eventSystemFlags |= k;
      var O0 = L.targetContainers;
      if (y !== null && O0.indexOf(y) === -1)
        O0.push(y);
      return L;
    }
    function ey0(L, O, _, k, y) {
      switch (O) {
        case "focusin": {
          var d = y;
          return dU = Xj(dU, L, O, _, k, d), !0;
        }
        case "dragenter": {
          var o = y;
          return pU = Xj(pU, L, O, _, k, o), !0;
        }
        case "mouseover": {
          var H0 = y;
          return uU = Xj(uU, L, O, _, k, H0), !0;
        }
        case "pointerover": {
          var O0 = y, I0 = O0.pointerId;
          return Jj.set(I0, Xj(Jj.get(I0) || null, L, O, _, k, O0)), !0;
        }
        case "gotpointercapture": {
          var g0 = y, R1 = g0.pointerId;
          return $j.set(R1, Xj($j.get(R1) || null, L, O, _, k, g0)), !0;
        }
      }
      return !1;
    }
    function n90(L) {
      var O = WO(L.target);
      if (O !== null) {
        var _ = rE(O);
        if (_ !== null) {
          var k = _.tag;
          if (k === B) {
            var y = E90(_);
            if (y !== null) {
              L.blockedOn = y, c90(L.priority, function() {
                p90(_);
              });
              return;
            }
          } else if (k === H) {
            var d = _.stateNode;
            if (YC(d)) {
              L.blockedOn = O90(_);
              return;
            }
          }
        }
      }
      L.blockedOn = null;
    }
    function Zg0(L) {
      var O = u90(), _ = {
        blockedOn: null,
        target: L,
        priority: O
      }, k = 0;
      for (;k < cU.length; k++)
        if (!Sd(O, cU[k].priority))
          break;
      if (cU.splice(k, 0, _), k === 0)
        n90(_);
    }
    function WC(L) {
      if (L.blockedOn !== null)
        return !1;
      var O = L.targetContainers;
      while (O.length > 0) {
        var _ = O[0], k = yd(L.domEventName, L.eventSystemFlags, _, L.nativeEvent);
        if (k === null) {
          var y = L.nativeEvent, d = new y.constructor(y.type, y);
          _x0(d), y.target.dispatchEvent(d), Vx0();
        } else {
          var o = iU(k);
          if (o !== null)
            fd(o);
          return L.blockedOn = k, !1;
        }
        O.shift();
      }
      return !0;
    }
    function i90(L, O, _) {
      if (WC(L))
        _.delete(O);
    }
    function Jg0() {
      if (hd = !1, dU !== null && WC(dU))
        dU = null;
      if (pU !== null && WC(pU))
        pU = null;
      if (uU !== null && WC(uU))
        uU = null;
      Jj.forEach(i90), $j.forEach(i90);
    }
    function Yj(L, O) {
      if (L.blockedOn === O) {
        if (L.blockedOn = null, !hd)
          hd = !0, E7.unstable_scheduleCallback(E7.unstable_NormalPriority, Jg0);
      }
    }
    function Qj(L) {
      if (QC.length > 0) {
        Yj(QC[0], L);
        for (var O = 1;O < QC.length; O++) {
          var _ = QC[O];
          if (_.blockedOn === L)
            _.blockedOn = null;
        }
      }
      if (dU !== null)
        Yj(dU, L);
      if (pU !== null)
        Yj(pU, L);
      if (uU !== null)
        Yj(uU, L);
      var k = function(H0) {
        return Yj(H0, L);
      };
      Jj.forEach(k), $j.forEach(k);
      for (var y = 0;y < cU.length; y++) {
        var d = cU[y];
        if (d.blockedOn === L)
          d.blockedOn = null;
      }
      while (cU.length > 0) {
        var o = cU[0];
        if (o.blockedOn !== null)
          break;
        else if (n90(o), o.blockedOn === null)
          cU.shift();
      }
    }
    var o4 = Z.ReactCurrentBatchConfig, bd = !0;
    function o90(L) {
      bd = !!L;
    }
    function $g0() {
      return bd;
    }
    function Xg0(L, O, _) {
      var k = s90(O), y;
      switch (k) {
        case s5:
          y = Yg0;
          break;
        case XF:
          y = Qg0;
          break;
        case YF:
        default:
          y = xd;
          break;
      }
      return y.bind(null, O, _, L);
    }
    function Yg0(L, O, _, k) {
      var y = IG(), d = o4.transition;
      o4.transition = null;
      try {
        ZY(s5), xd(L, O, _, k);
      } finally {
        ZY(y), o4.transition = d;
      }
    }
    function Qg0(L, O, _, k) {
      var y = IG(), d = o4.transition;
      o4.transition = null;
      try {
        ZY(XF), xd(L, O, _, k);
      } finally {
        ZY(y), o4.transition = d;
      }
    }
    function xd(L, O, _, k) {
      if (!bd)
        return;
      Wg0(L, O, _, k);
    }
    function Wg0(L, O, _, k) {
      var y = yd(L, O, _, k);
      if (y === null) {
        td(L, O, k, KC, _), l90(L, k);
        return;
      }
      if (ey0(y, L, O, _, k)) {
        k.stopPropagation();
        return;
      }
      if (l90(L, k), O & gw && ry0(L)) {
        while (y !== null) {
          var d = iU(y);
          if (d !== null)
            ly0(d);
          var o = yd(L, O, _, k);
          if (o === null)
            td(L, O, k, KC, _);
          if (o === y)
            break;
          y = o;
        }
        if (y !== null)
          k.stopPropagation();
        return;
      }
      td(L, O, k, null, _);
    }
    var KC = null;
    function yd(L, O, _, k) {
      KC = null;
      var y = lm(k), d = WO(y);
      if (d !== null) {
        var o = rE(d);
        if (o === null)
          d = null;
        else {
          var H0 = o.tag;
          if (H0 === B) {
            var O0 = E90(o);
            if (O0 !== null)
              return O0;
            d = null;
          } else if (H0 === H) {
            var I0 = o.stateNode;
            if (YC(I0))
              return O90(o);
            d = null;
          } else if (o !== d)
            d = null;
        }
      }
      return KC = d, null;
    }
    function s90(L) {
      switch (L) {
        case "cancel":
        case "click":
        case "close":
        case "contextmenu":
        case "copy":
        case "cut":
        case "auxclick":
        case "dblclick":
        case "dragend":
        case "dragstart":
        case "drop":
        case "focusin":
        case "focusout":
        case "input":
        case "invalid":
        case "keydown":
        case "keypress":
        case "keyup":
        case "mousedown":
        case "mouseup":
        case "paste":
        case "pause":
        case "play":
        case "pointercancel":
        case "pointerdown":
        case "pointerup":
        case "ratechange":
        case "reset":
        case "resize":
        case "seeked":
        case "submit":
        case "touchcancel":
        case "touchend":
        case "touchstart":
        case "volumechange":
        case "change":
        case "selectionchange":
        case "textInput":
        case "compositionstart":
        case "compositionend":
        case "compositionupdate":
        case "beforeblur":
        case "afterblur":
        case "beforeinput":
        case "blur":
        case "fullscreenchange":
        case "focus":
        case "hashchange":
        case "popstate":
        case "select":
        case "selectstart":
          return s5;
        case "drag":
        case "dragenter":
        case "dragexit":
        case "dragleave":
        case "dragover":
        case "mousemove":
        case "mouseout":
        case "mouseover":
        case "pointermove":
        case "pointerout":
        case "pointerover":
        case "scroll":
        case "toggle":
        case "touchmove":
        case "wheel":
        case "mouseenter":
        case "mouseleave":
        case "pointerenter":
        case "pointerleave":
          return XF;
        case "message": {
          var O = rx0();
          switch (O) {
            case sP:
              return s5;
            case Qd:
              return XF;
            case tE:
            case tx0:
              return YF;
            case Wd:
              return XC;
            default:
              return YF;
          }
        }
        default:
          return YF;
      }
    }
    function Kg0(L, O, _) {
      return L.addEventListener(O, _, !1), _;
    }
    function Gg0(L, O, _) {
      return L.addEventListener(O, _, !0), _;
    }
    function Hg0(L, O, _, k) {
      return L.addEventListener(O, _, {
        capture: !0,
        passive: k
      }), _;
    }
    function Ng0(L, O, _, k) {
      return L.addEventListener(O, _, {
        passive: k
      }), _;
    }
    var Wj = null, gd = null, Kj = null;
    function qg0(L) {
      return Wj = L, gd = r90(), !0;
    }
    function Fg0() {
      Wj = null, gd = null, Kj = null;
    }
    function a90() {
      if (Kj)
        return Kj;
      var L, O = gd, _ = O.length, k, y = r90(), d = y.length;
      for (L = 0;L < _; L++)
        if (O[L] !== y[L])
          break;
      var o = _ - L;
      for (k = 1;k <= o; k++)
        if (O[_ - k] !== y[d - k])
          break;
      var H0 = k > 1 ? 1 - k : void 0;
      return Kj = y.slice(L, H0), Kj;
    }
    function r90() {
      if ("value" in Wj)
        return Wj.value;
      return Wj.textContent;
    }
    function GC(L) {
      var O, _ = L.keyCode;
      if ("charCode" in L) {
        if (O = L.charCode, O === 0 && _ === 13)
          O = 13;
      } else
        O = _;
      if (O === 10)
        O = 13;
      if (O >= 32 || O === 13)
        return O;
      return 0;
    }
    function HC() {
      return !0;
    }
    function t90() {
      return !1;
    }
    function a5(L) {
      function O(_, k, y, d, o) {
        this._reactName = _, this._targetInst = y, this.type = k, this.nativeEvent = d, this.target = o, this.currentTarget = null;
        for (var H0 in L) {
          if (!L.hasOwnProperty(H0))
            continue;
          var O0 = L[H0];
          if (O0)
            this[H0] = O0(d);
          else
            this[H0] = d[H0];
        }
        var I0 = d.defaultPrevented != null ? d.defaultPrevented : d.returnValue === !1;
        if (I0)
          this.isDefaultPrevented = HC;
        else
          this.isDefaultPrevented = t90;
        return this.isPropagationStopped = t90, this;
      }
      return d0(O.prototype, {
        preventDefault: function() {
          this.defaultPrevented = !0;
          var _ = this.nativeEvent;
          if (!_)
            return;
          if (_.preventDefault)
            _.preventDefault();
          else if (typeof _.returnValue !== "unknown")
            _.returnValue = !1;
          this.isDefaultPrevented = HC;
        },
        stopPropagation: function() {
          var _ = this.nativeEvent;
          if (!_)
            return;
          if (_.stopPropagation)
            _.stopPropagation();
          else if (typeof _.cancelBubble !== "unknown")
            _.cancelBubble = !0;
          this.isPropagationStopped = HC;
        },
        persist: function() {},
        isPersistent: HC
      }), O;
    }
    var s4 = {
      eventPhase: 0,
      bubbles: 0,
      cancelable: 0,
      timeStamp: function(L) {
        return L.timeStamp || Date.now();
      },
      defaultPrevented: 0,
      isTrusted: 0
    }, md = a5(s4), Gj = d0({}, s4, {
      view: 0,
      detail: 0
    }), Ug0 = a5(Gj), dd, pd, Hj;
    function Lg0(L) {
      if (L !== Hj) {
        if (Hj && L.type === "mousemove")
          dd = L.screenX - Hj.screenX, pd = L.screenY - Hj.screenY;
        else
          dd = 0, pd = 0;
        Hj = L;
      }
    }
    var NC = d0({}, Gj, {
      screenX: 0,
      screenY: 0,
      clientX: 0,
      clientY: 0,
      pageX: 0,
      pageY: 0,
      ctrlKey: 0,
      shiftKey: 0,
      altKey: 0,
      metaKey: 0,
      getModifierState: cd,
      button: 0,
      buttons: 0,
      relatedTarget: function(L) {
        if (L.relatedTarget === void 0)
          return L.fromElement === L.srcElement ? L.toElement : L.fromElement;
        return L.relatedTarget;
      },
      movementX: function(L) {
        if ("movementX" in L)
          return L.movementX;
        return Lg0(L), dd;
      },
      movementY: function(L) {
        if ("movementY" in L)
          return L.movementY;
        return pd;
      }
    }), e90 = a5(NC), Rg0 = d0({}, NC, {
      dataTransfer: 0
    }), Eg0 = a5(Rg0), Og0 = d0({}, Gj, {
      relatedTarget: 0
    }), ud = a5(Og0), zg0 = d0({}, s4, {
      animationName: 0,
      elapsedTime: 0,
      pseudoElement: 0
    }), Dg0 = a5(zg0), Mg0 = d0({}, s4, {
      clipboardData: function(L) {
        return "clipboardData" in L ? L.clipboardData : window.clipboardData;
      }
    }), Ag0 = a5(Mg0), Bg0 = d0({}, s4, {
      data: 0
    }), Z70 = a5(Bg0), wg0 = Z70, jg0 = {
      Esc: "Escape",
      Spacebar: " ",
      Left: "ArrowLeft",
      Up: "ArrowUp",
      Right: "ArrowRight",
      Down: "ArrowDown",
      Del: "Delete",
      Win: "OS",
      Menu: "ContextMenu",
      Apps: "ContextMenu",
      Scroll: "ScrollLock",
      MozPrintableKey: "Unidentified"
    }, Tg0 = {
      "8": "Backspace",
      "9": "Tab",
      "12": "Clear",
      "13": "Enter",
      "16": "Shift",
      "17": "Control",
      "18": "Alt",
      "19": "Pause",
      "20": "CapsLock",
      "27": "Escape",
      "32": " ",
      "33": "PageUp",
      "34": "PageDown",
      "35": "End",
      "36": "Home",
      "37": "ArrowLeft",
      "38": "ArrowUp",
      "39": "ArrowRight",
      "40": "ArrowDown",
      "45": "Insert",
      "46": "Delete",
      "112": "F1",
      "113": "F2",
      "114": "F3",
      "115": "F4",
      "116": "F5",
      "117": "F6",
      "118": "F7",
      "119": "F8",
      "120": "F9",
      "121": "F10",
      "122": "F11",
      "123": "F12",
      "144": "NumLock",
      "145": "ScrollLock",
      "224": "Meta"
    };
    function _g0(L) {
      if (L.key) {
        var O = jg0[L.key] || L.key;
        if (O !== "Unidentified")
          return O;
      }
      if (L.type === "keypress") {
        var _ = GC(L);
        return _ === 13 ? "Enter" : String.fromCharCode(_);
      }
      if (L.type === "keydown" || L.type === "keyup")
        return Tg0[L.keyCode] || "Unidentified";
      return "";
    }
    var Vg0 = {
      Alt: "altKey",
      Control: "ctrlKey",
      Meta: "metaKey",
      Shift: "shiftKey"
    };
    function Ig0(L) {
      var O = this, _ = O.nativeEvent;
      if (_.getModifierState)
        return _.getModifierState(L);
      var k = Vg0[L];
      return k ? !!_[k] : !1;
    }
    function cd(L) {
      return Ig0;
    }
    var Pg0 = d0({}, Gj, {
      key: _g0,
      code: 0,
      location: 0,
      ctrlKey: 0,
      shiftKey: 0,
      altKey: 0,
      metaKey: 0,
      repeat: 0,
      locale: 0,
      getModifierState: cd,
      charCode: function(L) {
        if (L.type === "keypress")
          return GC(L);
        return 0;
      },
      keyCode: function(L) {
        if (L.type === "keydown" || L.type === "keyup")
          return L.keyCode;
        return 0;
      },
      which: function(L) {
        if (L.type === "keypress")
          return GC(L);
        if (L.type === "keydown" || L.type === "keyup")
          return L.keyCode;
        return 0;
      }
    }), Cg0 = a5(Pg0), kg0 = d0({}, NC, {
      pointerId: 0,
      width: 0,
      height: 0,
      pressure: 0,
      tangentialPressure: 0,
      tiltX: 0,
      tiltY: 0,
      twist: 0,
      pointerType: 0,
      isPrimary: 0
    }), J70 = a5(kg0), vg0 = d0({}, Gj, {
      touches: 0,
      targetTouches: 0,
      changedTouches: 0,
      altKey: 0,
      metaKey: 0,
      ctrlKey: 0,
      shiftKey: 0,
      getModifierState: cd
    }), Sg0 = a5(vg0), fg0 = d0({}, s4, {
      propertyName: 0,
      elapsedTime: 0,
      pseudoElement: 0
    }), hg0 = a5(fg0), bg0 = d0({}, NC, {
      deltaX: function(L) {
        return "deltaX" in L ? L.deltaX : ("wheelDeltaX" in L) ? -L.wheelDeltaX : 0;
      },
      deltaY: function(L) {
        return "deltaY" in L ? L.deltaY : ("wheelDeltaY" in L) ? -L.wheelDeltaY : ("wheelDelta" in L) ? -L.wheelDelta : 0;
      },
      deltaZ: 0,
      deltaMode: 0
    }), xg0 = a5(bg0), yg0 = [9, 13, 27, 32], $70 = 229, ld = $0 && "CompositionEvent" in window, Nj = null;
    if ($0 && "documentMode" in document)
      Nj = document.documentMode;
    var gg0 = $0 && "TextEvent" in window && !Nj, X70 = $0 && (!ld || Nj && Nj > 8 && Nj <= 11), Y70 = 32, Q70 = String.fromCharCode(Y70);
    function mg0() {
      a("onBeforeInput", ["compositionend", "keypress", "textInput", "paste"]), a("onCompositionEnd", ["compositionend", "focusout", "keydown", "keypress", "keyup", "mousedown"]), a("onCompositionStart", ["compositionstart", "focusout", "keydown", "keypress", "keyup", "mousedown"]), a("onCompositionUpdate", ["compositionupdate", "focusout", "keydown", "keypress", "keyup", "mousedown"]);
    }
    var W70 = !1;
    function dg0(L) {
      return (L.ctrlKey || L.altKey || L.metaKey) && !(L.ctrlKey && L.altKey);
    }
    function pg0(L) {
      switch (L) {
        case "compositionstart":
          return "onCompositionStart";
        case "compositionend":
          return "onCompositionEnd";
        case "compositionupdate":
          return "onCompositionUpdate";
      }
    }
    function ug0(L, O) {
      return L === "keydown" && O.keyCode === $70;
    }
    function K70(L, O) {
      switch (L) {
        case "keyup":
          return yg0.indexOf(O.keyCode) !== -1;
        case "keydown":
          return O.keyCode !== $70;
        case "keypress":
        case "mousedown":
        case "focusout":
          return !0;
        default:
          return !1;
      }
    }
    function G70(L) {
      var O = L.detail;
      if (typeof O === "object" && "data" in O)
        return O.data;
      return null;
    }
    function H70(L) {
      return L.locale === "ko";
    }
    var a4 = !1;
    function cg0(L, O, _, k, y) {
      var d, o;
      if (ld)
        d = pg0(O);
      else if (!a4) {
        if (ug0(O, k))
          d = "onCompositionStart";
      } else if (K70(O, k))
        d = "onCompositionEnd";
      if (!d)
        return null;
      if (X70 && !H70(k)) {
        if (!a4 && d === "onCompositionStart")
          a4 = qg0(y);
        else if (d === "onCompositionEnd") {
          if (a4)
            o = a90();
        }
      }
      var H0 = RC(_, d);
      if (H0.length > 0) {
        var O0 = new Z70(d, O, null, k, y);
        if (L.push({
          event: O0,
          listeners: H0
        }), o)
          O0.data = o;
        else {
          var I0 = G70(k);
          if (I0 !== null)
            O0.data = I0;
        }
      }
    }
    function lg0(L, O) {
      switch (L) {
        case "compositionend":
          return G70(O);
        case "keypress":
          var _ = O.which;
          if (_ !== Y70)
            return null;
          return W70 = !0, Q70;
        case "textInput":
          var k = O.data;
          if (k === Q70 && W70)
            return null;
          return k;
        default:
          return null;
      }
    }
    function ng0(L, O) {
      if (a4) {
        if (L === "compositionend" || !ld && K70(L, O)) {
          var _ = a90();
          return Fg0(), a4 = !1, _;
        }
        return null;
      }
      switch (L) {
        case "paste":
          return null;
        case "keypress":
          if (!dg0(O)) {
            if (O.char && O.char.length > 1)
              return O.char;
            else if (O.which)
              return String.fromCharCode(O.which);
          }
          return null;
        case "compositionend":
          return X70 && !H70(O) ? null : O.data;
        default:
          return null;
      }
    }
    function ig0(L, O, _, k, y) {
      var d;
      if (gg0)
        d = lg0(O, k);
      else
        d = ng0(O, k);
      if (!d)
        return null;
      var o = RC(_, "onBeforeInput");
      if (o.length > 0) {
        var H0 = new wg0("onBeforeInput", "beforeinput", null, k, y);
        L.push({
          event: H0,
          listeners: o
        }), H0.data = d;
      }
    }
    function og0(L, O, _, k, y, d, o) {
      cg0(L, O, _, k, y), ig0(L, O, _, k, y);
    }
    var sg0 = {
      color: !0,
      date: !0,
      datetime: !0,
      "datetime-local": !0,
      email: !0,
      month: !0,
      number: !0,
      password: !0,
      range: !0,
      search: !0,
      tel: !0,
      text: !0,
      time: !0,
      url: !0,
      week: !0
    };
    function N70(L) {
      var O = L && L.nodeName && L.nodeName.toLowerCase();
      if (O === "input")
        return !!sg0[L.type];
      if (O === "textarea")
        return !0;
      return !1;
    }
    function ag0(L) {
      if (!$0)
        return !1;
      var O = "on" + L, _ = O in document;
      if (!_) {
        var k = document.createElement("div");
        k.setAttribute(O, "return;"), _ = typeof k[O] === "function";
      }
      return _;
    }
    function rg0() {
      a("onChange", ["change", "click", "focusin", "focusout", "input", "keydown", "keyup", "selectionchange"]);
    }
    function q70(L, O, _, k) {
      G90(k);
      var y = RC(O, "onChange");
      if (y.length > 0) {
        var d = new md("onChange", "change", null, _, k);
        L.push({
          event: d,
          listeners: y
        });
      }
    }
    var qj = null, Fj = null;
    function tg0(L) {
      var O = L.nodeName && L.nodeName.toLowerCase();
      return O === "select" || O === "input" && L.type === "file";
    }
    function eg0(L) {
      var O = [];
      q70(O, Fj, L, lm(L)), F90(Zm0, O);
    }
    function Zm0(L) {
      P70(L, 0);
    }
    function qC(L) {
      var O = $D(L);
      if (v4(O))
        return L;
    }
    function Jm0(L, O) {
      if (L === "change")
        return O;
    }
    var F70 = !1;
    if ($0)
      F70 = ag0("input") && (!document.documentMode || document.documentMode > 9);
    function $m0(L, O) {
      qj = L, Fj = O, qj.attachEvent("onpropertychange", L70);
    }
    function U70() {
      if (!qj)
        return;
      qj.detachEvent("onpropertychange", L70), qj = null, Fj = null;
    }
    function L70(L) {
      if (L.propertyName !== "value")
        return;
      if (qC(Fj))
        eg0(L);
    }
    function Xm0(L, O, _) {
      if (L === "focusin")
        U70(), $m0(O, _);
      else if (L === "focusout")
        U70();
    }
    function Ym0(L, O) {
      if (L === "selectionchange" || L === "keyup" || L === "keydown")
        return qC(Fj);
    }
    function Qm0(L) {
      var O = L.nodeName;
      return O && O.toLowerCase() === "input" && (L.type === "checkbox" || L.type === "radio");
    }
    function Wm0(L, O) {
      if (L === "click")
        return qC(O);
    }
    function Km0(L, O) {
      if (L === "input" || L === "change")
        return qC(O);
    }
    function Gm0(L) {
      var O = L._wrapperState;
      if (!O || !O.controlled || L.type !== "number")
        return;
      l6(L, "number", L.value);
    }
    function Hm0(L, O, _, k, y, d, o) {
      var H0 = _ ? $D(_) : window, O0, I0;
      if (tg0(H0))
        O0 = Jm0;
      else if (N70(H0))
        if (F70)
          O0 = Km0;
        else
          O0 = Ym0, I0 = Xm0;
      else if (Qm0(H0))
        O0 = Wm0;
      if (O0) {
        var g0 = O0(O, _);
        if (g0) {
          q70(L, g0, k, y);
          return;
        }
      }
      if (I0)
        I0(O, H0, _);
      if (O === "focusout")
        Gm0(H0);
    }
    function Nm0() {
      Q0("onMouseEnter", ["mouseout", "mouseover"]), Q0("onMouseLeave", ["mouseout", "mouseover"]), Q0("onPointerEnter", ["pointerout", "pointerover"]), Q0("onPointerLeave", ["pointerout", "pointerover"]);
    }
    function qm0(L, O, _, k, y, d, o) {
      var H0 = O === "mouseover" || O === "pointerover", O0 = O === "mouseout" || O === "pointerout";
      if (H0 && !Ix0(k)) {
        var I0 = k.relatedTarget || k.fromElement;
        if (I0) {
          if (WO(I0) || Vj(I0))
            return;
        }
      }
      if (!O0 && !H0)
        return;
      var g0;
      if (y.window === y)
        g0 = y;
      else {
        var R1 = y.ownerDocument;
        if (R1)
          g0 = R1.defaultView || R1.parentWindow;
        else
          g0 = window;
      }
      var U1, x1;
      if (O0) {
        var y1 = k.relatedTarget || k.toElement;
        if (U1 = _, x1 = y1 ? WO(y1) : null, x1 !== null) {
          var r1 = rE(x1);
          if (x1 !== r1 || x1.tag !== q && x1.tag !== U)
            x1 = null;
        }
      } else
        U1 = null, x1 = _;
      if (U1 === x1)
        return;
      var Q8 = e90, J6 = "onMouseLeave", b8 = "onMouseEnter", oZ = "mouse";
      if (O === "pointerout" || O === "pointerover")
        Q8 = J70, J6 = "onPointerLeave", b8 = "onPointerEnter", oZ = "pointer";
      var sZ = U1 == null ? g0 : $D(U1), C1 = x1 == null ? g0 : $D(x1), Y2 = new Q8(J6, oZ + "leave", U1, k, y);
      Y2.target = sZ, Y2.relatedTarget = C1;
      var k1 = null, k2 = WO(y);
      if (k2 === _) {
        var z8 = new Q8(b8, oZ + "enter", x1, k, y);
        z8.target = C1, z8.relatedTarget = sZ, k1 = z8;
      }
      hm0(L, Y2, k1, U1, x1);
    }
    function Fm0(L, O) {
      return L === O && (L !== 0 || 1 / L === 1 / O) || L !== L && O !== O;
    }
    var r5 = typeof Object.is === "function" ? Object.is : Fm0;
    function Uj(L, O) {
      if (r5(L, O))
        return !0;
      if (typeof L !== "object" || L === null || typeof O !== "object" || O === null)
        return !1;
      var _ = Object.keys(L), k = Object.keys(O);
      if (_.length !== k.length)
        return !1;
      for (var y = 0;y < _.length; y++) {
        var d = _[y];
        if (!R0.call(O, d) || !r5(L[d], O[d]))
          return !1;
      }
      return !0;
    }
    function R70(L) {
      while (L && L.firstChild)
        L = L.firstChild;
      return L;
    }
    function Um0(L) {
      while (L) {
        if (L.nextSibling)
          return L.nextSibling;
        L = L.parentNode;
      }
    }
    function E70(L, O) {
      var _ = R70(L), k = 0, y = 0;
      while (_) {
        if (_.nodeType === aq) {
          if (y = k + _.textContent.length, k <= O && y >= O)
            return {
              node: _,
              offset: O - k
            };
          k = y;
        }
        _ = R70(Um0(_));
      }
    }
    function Lm0(L) {
      var O = L.ownerDocument, _ = O && O.defaultView || window, k = _.getSelection && _.getSelection();
      if (!k || k.rangeCount === 0)
        return null;
      var { anchorNode: y, anchorOffset: d, focusNode: o, focusOffset: H0 } = k;
      try {
        y.nodeType, o.nodeType;
      } catch (O0) {
        return null;
      }
      return Rm0(L, y, d, o, H0);
    }
    function Rm0(L, O, _, k, y) {
      var d = 0, o = -1, H0 = -1, O0 = 0, I0 = 0, g0 = L, R1 = null;
      Z:
        while (!0) {
          var U1 = null;
          while (!0) {
            if (g0 === O && (_ === 0 || g0.nodeType === aq))
              o = d + _;
            if (g0 === k && (y === 0 || g0.nodeType === aq))
              H0 = d + y;
            if (g0.nodeType === aq)
              d += g0.nodeValue.length;
            if ((U1 = g0.firstChild) === null)
              break;
            R1 = g0, g0 = U1;
          }
          while (!0) {
            if (g0 === L)
              break Z;
            if (R1 === O && ++O0 === _)
              o = d;
            if (R1 === k && ++I0 === y)
              H0 = d;
            if ((U1 = g0.nextSibling) !== null)
              break;
            g0 = R1, R1 = g0.parentNode;
          }
          g0 = U1;
        }
      if (o === -1 || H0 === -1)
        return null;
      return {
        start: o,
        end: H0
      };
    }
    function Em0(L, O) {
      var _ = L.ownerDocument || document, k = _ && _.defaultView || window;
      if (!k.getSelection)
        return;
      var y = k.getSelection(), d = L.textContent.length, o = Math.min(O.start, d), H0 = O.end === void 0 ? o : Math.min(O.end, d);
      if (!y.extend && o > H0) {
        var O0 = H0;
        H0 = o, o = O0;
      }
      var I0 = E70(L, o), g0 = E70(L, H0);
      if (I0 && g0) {
        if (y.rangeCount === 1 && y.anchorNode === I0.node && y.anchorOffset === I0.offset && y.focusNode === g0.node && y.focusOffset === g0.offset)
          return;
        var R1 = _.createRange();
        if (R1.setStart(I0.node, I0.offset), y.removeAllRanges(), o > H0)
          y.addRange(R1), y.extend(g0.node, g0.offset);
        else
          R1.setEnd(g0.node, g0.offset), y.addRange(R1);
      }
    }
    function O70(L) {
      return L && L.nodeType === aq;
    }
    function z70(L, O) {
      if (!L || !O)
        return !1;
      else if (L === O)
        return !0;
      else if (O70(L))
        return !1;
      else if (O70(O))
        return z70(L, O.parentNode);
      else if ("contains" in L)
        return L.contains(O);
      else if (L.compareDocumentPosition)
        return !!(L.compareDocumentPosition(O) & 16);
      else
        return !1;
    }
    function Om0(L) {
      return L && L.ownerDocument && z70(L.ownerDocument.documentElement, L);
    }
    function zm0(L) {
      try {
        return typeof L.contentWindow.location.href === "string";
      } catch (O) {
        return !1;
      }
    }
    function D70() {
      var L = window, O = gU();
      while (O instanceof L.HTMLIFrameElement) {
        if (zm0(O))
          L = O.contentWindow;
        else
          return O;
        O = gU(L.document);
      }
      return O;
    }
    function nd(L) {
      var O = L && L.nodeName && L.nodeName.toLowerCase();
      return O && (O === "input" && (L.type === "text" || L.type === "search" || L.type === "tel" || L.type === "url" || L.type === "password") || O === "textarea" || L.contentEditable === "true");
    }
    function Dm0() {
      var L = D70();
      return {
        focusedElem: L,
        selectionRange: nd(L) ? Am0(L) : null
      };
    }
    function Mm0(L) {
      var O = D70(), _ = L.focusedElem, k = L.selectionRange;
      if (O !== _ && Om0(_)) {
        if (k !== null && nd(_))
          Bm0(_, k);
        var y = [], d = _;
        while (d = d.parentNode)
          if (d.nodeType === J5)
            y.push({
              element: d,
              left: d.scrollLeft,
              top: d.scrollTop
            });
        if (typeof _.focus === "function")
          _.focus();
        for (var o = 0;o < y.length; o++) {
          var H0 = y[o];
          H0.element.scrollLeft = H0.left, H0.element.scrollTop = H0.top;
        }
      }
    }
    function Am0(L) {
      var O;
      if ("selectionStart" in L)
        O = {
          start: L.selectionStart,
          end: L.selectionEnd
        };
      else
        O = Lm0(L);
      return O || {
        start: 0,
        end: 0
      };
    }
    function Bm0(L, O) {
      var { start: _, end: k } = O;
      if (k === void 0)
        k = _;
      if ("selectionStart" in L)
        L.selectionStart = _, L.selectionEnd = Math.min(k, L.value.length);
      else
        Em0(L, O);
    }
    var wm0 = $0 && "documentMode" in document && document.documentMode <= 11;
    function jm0() {
      a("onSelect", ["focusout", "contextmenu", "dragend", "focusin", "keydown", "keyup", "mousedown", "mouseup", "selectionchange"]);
    }
    var r4 = null, id = null, Lj = null, od = !1;
    function Tm0(L) {
      if ("selectionStart" in L && nd(L))
        return {
          start: L.selectionStart,
          end: L.selectionEnd
        };
      else {
        var O = L.ownerDocument && L.ownerDocument.defaultView || window, _ = O.getSelection();
        return {
          anchorNode: _.anchorNode,
          anchorOffset: _.anchorOffset,
          focusNode: _.focusNode,
          focusOffset: _.focusOffset
        };
      }
    }
    function _m0(L) {
      return L.window === L ? L.document : L.nodeType === rq ? L : L.ownerDocument;
    }
    function M70(L, O, _) {
      var k = _m0(_);
      if (od || r4 == null || r4 !== gU(k))
        return;
      var y = Tm0(r4);
      if (!Lj || !Uj(Lj, y)) {
        Lj = y;
        var d = RC(id, "onSelect");
        if (d.length > 0) {
          var o = new md("onSelect", "select", null, O, _);
          L.push({
            event: o,
            listeners: d
          }), o.target = r4;
        }
      }
    }
    function Vm0(L, O, _, k, y, d, o) {
      var H0 = _ ? $D(_) : window;
      switch (O) {
        case "focusin":
          if (N70(H0) || H0.contentEditable === "true")
            r4 = H0, id = _, Lj = null;
          break;
        case "focusout":
          r4 = null, id = null, Lj = null;
          break;
        case "mousedown":
          od = !0;
          break;
        case "contextmenu":
        case "mouseup":
        case "dragend":
          od = !1, M70(L, k, y);
          break;
        case "selectionchange":
          if (wm0)
            break;
        case "keydown":
        case "keyup":
          M70(L, k, y);
      }
    }
    function FC(L, O) {
      var _ = {};
      return _[L.toLowerCase()] = O.toLowerCase(), _["Webkit" + L] = "webkit" + O, _["Moz" + L] = "moz" + O, _;
    }
    var t4 = {
      animationend: FC("Animation", "AnimationEnd"),
      animationiteration: FC("Animation", "AnimationIteration"),
      animationstart: FC("Animation", "AnimationStart"),
      transitionend: FC("Transition", "TransitionEnd")
    }, sd = {}, A70 = {};
    if ($0) {
      if (A70 = document.createElement("div").style, !("AnimationEvent" in window))
        delete t4.animationend.animation, delete t4.animationiteration.animation, delete t4.animationstart.animation;
      if (!("TransitionEvent" in window))
        delete t4.transitionend.transition;
    }
    function UC(L) {
      if (sd[L])
        return sd[L];
      else if (!t4[L])
        return L;
      var O = t4[L];
      for (var _ in O)
        if (O.hasOwnProperty(_) && _ in A70)
          return sd[L] = O[_];
      return L;
    }
    var B70 = UC("animationend"), w70 = UC("animationiteration"), j70 = UC("animationstart"), T70 = UC("transitionend"), _70 = /* @__PURE__ */ new Map, V70 = ["abort", "auxClick", "cancel", "canPlay", "canPlayThrough", "click", "close", "contextMenu", "copy", "cut", "drag", "dragEnd", "dragEnter", "dragExit", "dragLeave", "dragOver", "dragStart", "drop", "durationChange", "emptied", "encrypted", "ended", "error", "gotPointerCapture", "input", "invalid", "keyDown", "keyPress", "keyUp", "load", "loadedData", "loadedMetadata", "loadStart", "lostPointerCapture", "mouseDown", "mouseMove", "mouseOut", "mouseOver", "mouseUp", "paste", "pause", "play", "playing", "pointerCancel", "pointerDown", "pointerMove", "pointerOut", "pointerOver", "pointerUp", "progress", "rateChange", "reset", "resize", "seeked", "seeking", "stalled", "submit", "suspend", "timeUpdate", "touchCancel", "touchEnd", "touchStart", "volumeChange", "scroll", "toggle", "touchMove", "waiting", "wheel"];
    function lU(L, O) {
      _70.set(L, O), a(O, [L]);
    }
    function Im0() {
      for (var L = 0;L < V70.length; L++) {
        var O = V70[L], _ = O.toLowerCase(), k = O[0].toUpperCase() + O.slice(1);
        lU(_, "on" + k);
      }
      lU(B70, "onAnimationEnd"), lU(w70, "onAnimationIteration"), lU(j70, "onAnimationStart"), lU("dblclick", "onDoubleClick"), lU("focusin", "onFocus"), lU("focusout", "onBlur"), lU(T70, "onTransitionEnd");
    }
    function Pm0(L, O, _, k, y, d, o) {
      var H0 = _70.get(O);
      if (H0 === void 0)
        return;
      var O0 = md, I0 = O;
      switch (O) {
        case "keypress":
          if (GC(k) === 0)
            return;
        case "keydown":
        case "keyup":
          O0 = Cg0;
          break;
        case "focusin":
          I0 = "focus", O0 = ud;
          break;
        case "focusout":
          I0 = "blur", O0 = ud;
          break;
        case "beforeblur":
        case "afterblur":
          O0 = ud;
          break;
        case "click":
          if (k.button === 2)
            return;
        case "auxclick":
        case "dblclick":
        case "mousedown":
        case "mousemove":
        case "mouseup":
        case "mouseout":
        case "mouseover":
        case "contextmenu":
          O0 = e90;
          break;
        case "drag":
        case "dragend":
        case "dragenter":
        case "dragexit":
        case "dragleave":
        case "dragover":
        case "dragstart":
        case "drop":
          O0 = Eg0;
          break;
        case "touchcancel":
        case "touchend":
        case "touchmove":
        case "touchstart":
          O0 = Sg0;
          break;
        case B70:
        case w70:
        case j70:
          O0 = Dg0;
          break;
        case T70:
          O0 = hg0;
          break;
        case "scroll":
          O0 = Ug0;
          break;
        case "wheel":
          O0 = xg0;
          break;
        case "copy":
        case "cut":
        case "paste":
          O0 = Ag0;
          break;
        case "gotpointercapture":
        case "lostpointercapture":
        case "pointercancel":
        case "pointerdown":
        case "pointermove":
        case "pointerout":
        case "pointerover":
        case "pointerup":
          O0 = J70;
          break;
      }
      var g0 = (d & gw) !== 0;
      {
        var R1 = !g0 && O === "scroll", U1 = Sm0(_, H0, k.type, g0, R1);
        if (U1.length > 0) {
          var x1 = new O0(H0, I0, null, k, y);
          L.push({
            event: x1,
            listeners: U1
          });
        }
      }
    }
    Im0(), Nm0(), rg0(), jm0(), mg0();
    function Cm0(L, O, _, k, y, d, o) {
      Pm0(L, O, _, k, y, d);
      var H0 = (d & Tx0) === 0;
      if (H0)
        qm0(L, O, _, k, y), Hm0(L, O, _, k, y), Vm0(L, O, _, k, y), og0(L, O, _, k, y);
    }
    var Rj = ["abort", "canplay", "canplaythrough", "durationchange", "emptied", "encrypted", "ended", "error", "loadeddata", "loadedmetadata", "loadstart", "pause", "play", "playing", "progress", "ratechange", "resize", "seeked", "seeking", "stalled", "suspend", "timeupdate", "volumechange", "waiting"], ad = new Set(["cancel", "close", "invalid", "load", "scroll", "toggle"].concat(Rj));
    function I70(L, O, _) {
      var k = L.type || "unknown-event";
      L.currentTarget = _, xx0(k, O, void 0, L), L.currentTarget = null;
    }
    function km0(L, O, _) {
      var k;
      if (_)
        for (var y = O.length - 1;y >= 0; y--) {
          var d = O[y], o = d.instance, H0 = d.currentTarget, O0 = d.listener;
          if (o !== k && L.isPropagationStopped())
            return;
          I70(L, O0, H0), k = o;
        }
      else
        for (var I0 = 0;I0 < O.length; I0++) {
          var g0 = O[I0], R1 = g0.instance, U1 = g0.currentTarget, x1 = g0.listener;
          if (R1 !== k && L.isPropagationStopped())
            return;
          I70(L, x1, U1), k = R1;
        }
    }
    function P70(L, O) {
      var _ = (O & gw) !== 0;
      for (var k = 0;k < L.length; k++) {
        var y = L[k], d = y.event, o = y.listeners;
        km0(d, o, _);
      }
      yx0();
    }
    function vm0(L, O, _, k, y) {
      var d = lm(_), o = [];
      Cm0(o, L, k, _, d, O), P70(o, O);
    }
    function HJ(L, O) {
      if (!ad.has(L))
        Y('Did not expect a listenToNonDelegatedEvent() call for "%s". This is a bug in React. Please file an issue.', L);
      var _ = !1, k = Gp0(O), y = bm0(L, _);
      if (!k.has(y))
        C70(O, L, cm, _), k.add(y);
    }
    function rd(L, O, _) {
      if (ad.has(L) && !O)
        Y('Did not expect a listenToNativeEvent() call for "%s" in the bubble phase. This is a bug in React. Please file an issue.', L);
      var k = 0;
      if (O)
        k |= gw;
      C70(_, L, k, O);
    }
    var LC = "_reactListening" + Math.random().toString(36).slice(2);
    function Ej(L) {
      if (!L[LC]) {
        L[LC] = !0, t.forEach(function(_) {
          if (_ !== "selectionchange") {
            if (!ad.has(_))
              rd(_, !1, L);
            rd(_, !0, L);
          }
        });
        var O = L.nodeType === rq ? L : L.ownerDocument;
        if (O !== null) {
          if (!O[LC])
            O[LC] = !0, rd("selectionchange", !1, O);
        }
      }
    }
    function C70(L, O, _, k, y) {
      var d = Xg0(L, O, _), o = void 0;
      if (om) {
        if (O === "touchstart" || O === "touchmove" || O === "wheel")
          o = !0;
      }
      L = L;
      var H0;
      if (k)
        if (o !== void 0)
          H0 = Hg0(L, O, d, o);
        else
          H0 = Gg0(L, O, d);
      else if (o !== void 0)
        H0 = Ng0(L, O, d, o);
      else
        H0 = Kg0(L, O, d);
    }
    function k70(L, O) {
      return L === O || L.nodeType === p$ && L.parentNode === O;
    }
    function td(L, O, _, k, y) {
      var d = k;
      if ((O & W90) === 0 && (O & cm) === 0) {
        var o = y;
        if (k !== null) {
          var H0 = k;
          Z:
            while (!0) {
              if (H0 === null)
                return;
              var O0 = H0.tag;
              if (O0 === H || O0 === N) {
                var I0 = H0.stateNode.containerInfo;
                if (k70(I0, o))
                  break;
                if (O0 === N) {
                  var g0 = H0.return;
                  while (g0 !== null) {
                    var R1 = g0.tag;
                    if (R1 === H || R1 === N) {
                      var U1 = g0.stateNode.containerInfo;
                      if (k70(U1, o))
                        return;
                    }
                    g0 = g0.return;
                  }
                }
                while (I0 !== null) {
                  var x1 = WO(I0);
                  if (x1 === null)
                    return;
                  var y1 = x1.tag;
                  if (y1 === q || y1 === U) {
                    H0 = d = x1;
                    continue Z;
                  }
                  I0 = I0.parentNode;
                }
              }
              H0 = H0.return;
            }
        }
      }
      F90(function() {
        return vm0(L, O, _, d);
      });
    }
    function Oj(L, O, _) {
      return {
        instance: L,
        listener: O,
        currentTarget: _
      };
    }
    function Sm0(L, O, _, k, y, d) {
      var o = O !== null ? O + "Capture" : null, H0 = k ? o : O, O0 = [], I0 = L, g0 = null;
      while (I0 !== null) {
        var R1 = I0, U1 = R1.stateNode, x1 = R1.tag;
        if (x1 === q && U1 !== null) {
          if (g0 = U1, H0 !== null) {
            var y1 = dw(I0, H0);
            if (y1 != null)
              O0.push(Oj(I0, y1, g0));
          }
        }
        if (y)
          break;
        I0 = I0.return;
      }
      return O0;
    }
    function RC(L, O) {
      var _ = O + "Capture", k = [], y = L;
      while (y !== null) {
        var d = y, o = d.stateNode, H0 = d.tag;
        if (H0 === q && o !== null) {
          var O0 = o, I0 = dw(y, _);
          if (I0 != null)
            k.unshift(Oj(y, I0, O0));
          var g0 = dw(y, O);
          if (g0 != null)
            k.push(Oj(y, g0, O0));
        }
        y = y.return;
      }
      return k;
    }
    function e4(L) {
      if (L === null)
        return null;
      do
        L = L.return;
      while (L && L.tag !== q);
      if (L)
        return L;
      return null;
    }
    function fm0(L, O) {
      var _ = L, k = O, y = 0;
      for (var d = _;d; d = e4(d))
        y++;
      var o = 0;
      for (var H0 = k;H0; H0 = e4(H0))
        o++;
      while (y - o > 0)
        _ = e4(_), y--;
      while (o - y > 0)
        k = e4(k), o--;
      var O0 = y;
      while (O0--) {
        if (_ === k || k !== null && _ === k.alternate)
          return _;
        _ = e4(_), k = e4(k);
      }
      return null;
    }
    function v70(L, O, _, k, y) {
      var d = O._reactName, o = [], H0 = _;
      while (H0 !== null) {
        if (H0 === k)
          break;
        var O0 = H0, I0 = O0.alternate, g0 = O0.stateNode, R1 = O0.tag;
        if (I0 !== null && I0 === k)
          break;
        if (R1 === q && g0 !== null) {
          var U1 = g0;
          if (y) {
            var x1 = dw(H0, d);
            if (x1 != null)
              o.unshift(Oj(H0, x1, U1));
          } else if (!y) {
            var y1 = dw(H0, d);
            if (y1 != null)
              o.push(Oj(H0, y1, U1));
          }
        }
        H0 = H0.return;
      }
      if (o.length !== 0)
        L.push({
          event: O,
          listeners: o
        });
    }
    function hm0(L, O, _, k, y) {
      var d = k && y ? fm0(k, y) : null;
      if (k !== null)
        v70(L, O, k, d, !1);
      if (y !== null && _ !== null)
        v70(L, _, y, d, !0);
    }
    function bm0(L, O) {
      return L + "__" + (O ? "capture" : "bubble");
    }
    var $5 = !1, zj = "dangerouslySetInnerHTML", EC = "suppressContentEditableWarning", nU = "suppressHydrationWarning", S70 = "autoFocus", YO = "children", QO = "style", OC = "__html", ed, zC, Dj, f70, DC, h70, b70;
    ed = {
      dialog: !0,
      webview: !0
    }, zC = function(L, O) {
      zx0(L, O), Dx0(L, O), jx0(L, O, {
        registrationNameDependencies: Z0,
        possibleRegistrationNames: U0
      });
    }, h70 = $0 && !document.documentMode, Dj = function(L, O, _) {
      if ($5)
        return;
      var k = MC(_), y = MC(O);
      if (y === k)
        return;
      $5 = !0, Y("Prop `%s` did not match. Server: %s Client: %s", L, JSON.stringify(y), JSON.stringify(k));
    }, f70 = function(L) {
      if ($5)
        return;
      $5 = !0;
      var O = [];
      L.forEach(function(_) {
        O.push(_);
      }), Y("Extra attributes from the server: %s", O);
    }, DC = function(L, O) {
      if (O === !1)
        Y("Expected `%s` listener to be a function, instead got `false`.\n\nIf you used to conditionally omit it with %s={condition && value}, pass %s={condition ? value : undefined} instead.", L, L, L);
      else
        Y("Expected `%s` listener to be a function, instead got a value of `%s` type.", L, typeof O);
    }, b70 = function(L, O) {
      var _ = L.namespaceURI === sq ? L.ownerDocument.createElement(L.tagName) : L.ownerDocument.createElementNS(L.namespaceURI, L.tagName);
      return _.innerHTML = O, _.innerHTML;
    };
    var xm0 = /\r\n?/g, ym0 = /\u0000|\uFFFD/g;
    function MC(L) {
      S0(L);
      var O = typeof L === "string" ? L : "" + L;
      return O.replace(xm0, `
`).replace(ym0, "");
    }
    function AC(L, O, _, k) {
      var y = MC(O), d = MC(L);
      if (d === y)
        return;
      if (k) {
        if (!$5)
          $5 = !0, Y('Text content did not match. Server: "%s" Client: "%s"', d, y);
      }
      if (_ && g)
        throw new Error("Text content does not match server-rendered HTML.");
    }
    function x70(L) {
      return L.nodeType === rq ? L : L.ownerDocument;
    }
    function gm0() {}
    function BC(L) {
      L.onclick = gm0;
    }
    function mm0(L, O, _, k, y) {
      for (var d in k) {
        if (!k.hasOwnProperty(d))
          continue;
        var o = k[d];
        if (d === QO) {
          if (o)
            Object.freeze(o);
          Z90(O, o);
        } else if (d === zj) {
          var H0 = o ? o[OC] : void 0;
          if (H0 != null)
            sZ0(O, H0);
        } else if (d === YO) {
          if (typeof o === "string") {
            var O0 = L !== "textarea" || o !== "";
            if (O0)
              uP(O, o);
          } else if (typeof o === "number")
            uP(O, "" + o);
        } else if (d === EC || d === nU)
          ;
        else if (d === S70)
          ;
        else if (Z0.hasOwnProperty(d)) {
          if (o != null) {
            if (typeof o !== "function")
              DC(d, o);
            if (d === "onScroll")
              HJ("scroll", O);
          }
        } else if (o != null)
          w0(O, d, o, y);
      }
    }
    function dm0(L, O, _, k) {
      for (var y = 0;y < O.length; y += 2) {
        var d = O[y], o = O[y + 1];
        if (d === QO)
          Z90(L, o);
        else if (d === zj)
          sZ0(L, o);
        else if (d === YO)
          uP(L, o);
        else
          w0(L, d, o, k);
      }
    }
    function pm0(L, O, _, k) {
      var y, d = x70(_), o, H0 = k;
      if (H0 === sq)
        H0 = ym(L);
      if (H0 === sq) {
        if (y = nE(L, O), !y && L !== L.toLowerCase())
          Y("<%s /> is using incorrect casing. Use PascalCase for React components, or lowercase for HTML elements.", L);
        if (L === "script") {
          var O0 = d.createElement("div");
          O0.innerHTML = "<script></script>";
          var I0 = O0.firstChild;
          o = O0.removeChild(I0);
        } else if (typeof O.is === "string")
          o = d.createElement(L, {
            is: O.is
          });
        else if (o = d.createElement(L), L === "select") {
          var g0 = o;
          if (O.multiple)
            g0.multiple = !0;
          else if (O.size)
            g0.size = O.size;
        }
      } else
        o = d.createElementNS(H0, L);
      if (H0 === sq) {
        if (!y && Object.prototype.toString.call(o) === "[object HTMLUnknownElement]" && !R0.call(ed, L))
          ed[L] = !0, Y("The tag <%s> is unrecognized in this browser. If you meant to render a React component, start its name with an uppercase letter.", L);
      }
      return o;
    }
    function um0(L, O) {
      return x70(O).createTextNode(L);
    }
    function cm0(L, O, _, k) {
      var y = nE(O, _);
      zC(O, _);
      var d;
      switch (O) {
        case "dialog":
          HJ("cancel", L), HJ("close", L), d = _;
          break;
        case "iframe":
        case "object":
        case "embed":
          HJ("load", L), d = _;
          break;
        case "video":
        case "audio":
          for (var o = 0;o < Rj.length; o++)
            HJ(Rj[o], L);
          d = _;
          break;
        case "source":
          HJ("error", L), d = _;
          break;
        case "img":
        case "image":
        case "link":
          HJ("error", L), HJ("load", L), d = _;
          break;
        case "details":
          HJ("toggle", L), d = _;
          break;
        case "input":
          J1(L, _), d = B0(L, _), HJ("invalid", L);
          break;
        case "option":
          f7(L, _), d = _;
          break;
        case "select":
          xw(L, _), d = bw(L, _), HJ("invalid", L);
          break;
        case "textarea":
          nZ0(L, _), d = bm(L, _), HJ("invalid", L);
          break;
        default:
          d = _;
      }
      switch (um(O, d), mm0(O, L, k, d, y), O) {
        case "input":
          iq(L), i2(L, _, !1);
          break;
        case "textarea":
          iq(L), oZ0(L);
          break;
        case "option":
          GJ(L, _);
          break;
        case "select":
          hm(L, _);
          break;
        default:
          if (typeof d.onClick === "function")
            BC(L);
          break;
      }
    }
    function lm0(L, O, _, k, y) {
      zC(O, k);
      var d = null, o, H0;
      switch (O) {
        case "input":
          o = B0(L, _), H0 = B0(L, k), d = [];
          break;
        case "select":
          o = bw(L, _), H0 = bw(L, k), d = [];
          break;
        case "textarea":
          o = bm(L, _), H0 = bm(L, k), d = [];
          break;
        default:
          if (o = _, H0 = k, typeof o.onClick !== "function" && typeof H0.onClick === "function")
            BC(L);
          break;
      }
      um(O, H0);
      var O0, I0, g0 = null;
      for (O0 in o) {
        if (H0.hasOwnProperty(O0) || !o.hasOwnProperty(O0) || o[O0] == null)
          continue;
        if (O0 === QO) {
          var R1 = o[O0];
          for (I0 in R1)
            if (R1.hasOwnProperty(I0)) {
              if (!g0)
                g0 = {};
              g0[I0] = "";
            }
        } else if (O0 === zj || O0 === YO)
          ;
        else if (O0 === EC || O0 === nU)
          ;
        else if (O0 === S70)
          ;
        else if (Z0.hasOwnProperty(O0)) {
          if (!d)
            d = [];
        } else
          (d = d || []).push(O0, null);
      }
      for (O0 in H0) {
        var U1 = H0[O0], x1 = o != null ? o[O0] : void 0;
        if (!H0.hasOwnProperty(O0) || U1 === x1 || U1 == null && x1 == null)
          continue;
        if (O0 === QO) {
          if (U1)
            Object.freeze(U1);
          if (x1) {
            for (I0 in x1)
              if (x1.hasOwnProperty(I0) && (!U1 || !U1.hasOwnProperty(I0))) {
                if (!g0)
                  g0 = {};
                g0[I0] = "";
              }
            for (I0 in U1)
              if (U1.hasOwnProperty(I0) && x1[I0] !== U1[I0]) {
                if (!g0)
                  g0 = {};
                g0[I0] = U1[I0];
              }
          } else {
            if (!g0) {
              if (!d)
                d = [];
              d.push(O0, g0);
            }
            g0 = U1;
          }
        } else if (O0 === zj) {
          var y1 = U1 ? U1[OC] : void 0, r1 = x1 ? x1[OC] : void 0;
          if (y1 != null) {
            if (r1 !== y1)
              (d = d || []).push(O0, y1);
          }
        } else if (O0 === YO) {
          if (typeof U1 === "string" || typeof U1 === "number")
            (d = d || []).push(O0, "" + U1);
        } else if (O0 === EC || O0 === nU)
          ;
        else if (Z0.hasOwnProperty(O0)) {
          if (U1 != null) {
            if (typeof U1 !== "function")
              DC(O0, U1);
            if (O0 === "onScroll")
              HJ("scroll", L);
          }
          if (!d && x1 !== U1)
            d = [];
        } else
          (d = d || []).push(O0, U1);
      }
      if (g0)
        Nx0(g0, H0[QO]), (d = d || []).push(QO, g0);
      return d;
    }
    function nm0(L, O, _, k, y) {
      if (_ === "input" && y.type === "radio" && y.name != null)
        b1(L, y);
      var d = nE(_, k), o = nE(_, y);
      switch (dm0(L, O, d, o), _) {
        case "input":
          X2(L, y);
          break;
        case "textarea":
          iZ0(L, y);
          break;
        case "select":
          db0(L, y);
          break;
      }
    }
    function im0(L) {
      {
        var O = L.toLowerCase();
        if (!cP.hasOwnProperty(O))
          return null;
        return cP[O] || null;
      }
    }
    function om0(L, O, _, k, y, d, o) {
      var H0, O0;
      switch (H0 = nE(O, _), zC(O, _), O) {
        case "dialog":
          HJ("cancel", L), HJ("close", L);
          break;
        case "iframe":
        case "object":
        case "embed":
          HJ("load", L);
          break;
        case "video":
        case "audio":
          for (var I0 = 0;I0 < Rj.length; I0++)
            HJ(Rj[I0], L);
          break;
        case "source":
          HJ("error", L);
          break;
        case "img":
        case "image":
        case "link":
          HJ("error", L), HJ("load", L);
          break;
        case "details":
          HJ("toggle", L);
          break;
        case "input":
          J1(L, _), HJ("invalid", L);
          break;
        case "option":
          f7(L, _);
          break;
        case "select":
          xw(L, _), HJ("invalid", L);
          break;
        case "textarea":
          nZ0(L, _), HJ("invalid", L);
          break;
      }
      um(O, _);
      {
        O0 = /* @__PURE__ */ new Set;
        var g0 = L.attributes;
        for (var R1 = 0;R1 < g0.length; R1++) {
          var U1 = g0[R1].name.toLowerCase();
          switch (U1) {
            case "value":
              break;
            case "checked":
              break;
            case "selected":
              break;
            default:
              O0.add(g0[R1].name);
          }
        }
      }
      var x1 = null;
      for (var y1 in _) {
        if (!_.hasOwnProperty(y1))
          continue;
        var r1 = _[y1];
        if (y1 === YO) {
          if (typeof r1 === "string") {
            if (L.textContent !== r1) {
              if (_[nU] !== !0)
                AC(L.textContent, r1, d, o);
              x1 = [YO, r1];
            }
          } else if (typeof r1 === "number") {
            if (L.textContent !== "" + r1) {
              if (_[nU] !== !0)
                AC(L.textContent, r1, d, o);
              x1 = [YO, "" + r1];
            }
          }
        } else if (Z0.hasOwnProperty(y1)) {
          if (r1 != null) {
            if (typeof r1 !== "function")
              DC(y1, r1);
            if (y1 === "onScroll")
              HJ("scroll", L);
          }
        } else if (o && !0 && typeof H0 === "boolean") {
          var Q8 = void 0, J6 = H0 && n ? null : S1(y1);
          if (_[nU] === !0)
            ;
          else if (y1 === EC || y1 === nU || y1 === "value" || y1 === "checked" || y1 === "selected")
            ;
          else if (y1 === zj) {
            var b8 = L.innerHTML, oZ = r1 ? r1[OC] : void 0;
            if (oZ != null) {
              var sZ = b70(L, oZ);
              if (sZ !== b8)
                Dj(y1, b8, sZ);
            }
          } else if (y1 === QO) {
            if (O0.delete(y1), h70) {
              var C1 = Gx0(r1);
              if (Q8 = L.getAttribute("style"), C1 !== Q8)
                Dj(y1, Q8, C1);
            }
          } else if (H0 && !n) {
            if (O0.delete(y1.toLowerCase()), Q8 = R8(L, y1, r1), r1 !== Q8)
              Dj(y1, Q8, r1);
          } else if (!F1(y1, J6, H0) && !P1(y1, r1, J6, H0)) {
            var Y2 = !1;
            if (J6 !== null)
              O0.delete(J6.attributeName), Q8 = L8(L, y1, r1, J6);
            else {
              var k1 = k;
              if (k1 === sq)
                k1 = ym(O);
              if (k1 === sq)
                O0.delete(y1.toLowerCase());
              else {
                var k2 = im0(y1);
                if (k2 !== null && k2 !== y1)
                  Y2 = !0, O0.delete(k2);
                O0.delete(y1);
              }
              Q8 = R8(L, y1, r1);
            }
            var z8 = n;
            if (!z8 && r1 !== Q8 && !Y2)
              Dj(y1, Q8, r1);
          }
        }
      }
      if (o) {
        if (O0.size > 0 && _[nU] !== !0)
          f70(O0);
      }
      switch (O) {
        case "input":
          iq(L), i2(L, _, !0);
          break;
        case "textarea":
          iq(L), oZ0(L);
          break;
        case "select":
        case "option":
          break;
        default:
          if (typeof _.onClick === "function")
            BC(L);
          break;
      }
      return x1;
    }
    function sm0(L, O, _) {
      var k = L.nodeValue !== O;
      return k;
    }
    function Zp(L, O) {
      {
        if ($5)
          return;
        $5 = !0, Y("Did not expect server HTML to contain a <%s> in <%s>.", O.nodeName.toLowerCase(), L.nodeName.toLowerCase());
      }
    }
    function Jp(L, O) {
      {
        if ($5)
          return;
        $5 = !0, Y('Did not expect server HTML to contain the text node "%s" in <%s>.', O.nodeValue, L.nodeName.toLowerCase());
      }
    }
    function $p(L, O, _) {
      {
        if ($5)
          return;
        $5 = !0, Y("Expected server HTML to contain a matching <%s> in <%s>.", O, L.nodeName.toLowerCase());
      }
    }
    function Xp(L, O) {
      {
        if (O === "")
          return;
        if ($5)
          return;
        $5 = !0, Y('Expected server HTML to contain a matching text node for "%s" in <%s>.', O, L.nodeName.toLowerCase());
      }
    }
    function am0(L, O, _) {
      switch (O) {
        case "input":
          V6(L, _);
          return;
        case "textarea":
          ub0(L, _);
          return;
        case "select":
          pb0(L, _);
          return;
      }
    }
    var Mj = function() {}, Aj = function() {};
    {
      var rm0 = ["address", "applet", "area", "article", "aside", "base", "basefont", "bgsound", "blockquote", "body", "br", "button", "caption", "center", "col", "colgroup", "dd", "details", "dir", "div", "dl", "dt", "embed", "fieldset", "figcaption", "figure", "footer", "form", "frame", "frameset", "h1", "h2", "h3", "h4", "h5", "h6", "head", "header", "hgroup", "hr", "html", "iframe", "img", "input", "isindex", "li", "link", "listing", "main", "marquee", "menu", "menuitem", "meta", "nav", "noembed", "noframes", "noscript", "object", "ol", "p", "param", "plaintext", "pre", "script", "section", "select", "source", "style", "summary", "table", "tbody", "td", "template", "textarea", "tfoot", "th", "thead", "title", "tr", "track", "ul", "wbr", "xmp"], y70 = [
        "applet",
        "caption",
        "html",
        "table",
        "td",
        "th",
        "marquee",
        "object",
        "template",
        "foreignObject",
        "desc",
        "title"
      ], tm0 = y70.concat(["button"]), em0 = ["dd", "dt", "li", "option", "optgroup", "p", "rp", "rt"], g70 = {
        current: null,
        formTag: null,
        aTagInScope: null,
        buttonTagInScope: null,
        nobrTagInScope: null,
        pTagInButtonScope: null,
        listItemTagAutoclosing: null,
        dlItemTagAutoclosing: null
      };
      Aj = function(L, O) {
        var _ = d0({}, L || g70), k = {
          tag: O
        };
        if (y70.indexOf(O) !== -1)
          _.aTagInScope = null, _.buttonTagInScope = null, _.nobrTagInScope = null;
        if (tm0.indexOf(O) !== -1)
          _.pTagInButtonScope = null;
        if (rm0.indexOf(O) !== -1 && O !== "address" && O !== "div" && O !== "p")
          _.listItemTagAutoclosing = null, _.dlItemTagAutoclosing = null;
        if (_.current = k, O === "form")
          _.formTag = k;
        if (O === "a")
          _.aTagInScope = k;
        if (O === "button")
          _.buttonTagInScope = k;
        if (O === "nobr")
          _.nobrTagInScope = k;
        if (O === "p")
          _.pTagInButtonScope = k;
        if (O === "li")
          _.listItemTagAutoclosing = k;
        if (O === "dd" || O === "dt")
          _.dlItemTagAutoclosing = k;
        return _;
      };
      var Zd0 = function(L, O) {
        switch (O) {
          case "select":
            return L === "option" || L === "optgroup" || L === "#text";
          case "optgroup":
            return L === "option" || L === "#text";
          case "option":
            return L === "#text";
          case "tr":
            return L === "th" || L === "td" || L === "style" || L === "script" || L === "template";
          case "tbody":
          case "thead":
          case "tfoot":
            return L === "tr" || L === "style" || L === "script" || L === "template";
          case "colgroup":
            return L === "col" || L === "template";
          case "table":
            return L === "caption" || L === "colgroup" || L === "tbody" || L === "tfoot" || L === "thead" || L === "style" || L === "script" || L === "template";
          case "head":
            return L === "base" || L === "basefont" || L === "bgsound" || L === "link" || L === "meta" || L === "title" || L === "noscript" || L === "noframes" || L === "style" || L === "script" || L === "template";
          case "html":
            return L === "head" || L === "body" || L === "frameset";
          case "frameset":
            return L === "frame";
          case "#document":
            return L === "html";
        }
        switch (L) {
          case "h1":
          case "h2":
          case "h3":
          case "h4":
          case "h5":
          case "h6":
            return O !== "h1" && O !== "h2" && O !== "h3" && O !== "h4" && O !== "h5" && O !== "h6";
          case "rp":
          case "rt":
            return em0.indexOf(O) === -1;
          case "body":
          case "caption":
          case "col":
          case "colgroup":
          case "frameset":
          case "frame":
          case "head":
          case "html":
          case "tbody":
          case "td":
          case "tfoot":
          case "th":
          case "thead":
          case "tr":
            return O == null;
        }
        return !0;
      }, Jd0 = function(L, O) {
        switch (L) {
          case "address":
          case "article":
          case "aside":
          case "blockquote":
          case "center":
          case "details":
          case "dialog":
          case "dir":
          case "div":
          case "dl":
          case "fieldset":
          case "figcaption":
          case "figure":
          case "footer":
          case "header":
          case "hgroup":
          case "main":
          case "menu":
          case "nav":
          case "ol":
          case "p":
          case "section":
          case "summary":
          case "ul":
          case "pre":
          case "listing":
          case "table":
          case "hr":
          case "xmp":
          case "h1":
          case "h2":
          case "h3":
          case "h4":
          case "h5":
          case "h6":
            return O.pTagInButtonScope;
          case "form":
            return O.formTag || O.pTagInButtonScope;
          case "li":
            return O.listItemTagAutoclosing;
          case "dd":
          case "dt":
            return O.dlItemTagAutoclosing;
          case "button":
            return O.buttonTagInScope;
          case "a":
            return O.aTagInScope;
          case "nobr":
            return O.nobrTagInScope;
        }
        return null;
      }, m70 = {};
      Mj = function(L, O, _) {
        _ = _ || g70;
        var k = _.current, y = k && k.tag;
        if (O != null) {
          if (L != null)
            Y("validateDOMNesting: when childText is passed, childTag should be null");
          L = "#text";
        }
        var d = Zd0(L, y) ? null : k, o = d ? null : Jd0(L, _), H0 = d || o;
        if (!H0)
          return;
        var O0 = H0.tag, I0 = !!d + "|" + L + "|" + O0;
        if (m70[I0])
          return;
        m70[I0] = !0;
        var g0 = L, R1 = "";
        if (L === "#text")
          if (/\S/.test(O))
            g0 = "Text nodes";
          else
            g0 = "Whitespace text nodes", R1 = " Make sure you don't have any extra whitespace between tags on each line of your source code.";
        else
          g0 = "<" + L + ">";
        if (d) {
          var U1 = "";
          if (O0 === "table" && L === "tr")
            U1 += " Add a <tbody>, <thead> or <tfoot> to your code to match the DOM tree generated by the browser.";
          Y("validateDOMNesting(...): %s cannot appear as a child of <%s>.%s%s", g0, O0, R1, U1);
        } else
          Y("validateDOMNesting(...): %s cannot appear as a descendant of <%s>.", g0, O0);
      };
    }
    var wC = "suppressHydrationWarning", jC = "$", TC = "/$", Bj = "$?", wj = "$!", $d0 = "style", Yp = null, Qp = null;
    function Xd0(L) {
      var O, _, k = L.nodeType;
      switch (k) {
        case rq:
        case mm: {
          O = k === rq ? "#document" : "#fragment";
          var y = L.documentElement;
          _ = y ? y.namespaceURI : gm(null, "");
          break;
        }
        default: {
          var d = k === p$ ? L.parentNode : L, o = d.namespaceURI || null;
          O = d.tagName, _ = gm(o, O);
          break;
        }
      }
      {
        var H0 = O.toLowerCase(), O0 = Aj(null, H0);
        return {
          namespace: _,
          ancestorInfo: O0
        };
      }
    }
    function Yd0(L, O, _) {
      {
        var k = L, y = gm(k.namespace, O), d = Aj(k.ancestorInfo, O);
        return {
          namespace: y,
          ancestorInfo: d
        };
      }
    }
    function Wp(L) {
      return L;
    }
    function Qd0(L) {
      Yp = $g0(), Qp = Dm0();
      var O = null;
      return o90(!1), O;
    }
    function Wd0(L) {
      Mm0(Qp), o90(Yp), Yp = null, Qp = null;
    }
    function Kd0(L, O, _, k, y) {
      var d;
      {
        var o = k;
        if (Mj(L, null, o.ancestorInfo), typeof O.children === "string" || typeof O.children === "number") {
          var H0 = "" + O.children, O0 = Aj(o.ancestorInfo, L);
          Mj(null, H0, O0);
        }
        d = o.namespace;
      }
      var I0 = pm0(L, O, _, d);
      return _j(y, I0), Lp(I0, O), I0;
    }
    function Gd0(L, O) {
      L.appendChild(O);
    }
    function Hd0(L, O, _, k, y) {
      switch (cm0(L, O, _, k), O) {
        case "button":
        case "input":
        case "select":
        case "textarea":
          return !!_.autoFocus;
        case "img":
          return !0;
        default:
          return !1;
      }
    }
    function Nd0(L, O, _, k, y, d) {
      {
        var o = d;
        if (typeof k.children !== typeof _.children && (typeof k.children === "string" || typeof k.children === "number")) {
          var H0 = "" + k.children, O0 = Aj(o.ancestorInfo, O);
          Mj(null, H0, O0);
        }
      }
      return lm0(L, O, _, k);
    }
    function Kp(L, O) {
      return L === "textarea" || L === "noscript" || typeof O.children === "string" || typeof O.children === "number" || typeof O.dangerouslySetInnerHTML === "object" && O.dangerouslySetInnerHTML !== null && O.dangerouslySetInnerHTML.__html != null;
    }
    function qd0(L, O, _, k) {
      {
        var y = _;
        Mj(null, L, y.ancestorInfo);
      }
      var d = um0(L, O);
      return _j(k, d), d;
    }
    function Fd0() {
      var L = window.event;
      if (L === void 0)
        return YF;
      return s90(L.type);
    }
    var Gp = typeof setTimeout === "function" ? setTimeout : void 0, Ud0 = typeof clearTimeout === "function" ? clearTimeout : void 0, Hp = -1, d70 = typeof Promise === "function" ? Promise : void 0, Ld0 = typeof queueMicrotask === "function" ? queueMicrotask : typeof d70 !== "undefined" ? function(L) {
      return d70.resolve(null).then(L).catch(Rd0);
    } : Gp;
    function Rd0(L) {
      setTimeout(function() {
        throw L;
      });
    }
    function Ed0(L, O, _, k) {
      switch (O) {
        case "button":
        case "input":
        case "select":
        case "textarea":
          if (_.autoFocus)
            L.focus();
          return;
        case "img": {
          if (_.src)
            L.src = _.src;
          return;
        }
      }
    }
    function Od0(L, O, _, k, y, d) {
      nm0(L, O, _, k, y), Lp(L, y);
    }
    function p70(L) {
      uP(L, "");
    }
    function zd0(L, O, _) {
      L.nodeValue = _;
    }
    function Dd0(L, O) {
      L.appendChild(O);
    }
    function Md0(L, O) {
      var _;
      if (L.nodeType === p$)
        _ = L.parentNode, _.insertBefore(O, L);
      else
        _ = L, _.appendChild(O);
      var k = L._reactRootContainer;
      if ((k === null || k === void 0) && _.onclick === null)
        BC(_);
    }
    function Ad0(L, O, _) {
      L.insertBefore(O, _);
    }
    function Bd0(L, O, _) {
      if (L.nodeType === p$)
        L.parentNode.insertBefore(O, _);
      else
        L.insertBefore(O, _);
    }
    function wd0(L, O) {
      L.removeChild(O);
    }
    function jd0(L, O) {
      if (L.nodeType === p$)
        L.parentNode.removeChild(O);
      else
        L.removeChild(O);
    }
    function Np(L, O) {
      var _ = O, k = 0;
      do {
        var y = _.nextSibling;
        if (L.removeChild(_), y && y.nodeType === p$) {
          var d = y.data;
          if (d === TC)
            if (k === 0) {
              L.removeChild(y), Qj(O);
              return;
            } else
              k--;
          else if (d === jC || d === Bj || d === wj)
            k++;
        }
        _ = y;
      } while (_);
      Qj(O);
    }
    function Td0(L, O) {
      if (L.nodeType === p$)
        Np(L.parentNode, O);
      else if (L.nodeType === J5)
        Np(L, O);
      Qj(L);
    }
    function _d0(L) {
      L = L;
      var O = L.style;
      if (typeof O.setProperty === "function")
        O.setProperty("display", "none", "important");
      else
        O.display = "none";
    }
    function Vd0(L) {
      L.nodeValue = "";
    }
    function Id0(L, O) {
      L = L;
      var _ = O[$d0], k = _ !== void 0 && _ !== null && _.hasOwnProperty("display") ? _.display : null;
      L.style.display = dm("display", k);
    }
    function Pd0(L, O) {
      L.nodeValue = O;
    }
    function Cd0(L) {
      if (L.nodeType === J5)
        L.textContent = "";
      else if (L.nodeType === rq) {
        if (L.documentElement)
          L.removeChild(L.documentElement);
      }
    }
    function kd0(L, O, _) {
      if (L.nodeType !== J5 || O.toLowerCase() !== L.nodeName.toLowerCase())
        return null;
      return L;
    }
    function vd0(L, O) {
      if (O === "" || L.nodeType !== aq)
        return null;
      return L;
    }
    function Sd0(L) {
      if (L.nodeType !== p$)
        return null;
      return L;
    }
    function u70(L) {
      return L.data === Bj;
    }
    function qp(L) {
      return L.data === wj;
    }
    function fd0(L) {
      var O = L.nextSibling && L.nextSibling.dataset, _, k, y;
      if (O)
        _ = O.dgst, k = O.msg, y = O.stck;
      return {
        message: k,
        digest: _,
        stack: y
      };
    }
    function hd0(L, O) {
      L._reactRetry = O;
    }
    function _C(L) {
      for (;L != null; L = L.nextSibling) {
        var O = L.nodeType;
        if (O === J5 || O === aq)
          break;
        if (O === p$) {
          var _ = L.data;
          if (_ === jC || _ === wj || _ === Bj)
            break;
          if (_ === TC)
            return null;
        }
      }
      return L;
    }
    function jj(L) {
      return _C(L.nextSibling);
    }
    function bd0(L) {
      return _C(L.firstChild);
    }
    function xd0(L) {
      return _C(L.firstChild);
    }
    function yd0(L) {
      return _C(L.nextSibling);
    }
    function gd0(L, O, _, k, y, d, o) {
      _j(d, L), Lp(L, _);
      var H0;
      {
        var O0 = y;
        H0 = O0.namespace;
      }
      var I0 = (d.mode & W9) !== N6;
      return om0(L, O, _, H0, k, I0, o);
    }
    function md0(L, O, _, k) {
      _j(_, L);
      var y = (_.mode & W9) !== N6;
      return sm0(L, O);
    }
    function dd0(L, O) {
      _j(O, L);
    }
    function pd0(L) {
      var O = L.nextSibling, _ = 0;
      while (O) {
        if (O.nodeType === p$) {
          var k = O.data;
          if (k === TC)
            if (_ === 0)
              return jj(O);
            else
              _--;
          else if (k === jC || k === wj || k === Bj)
            _++;
        }
        O = O.nextSibling;
      }
      return null;
    }
    function c70(L) {
      var O = L.previousSibling, _ = 0;
      while (O) {
        if (O.nodeType === p$) {
          var k = O.data;
          if (k === jC || k === wj || k === Bj)
            if (_ === 0)
              return O;
            else
              _--;
          else if (k === TC)
            _++;
        }
        O = O.previousSibling;
      }
      return null;
    }
    function ud0(L) {
      Qj(L);
    }
    function cd0(L) {
      Qj(L);
    }
    function ld0(L) {
      return L !== "head" && L !== "body";
    }
    function nd0(L, O, _, k) {
      var y = !0;
      AC(O.nodeValue, _, k, y);
    }
    function id0(L, O, _, k, y, d) {
      if (O[wC] !== !0) {
        var o = !0;
        AC(k.nodeValue, y, d, o);
      }
    }
    function od0(L, O) {
      if (O.nodeType === J5)
        Zp(L, O);
      else if (O.nodeType === p$)
        ;
      else
        Jp(L, O);
    }
    function sd0(L, O) {
      {
        var _ = L.parentNode;
        if (_ !== null)
          if (O.nodeType === J5)
            Zp(_, O);
          else if (O.nodeType === p$)
            ;
          else
            Jp(_, O);
      }
    }
    function ad0(L, O, _, k, y) {
      if (y || O[wC] !== !0)
        if (k.nodeType === J5)
          Zp(_, k);
        else if (k.nodeType === p$)
          ;
        else
          Jp(_, k);
    }
    function rd0(L, O, _) {
      $p(L, O);
    }
    function td0(L, O) {
      Xp(L, O);
    }
    function ed0(L, O, _) {
      {
        var k = L.parentNode;
        if (k !== null)
          $p(k, O);
      }
    }
    function Zp0(L, O) {
      {
        var _ = L.parentNode;
        if (_ !== null)
          Xp(_, O);
      }
    }
    function Jp0(L, O, _, k, y, d) {
      if (d || O[wC] !== !0)
        $p(_, k);
    }
    function $p0(L, O, _, k, y) {
      if (y || O[wC] !== !0)
        Xp(_, k);
    }
    function Xp0(L) {
      Y("An error occurred during hydration. The server HTML was replaced with client content in <%s>.", L.nodeName.toLowerCase());
    }
    function Yp0(L) {
      Ej(L);
    }
    var ZD = Math.random().toString(36).slice(2), JD = "__reactFiber$" + ZD, Fp = "__reactProps$" + ZD, Tj = "__reactContainer$" + ZD, Up = "__reactEvents$" + ZD, Qp0 = "__reactListeners$" + ZD, Wp0 = "__reactHandles$" + ZD;
    function Kp0(L) {
      delete L[JD], delete L[Fp], delete L[Up], delete L[Qp0], delete L[Wp0];
    }
    function _j(L, O) {
      O[JD] = L;
    }
    function VC(L, O) {
      O[Tj] = L;
    }
    function l70(L) {
      L[Tj] = null;
    }
    function Vj(L) {
      return !!L[Tj];
    }
    function WO(L) {
      var O = L[JD];
      if (O)
        return O;
      var _ = L.parentNode;
      while (_) {
        if (O = _[Tj] || _[JD], O) {
          var k = O.alternate;
          if (O.child !== null || k !== null && k.child !== null) {
            var y = c70(L);
            while (y !== null) {
              var d = y[JD];
              if (d)
                return d;
              y = c70(y);
            }
          }
          return O;
        }
        L = _, _ = L.parentNode;
      }
      return null;
    }
    function iU(L) {
      var O = L[JD] || L[Tj];
      if (O)
        if (O.tag === q || O.tag === U || O.tag === B || O.tag === H)
          return O;
        else
          return null;
      return null;
    }
    function $D(L) {
      if (L.tag === q || L.tag === U)
        return L.stateNode;
      throw new Error("getNodeFromInstance: Invalid argument.");
    }
    function IC(L) {
      return L[Fp] || null;
    }
    function Lp(L, O) {
      L[Fp] = O;
    }
    function Gp0(L) {
      var O = L[Up];
      if (O === void 0)
        O = L[Up] = /* @__PURE__ */ new Set;
      return O;
    }
    var n70 = {}, i70 = Z.ReactDebugCurrentFrame;
    function PC(L) {
      if (L) {
        var O = L._owner, _ = N8(L.type, L._source, O ? O.type : null);
        i70.setExtraStackFrame(_);
      } else
        i70.setExtraStackFrame(null);
    }
    function PG(L, O, _, k, y) {
      {
        var d = Function.call.bind(R0);
        for (var o in L)
          if (d(L, o)) {
            var H0 = void 0;
            try {
              if (typeof L[o] !== "function") {
                var O0 = Error((k || "React class") + ": " + _ + " type `" + o + "` is invalid; it must be a function, usually from the `prop-types` package, but received `" + typeof L[o] + "`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");
                throw O0.name = "Invariant Violation", O0;
              }
              H0 = L[o](O, o, k, _, null, "SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED");
            } catch (I0) {
              H0 = I0;
            }
            if (H0 && !(H0 instanceof Error))
              PC(y), Y("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).", k || "React class", _, o, typeof H0), PC(null);
            if (H0 instanceof Error && !(H0.message in n70))
              n70[H0.message] = !0, PC(y), Y("Failed %s type: %s", _, H0.message), PC(null);
          }
      }
    }
    var Rp = [], CC;
    CC = [];
    var QF = -1;
    function oU(L) {
      return {
        current: L
      };
    }
    function AQ(L, O) {
      if (QF < 0) {
        Y("Unexpected pop.");
        return;
      }
      if (O !== CC[QF])
        Y("Unexpected Fiber popped.");
      L.current = Rp[QF], Rp[QF] = null, CC[QF] = null, QF--;
    }
    function BQ(L, O, _) {
      QF++, Rp[QF] = L.current, CC[QF] = _, L.current = O;
    }
    var o70 = {}, t5 = {};
    Object.freeze(t5);
    var WF = oU(t5), rH = oU(!1), Ep = t5;
    function XD(L, O, _) {
      {
        if (_ && tH(O))
          return Ep;
        return WF.current;
      }
    }
    function s70(L, O, _) {
      {
        var k = L.stateNode;
        k.__reactInternalMemoizedUnmaskedChildContext = O, k.__reactInternalMemoizedMaskedChildContext = _;
      }
    }
    function YD(L, O) {
      {
        var _ = L.type, k = _.contextTypes;
        if (!k)
          return t5;
        var y = L.stateNode;
        if (y && y.__reactInternalMemoizedUnmaskedChildContext === O)
          return y.__reactInternalMemoizedMaskedChildContext;
        var d = {};
        for (var o in k)
          d[o] = O[o];
        {
          var H0 = D6(L) || "Unknown";
          PG(k, d, "context", H0);
        }
        if (y)
          s70(L, O, d);
        return d;
      }
    }
    function kC() {
      return rH.current;
    }
    function tH(L) {
      {
        var O = L.childContextTypes;
        return O !== null && O !== void 0;
      }
    }
    function vC(L) {
      AQ(rH, L), AQ(WF, L);
    }
    function Op(L) {
      AQ(rH, L), AQ(WF, L);
    }
    function a70(L, O, _) {
      {
        if (WF.current !== t5)
          throw new Error("Unexpected context found on stack. This error is likely caused by a bug in React. Please file an issue.");
        BQ(WF, O, L), BQ(rH, _, L);
      }
    }
    function r70(L, O, _) {
      {
        var k = L.stateNode, y = O.childContextTypes;
        if (typeof k.getChildContext !== "function") {
          {
            var d = D6(L) || "Unknown";
            if (!o70[d])
              o70[d] = !0, Y("%s.childContextTypes is specified but there is no getChildContext() method on the instance. You can either define getChildContext() on %s or remove childContextTypes from it.", d, d);
          }
          return _;
        }
        var o = k.getChildContext();
        for (var H0 in o)
          if (!(H0 in y))
            throw new Error((D6(L) || "Unknown") + '.getChildContext(): key "' + H0 + '" is not defined in childContextTypes.');
        {
          var O0 = D6(L) || "Unknown";
          PG(y, o, "child context", O0);
        }
        return d0({}, _, o);
      }
    }
    function SC(L) {
      {
        var O = L.stateNode, _ = O && O.__reactInternalMemoizedMergedChildContext || t5;
        return Ep = WF.current, BQ(WF, _, L), BQ(rH, rH.current, L), !0;
      }
    }
    function t70(L, O, _) {
      {
        var k = L.stateNode;
        if (!k)
          throw new Error("Expected to have an instance by this point. This error is likely caused by a bug in React. Please file an issue.");
        if (_) {
          var y = r70(L, O, Ep);
          k.__reactInternalMemoizedMergedChildContext = y, AQ(rH, L), AQ(WF, L), BQ(WF, y, L), BQ(rH, _, L);
        } else
          AQ(rH, L), BQ(rH, _, L);
      }
    }
    function Hp0(L) {
      {
        if (!lx0(L) || L.tag !== K)
          throw new Error("Expected subtree parent to be a mounted class component. This error is likely caused by a bug in React. Please file an issue.");
        var O = L;
        do {
          switch (O.tag) {
            case H:
              return O.stateNode.context;
            case K: {
              var _ = O.type;
              if (tH(_))
                return O.stateNode.__reactInternalMemoizedMergedChildContext;
              break;
            }
          }
          O = O.return;
        } while (O !== null);
        throw new Error("Found unexpected detached subtree parent. This error is likely caused by a bug in React. Please file an issue.");
      }
    }
    var sU = 0, fC = 1, KF = null, zp = !1, Dp = !1;
    function e70(L) {
      if (KF === null)
        KF = [L];
      else
        KF.push(L);
    }
    function Np0(L) {
      zp = !0, e70(L);
    }
    function ZJ0() {
      if (zp)
        aU();
    }
    function aU() {
      if (!Dp && KF !== null) {
        Dp = !0;
        var L = 0, O = IG();
        try {
          var _ = !0, k = KF;
          ZY(s5);
          for (;L < k.length; L++) {
            var y = k[L];
            do
              y = y(_);
            while (y !== null);
          }
          KF = null, zp = !1;
        } catch (d) {
          if (KF !== null)
            KF = KF.slice(L + 1);
          throw w90(sP, aU), d;
        } finally {
          ZY(O), Dp = !1;
        }
      }
      return null;
    }
    var QD = [], WD = 0, hC = null, bC = 0, uK = [], cK = 0, KO = null, GF = 1, HF = "";
    function qp0(L) {
      return HO(), (L.flags & R90) !== M6;
    }
    function Fp0(L) {
      return HO(), bC;
    }
    function Up0() {
      var L = HF, O = GF, _ = O & ~Lp0(O);
      return _.toString(32) + L;
    }
    function GO(L, O) {
      HO(), QD[WD++] = bC, QD[WD++] = hC, hC = L, bC = O;
    }
    function JJ0(L, O, _) {
      HO(), uK[cK++] = GF, uK[cK++] = HF, uK[cK++] = KO, KO = L;
      var k = GF, y = HF, d = xC(k) - 1, o = k & ~(1 << d), H0 = _ + 1, O0 = xC(O) + d;
      if (O0 > 30) {
        var I0 = d - d % 5, g0 = (1 << I0) - 1, R1 = (o & g0).toString(32), U1 = o >> I0, x1 = d - I0, y1 = xC(O) + x1, r1 = H0 << x1, Q8 = r1 | U1, J6 = R1 + y;
        GF = 1 << y1 | Q8, HF = J6;
      } else {
        var b8 = H0 << d, oZ = b8 | o, sZ = y;
        GF = 1 << O0 | oZ, HF = sZ;
      }
    }
    function Mp(L) {
      HO();
      var O = L.return;
      if (O !== null) {
        var _ = 1, k = 0;
        GO(L, _), JJ0(L, _, k);
      }
    }
    function xC(L) {
      return 32 - P90(L);
    }
    function Lp0(L) {
      return 1 << xC(L) - 1;
    }
    function Ap(L) {
      while (L === hC)
        hC = QD[--WD], QD[WD] = null, bC = QD[--WD], QD[WD] = null;
      while (L === KO)
        KO = uK[--cK], uK[cK] = null, HF = uK[--cK], uK[cK] = null, GF = uK[--cK], uK[cK] = null;
    }
    function Rp0() {
      if (HO(), KO !== null)
        return {
          id: GF,
          overflow: HF
        };
      else
        return null;
    }
    function Ep0(L, O) {
      HO(), uK[cK++] = GF, uK[cK++] = HF, uK[cK++] = KO, GF = O.id, HF = O.overflow, KO = L;
    }
    function HO() {
      if (!nY())
        Y("Expected to be hydrating. This is a bug in React. Please file an issue.");
    }
    var lY = null, lK = null, CG = !1, NO = !1, rU = null;
    function Op0() {
      if (CG)
        Y("We should not be hydrating here. This is a bug in React. Please file a bug.");
    }
    function $J0() {
      NO = !0;
    }
    function zp0() {
      return NO;
    }
    function Dp0(L) {
      var O = L.stateNode.containerInfo;
      return lK = xd0(O), lY = L, CG = !0, rU = null, NO = !1, !0;
    }
    function Mp0(L, O, _) {
      if (lK = yd0(O), lY = L, CG = !0, rU = null, NO = !1, _ !== null)
        Ep0(L, _);
      return !0;
    }
    function XJ0(L, O) {
      switch (L.tag) {
        case H: {
          od0(L.stateNode.containerInfo, O);
          break;
        }
        case q: {
          var _ = (L.mode & W9) !== N6;
          ad0(L.type, L.memoizedProps, L.stateNode, O, _);
          break;
        }
        case B: {
          var k = L.memoizedState;
          if (k.dehydrated !== null)
            sd0(k.dehydrated, O);
          break;
        }
      }
    }
    function YJ0(L, O) {
      XJ0(L, O);
      var _ = Il0();
      _.stateNode = O, _.return = L;
      var k = L.deletions;
      if (k === null)
        L.deletions = [_], L.flags |= iE;
      else
        k.push(_);
    }
    function Bp(L, O) {
      {
        if (NO)
          return;
        switch (L.tag) {
          case H: {
            var _ = L.stateNode.containerInfo;
            switch (O.tag) {
              case q:
                var { type: k, pendingProps: y } = O;
                rd0(_, k);
                break;
              case U:
                var d = O.pendingProps;
                td0(_, d);
                break;
            }
            break;
          }
          case q: {
            var { type: o, memoizedProps: H0, stateNode: O0 } = L;
            switch (O.tag) {
              case q: {
                var { type: I0, pendingProps: g0 } = O, R1 = (L.mode & W9) !== N6;
                Jp0(o, H0, O0, I0, g0, R1);
                break;
              }
              case U: {
                var U1 = O.pendingProps, x1 = (L.mode & W9) !== N6;
                $p0(o, H0, O0, U1, x1);
                break;
              }
            }
            break;
          }
          case B: {
            var y1 = L.memoizedState, r1 = y1.dehydrated;
            if (r1 !== null)
              switch (O.tag) {
                case q:
                  var { type: Q8, pendingProps: J6 } = O;
                  ed0(r1, Q8);
                  break;
                case U:
                  var b8 = O.pendingProps;
                  Zp0(r1, b8);
                  break;
              }
            break;
          }
          default:
            return;
        }
      }
    }
    function QJ0(L, O) {
      O.flags = O.flags & ~eq | u$, Bp(L, O);
    }
    function WJ0(L, O) {
      switch (L.tag) {
        case q: {
          var { type: _, pendingProps: k } = L, y = kd0(O, _);
          if (y !== null)
            return L.stateNode = y, lY = L, lK = bd0(y), !0;
          return !1;
        }
        case U: {
          var d = L.pendingProps, o = vd0(O, d);
          if (o !== null)
            return L.stateNode = o, lY = L, lK = null, !0;
          return !1;
        }
        case B: {
          var H0 = Sd0(O);
          if (H0 !== null) {
            var O0 = {
              dehydrated: H0,
              treeContext: Rp0(),
              retryLane: i5
            };
            L.memoizedState = O0;
            var I0 = Pl0(H0);
            return I0.return = L, L.child = I0, lY = L, lK = null, !0;
          }
          return !1;
        }
        default:
          return !1;
      }
    }
    function wp(L) {
      return (L.mode & W9) !== N6 && (L.flags & x9) === M6;
    }
    function jp(L) {
      throw new Error("Hydration failed because the initial UI does not match what was rendered on the server.");
    }
    function Tp(L) {
      if (!CG)
        return;
      var O = lK;
      if (!O) {
        if (wp(L))
          Bp(lY, L), jp();
        QJ0(lY, L), CG = !1, lY = L;
        return;
      }
      var _ = O;
      if (!WJ0(L, O)) {
        if (wp(L))
          Bp(lY, L), jp();
        O = jj(_);
        var k = lY;
        if (!O || !WJ0(L, O)) {
          QJ0(lY, L), CG = !1, lY = L;
          return;
        }
        YJ0(k, _);
      }
    }
    function Ap0(L, O, _) {
      var k = L.stateNode, y = !NO, d = gd0(k, L.type, L.memoizedProps, O, _, L, y);
      if (L.updateQueue = d, d !== null)
        return !0;
      return !1;
    }
    function Bp0(L) {
      var { stateNode: O, memoizedProps: _ } = L, k = md0(O, _, L);
      if (k) {
        var y = lY;
        if (y !== null)
          switch (y.tag) {
            case H: {
              var d = y.stateNode.containerInfo, o = (y.mode & W9) !== N6;
              nd0(d, O, _, o);
              break;
            }
            case q: {
              var { type: H0, memoizedProps: O0, stateNode: I0 } = y, g0 = (y.mode & W9) !== N6;
              id0(H0, O0, I0, O, _, g0);
              break;
            }
          }
      }
      return k;
    }
    function wp0(L) {
      var O = L.memoizedState, _ = O !== null ? O.dehydrated : null;
      if (!_)
        throw new Error("Expected to have a hydrated suspense instance. This error is likely caused by a bug in React. Please file an issue.");
      dd0(_, L);
    }
    function jp0(L) {
      var O = L.memoizedState, _ = O !== null ? O.dehydrated : null;
      if (!_)
        throw new Error("Expected to have a hydrated suspense instance. This error is likely caused by a bug in React. Please file an issue.");
      return pd0(_);
    }
    function KJ0(L) {
      var O = L.return;
      while (O !== null && O.tag !== q && O.tag !== H && O.tag !== B)
        O = O.return;
      lY = O;
    }
    function yC(L) {
      if (L !== lY)
        return !1;
      if (!CG)
        return KJ0(L), CG = !0, !1;
      if (L.tag !== H && (L.tag !== q || ld0(L.type) && !Kp(L.type, L.memoizedProps))) {
        var O = lK;
        if (O)
          if (wp(L))
            GJ0(L), jp();
          else
            while (O)
              YJ0(L, O), O = jj(O);
      }
      if (KJ0(L), L.tag === B)
        lK = jp0(L);
      else
        lK = lY ? jj(L.stateNode) : null;
      return !0;
    }
    function Tp0() {
      return CG && lK !== null;
    }
    function GJ0(L) {
      var O = lK;
      while (O)
        XJ0(L, O), O = jj(O);
    }
    function KD() {
      lY = null, lK = null, CG = !1, NO = !1;
    }
    function HJ0() {
      if (rU !== null)
        XX0(rU), rU = null;
    }
    function nY() {
      return CG;
    }
    function _p(L) {
      if (rU === null)
        rU = [L];
      else
        rU.push(L);
    }
    var _p0 = Z.ReactCurrentBatchConfig, Vp0 = null;
    function Ip0() {
      return _p0.transition;
    }
    var kG = {
      recordUnsafeLifecycleWarnings: function(L, O) {},
      flushPendingUnsafeLifecycleWarnings: function() {},
      recordLegacyContextWarning: function(L, O) {},
      flushLegacyContextWarning: function() {},
      discardPendingWarnings: function() {}
    };
    {
      var Pp0 = function(L) {
        var O = null, _ = L;
        while (_ !== null) {
          if (_.mode & Y$)
            O = _;
          _ = _.return;
        }
        return O;
      }, qO = function(L) {
        var O = [];
        return L.forEach(function(_) {
          O.push(_);
        }), O.sort().join(", ");
      }, Ij = [], Pj = [], Cj = [], kj = [], vj = [], Sj = [], FO = /* @__PURE__ */ new Set;
      kG.recordUnsafeLifecycleWarnings = function(L, O) {
        if (FO.has(L.type))
          return;
        if (typeof O.componentWillMount === "function" && O.componentWillMount.__suppressDeprecationWarning !== !0)
          Ij.push(L);
        if (L.mode & Y$ && typeof O.UNSAFE_componentWillMount === "function")
          Pj.push(L);
        if (typeof O.componentWillReceiveProps === "function" && O.componentWillReceiveProps.__suppressDeprecationWarning !== !0)
          Cj.push(L);
        if (L.mode & Y$ && typeof O.UNSAFE_componentWillReceiveProps === "function")
          kj.push(L);
        if (typeof O.componentWillUpdate === "function" && O.componentWillUpdate.__suppressDeprecationWarning !== !0)
          vj.push(L);
        if (L.mode & Y$ && typeof O.UNSAFE_componentWillUpdate === "function")
          Sj.push(L);
      }, kG.flushPendingUnsafeLifecycleWarnings = function() {
        var L = /* @__PURE__ */ new Set;
        if (Ij.length > 0)
          Ij.forEach(function(U1) {
            L.add(D6(U1) || "Component"), FO.add(U1.type);
          }), Ij = [];
        var O = /* @__PURE__ */ new Set;
        if (Pj.length > 0)
          Pj.forEach(function(U1) {
            O.add(D6(U1) || "Component"), FO.add(U1.type);
          }), Pj = [];
        var _ = /* @__PURE__ */ new Set;
        if (Cj.length > 0)
          Cj.forEach(function(U1) {
            _.add(D6(U1) || "Component"), FO.add(U1.type);
          }), Cj = [];
        var k = /* @__PURE__ */ new Set;
        if (kj.length > 0)
          kj.forEach(function(U1) {
            k.add(D6(U1) || "Component"), FO.add(U1.type);
          }), kj = [];
        var y = /* @__PURE__ */ new Set;
        if (vj.length > 0)
          vj.forEach(function(U1) {
            y.add(D6(U1) || "Component"), FO.add(U1.type);
          }), vj = [];
        var d = /* @__PURE__ */ new Set;
        if (Sj.length > 0)
          Sj.forEach(function(U1) {
            d.add(D6(U1) || "Component"), FO.add(U1.type);
          }), Sj = [];
        if (O.size > 0) {
          var o = qO(O);
          Y(`Using UNSAFE_componentWillMount in strict mode is not recommended and may indicate bugs in your code. See https://reactjs.org/link/unsafe-component-lifecycles for details.

* Move code with side effects to componentDidMount, and set initial state in the constructor.

Please update the following components: %s`, o);
        }
        if (k.size > 0) {
          var H0 = qO(k);
          Y(`Using UNSAFE_componentWillReceiveProps in strict mode is not recommended and may indicate bugs in your code. See https://reactjs.org/link/unsafe-component-lifecycles for details.

* Move data fetching code or side effects to componentDidUpdate.
* If you're updating state whenever props change, refactor your code to use memoization techniques or move it to static getDerivedStateFromProps. Learn more at: https://reactjs.org/link/derived-state

Please update the following components: %s`, H0);
        }
        if (d.size > 0) {
          var O0 = qO(d);
          Y(`Using UNSAFE_componentWillUpdate in strict mode is not recommended and may indicate bugs in your code. See https://reactjs.org/link/unsafe-component-lifecycles for details.

* Move data fetching code or side effects to componentDidUpdate.

Please update the following components: %s`, O0);
        }
        if (L.size > 0) {
          var I0 = qO(L);
          X(`componentWillMount has been renamed, and is not recommended for use. See https://reactjs.org/link/unsafe-component-lifecycles for details.

* Move code with side effects to componentDidMount, and set initial state in the constructor.
* Rename componentWillMount to UNSAFE_componentWillMount to suppress this warning in non-strict mode. In React 18.x, only the UNSAFE_ name will work. To rename all deprecated lifecycles to their new names, you can run \`npx react-codemod rename-unsafe-lifecycles\` in your project source folder.

Please update the following components: %s`, I0);
        }
        if (_.size > 0) {
          var g0 = qO(_);
          X(`componentWillReceiveProps has been renamed, and is not recommended for use. See https://reactjs.org/link/unsafe-component-lifecycles for details.

* Move data fetching code or side effects to componentDidUpdate.
* If you're updating state whenever props change, refactor your code to use memoization techniques or move it to static getDerivedStateFromProps. Learn more at: https://reactjs.org/link/derived-state
* Rename componentWillReceiveProps to UNSAFE_componentWillReceiveProps to suppress this warning in non-strict mode. In React 18.x, only the UNSAFE_ name will work. To rename all deprecated lifecycles to their new names, you can run \`npx react-codemod rename-unsafe-lifecycles\` in your project source folder.

Please update the following components: %s`, g0);
        }
        if (y.size > 0) {
          var R1 = qO(y);
          X(`componentWillUpdate has been renamed, and is not recommended for use. See https://reactjs.org/link/unsafe-component-lifecycles for details.

* Move data fetching code or side effects to componentDidUpdate.
* Rename componentWillUpdate to UNSAFE_componentWillUpdate to suppress this warning in non-strict mode. In React 18.x, only the UNSAFE_ name will work. To rename all deprecated lifecycles to their new names, you can run \`npx react-codemod rename-unsafe-lifecycles\` in your project source folder.

Please update the following components: %s`, R1);
        }
      };
      var gC = /* @__PURE__ */ new Map, NJ0 = /* @__PURE__ */ new Set;
      kG.recordLegacyContextWarning = function(L, O) {
        var _ = Pp0(L);
        if (_ === null) {
          Y("Expected to find a StrictMode component in a strict mode tree. This error is likely caused by a bug in React. Please file an issue.");
          return;
        }
        if (NJ0.has(L.type))
          return;
        var k = gC.get(_);
        if (L.type.contextTypes != null || L.type.childContextTypes != null || O !== null && typeof O.getChildContext === "function") {
          if (k === void 0)
            k = [], gC.set(_, k);
          k.push(L);
        }
      }, kG.flushLegacyContextWarning = function() {
        gC.forEach(function(L, O) {
          if (L.length === 0)
            return;
          var _ = L[0], k = /* @__PURE__ */ new Set;
          L.forEach(function(d) {
            k.add(D6(d) || "Component"), NJ0.add(d.type);
          });
          var y = qO(k);
          try {
            mJ(_), Y(`Legacy context API has been detected within a strict-mode tree.

The old API will be supported in all 16.x releases, but applications using it should migrate to the new version.

Please update the following components: %s

Learn more about this warning here: https://reactjs.org/link/legacy-context`, y);
          } finally {
            aX();
          }
        });
      }, kG.discardPendingWarnings = function() {
        Ij = [], Pj = [], Cj = [], kj = [], vj = [], Sj = [], gC = /* @__PURE__ */ new Map;
      };
    }
    var Vp, Ip, Pp, Cp, kp, qJ0 = function(L, O) {};
    Vp = !1, Ip = !1, Pp = {}, Cp = {}, kp = {}, qJ0 = function(L, O) {
      if (L === null || typeof L !== "object")
        return;
      if (!L._store || L._store.validated || L.key != null)
        return;
      if (typeof L._store !== "object")
        throw new Error("React Component in warnForMissingKey should have a _store. This error is likely caused by a bug in React. Please file an issue.");
      L._store.validated = !0;
      var _ = D6(O) || "Component";
      if (Cp[_])
        return;
      Cp[_] = !0, Y('Each child in a list should have a unique "key" prop. See https://reactjs.org/link/warning-keys for more information.');
    };
    function Cp0(L) {
      return L.prototype && L.prototype.isReactComponent;
    }
    function fj(L, O, _) {
      var k = _.ref;
      if (k !== null && typeof k !== "function" && typeof k !== "object") {
        if ((L.mode & Y$ || l) && !(_._owner && _._self && _._owner.stateNode !== _._self) && !(_._owner && _._owner.tag !== K) && !(typeof _.type === "function" && !Cp0(_.type)) && _._owner) {
          var y = D6(L) || "Component";
          if (!Pp[y])
            Y('Component "%s" contains the string ref "%s". Support for string refs will be removed in a future major release. We recommend using useRef() or createRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref', y, k), Pp[y] = !0;
        }
        if (_._owner) {
          var d = _._owner, o;
          if (d) {
            var H0 = d;
            if (H0.tag !== K)
              throw new Error("Function components cannot have string refs. We recommend using useRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref");
            o = H0.stateNode;
          }
          if (!o)
            throw new Error("Missing owner for string ref " + k + ". This error is likely caused by a bug in React. Please file an issue.");
          var O0 = o;
          q0(k, "ref");
          var I0 = "" + k;
          if (O !== null && O.ref !== null && typeof O.ref === "function" && O.ref._stringRef === I0)
            return O.ref;
          var g0 = function(R1) {
            var U1 = O0.refs;
            if (R1 === null)
              delete U1[I0];
            else
              U1[I0] = R1;
          };
          return g0._stringRef = I0, g0;
        } else {
          if (typeof k !== "string")
            throw new Error("Expected ref to be a function, a string, an object returned by React.createRef(), or null.");
          if (!_._owner)
            throw new Error("Element ref was specified as a string (" + k + `) but no owner was set. This could happen for one of the following reasons:
1. You may be adding a ref to a function component
2. You may be adding a ref to a component that was not created inside a component's render method
3. You have multiple copies of React loaded
See https://reactjs.org/link/refs-must-have-owner for more information.`);
        }
      }
      return k;
    }
    function mC(L, O) {
      var _ = Object.prototype.toString.call(O);
      throw new Error("Objects are not valid as a React child (found: " + (_ === "[object Object]" ? "object with keys {" + Object.keys(O).join(", ") + "}" : _) + "). If you meant to render a collection of children, use an array instead.");
    }
    function dC(L) {
      {
        var O = D6(L) || "Component";
        if (kp[O])
          return;
        kp[O] = !0, Y("Functions are not valid as a React child. This may happen if you return a Component instead of <Component /> from render. Or maybe you meant to call this function rather than return it.");
      }
    }
    function FJ0(L) {
      var { _payload: O, _init: _ } = L;
      return _(O);
    }
    function UJ0(L) {
      function O(C1, Y2) {
        if (!L)
          return;
        var k1 = C1.deletions;
        if (k1 === null)
          C1.deletions = [Y2], C1.flags |= iE;
        else
          k1.push(Y2);
      }
      function _(C1, Y2) {
        if (!L)
          return null;
        var k1 = Y2;
        while (k1 !== null)
          O(C1, k1), k1 = k1.sibling;
        return null;
      }
      function k(C1, Y2) {
        var k1 = /* @__PURE__ */ new Map, k2 = Y2;
        while (k2 !== null) {
          if (k2.key !== null)
            k1.set(k2.key, k2);
          else
            k1.set(k2.index, k2);
          k2 = k2.sibling;
        }
        return k1;
      }
      function y(C1, Y2) {
        var k1 = AO(C1, Y2);
        return k1.index = 0, k1.sibling = null, k1;
      }
      function d(C1, Y2, k1) {
        if (C1.index = k1, !L)
          return C1.flags |= R90, Y2;
        var k2 = C1.alternate;
        if (k2 !== null) {
          var z8 = k2.index;
          if (z8 < Y2)
            return C1.flags |= u$, Y2;
          else
            return z8;
        } else
          return C1.flags |= u$, Y2;
      }
      function o(C1) {
        if (L && C1.alternate === null)
          C1.flags |= u$;
        return C1;
      }
      function H0(C1, Y2, k1, k2) {
        if (Y2 === null || Y2.tag !== U) {
          var z8 = Ic(k1, C1.mode, k2);
          return z8.return = C1, z8;
        } else {
          var q8 = y(Y2, k1);
          return q8.return = C1, q8;
        }
      }
      function O0(C1, Y2, k1, k2) {
        var z8 = k1.type;
        if (z8 === z1)
          return g0(C1, Y2, k1.props.children, k2, k1.key);
        if (Y2 !== null) {
          if (Y2.elementType === z8 || DX0(Y2, k1) || typeof z8 === "object" && z8 !== null && z8.$$typeof === I1 && FJ0(z8) === Y2.type) {
            var q8 = y(Y2, k1.props);
            return q8.ref = fj(C1, Y2, k1), q8.return = C1, q8._debugSource = k1._source, q8._debugOwner = k1._owner, q8;
          }
        }
        var I6 = Vc(k1, C1.mode, k2);
        return I6.ref = fj(C1, Y2, k1), I6.return = C1, I6;
      }
      function I0(C1, Y2, k1, k2) {
        if (Y2 === null || Y2.tag !== N || Y2.stateNode.containerInfo !== k1.containerInfo || Y2.stateNode.implementation !== k1.implementation) {
          var z8 = Pc(k1, C1.mode, k2);
          return z8.return = C1, z8;
        } else {
          var q8 = y(Y2, k1.children || []);
          return q8.return = C1, q8;
        }
      }
      function g0(C1, Y2, k1, k2, z8) {
        if (Y2 === null || Y2.tag !== F) {
          var q8 = GL(k1, C1.mode, k2, z8);
          return q8.return = C1, q8;
        } else {
          var I6 = y(Y2, k1);
          return I6.return = C1, I6;
        }
      }
      function R1(C1, Y2, k1) {
        if (typeof Y2 === "string" && Y2 !== "" || typeof Y2 === "number") {
          var k2 = Ic("" + Y2, C1.mode, k1);
          return k2.return = C1, k2;
        }
        if (typeof Y2 === "object" && Y2 !== null) {
          switch (Y2.$$typeof) {
            case P0: {
              var z8 = Vc(Y2, C1.mode, k1);
              return z8.ref = fj(C1, null, Y2), z8.return = C1, z8;
            }
            case l0: {
              var q8 = Pc(Y2, C1.mode, k1);
              return q8.return = C1, q8;
            }
            case I1: {
              var { _payload: I6, _init: e6 } = Y2;
              return R1(C1, e6(I6), k1);
            }
          }
          if (b9(Y2) || s2(Y2)) {
            var R7 = GL(Y2, C1.mode, k1, null);
            return R7.return = C1, R7;
          }
          mC(C1, Y2);
        }
        if (typeof Y2 === "function")
          dC(C1);
        return null;
      }
      function U1(C1, Y2, k1, k2) {
        var z8 = Y2 !== null ? Y2.key : null;
        if (typeof k1 === "string" && k1 !== "" || typeof k1 === "number") {
          if (z8 !== null)
            return null;
          return H0(C1, Y2, "" + k1, k2);
        }
        if (typeof k1 === "object" && k1 !== null) {
          switch (k1.$$typeof) {
            case P0:
              if (k1.key === z8)
                return O0(C1, Y2, k1, k2);
              else
                return null;
            case l0:
              if (k1.key === z8)
                return I0(C1, Y2, k1, k2);
              else
                return null;
            case I1: {
              var { _payload: q8, _init: I6 } = k1;
              return U1(C1, Y2, I6(q8), k2);
            }
          }
          if (b9(k1) || s2(k1)) {
            if (z8 !== null)
              return null;
            return g0(C1, Y2, k1, k2, null);
          }
          mC(C1, k1);
        }
        if (typeof k1 === "function")
          dC(C1);
        return null;
      }
      function x1(C1, Y2, k1, k2, z8) {
        if (typeof k2 === "string" && k2 !== "" || typeof k2 === "number") {
          var q8 = C1.get(k1) || null;
          return H0(Y2, q8, "" + k2, z8);
        }
        if (typeof k2 === "object" && k2 !== null) {
          switch (k2.$$typeof) {
            case P0: {
              var I6 = C1.get(k2.key === null ? k1 : k2.key) || null;
              return O0(Y2, I6, k2, z8);
            }
            case l0: {
              var e6 = C1.get(k2.key === null ? k1 : k2.key) || null;
              return I0(Y2, e6, k2, z8);
            }
            case I1:
              var { _payload: R7, _init: V9 } = k2;
              return x1(C1, Y2, k1, V9(R7), z8);
          }
          if (b9(k2) || s2(k2)) {
            var I$ = C1.get(k1) || null;
            return g0(Y2, I$, k2, z8, null);
          }
          mC(Y2, k2);
        }
        if (typeof k2 === "function")
          dC(Y2);
        return null;
      }
      function y1(C1, Y2, k1) {
        {
          if (typeof C1 !== "object" || C1 === null)
            return Y2;
          switch (C1.$$typeof) {
            case P0:
            case l0:
              qJ0(C1, k1);
              var k2 = C1.key;
              if (typeof k2 !== "string")
                break;
              if (Y2 === null) {
                Y2 = /* @__PURE__ */ new Set, Y2.add(k2);
                break;
              }
              if (!Y2.has(k2)) {
                Y2.add(k2);
                break;
              }
              Y("Encountered two children with the same key, `%s`. Keys should be unique so that components maintain their identity across updates. Non-unique keys may cause children to be " + "duplicated and/or omitted — the behavior is unsupported and " + "could change in a future version.", k2);
              break;
            case I1:
              var { _payload: z8, _init: q8 } = C1;
              y1(q8(z8), Y2, k1);
              break;
          }
        }
        return Y2;
      }
      function r1(C1, Y2, k1, k2) {
        {
          var z8 = null;
          for (var q8 = 0;q8 < k1.length; q8++) {
            var I6 = k1[q8];
            z8 = y1(I6, z8, C1);
          }
        }
        var e6 = null, R7 = null, V9 = Y2, I$ = 0, I9 = 0, Q$ = null;
        for (;V9 !== null && I9 < k1.length; I9++) {
          if (V9.index > I9)
            Q$ = V9, V9 = null;
          else
            Q$ = V9.sibling;
          var jQ = U1(C1, V9, k1[I9], k2);
          if (jQ === null) {
            if (V9 === null)
              V9 = Q$;
            break;
          }
          if (L) {
            if (V9 && jQ.alternate === null)
              O(C1, V9);
          }
          if (I$ = d(jQ, I$, I9), R7 === null)
            e6 = jQ;
          else
            R7.sibling = jQ;
          R7 = jQ, V9 = Q$;
        }
        if (I9 === k1.length) {
          if (_(C1, V9), nY()) {
            var eY = I9;
            GO(C1, eY);
          }
          return e6;
        }
        if (V9 === null) {
          for (;I9 < k1.length; I9++) {
            var ZK = R1(C1, k1[I9], k2);
            if (ZK === null)
              continue;
            if (I$ = d(ZK, I$, I9), R7 === null)
              e6 = ZK;
            else
              R7.sibling = ZK;
            R7 = ZK;
          }
          if (nY()) {
            var RW = I9;
            GO(C1, RW);
          }
          return e6;
        }
        var EW = k(C1, V9);
        for (;I9 < k1.length; I9++) {
          var TQ = x1(EW, C1, I9, k1[I9], k2);
          if (TQ !== null) {
            if (L) {
              if (TQ.alternate !== null)
                EW.delete(TQ.key === null ? I9 : TQ.key);
            }
            if (I$ = d(TQ, I$, I9), R7 === null)
              e6 = TQ;
            else
              R7.sibling = TQ;
            R7 = TQ;
          }
        }
        if (L)
          EW.forEach(function(_D) {
            return O(C1, _D);
          });
        if (nY()) {
          var EF = I9;
          GO(C1, EF);
        }
        return e6;
      }
      function Q8(C1, Y2, k1, k2) {
        var z8 = s2(k1);
        if (typeof z8 !== "function")
          throw new Error("An object is not an iterable. This error is likely caused by a bug in React. Please file an issue.");
        {
          if (typeof Symbol === "function" && k1[Symbol.toStringTag] === "Generator") {
            if (!Ip)
              Y("Using Generators as children is unsupported and will likely yield unexpected results because enumerating a generator mutates it. You may convert it to an array with `Array.from()` or the `[...spread]` operator before rendering. Keep in mind you might need to polyfill these features for older browsers.");
            Ip = !0;
          }
          if (k1.entries === z8) {
            if (!Vp)
              Y("Using Maps as children is not supported. Use an array of keyed ReactElements instead.");
            Vp = !0;
          }
          var q8 = z8.call(k1);
          if (q8) {
            var I6 = null, e6 = q8.next();
            for (;!e6.done; e6 = q8.next()) {
              var R7 = e6.value;
              I6 = y1(R7, I6, C1);
            }
          }
        }
        var V9 = z8.call(k1);
        if (V9 == null)
          throw new Error("An iterable object provided no iterator.");
        var I$ = null, I9 = null, Q$ = Y2, jQ = 0, eY = 0, ZK = null, RW = V9.next();
        for (;Q$ !== null && !RW.done; eY++, RW = V9.next()) {
          if (Q$.index > eY)
            ZK = Q$, Q$ = null;
          else
            ZK = Q$.sibling;
          var EW = U1(C1, Q$, RW.value, k2);
          if (EW === null) {
            if (Q$ === null)
              Q$ = ZK;
            break;
          }
          if (L) {
            if (Q$ && EW.alternate === null)
              O(C1, Q$);
          }
          if (jQ = d(EW, jQ, eY), I9 === null)
            I$ = EW;
          else
            I9.sibling = EW;
          I9 = EW, Q$ = ZK;
        }
        if (RW.done) {
          if (_(C1, Q$), nY()) {
            var TQ = eY;
            GO(C1, TQ);
          }
          return I$;
        }
        if (Q$ === null) {
          for (;!RW.done; eY++, RW = V9.next()) {
            var EF = R1(C1, RW.value, k2);
            if (EF === null)
              continue;
            if (jQ = d(EF, jQ, eY), I9 === null)
              I$ = EF;
            else
              I9.sibling = EF;
            I9 = EF;
          }
          if (nY()) {
            var _D = eY;
            GO(C1, _D);
          }
          return I$;
        }
        var FT = k(C1, Q$);
        for (;!RW.done; eY++, RW = V9.next()) {
          var WN = x1(FT, C1, eY, RW.value, k2);
          if (WN !== null) {
            if (L) {
              if (WN.alternate !== null)
                FT.delete(WN.key === null ? eY : WN.key);
            }
            if (jQ = d(WN, jQ, eY), I9 === null)
              I$ = WN;
            else
              I9.sibling = WN;
            I9 = WN;
          }
        }
        if (L)
          FT.forEach(function(Wn0) {
            return O(C1, Wn0);
          });
        if (nY()) {
          var Qn0 = eY;
          GO(C1, Qn0);
        }
        return I$;
      }
      function J6(C1, Y2, k1, k2) {
        if (Y2 !== null && Y2.tag === U) {
          _(C1, Y2.sibling);
          var z8 = y(Y2, k1);
          return z8.return = C1, z8;
        }
        _(C1, Y2);
        var q8 = Ic(k1, C1.mode, k2);
        return q8.return = C1, q8;
      }
      function b8(C1, Y2, k1, k2) {
        var z8 = k1.key, q8 = Y2;
        while (q8 !== null) {
          if (q8.key === z8) {
            var I6 = k1.type;
            if (I6 === z1) {
              if (q8.tag === F) {
                _(C1, q8.sibling);
                var e6 = y(q8, k1.props.children);
                return e6.return = C1, e6._debugSource = k1._source, e6._debugOwner = k1._owner, e6;
              }
            } else if (q8.elementType === I6 || DX0(q8, k1) || typeof I6 === "object" && I6 !== null && I6.$$typeof === I1 && FJ0(I6) === q8.type) {
              _(C1, q8.sibling);
              var R7 = y(q8, k1.props);
              return R7.ref = fj(C1, q8, k1), R7.return = C1, R7._debugSource = k1._source, R7._debugOwner = k1._owner, R7;
            }
            _(C1, q8);
            break;
          } else
            O(C1, q8);
          q8 = q8.sibling;
        }
        if (k1.type === z1) {
          var V9 = GL(k1.props.children, C1.mode, k2, k1.key);
          return V9.return = C1, V9;
        } else {
          var I$ = Vc(k1, C1.mode, k2);
          return I$.ref = fj(C1, Y2, k1), I$.return = C1, I$;
        }
      }
      function oZ(C1, Y2, k1, k2) {
        var z8 = k1.key, q8 = Y2;
        while (q8 !== null) {
          if (q8.key === z8)
            if (q8.tag === N && q8.stateNode.containerInfo === k1.containerInfo && q8.stateNode.implementation === k1.implementation) {
              _(C1, q8.sibling);
              var I6 = y(q8, k1.children || []);
              return I6.return = C1, I6;
            } else {
              _(C1, q8);
              break;
            }
          else
            O(C1, q8);
          q8 = q8.sibling;
        }
        var e6 = Pc(k1, C1.mode, k2);
        return e6.return = C1, e6;
      }
      function sZ(C1, Y2, k1, k2) {
        var z8 = typeof k1 === "object" && k1 !== null && k1.type === z1 && k1.key === null;
        if (z8)
          k1 = k1.props.children;
        if (typeof k1 === "object" && k1 !== null) {
          switch (k1.$$typeof) {
            case P0:
              return o(b8(C1, Y2, k1, k2));
            case l0:
              return o(oZ(C1, Y2, k1, k2));
            case I1:
              var { _payload: q8, _init: I6 } = k1;
              return sZ(C1, Y2, I6(q8), k2);
          }
          if (b9(k1))
            return r1(C1, Y2, k1, k2);
          if (s2(k1))
            return Q8(C1, Y2, k1, k2);
          mC(C1, k1);
        }
        if (typeof k1 === "string" && k1 !== "" || typeof k1 === "number")
          return o(J6(C1, Y2, "" + k1, k2));
        if (typeof k1 === "function")
          dC(C1);
        return _(C1, Y2);
      }
      return sZ;
    }
    var GD = UJ0(!0), LJ0 = UJ0(!1);
    function kp0(L, O) {
      if (L !== null && O.child !== L.child)
        throw new Error("Resuming work not yet implemented.");
      if (O.child === null)
        return;
      var _ = O.child, k = AO(_, _.pendingProps);
      O.child = k, k.return = O;
      while (_.sibling !== null)
        _ = _.sibling, k = k.sibling = AO(_, _.pendingProps), k.return = O;
      k.sibling = null;
    }
    function vp0(L, O) {
      var _ = L.child;
      while (_ !== null)
        wl0(_, O), _ = _.sibling;
    }
    var vp = oU(null), Sp;
    Sp = {};
    var pC = null, HD = null, fp = null, uC = !1;
    function cC() {
      pC = null, HD = null, fp = null, uC = !1;
    }
    function RJ0() {
      uC = !0;
    }
    function EJ0() {
      uC = !1;
    }
    function OJ0(L, O, _) {
      {
        BQ(vp, O._currentValue, L), O._currentValue = _;
        {
          if (O._currentRenderer !== void 0 && O._currentRenderer !== null && O._currentRenderer !== Sp)
            Y("Detected multiple renderers concurrently rendering the same context provider. This is currently unsupported.");
          O._currentRenderer = Sp;
        }
      }
    }
    function hp(L, O) {
      var _ = vp.current;
      AQ(vp, O), L._currentValue = _;
    }
    function bp(L, O, _) {
      var k = L;
      while (k !== null) {
        var y = k.alternate;
        if (!i4(k.childLanes, O)) {
          if (k.childLanes = BZ(k.childLanes, O), y !== null)
            y.childLanes = BZ(y.childLanes, O);
        } else if (y !== null && !i4(y.childLanes, O))
          y.childLanes = BZ(y.childLanes, O);
        if (k === _)
          break;
        k = k.return;
      }
      if (k !== _)
        Y("Expected to find the propagation root when scheduling context work. This error is likely caused by a bug in React. Please file an issue.");
    }
    function Sp0(L, O, _) {
      fp0(L, O, _);
    }
    function fp0(L, O, _) {
      var k = L.child;
      if (k !== null)
        k.return = L;
      while (k !== null) {
        var y = void 0, d = k.dependencies;
        if (d !== null) {
          y = k.child;
          var o = d.firstContext;
          while (o !== null) {
            if (o.context === O) {
              if (k.tag === K) {
                var H0 = tw(_), O0 = NF(s7, H0);
                O0.tag = nC;
                var I0 = k.updateQueue;
                if (I0 === null)
                  ;
                else {
                  var g0 = I0.shared, R1 = g0.pending;
                  if (R1 === null)
                    O0.next = O0;
                  else
                    O0.next = R1.next, R1.next = O0;
                  g0.pending = O0;
                }
              }
              k.lanes = BZ(k.lanes, _);
              var U1 = k.alternate;
              if (U1 !== null)
                U1.lanes = BZ(U1.lanes, _);
              bp(k.return, _, L), d.lanes = BZ(d.lanes, _);
              break;
            }
            o = o.next;
          }
        } else if (k.tag === z)
          y = k.type === L.type ? null : k.child;
        else if (k.tag === I) {
          var x1 = k.return;
          if (x1 === null)
            throw new Error("We just came from a parent so we must have had a parent. This is a bug in React.");
          x1.lanes = BZ(x1.lanes, _);
          var y1 = x1.alternate;
          if (y1 !== null)
            y1.lanes = BZ(y1.lanes, _);
          bp(x1, _, L), y = k.sibling;
        } else
          y = k.child;
        if (y !== null)
          y.return = k;
        else {
          y = k;
          while (y !== null) {
            if (y === L) {
              y = null;
              break;
            }
            var r1 = y.sibling;
            if (r1 !== null) {
              r1.return = y.return, y = r1;
              break;
            }
            y = y.return;
          }
        }
        k = y;
      }
    }
    function ND(L, O) {
      pC = L, HD = null, fp = null;
      var _ = L.dependencies;
      if (_ !== null) {
        var k = _.firstContext;
        if (k !== null) {
          if (o5(_.lanes, O))
            sj();
          _.firstContext = null;
        }
      }
    }
    function c$(L) {
      if (uC)
        Y("Context can only be read while React is rendering. In classes, you can read it in the render method or getDerivedStateFromProps. In function components, you can read it directly in the function body, but not inside Hooks like useReducer() or useMemo().");
      var O = L._currentValue;
      if (fp === L)
        ;
      else {
        var _ = {
          context: L,
          memoizedValue: O,
          next: null
        };
        if (HD === null) {
          if (pC === null)
            throw new Error("Context can only be read while React is rendering. In classes, you can read it in the render method or getDerivedStateFromProps. In function components, you can read it directly in the function body, but not inside Hooks like useReducer() or useMemo().");
          HD = _, pC.dependencies = {
            lanes: T2,
            firstContext: _
          };
        } else
          HD = HD.next = _;
      }
      return O;
    }
    var UO = null;
    function xp(L) {
      if (UO === null)
        UO = [L];
      else
        UO.push(L);
    }
    function hp0() {
      if (UO !== null) {
        for (var L = 0;L < UO.length; L++) {
          var O = UO[L], _ = O.interleaved;
          if (_ !== null) {
            O.interleaved = null;
            var k = _.next, y = O.pending;
            if (y !== null) {
              var d = y.next;
              y.next = k, _.next = d;
            }
            O.pending = _;
          }
        }
        UO = null;
      }
    }
    function zJ0(L, O, _, k) {
      var y = O.interleaved;
      if (y === null)
        _.next = _, xp(O);
      else
        _.next = y.next, y.next = _;
      return O.interleaved = _, lC(L, k);
    }
    function bp0(L, O, _, k) {
      var y = O.interleaved;
      if (y === null)
        _.next = _, xp(O);
      else
        _.next = y.next, y.next = _;
      O.interleaved = _;
    }
    function xp0(L, O, _, k) {
      var y = O.interleaved;
      if (y === null)
        _.next = _, xp(O);
      else
        _.next = y.next, y.next = _;
      return O.interleaved = _, lC(L, k);
    }
    function X5(L, O) {
      return lC(L, O);
    }
    var yp0 = lC;
    function lC(L, O) {
      L.lanes = BZ(L.lanes, O);
      var _ = L.alternate;
      if (_ !== null)
        _.lanes = BZ(_.lanes, O);
      if (_ === null && (L.flags & (u$ | eq)) !== M6)
        RX0(L);
      var k = L, y = L.return;
      while (y !== null) {
        if (y.childLanes = BZ(y.childLanes, O), _ = y.alternate, _ !== null)
          _.childLanes = BZ(_.childLanes, O);
        else if ((y.flags & (u$ | eq)) !== M6)
          RX0(L);
        k = y, y = y.return;
      }
      if (k.tag === H) {
        var d = k.stateNode;
        return d;
      } else
        return null;
    }
    var DJ0 = 0, MJ0 = 1, nC = 2, yp = 3, iC = !1, gp, oC;
    gp = !1, oC = null;
    function mp(L) {
      var O = {
        baseState: L.memoizedState,
        firstBaseUpdate: null,
        lastBaseUpdate: null,
        shared: {
          pending: null,
          interleaved: null,
          lanes: T2
        },
        effects: null
      };
      L.updateQueue = O;
    }
    function AJ0(L, O) {
      var _ = O.updateQueue, k = L.updateQueue;
      if (_ === k) {
        var y = {
          baseState: k.baseState,
          firstBaseUpdate: k.firstBaseUpdate,
          lastBaseUpdate: k.lastBaseUpdate,
          shared: k.shared,
          effects: k.effects
        };
        O.updateQueue = y;
      }
    }
    function NF(L, O) {
      var _ = {
        eventTime: L,
        lane: O,
        tag: DJ0,
        payload: null,
        callback: null,
        next: null
      };
      return _;
    }
    function tU(L, O, _) {
      var k = L.updateQueue;
      if (k === null)
        return null;
      var y = k.shared;
      if (oC === y && !gp)
        Y("An update (setState, replaceState, or forceUpdate) was scheduled from inside an update function. Update functions should be pure, with zero side-effects. Consider using componentDidUpdate or a callback."), gp = !0;
      if (mc0()) {
        var d = y.pending;
        if (d === null)
          O.next = O;
        else
          O.next = d.next, d.next = O;
        return y.pending = O, yp0(L, _);
      } else
        return xp0(L, y, O, _);
    }
    function sC(L, O, _) {
      var k = O.updateQueue;
      if (k === null)
        return;
      var y = k.shared;
      if (S90(_)) {
        var d = y.lanes;
        d = h90(d, L.pendingLanes);
        var o = BZ(d, _);
        y.lanes = o, vd(L, o);
      }
    }
    function dp(L, O) {
      var { updateQueue: _, alternate: k } = L;
      if (k !== null) {
        var y = k.updateQueue;
        if (_ === y) {
          var d = null, o = null, H0 = _.firstBaseUpdate;
          if (H0 !== null) {
            var O0 = H0;
            do {
              var I0 = {
                eventTime: O0.eventTime,
                lane: O0.lane,
                tag: O0.tag,
                payload: O0.payload,
                callback: O0.callback,
                next: null
              };
              if (o === null)
                d = o = I0;
              else
                o.next = I0, o = I0;
              O0 = O0.next;
            } while (O0 !== null);
            if (o === null)
              d = o = O;
            else
              o.next = O, o = O;
          } else
            d = o = O;
          _ = {
            baseState: y.baseState,
            firstBaseUpdate: d,
            lastBaseUpdate: o,
            shared: y.shared,
            effects: y.effects
          }, L.updateQueue = _;
          return;
        }
      }
      var g0 = _.lastBaseUpdate;
      if (g0 === null)
        _.firstBaseUpdate = O;
      else
        g0.next = O;
      _.lastBaseUpdate = O;
    }
    function gp0(L, O, _, k, y, d) {
      switch (_.tag) {
        case MJ0: {
          var o = _.payload;
          if (typeof o === "function") {
            RJ0();
            var H0 = o.call(d, k, y);
            {
              if (L.mode & Y$) {
                tX(!0);
                try {
                  o.call(d, k, y);
                } finally {
                  tX(!1);
                }
              }
              EJ0();
            }
            return H0;
          }
          return o;
        }
        case yp:
          L.flags = L.flags & ~qW | x9;
        case DJ0: {
          var O0 = _.payload, I0;
          if (typeof O0 === "function") {
            RJ0(), I0 = O0.call(d, k, y);
            {
              if (L.mode & Y$) {
                tX(!0);
                try {
                  O0.call(d, k, y);
                } finally {
                  tX(!1);
                }
              }
              EJ0();
            }
          } else
            I0 = O0;
          if (I0 === null || I0 === void 0)
            return k;
          return d0({}, k, I0);
        }
        case nC:
          return iC = !0, k;
      }
      return k;
    }
    function aC(L, O, _, k) {
      var y = L.updateQueue;
      iC = !1, oC = y.shared;
      var { firstBaseUpdate: d, lastBaseUpdate: o } = y, H0 = y.shared.pending;
      if (H0 !== null) {
        y.shared.pending = null;
        var O0 = H0, I0 = O0.next;
        if (O0.next = null, o === null)
          d = I0;
        else
          o.next = I0;
        o = O0;
        var g0 = L.alternate;
        if (g0 !== null) {
          var R1 = g0.updateQueue, U1 = R1.lastBaseUpdate;
          if (U1 !== o) {
            if (U1 === null)
              R1.firstBaseUpdate = I0;
            else
              U1.next = I0;
            R1.lastBaseUpdate = O0;
          }
        }
      }
      if (d !== null) {
        var x1 = y.baseState, y1 = T2, r1 = null, Q8 = null, J6 = null, b8 = d;
        do {
          var { lane: oZ, eventTime: sZ } = b8;
          if (!i4(k, oZ)) {
            var C1 = {
              eventTime: sZ,
              lane: oZ,
              tag: b8.tag,
              payload: b8.payload,
              callback: b8.callback,
              next: null
            };
            if (J6 === null)
              Q8 = J6 = C1, r1 = x1;
            else
              J6 = J6.next = C1;
            y1 = BZ(y1, oZ);
          } else {
            if (J6 !== null) {
              var Y2 = {
                eventTime: sZ,
                lane: eX,
                tag: b8.tag,
                payload: b8.payload,
                callback: b8.callback,
                next: null
              };
              J6 = J6.next = Y2;
            }
            x1 = gp0(L, y, b8, x1, O, _);
            var k1 = b8.callback;
            if (k1 !== null && b8.lane !== eX) {
              L.flags |= em;
              var k2 = y.effects;
              if (k2 === null)
                y.effects = [b8];
              else
                k2.push(b8);
            }
          }
          if (b8 = b8.next, b8 === null)
            if (H0 = y.shared.pending, H0 === null)
              break;
            else {
              var z8 = H0, q8 = z8.next;
              z8.next = null, b8 = q8, y.lastBaseUpdate = z8, y.shared.pending = null;
            }
        } while (!0);
        if (J6 === null)
          r1 = x1;
        y.baseState = r1, y.firstBaseUpdate = Q8, y.lastBaseUpdate = J6;
        var I6 = y.shared.interleaved;
        if (I6 !== null) {
          var e6 = I6;
          do
            y1 = BZ(y1, e6.lane), e6 = e6.next;
          while (e6 !== I6);
        } else if (d === null)
          y.shared.lanes = T2;
        KT(y1), L.lanes = y1, L.memoizedState = x1;
      }
      oC = null;
    }
    function mp0(L, O) {
      if (typeof L !== "function")
        throw new Error("Invalid argument passed as callback. Expected a function. Instead " + ("received: " + L));
      L.call(O);
    }
    function BJ0() {
      iC = !1;
    }
    function rC() {
      return iC;
    }
    function wJ0(L, O, _) {
      var k = O.effects;
      if (O.effects = null, k !== null)
        for (var y = 0;y < k.length; y++) {
          var d = k[y], o = d.callback;
          if (o !== null)
            d.callback = null, mp0(o, _);
        }
    }
    var hj = {}, eU = oU(hj), bj = oU(hj), tC = oU(hj);
    function eC(L) {
      if (L === hj)
        throw new Error("Expected host context to exist. This error is likely caused by a bug in React. Please file an issue.");
      return L;
    }
    function jJ0() {
      var L = eC(tC.current);
      return L;
    }
    function pp(L, O) {
      BQ(tC, O, L), BQ(bj, L, L), BQ(eU, hj, L);
      var _ = Xd0(O);
      AQ(eU, L), BQ(eU, _, L);
    }
    function qD(L) {
      AQ(eU, L), AQ(bj, L), AQ(tC, L);
    }
    function up() {
      var L = eC(eU.current);
      return L;
    }
    function TJ0(L) {
      var O = eC(tC.current), _ = eC(eU.current), k = Yd0(_, L.type);
      if (_ === k)
        return;
      BQ(bj, L, L), BQ(eU, k, L);
    }
    function cp(L) {
      if (bj.current !== L)
        return;
      AQ(eU, L), AQ(bj, L);
    }
    var dp0 = 0, _J0 = 1, VJ0 = 1, xj = 2, vG = oU(dp0);
    function lp(L, O) {
      return (L & O) !== 0;
    }
    function FD(L) {
      return L & _J0;
    }
    function np(L, O) {
      return L & _J0 | O;
    }
    function pp0(L, O) {
      return L | O;
    }
    function ZL(L, O) {
      BQ(vG, O, L);
    }
    function UD(L) {
      AQ(vG, L);
    }
    function up0(L, O) {
      var _ = L.memoizedState;
      if (_ !== null) {
        if (_.dehydrated !== null)
          return !0;
        return !1;
      }
      var k = L.memoizedProps;
      return !0;
    }
    function Zk(L) {
      var O = L;
      while (O !== null) {
        if (O.tag === B) {
          var _ = O.memoizedState;
          if (_ !== null) {
            var k = _.dehydrated;
            if (k === null || u70(k) || qp(k))
              return O;
          }
        } else if (O.tag === S && O.memoizedProps.revealOrder !== void 0) {
          var y = (O.flags & x9) !== M6;
          if (y)
            return O;
        } else if (O.child !== null) {
          O.child.return = O, O = O.child;
          continue;
        }
        if (O === L)
          return null;
        while (O.sibling === null) {
          if (O.return === null || O.return === L)
            return null;
          O = O.return;
        }
        O.sibling.return = O.return, O = O.sibling;
      }
      return null;
    }
    var Y5 = 0, TX = 1, eH = 2, _X = 4, iY = 8, ip = [];
    function op() {
      for (var L = 0;L < ip.length; L++) {
        var O = ip[L];
        O._workInProgressVersionPrimary = null;
      }
      ip.length = 0;
    }
    function cp0(L, O) {
      var _ = O._getVersion, k = _(O._source);
      if (L.mutableSourceEagerHydrationData == null)
        L.mutableSourceEagerHydrationData = [O, k];
      else
        L.mutableSourceEagerHydrationData.push(O, k);
    }
    var { ReactCurrentDispatcher: E8, ReactCurrentBatchConfig: yj } = Z, sp, LD;
    sp = /* @__PURE__ */ new Set;
    var LO = T2, L7 = null, VX = null, IX = null, Jk = !1, gj = !1, mj = 0, lp0 = 0, np0 = 25, H2 = null, nK = null, JL = -1, ap = !1;
    function c9() {
      {
        var L = H2;
        if (nK === null)
          nK = [L];
        else
          nK.push(L);
      }
    }
    function J8() {
      {
        var L = H2;
        if (nK !== null) {
          if (JL++, nK[JL] !== L)
            ip0(L);
        }
      }
    }
    function RD(L) {
      if (L !== void 0 && L !== null && !b9(L))
        Y("%s received a final argument that is not an array (instead, received `%s`). When specified, the final argument must be an array.", H2, typeof L);
    }
    function ip0(L) {
      {
        var O = D6(L7);
        if (!sp.has(O)) {
          if (sp.add(O), nK !== null) {
            var _ = "", k = 30;
            for (var y = 0;y <= JL; y++) {
              var d = nK[y], o = y === JL ? L : d, H0 = y + 1 + ". " + d;
              while (H0.length < k)
                H0 += " ";
              H0 += o + `
`, _ += H0;
            }
            Y(`React has detected a change in the order of Hooks called by %s. This will lead to bugs and errors if not fixed. For more information, read the Rules of Hooks: https://reactjs.org/link/rules-of-hooks

   Previous render            Next render
   ------------------------------------------------------
%s   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
`, O, _);
          }
        }
      }
    }
    function wQ() {
      throw new Error(`Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:
1. You might have mismatching versions of React and the renderer (such as React DOM)
2. You might be breaking the Rules of Hooks
3. You might have more than one copy of React in the same app
See https://reactjs.org/link/invalid-hook-call for tips about how to debug and fix this problem.`);
    }
    function rp(L, O) {
      if (ap)
        return !1;
      if (O === null)
        return Y("%s received a final argument during this render, but not during the previous render. Even though the final argument is optional, its type cannot change between renders.", H2), !1;
      if (L.length !== O.length)
        Y(`The final argument passed to %s changed size between renders. The order and size of this array must remain constant.

Previous: %s
Incoming: %s`, H2, "[" + O.join(", ") + "]", "[" + L.join(", ") + "]");
      for (var _ = 0;_ < O.length && _ < L.length; _++) {
        if (r5(L[_], O[_]))
          continue;
        return !1;
      }
      return !0;
    }
    function ED(L, O, _, k, y, d) {
      if (LO = d, L7 = O, nK = L !== null ? L._debugHookTypes : null, JL = -1, ap = L !== null && L.type !== O.type, O.memoizedState = null, O.updateQueue = null, O.lanes = T2, L !== null && L.memoizedState !== null)
        E8.current = sJ0;
      else if (nK !== null)
        E8.current = oJ0;
      else
        E8.current = iJ0;
      var o = _(k, y);
      if (gj) {
        var H0 = 0;
        do {
          if (gj = !1, mj = 0, H0 >= np0)
            throw new Error("Too many re-renders. React limits the number of renders to prevent an infinite loop.");
          H0 += 1, ap = !1, VX = null, IX = null, O.updateQueue = null, JL = -1, E8.current = aJ0, o = _(k, y);
        } while (gj);
      }
      E8.current = Ek, O._debugHookTypes = nK;
      var O0 = VX !== null && VX.next !== null;
      if (LO = T2, L7 = null, VX = null, IX = null, H2 = null, nK = null, JL = -1, L !== null && (L.flags & JF) !== (O.flags & JF) && (L.mode & W9) !== N6)
        Y("Internal React error: Expected static flag was missing. Please notify the React team.");
      if (Jk = !1, O0)
        throw new Error("Rendered fewer hooks than expected. This may be caused by an accidental early return statement.");
      return o;
    }
    function OD() {
      var L = mj !== 0;
      return mj = 0, L;
    }
    function IJ0(L, O, _) {
      if (O.updateQueue = L.updateQueue, (O.mode & sH) !== N6)
        O.flags &= ~(oP | ZF | _G | F9);
      else
        O.flags &= ~(_G | F9);
      L.lanes = JC(L.lanes, _);
    }
    function PJ0() {
      if (E8.current = Ek, Jk) {
        var L = L7.memoizedState;
        while (L !== null) {
          var O = L.queue;
          if (O !== null)
            O.pending = null;
          L = L.next;
        }
        Jk = !1;
      }
      LO = T2, L7 = null, VX = null, IX = null, nK = null, JL = -1, H2 = null, pJ0 = !1, gj = !1, mj = 0;
    }
    function ZN() {
      var L = {
        memoizedState: null,
        baseState: null,
        baseQueue: null,
        queue: null,
        next: null
      };
      if (IX === null)
        L7.memoizedState = IX = L;
      else
        IX = IX.next = L;
      return IX;
    }
    function iK() {
      var L;
      if (VX === null) {
        var O = L7.alternate;
        if (O !== null)
          L = O.memoizedState;
        else
          L = null;
      } else
        L = VX.next;
      var _;
      if (IX === null)
        _ = L7.memoizedState;
      else
        _ = IX.next;
      if (_ !== null)
        IX = _, _ = IX.next, VX = L;
      else {
        if (L === null)
          throw new Error("Rendered more hooks than during the previous render.");
        VX = L;
        var k = {
          memoizedState: VX.memoizedState,
          baseState: VX.baseState,
          baseQueue: VX.baseQueue,
          queue: VX.queue,
          next: null
        };
        if (IX === null)
          L7.memoizedState = IX = k;
        else
          IX = IX.next = k;
      }
      return IX;
    }
    function CJ0() {
      return {
        lastEffect: null,
        stores: null
      };
    }
    function tp(L, O) {
      return typeof O === "function" ? O(L) : O;
    }
    function ep(L, O, _) {
      var k = ZN(), y;
      if (_ !== void 0)
        y = _(O);
      else
        y = O;
      k.memoizedState = k.baseState = y;
      var d = {
        pending: null,
        interleaved: null,
        lanes: T2,
        dispatch: null,
        lastRenderedReducer: L,
        lastRenderedState: y
      };
      k.queue = d;
      var o = d.dispatch = ap0.bind(null, L7, d);
      return [k.memoizedState, o];
    }
    function Zu(L, O, _) {
      var k = iK(), y = k.queue;
      if (y === null)
        throw new Error("Should have a queue. This is likely a bug in React. Please file an issue.");
      y.lastRenderedReducer = L;
      var d = VX, o = d.baseQueue, H0 = y.pending;
      if (H0 !== null) {
        if (o !== null) {
          var O0 = o.next, I0 = H0.next;
          o.next = I0, H0.next = O0;
        }
        if (d.baseQueue !== o)
          Y("Internal error: Expected work-in-progress queue to be a clone. This is a bug in React.");
        d.baseQueue = o = H0, y.pending = null;
      }
      if (o !== null) {
        var g0 = o.next, R1 = d.baseState, U1 = null, x1 = null, y1 = null, r1 = g0;
        do {
          var Q8 = r1.lane;
          if (!i4(LO, Q8)) {
            var J6 = {
              lane: Q8,
              action: r1.action,
              hasEagerState: r1.hasEagerState,
              eagerState: r1.eagerState,
              next: null
            };
            if (y1 === null)
              x1 = y1 = J6, U1 = R1;
            else
              y1 = y1.next = J6;
            L7.lanes = BZ(L7.lanes, Q8), KT(Q8);
          } else {
            if (y1 !== null) {
              var b8 = {
                lane: eX,
                action: r1.action,
                hasEagerState: r1.hasEagerState,
                eagerState: r1.eagerState,
                next: null
              };
              y1 = y1.next = b8;
            }
            if (r1.hasEagerState)
              R1 = r1.eagerState;
            else {
              var oZ = r1.action;
              R1 = L(R1, oZ);
            }
          }
          r1 = r1.next;
        } while (r1 !== null && r1 !== g0);
        if (y1 === null)
          U1 = R1;
        else
          y1.next = x1;
        if (!r5(R1, k.memoizedState))
          sj();
        k.memoizedState = R1, k.baseState = U1, k.baseQueue = y1, y.lastRenderedState = R1;
      }
      var sZ = y.interleaved;
      if (sZ !== null) {
        var C1 = sZ;
        do {
          var Y2 = C1.lane;
          L7.lanes = BZ(L7.lanes, Y2), KT(Y2), C1 = C1.next;
        } while (C1 !== sZ);
      } else if (o === null)
        y.lanes = T2;
      var k1 = y.dispatch;
      return [k.memoizedState, k1];
    }
    function Ju(L, O, _) {
      var k = iK(), y = k.queue;
      if (y === null)
        throw new Error("Should have a queue. This is likely a bug in React. Please file an issue.");
      y.lastRenderedReducer = L;
      var { dispatch: d, pending: o } = y, H0 = k.memoizedState;
      if (o !== null) {
        y.pending = null;
        var O0 = o.next, I0 = O0;
        do {
          var g0 = I0.action;
          H0 = L(H0, g0), I0 = I0.next;
        } while (I0 !== O0);
        if (!r5(H0, k.memoizedState))
          sj();
        if (k.memoizedState = H0, k.baseQueue === null)
          k.baseState = H0;
        y.lastRenderedState = H0;
      }
      return [H0, d];
    }
    function $u(L, O, _) {
      return;
    }
    function $k(L, O, _) {
      return;
    }
    function Xu(L, O, _) {
      var k = L7, y = ZN(), d, o = nY();
      if (o) {
        if (_ === void 0)
          throw new Error("Missing getServerSnapshot, which is required for server-rendered content. Will revert to client rendering.");
        if (d = _(), !LD) {
          if (d !== _())
            Y("The result of getServerSnapshot should be cached to avoid an infinite loop"), LD = !0;
        }
      } else {
        if (d = O(), !LD) {
          var H0 = O();
          if (!r5(d, H0))
            Y("The result of getSnapshot should be cached to avoid an infinite loop"), LD = !0;
        }
        var O0 = hk();
        if (O0 === null)
          throw new Error("Expected a work-in-progress root. This is a bug in React. Please file an issue.");
        if (!ZC(O0, LO))
          kJ0(k, O, d);
      }
      y.memoizedState = d;
      var I0 = {
        value: d,
        getSnapshot: O
      };
      return y.queue = I0, Kk(SJ0.bind(null, k, I0, L), [L]), k.flags |= _G, dj(TX | iY, vJ0.bind(null, k, I0, d, O), void 0, null), d;
    }
    function Xk(L, O, _) {
      var k = L7, y = iK(), d = O();
      if (!LD) {
        var o = O();
        if (!r5(d, o))
          Y("The result of getSnapshot should be cached to avoid an infinite loop"), LD = !0;
      }
      var H0 = y.memoizedState, O0 = !r5(H0, d);
      if (O0)
        y.memoizedState = d, sj();
      var I0 = y.queue;
      if (uj(SJ0.bind(null, k, I0, L), [L]), I0.getSnapshot !== O || O0 || IX !== null && IX.memoizedState.tag & TX) {
        k.flags |= _G, dj(TX | iY, vJ0.bind(null, k, I0, d, O), void 0, null);
        var g0 = hk();
        if (g0 === null)
          throw new Error("Expected a work-in-progress root. This is a bug in React. Please file an issue.");
        if (!ZC(g0, LO))
          kJ0(k, O, d);
      }
      return d;
    }
    function kJ0(L, O, _) {
      L.flags |= iP;
      var k = {
        getSnapshot: O,
        value: _
      }, y = L7.updateQueue;
      if (y === null)
        y = CJ0(), L7.updateQueue = y, y.stores = [k];
      else {
        var d = y.stores;
        if (d === null)
          y.stores = [k];
        else
          d.push(k);
      }
    }
    function vJ0(L, O, _, k) {
      if (O.value = _, O.getSnapshot = k, fJ0(O))
        hJ0(L);
    }
    function SJ0(L, O, _) {
      var k = function() {
        if (fJ0(O))
          hJ0(L);
      };
      return _(k);
    }
    function fJ0(L) {
      var { getSnapshot: O, value: _ } = L;
      try {
        var k = O();
        return !r5(_, k);
      } catch (y) {
        return !0;
      }
    }
    function hJ0(L) {
      var O = X5(L, n6);
      if (O !== null)
        vX(O, L, n6, s7);
    }
    function Yk(L) {
      var O = ZN();
      if (typeof L === "function")
        L = L();
      O.memoizedState = O.baseState = L;
      var _ = {
        pending: null,
        interleaved: null,
        lanes: T2,
        dispatch: null,
        lastRenderedReducer: tp,
        lastRenderedState: L
      };
      O.queue = _;
      var k = _.dispatch = rp0.bind(null, L7, _);
      return [O.memoizedState, k];
    }
    function Yu(L) {
      return Zu(tp);
    }
    function Qu(L) {
      return Ju(tp);
    }
    function dj(L, O, _, k) {
      var y = {
        tag: L,
        create: O,
        destroy: _,
        deps: k,
        next: null
      }, d = L7.updateQueue;
      if (d === null)
        d = CJ0(), L7.updateQueue = d, d.lastEffect = y.next = y;
      else {
        var o = d.lastEffect;
        if (o === null)
          d.lastEffect = y.next = y;
        else {
          var H0 = o.next;
          o.next = y, y.next = H0, d.lastEffect = y;
        }
      }
      return y;
    }
    function Wu(L) {
      var O = ZN();
      {
        var _ = {
          current: L
        };
        return O.memoizedState = _, _;
      }
    }
    function Qk(L) {
      var O = iK();
      return O.memoizedState;
    }
    function pj(L, O, _, k) {
      var y = ZN(), d = k === void 0 ? null : k;
      L7.flags |= L, y.memoizedState = dj(TX | O, _, void 0, d);
    }
    function Wk(L, O, _, k) {
      var y = iK(), d = k === void 0 ? null : k, o = void 0;
      if (VX !== null) {
        var H0 = VX.memoizedState;
        if (o = H0.destroy, d !== null) {
          var O0 = H0.deps;
          if (rp(d, O0)) {
            y.memoizedState = dj(O, _, o, d);
            return;
          }
        }
      }
      L7.flags |= L, y.memoizedState = dj(TX | O, _, o, d);
    }
    function Kk(L, O) {
      if ((L7.mode & sH) !== N6)
        return pj(oP | _G | $d, iY, L, O);
      else
        return pj(_G | $d, iY, L, O);
    }
    function uj(L, O) {
      return Wk(_G, iY, L, O);
    }
    function Ku(L, O) {
      return pj(F9, eH, L, O);
    }
    function Gk(L, O) {
      return Wk(F9, eH, L, O);
    }
    function Gu(L, O) {
      var _ = F9;
      if (_ |= aE, (L7.mode & sH) !== N6)
        _ |= ZF;
      return pj(_, _X, L, O);
    }
    function Hk(L, O) {
      return Wk(F9, _X, L, O);
    }
    function bJ0(L, O) {
      if (typeof O === "function") {
        var _ = O, k = L();
        return _(k), function() {
          _(null);
        };
      } else if (O !== null && O !== void 0) {
        var y = O;
        if (!y.hasOwnProperty("current"))
          Y("Expected useImperativeHandle() first argument to either be a ref callback or React.createRef() object. Instead received: %s.", "an object with keys {" + Object.keys(y).join(", ") + "}");
        var d = L();
        return y.current = d, function() {
          y.current = null;
        };
      }
    }
    function Hu(L, O, _) {
      if (typeof O !== "function")
        Y("Expected useImperativeHandle() second argument to be a function that creates a handle. Instead received: %s.", O !== null ? typeof O : "null");
      var k = _ !== null && _ !== void 0 ? _.concat([L]) : null, y = F9;
      if (y |= aE, (L7.mode & sH) !== N6)
        y |= ZF;
      return pj(y, _X, bJ0.bind(null, O, L), k);
    }
    function Nk(L, O, _) {
      if (typeof O !== "function")
        Y("Expected useImperativeHandle() second argument to be a function that creates a handle. Instead received: %s.", O !== null ? typeof O : "null");
      var k = _ !== null && _ !== void 0 ? _.concat([L]) : null;
      return Wk(F9, _X, bJ0.bind(null, O, L), k);
    }
    function qk(L, O) {}
    var Fk = qk;
    function Nu(L, O) {
      var _ = ZN(), k = O === void 0 ? null : O;
      return _.memoizedState = [L, k], L;
    }
    function Uk(L, O) {
      var _ = iK(), k = O === void 0 ? null : O, y = _.memoizedState;
      if (y !== null) {
        if (k !== null) {
          var d = y[1];
          if (rp(k, d))
            return y[0];
        }
      }
      return _.memoizedState = [L, k], L;
    }
    function qu(L, O) {
      var _ = ZN(), k = O === void 0 ? null : O, y = L();
      return _.memoizedState = [y, k], y;
    }
    function Lk(L, O) {
      var _ = iK(), k = O === void 0 ? null : O, y = _.memoizedState;
      if (y !== null) {
        if (k !== null) {
          var d = y[1];
          if (rp(k, d))
            return y[0];
        }
      }
      var o = L();
      return _.memoizedState = [o, k], o;
    }
    function Fu(L) {
      var O = ZN();
      return O.memoizedState = L, L;
    }
    function xJ0(L) {
      var O = iK(), _ = VX, k = _.memoizedState;
      return gJ0(O, k, L);
    }
    function yJ0(L) {
      var O = iK();
      if (VX === null)
        return O.memoizedState = L, L;
      else {
        var _ = VX.memoizedState;
        return gJ0(O, _, L);
      }
    }
    function gJ0(L, O, _) {
      var k = !Sy0(LO);
      if (k) {
        if (!r5(_, O)) {
          var y = f90();
          L7.lanes = BZ(L7.lanes, y), KT(y), L.baseState = !0;
        }
        return O;
      } else {
        if (L.baseState)
          L.baseState = !1, sj();
        return L.memoizedState = _, _;
      }
    }
    function op0(L, O, _) {
      var k = IG();
      ZY(py0(k, XF)), L(!0);
      var y = yj.transition;
      yj.transition = {};
      var d = yj.transition;
      yj.transition._updatedFibers = /* @__PURE__ */ new Set;
      try {
        L(!1), O();
      } finally {
        if (ZY(k), yj.transition = y, y === null && d._updatedFibers) {
          var o = d._updatedFibers.size;
          if (o > 10)
            X("Detected a large number of updates inside startTransition. If this is due to a subscription please re-write it to use React provided hooks. Otherwise concurrent mode guarantees are off the table.");
          d._updatedFibers.clear();
        }
      }
    }
    function Uu() {
      var L = Yk(!1), O = L[0], _ = L[1], k = op0.bind(null, _), y = ZN();
      return y.memoizedState = k, [O, k];
    }
    function mJ0() {
      var L = Yu(), O = L[0], _ = iK(), k = _.memoizedState;
      return [O, k];
    }
    function dJ0() {
      var L = Qu(), O = L[0], _ = iK(), k = _.memoizedState;
      return [O, k];
    }
    var pJ0 = !1;
    function sp0() {
      return pJ0;
    }
    function Lu() {
      var L = ZN(), O = hk(), _ = O.identifierPrefix, k;
      if (nY()) {
        var y = Up0();
        k = ":" + _ + "R" + y;
        var d = mj++;
        if (d > 0)
          k += "H" + d.toString(32);
        k += ":";
      } else {
        var o = lp0++;
        k = ":" + _ + "r" + o.toString(32) + ":";
      }
      return L.memoizedState = k, k;
    }
    function Rk() {
      var L = iK(), O = L.memoizedState;
      return O;
    }
    function ap0(L, O, _) {
      if (typeof arguments[3] === "function")
        Y("State updates from the useState() and useReducer() Hooks don't support the second callback argument. To execute a side effect after rendering, declare it in the component body with useEffect().");
      var k = WL(L), y = {
        lane: k,
        action: _,
        hasEagerState: !1,
        eagerState: null,
        next: null
      };
      if (uJ0(L))
        cJ0(O, y);
      else {
        var d = zJ0(L, O, y, k);
        if (d !== null) {
          var o = LW();
          vX(d, L, k, o), lJ0(d, O, k);
        }
      }
      nJ0(L, k);
    }
    function rp0(L, O, _) {
      if (typeof arguments[3] === "function")
        Y("State updates from the useState() and useReducer() Hooks don't support the second callback argument. To execute a side effect after rendering, declare it in the component body with useEffect().");
      var k = WL(L), y = {
        lane: k,
        action: _,
        hasEagerState: !1,
        eagerState: null,
        next: null
      };
      if (uJ0(L))
        cJ0(O, y);
      else {
        var d = L.alternate;
        if (L.lanes === T2 && (d === null || d.lanes === T2)) {
          var o = O.lastRenderedReducer;
          if (o !== null) {
            var H0;
            H0 = E8.current, E8.current = SG;
            try {
              var O0 = O.lastRenderedState, I0 = o(O0, _);
              if (y.hasEagerState = !0, y.eagerState = I0, r5(I0, O0)) {
                bp0(L, O, y, k);
                return;
              }
            } catch (U1) {} finally {
              E8.current = H0;
            }
          }
        }
        var g0 = zJ0(L, O, y, k);
        if (g0 !== null) {
          var R1 = LW();
          vX(g0, L, k, R1), lJ0(g0, O, k);
        }
      }
      nJ0(L, k);
    }
    function uJ0(L) {
      var O = L.alternate;
      return L === L7 || O !== null && O === L7;
    }
    function cJ0(L, O) {
      gj = Jk = !0;
      var _ = L.pending;
      if (_ === null)
        O.next = O;
      else
        O.next = _.next, _.next = O;
      L.pending = O;
    }
    function lJ0(L, O, _) {
      if (S90(_)) {
        var k = O.lanes;
        k = h90(k, L.pendingLanes);
        var y = BZ(k, _);
        O.lanes = y, vd(L, y);
      }
    }
    function nJ0(L, O, _) {
      Kd(L, O);
    }
    var Ek = {
      readContext: c$,
      useCallback: wQ,
      useContext: wQ,
      useEffect: wQ,
      useImperativeHandle: wQ,
      useInsertionEffect: wQ,
      useLayoutEffect: wQ,
      useMemo: wQ,
      useReducer: wQ,
      useRef: wQ,
      useState: wQ,
      useDebugValue: wQ,
      useDeferredValue: wQ,
      useTransition: wQ,
      useMutableSource: wQ,
      useSyncExternalStore: wQ,
      useId: wQ,
      unstable_isNewReconciler: m
    }, iJ0 = null, oJ0 = null, sJ0 = null, aJ0 = null, JN = null, SG = null, Ok = null;
    {
      var Ru = function() {
        Y("Context can only be read while React is rendering. In classes, you can read it in the render method or getDerivedStateFromProps. In function components, you can read it directly in the function body, but not inside Hooks like useReducer() or useMemo().");
      }, i6 = function() {
        Y("Do not call Hooks inside useEffect(...), useMemo(...), or other built-in Hooks. You can only call Hooks at the top level of your React function. For more information, see https://reactjs.org/link/rules-of-hooks");
      };
      iJ0 = {
        readContext: function(L) {
          return c$(L);
        },
        useCallback: function(L, O) {
          return H2 = "useCallback", c9(), RD(O), Nu(L, O);
        },
        useContext: function(L) {
          return H2 = "useContext", c9(), c$(L);
        },
        useEffect: function(L, O) {
          return H2 = "useEffect", c9(), RD(O), Kk(L, O);
        },
        useImperativeHandle: function(L, O, _) {
          return H2 = "useImperativeHandle", c9(), RD(_), Hu(L, O, _);
        },
        useInsertionEffect: function(L, O) {
          return H2 = "useInsertionEffect", c9(), RD(O), Ku(L, O);
        },
        useLayoutEffect: function(L, O) {
          return H2 = "useLayoutEffect", c9(), RD(O), Gu(L, O);
        },
        useMemo: function(L, O) {
          H2 = "useMemo", c9(), RD(O);
          var _ = E8.current;
          E8.current = JN;
          try {
            return qu(L, O);
          } finally {
            E8.current = _;
          }
        },
        useReducer: function(L, O, _) {
          H2 = "useReducer", c9();
          var k = E8.current;
          E8.current = JN;
          try {
            return ep(L, O, _);
          } finally {
            E8.current = k;
          }
        },
        useRef: function(L) {
          return H2 = "useRef", c9(), Wu(L);
        },
        useState: function(L) {
          H2 = "useState", c9();
          var O = E8.current;
          E8.current = JN;
          try {
            return Yk(L);
          } finally {
            E8.current = O;
          }
        },
        useDebugValue: function(L, O) {
          return H2 = "useDebugValue", c9(), qk();
        },
        useDeferredValue: function(L) {
          return H2 = "useDeferredValue", c9(), Fu(L);
        },
        useTransition: function() {
          return H2 = "useTransition", c9(), Uu();
        },
        useMutableSource: function(L, O, _) {
          return H2 = "useMutableSource", c9(), $u();
        },
        useSyncExternalStore: function(L, O, _) {
          return H2 = "useSyncExternalStore", c9(), Xu(L, O, _);
        },
        useId: function() {
          return H2 = "useId", c9(), Lu();
        },
        unstable_isNewReconciler: m
      }, oJ0 = {
        readContext: function(L) {
          return c$(L);
        },
        useCallback: function(L, O) {
          return H2 = "useCallback", J8(), Nu(L, O);
        },
        useContext: function(L) {
          return H2 = "useContext", J8(), c$(L);
        },
        useEffect: function(L, O) {
          return H2 = "useEffect", J8(), Kk(L, O);
        },
        useImperativeHandle: function(L, O, _) {
          return H2 = "useImperativeHandle", J8(), Hu(L, O, _);
        },
        useInsertionEffect: function(L, O) {
          return H2 = "useInsertionEffect", J8(), Ku(L, O);
        },
        useLayoutEffect: function(L, O) {
          return H2 = "useLayoutEffect", J8(), Gu(L, O);
        },
        useMemo: function(L, O) {
          H2 = "useMemo", J8();
          var _ = E8.current;
          E8.current = JN;
          try {
            return qu(L, O);
          } finally {
            E8.current = _;
          }
        },
        useReducer: function(L, O, _) {
          H2 = "useReducer", J8();
          var k = E8.current;
          E8.current = JN;
          try {
            return ep(L, O, _);
          } finally {
            E8.current = k;
          }
        },
        useRef: function(L) {
          return H2 = "useRef", J8(), Wu(L);
        },
        useState: function(L) {
          H2 = "useState", J8();
          var O = E8.current;
          E8.current = JN;
          try {
            return Yk(L);
          } finally {
            E8.current = O;
          }
        },
        useDebugValue: function(L, O) {
          return H2 = "useDebugValue", J8(), qk();
        },
        useDeferredValue: function(L) {
          return H2 = "useDeferredValue", J8(), Fu(L);
        },
        useTransition: function() {
          return H2 = "useTransition", J8(), Uu();
        },
        useMutableSource: function(L, O, _) {
          return H2 = "useMutableSource", J8(), $u();
        },
        useSyncExternalStore: function(L, O, _) {
          return H2 = "useSyncExternalStore", J8(), Xu(L, O, _);
        },
        useId: function() {
          return H2 = "useId", J8(), Lu();
        },
        unstable_isNewReconciler: m
      }, sJ0 = {
        readContext: function(L) {
          return c$(L);
        },
        useCallback: function(L, O) {
          return H2 = "useCallback", J8(), Uk(L, O);
        },
        useContext: function(L) {
          return H2 = "useContext", J8(), c$(L);
        },
        useEffect: function(L, O) {
          return H2 = "useEffect", J8(), uj(L, O);
        },
        useImperativeHandle: function(L, O, _) {
          return H2 = "useImperativeHandle", J8(), Nk(L, O, _);
        },
        useInsertionEffect: function(L, O) {
          return H2 = "useInsertionEffect", J8(), Gk(L, O);
        },
        useLayoutEffect: function(L, O) {
          return H2 = "useLayoutEffect", J8(), Hk(L, O);
        },
        useMemo: function(L, O) {
          H2 = "useMemo", J8();
          var _ = E8.current;
          E8.current = SG;
          try {
            return Lk(L, O);
          } finally {
            E8.current = _;
          }
        },
        useReducer: function(L, O, _) {
          H2 = "useReducer", J8();
          var k = E8.current;
          E8.current = SG;
          try {
            return Zu(L, O, _);
          } finally {
            E8.current = k;
          }
        },
        useRef: function(L) {
          return H2 = "useRef", J8(), Qk();
        },
        useState: function(L) {
          H2 = "useState", J8();
          var O = E8.current;
          E8.current = SG;
          try {
            return Yu(L);
          } finally {
            E8.current = O;
          }
        },
        useDebugValue: function(L, O) {
          return H2 = "useDebugValue", J8(), Fk();
        },
        useDeferredValue: function(L) {
          return H2 = "useDeferredValue", J8(), xJ0(L);
        },
        useTransition: function() {
          return H2 = "useTransition", J8(), mJ0();
        },
        useMutableSource: function(L, O, _) {
          return H2 = "useMutableSource", J8(), $k();
        },
        useSyncExternalStore: function(L, O, _) {
          return H2 = "useSyncExternalStore", J8(), Xk(L, O);
        },
        useId: function() {
          return H2 = "useId", J8(), Rk();
        },
        unstable_isNewReconciler: m
      }, aJ0 = {
        readContext: function(L) {
          return c$(L);
        },
        useCallback: function(L, O) {
          return H2 = "useCallback", J8(), Uk(L, O);
        },
        useContext: function(L) {
          return H2 = "useContext", J8(), c$(L);
        },
        useEffect: function(L, O) {
          return H2 = "useEffect", J8(), uj(L, O);
        },
        useImperativeHandle: function(L, O, _) {
          return H2 = "useImperativeHandle", J8(), Nk(L, O, _);
        },
        useInsertionEffect: function(L, O) {
          return H2 = "useInsertionEffect", J8(), Gk(L, O);
        },
        useLayoutEffect: function(L, O) {
          return H2 = "useLayoutEffect", J8(), Hk(L, O);
        },
        useMemo: function(L, O) {
          H2 = "useMemo", J8();
          var _ = E8.current;
          E8.current = Ok;
          try {
            return Lk(L, O);
          } finally {
            E8.current = _;
          }
        },
        useReducer: function(L, O, _) {
          H2 = "useReducer", J8();
          var k = E8.current;
          E8.current = Ok;
          try {
            return Ju(L, O, _);
          } finally {
            E8.current = k;
          }
        },
        useRef: function(L) {
          return H2 = "useRef", J8(), Qk();
        },
        useState: function(L) {
          H2 = "useState", J8();
          var O = E8.current;
          E8.current = Ok;
          try {
            return Qu(L);
          } finally {
            E8.current = O;
          }
        },
        useDebugValue: function(L, O) {
          return H2 = "useDebugValue", J8(), Fk();
        },
        useDeferredValue: function(L) {
          return H2 = "useDeferredValue", J8(), yJ0(L);
        },
        useTransition: function() {
          return H2 = "useTransition", J8(), dJ0();
        },
        useMutableSource: function(L, O, _) {
          return H2 = "useMutableSource", J8(), $k();
        },
        useSyncExternalStore: function(L, O, _) {
          return H2 = "useSyncExternalStore", J8(), Xk(L, O);
        },
        useId: function() {
          return H2 = "useId", J8(), Rk();
        },
        unstable_isNewReconciler: m
      }, JN = {
        readContext: function(L) {
          return Ru(), c$(L);
        },
        useCallback: function(L, O) {
          return H2 = "useCallback", i6(), c9(), Nu(L, O);
        },
        useContext: function(L) {
          return H2 = "useContext", i6(), c9(), c$(L);
        },
        useEffect: function(L, O) {
          return H2 = "useEffect", i6(), c9(), Kk(L, O);
        },
        useImperativeHandle: function(L, O, _) {
          return H2 = "useImperativeHandle", i6(), c9(), Hu(L, O, _);
        },
        useInsertionEffect: function(L, O) {
          return H2 = "useInsertionEffect", i6(), c9(), Ku(L, O);
        },
        useLayoutEffect: function(L, O) {
          return H2 = "useLayoutEffect", i6(), c9(), Gu(L, O);
        },
        useMemo: function(L, O) {
          H2 = "useMemo", i6(), c9();
          var _ = E8.current;
          E8.current = JN;
          try {
            return qu(L, O);
          } finally {
            E8.current = _;
          }
        },
        useReducer: function(L, O, _) {
          H2 = "useReducer", i6(), c9();
          var k = E8.current;
          E8.current = JN;
          try {
            return ep(L, O, _);
          } finally {
            E8.current = k;
          }
        },
        useRef: function(L) {
          return H2 = "useRef", i6(), c9(), Wu(L);
        },
        useState: function(L) {
          H2 = "useState", i6(), c9();
          var O = E8.current;
          E8.current = JN;
          try {
            return Yk(L);
          } finally {
            E8.current = O;
          }
        },
        useDebugValue: function(L, O) {
          return H2 = "useDebugValue", i6(), c9(), qk();
        },
        useDeferredValue: function(L) {
          return H2 = "useDeferredValue", i6(), c9(), Fu(L);
        },
        useTransition: function() {
          return H2 = "useTransition", i6(), c9(), Uu();
        },
        useMutableSource: function(L, O, _) {
          return H2 = "useMutableSource", i6(), c9(), $u();
        },
        useSyncExternalStore: function(L, O, _) {
          return H2 = "useSyncExternalStore", i6(), c9(), Xu(L, O, _);
        },
        useId: function() {
          return H2 = "useId", i6(), c9(), Lu();
        },
        unstable_isNewReconciler: m
      }, SG = {
        readContext: function(L) {
          return Ru(), c$(L);
        },
        useCallback: function(L, O) {
          return H2 = "useCallback", i6(), J8(), Uk(L, O);
        },
        useContext: function(L) {
          return H2 = "useContext", i6(), J8(), c$(L);
        },
        useEffect: function(L, O) {
          return H2 = "useEffect", i6(), J8(), uj(L, O);
        },
        useImperativeHandle: function(L, O, _) {
          return H2 = "useImperativeHandle", i6(), J8(), Nk(L, O, _);
        },
        useInsertionEffect: function(L, O) {
          return H2 = "useInsertionEffect", i6(), J8(), Gk(L, O);
        },
        useLayoutEffect: function(L, O) {
          return H2 = "useLayoutEffect", i6(), J8(), Hk(L, O);
        },
        useMemo: function(L, O) {
          H2 = "useMemo", i6(), J8();
          var _ = E8.current;
          E8.current = SG;
          try {
            return Lk(L, O);
          } finally {
            E8.current = _;
          }
        },
        useReducer: function(L, O, _) {
          H2 = "useReducer", i6(), J8();
          var k = E8.current;
          E8.current = SG;
          try {
            return Zu(L, O, _);
          } finally {
            E8.current = k;
          }
        },
        useRef: function(L) {
          return H2 = "useRef", i6(), J8(), Qk();
        },
        useState: function(L) {
          H2 = "useState", i6(), J8();
          var O = E8.current;
          E8.current = SG;
          try {
            return Yu(L);
          } finally {
            E8.current = O;
          }
        },
        useDebugValue: function(L, O) {
          return H2 = "useDebugValue", i6(), J8(), Fk();
        },
        useDeferredValue: function(L) {
          return H2 = "useDeferredValue", i6(), J8(), xJ0(L);
        },
        useTransition: function() {
          return H2 = "useTransition", i6(), J8(), mJ0();
        },
        useMutableSource: function(L, O, _) {
          return H2 = "useMutableSource", i6(), J8(), $k();
        },
        useSyncExternalStore: function(L, O, _) {
          return H2 = "useSyncExternalStore", i6(), J8(), Xk(L, O);
        },
        useId: function() {
          return H2 = "useId", i6(), J8(), Rk();
        },
        unstable_isNewReconciler: m
      }, Ok = {
        readContext: function(L) {
          return Ru(), c$(L);
        },
        useCallback: function(L, O) {
          return H2 = "useCallback", i6(), J8(), Uk(L, O);
        },
        useContext: function(L) {
          return H2 = "useContext", i6(), J8(), c$(L);
        },
        useEffect: function(L, O) {
          return H2 = "useEffect", i6(), J8(), uj(L, O);
        },
        useImperativeHandle: function(L, O, _) {
          return H2 = "useImperativeHandle", i6(), J8(), Nk(L, O, _);
        },
        useInsertionEffect: function(L, O) {
          return H2 = "useInsertionEffect", i6(), J8(), Gk(L, O);
        },
        useLayoutEffect: function(L, O) {
          return H2 = "useLayoutEffect", i6(), J8(), Hk(L, O);
        },
        useMemo: function(L, O) {
          H2 = "useMemo", i6(), J8();
          var _ = E8.current;
          E8.current = SG;
          try {
            return Lk(L, O);
          } finally {
            E8.current = _;
          }
        },
        useReducer: function(L, O, _) {
          H2 = "useReducer", i6(), J8();
          var k = E8.current;
          E8.current = SG;
          try {
            return Ju(L, O, _);
          } finally {
            E8.current = k;
          }
        },
        useRef: function(L) {
          return H2 = "useRef", i6(), J8(), Qk();
        },
        useState: function(L) {
          H2 = "useState", i6(), J8();
          var O = E8.current;
          E8.current = SG;
          try {
            return Qu(L);
          } finally {
            E8.current = O;
          }
        },
        useDebugValue: function(L, O) {
          return H2 = "useDebugValue", i6(), J8(), Fk();
        },
        useDeferredValue: function(L) {
          return H2 = "useDeferredValue", i6(), J8(), yJ0(L);
        },
        useTransition: function() {
          return H2 = "useTransition", i6(), J8(), dJ0();
        },
        useMutableSource: function(L, O, _) {
          return H2 = "useMutableSource", i6(), J8(), $k();
        },
        useSyncExternalStore: function(L, O, _) {
          return H2 = "useSyncExternalStore", i6(), J8(), Xk(L, O);
        },
        useId: function() {
          return H2 = "useId", i6(), J8(), Rk();
        },
        unstable_isNewReconciler: m
      };
    }
    var $L = E7.unstable_now, rJ0 = 0, zk = -1, cj = -1, Dk = -1, Eu = !1, Mk = !1;
    function tJ0() {
      return Eu;
    }
    function tp0() {
      Mk = !0;
    }
    function ep0() {
      Eu = !1, Mk = !1;
    }
    function Zu0() {
      Eu = Mk, Mk = !1;
    }
    function eJ0() {
      return rJ0;
    }
    function Z$0() {
      rJ0 = $L();
    }
    function Ou(L) {
      if (cj = $L(), L.actualStartTime < 0)
        L.actualStartTime = $L();
    }
    function J$0(L) {
      cj = -1;
    }
    function Ak(L, O) {
      if (cj >= 0) {
        var _ = $L() - cj;
        if (L.actualDuration += _, O)
          L.selfBaseDuration = _;
        cj = -1;
      }
    }
    function $N(L) {
      if (zk >= 0) {
        var O = $L() - zk;
        zk = -1;
        var _ = L.return;
        while (_ !== null) {
          switch (_.tag) {
            case H:
              var k = _.stateNode;
              k.effectDuration += O;
              return;
            case A:
              var y = _.stateNode;
              y.effectDuration += O;
              return;
          }
          _ = _.return;
        }
      }
    }
    function zu(L) {
      if (Dk >= 0) {
        var O = $L() - Dk;
        Dk = -1;
        var _ = L.return;
        while (_ !== null) {
          switch (_.tag) {
            case H:
              var k = _.stateNode;
              if (k !== null)
                k.passiveEffectDuration += O;
              return;
            case A:
              var y = _.stateNode;
              if (y !== null)
                y.passiveEffectDuration += O;
              return;
          }
          _ = _.return;
        }
      }
    }
    function XN() {
      zk = $L();
    }
    function Du() {
      Dk = $L();
    }
    function Mu(L) {
      var O = L.child;
      while (O)
        L.actualDuration += O.actualDuration, O = O.sibling;
    }
    function fG(L, O) {
      if (L && L.defaultProps) {
        var _ = d0({}, O), k = L.defaultProps;
        for (var y in k)
          if (_[y] === void 0)
            _[y] = k[y];
        return _;
      }
      return O;
    }
    var Au = {}, Bu, wu, ju, Tu, _u, $$0, Bk, Vu, Iu, Pu, lj;
    {
      Bu = /* @__PURE__ */ new Set, wu = /* @__PURE__ */ new Set, ju = /* @__PURE__ */ new Set, Tu = /* @__PURE__ */ new Set, Vu = /* @__PURE__ */ new Set, _u = /* @__PURE__ */ new Set, Iu = /* @__PURE__ */ new Set, Pu = /* @__PURE__ */ new Set, lj = /* @__PURE__ */ new Set;
      var X$0 = /* @__PURE__ */ new Set;
      Bk = function(L, O) {
        if (L === null || typeof L === "function")
          return;
        var _ = O + "_" + L;
        if (!X$0.has(_))
          X$0.add(_), Y("%s(...): Expected the last optional `callback` argument to be a function. Instead received: %s.", O, L);
      }, $$0 = function(L, O) {
        if (O === void 0) {
          var _ = y6(L) || "Component";
          if (!_u.has(_))
            _u.add(_), Y("%s.getDerivedStateFromProps(): A valid state object (or null) must be returned. You have returned undefined.", _);
        }
      }, Object.defineProperty(Au, "_processChildContext", {
        enumerable: !1,
        value: function() {
          throw new Error("_processChildContext is not available in React 16+. This likely means you have multiple copies of React and are attempting to nest a React 15 tree inside a React 16 tree using unstable_renderSubtreeIntoContainer, which isn't supported. Try to make sure you have only one copy of React (and ideally, switch to ReactDOM.createPortal).");
        }
      }), Object.freeze(Au);
    }
    function Cu(L, O, _, k) {
      var y = L.memoizedState, d = _(k, y);
      {
        if (L.mode & Y$) {
          tX(!0);
          try {
            d = _(k, y);
          } finally {
            tX(!1);
          }
        }
        $$0(O, d);
      }
      var o = d === null || d === void 0 ? y : d0({}, y, d);
      if (L.memoizedState = o, L.lanes === T2) {
        var H0 = L.updateQueue;
        H0.baseState = o;
      }
    }
    var ku = {
      isMounted: nx0,
      enqueueSetState: function(L, O, _) {
        var k = m4(L), y = LW(), d = WL(k), o = NF(y, d);
        if (o.payload = O, _ !== void 0 && _ !== null)
          Bk(_, "setState"), o.callback = _;
        var H0 = tU(k, o, d);
        if (H0 !== null)
          vX(H0, k, d, y), sC(H0, k, d);
        Kd(k, d);
      },
      enqueueReplaceState: function(L, O, _) {
        var k = m4(L), y = LW(), d = WL(k), o = NF(y, d);
        if (o.tag = MJ0, o.payload = O, _ !== void 0 && _ !== null)
          Bk(_, "replaceState"), o.callback = _;
        var H0 = tU(k, o, d);
        if (H0 !== null)
          vX(H0, k, d, y), sC(H0, k, d);
        Kd(k, d);
      },
      enqueueForceUpdate: function(L, O) {
        var _ = m4(L), k = LW(), y = WL(_), d = NF(k, y);
        if (d.tag = nC, O !== void 0 && O !== null)
          Bk(O, "forceUpdate"), d.callback = O;
        var o = tU(_, d, y);
        if (o !== null)
          vX(o, _, y, k), sC(o, _, y);
        wy0(_, y);
      }
    };
    function Y$0(L, O, _, k, y, d, o) {
      var H0 = L.stateNode;
      if (typeof H0.shouldComponentUpdate === "function") {
        var O0 = H0.shouldComponentUpdate(k, d, o);
        {
          if (L.mode & Y$) {
            tX(!0);
            try {
              O0 = H0.shouldComponentUpdate(k, d, o);
            } finally {
              tX(!1);
            }
          }
          if (O0 === void 0)
            Y("%s.shouldComponentUpdate(): Returned undefined instead of a boolean value. Make sure to return true or false.", y6(O) || "Component");
        }
        return O0;
      }
      if (O.prototype && O.prototype.isPureReactComponent)
        return !Uj(_, k) || !Uj(y, d);
      return !0;
    }
    function Ju0(L, O, _) {
      var k = L.stateNode;
      {
        var y = y6(O) || "Component", d = k.render;
        if (!d)
          if (O.prototype && typeof O.prototype.render === "function")
            Y("%s(...): No `render` method found on the returned component instance: did you accidentally return an object from the constructor?", y);
          else
            Y("%s(...): No `render` method found on the returned component instance: you may have forgotten to define `render`.", y);
        if (k.getInitialState && !k.getInitialState.isReactClassApproved && !k.state)
          Y("getInitialState was defined on %s, a plain JavaScript class. This is only supported for classes created using React.createClass. Did you mean to define a state property instead?", y);
        if (k.getDefaultProps && !k.getDefaultProps.isReactClassApproved)
          Y("getDefaultProps was defined on %s, a plain JavaScript class. This is only supported for classes created using React.createClass. Use a static property to define defaultProps instead.", y);
        if (k.propTypes)
          Y("propTypes was defined as an instance property on %s. Use a static property to define propTypes instead.", y);
        if (k.contextType)
          Y("contextType was defined as an instance property on %s. Use a static property to define contextType instead.", y);
        {
          if (O.childContextTypes && !lj.has(O) && (L.mode & Y$) === N6)
            lj.add(O), Y(`%s uses the legacy childContextTypes API which is no longer supported and will be removed in the next major release. Use React.createContext() instead

.Learn more about this warning here: https://reactjs.org/link/legacy-context`, y);
          if (O.contextTypes && !lj.has(O) && (L.mode & Y$) === N6)
            lj.add(O), Y(`%s uses the legacy contextTypes API which is no longer supported and will be removed in the next major release. Use React.createContext() with static contextType instead.

Learn more about this warning here: https://reactjs.org/link/legacy-context`, y);
          if (k.contextTypes)
            Y("contextTypes was defined as an instance property on %s. Use a static property to define contextTypes instead.", y);
          if (O.contextType && O.contextTypes && !Iu.has(O))
            Iu.add(O), Y("%s declares both contextTypes and contextType static properties. The legacy contextTypes property will be ignored.", y);
        }
        if (typeof k.componentShouldUpdate === "function")
          Y("%s has a method called componentShouldUpdate(). Did you mean shouldComponentUpdate()? The name is phrased as a question because the function is expected to return a value.", y);
        if (O.prototype && O.prototype.isPureReactComponent && typeof k.shouldComponentUpdate !== "undefined")
          Y("%s has a method called shouldComponentUpdate(). shouldComponentUpdate should not be used when extending React.PureComponent. Please extend React.Component if shouldComponentUpdate is used.", y6(O) || "A pure component");
        if (typeof k.componentDidUnmount === "function")
          Y("%s has a method called componentDidUnmount(). But there is no such lifecycle method. Did you mean componentWillUnmount()?", y);
        if (typeof k.componentDidReceiveProps === "function")
          Y("%s has a method called componentDidReceiveProps(). But there is no such lifecycle method. If you meant to update the state in response to changing props, use componentWillReceiveProps(). If you meant to fetch data or run side-effects or mutations after React has updated the UI, use componentDidUpdate().", y);
        if (typeof k.componentWillRecieveProps === "function")
          Y("%s has a method called componentWillRecieveProps(). Did you mean componentWillReceiveProps()?", y);
        if (typeof k.UNSAFE_componentWillRecieveProps === "function")
          Y("%s has a method called UNSAFE_componentWillRecieveProps(). Did you mean UNSAFE_componentWillReceiveProps()?", y);
        var o = k.props !== _;
        if (k.props !== void 0 && o)
          Y("%s(...): When calling super() in `%s`, make sure to pass up the same props that your component's constructor was passed.", y, y);
        if (k.defaultProps)
          Y("Setting defaultProps as an instance property on %s is not supported and will be ignored. Instead, define defaultProps as a static property on %s.", y, y);
        if (typeof k.getSnapshotBeforeUpdate === "function" && typeof k.componentDidUpdate !== "function" && !ju.has(O))
          ju.add(O), Y("%s: getSnapshotBeforeUpdate() should be used with componentDidUpdate(). This component defines getSnapshotBeforeUpdate() only.", y6(O));
        if (typeof k.getDerivedStateFromProps === "function")
          Y("%s: getDerivedStateFromProps() is defined as an instance method and will be ignored. Instead, declare it as a static method.", y);
        if (typeof k.getDerivedStateFromError === "function")
          Y("%s: getDerivedStateFromError() is defined as an instance method and will be ignored. Instead, declare it as a static method.", y);
        if (typeof O.getSnapshotBeforeUpdate === "function")
          Y("%s: getSnapshotBeforeUpdate() is defined as a static method and will be ignored. Instead, declare it as an instance method.", y);
        var H0 = k.state;
        if (H0 && (typeof H0 !== "object" || b9(H0)))
          Y("%s.state: must be set to an object or null", y);
        if (typeof k.getChildContext === "function" && typeof O.childContextTypes !== "object")
          Y("%s.getChildContext(): childContextTypes must be defined in order to use getChildContext().", y);
      }
    }
    function Q$0(L, O) {
      O.updater = ku, L.stateNode = O, dx0(O, L), O._reactInternalInstance = Au;
    }
    function W$0(L, O, _) {
      var k = !1, y = t5, d = t5, o = O.contextType;
      if ("contextType" in O) {
        var H0 = o === null || o !== void 0 && o.$$typeof === c0 && o._context === void 0;
        if (!H0 && !Pu.has(O)) {
          Pu.add(O);
          var O0 = "";
          if (o === void 0)
            O0 = " However, it is set to undefined. This can be caused by a typo or by mixing up named and default imports. This can also happen due to a circular dependency, so try moving the createContext() call to a separate file.";
          else if (typeof o !== "object")
            O0 = " However, it is set to a " + typeof o + ".";
          else if (o.$$typeof === X8)
            O0 = " Did you accidentally pass the Context.Provider instead?";
          else if (o._context !== void 0)
            O0 = " Did you accidentally pass the Context.Consumer instead?";
          else
            O0 = " However, it is set to an object with keys {" + Object.keys(o).join(", ") + "}.";
          Y("%s defines an invalid contextType. contextType should point to the Context object returned by React.createContext().%s", y6(O) || "Component", O0);
        }
      }
      if (typeof o === "object" && o !== null)
        d = c$(o);
      else {
        y = XD(L, O, !0);
        var I0 = O.contextTypes;
        k = I0 !== null && I0 !== void 0, d = k ? YD(L, y) : t5;
      }
      var g0 = new O(_, d);
      if (L.mode & Y$) {
        tX(!0);
        try {
          g0 = new O(_, d);
        } finally {
          tX(!1);
        }
      }
      var R1 = L.memoizedState = g0.state !== null && g0.state !== void 0 ? g0.state : null;
      Q$0(L, g0);
      {
        if (typeof O.getDerivedStateFromProps === "function" && R1 === null) {
          var U1 = y6(O) || "Component";
          if (!wu.has(U1))
            wu.add(U1), Y("`%s` uses `getDerivedStateFromProps` but its initial state is %s. This is not recommended. Instead, define the initial state by assigning an object to `this.state` in the constructor of `%s`. This ensures that `getDerivedStateFromProps` arguments have a consistent shape.", U1, g0.state === null ? "null" : "undefined", U1);
        }
        if (typeof O.getDerivedStateFromProps === "function" || typeof g0.getSnapshotBeforeUpdate === "function") {
          var x1 = null, y1 = null, r1 = null;
          if (typeof g0.componentWillMount === "function" && g0.componentWillMount.__suppressDeprecationWarning !== !0)
            x1 = "componentWillMount";
          else if (typeof g0.UNSAFE_componentWillMount === "function")
            x1 = "UNSAFE_componentWillMount";
          if (typeof g0.componentWillReceiveProps === "function" && g0.componentWillReceiveProps.__suppressDeprecationWarning !== !0)
            y1 = "componentWillReceiveProps";
          else if (typeof g0.UNSAFE_componentWillReceiveProps === "function")
            y1 = "UNSAFE_componentWillReceiveProps";
          if (typeof g0.componentWillUpdate === "function" && g0.componentWillUpdate.__suppressDeprecationWarning !== !0)
            r1 = "componentWillUpdate";
          else if (typeof g0.UNSAFE_componentWillUpdate === "function")
            r1 = "UNSAFE_componentWillUpdate";
          if (x1 !== null || y1 !== null || r1 !== null) {
            var Q8 = y6(O) || "Component", J6 = typeof O.getDerivedStateFromProps === "function" ? "getDerivedStateFromProps()" : "getSnapshotBeforeUpdate()";
            if (!Tu.has(Q8))
              Tu.add(Q8), Y(`Unsafe legacy lifecycles will not be called for components using new component APIs.

%s uses %s but also contains the following legacy lifecycles:%s%s%s

The above lifecycles should be removed. Learn more about this warning here:
https://reactjs.org/link/unsafe-component-lifecycles`, Q8, J6, x1 !== null ? `
  ` + x1 : "", y1 !== null ? `
  ` + y1 : "", r1 !== null ? `
  ` + r1 : "");
          }
        }
      }
      if (k)
        s70(L, y, d);
      return g0;
    }
    function $u0(L, O) {
      var _ = O.state;
      if (typeof O.componentWillMount === "function")
        O.componentWillMount();
      if (typeof O.UNSAFE_componentWillMount === "function")
        O.UNSAFE_componentWillMount();
      if (_ !== O.state)
        Y("%s.componentWillMount(): Assigning directly to this.state is deprecated (except inside a component's constructor). Use setState instead.", D6(L) || "Component"), ku.enqueueReplaceState(O, O.state, null);
    }
    function K$0(L, O, _, k) {
      var y = O.state;
      if (typeof O.componentWillReceiveProps === "function")
        O.componentWillReceiveProps(_, k);
      if (typeof O.UNSAFE_componentWillReceiveProps === "function")
        O.UNSAFE_componentWillReceiveProps(_, k);
      if (O.state !== y) {
        {
          var d = D6(L) || "Component";
          if (!Bu.has(d))
            Bu.add(d), Y("%s.componentWillReceiveProps(): Assigning directly to this.state is deprecated (except inside a component's constructor). Use setState instead.", d);
        }
        ku.enqueueReplaceState(O, O.state, null);
      }
    }
    function vu(L, O, _, k) {
      Ju0(L, O, _);
      var y = L.stateNode;
      y.props = _, y.state = L.memoizedState, y.refs = {}, mp(L);
      var d = O.contextType;
      if (typeof d === "object" && d !== null)
        y.context = c$(d);
      else {
        var o = XD(L, O, !0);
        y.context = YD(L, o);
      }
      {
        if (y.state === _) {
          var H0 = y6(O) || "Component";
          if (!Vu.has(H0))
            Vu.add(H0), Y("%s: It is not recommended to assign props directly to state because updates to props won't be reflected in state. In most cases, it is better to use props directly.", H0);
        }
        if (L.mode & Y$)
          kG.recordLegacyContextWarning(L, y);
        kG.recordUnsafeLifecycleWarnings(L, y);
      }
      y.state = L.memoizedState;
      var O0 = O.getDerivedStateFromProps;
      if (typeof O0 === "function")
        Cu(L, O, O0, _), y.state = L.memoizedState;
      if (typeof O.getDerivedStateFromProps !== "function" && typeof y.getSnapshotBeforeUpdate !== "function" && (typeof y.UNSAFE_componentWillMount === "function" || typeof y.componentWillMount === "function"))
        $u0(L, y), aC(L, _, y, k), y.state = L.memoizedState;
      if (typeof y.componentDidMount === "function") {
        var I0 = F9;
        if (I0 |= aE, (L.mode & sH) !== N6)
          I0 |= ZF;
        L.flags |= I0;
      }
    }
    function Xu0(L, O, _, k) {
      var { stateNode: y, memoizedProps: d } = L;
      y.props = d;
      var o = y.context, H0 = O.contextType, O0 = t5;
      if (typeof H0 === "object" && H0 !== null)
        O0 = c$(H0);
      else {
        var I0 = XD(L, O, !0);
        O0 = YD(L, I0);
      }
      var g0 = O.getDerivedStateFromProps, R1 = typeof g0 === "function" || typeof y.getSnapshotBeforeUpdate === "function";
      if (!R1 && (typeof y.UNSAFE_componentWillReceiveProps === "function" || typeof y.componentWillReceiveProps === "function")) {
        if (d !== _ || o !== O0)
          K$0(L, y, _, O0);
      }
      BJ0();
      var U1 = L.memoizedState, x1 = y.state = U1;
      if (aC(L, _, y, k), x1 = L.memoizedState, d === _ && U1 === x1 && !kC() && !rC()) {
        if (typeof y.componentDidMount === "function") {
          var y1 = F9;
          if (y1 |= aE, (L.mode & sH) !== N6)
            y1 |= ZF;
          L.flags |= y1;
        }
        return !1;
      }
      if (typeof g0 === "function")
        Cu(L, O, g0, _), x1 = L.memoizedState;
      var r1 = rC() || Y$0(L, O, d, _, U1, x1, O0);
      if (r1) {
        if (!R1 && (typeof y.UNSAFE_componentWillMount === "function" || typeof y.componentWillMount === "function")) {
          if (typeof y.componentWillMount === "function")
            y.componentWillMount();
          if (typeof y.UNSAFE_componentWillMount === "function")
            y.UNSAFE_componentWillMount();
        }
        if (typeof y.componentDidMount === "function") {
          var Q8 = F9;
          if (Q8 |= aE, (L.mode & sH) !== N6)
            Q8 |= ZF;
          L.flags |= Q8;
        }
      } else {
        if (typeof y.componentDidMount === "function") {
          var J6 = F9;
          if (J6 |= aE, (L.mode & sH) !== N6)
            J6 |= ZF;
          L.flags |= J6;
        }
        L.memoizedProps = _, L.memoizedState = x1;
      }
      return y.props = _, y.state = x1, y.context = O0, r1;
    }
    function Yu0(L, O, _, k, y) {
      var d = O.stateNode;
      AJ0(L, O);
      var o = O.memoizedProps, H0 = O.type === O.elementType ? o : fG(O.type, o);
      d.props = H0;
      var O0 = O.pendingProps, I0 = d.context, g0 = _.contextType, R1 = t5;
      if (typeof g0 === "object" && g0 !== null)
        R1 = c$(g0);
      else {
        var U1 = XD(O, _, !0);
        R1 = YD(O, U1);
      }
      var x1 = _.getDerivedStateFromProps, y1 = typeof x1 === "function" || typeof d.getSnapshotBeforeUpdate === "function";
      if (!y1 && (typeof d.UNSAFE_componentWillReceiveProps === "function" || typeof d.componentWillReceiveProps === "function")) {
        if (o !== O0 || I0 !== R1)
          K$0(O, d, k, R1);
      }
      BJ0();
      var r1 = O.memoizedState, Q8 = d.state = r1;
      if (aC(O, k, d, y), Q8 = O.memoizedState, o === O0 && r1 === Q8 && !kC() && !rC() && !i) {
        if (typeof d.componentDidUpdate === "function") {
          if (o !== L.memoizedProps || r1 !== L.memoizedState)
            O.flags |= F9;
        }
        if (typeof d.getSnapshotBeforeUpdate === "function") {
          if (o !== L.memoizedProps || r1 !== L.memoizedState)
            O.flags |= oE;
        }
        return !1;
      }
      if (typeof x1 === "function")
        Cu(O, _, x1, k), Q8 = O.memoizedState;
      var J6 = rC() || Y$0(O, _, H0, k, r1, Q8, R1) || i;
      if (J6) {
        if (!y1 && (typeof d.UNSAFE_componentWillUpdate === "function" || typeof d.componentWillUpdate === "function")) {
          if (typeof d.componentWillUpdate === "function")
            d.componentWillUpdate(k, Q8, R1);
          if (typeof d.UNSAFE_componentWillUpdate === "function")
            d.UNSAFE_componentWillUpdate(k, Q8, R1);
        }
        if (typeof d.componentDidUpdate === "function")
          O.flags |= F9;
        if (typeof d.getSnapshotBeforeUpdate === "function")
          O.flags |= oE;
      } else {
        if (typeof d.componentDidUpdate === "function") {
          if (o !== L.memoizedProps || r1 !== L.memoizedState)
            O.flags |= F9;
        }
        if (typeof d.getSnapshotBeforeUpdate === "function") {
          if (o !== L.memoizedProps || r1 !== L.memoizedState)
            O.flags |= oE;
        }
        O.memoizedProps = k, O.memoizedState = Q8;
      }
      return d.props = k, d.state = Q8, d.context = R1, J6;
    }
    function RO(L, O) {
      return {
        value: L,
        source: O,
        stack: _6(O),
        digest: null
      };
    }
    function Su(L, O, _) {
      return {
        value: L,
        source: null,
        stack: _ != null ? _ : null,
        digest: O != null ? O : null
      };
    }
    function Qu0(L, O) {
      return !0;
    }
    function fu(L, O) {
      try {
        var _ = Qu0(L, O);
        if (_ === !1)
          return;
        var { value: k, source: y, stack: d } = O, o = d !== null ? d : "";
        if (k != null && k._suppressLogging) {
          if (L.tag === K)
            return;
          console.error(k);
        }
        var H0 = y ? D6(y) : null, O0 = H0 ? "The above error occurred in the <" + H0 + "> component:" : "The above error occurred in one of your React components:", I0;
        if (L.tag === H)
          I0 = `Consider adding an error boundary to your tree to customize error handling behavior.
Visit https://reactjs.org/link/error-boundaries to learn more about error boundaries.`;
        else {
          var g0 = D6(L) || "Anonymous";
          I0 = "React will try to recreate this component tree from scratch " + ("using the error boundary you provided, " + g0 + ".");
        }
        var R1 = O0 + `
` + o + `

` + ("" + I0);
        console.error(R1);
      } catch (U1) {
        setTimeout(function() {
          throw U1;
        });
      }
    }
    var Wu0 = typeof WeakMap === "function" ? WeakMap : Map;
    function G$0(L, O, _) {
      var k = NF(s7, _);
      k.tag = yp, k.payload = {
        element: null
      };
      var y = O.value;
      return k.callback = function() {
        Xl0(y), fu(L, O);
      }, k;
    }
    function hu(L, O, _) {
      var k = NF(s7, _);
      k.tag = yp;
      var y = L.type.getDerivedStateFromError;
      if (typeof y === "function") {
        var d = O.value;
        k.payload = function() {
          return y(d);
        }, k.callback = function() {
          MX0(L), fu(L, O);
        };
      }
      var o = L.stateNode;
      if (o !== null && typeof o.componentDidCatch === "function")
        k.callback = function H0() {
          if (MX0(L), fu(L, O), typeof y !== "function")
            Jl0(this);
          var { value: O0, stack: I0 } = O;
          if (this.componentDidCatch(O0, {
            componentStack: I0 !== null ? I0 : ""
          }), typeof y !== "function") {
            if (!o5(L.lanes, n6))
              Y("%s: Error boundaries should implement getDerivedStateFromError(). In that method, return a state update to display an error message or fallback UI.", D6(L) || "Unknown");
          }
        };
      return k;
    }
    function H$0(L, O, _) {
      var k = L.pingCache, y;
      if (k === null)
        k = L.pingCache = new Wu0, y = /* @__PURE__ */ new Set, k.set(O, y);
      else if (y = k.get(O), y === void 0)
        y = /* @__PURE__ */ new Set, k.set(O, y);
      if (!y.has(_)) {
        y.add(_);
        var d = Yl0.bind(null, L, O, _);
        if (VG)
          GT(L, _);
        O.then(d, d);
      }
    }
    function Ku0(L, O, _, k) {
      var y = L.updateQueue;
      if (y === null) {
        var d = /* @__PURE__ */ new Set;
        d.add(_), L.updateQueue = d;
      } else
        y.add(_);
    }
    function Gu0(L, O) {
      var _ = L.tag;
      if ((L.mode & W9) === N6 && (_ === W || _ === D || _ === w)) {
        var k = L.alternate;
        if (k)
          L.updateQueue = k.updateQueue, L.memoizedState = k.memoizedState, L.lanes = k.lanes;
        else
          L.updateQueue = null, L.memoizedState = null;
      }
    }
    function N$0(L) {
      var O = L;
      do {
        if (O.tag === B && up0(O))
          return O;
        O = O.return;
      } while (O !== null);
      return null;
    }
    function q$0(L, O, _, k, y) {
      if ((L.mode & W9) === N6) {
        if (L === O)
          L.flags |= qW;
        else {
          if (L.flags |= x9, _.flags |= Zd, _.flags &= ~(px0 | cw), _.tag === K) {
            var d = _.alternate;
            if (d === null)
              _.tag = P;
            else {
              var o = NF(s7, n6);
              o.tag = nC, tU(_, o, n6);
            }
          }
          _.lanes = BZ(_.lanes, n6);
        }
        return L;
      }
      return L.flags |= qW, L.lanes = y, L;
    }
    function Hu0(L, O, _, k, y) {
      if (_.flags |= cw, VG)
        GT(L, y);
      if (k !== null && typeof k === "object" && typeof k.then === "function") {
        var d = k;
        if (Gu0(_), nY() && _.mode & W9)
          $J0();
        var o = N$0(O);
        if (o !== null) {
          if (o.flags &= ~tq, q$0(o, O, _, L, y), o.mode & W9)
            H$0(L, d, y);
          Ku0(o, L, d);
          return;
        } else {
          if (!vy0(y)) {
            H$0(L, d, y), Rc();
            return;
          }
          var H0 = new Error("A component suspended while responding to synchronous input. This will cause the UI to be replaced with a loading indicator. To fix, updates that suspend should be wrapped with startTransition.");
          k = H0;
        }
      } else if (nY() && _.mode & W9) {
        $J0();
        var O0 = N$0(O);
        if (O0 !== null) {
          if ((O0.flags & qW) === M6)
            O0.flags |= tq;
          q$0(O0, O, _, L, y), _p(RO(k, _));
          return;
        }
      }
      k = RO(k, _), ic0(k);
      var I0 = O;
      do {
        switch (I0.tag) {
          case H: {
            var g0 = k;
            I0.flags |= qW;
            var R1 = tw(y);
            I0.lanes = BZ(I0.lanes, R1);
            var U1 = G$0(I0, g0, R1);
            dp(I0, U1);
            return;
          }
          case K:
            var x1 = k, y1 = I0.type, r1 = I0.stateNode;
            if ((I0.flags & x9) === M6 && (typeof y1.getDerivedStateFromError === "function" || r1 !== null && typeof r1.componentDidCatch === "function" && !qX0(r1))) {
              I0.flags |= qW;
              var Q8 = tw(y);
              I0.lanes = BZ(I0.lanes, Q8);
              var J6 = hu(I0, x1, Q8);
              dp(I0, J6);
              return;
            }
            break;
        }
        I0 = I0.return;
      } while (I0 !== null);
    }
    function Nu0() {
      return null;
    }
    var nj = Z.ReactCurrentOwner, hG = !1, bu, ij, xu, yu, gu, EO, mu, wk, oj;
    bu = {}, ij = {}, xu = {}, yu = {}, gu = {}, EO = !1, mu = {}, wk = {}, oj = {};
    function FW(L, O, _, k) {
      if (L === null)
        O.child = LJ0(O, null, _, k);
      else
        O.child = GD(O, L.child, _, k);
    }
    function qu0(L, O, _, k) {
      O.child = GD(O, L.child, null, k), O.child = GD(O, null, _, k);
    }
    function F$0(L, O, _, k, y) {
      if (O.type !== O.elementType) {
        var d = _.propTypes;
        if (d)
          PG(d, k, "prop", y6(_));
      }
      var o = _.render, H0 = O.ref, O0, I0;
      ND(O, y), nw(O);
      {
        if (nj.current = O, n5(!0), O0 = ED(L, O, o, k, H0, y), I0 = OD(), O.mode & Y$) {
          tX(!0);
          try {
            O0 = ED(L, O, o, k, H0, y), I0 = OD();
          } finally {
            tX(!1);
          }
        }
        n5(!1);
      }
      if (u4(), L !== null && !hG)
        return IJ0(L, O, y), qF(L, O, y);
      if (nY() && I0)
        Mp(O);
      return O.flags |= d4, FW(L, O, O0, y), O.child;
    }
    function U$0(L, O, _, k, y) {
      if (L === null) {
        var d = _.type;
        if (Al0(d) && _.compare === null && _.defaultProps === void 0) {
          var o = d;
          return o = TD(d), O.tag = w, O.type = o, uu(O, d), L$0(L, O, o, k, y);
        }
        {
          var H0 = d.propTypes;
          if (H0)
            PG(H0, k, "prop", y6(d));
          if (_.defaultProps !== void 0) {
            var O0 = y6(d) || "Unknown";
            if (!oj[O0])
              Y("%s: Support for defaultProps will be removed from memo components in a future major release. Use JavaScript default parameters instead.", O0), oj[O0] = !0;
          }
        }
        var I0 = _c(_.type, null, k, O, O.mode, y);
        return I0.ref = O.ref, I0.return = O, O.child = I0, I0;
      }
      {
        var g0 = _.type, R1 = g0.propTypes;
        if (R1)
          PG(R1, k, "prop", y6(g0));
      }
      var U1 = L.child, x1 = su(L, y);
      if (!x1) {
        var y1 = U1.memoizedProps, r1 = _.compare;
        if (r1 = r1 !== null ? r1 : Uj, r1(y1, k) && L.ref === O.ref)
          return qF(L, O, y);
      }
      O.flags |= d4;
      var Q8 = AO(U1, k);
      return Q8.ref = O.ref, Q8.return = O, O.child = Q8, Q8;
    }
    function L$0(L, O, _, k, y) {
      if (O.type !== O.elementType) {
        var d = O.elementType;
        if (d.$$typeof === I1) {
          var o = d, H0 = o._payload, O0 = o._init;
          try {
            d = O0(H0);
          } catch (R1) {
            d = null;
          }
          var I0 = d && d.propTypes;
          if (I0)
            PG(I0, k, "prop", y6(d));
        }
      }
      if (L !== null) {
        var g0 = L.memoizedProps;
        if (Uj(g0, k) && L.ref === O.ref && O.type === L.type) {
          if (hG = !1, O.pendingProps = k = g0, !su(L, y))
            return O.lanes = L.lanes, qF(L, O, y);
          else if ((L.flags & Zd) !== M6)
            hG = !0;
        }
      }
      return du(L, O, _, k, y);
    }
    function R$0(L, O, _) {
      var k = O.pendingProps, y = k.children, d = L !== null ? L.memoizedState : null;
      if (k.mode === "hidden" || r)
        if ((O.mode & W9) === N6) {
          var o = {
            baseLanes: T2,
            cachePool: null,
            transitions: null
          };
          O.memoizedState = o, bk(O, _);
        } else if (!o5(_, i5)) {
          var H0 = null, O0;
          if (d !== null) {
            var I0 = d.baseLanes;
            O0 = BZ(I0, _);
          } else
            O0 = _;
          O.lanes = O.childLanes = $C(i5);
          var g0 = {
            baseLanes: O0,
            cachePool: H0,
            transitions: null
          };
          return O.memoizedState = g0, O.updateQueue = null, bk(O, O0), null;
        } else {
          var R1 = {
            baseLanes: T2,
            cachePool: null,
            transitions: null
          };
          O.memoizedState = R1;
          var U1 = d !== null ? d.baseLanes : _;
          bk(O, U1);
        }
      else {
        var x1;
        if (d !== null)
          x1 = BZ(d.baseLanes, _), O.memoizedState = null;
        else
          x1 = _;
        bk(O, x1);
      }
      return FW(L, O, y, _), O.child;
    }
    function Fu0(L, O, _) {
      var k = O.pendingProps;
      return FW(L, O, k, _), O.child;
    }
    function Uu0(L, O, _) {
      var k = O.pendingProps.children;
      return FW(L, O, k, _), O.child;
    }
    function Lu0(L, O, _) {
      {
        O.flags |= F9;
        {
          var k = O.stateNode;
          k.effectDuration = 0, k.passiveEffectDuration = 0;
        }
      }
      var y = O.pendingProps, d = y.children;
      return FW(L, O, d, _), O.child;
    }
    function E$0(L, O) {
      var _ = O.ref;
      if (L === null && _ !== null || L !== null && L.ref !== _)
        O.flags |= mU, O.flags |= Jd;
    }
    function du(L, O, _, k, y) {
      if (O.type !== O.elementType) {
        var d = _.propTypes;
        if (d)
          PG(d, k, "prop", y6(_));
      }
      var o;
      {
        var H0 = XD(O, _, !0);
        o = YD(O, H0);
      }
      var O0, I0;
      ND(O, y), nw(O);
      {
        if (nj.current = O, n5(!0), O0 = ED(L, O, _, k, o, y), I0 = OD(), O.mode & Y$) {
          tX(!0);
          try {
            O0 = ED(L, O, _, k, o, y), I0 = OD();
          } finally {
            tX(!1);
          }
        }
        n5(!1);
      }
      if (u4(), L !== null && !hG)
        return IJ0(L, O, y), qF(L, O, y);
      if (nY() && I0)
        Mp(O);
      return O.flags |= d4, FW(L, O, O0, y), O.child;
    }
    function O$0(L, O, _, k, y) {
      {
        switch (bl0(O)) {
          case !1: {
            var { stateNode: d, type: o } = O, H0 = new o(O.memoizedProps, d.context), O0 = H0.state;
            d.updater.enqueueSetState(d, O0, null);
            break;
          }
          case !0: {
            O.flags |= x9, O.flags |= qW;
            var I0 = new Error("Simulated error coming from DevTools"), g0 = tw(y);
            O.lanes = BZ(O.lanes, g0);
            var R1 = hu(O, RO(I0, O), g0);
            dp(O, R1);
            break;
          }
        }
        if (O.type !== O.elementType) {
          var U1 = _.propTypes;
          if (U1)
            PG(U1, k, "prop", y6(_));
        }
      }
      var x1;
      if (tH(_))
        x1 = !0, SC(O);
      else
        x1 = !1;
      ND(O, y);
      var y1 = O.stateNode, r1;
      if (y1 === null)
        Tk(L, O), W$0(O, _, k), vu(O, _, k, y), r1 = !0;
      else if (L === null)
        r1 = Xu0(O, _, k, y);
      else
        r1 = Yu0(L, O, _, k, y);
      var Q8 = pu(L, O, _, r1, x1, y);
      {
        var J6 = O.stateNode;
        if (r1 && J6.props !== k) {
          if (!EO)
            Y("It looks like %s is reassigning its own `this.props` while rendering. This is not supported and can lead to confusing bugs.", D6(O) || "a component");
          EO = !0;
        }
      }
      return Q8;
    }
    function pu(L, O, _, k, y, d) {
      E$0(L, O);
      var o = (O.flags & x9) !== M6;
      if (!k && !o) {
        if (y)
          t70(O, _, !1);
        return qF(L, O, d);
      }
      var H0 = O.stateNode;
      nj.current = O;
      var O0;
      if (o && typeof _.getDerivedStateFromError !== "function")
        O0 = null, J$0();
      else {
        nw(O);
        {
          if (n5(!0), O0 = H0.render(), O.mode & Y$) {
            tX(!0);
            try {
              H0.render();
            } finally {
              tX(!1);
            }
          }
          n5(!1);
        }
        u4();
      }
      if (O.flags |= d4, L !== null && o)
        qu0(L, O, O0, d);
      else
        FW(L, O, O0, d);
      if (O.memoizedState = H0.state, y)
        t70(O, _, !0);
      return O.child;
    }
    function z$0(L) {
      var O = L.stateNode;
      if (O.pendingContext)
        a70(L, O.pendingContext, O.pendingContext !== O.context);
      else if (O.context)
        a70(L, O.context, !1);
      pp(L, O.containerInfo);
    }
    function Ru0(L, O, _) {
      if (z$0(O), L === null)
        throw new Error("Should have a current fiber. This is a bug in React.");
      var { pendingProps: k, memoizedState: y } = O, d = y.element;
      AJ0(L, O), aC(O, k, null, _);
      var { memoizedState: o, stateNode: H0 } = O, O0 = o.element;
      if (y.isDehydrated) {
        var I0 = {
          element: O0,
          isDehydrated: !1,
          cache: o.cache,
          pendingSuspenseBoundaries: o.pendingSuspenseBoundaries,
          transitions: o.transitions
        }, g0 = O.updateQueue;
        if (g0.baseState = I0, O.memoizedState = I0, O.flags & tq) {
          var R1 = RO(new Error("There was an error while hydrating. Because the error happened outside of a Suspense boundary, the entire root will switch to client rendering."), O);
          return D$0(L, O, O0, _, R1);
        } else if (O0 !== d) {
          var U1 = RO(new Error("This root received an early update, before anything was able hydrate. Switched the entire root to client rendering."), O);
          return D$0(L, O, O0, _, U1);
        } else {
          Dp0(O);
          var x1 = LJ0(O, null, O0, _);
          O.child = x1;
          var y1 = x1;
          while (y1)
            y1.flags = y1.flags & ~u$ | eq, y1 = y1.sibling;
        }
      } else {
        if (KD(), O0 === d)
          return qF(L, O, _);
        FW(L, O, O0, _);
      }
      return O.child;
    }
    function D$0(L, O, _, k, y) {
      return KD(), _p(y), O.flags |= tq, FW(L, O, _, k), O.child;
    }
    function Eu0(L, O, _) {
      if (TJ0(O), L === null)
        Tp(O);
      var { type: k, pendingProps: y } = O, d = L !== null ? L.memoizedProps : null, o = y.children, H0 = Kp(k, y);
      if (H0)
        o = null;
      else if (d !== null && Kp(k, d))
        O.flags |= uw;
      return E$0(L, O), FW(L, O, o, _), O.child;
    }
    function Ou0(L, O) {
      if (L === null)
        Tp(O);
      return null;
    }
    function zu0(L, O, _, k) {
      Tk(L, O);
      var y = O.pendingProps, d = _, o = d._payload, H0 = d._init, O0 = H0(o);
      O.type = O0;
      var I0 = O.tag = Bl0(O0), g0 = fG(O0, y), R1;
      switch (I0) {
        case W:
          return uu(O, O0), O.type = O0 = TD(O0), R1 = du(null, O, O0, g0, k), R1;
        case K:
          return O.type = O0 = Mc(O0), R1 = O$0(null, O, O0, g0, k), R1;
        case D:
          return O.type = O0 = Ac(O0), R1 = F$0(null, O, O0, g0, k), R1;
        case T: {
          if (O.type !== O.elementType) {
            var U1 = O0.propTypes;
            if (U1)
              PG(U1, g0, "prop", y6(O0));
          }
          return R1 = U$0(null, O, O0, fG(O0.type, g0), k), R1;
        }
      }
      var x1 = "";
      if (O0 !== null && typeof O0 === "object" && O0.$$typeof === I1)
        x1 = " Did you wrap a component in React.lazy() more than once?";
      throw new Error("Element type is invalid. Received a promise that resolves to: " + O0 + ". " + ("Lazy element type must resolve to a class or function." + x1));
    }
    function Du0(L, O, _, k, y) {
      Tk(L, O), O.tag = K;
      var d;
      if (tH(_))
        d = !0, SC(O);
      else
        d = !1;
      return ND(O, y), W$0(O, _, k), vu(O, _, k, y), pu(null, O, _, !0, d, y);
    }
    function Mu0(L, O, _, k) {
      Tk(L, O);
      var y = O.pendingProps, d;
      {
        var o = XD(O, _, !1);
        d = YD(O, o);
      }
      ND(O, k);
      var H0, O0;
      nw(O);
      {
        if (_.prototype && typeof _.prototype.render === "function") {
          var I0 = y6(_) || "Unknown";
          if (!bu[I0])
            Y("The <%s /> component appears to have a render method, but doesn't extend React.Component. This is likely to cause errors. Change %s to extend React.Component instead.", I0, I0), bu[I0] = !0;
        }
        if (O.mode & Y$)
          kG.recordLegacyContextWarning(O, null);
        n5(!0), nj.current = O, H0 = ED(null, O, _, y, d, k), O0 = OD(), n5(!1);
      }
      if (u4(), O.flags |= d4, typeof H0 === "object" && H0 !== null && typeof H0.render === "function" && H0.$$typeof === void 0) {
        var g0 = y6(_) || "Unknown";
        if (!ij[g0])
          Y("The <%s /> component appears to be a function component that returns a class instance. Change %s to a class that extends React.Component instead. If you can't use a class try assigning the prototype on the function as a workaround. `%s.prototype = React.Component.prototype`. Don't use an arrow function since it cannot be called with `new` by React.", g0, g0, g0), ij[g0] = !0;
      }
      if (typeof H0 === "object" && H0 !== null && typeof H0.render === "function" && H0.$$typeof === void 0) {
        {
          var R1 = y6(_) || "Unknown";
          if (!ij[R1])
            Y("The <%s /> component appears to be a function component that returns a class instance. Change %s to a class that extends React.Component instead. If you can't use a class try assigning the prototype on the function as a workaround. `%s.prototype = React.Component.prototype`. Don't use an arrow function since it cannot be called with `new` by React.", R1, R1, R1), ij[R1] = !0;
        }
        O.tag = K, O.memoizedState = null, O.updateQueue = null;
        var U1 = !1;
        if (tH(_))
          U1 = !0, SC(O);
        else
          U1 = !1;
        return O.memoizedState = H0.state !== null && H0.state !== void 0 ? H0.state : null, mp(O), Q$0(O, H0), vu(O, _, y, k), pu(null, O, _, !0, U1, k);
      } else {
        if (O.tag = W, O.mode & Y$) {
          tX(!0);
          try {
            H0 = ED(null, O, _, y, d, k), O0 = OD();
          } finally {
            tX(!1);
          }
        }
        if (nY() && O0)
          Mp(O);
        return FW(null, O, H0, k), uu(O, _), O.child;
      }
    }
    function uu(L, O) {
      {
        if (O) {
          if (O.childContextTypes)
            Y("%s(...): childContextTypes cannot be defined on a function component.", O.displayName || O.name || "Component");
        }
        if (L.ref !== null) {
          var _ = "", k = TG();
          if (k)
            _ += `

Check the render method of \`` + k + "`.";
          var y = k || "", d = L._debugSource;
          if (d)
            y = d.fileName + ":" + d.lineNumber;
          if (!gu[y])
            gu[y] = !0, Y("Function components cannot be given refs. Attempts to access this ref will fail. Did you mean to use React.forwardRef()?%s", _);
        }
        if (O.defaultProps !== void 0) {
          var o = y6(O) || "Unknown";
          if (!oj[o])
            Y("%s: Support for defaultProps will be removed from function components in a future major release. Use JavaScript default parameters instead.", o), oj[o] = !0;
        }
        if (typeof O.getDerivedStateFromProps === "function") {
          var H0 = y6(O) || "Unknown";
          if (!yu[H0])
            Y("%s: Function components do not support getDerivedStateFromProps.", H0), yu[H0] = !0;
        }
        if (typeof O.contextType === "object" && O.contextType !== null) {
          var O0 = y6(O) || "Unknown";
          if (!xu[O0])
            Y("%s: Function components do not support contextType.", O0), xu[O0] = !0;
        }
      }
    }
    var cu = {
      dehydrated: null,
      treeContext: null,
      retryLane: eX
    };
    function lu(L) {
      return {
        baseLanes: L,
        cachePool: Nu0(),
        transitions: null
      };
    }
    function Au0(L, O) {
      var _ = null;
      return {
        baseLanes: BZ(L.baseLanes, O),
        cachePool: _,
        transitions: L.transitions
      };
    }
    function Bu0(L, O, _, k) {
      if (O !== null) {
        var y = O.memoizedState;
        if (y === null)
          return !1;
      }
      return lp(L, xj);
    }
    function wu0(L, O) {
      return JC(L.childLanes, O);
    }
    function M$0(L, O, _) {
      var k = O.pendingProps;
      if (xl0(O))
        O.flags |= x9;
      var y = vG.current, d = !1, o = (O.flags & x9) !== M6;
      if (o || Bu0(y, L))
        d = !0, O.flags &= ~x9;
      else if (L === null || L.memoizedState !== null)
        y = pp0(y, VJ0);
      if (y = FD(y), ZL(O, y), L === null) {
        Tp(O);
        var H0 = O.memoizedState;
        if (H0 !== null) {
          var O0 = H0.dehydrated;
          if (O0 !== null)
            return Iu0(O, O0);
        }
        var { children: I0, fallback: g0 } = k;
        if (d) {
          var R1 = ju0(O, I0, g0, _), U1 = O.child;
          return U1.memoizedState = lu(_), O.memoizedState = cu, R1;
        } else
          return nu(O, I0);
      } else {
        var x1 = L.memoizedState;
        if (x1 !== null) {
          var y1 = x1.dehydrated;
          if (y1 !== null)
            return Pu0(L, O, o, k, y1, x1, _);
        }
        if (d) {
          var { fallback: r1, children: Q8 } = k, J6 = _u0(L, O, Q8, r1, _), b8 = O.child, oZ = L.child.memoizedState;
          return b8.memoizedState = oZ === null ? lu(_) : Au0(oZ, _), b8.childLanes = wu0(L, _), O.memoizedState = cu, J6;
        } else {
          var sZ = k.children, C1 = Tu0(L, O, sZ, _);
          return O.memoizedState = null, C1;
        }
      }
    }
    function nu(L, O, _) {
      var k = L.mode, y = {
        mode: "visible",
        children: O
      }, d = iu(y, k);
      return d.return = L, L.child = d, d;
    }
    function ju0(L, O, _, k) {
      var { mode: y, child: d } = L, o = {
        mode: "hidden",
        children: O
      }, H0, O0;
      if ((y & W9) === N6 && d !== null) {
        if (H0 = d, H0.childLanes = T2, H0.pendingProps = o, L.mode & U7)
          H0.actualDuration = 0, H0.actualStartTime = -1, H0.selfBaseDuration = 0, H0.treeBaseDuration = 0;
        O0 = GL(_, y, k, null);
      } else
        H0 = iu(o, y), O0 = GL(_, y, k, null);
      return H0.return = L, O0.return = L, H0.sibling = O0, L.child = H0, O0;
    }
    function iu(L, O, _) {
      return BX0(L, O, T2, null);
    }
    function A$0(L, O) {
      return AO(L, O);
    }
    function Tu0(L, O, _, k) {
      var y = L.child, d = y.sibling, o = A$0(y, {
        mode: "visible",
        children: _
      });
      if ((O.mode & W9) === N6)
        o.lanes = k;
      if (o.return = O, o.sibling = null, d !== null) {
        var H0 = O.deletions;
        if (H0 === null)
          O.deletions = [d], O.flags |= iE;
        else
          H0.push(d);
      }
      return O.child = o, o;
    }
    function _u0(L, O, _, k, y) {
      var d = O.mode, o = L.child, H0 = o.sibling, O0 = {
        mode: "hidden",
        children: _
      }, I0;
      if ((d & W9) === N6 && O.child !== o) {
        var g0 = O.child;
        if (I0 = g0, I0.childLanes = T2, I0.pendingProps = O0, O.mode & U7)
          I0.actualDuration = 0, I0.actualStartTime = -1, I0.selfBaseDuration = o.selfBaseDuration, I0.treeBaseDuration = o.treeBaseDuration;
        O.deletions = null;
      } else
        I0 = A$0(o, O0), I0.subtreeFlags = o.subtreeFlags & JF;
      var R1;
      if (H0 !== null)
        R1 = AO(H0, k);
      else
        R1 = GL(k, d, y, null), R1.flags |= u$;
      return R1.return = O, I0.return = O, I0.sibling = R1, O.child = I0, R1;
    }
    function jk(L, O, _, k) {
      if (k !== null)
        _p(k);
      GD(O, L.child, null, _);
      var y = O.pendingProps, d = y.children, o = nu(O, d);
      return o.flags |= u$, O.memoizedState = null, o;
    }
    function Vu0(L, O, _, k, y) {
      var d = O.mode, o = {
        mode: "visible",
        children: _
      }, H0 = iu(o, d), O0 = GL(k, d, y, null);
      if (O0.flags |= u$, H0.return = O, O0.return = O, H0.sibling = O0, O.child = H0, (O.mode & W9) !== N6)
        GD(O, L.child, null, y);
      return O0;
    }
    function Iu0(L, O, _) {
      if ((L.mode & W9) === N6)
        Y("Cannot hydrate Suspense in legacy mode. Switch from ReactDOM.hydrate(element, container) to ReactDOMClient.hydrateRoot(container, <App />).render(element) or remove the Suspense components from the server rendered components."), L.lanes = $C(n6);
      else if (qp(O))
        L.lanes = $C(ZO);
      else
        L.lanes = $C(i5);
      return null;
    }
    function Pu0(L, O, _, k, y, d, o) {
      if (!_) {
        if (Op0(), (O.mode & W9) === N6)
          return jk(L, O, o, null);
        if (qp(y)) {
          var H0, O0, I0;
          {
            var g0 = fd0(y);
            H0 = g0.digest, O0 = g0.message, I0 = g0.stack;
          }
          var R1;
          if (O0)
            R1 = new Error(O0);
          else
            R1 = new Error("The server could not finish this Suspense boundary, likely due to an error during server rendering. Switched to client rendering.");
          var U1 = Su(R1, H0, I0);
          return jk(L, O, o, U1);
        }
        var x1 = o5(o, L.childLanes);
        if (hG || x1) {
          var y1 = hk();
          if (y1 !== null) {
            var r1 = my0(y1, o);
            if (r1 !== eX && r1 !== d.retryLane) {
              d.retryLane = r1;
              var Q8 = s7;
              X5(L, r1), vX(y1, L, r1, Q8);
            }
          }
          Rc();
          var J6 = Su(new Error("This Suspense boundary received an update before it finished hydrating. This caused the boundary to switch to client rendering. The usual way to fix this is to wrap the original update in startTransition."));
          return jk(L, O, o, J6);
        } else if (u70(y)) {
          O.flags |= x9, O.child = L.child;
          var b8 = Ql0.bind(null, L);
          return hd0(y, b8), null;
        } else {
          Mp0(O, y, d.treeContext);
          var oZ = k.children, sZ = nu(O, oZ);
          return sZ.flags |= eq, sZ;
        }
      } else if (O.flags & tq) {
        O.flags &= ~tq;
        var C1 = Su(new Error("There was an error while hydrating this Suspense boundary. Switched to client rendering."));
        return jk(L, O, o, C1);
      } else if (O.memoizedState !== null)
        return O.child = L.child, O.flags |= x9, null;
      else {
        var { children: Y2, fallback: k1 } = k, k2 = Vu0(L, O, Y2, k1, o), z8 = O.child;
        return z8.memoizedState = lu(o), O.memoizedState = cu, k2;
      }
    }
    function B$0(L, O, _) {
      L.lanes = BZ(L.lanes, O);
      var k = L.alternate;
      if (k !== null)
        k.lanes = BZ(k.lanes, O);
      bp(L.return, O, _);
    }
    function Cu0(L, O, _) {
      var k = O;
      while (k !== null) {
        if (k.tag === B) {
          var y = k.memoizedState;
          if (y !== null)
            B$0(k, _, L);
        } else if (k.tag === S)
          B$0(k, _, L);
        else if (k.child !== null) {
          k.child.return = k, k = k.child;
          continue;
        }
        if (k === L)
          return;
        while (k.sibling === null) {
          if (k.return === null || k.return === L)
            return;
          k = k.return;
        }
        k.sibling.return = k.return, k = k.sibling;
      }
    }
    function ku0(L) {
      var O = L, _ = null;
      while (O !== null) {
        var k = O.alternate;
        if (k !== null && Zk(k) === null)
          _ = O;
        O = O.sibling;
      }
      return _;
    }
    function vu0(L) {
      if (L !== void 0 && L !== "forwards" && L !== "backwards" && L !== "together" && !mu[L])
        if (mu[L] = !0, typeof L === "string")
          switch (L.toLowerCase()) {
            case "together":
            case "forwards":
            case "backwards": {
              Y('"%s" is not a valid value for revealOrder on <SuspenseList />. Use lowercase "%s" instead.', L, L.toLowerCase());
              break;
            }
            case "forward":
            case "backward": {
              Y('"%s" is not a valid value for revealOrder on <SuspenseList />. React uses the -s suffix in the spelling. Use "%ss" instead.', L, L.toLowerCase());
              break;
            }
            default:
              Y('"%s" is not a supported revealOrder on <SuspenseList />. Did you mean "together", "forwards" or "backwards"?', L);
              break;
          }
        else
          Y('%s is not a supported value for revealOrder on <SuspenseList />. Did you mean "together", "forwards" or "backwards"?', L);
    }
    function Su0(L, O) {
      if (L !== void 0 && !wk[L]) {
        if (L !== "collapsed" && L !== "hidden")
          wk[L] = !0, Y('"%s" is not a supported value for tail on <SuspenseList />. Did you mean "collapsed" or "hidden"?', L);
        else if (O !== "forwards" && O !== "backwards")
          wk[L] = !0, Y('<SuspenseList tail="%s" /> is only valid if revealOrder is "forwards" or "backwards". Did you mean to specify revealOrder="forwards"?', L);
      }
    }
    function w$0(L, O) {
      {
        var _ = b9(L), k = !_ && typeof s2(L) === "function";
        if (_ || k) {
          var y = _ ? "array" : "iterable";
          return Y("A nested %s was passed to row #%s in <SuspenseList />. Wrap it in an additional SuspenseList to configure its revealOrder: <SuspenseList revealOrder=...> ... <SuspenseList revealOrder=...>{%s}</SuspenseList> ... </SuspenseList>", y, O, y), !1;
        }
      }
      return !0;
    }
    function fu0(L, O) {
      if ((O === "forwards" || O === "backwards") && L !== void 0 && L !== null && L !== !1)
        if (b9(L)) {
          for (var _ = 0;_ < L.length; _++)
            if (!w$0(L[_], _))
              return;
        } else {
          var k = s2(L);
          if (typeof k === "function") {
            var y = k.call(L);
            if (y) {
              var d = y.next(), o = 0;
              for (;!d.done; d = y.next()) {
                if (!w$0(d.value, o))
                  return;
                o++;
              }
            }
          } else
            Y('A single row was passed to a <SuspenseList revealOrder="%s" />. This is not useful since it needs multiple rows. Did you mean to pass multiple children or an array?', O);
        }
    }
    function ou(L, O, _, k, y) {
      var d = L.memoizedState;
      if (d === null)
        L.memoizedState = {
          isBackwards: O,
          rendering: null,
          renderingStartTime: 0,
          last: k,
          tail: _,
          tailMode: y
        };
      else
        d.isBackwards = O, d.rendering = null, d.renderingStartTime = 0, d.last = k, d.tail = _, d.tailMode = y;
    }
    function j$0(L, O, _) {
      var k = O.pendingProps, y = k.revealOrder, d = k.tail, o = k.children;
      vu0(y), Su0(d, y), fu0(o, y), FW(L, O, o, _);
      var H0 = vG.current, O0 = lp(H0, xj);
      if (O0)
        H0 = np(H0, xj), O.flags |= x9;
      else {
        var I0 = L !== null && (L.flags & x9) !== M6;
        if (I0)
          Cu0(O, O.child, _);
        H0 = FD(H0);
      }
      if (ZL(O, H0), (O.mode & W9) === N6)
        O.memoizedState = null;
      else
        switch (y) {
          case "forwards": {
            var g0 = ku0(O.child), R1;
            if (g0 === null)
              R1 = O.child, O.child = null;
            else
              R1 = g0.sibling, g0.sibling = null;
            ou(O, !1, R1, g0, d);
            break;
          }
          case "backwards": {
            var U1 = null, x1 = O.child;
            O.child = null;
            while (x1 !== null) {
              var y1 = x1.alternate;
              if (y1 !== null && Zk(y1) === null) {
                O.child = x1;
                break;
              }
              var r1 = x1.sibling;
              x1.sibling = U1, U1 = x1, x1 = r1;
            }
            ou(O, !0, U1, null, d);
            break;
          }
          case "together": {
            ou(O, !1, null, null, void 0);
            break;
          }
          default:
            O.memoizedState = null;
        }
      return O.child;
    }
    function hu0(L, O, _) {
      pp(O, O.stateNode.containerInfo);
      var k = O.pendingProps;
      if (L === null)
        O.child = GD(O, null, k, _);
      else
        FW(L, O, k, _);
      return O.child;
    }
    var T$0 = !1;
    function bu0(L, O, _) {
      var k = O.type, y = k._context, d = O.pendingProps, o = O.memoizedProps, H0 = d.value;
      {
        if (!("value" in d)) {
          if (!T$0)
            T$0 = !0, Y("The `value` prop is required for the `<Context.Provider>`. Did you misspell it or forget to pass it?");
        }
        var O0 = O.type.propTypes;
        if (O0)
          PG(O0, d, "prop", "Context.Provider");
      }
      if (OJ0(O, y, H0), o !== null) {
        var I0 = o.value;
        if (r5(I0, H0)) {
          if (o.children === d.children && !kC())
            return qF(L, O, _);
        } else
          Sp0(O, y, _);
      }
      var g0 = d.children;
      return FW(L, O, g0, _), O.child;
    }
    var _$0 = !1;
    function xu0(L, O, _) {
      var k = O.type;
      if (k._context === void 0) {
        if (k !== k.Consumer) {
          if (!_$0)
            _$0 = !0, Y("Rendering <Context> directly is not supported and will be removed in a future major release. Did you mean to render <Context.Consumer> instead?");
        }
      } else
        k = k._context;
      var y = O.pendingProps, d = y.children;
      if (typeof d !== "function")
        Y("A context consumer was rendered with multiple children, or a child that isn't a function. A context consumer expects a single child that is a function. If you did pass a function, make sure there is no trailing or leading whitespace around it.");
      ND(O, _);
      var o = c$(k);
      nw(O);
      var H0;
      return nj.current = O, n5(!0), H0 = d(o), n5(!1), u4(), O.flags |= d4, FW(L, O, H0, _), O.child;
    }
    function sj() {
      hG = !0;
    }
    function Tk(L, O) {
      if ((O.mode & W9) === N6) {
        if (L !== null)
          L.alternate = null, O.alternate = null, O.flags |= u$;
      }
    }
    function qF(L, O, _) {
      if (L !== null)
        O.dependencies = L.dependencies;
      if (J$0(), KT(O.lanes), !o5(_, O.childLanes))
        return null;
      return kp0(L, O), O.child;
    }
    function yu0(L, O, _) {
      {
        var k = O.return;
        if (k === null)
          throw new Error("Cannot swap the root fiber.");
        if (L.alternate = null, O.alternate = null, _.index = O.index, _.sibling = O.sibling, _.return = O.return, _.ref = O.ref, O === k.child)
          k.child = _;
        else {
          var y = k.child;
          if (y === null)
            throw new Error("Expected parent to have a child.");
          while (y.sibling !== O)
            if (y = y.sibling, y === null)
              throw new Error("Expected to find the previous sibling.");
          y.sibling = _;
        }
        var d = k.deletions;
        if (d === null)
          k.deletions = [L], k.flags |= iE;
        else
          d.push(L);
        return _.flags |= u$, _;
      }
    }
    function su(L, O) {
      var _ = L.lanes;
      if (o5(_, O))
        return !0;
      return !1;
    }
    function gu0(L, O, _) {
      switch (O.tag) {
        case H:
          z$0(O);
          var k = O.stateNode;
          KD();
          break;
        case q:
          TJ0(O);
          break;
        case K: {
          var y = O.type;
          if (tH(y))
            SC(O);
          break;
        }
        case N:
          pp(O, O.stateNode.containerInfo);
          break;
        case z: {
          var d = O.memoizedProps.value, o = O.type._context;
          OJ0(O, o, d);
          break;
        }
        case A:
          {
            var H0 = o5(_, O.childLanes);
            if (H0)
              O.flags |= F9;
            {
              var O0 = O.stateNode;
              O0.effectDuration = 0, O0.passiveEffectDuration = 0;
            }
          }
          break;
        case B: {
          var I0 = O.memoizedState;
          if (I0 !== null) {
            if (I0.dehydrated !== null)
              return ZL(O, FD(vG.current)), O.flags |= x9, null;
            var g0 = O.child, R1 = g0.childLanes;
            if (o5(_, R1))
              return M$0(L, O, _);
            else {
              ZL(O, FD(vG.current));
              var U1 = qF(L, O, _);
              if (U1 !== null)
                return U1.sibling;
              else
                return null;
            }
          } else
            ZL(O, FD(vG.current));
          break;
        }
        case S: {
          var x1 = (L.flags & x9) !== M6, y1 = o5(_, O.childLanes);
          if (x1) {
            if (y1)
              return j$0(L, O, _);
            O.flags |= x9;
          }
          var r1 = O.memoizedState;
          if (r1 !== null)
            r1.rendering = null, r1.tail = null, r1.lastEffect = null;
          if (ZL(O, vG.current), y1)
            break;
          else
            return null;
        }
        case v:
        case h:
          return O.lanes = T2, R$0(L, O, _);
      }
      return qF(L, O, _);
    }
    function V$0(L, O, _) {
      if (O._debugNeedsRemount && L !== null)
        return yu0(L, O, _c(O.type, O.key, O.pendingProps, O._debugOwner || null, O.mode, O.lanes));
      if (L !== null) {
        var k = L.memoizedProps, y = O.pendingProps;
        if (k !== y || kC() || O.type !== L.type)
          hG = !0;
        else {
          var d = su(L, _);
          if (!d && (O.flags & x9) === M6)
            return hG = !1, gu0(L, O, _);
          if ((L.flags & Zd) !== M6)
            hG = !0;
          else
            hG = !1;
        }
      } else if (hG = !1, nY() && qp0(O)) {
        var o = O.index, H0 = Fp0();
        JJ0(O, H0, o);
      }
      switch (O.lanes = T2, O.tag) {
        case G:
          return Mu0(L, O, O.type, _);
        case V: {
          var O0 = O.elementType;
          return zu0(L, O, O0, _);
        }
        case W: {
          var { type: I0, pendingProps: g0 } = O, R1 = O.elementType === I0 ? g0 : fG(I0, g0);
          return du(L, O, I0, R1, _);
        }
        case K: {
          var { type: U1, pendingProps: x1 } = O, y1 = O.elementType === U1 ? x1 : fG(U1, x1);
          return O$0(L, O, U1, y1, _);
        }
        case H:
          return Ru0(L, O, _);
        case q:
          return Eu0(L, O, _);
        case U:
          return Ou0(L, O);
        case B:
          return M$0(L, O, _);
        case N:
          return hu0(L, O, _);
        case D: {
          var { type: r1, pendingProps: Q8 } = O, J6 = O.elementType === r1 ? Q8 : fG(r1, Q8);
          return F$0(L, O, r1, J6, _);
        }
        case F:
          return Fu0(L, O, _);
        case E:
          return Uu0(L, O, _);
        case A:
          return Lu0(L, O, _);
        case z:
          return bu0(L, O, _);
        case R:
          return xu0(L, O, _);
        case T: {
          var { type: b8, pendingProps: oZ } = O, sZ = fG(b8, oZ);
          if (O.type !== O.elementType) {
            var C1 = b8.propTypes;
            if (C1)
              PG(C1, sZ, "prop", y6(b8));
          }
          return sZ = fG(b8.type, sZ), U$0(L, O, b8, sZ, _);
        }
        case w:
          return L$0(L, O, O.type, O.pendingProps, _);
        case P: {
          var { type: Y2, pendingProps: k1 } = O, k2 = O.elementType === Y2 ? k1 : fG(Y2, k1);
          return Du0(L, O, Y2, k2, _);
        }
        case S:
          return j$0(L, O, _);
        case f:
          break;
        case v:
          return R$0(L, O, _);
      }
      throw new Error("Unknown unit of work tag (" + O.tag + "). This error is likely caused by a bug in React. Please file an issue.");
    }
    function zD(L) {
      L.flags |= F9;
    }
    function I$0(L) {
      L.flags |= mU, L.flags |= Jd;
    }
    var P$0, au, C$0, k$0;
    P$0 = function(L, O, _, k) {
      var y = O.child;
      while (y !== null) {
        if (y.tag === q || y.tag === U)
          Gd0(L, y.stateNode);
        else if (y.tag === N)
          ;
        else if (y.child !== null) {
          y.child.return = y, y = y.child;
          continue;
        }
        if (y === O)
          return;
        while (y.sibling === null) {
          if (y.return === null || y.return === O)
            return;
          y = y.return;
        }
        y.sibling.return = y.return, y = y.sibling;
      }
    }, au = function(L, O) {}, C$0 = function(L, O, _, k, y) {
      var d = L.memoizedProps;
      if (d === k)
        return;
      var o = O.stateNode, H0 = up(), O0 = Nd0(o, _, d, k, y, H0);
      if (O.updateQueue = O0, O0)
        zD(O);
    }, k$0 = function(L, O, _, k) {
      if (_ !== k)
        zD(O);
    };
    function aj(L, O) {
      if (nY())
        return;
      switch (L.tailMode) {
        case "hidden": {
          var _ = L.tail, k = null;
          while (_ !== null) {
            if (_.alternate !== null)
              k = _;
            _ = _.sibling;
          }
          if (k === null)
            L.tail = null;
          else
            k.sibling = null;
          break;
        }
        case "collapsed": {
          var y = L.tail, d = null;
          while (y !== null) {
            if (y.alternate !== null)
              d = y;
            y = y.sibling;
          }
          if (d === null)
            if (!O && L.tail !== null)
              L.tail.sibling = null;
            else
              L.tail = null;
          else
            d.sibling = null;
          break;
        }
      }
    }
    function oY(L) {
      var O = L.alternate !== null && L.alternate.child === L.child, _ = T2, k = M6;
      if (!O) {
        if ((L.mode & U7) !== N6) {
          var { actualDuration: y, selfBaseDuration: d, child: o } = L;
          while (o !== null)
            _ = BZ(_, BZ(o.lanes, o.childLanes)), k |= o.subtreeFlags, k |= o.flags, y += o.actualDuration, d += o.treeBaseDuration, o = o.sibling;
          L.actualDuration = y, L.treeBaseDuration = d;
        } else {
          var H0 = L.child;
          while (H0 !== null)
            _ = BZ(_, BZ(H0.lanes, H0.childLanes)), k |= H0.subtreeFlags, k |= H0.flags, H0.return = L, H0 = H0.sibling;
        }
        L.subtreeFlags |= k;
      } else {
        if ((L.mode & U7) !== N6) {
          var { selfBaseDuration: O0, child: I0 } = L;
          while (I0 !== null)
            _ = BZ(_, BZ(I0.lanes, I0.childLanes)), k |= I0.subtreeFlags & JF, k |= I0.flags & JF, O0 += I0.treeBaseDuration, I0 = I0.sibling;
          L.treeBaseDuration = O0;
        } else {
          var g0 = L.child;
          while (g0 !== null)
            _ = BZ(_, BZ(g0.lanes, g0.childLanes)), k |= g0.subtreeFlags & JF, k |= g0.flags & JF, g0.return = L, g0 = g0.sibling;
        }
        L.subtreeFlags |= k;
      }
      return L.childLanes = _, O;
    }
    function mu0(L, O, _) {
      if (Tp0() && (O.mode & W9) !== N6 && (O.flags & x9) === M6)
        return GJ0(O), KD(), O.flags |= tq | cw | qW, !1;
      var k = yC(O);
      if (_ !== null && _.dehydrated !== null)
        if (L === null) {
          if (!k)
            throw new Error("A dehydrated suspense component was completed without a hydrated node. This is probably a bug in React.");
          if (wp0(O), oY(O), (O.mode & U7) !== N6) {
            var y = _ !== null;
            if (y) {
              var d = O.child;
              if (d !== null)
                O.treeBaseDuration -= d.treeBaseDuration;
            }
          }
          return !1;
        } else {
          if (KD(), (O.flags & x9) === M6)
            O.memoizedState = null;
          if (O.flags |= F9, oY(O), (O.mode & U7) !== N6) {
            var o = _ !== null;
            if (o) {
              var H0 = O.child;
              if (H0 !== null)
                O.treeBaseDuration -= H0.treeBaseDuration;
            }
          }
          return !1;
        }
      else
        return HJ0(), !0;
    }
    function v$0(L, O, _) {
      var k = O.pendingProps;
      switch (Ap(O), O.tag) {
        case G:
        case V:
        case w:
        case W:
        case D:
        case F:
        case E:
        case A:
        case R:
        case T:
          return oY(O), null;
        case K: {
          var y = O.type;
          if (tH(y))
            vC(O);
          return oY(O), null;
        }
        case H: {
          var d = O.stateNode;
          if (qD(O), Op(O), op(), d.pendingContext)
            d.context = d.pendingContext, d.pendingContext = null;
          if (L === null || L.child === null) {
            var o = yC(O);
            if (o)
              zD(O);
            else if (L !== null) {
              var H0 = L.memoizedState;
              if (!H0.isDehydrated || (O.flags & tq) !== M6)
                O.flags |= oE, HJ0();
            }
          }
          return au(L, O), oY(O), null;
        }
        case q: {
          cp(O);
          var O0 = jJ0(), I0 = O.type;
          if (L !== null && O.stateNode != null) {
            if (C$0(L, O, I0, k, O0), L.ref !== O.ref)
              I$0(O);
          } else {
            if (!k) {
              if (O.stateNode === null)
                throw new Error("We must have new props for new mounts. This error is likely caused by a bug in React. Please file an issue.");
              return oY(O), null;
            }
            var g0 = up(), R1 = yC(O);
            if (R1) {
              if (Ap0(O, O0, g0))
                zD(O);
            } else {
              var U1 = Kd0(I0, k, O0, g0, O);
              if (P$0(U1, O, !1, !1), O.stateNode = U1, Hd0(U1, I0, k, O0))
                zD(O);
            }
            if (O.ref !== null)
              I$0(O);
          }
          return oY(O), null;
        }
        case U: {
          var x1 = k;
          if (L && O.stateNode != null) {
            var y1 = L.memoizedProps;
            k$0(L, O, y1, x1);
          } else {
            if (typeof x1 !== "string") {
              if (O.stateNode === null)
                throw new Error("We must have new props for new mounts. This error is likely caused by a bug in React. Please file an issue.");
            }
            var r1 = jJ0(), Q8 = up(), J6 = yC(O);
            if (J6) {
              if (Bp0(O))
                zD(O);
            } else
              O.stateNode = qd0(x1, r1, Q8, O);
          }
          return oY(O), null;
        }
        case B: {
          UD(O);
          var b8 = O.memoizedState;
          if (L === null || L.memoizedState !== null && L.memoizedState.dehydrated !== null) {
            var oZ = mu0(L, O, b8);
            if (!oZ)
              if (O.flags & qW)
                return O;
              else
                return null;
          }
          if ((O.flags & x9) !== M6) {
            if (O.lanes = _, (O.mode & U7) !== N6)
              Mu(O);
            return O;
          }
          var sZ = b8 !== null, C1 = L !== null && L.memoizedState !== null;
          if (sZ !== C1) {
            if (sZ) {
              var Y2 = O.child;
              if (Y2.flags |= sE, (O.mode & W9) !== N6) {
                var k1 = L === null && (O.memoizedProps.unstable_avoidThisFallback !== !0 || !Y0);
                if (k1 || lp(vG.current, VJ0))
                  nc0();
                else
                  Rc();
              }
            }
          }
          var k2 = O.updateQueue;
          if (k2 !== null)
            O.flags |= F9;
          if (oY(O), (O.mode & U7) !== N6) {
            if (sZ) {
              var z8 = O.child;
              if (z8 !== null)
                O.treeBaseDuration -= z8.treeBaseDuration;
            }
          }
          return null;
        }
        case N:
          if (qD(O), au(L, O), L === null)
            Yp0(O.stateNode.containerInfo);
          return oY(O), null;
        case z:
          var q8 = O.type._context;
          return hp(q8, O), oY(O), null;
        case P: {
          var I6 = O.type;
          if (tH(I6))
            vC(O);
          return oY(O), null;
        }
        case S: {
          UD(O);
          var e6 = O.memoizedState;
          if (e6 === null)
            return oY(O), null;
          var R7 = (O.flags & x9) !== M6, V9 = e6.rendering;
          if (V9 === null)
            if (!R7) {
              var I$ = oc0() && (L === null || (L.flags & x9) === M6);
              if (!I$) {
                var I9 = O.child;
                while (I9 !== null) {
                  var Q$ = Zk(I9);
                  if (Q$ !== null) {
                    R7 = !0, O.flags |= x9, aj(e6, !1);
                    var jQ = Q$.updateQueue;
                    if (jQ !== null)
                      O.updateQueue = jQ, O.flags |= F9;
                    return O.subtreeFlags = M6, vp0(O, _), ZL(O, np(vG.current, xj)), O.child;
                  }
                  I9 = I9.sibling;
                }
              }
              if (e6.tail !== null && rX() > ZX0())
                O.flags |= x9, R7 = !0, aj(e6, !1), O.lanes = C90;
            } else
              aj(e6, !1);
          else {
            if (!R7) {
              var eY = Zk(V9);
              if (eY !== null) {
                O.flags |= x9, R7 = !0;
                var ZK = eY.updateQueue;
                if (ZK !== null)
                  O.updateQueue = ZK, O.flags |= F9;
                if (aj(e6, !0), e6.tail === null && e6.tailMode === "hidden" && !V9.alternate && !nY())
                  return oY(O), null;
              } else if (rX() * 2 - e6.renderingStartTime > ZX0() && _ !== i5)
                O.flags |= x9, R7 = !0, aj(e6, !1), O.lanes = C90;
            }
            if (e6.isBackwards)
              V9.sibling = O.child, O.child = V9;
            else {
              var RW = e6.last;
              if (RW !== null)
                RW.sibling = V9;
              else
                O.child = V9;
              e6.last = V9;
            }
          }
          if (e6.tail !== null) {
            var EW = e6.tail;
            e6.rendering = EW, e6.tail = EW.sibling, e6.renderingStartTime = rX(), EW.sibling = null;
            var TQ = vG.current;
            if (R7)
              TQ = np(TQ, xj);
            else
              TQ = FD(TQ);
            return ZL(O, TQ), EW;
          }
          return oY(O), null;
        }
        case f:
          break;
        case v:
        case h: {
          Lc(O);
          var EF = O.memoizedState, _D = EF !== null;
          if (L !== null) {
            var FT = L.memoizedState, WN = FT !== null;
            if (WN !== _D && !r)
              O.flags |= sE;
          }
          if (!_D || (O.mode & W9) === N6)
            oY(O);
          else if (o5(QN, i5)) {
            if (oY(O), O.subtreeFlags & (u$ | F9))
              O.flags |= sE;
          }
          return null;
        }
        case x:
          return null;
        case b:
          return null;
      }
      throw new Error("Unknown unit of work tag (" + O.tag + "). This error is likely caused by a bug in React. Please file an issue.");
    }
    function du0(L, O, _) {
      switch (Ap(O), O.tag) {
        case K: {
          var k = O.type;
          if (tH(k))
            vC(O);
          var y = O.flags;
          if (y & qW) {
            if (O.flags = y & ~qW | x9, (O.mode & U7) !== N6)
              Mu(O);
            return O;
          }
          return null;
        }
        case H: {
          var d = O.stateNode;
          qD(O), Op(O), op();
          var o = O.flags;
          if ((o & qW) !== M6 && (o & x9) === M6)
            return O.flags = o & ~qW | x9, O;
          return null;
        }
        case q:
          return cp(O), null;
        case B: {
          UD(O);
          var H0 = O.memoizedState;
          if (H0 !== null && H0.dehydrated !== null) {
            if (O.alternate === null)
              throw new Error("Threw in newly mounted dehydrated component. This is likely a bug in React. Please file an issue.");
            KD();
          }
          var O0 = O.flags;
          if (O0 & qW) {
            if (O.flags = O0 & ~qW | x9, (O.mode & U7) !== N6)
              Mu(O);
            return O;
          }
          return null;
        }
        case S:
          return UD(O), null;
        case N:
          return qD(O), null;
        case z:
          var I0 = O.type._context;
          return hp(I0, O), null;
        case v:
        case h:
          return Lc(O), null;
        case x:
          return null;
        default:
          return null;
      }
    }
    function S$0(L, O, _) {
      switch (Ap(O), O.tag) {
        case K: {
          var k = O.type.childContextTypes;
          if (k !== null && k !== void 0)
            vC(O);
          break;
        }
        case H: {
          var y = O.stateNode;
          qD(O), Op(O), op();
          break;
        }
        case q: {
          cp(O);
          break;
        }
        case N:
          qD(O);
          break;
        case B:
          UD(O);
          break;
        case S:
          UD(O);
          break;
        case z:
          var d = O.type._context;
          hp(d, O);
          break;
        case v:
        case h:
          Lc(O);
          break;
      }
    }
    var f$0 = null;
    f$0 = /* @__PURE__ */ new Set;
    var _k = !1, sY = !1, pu0 = typeof WeakSet === "function" ? WeakSet : Set, C8 = null, DD = null, MD = null;
    function uu0(L) {
      rm(null, function() {
        throw L;
      }), tm();
    }
    var cu0 = function(L, O) {
      if (O.props = L.memoizedProps, O.state = L.memoizedState, L.mode & U7)
        try {
          XN(), O.componentWillUnmount();
        } finally {
          $N(L);
        }
      else
        O.componentWillUnmount();
    };
    function h$0(L, O) {
      try {
        XL(_X, L);
      } catch (_) {
        h7(L, O, _);
      }
    }
    function ru(L, O, _) {
      try {
        cu0(L, _);
      } catch (k) {
        h7(L, O, k);
      }
    }
    function lu0(L, O, _) {
      try {
        _.componentDidMount();
      } catch (k) {
        h7(L, O, k);
      }
    }
    function b$0(L, O) {
      try {
        g$0(L);
      } catch (_) {
        h7(L, O, _);
      }
    }
    function AD(L, O) {
      var _ = L.ref;
      if (_ !== null)
        if (typeof _ === "function") {
          var k;
          try {
            if (G0 && F0 && L.mode & U7)
              try {
                XN(), k = _(null);
              } finally {
                $N(L);
              }
            else
              k = _(null);
          } catch (y) {
            h7(L, O, y);
          }
          if (typeof k === "function")
            Y("Unexpected return value from a callback ref in %s. A callback ref should not return a function.", D6(L));
        } else
          _.current = null;
    }
    function Vk(L, O, _) {
      try {
        _();
      } catch (k) {
        h7(L, O, k);
      }
    }
    var x$0 = null, y$0 = !1;
    function nu0(L, O) {
      x$0 = Qd0(L.containerInfo), C8 = O, iu0();
      var _ = y$0;
      return y$0 = !1, x$0 = null, _;
    }
    function iu0() {
      while (C8 !== null) {
        var L = C8, O = L.child;
        if ((L.subtreeFlags & Xd) !== M6 && O !== null)
          O.return = L, C8 = O;
        else
          ou0();
      }
    }
    function ou0() {
      while (C8 !== null) {
        var L = C8;
        mJ(L);
        try {
          su0(L);
        } catch (_) {
          h7(L, L.return, _);
        }
        aX();
        var O = L.sibling;
        if (O !== null) {
          O.return = L.return, C8 = O;
          return;
        }
        C8 = L.return;
      }
    }
    function su0(L) {
      var { alternate: O, flags: _ } = L;
      if ((_ & oE) !== M6) {
        switch (mJ(L), L.tag) {
          case W:
          case D:
          case w:
            break;
          case K: {
            if (O !== null) {
              var { memoizedProps: k, memoizedState: y } = O, d = L.stateNode;
              if (L.type === L.elementType && !EO) {
                if (d.props !== L.memoizedProps)
                  Y("Expected %s props to match memoized props before getSnapshotBeforeUpdate. This might either be because of a bug in React, or because a component reassigns its own `this.props`. Please file an issue.", D6(L) || "instance");
                if (d.state !== L.memoizedState)
                  Y("Expected %s state to match memoized state before getSnapshotBeforeUpdate. This might either be because of a bug in React, or because a component reassigns its own `this.state`. Please file an issue.", D6(L) || "instance");
              }
              var o = d.getSnapshotBeforeUpdate(L.elementType === L.type ? k : fG(L.type, k), y);
              {
                var H0 = f$0;
                if (o === void 0 && !H0.has(L.type))
                  H0.add(L.type), Y("%s.getSnapshotBeforeUpdate(): A snapshot value (or null) must be returned. You have returned undefined.", D6(L));
              }
              d.__reactInternalSnapshotBeforeUpdate = o;
            }
            break;
          }
          case H: {
            {
              var O0 = L.stateNode;
              Cd0(O0.containerInfo);
            }
            break;
          }
          case q:
          case U:
          case N:
          case P:
            break;
          default:
            throw new Error("This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue.");
        }
        aX();
      }
    }
    function bG(L, O, _) {
      var k = O.updateQueue, y = k !== null ? k.lastEffect : null;
      if (y !== null) {
        var d = y.next, o = d;
        do {
          if ((o.tag & L) === L) {
            var H0 = o.destroy;
            if (o.destroy = void 0, H0 !== void 0) {
              if ((L & iY) !== Y5)
                qy0(O);
              else if ((L & _X) !== Y5)
                T90(O);
              if ((L & eH) !== Y5)
                HT(!0);
              if (Vk(O, _, H0), (L & eH) !== Y5)
                HT(!1);
              if ((L & iY) !== Y5)
                Fy0();
              else if ((L & _X) !== Y5)
                _90();
            }
          }
          o = o.next;
        } while (o !== d);
      }
    }
    function XL(L, O) {
      var _ = O.updateQueue, k = _ !== null ? _.lastEffect : null;
      if (k !== null) {
        var y = k.next, d = y;
        do {
          if ((d.tag & L) === L) {
            if ((L & iY) !== Y5)
              Hy0(O);
            else if ((L & _X) !== Y5)
              Uy0(O);
            var o = d.create;
            if ((L & eH) !== Y5)
              HT(!0);
            if (d.destroy = o(), (L & eH) !== Y5)
              HT(!1);
            if ((L & iY) !== Y5)
              Ny0();
            else if ((L & _X) !== Y5)
              Ly0();
            {
              var H0 = d.destroy;
              if (H0 !== void 0 && typeof H0 !== "function") {
                var O0 = void 0;
                if ((d.tag & _X) !== M6)
                  O0 = "useLayoutEffect";
                else if ((d.tag & eH) !== M6)
                  O0 = "useInsertionEffect";
                else
                  O0 = "useEffect";
                var I0 = void 0;
                if (H0 === null)
                  I0 = " You returned null. If your effect does not require clean up, return undefined (or nothing).";
                else if (typeof H0.then === "function")
                  I0 = `

It looks like you wrote ` + O0 + `(async () => ...) or returned a Promise. Instead, write the async function inside your effect and call it immediately:

` + O0 + `(() => {
  async function fetchData() {
    // You can await here
    const response = await MyAPI.getData(someId);
    // ...
  }
  fetchData();
}, [someId]); // Or [] if effect doesn't need props or state

Learn more about data fetching with Hooks: https://reactjs.org/link/hooks-data-fetching`;
                else
                  I0 = " You returned: " + H0;
                Y("%s must not return anything besides a function, which is used for clean-up.%s", O0, I0);
              }
            }
          }
          d = d.next;
        } while (d !== y);
      }
    }
    function au0(L, O) {
      if ((O.flags & F9) !== M6)
        switch (O.tag) {
          case A: {
            var _ = O.stateNode.passiveEffectDuration, k = O.memoizedProps, y = k.id, d = k.onPostCommit, o = eJ0(), H0 = O.alternate === null ? "mount" : "update";
            if (tJ0())
              H0 = "nested-update";
            if (typeof d === "function")
              d(y, H0, _, o);
            var O0 = O.return;
            Z:
              while (O0 !== null) {
                switch (O0.tag) {
                  case H:
                    var I0 = O0.stateNode;
                    I0.passiveEffectDuration += _;
                    break Z;
                  case A:
                    var g0 = O0.stateNode;
                    g0.passiveEffectDuration += _;
                    break Z;
                }
                O0 = O0.return;
              }
            break;
          }
        }
    }
    function ru0(L, O, _, k) {
      if ((_.flags & lw) !== M6)
        switch (_.tag) {
          case W:
          case D:
          case w: {
            if (!sY)
              if (_.mode & U7)
                try {
                  XN(), XL(_X | TX, _);
                } finally {
                  $N(_);
                }
              else
                XL(_X | TX, _);
            break;
          }
          case K: {
            var y = _.stateNode;
            if (_.flags & F9) {
              if (!sY)
                if (O === null) {
                  if (_.type === _.elementType && !EO) {
                    if (y.props !== _.memoizedProps)
                      Y("Expected %s props to match memoized props before componentDidMount. This might either be because of a bug in React, or because a component reassigns its own `this.props`. Please file an issue.", D6(_) || "instance");
                    if (y.state !== _.memoizedState)
                      Y("Expected %s state to match memoized state before componentDidMount. This might either be because of a bug in React, or because a component reassigns its own `this.state`. Please file an issue.", D6(_) || "instance");
                  }
                  if (_.mode & U7)
                    try {
                      XN(), y.componentDidMount();
                    } finally {
                      $N(_);
                    }
                  else
                    y.componentDidMount();
                } else {
                  var d = _.elementType === _.type ? O.memoizedProps : fG(_.type, O.memoizedProps), o = O.memoizedState;
                  if (_.type === _.elementType && !EO) {
                    if (y.props !== _.memoizedProps)
                      Y("Expected %s props to match memoized props before componentDidUpdate. This might either be because of a bug in React, or because a component reassigns its own `this.props`. Please file an issue.", D6(_) || "instance");
                    if (y.state !== _.memoizedState)
                      Y("Expected %s state to match memoized state before componentDidUpdate. This might either be because of a bug in React, or because a component reassigns its own `this.state`. Please file an issue.", D6(_) || "instance");
                  }
                  if (_.mode & U7)
                    try {
                      XN(), y.componentDidUpdate(d, o, y.__reactInternalSnapshotBeforeUpdate);
                    } finally {
                      $N(_);
                    }
                  else
                    y.componentDidUpdate(d, o, y.__reactInternalSnapshotBeforeUpdate);
                }
            }
            var H0 = _.updateQueue;
            if (H0 !== null) {
              if (_.type === _.elementType && !EO) {
                if (y.props !== _.memoizedProps)
                  Y("Expected %s props to match memoized props before processing the update queue. This might either be because of a bug in React, or because a component reassigns its own `this.props`. Please file an issue.", D6(_) || "instance");
                if (y.state !== _.memoizedState)
                  Y("Expected %s state to match memoized state before processing the update queue. This might either be because of a bug in React, or because a component reassigns its own `this.state`. Please file an issue.", D6(_) || "instance");
              }
              wJ0(_, H0, y);
            }
            break;
          }
          case H: {
            var O0 = _.updateQueue;
            if (O0 !== null) {
              var I0 = null;
              if (_.child !== null)
                switch (_.child.tag) {
                  case q:
                    I0 = Wp(_.child.stateNode);
                    break;
                  case K:
                    I0 = _.child.stateNode;
                    break;
                }
              wJ0(_, O0, I0);
            }
            break;
          }
          case q: {
            var g0 = _.stateNode;
            if (O === null && _.flags & F9) {
              var { type: R1, memoizedProps: U1 } = _;
              Ed0(g0, R1, U1);
            }
            break;
          }
          case U:
            break;
          case N:
            break;
          case A: {
            {
              var x1 = _.memoizedProps, y1 = x1.onCommit, r1 = x1.onRender, Q8 = _.stateNode.effectDuration, J6 = eJ0(), b8 = O === null ? "mount" : "update";
              if (tJ0())
                b8 = "nested-update";
              if (typeof r1 === "function")
                r1(_.memoizedProps.id, b8, _.actualDuration, _.treeBaseDuration, _.actualStartTime, J6);
              {
                if (typeof y1 === "function")
                  y1(_.memoizedProps.id, b8, Q8, J6);
                ec0(_);
                var oZ = _.return;
                Z:
                  while (oZ !== null) {
                    switch (oZ.tag) {
                      case H:
                        var sZ = oZ.stateNode;
                        sZ.effectDuration += Q8;
                        break Z;
                      case A:
                        var C1 = oZ.stateNode;
                        C1.effectDuration += Q8;
                        break Z;
                    }
                    oZ = oZ.return;
                  }
              }
            }
            break;
          }
          case B: {
            Qc0(L, _);
            break;
          }
          case S:
          case P:
          case f:
          case v:
          case h:
          case b:
            break;
          default:
            throw new Error("This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue.");
        }
      if (!sY) {
        if (_.flags & mU)
          g$0(_);
      }
    }
    function tu0(L) {
      switch (L.tag) {
        case W:
        case D:
        case w: {
          if (L.mode & U7)
            try {
              XN(), h$0(L, L.return);
            } finally {
              $N(L);
            }
          else
            h$0(L, L.return);
          break;
        }
        case K: {
          var O = L.stateNode;
          if (typeof O.componentDidMount === "function")
            lu0(L, L.return, O);
          b$0(L, L.return);
          break;
        }
        case q: {
          b$0(L, L.return);
          break;
        }
      }
    }
    function eu0(L, O) {
      var _ = null;
      {
        var k = L;
        while (!0) {
          if (k.tag === q) {
            if (_ === null) {
              _ = k;
              try {
                var y = k.stateNode;
                if (O)
                  _d0(y);
                else
                  Id0(k.stateNode, k.memoizedProps);
              } catch (o) {
                h7(L, L.return, o);
              }
            }
          } else if (k.tag === U) {
            if (_ === null)
              try {
                var d = k.stateNode;
                if (O)
                  Vd0(d);
                else
                  Pd0(d, k.memoizedProps);
              } catch (o) {
                h7(L, L.return, o);
              }
          } else if ((k.tag === v || k.tag === h) && k.memoizedState !== null && k !== L)
            ;
          else if (k.child !== null) {
            k.child.return = k, k = k.child;
            continue;
          }
          if (k === L)
            return;
          while (k.sibling === null) {
            if (k.return === null || k.return === L)
              return;
            if (_ === k)
              _ = null;
            k = k.return;
          }
          if (_ === k)
            _ = null;
          k.sibling.return = k.return, k = k.sibling;
        }
      }
    }
    function g$0(L) {
      var O = L.ref;
      if (O !== null) {
        var _ = L.stateNode, k;
        switch (L.tag) {
          case q:
            k = Wp(_);
            break;
          default:
            k = _;
        }
        if (typeof O === "function") {
          var y;
          if (L.mode & U7)
            try {
              XN(), y = O(k);
            } finally {
              $N(L);
            }
          else
            y = O(k);
          if (typeof y === "function")
            Y("Unexpected return value from a callback ref in %s. A callback ref should not return a function.", D6(L));
        } else {
          if (!O.hasOwnProperty("current"))
            Y("Unexpected ref object provided for %s. Use either a ref-setter function or React.createRef().", D6(L));
          O.current = k;
        }
      }
    }
    function Zc0(L) {
      var O = L.alternate;
      if (O !== null)
        O.return = null;
      L.return = null;
    }
    function m$0(L) {
      var O = L.alternate;
      if (O !== null)
        L.alternate = null, m$0(O);
      {
        if (L.child = null, L.deletions = null, L.sibling = null, L.tag === q) {
          var _ = L.stateNode;
          if (_ !== null)
            Kp0(_);
        }
        L.stateNode = null, L._debugOwner = null, L.return = null, L.dependencies = null, L.memoizedProps = null, L.memoizedState = null, L.pendingProps = null, L.stateNode = null, L.updateQueue = null;
      }
    }
    function Jc0(L) {
      var O = L.return;
      while (O !== null) {
        if (d$0(O))
          return O;
        O = O.return;
      }
      throw new Error("Expected to find a host parent. This error is likely caused by a bug in React. Please file an issue.");
    }
    function d$0(L) {
      return L.tag === q || L.tag === H || L.tag === N;
    }
    function p$0(L) {
      var O = L;
      Z:
        while (!0) {
          while (O.sibling === null) {
            if (O.return === null || d$0(O.return))
              return null;
            O = O.return;
          }
          O.sibling.return = O.return, O = O.sibling;
          while (O.tag !== q && O.tag !== U && O.tag !== I) {
            if (O.flags & u$)
              continue Z;
            if (O.child === null || O.tag === N)
              continue Z;
            else
              O.child.return = O, O = O.child;
          }
          if (!(O.flags & u$))
            return O.stateNode;
        }
    }
    function $c0(L) {
      var O = Jc0(L);
      switch (O.tag) {
        case q: {
          var _ = O.stateNode;
          if (O.flags & uw)
            p70(_), O.flags &= ~uw;
          var k = p$0(L);
          eu(L, k, _);
          break;
        }
        case H:
        case N: {
          var y = O.stateNode.containerInfo, d = p$0(L);
          tu(L, d, y);
          break;
        }
        default:
          throw new Error("Invalid host parent fiber. This error is likely caused by a bug in React. Please file an issue.");
      }
    }
    function tu(L, O, _) {
      var k = L.tag, y = k === q || k === U;
      if (y) {
        var d = L.stateNode;
        if (O)
          Bd0(_, d, O);
        else
          Md0(_, d);
      } else if (k === N)
        ;
      else {
        var o = L.child;
        if (o !== null) {
          tu(o, O, _);
          var H0 = o.sibling;
          while (H0 !== null)
            tu(H0, O, _), H0 = H0.sibling;
        }
      }
    }
    function eu(L, O, _) {
      var k = L.tag, y = k === q || k === U;
      if (y) {
        var d = L.stateNode;
        if (O)
          Ad0(_, d, O);
        else
          Dd0(_, d);
      } else if (k === N)
        ;
      else {
        var o = L.child;
        if (o !== null) {
          eu(o, O, _);
          var H0 = o.sibling;
          while (H0 !== null)
            eu(H0, O, _), H0 = H0.sibling;
        }
      }
    }
    var aY = null, xG = !1;
    function Xc0(L, O, _) {
      {
        var k = O;
        Z:
          while (k !== null) {
            switch (k.tag) {
              case q: {
                aY = k.stateNode, xG = !1;
                break Z;
              }
              case H: {
                aY = k.stateNode.containerInfo, xG = !0;
                break Z;
              }
              case N: {
                aY = k.stateNode.containerInfo, xG = !0;
                break Z;
              }
            }
            k = k.return;
          }
        if (aY === null)
          throw new Error("Expected to find a host parent. This error is likely caused by a bug in React. Please file an issue.");
        u$0(L, O, _), aY = null, xG = !1;
      }
      Zc0(_);
    }
    function YL(L, O, _) {
      var k = _.child;
      while (k !== null)
        u$0(L, O, k), k = k.sibling;
    }
    function u$0(L, O, _) {
      switch (Qy0(_), _.tag) {
        case q:
          if (!sY)
            AD(_, O);
        case U: {
          {
            var k = aY, y = xG;
            if (aY = null, YL(L, O, _), aY = k, xG = y, aY !== null)
              if (xG)
                jd0(aY, _.stateNode);
              else
                wd0(aY, _.stateNode);
          }
          return;
        }
        case I: {
          if (aY !== null)
            if (xG)
              Td0(aY, _.stateNode);
            else
              Np(aY, _.stateNode);
          return;
        }
        case N: {
          {
            var d = aY, o = xG;
            aY = _.stateNode.containerInfo, xG = !0, YL(L, O, _), aY = d, xG = o;
          }
          return;
        }
        case W:
        case D:
        case T:
        case w: {
          if (!sY) {
            var H0 = _.updateQueue;
            if (H0 !== null) {
              var O0 = H0.lastEffect;
              if (O0 !== null) {
                var I0 = O0.next, g0 = I0;
                do {
                  var R1 = g0, U1 = R1.destroy, x1 = R1.tag;
                  if (U1 !== void 0) {
                    if ((x1 & eH) !== Y5)
                      Vk(_, O, U1);
                    else if ((x1 & _X) !== Y5) {
                      if (T90(_), _.mode & U7)
                        XN(), Vk(_, O, U1), $N(_);
                      else
                        Vk(_, O, U1);
                      _90();
                    }
                  }
                  g0 = g0.next;
                } while (g0 !== I0);
              }
            }
          }
          YL(L, O, _);
          return;
        }
        case K: {
          if (!sY) {
            AD(_, O);
            var y1 = _.stateNode;
            if (typeof y1.componentWillUnmount === "function")
              ru(_, O, y1);
          }
          YL(L, O, _);
          return;
        }
        case f: {
          YL(L, O, _);
          return;
        }
        case v: {
          if (_.mode & W9) {
            var r1 = sY;
            sY = r1 || _.memoizedState !== null, YL(L, O, _), sY = r1;
          } else
            YL(L, O, _);
          break;
        }
        default: {
          YL(L, O, _);
          return;
        }
      }
    }
    function Yc0(L) {
      var O = L.memoizedState;
    }
    function Qc0(L, O) {
      var _ = O.memoizedState;
      if (_ === null) {
        var k = O.alternate;
        if (k !== null) {
          var y = k.memoizedState;
          if (y !== null) {
            var d = y.dehydrated;
            if (d !== null)
              cd0(d);
          }
        }
      }
    }
    function c$0(L) {
      var O = L.updateQueue;
      if (O !== null) {
        L.updateQueue = null;
        var _ = L.stateNode;
        if (_ === null)
          _ = L.stateNode = new pu0;
        O.forEach(function(k) {
          var y = Wl0.bind(null, L, k);
          if (!_.has(k)) {
            if (_.add(k), VG)
              if (DD !== null && MD !== null)
                GT(MD, DD);
              else
                throw Error("Expected finished root and lanes to be set. This is a bug in React.");
            k.then(y, y);
          }
        });
      }
    }
    function Wc0(L, O, _) {
      DD = _, MD = L, mJ(O), l$0(O, L), mJ(O), DD = null, MD = null;
    }
    function yG(L, O, _) {
      var k = O.deletions;
      if (k !== null)
        for (var y = 0;y < k.length; y++) {
          var d = k[y];
          try {
            Xc0(L, O, d);
          } catch (O0) {
            h7(d, O, O0);
          }
        }
      var o = fP();
      if (O.subtreeFlags & Yd) {
        var H0 = O.child;
        while (H0 !== null)
          mJ(H0), l$0(H0, L), H0 = H0.sibling;
      }
      mJ(o);
    }
    function l$0(L, O, _) {
      var { alternate: k, flags: y } = L;
      switch (L.tag) {
        case W:
        case D:
        case T:
        case w: {
          if (yG(O, L), YN(L), y & F9) {
            try {
              bG(eH | TX, L, L.return), XL(eH | TX, L);
            } catch (I6) {
              h7(L, L.return, I6);
            }
            if (L.mode & U7) {
              try {
                XN(), bG(_X | TX, L, L.return);
              } catch (I6) {
                h7(L, L.return, I6);
              }
              $N(L);
            } else
              try {
                bG(_X | TX, L, L.return);
              } catch (I6) {
                h7(L, L.return, I6);
              }
          }
          return;
        }
        case K: {
          if (yG(O, L), YN(L), y & mU) {
            if (k !== null)
              AD(k, k.return);
          }
          return;
        }
        case q: {
          if (yG(O, L), YN(L), y & mU) {
            if (k !== null)
              AD(k, k.return);
          }
          {
            if (L.flags & uw) {
              var d = L.stateNode;
              try {
                p70(d);
              } catch (I6) {
                h7(L, L.return, I6);
              }
            }
            if (y & F9) {
              var o = L.stateNode;
              if (o != null) {
                var H0 = L.memoizedProps, O0 = k !== null ? k.memoizedProps : H0, I0 = L.type, g0 = L.updateQueue;
                if (L.updateQueue = null, g0 !== null)
                  try {
                    Od0(o, g0, I0, O0, H0, L);
                  } catch (I6) {
                    h7(L, L.return, I6);
                  }
              }
            }
          }
          return;
        }
        case U: {
          if (yG(O, L), YN(L), y & F9) {
            if (L.stateNode === null)
              throw new Error("This should have a text node initialized. This error is likely caused by a bug in React. Please file an issue.");
            var { stateNode: R1, memoizedProps: U1 } = L, x1 = k !== null ? k.memoizedProps : U1;
            try {
              zd0(R1, x1, U1);
            } catch (I6) {
              h7(L, L.return, I6);
            }
          }
          return;
        }
        case H: {
          if (yG(O, L), YN(L), y & F9) {
            if (k !== null) {
              var y1 = k.memoizedState;
              if (y1.isDehydrated)
                try {
                  ud0(O.containerInfo);
                } catch (I6) {
                  h7(L, L.return, I6);
                }
            }
          }
          return;
        }
        case N: {
          yG(O, L), YN(L);
          return;
        }
        case B: {
          yG(O, L), YN(L);
          var r1 = L.child;
          if (r1.flags & sE) {
            var { stateNode: Q8, memoizedState: J6 } = r1, b8 = J6 !== null;
            if (Q8.isHidden = b8, b8) {
              var oZ = r1.alternate !== null && r1.alternate.memoizedState !== null;
              if (!oZ)
                lc0();
            }
          }
          if (y & F9) {
            try {
              Yc0(L);
            } catch (I6) {
              h7(L, L.return, I6);
            }
            c$0(L);
          }
          return;
        }
        case v: {
          var sZ = k !== null && k.memoizedState !== null;
          if (L.mode & W9) {
            var C1 = sY;
            sY = C1 || sZ, yG(O, L), sY = C1;
          } else
            yG(O, L);
          if (YN(L), y & sE) {
            var { stateNode: Y2, memoizedState: k1 } = L, k2 = k1 !== null, z8 = L;
            if (Y2.isHidden = k2, k2) {
              if (!sZ) {
                if ((z8.mode & W9) !== N6) {
                  C8 = z8;
                  var q8 = z8.child;
                  while (q8 !== null)
                    C8 = q8, Gc0(q8), q8 = q8.sibling;
                }
              }
            }
            eu0(z8, k2);
          }
          return;
        }
        case S: {
          if (yG(O, L), YN(L), y & F9)
            c$0(L);
          return;
        }
        case f:
          return;
        default: {
          yG(O, L), YN(L);
          return;
        }
      }
    }
    function YN(L) {
      var O = L.flags;
      if (O & u$) {
        try {
          $c0(L);
        } catch (_) {
          h7(L, L.return, _);
        }
        L.flags &= ~u$;
      }
      if (O & eq)
        L.flags &= ~eq;
    }
    function Kc0(L, O, _) {
      DD = _, MD = O, C8 = L, n$0(L, O, _), DD = null, MD = null;
    }
    function n$0(L, O, _) {
      var k = (L.mode & W9) !== N6;
      while (C8 !== null) {
        var y = C8, d = y.child;
        if (y.tag === v && k) {
          var o = y.memoizedState !== null, H0 = o || _k;
          if (H0) {
            Zc(L, O, _);
            continue;
          } else {
            var O0 = y.alternate, I0 = O0 !== null && O0.memoizedState !== null, g0 = I0 || sY, R1 = _k, U1 = sY;
            if (_k = H0, sY = g0, sY && !U1)
              C8 = y, Hc0(y);
            var x1 = d;
            while (x1 !== null)
              C8 = x1, n$0(x1, O, _), x1 = x1.sibling;
            C8 = y, _k = R1, sY = U1, Zc(L, O, _);
            continue;
          }
        }
        if ((y.subtreeFlags & lw) !== M6 && d !== null)
          d.return = y, C8 = d;
        else
          Zc(L, O, _);
      }
    }
    function Zc(L, O, _) {
      while (C8 !== null) {
        var k = C8;
        if ((k.flags & lw) !== M6) {
          var y = k.alternate;
          mJ(k);
          try {
            ru0(O, y, k, _);
          } catch (o) {
            h7(k, k.return, o);
          }
          aX();
        }
        if (k === L) {
          C8 = null;
          return;
        }
        var d = k.sibling;
        if (d !== null) {
          d.return = k.return, C8 = d;
          return;
        }
        C8 = k.return;
      }
    }
    function Gc0(L) {
      while (C8 !== null) {
        var O = C8, _ = O.child;
        switch (O.tag) {
          case W:
          case D:
          case T:
          case w: {
            if (O.mode & U7)
              try {
                XN(), bG(_X, O, O.return);
              } finally {
                $N(O);
              }
            else
              bG(_X, O, O.return);
            break;
          }
          case K: {
            AD(O, O.return);
            var k = O.stateNode;
            if (typeof k.componentWillUnmount === "function")
              ru(O, O.return, k);
            break;
          }
          case q: {
            AD(O, O.return);
            break;
          }
          case v: {
            var y = O.memoizedState !== null;
            if (y) {
              i$0(L);
              continue;
            }
            break;
          }
        }
        if (_ !== null)
          _.return = O, C8 = _;
        else
          i$0(L);
      }
    }
    function i$0(L) {
      while (C8 !== null) {
        var O = C8;
        if (O === L) {
          C8 = null;
          return;
        }
        var _ = O.sibling;
        if (_ !== null) {
          _.return = O.return, C8 = _;
          return;
        }
        C8 = O.return;
      }
    }
    function Hc0(L) {
      while (C8 !== null) {
        var O = C8, _ = O.child;
        if (O.tag === v) {
          var k = O.memoizedState !== null;
          if (k) {
            o$0(L);
            continue;
          }
        }
        if (_ !== null)
          _.return = O, C8 = _;
        else
          o$0(L);
      }
    }
    function o$0(L) {
      while (C8 !== null) {
        var O = C8;
        mJ(O);
        try {
          tu0(O);
        } catch (k) {
          h7(O, O.return, k);
        }
        if (aX(), O === L) {
          C8 = null;
          return;
        }
        var _ = O.sibling;
        if (_ !== null) {
          _.return = O.return, C8 = _;
          return;
        }
        C8 = O.return;
      }
    }
    function Nc0(L, O, _, k) {
      C8 = O, qc0(O, L, _, k);
    }
    function qc0(L, O, _, k) {
      while (C8 !== null) {
        var y = C8, d = y.child;
        if ((y.subtreeFlags & p4) !== M6 && d !== null)
          d.return = y, C8 = d;
        else
          Fc0(L, O, _, k);
      }
    }
    function Fc0(L, O, _, k) {
      while (C8 !== null) {
        var y = C8;
        if ((y.flags & _G) !== M6) {
          mJ(y);
          try {
            Uc0(O, y, _, k);
          } catch (o) {
            h7(y, y.return, o);
          }
          aX();
        }
        if (y === L) {
          C8 = null;
          return;
        }
        var d = y.sibling;
        if (d !== null) {
          d.return = y.return, C8 = d;
          return;
        }
        C8 = y.return;
      }
    }
    function Uc0(L, O, _, k) {
      switch (O.tag) {
        case W:
        case D:
        case w: {
          if (O.mode & U7) {
            Du();
            try {
              XL(iY | TX, O);
            } finally {
              zu(O);
            }
          } else
            XL(iY | TX, O);
          break;
        }
      }
    }
    function Lc0(L) {
      C8 = L, Rc0();
    }
    function Rc0() {
      while (C8 !== null) {
        var L = C8, O = L.child;
        if ((C8.flags & iE) !== M6) {
          var _ = L.deletions;
          if (_ !== null) {
            for (var k = 0;k < _.length; k++) {
              var y = _[k];
              C8 = y, zc0(y, L);
            }
            {
              var d = L.alternate;
              if (d !== null) {
                var o = d.child;
                if (o !== null) {
                  d.child = null;
                  do {
                    var H0 = o.sibling;
                    o.sibling = null, o = H0;
                  } while (o !== null);
                }
              }
            }
            C8 = L;
          }
        }
        if ((L.subtreeFlags & p4) !== M6 && O !== null)
          O.return = L, C8 = O;
        else
          Ec0();
      }
    }
    function Ec0() {
      while (C8 !== null) {
        var L = C8;
        if ((L.flags & _G) !== M6)
          mJ(L), Oc0(L), aX();
        var O = L.sibling;
        if (O !== null) {
          O.return = L.return, C8 = O;
          return;
        }
        C8 = L.return;
      }
    }
    function Oc0(L) {
      switch (L.tag) {
        case W:
        case D:
        case w: {
          if (L.mode & U7)
            Du(), bG(iY | TX, L, L.return), zu(L);
          else
            bG(iY | TX, L, L.return);
          break;
        }
      }
    }
    function zc0(L, O) {
      while (C8 !== null) {
        var _ = C8;
        mJ(_), Mc0(_, O), aX();
        var k = _.child;
        if (k !== null)
          k.return = _, C8 = k;
        else
          Dc0(L);
      }
    }
    function Dc0(L) {
      while (C8 !== null) {
        var O = C8, _ = O.sibling, k = O.return;
        if (m$0(O), O === L) {
          C8 = null;
          return;
        }
        if (_ !== null) {
          _.return = k, C8 = _;
          return;
        }
        C8 = k;
      }
    }
    function Mc0(L, O) {
      switch (L.tag) {
        case W:
        case D:
        case w: {
          if (L.mode & U7)
            Du(), bG(iY, L, O), zu(L);
          else
            bG(iY, L, O);
          break;
        }
      }
    }
    function Ac0(L) {
      switch (L.tag) {
        case W:
        case D:
        case w: {
          try {
            XL(_X | TX, L);
          } catch (_) {
            h7(L, L.return, _);
          }
          break;
        }
        case K: {
          var O = L.stateNode;
          try {
            O.componentDidMount();
          } catch (_) {
            h7(L, L.return, _);
          }
          break;
        }
      }
    }
    function Bc0(L) {
      switch (L.tag) {
        case W:
        case D:
        case w: {
          try {
            XL(iY | TX, L);
          } catch (O) {
            h7(L, L.return, O);
          }
          break;
        }
      }
    }
    function wc0(L) {
      switch (L.tag) {
        case W:
        case D:
        case w: {
          try {
            bG(_X | TX, L, L.return);
          } catch (_) {
            h7(L, L.return, _);
          }
          break;
        }
        case K: {
          var O = L.stateNode;
          if (typeof O.componentWillUnmount === "function")
            ru(L, L.return, O);
          break;
        }
      }
    }
    function jc0(L) {
      switch (L.tag) {
        case W:
        case D:
        case w:
          try {
            bG(iY | TX, L, L.return);
          } catch (O) {
            h7(L, L.return, O);
          }
      }
    }
    var Tc0 = 0, _c0 = 1, Vc0 = 2, Ic0 = 3, Pc0 = 4;
    if (typeof Symbol === "function" && Symbol.for) {
      var rj = Symbol.for;
      Tc0 = rj("selector.component"), _c0 = rj("selector.has_pseudo_class"), Vc0 = rj("selector.role"), Ic0 = rj("selector.test_id"), Pc0 = rj("selector.text");
    }
    var Cc0 = [];
    function kc0() {
      Cc0.forEach(function(L) {
        return L();
      });
    }
    var vc0 = Z.ReactCurrentActQueue;
    function Sc0(L) {
      {
        var O = typeof IS_REACT_ACT_ENVIRONMENT !== "undefined" ? IS_REACT_ACT_ENVIRONMENT : void 0, _ = typeof jest !== "undefined";
        return _ && O !== !1;
      }
    }
    function s$0() {
      {
        var L = typeof IS_REACT_ACT_ENVIRONMENT !== "undefined" ? IS_REACT_ACT_ENVIRONMENT : void 0;
        if (!L && vc0.current !== null)
          Y("The current testing environment is not configured to support act(...)");
        return L;
      }
    }
    var fc0 = Math.ceil, Jc = Z.ReactCurrentDispatcher, $c = Z.ReactCurrentOwner, rY = Z.ReactCurrentBatchConfig, gG = Z.ReactCurrentActQueue, PX = 0, a$0 = 1, tY = 2, oK = 4, FF = 0, tj = 1, OO = 2, Ik = 3, ej = 4, r$0 = 5, Xc = 6, K9 = PX, UW = null, dJ = null, CX = T2, QN = T2, Yc = oU(T2), kX = FF, ZT = null, Qc = T2, Pk = T2, JT = T2, Ck = T2, $T = null, Q5 = null, Wc = 0, t$0 = 500, e$0 = 1 / 0, hc0 = 500, UF = null;
    function XT() {
      e$0 = rX() + hc0;
    }
    function ZX0() {
      return e$0;
    }
    var kk = !1, Kc = null, BD = null, zO = !1, QL = null, YT = T2, Gc = [], Hc = null, bc0 = 50, QT = 0, Nc = null, qc = !1, vk = !1, xc0 = 50, wD = 0, Sk = null, WT = s7, fk = T2, JX0 = !1;
    function hk() {
      return UW;
    }
    function LW() {
      if ((K9 & (tY | oK)) !== PX)
        return rX();
      if (WT !== s7)
        return WT;
      return WT = rX(), WT;
    }
    function WL(L) {
      var O = L.mode;
      if ((O & W9) === N6)
        return n6;
      else if ((K9 & tY) !== PX && CX !== T2)
        return tw(CX);
      var _ = Ip0() !== Vp0;
      if (_) {
        if (rY.transition !== null) {
          var k = rY.transition;
          if (!k._updatedFibers)
            k._updatedFibers = /* @__PURE__ */ new Set;
          k._updatedFibers.add(L);
        }
        if (fk === eX)
          fk = f90();
        return fk;
      }
      var y = IG();
      if (y !== eX)
        return y;
      var d = Fd0();
      return d;
    }
    function yc0(L) {
      var O = L.mode;
      if ((O & W9) === N6)
        return n6;
      return by0();
    }
    function vX(L, O, _, k) {
      if (Gl0(), JX0)
        Y("useInsertionEffect must not schedule updates.");
      if (qc)
        vk = !0;
      if (ew(L, _, k), (K9 & tY) !== T2 && L === UW)
        ql0(O);
      else {
        if (VG)
          x90(L, O, _);
        if (Fl0(O), L === UW) {
          if ((K9 & tY) === PX)
            JT = BZ(JT, _);
          if (kX === ej)
            KL(L, CX);
        }
        if (W5(L, k), _ === n6 && K9 === PX && (O.mode & W9) === N6 && !gG.isBatchingLegacy)
          XT(), ZJ0();
      }
    }
    function gc0(L, O, _) {
      var k = L.current;
      k.lanes = O, ew(L, O, _), W5(L, _);
    }
    function mc0(L) {
      return (K9 & tY) !== PX;
    }
    function W5(L, O) {
      var _ = L.callbackNode;
      Cy0(L, O);
      var k = eP(L, L === UW ? CX : T2);
      if (k === T2) {
        if (_ !== null)
          OX0(_);
        L.callbackNode = null, L.callbackPriority = eX;
        return;
      }
      var y = $O(k), d = L.callbackPriority;
      if (d === y && !(gG.current !== null && _ !== zc)) {
        if (_ == null && d !== n6)
          Y("Expected scheduled callback to exist. This error is likely caused by a bug in React. Please file an issue.");
        return;
      }
      if (_ != null)
        OX0(_);
      var o;
      if (y === n6) {
        if (L.tag === sU) {
          if (gG.isBatchingLegacy !== null)
            gG.didScheduleLegacyUpdate = !0;
          Np0(YX0.bind(null, L));
        } else
          e70(YX0.bind(null, L));
        if (gG.current !== null)
          gG.current.push(aU);
        else
          Ld0(function() {
            if ((K9 & (tY | oK)) === PX)
              aU();
          });
        o = null;
      } else {
        var H0;
        switch (m90(k)) {
          case s5:
            H0 = sP;
            break;
          case XF:
            H0 = Qd;
            break;
          case YF:
            H0 = tE;
            break;
          case XC:
            H0 = Wd;
            break;
          default:
            H0 = tE;
            break;
        }
        o = Dc(H0, $X0.bind(null, L));
      }
      L.callbackPriority = y, L.callbackNode = o;
    }
    function $X0(L, O) {
      if (ep0(), WT = s7, fk = T2, (K9 & (tY | oK)) !== PX)
        throw new Error("Should not already be working.");
      var _ = L.callbackNode, k = RF();
      if (k) {
        if (L.callbackNode !== _)
          return null;
      }
      var y = eP(L, L === UW ? CX : T2);
      if (y === T2)
        return null;
      var d = !ZC(L, y) && !hy0(L, y) && !O, o = d ? ac0(L, y) : xk(L, y);
      if (o !== FF) {
        if (o === OO) {
          var H0 = Id(L);
          if (H0 !== T2)
            y = H0, o = Fc(L, H0);
        }
        if (o === tj) {
          var O0 = ZT;
          throw DO(L, T2), KL(L, y), W5(L, rX()), O0;
        }
        if (o === Xc)
          KL(L, y);
        else {
          var I0 = !ZC(L, y), g0 = L.current.alternate;
          if (I0 && !pc0(g0)) {
            if (o = xk(L, y), o === OO) {
              var R1 = Id(L);
              if (R1 !== T2)
                y = R1, o = Fc(L, R1);
            }
            if (o === tj) {
              var U1 = ZT;
              throw DO(L, T2), KL(L, y), W5(L, rX()), U1;
            }
          }
          L.finishedWork = g0, L.finishedLanes = y, dc0(L, o, y);
        }
      }
      if (W5(L, rX()), L.callbackNode === _)
        return $X0.bind(null, L);
      return null;
    }
    function Fc(L, O) {
      var _ = $T;
      if (YC(L)) {
        var k = DO(L, O);
        k.flags |= tq, Xp0(L.containerInfo);
      }
      var y = xk(L, O);
      if (y !== OO) {
        var d = Q5;
        if (Q5 = _, d !== null)
          XX0(d);
      }
      return y;
    }
    function XX0(L) {
      if (Q5 === null)
        Q5 = L;
      else
        Q5.push.apply(Q5, L);
    }
    function dc0(L, O, _) {
      switch (O) {
        case FF:
        case tj:
          throw new Error("Root did not complete. This is a bug in React.");
        case OO: {
          MO(L, Q5, UF);
          break;
        }
        case Ik: {
          if (KL(L, _), v90(_) && !zX0()) {
            var k = Wc + t$0 - rX();
            if (k > 10) {
              var y = eP(L, T2);
              if (y !== T2)
                break;
              var d = L.suspendedLanes;
              if (!i4(d, _)) {
                var o = LW();
                b90(L, d);
                break;
              }
              L.timeoutHandle = Gp(MO.bind(null, L, Q5, UF), k);
              break;
            }
          }
          MO(L, Q5, UF);
          break;
        }
        case ej: {
          if (KL(L, _), fy0(_))
            break;
          if (!zX0()) {
            var H0 = Iy0(L, _), O0 = H0, I0 = rX() - O0, g0 = Kl0(I0) - I0;
            if (g0 > 10) {
              L.timeoutHandle = Gp(MO.bind(null, L, Q5, UF), g0);
              break;
            }
          }
          MO(L, Q5, UF);
          break;
        }
        case r$0: {
          MO(L, Q5, UF);
          break;
        }
        default:
          throw new Error("Unknown root exit status.");
      }
    }
    function pc0(L) {
      var O = L;
      while (!0) {
        if (O.flags & iP) {
          var _ = O.updateQueue;
          if (_ !== null) {
            var k = _.stores;
            if (k !== null)
              for (var y = 0;y < k.length; y++) {
                var d = k[y], o = d.getSnapshot, H0 = d.value;
                try {
                  if (!r5(o(), H0))
                    return !1;
                } catch (I0) {
                  return !1;
                }
              }
          }
        }
        var O0 = O.child;
        if (O.subtreeFlags & iP && O0 !== null) {
          O0.return = O, O = O0;
          continue;
        }
        if (O === L)
          return !0;
        while (O.sibling === null) {
          if (O.return === null || O.return === L)
            return !0;
          O = O.return;
        }
        O.sibling.return = O.return, O = O.sibling;
      }
      return !0;
    }
    function KL(L, O) {
      O = JC(O, Ck), O = JC(O, JT), yy0(L, O);
    }
    function YX0(L) {
      if (Zu0(), (K9 & (tY | oK)) !== PX)
        throw new Error("Should not already be working.");
      RF();
      var O = eP(L, T2);
      if (!o5(O, n6))
        return W5(L, rX()), null;
      var _ = xk(L, O);
      if (L.tag !== sU && _ === OO) {
        var k = Id(L);
        if (k !== T2)
          O = k, _ = Fc(L, k);
      }
      if (_ === tj) {
        var y = ZT;
        throw DO(L, T2), KL(L, O), W5(L, rX()), y;
      }
      if (_ === Xc)
        throw new Error("Root did not complete. This is a bug in React.");
      var d = L.current.alternate;
      return L.finishedWork = d, L.finishedLanes = O, MO(L, Q5, UF), W5(L, rX()), null;
    }
    function uc0(L, O) {
      if (O !== T2) {
        if (vd(L, BZ(O, n6)), W5(L, rX()), (K9 & (tY | oK)) === PX)
          XT(), aU();
      }
    }
    function Uc(L, O) {
      var _ = K9;
      K9 |= a$0;
      try {
        return L(O);
      } finally {
        if (K9 = _, K9 === PX && !gG.isBatchingLegacy)
          XT(), ZJ0();
      }
    }
    function cc0(L, O, _, k, y) {
      var d = IG(), o = rY.transition;
      try {
        return rY.transition = null, ZY(s5), L(O, _, k, y);
      } finally {
        if (ZY(d), rY.transition = o, K9 === PX)
          XT();
      }
    }
    function LF(L) {
      if (QL !== null && QL.tag === sU && (K9 & (tY | oK)) === PX)
        RF();
      var O = K9;
      K9 |= a$0;
      var _ = rY.transition, k = IG();
      try {
        if (rY.transition = null, ZY(s5), L)
          return L();
        else
          return;
      } finally {
        if (ZY(k), rY.transition = _, K9 = O, (K9 & (tY | oK)) === PX)
          aU();
      }
    }
    function QX0() {
      return (K9 & (tY | oK)) !== PX;
    }
    function bk(L, O) {
      BQ(Yc, QN, L), QN = BZ(QN, O), Qc = BZ(Qc, O);
    }
    function Lc(L) {
      QN = Yc.current, AQ(Yc, L);
    }
    function DO(L, O) {
      L.finishedWork = null, L.finishedLanes = T2;
      var _ = L.timeoutHandle;
      if (_ !== Hp)
        L.timeoutHandle = Hp, Ud0(_);
      if (dJ !== null) {
        var k = dJ.return;
        while (k !== null) {
          var y = k.alternate;
          S$0(y, k), k = k.return;
        }
      }
      UW = L;
      var d = AO(L.current, null);
      return dJ = d, CX = QN = Qc = O, kX = FF, ZT = null, Pk = T2, JT = T2, Ck = T2, $T = null, Q5 = null, hp0(), kG.discardPendingWarnings(), d;
    }
    function WX0(L, O) {
      do {
        var _ = dJ;
        try {
          if (cC(), PJ0(), aX(), $c.current = null, _ === null || _.return === null) {
            kX = tj, ZT = O, dJ = null;
            return;
          }
          if (G0 && _.mode & U7)
            Ak(_, !0);
          if (u)
            if (u4(), O !== null && typeof O === "object" && typeof O.then === "function") {
              var k = O;
              Ey0(_, k, CX);
            } else
              Ry0(_, O, CX);
          Hu0(L, _.return, _, O, CX), NX0(_);
        } catch (y) {
          if (O = y, dJ === _ && _ !== null)
            _ = _.return, dJ = _;
          else
            _ = dJ;
          continue;
        }
        return;
      } while (!0);
    }
    function KX0() {
      var L = Jc.current;
      if (Jc.current = Ek, L === null)
        return Ek;
      else
        return L;
    }
    function GX0(L) {
      Jc.current = L;
    }
    function lc0() {
      Wc = rX();
    }
    function KT(L) {
      Pk = BZ(L, Pk);
    }
    function nc0() {
      if (kX === FF)
        kX = Ik;
    }
    function Rc() {
      if (kX === FF || kX === Ik || kX === OO)
        kX = ej;
      if (UW !== null && (Pd(Pk) || Pd(JT)))
        KL(UW, CX);
    }
    function ic0(L) {
      if (kX !== ej)
        kX = OO;
      if ($T === null)
        $T = [L];
      else
        $T.push(L);
    }
    function oc0() {
      return kX === FF;
    }
    function xk(L, O) {
      var _ = K9;
      K9 |= tY;
      var k = KX0();
      if (UW !== L || CX !== O) {
        if (VG) {
          var y = L.memoizedUpdaters;
          if (y.size > 0)
            GT(L, CX), y.clear();
          y90(L, O);
        }
        UF = g90(), DO(L, O);
      }
      V90(O);
      do
        try {
          sc0();
          break;
        } catch (d) {
          WX0(L, d);
        }
      while (!0);
      if (cC(), K9 = _, GX0(k), dJ !== null)
        throw new Error("Cannot commit an incomplete root. This error is likely caused by a bug in React. Please file an issue.");
      return I90(), UW = null, CX = T2, kX;
    }
    function sc0() {
      while (dJ !== null)
        HX0(dJ);
    }
    function ac0(L, O) {
      var _ = K9;
      K9 |= tY;
      var k = KX0();
      if (UW !== L || CX !== O) {
        if (VG) {
          var y = L.memoizedUpdaters;
          if (y.size > 0)
            GT(L, CX), y.clear();
          y90(L, O);
        }
        UF = g90(), XT(), DO(L, O);
      }
      V90(O);
      do
        try {
          rc0();
          break;
        } catch (d) {
          WX0(L, d);
        }
      while (!0);
      if (cC(), GX0(k), K9 = _, dJ !== null)
        return Ay0(), FF;
      else
        return I90(), UW = null, CX = T2, kX;
    }
    function rc0() {
      while (dJ !== null && !sx0())
        HX0(dJ);
    }
    function HX0(L) {
      var O = L.alternate;
      mJ(L);
      var _;
      if ((L.mode & U7) !== N6)
        Ou(L), _ = Ec(O, L, QN), Ak(L, !0);
      else
        _ = Ec(O, L, QN);
      if (aX(), L.memoizedProps = L.pendingProps, _ === null)
        NX0(L);
      else
        dJ = _;
      $c.current = null;
    }
    function NX0(L) {
      var O = L;
      do {
        var { alternate: _, return: k } = O;
        if ((O.flags & cw) === M6) {
          mJ(O);
          var y = void 0;
          if ((O.mode & U7) === N6)
            y = v$0(_, O, QN);
          else
            Ou(O), y = v$0(_, O, QN), Ak(O, !1);
          if (aX(), y !== null) {
            dJ = y;
            return;
          }
        } else {
          var d = du0(_, O);
          if (d !== null) {
            d.flags &= ux0, dJ = d;
            return;
          }
          if ((O.mode & U7) !== N6) {
            Ak(O, !1);
            var { actualDuration: o, child: H0 } = O;
            while (H0 !== null)
              o += H0.actualDuration, H0 = H0.sibling;
            O.actualDuration = o;
          }
          if (k !== null)
            k.flags |= cw, k.subtreeFlags = M6, k.deletions = null;
          else {
            kX = Xc, dJ = null;
            return;
          }
        }
        var O0 = O.sibling;
        if (O0 !== null) {
          dJ = O0;
          return;
        }
        O = k, dJ = O;
      } while (O !== null);
      if (kX === FF)
        kX = r$0;
    }
    function MO(L, O, _) {
      var k = IG(), y = rY.transition;
      try {
        rY.transition = null, ZY(s5), tc0(L, O, _, k);
      } finally {
        rY.transition = y, ZY(k);
      }
      return null;
    }
    function tc0(L, O, _, k) {
      do
        RF();
      while (QL !== null);
      if (Hl0(), (K9 & (tY | oK)) !== PX)
        throw new Error("Should not already be working.");
      var { finishedWork: y, finishedLanes: d } = L;
      if (Gy0(d), y === null)
        return j90(), null;
      else if (d === T2)
        Y("root.finishedLanes should not be empty during a commit. This is a bug in React.");
      if (L.finishedWork = null, L.finishedLanes = T2, y === L.current)
        throw new Error("Cannot commit the same tree as before. This error is likely caused by a bug in React. Please file an issue.");
      L.callbackNode = null, L.callbackPriority = eX;
      var o = BZ(y.lanes, y.childLanes);
      if (gy0(L, o), L === UW)
        UW = null, dJ = null, CX = T2;
      if ((y.subtreeFlags & p4) !== M6 || (y.flags & p4) !== M6) {
        if (!zO)
          zO = !0, Hc = _, Dc(tE, function() {
            return RF(), null;
          });
      }
      var H0 = (y.subtreeFlags & (Xd | Yd | lw | p4)) !== M6, O0 = (y.flags & (Xd | Yd | lw | p4)) !== M6;
      if (H0 || O0) {
        var I0 = rY.transition;
        rY.transition = null;
        var g0 = IG();
        ZY(s5);
        var R1 = K9;
        K9 |= oK, $c.current = null;
        var U1 = nu0(L, y);
        Z$0(), Wc0(L, y, d), Wd0(L.containerInfo), L.current = y, Oy0(d), Kc0(y, L, d), zy0(), ax0(), K9 = R1, ZY(g0), rY.transition = I0;
      } else
        L.current = y, Z$0();
      var x1 = zO;
      if (zO)
        zO = !1, QL = L, YT = d;
      else
        wD = 0, Sk = null;
      if (o = L.pendingLanes, o === T2)
        BD = null;
      if (!x1)
        LX0(L.current, !1);
      if (Xy0(y.stateNode, k), VG)
        L.memoizedUpdaters.clear();
      if (kc0(), W5(L, rX()), O !== null) {
        var y1 = L.onRecoverableError;
        for (var r1 = 0;r1 < O.length; r1++) {
          var Q8 = O[r1], J6 = Q8.stack, b8 = Q8.digest;
          y1(Q8.value, {
            componentStack: J6,
            digest: b8
          });
        }
      }
      if (kk) {
        kk = !1;
        var oZ = Kc;
        throw Kc = null, oZ;
      }
      if (o5(YT, n6) && L.tag !== sU)
        RF();
      if (o = L.pendingLanes, o5(o, n6))
        if (tp0(), L === Nc)
          QT++;
        else
          QT = 0, Nc = L;
      else
        QT = 0;
      return aU(), j90(), null;
    }
    function RF() {
      if (QL !== null) {
        var L = m90(YT), O = uy0(YF, L), _ = rY.transition, k = IG();
        try {
          return rY.transition = null, ZY(O), Zl0();
        } finally {
          ZY(k), rY.transition = _;
        }
      }
      return !1;
    }
    function ec0(L) {
      if (Gc.push(L), !zO)
        zO = !0, Dc(tE, function() {
          return RF(), null;
        });
    }
    function Zl0() {
      if (QL === null)
        return !1;
      var L = Hc;
      Hc = null;
      var O = QL, _ = YT;
      if (QL = null, YT = T2, (K9 & (tY | oK)) !== PX)
        throw new Error("Cannot flush passive effects while already rendering.");
      qc = !0, vk = !1, Dy0(_);
      var k = K9;
      K9 |= oK, Lc0(O.current), Nc0(O, O.current, _, L);
      {
        var y = Gc;
        Gc = [];
        for (var d = 0;d < y.length; d++) {
          var o = y[d];
          au0(O, o);
        }
      }
      My0(), LX0(O.current, !0), K9 = k, aU();
      {
        if (vk)
          if (O === Sk)
            wD++;
          else
            wD = 0, Sk = O;
        else
          wD = 0;
        qc = !1, vk = !1;
      }
      Yy0(O);
      {
        var H0 = O.current.stateNode;
        H0.effectDuration = 0, H0.passiveEffectDuration = 0;
      }
      return !0;
    }
    function qX0(L) {
      return BD !== null && BD.has(L);
    }
    function Jl0(L) {
      if (BD === null)
        BD = /* @__PURE__ */ new Set([L]);
      else
        BD.add(L);
    }
    function $l0(L) {
      if (!kk)
        kk = !0, Kc = L;
    }
    var Xl0 = $l0;
    function FX0(L, O, _) {
      var k = RO(_, O), y = G$0(L, k, n6), d = tU(L, y, n6), o = LW();
      if (d !== null)
        ew(d, n6, o), W5(d, o);
    }
    function h7(L, O, _) {
      if (uu0(_), HT(!1), L.tag === H) {
        FX0(L, L, _);
        return;
      }
      var k = null;
      k = O;
      while (k !== null) {
        if (k.tag === H) {
          FX0(k, L, _);
          return;
        } else if (k.tag === K) {
          var { type: y, stateNode: d } = k;
          if (typeof y.getDerivedStateFromError === "function" || typeof d.componentDidCatch === "function" && !qX0(d)) {
            var o = RO(_, L), H0 = hu(k, o, n6), O0 = tU(k, H0, n6), I0 = LW();
            if (O0 !== null)
              ew(O0, n6, I0), W5(O0, I0);
            return;
          }
        }
        k = k.return;
      }
      Y(`Internal React error: Attempted to capture a commit phase error inside a detached tree. This indicates a bug in React. Likely causes include deleting the same fiber more than once, committing an already-finished tree, or an inconsistent return pointer.

Error message:

%s`, _);
    }
    function Yl0(L, O, _) {
      var k = L.pingCache;
      if (k !== null)
        k.delete(O);
      var y = LW();
      if (b90(L, _), Ul0(L), UW === L && i4(CX, _))
        if (kX === ej || kX === Ik && v90(CX) && rX() - Wc < t$0)
          DO(L, T2);
        else
          Ck = BZ(Ck, _);
      W5(L, y);
    }
    function UX0(L, O) {
      if (O === eX)
        O = yc0(L);
      var _ = LW(), k = X5(L, O);
      if (k !== null)
        ew(k, O, _), W5(k, _);
    }
    function Ql0(L) {
      var O = L.memoizedState, _ = eX;
      if (O !== null)
        _ = O.retryLane;
      UX0(L, _);
    }
    function Wl0(L, O) {
      var _ = eX, k;
      switch (L.tag) {
        case B:
          k = L.stateNode;
          var y = L.memoizedState;
          if (y !== null)
            _ = y.retryLane;
          break;
        case S:
          k = L.stateNode;
          break;
        default:
          throw new Error("Pinged unknown suspense boundary type. This is probably a bug in React.");
      }
      if (k !== null)
        k.delete(O);
      UX0(L, _);
    }
    function Kl0(L) {
      return L < 120 ? 120 : L < 480 ? 480 : L < 1080 ? 1080 : L < 1920 ? 1920 : L < 3000 ? 3000 : L < 4320 ? 4320 : fc0(L / 1960) * 1960;
    }
    function Gl0() {
      if (QT > bc0)
        throw QT = 0, Nc = null, new Error("Maximum update depth exceeded. This can happen when a component repeatedly calls setState inside componentWillUpdate or componentDidUpdate. React limits the number of nested updates to prevent infinite loops.");
      if (wD > xc0)
        wD = 0, Sk = null, Y("Maximum update depth exceeded. This can happen when a component calls setState inside useEffect, but useEffect either doesn't have a dependency array, or one of the dependencies changes on every render.");
    }
    function Hl0() {
      kG.flushLegacyContextWarning(), kG.flushPendingUnsafeLifecycleWarnings();
    }
    function LX0(L, O) {
      {
        if (mJ(L), yk(L, ZF, wc0), O)
          yk(L, oP, jc0);
        if (yk(L, ZF, Ac0), O)
          yk(L, oP, Bc0);
        aX();
      }
    }
    function yk(L, O, _) {
      {
        var k = L, y = null;
        while (k !== null) {
          var d = k.subtreeFlags & O;
          if (k !== y && k.child !== null && d !== M6)
            k = k.child;
          else {
            if ((k.flags & O) !== M6)
              _(k);
            if (k.sibling !== null)
              k = k.sibling;
            else
              k = y = k.return;
          }
        }
      }
    }
    var gk = null;
    function RX0(L) {
      {
        if ((K9 & tY) !== PX)
          return;
        if (!(L.mode & W9))
          return;
        var O = L.tag;
        if (O !== G && O !== H && O !== K && O !== W && O !== D && O !== T && O !== w)
          return;
        var _ = D6(L) || "ReactComponent";
        if (gk !== null) {
          if (gk.has(_))
            return;
          gk.add(_);
        } else
          gk = /* @__PURE__ */ new Set([_]);
        var k = sX;
        try {
          mJ(L), Y("Can't perform a React state update on a component that hasn't mounted yet. This indicates that you have a side-effect in your render function that asynchronously later calls tries to update the component. Move this work to useEffect instead.");
        } finally {
          if (k)
            mJ(L);
          else
            aX();
        }
      }
    }
    var Ec;
    {
      var Nl0 = null;
      Ec = function(L, O, _) {
        var k = wX0(Nl0, O);
        try {
          return V$0(L, O, _);
        } catch (d) {
          if (zp0() || d !== null && typeof d === "object" && typeof d.then === "function")
            throw d;
          if (cC(), PJ0(), S$0(L, O), wX0(O, k), O.mode & U7)
            Ou(O);
          if (rm(null, V$0, null, L, O, _), gx0()) {
            var y = tm();
            if (typeof y === "object" && y !== null && y._suppressLogging && typeof d === "object" && d !== null && !d._suppressLogging)
              d._suppressLogging = !0;
          }
          throw d;
        }
      };
    }
    var EX0 = !1, Oc;
    Oc = /* @__PURE__ */ new Set;
    function ql0(L) {
      if (nH && !sp0())
        switch (L.tag) {
          case W:
          case D:
          case w: {
            var O = dJ && D6(dJ) || "Unknown", _ = O;
            if (!Oc.has(_)) {
              Oc.add(_);
              var k = D6(L) || "Unknown";
              Y("Cannot update a component (`%s`) while rendering a different component (`%s`). To locate the bad setState() call inside `%s`, follow the stack trace as described in https://reactjs.org/link/setstate-in-render", k, O, O);
            }
            break;
          }
          case K: {
            if (!EX0)
              Y("Cannot update during an existing state transition (such as within `render`). Render methods should be a pure function of props and state."), EX0 = !0;
            break;
          }
        }
    }
    function GT(L, O) {
      if (VG) {
        var _ = L.memoizedUpdaters;
        _.forEach(function(k) {
          x90(L, k, O);
        });
      }
    }
    var zc = {};
    function Dc(L, O) {
      {
        var _ = gG.current;
        if (_ !== null)
          return _.push(O), zc;
        else
          return w90(L, O);
      }
    }
    function OX0(L) {
      if (L === zc)
        return;
      return ox0(L);
    }
    function zX0() {
      return gG.current !== null;
    }
    function Fl0(L) {
      {
        if (L.mode & W9) {
          if (!s$0())
            return;
        } else {
          if (!Sc0())
            return;
          if (K9 !== PX)
            return;
          if (L.tag !== W && L.tag !== D && L.tag !== w)
            return;
        }
        if (gG.current === null) {
          var O = sX;
          try {
            mJ(L), Y(`An update to %s inside a test was not wrapped in act(...).

When testing, code that causes React state updates should be wrapped into act(...):

act(() => {
  /* fire events that update state */
});
/* assert on the output */

This ensures that you're testing the behavior the user would see in the browser. Learn more at https://reactjs.org/link/wrap-tests-with-act`, D6(L));
          } finally {
            if (O)
              mJ(L);
            else
              aX();
          }
        }
      }
    }
    function Ul0(L) {
      if (L.tag !== sU && s$0() && gG.current === null)
        Y(`A suspended resource finished loading inside a test, but the event was not wrapped in act(...).

When testing, code that resolves suspended data should be wrapped into act(...):

act(() => {
  /* finish loading suspended data */
});
/* assert on the output */

This ensures that you're testing the behavior the user would see in the browser. Learn more at https://reactjs.org/link/wrap-tests-with-act`);
    }
    function HT(L) {
      JX0 = L;
    }
    var sK = null, jD = null, Ll0 = function(L) {
      sK = L;
    };
    function TD(L) {
      {
        if (sK === null)
          return L;
        var O = sK(L);
        if (O === void 0)
          return L;
        return O.current;
      }
    }
    function Mc(L) {
      return TD(L);
    }
    function Ac(L) {
      {
        if (sK === null)
          return L;
        var O = sK(L);
        if (O === void 0) {
          if (L !== null && L !== void 0 && typeof L.render === "function") {
            var _ = TD(L.render);
            if (L.render !== _) {
              var k = {
                $$typeof: M1,
                render: _
              };
              if (L.displayName !== void 0)
                k.displayName = L.displayName;
              return k;
            }
          }
          return L;
        }
        return O.current;
      }
    }
    function DX0(L, O) {
      {
        if (sK === null)
          return !1;
        var _ = L.elementType, k = O.type, y = !1, d = typeof k === "object" && k !== null ? k.$$typeof : null;
        switch (L.tag) {
          case K: {
            if (typeof k === "function")
              y = !0;
            break;
          }
          case W: {
            if (typeof k === "function")
              y = !0;
            else if (d === I1)
              y = !0;
            break;
          }
          case D: {
            if (d === M1)
              y = !0;
            else if (d === I1)
              y = !0;
            break;
          }
          case T:
          case w: {
            if (d === d8)
              y = !0;
            else if (d === I1)
              y = !0;
            break;
          }
          default:
            return !1;
        }
        if (y) {
          var o = sK(_);
          if (o !== void 0 && o === sK(k))
            return !0;
        }
        return !1;
      }
    }
    function MX0(L) {
      {
        if (sK === null)
          return;
        if (typeof WeakSet !== "function")
          return;
        if (jD === null)
          jD = /* @__PURE__ */ new WeakSet;
        jD.add(L);
      }
    }
    var Rl0 = function(L, O) {
      {
        if (sK === null)
          return;
        var { staleFamilies: _, updatedFamilies: k } = O;
        RF(), LF(function() {
          Bc(L.current, k, _);
        });
      }
    }, El0 = function(L, O) {
      {
        if (L.context !== t5)
          return;
        RF(), LF(function() {
          NT(O, L, null, null);
        });
      }
    };
    function Bc(L, O, _) {
      {
        var { alternate: k, child: y, sibling: d, tag: o, type: H0 } = L, O0 = null;
        switch (o) {
          case W:
          case w:
          case K:
            O0 = H0;
            break;
          case D:
            O0 = H0.render;
            break;
        }
        if (sK === null)
          throw new Error("Expected resolveFamily to be set during hot reload.");
        var I0 = !1, g0 = !1;
        if (O0 !== null) {
          var R1 = sK(O0);
          if (R1 !== void 0) {
            if (_.has(R1))
              g0 = !0;
            else if (O.has(R1))
              if (o === K)
                g0 = !0;
              else
                I0 = !0;
          }
        }
        if (jD !== null) {
          if (jD.has(L) || k !== null && jD.has(k))
            g0 = !0;
        }
        if (g0)
          L._debugNeedsRemount = !0;
        if (g0 || I0) {
          var U1 = X5(L, n6);
          if (U1 !== null)
            vX(U1, L, n6, s7);
        }
        if (y !== null && !g0)
          Bc(y, O, _);
        if (d !== null)
          Bc(d, O, _);
      }
    }
    var Ol0 = function(L, O) {
      {
        var _ = /* @__PURE__ */ new Set, k = new Set(O.map(function(y) {
          return y.current;
        }));
        return wc(L.current, k, _), _;
      }
    };
    function wc(L, O, _) {
      {
        var { child: k, sibling: y, tag: d, type: o } = L, H0 = null;
        switch (d) {
          case W:
          case w:
          case K:
            H0 = o;
            break;
          case D:
            H0 = o.render;
            break;
        }
        var O0 = !1;
        if (H0 !== null) {
          if (O.has(H0))
            O0 = !0;
        }
        if (O0)
          zl0(L, _);
        else if (k !== null)
          wc(k, O, _);
        if (y !== null)
          wc(y, O, _);
      }
    }
    function zl0(L, O) {
      {
        var _ = Dl0(L, O);
        if (_)
          return;
        var k = L;
        while (!0) {
          switch (k.tag) {
            case q:
              O.add(k.stateNode);
              return;
            case N:
              O.add(k.stateNode.containerInfo);
              return;
            case H:
              O.add(k.stateNode.containerInfo);
              return;
          }
          if (k.return === null)
            throw new Error("Expected to reach root first.");
          k = k.return;
        }
      }
    }
    function Dl0(L, O) {
      {
        var _ = L, k = !1;
        while (!0) {
          if (_.tag === q)
            k = !0, O.add(_.stateNode);
          else if (_.child !== null) {
            _.child.return = _, _ = _.child;
            continue;
          }
          if (_ === L)
            return k;
          while (_.sibling === null) {
            if (_.return === null || _.return === L)
              return k;
            _ = _.return;
          }
          _.sibling.return = _.return, _ = _.sibling;
        }
      }
      return !1;
    }
    var jc;
    {
      jc = !1;
      try {
        var AX0 = Object.preventExtensions({});
        ;
      } catch (L) {
        jc = !0;
      }
    }
    function Ml0(L, O, _, k) {
      if (this.tag = L, this.key = _, this.elementType = null, this.type = null, this.stateNode = null, this.return = null, this.child = null, this.sibling = null, this.index = 0, this.ref = null, this.pendingProps = O, this.memoizedProps = null, this.updateQueue = null, this.memoizedState = null, this.dependencies = null, this.mode = k, this.flags = M6, this.subtreeFlags = M6, this.deletions = null, this.lanes = T2, this.childLanes = T2, this.alternate = null, this.actualDuration = Number.NaN, this.actualStartTime = Number.NaN, this.selfBaseDuration = Number.NaN, this.treeBaseDuration = Number.NaN, this.actualDuration = 0, this.actualStartTime = -1, this.selfBaseDuration = 0, this.treeBaseDuration = 0, this._debugSource = null, this._debugOwner = null, this._debugNeedsRemount = !1, this._debugHookTypes = null, !jc && typeof Object.preventExtensions === "function")
        Object.preventExtensions(this);
    }
    var e5 = function(L, O, _, k) {
      return new Ml0(L, O, _, k);
    };
    function Tc(L) {
      var O = L.prototype;
      return !!(O && O.isReactComponent);
    }
    function Al0(L) {
      return typeof L === "function" && !Tc(L) && L.defaultProps === void 0;
    }
    function Bl0(L) {
      if (typeof L === "function")
        return Tc(L) ? K : W;
      else if (L !== void 0 && L !== null) {
        var O = L.$$typeof;
        if (O === M1)
          return D;
        if (O === d8)
          return T;
      }
      return G;
    }
    function AO(L, O) {
      var _ = L.alternate;
      if (_ === null)
        _ = e5(L.tag, O, L.key, L.mode), _.elementType = L.elementType, _.type = L.type, _.stateNode = L.stateNode, _._debugSource = L._debugSource, _._debugOwner = L._debugOwner, _._debugHookTypes = L._debugHookTypes, _.alternate = L, L.alternate = _;
      else
        _.pendingProps = O, _.type = L.type, _.flags = M6, _.subtreeFlags = M6, _.deletions = null, _.actualDuration = 0, _.actualStartTime = -1;
      _.flags = L.flags & JF, _.childLanes = L.childLanes, _.lanes = L.lanes, _.child = L.child, _.memoizedProps = L.memoizedProps, _.memoizedState = L.memoizedState, _.updateQueue = L.updateQueue;
      var k = L.dependencies;
      switch (_.dependencies = k === null ? null : {
        lanes: k.lanes,
        firstContext: k.firstContext
      }, _.sibling = L.sibling, _.index = L.index, _.ref = L.ref, _.selfBaseDuration = L.selfBaseDuration, _.treeBaseDuration = L.treeBaseDuration, _._debugNeedsRemount = L._debugNeedsRemount, _.tag) {
        case G:
        case W:
        case w:
          _.type = TD(L.type);
          break;
        case K:
          _.type = Mc(L.type);
          break;
        case D:
          _.type = Ac(L.type);
          break;
      }
      return _;
    }
    function wl0(L, O) {
      L.flags &= JF | u$;
      var _ = L.alternate;
      if (_ === null)
        L.childLanes = T2, L.lanes = O, L.child = null, L.subtreeFlags = M6, L.memoizedProps = null, L.memoizedState = null, L.updateQueue = null, L.dependencies = null, L.stateNode = null, L.selfBaseDuration = 0, L.treeBaseDuration = 0;
      else {
        L.childLanes = _.childLanes, L.lanes = _.lanes, L.child = _.child, L.subtreeFlags = M6, L.deletions = null, L.memoizedProps = _.memoizedProps, L.memoizedState = _.memoizedState, L.updateQueue = _.updateQueue, L.type = _.type;
        var k = _.dependencies;
        L.dependencies = k === null ? null : {
          lanes: k.lanes,
          firstContext: k.firstContext
        }, L.selfBaseDuration = _.selfBaseDuration, L.treeBaseDuration = _.treeBaseDuration;
      }
      return L;
    }
    function jl0(L, O, _) {
      var k;
      if (L === fC) {
        if (k = W9, O === !0)
          k |= Y$, k |= sH;
      } else
        k = N6;
      if (VG)
        k |= U7;
      return e5(H, null, null, k);
    }
    function _c(L, O, _, k, y, d) {
      var o = G, H0 = L;
      if (typeof L === "function")
        if (Tc(L))
          o = K, H0 = Mc(H0);
        else
          H0 = TD(H0);
      else if (typeof L === "string")
        o = q;
      else
        Z:
          switch (L) {
            case z1:
              return GL(_.children, y, d, O);
            case J2:
              if (o = E, y |= Y$, (y & W9) !== N6)
                y |= sH;
              break;
            case N2:
              return Tl0(_, y, d, O);
            case g1:
              return _l0(_, y, d, O);
            case l2:
              return Vl0(_, y, d, O);
            case p8:
              return BX0(_, y, d, O);
            case W6:
            case W2:
            case v6:
            case AZ:
            case z2:
            default: {
              if (typeof L === "object" && L !== null)
                switch (L.$$typeof) {
                  case X8:
                    o = z;
                    break Z;
                  case c0:
                    o = R;
                    break Z;
                  case M1:
                    o = D, H0 = Ac(H0);
                    break Z;
                  case d8:
                    o = T;
                    break Z;
                  case I1:
                    o = V, H0 = null;
                    break Z;
                }
              var O0 = "";
              {
                if (L === void 0 || typeof L === "object" && L !== null && Object.keys(L).length === 0)
                  O0 += " You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.";
                var I0 = k ? D6(k) : null;
                if (I0)
                  O0 += `

Check the render method of \`` + I0 + "`.";
              }
              throw new Error("Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) " + ("but got: " + (L == null ? L : typeof L) + "." + O0));
            }
          }
      var g0 = e5(o, _, O, y);
      return g0.elementType = L, g0.type = H0, g0.lanes = d, g0._debugOwner = k, g0;
    }
    function Vc(L, O, _) {
      var k = null;
      k = L._owner;
      var { type: y, key: d, props: o } = L, H0 = _c(y, d, o, k, O, _);
      return H0._debugSource = L._source, H0._debugOwner = L._owner, H0;
    }
    function GL(L, O, _, k) {
      var y = e5(F, L, k, O);
      return y.lanes = _, y;
    }
    function Tl0(L, O, _, k) {
      if (typeof L.id !== "string")
        Y('Profiler must specify an "id" of type `string` as a prop. Received the type `%s` instead.', typeof L.id);
      var y = e5(A, L, k, O | U7);
      return y.elementType = N2, y.lanes = _, y.stateNode = {
        effectDuration: 0,
        passiveEffectDuration: 0
      }, y;
    }
    function _l0(L, O, _, k) {
      var y = e5(B, L, k, O);
      return y.elementType = g1, y.lanes = _, y;
    }
    function Vl0(L, O, _, k) {
      var y = e5(S, L, k, O);
      return y.elementType = l2, y.lanes = _, y;
    }
    function BX0(L, O, _, k) {
      var y = e5(v, L, k, O);
      y.elementType = p8, y.lanes = _;
      var d = {
        isHidden: !1
      };
      return y.stateNode = d, y;
    }
    function Ic(L, O, _) {
      var k = e5(U, L, null, O);
      return k.lanes = _, k;
    }
    function Il0() {
      var L = e5(q, null, null, N6);
      return L.elementType = "DELETED", L;
    }
    function Pl0(L) {
      var O = e5(I, null, null, N6);
      return O.stateNode = L, O;
    }
    function Pc(L, O, _) {
      var k = L.children !== null ? L.children : [], y = e5(N, k, L.key, O);
      return y.lanes = _, y.stateNode = {
        containerInfo: L.containerInfo,
        pendingChildren: null,
        implementation: L.implementation
      }, y;
    }
    function wX0(L, O) {
      if (L === null)
        L = e5(G, null, null, N6);
      return L.tag = O.tag, L.key = O.key, L.elementType = O.elementType, L.type = O.type, L.stateNode = O.stateNode, L.return = O.return, L.child = O.child, L.sibling = O.sibling, L.index = O.index, L.ref = O.ref, L.pendingProps = O.pendingProps, L.memoizedProps = O.memoizedProps, L.updateQueue = O.updateQueue, L.memoizedState = O.memoizedState, L.dependencies = O.dependencies, L.mode = O.mode, L.flags = O.flags, L.subtreeFlags = O.subtreeFlags, L.deletions = O.deletions, L.lanes = O.lanes, L.childLanes = O.childLanes, L.alternate = O.alternate, L.actualDuration = O.actualDuration, L.actualStartTime = O.actualStartTime, L.selfBaseDuration = O.selfBaseDuration, L.treeBaseDuration = O.treeBaseDuration, L._debugSource = O._debugSource, L._debugOwner = O._debugOwner, L._debugNeedsRemount = O._debugNeedsRemount, L._debugHookTypes = O._debugHookTypes, L;
    }
    function Cl0(L, O, _, k, y) {
      this.tag = O, this.containerInfo = L, this.pendingChildren = null, this.current = null, this.pingCache = null, this.finishedWork = null, this.timeoutHandle = Hp, this.context = null, this.pendingContext = null, this.callbackNode = null, this.callbackPriority = eX, this.eventTimes = kd(T2), this.expirationTimes = kd(s7), this.pendingLanes = T2, this.suspendedLanes = T2, this.pingedLanes = T2, this.expiredLanes = T2, this.mutableReadLanes = T2, this.finishedLanes = T2, this.entangledLanes = T2, this.entanglements = kd(T2), this.identifierPrefix = k, this.onRecoverableError = y, this.mutableSourceEagerHydrationData = null, this.effectDuration = 0, this.passiveEffectDuration = 0;
      {
        this.memoizedUpdaters = /* @__PURE__ */ new Set;
        var d = this.pendingUpdatersLaneMap = [];
        for (var o = 0;o < Gd; o++)
          d.push(/* @__PURE__ */ new Set);
      }
      switch (O) {
        case fC:
          this._debugRootType = _ ? "hydrateRoot()" : "createRoot()";
          break;
        case sU:
          this._debugRootType = _ ? "hydrate()" : "render()";
          break;
      }
    }
    function jX0(L, O, _, k, y, d, o, H0, O0, I0) {
      var g0 = new Cl0(L, O, _, H0, O0), R1 = jl0(O, d);
      g0.current = R1, R1.stateNode = g0;
      {
        var U1 = {
          element: k,
          isDehydrated: _,
          cache: null,
          transitions: null,
          pendingSuspenseBoundaries: null
        };
        R1.memoizedState = U1;
      }
      return mp(R1), g0;
    }
    var Cc = "18.3.1";
    function kl0(L, O, _) {
      var k = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : null;
      return N0(k), {
        $$typeof: l0,
        key: k == null ? null : "" + k,
        children: L,
        containerInfo: O,
        implementation: _
      };
    }
    var kc, vc;
    kc = !1, vc = {};
    function TX0(L) {
      if (!L)
        return t5;
      var O = m4(L), _ = Hp0(O);
      if (O.tag === K) {
        var k = O.type;
        if (tH(k))
          return r70(O, k, _);
      }
      return _;
    }
    function vl0(L, O) {
      {
        var _ = m4(L);
        if (_ === void 0)
          if (typeof L.render === "function")
            throw new Error("Unable to find node on an unmounted component.");
          else {
            var k = Object.keys(L).join(",");
            throw new Error("Argument appears to not be a ReactComponent. Keys: " + k);
          }
        var y = M90(_);
        if (y === null)
          return null;
        if (y.mode & Y$) {
          var d = D6(_) || "Component";
          if (!vc[d]) {
            vc[d] = !0;
            var o = sX;
            try {
              if (mJ(y), _.mode & Y$)
                Y("%s is deprecated in StrictMode. %s was passed an instance of %s which is inside StrictMode. Instead, add a ref directly to the element you want to reference. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-find-node", O, O, d);
              else
                Y("%s is deprecated in StrictMode. %s was passed an instance of %s which renders StrictMode children. Instead, add a ref directly to the element you want to reference. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-find-node", O, O, d);
            } finally {
              if (o)
                mJ(o);
              else
                aX();
            }
          }
        }
        return y.stateNode;
      }
    }
    function _X0(L, O, _, k, y, d, o, H0) {
      var O0 = !1, I0 = null;
      return jX0(L, O, O0, I0, _, k, y, d, o);
    }
    function VX0(L, O, _, k, y, d, o, H0, O0, I0) {
      var g0 = !0, R1 = jX0(_, k, g0, L, y, d, o, H0, O0);
      R1.context = TX0(null);
      var U1 = R1.current, x1 = LW(), y1 = WL(U1), r1 = NF(x1, y1);
      return r1.callback = O !== void 0 && O !== null ? O : null, tU(U1, r1, y1), gc0(R1, y1, x1), R1;
    }
    function NT(L, O, _, k) {
      $y0(O, L);
      var y = O.current, d = LW(), o = WL(y);
      By0(o);
      var H0 = TX0(_);
      if (O.context === null)
        O.context = H0;
      else
        O.pendingContext = H0;
      if (nH && sX !== null && !kc)
        kc = !0, Y(`Render methods should be a pure function of props and state; triggering nested component updates from render is not allowed. If necessary, trigger nested updates in componentDidUpdate.

Check the render method of %s.`, D6(sX) || "Unknown");
      var O0 = NF(d, o);
      if (O0.payload = {
        element: L
      }, k = k === void 0 ? null : k, k !== null) {
        if (typeof k !== "function")
          Y("render(...): Expected the last optional `callback` argument to be a function. Instead received: %s.", k);
        O0.callback = k;
      }
      var I0 = tU(y, O0, o);
      if (I0 !== null)
        vX(I0, y, o, d), sC(I0, y, o);
      return o;
    }
    function mk(L) {
      var O = L.current;
      if (!O.child)
        return null;
      switch (O.child.tag) {
        case q:
          return Wp(O.child.stateNode);
        default:
          return O.child.stateNode;
      }
    }
    function Sl0(L) {
      switch (L.tag) {
        case H: {
          var O = L.stateNode;
          if (YC(O)) {
            var _ = ky0(O);
            uc0(O, _);
          }
          break;
        }
        case B: {
          LF(function() {
            var y = X5(L, n6);
            if (y !== null) {
              var d = LW();
              vX(y, L, n6, d);
            }
          });
          var k = n6;
          Sc(L, k);
          break;
        }
      }
    }
    function IX0(L, O) {
      var _ = L.memoizedState;
      if (_ !== null && _.dehydrated !== null)
        _.retryLane = xy0(_.retryLane, O);
    }
    function Sc(L, O) {
      IX0(L, O);
      var _ = L.alternate;
      if (_)
        IX0(_, O);
    }
    function fl0(L) {
      if (L.tag !== B)
        return;
      var O = sw, _ = X5(L, O);
      if (_ !== null) {
        var k = LW();
        vX(_, L, O, k);
      }
      Sc(L, O);
    }
    function hl0(L) {
      if (L.tag !== B)
        return;
      var O = WL(L), _ = X5(L, O);
      if (_ !== null) {
        var k = LW();
        vX(_, L, O, k);
      }
      Sc(L, O);
    }
    function PX0(L) {
      var O = ix0(L);
      if (O === null)
        return null;
      return O.stateNode;
    }
    var CX0 = function(L) {
      return null;
    };
    function bl0(L) {
      return CX0(L);
    }
    var kX0 = function(L) {
      return !1;
    };
    function xl0(L) {
      return kX0(L);
    }
    var vX0 = null, SX0 = null, fX0 = null, hX0 = null, bX0 = null, xX0 = null, yX0 = null, gX0 = null, mX0 = null;
    {
      var dX0 = function(L, O, _) {
        var k = O[_], y = b9(L) ? L.slice() : d0({}, L);
        if (_ + 1 === O.length) {
          if (b9(y))
            y.splice(k, 1);
          else
            delete y[k];
          return y;
        }
        return y[k] = dX0(L[k], O, _ + 1), y;
      }, pX0 = function(L, O) {
        return dX0(L, O, 0);
      }, uX0 = function(L, O, _, k) {
        var y = O[k], d = b9(L) ? L.slice() : d0({}, L);
        if (k + 1 === O.length) {
          var o = _[k];
          if (d[o] = d[y], b9(d))
            d.splice(y, 1);
          else
            delete d[y];
        } else
          d[y] = uX0(L[y], O, _, k + 1);
        return d;
      }, cX0 = function(L, O, _) {
        if (O.length !== _.length) {
          X("copyWithRename() expects paths of the same length");
          return;
        } else
          for (var k = 0;k < _.length - 1; k++)
            if (O[k] !== _[k]) {
              X("copyWithRename() expects paths to be the same except for the deepest key");
              return;
            }
        return uX0(L, O, _, 0);
      }, lX0 = function(L, O, _, k) {
        if (_ >= O.length)
          return k;
        var y = O[_], d = b9(L) ? L.slice() : d0({}, L);
        return d[y] = lX0(L[y], O, _ + 1, k), d;
      }, nX0 = function(L, O, _) {
        return lX0(L, O, 0, _);
      }, fc = function(L, O) {
        var _ = L.memoizedState;
        while (_ !== null && O > 0)
          _ = _.next, O--;
        return _;
      };
      vX0 = function(L, O, _, k) {
        var y = fc(L, O);
        if (y !== null) {
          var d = nX0(y.memoizedState, _, k);
          y.memoizedState = d, y.baseState = d, L.memoizedProps = d0({}, L.memoizedProps);
          var o = X5(L, n6);
          if (o !== null)
            vX(o, L, n6, s7);
        }
      }, SX0 = function(L, O, _) {
        var k = fc(L, O);
        if (k !== null) {
          var y = pX0(k.memoizedState, _);
          k.memoizedState = y, k.baseState = y, L.memoizedProps = d0({}, L.memoizedProps);
          var d = X5(L, n6);
          if (d !== null)
            vX(d, L, n6, s7);
        }
      }, fX0 = function(L, O, _, k) {
        var y = fc(L, O);
        if (y !== null) {
          var d = cX0(y.memoizedState, _, k);
          y.memoizedState = d, y.baseState = d, L.memoizedProps = d0({}, L.memoizedProps);
          var o = X5(L, n6);
          if (o !== null)
            vX(o, L, n6, s7);
        }
      }, hX0 = function(L, O, _) {
        if (L.pendingProps = nX0(L.memoizedProps, O, _), L.alternate)
          L.alternate.pendingProps = L.pendingProps;
        var k = X5(L, n6);
        if (k !== null)
          vX(k, L, n6, s7);
      }, bX0 = function(L, O) {
        if (L.pendingProps = pX0(L.memoizedProps, O), L.alternate)
          L.alternate.pendingProps = L.pendingProps;
        var _ = X5(L, n6);
        if (_ !== null)
          vX(_, L, n6, s7);
      }, xX0 = function(L, O, _) {
        if (L.pendingProps = cX0(L.memoizedProps, O, _), L.alternate)
          L.alternate.pendingProps = L.pendingProps;
        var k = X5(L, n6);
        if (k !== null)
          vX(k, L, n6, s7);
      }, yX0 = function(L) {
        var O = X5(L, n6);
        if (O !== null)
          vX(O, L, n6, s7);
      }, gX0 = function(L) {
        CX0 = L;
      }, mX0 = function(L) {
        kX0 = L;
      };
    }
    function yl0(L) {
      var O = M90(L);
      if (O === null)
        return null;
      return O.stateNode;
    }
    function gl0(L) {
      return null;
    }
    function ml0() {
      return sX;
    }
    function dl0(L) {
      var O = L.findFiberByHostInstance, _ = Z.ReactCurrentDispatcher;
      return Jy0({
        bundleType: L.bundleType,
        version: L.version,
        rendererPackageName: L.rendererPackageName,
        rendererConfig: L.rendererConfig,
        overrideHookState: vX0,
        overrideHookStateDeletePath: SX0,
        overrideHookStateRenamePath: fX0,
        overrideProps: hX0,
        overridePropsDeletePath: bX0,
        overridePropsRenamePath: xX0,
        setErrorHandler: gX0,
        setSuspenseHandler: mX0,
        scheduleUpdate: yX0,
        currentDispatcherRef: _,
        findHostInstanceByFiber: yl0,
        findFiberByHostInstance: O || gl0,
        findHostInstancesForRefresh: Ol0,
        scheduleRefresh: Rl0,
        scheduleRoot: El0,
        setRefreshHandler: Ll0,
        getCurrentFiber: ml0,
        reconcilerVersion: Cc
      });
    }
    var iX0 = typeof reportError === "function" ? reportError : function(L) {
      console.error(L);
    };
    function hc(L) {
      this._internalRoot = L;
    }
    dk.prototype.render = hc.prototype.render = function(L) {
      var O = this._internalRoot;
      if (O === null)
        throw new Error("Cannot update an unmounted root.");
      {
        if (typeof arguments[1] === "function")
          Y("render(...): does not support the second callback argument. To execute a side effect after rendering, declare it in a component body with useEffect().");
        else if (pk(arguments[1]))
          Y("You passed a container to the second argument of root.render(...). You don't need to pass it again since you already passed it to create the root.");
        else if (typeof arguments[1] !== "undefined")
          Y("You passed a second argument to root.render(...) but it only accepts one argument.");
        var _ = O.containerInfo;
        if (_.nodeType !== p$) {
          var k = PX0(O.current);
          if (k) {
            if (k.parentNode !== _)
              Y("render(...): It looks like the React-rendered content of the root container was removed without using React. This is not supported and will cause errors. Instead, call root.unmount() to empty a root's container.");
          }
        }
      }
      NT(L, O, null, null);
    }, dk.prototype.unmount = hc.prototype.unmount = function() {
      if (typeof arguments[0] === "function")
        Y("unmount(...): does not support a callback argument. To execute a side effect after rendering, declare it in a component body with useEffect().");
      var L = this._internalRoot;
      if (L !== null) {
        this._internalRoot = null;
        var O = L.containerInfo;
        if (QX0())
          Y("Attempted to synchronously unmount a root while React was already rendering. React cannot finish unmounting the root until the current render has completed, which may lead to a race condition.");
        LF(function() {
          NT(null, L, null, null);
        }), l70(O);
      }
    };
    function pl0(L, O) {
      if (!pk(L))
        throw new Error("createRoot(...): Target container is not a DOM element.");
      oX0(L);
      var _ = !1, k = !1, y = "", d = iX0, o = null;
      if (O !== null && O !== void 0) {
        if (O.hydrate)
          X("hydrate through createRoot is deprecated. Use ReactDOMClient.hydrateRoot(container, <App />) instead.");
        else if (typeof O === "object" && O !== null && O.$$typeof === P0)
          Y(`You passed a JSX element to createRoot. You probably meant to call root.render instead. Example usage:

  let root = createRoot(domContainer);
  root.render(<App />);`);
        if (O.unstable_strictMode === !0)
          _ = !0;
        if (O.identifierPrefix !== void 0)
          y = O.identifierPrefix;
        if (O.onRecoverableError !== void 0)
          d = O.onRecoverableError;
        if (O.transitionCallbacks !== void 0)
          o = O.transitionCallbacks;
      }
      var H0 = _X0(L, fC, null, _, k, y, d);
      VC(H0.current, L);
      var O0 = L.nodeType === p$ ? L.parentNode : L;
      return Ej(O0), new hc(H0);
    }
    function dk(L) {
      this._internalRoot = L;
    }
    function ul0(L) {
      if (L)
        Zg0(L);
    }
    dk.prototype.unstable_scheduleHydration = ul0;
    function cl0(L, O, _) {
      if (!pk(L))
        throw new Error("hydrateRoot(...): Target container is not a DOM element.");
      if (oX0(L), O === void 0)
        Y("Must provide initial children as second argument to hydrateRoot. Example usage: hydrateRoot(domContainer, <App />)");
      var k = _ != null ? _ : null, y = _ != null && _.hydratedSources || null, d = !1, o = !1, H0 = "", O0 = iX0;
      if (_ !== null && _ !== void 0) {
        if (_.unstable_strictMode === !0)
          d = !0;
        if (_.identifierPrefix !== void 0)
          H0 = _.identifierPrefix;
        if (_.onRecoverableError !== void 0)
          O0 = _.onRecoverableError;
      }
      var I0 = VX0(O, null, L, fC, k, d, o, H0, O0);
      if (VC(I0.current, L), Ej(L), y)
        for (var g0 = 0;g0 < y.length; g0++) {
          var R1 = y[g0];
          cp0(I0, R1);
        }
      return new dk(I0);
    }
    function pk(L) {
      return !!(L && (L.nodeType === J5 || L.nodeType === rq || L.nodeType === mm || !c));
    }
    function qT(L) {
      return !!(L && (L.nodeType === J5 || L.nodeType === rq || L.nodeType === mm || L.nodeType === p$ && L.nodeValue === " react-mount-point-unstable "));
    }
    function oX0(L) {
      {
        if (L.nodeType === J5 && L.tagName && L.tagName.toUpperCase() === "BODY")
          Y("createRoot(): Creating roots directly with document.body is discouraged, since its children are often manipulated by third-party scripts and browser extensions. This may lead to subtle reconciliation issues. Try using a container element created for your app.");
        if (Vj(L))
          if (L._reactRootContainer)
            Y("You are calling ReactDOMClient.createRoot() on a container that was previously passed to ReactDOM.render(). This is not supported.");
          else
            Y("You are calling ReactDOMClient.createRoot() on a container that has already been passed to createRoot() before. Instead, call root.render() on the existing root instead if you want to update it.");
      }
    }
    var ll0 = Z.ReactCurrentOwner, sX0;
    sX0 = function(L) {
      if (L._reactRootContainer && L.nodeType !== p$) {
        var O = PX0(L._reactRootContainer.current);
        if (O) {
          if (O.parentNode !== L)
            Y("render(...): It looks like the React-rendered content of this container was removed without using React. This is not supported and will cause errors. Instead, call ReactDOM.unmountComponentAtNode to empty a container.");
        }
      }
      var _ = !!L._reactRootContainer, k = bc(L), y = !!(k && iU(k));
      if (y && !_)
        Y("render(...): Replacing React-rendered children with a new root component. If you intended to update the children of this node, you should instead have the existing children update their state and render the new components instead of calling ReactDOM.render.");
      if (L.nodeType === J5 && L.tagName && L.tagName.toUpperCase() === "BODY")
        Y("render(): Rendering components directly into document.body is discouraged, since its children are often manipulated by third-party scripts and browser extensions. This may lead to subtle reconciliation issues. Try rendering into a container element created for your app.");
    };
    function bc(L) {
      if (!L)
        return null;
      if (L.nodeType === rq)
        return L.documentElement;
      else
        return L.firstChild;
    }
    function aX0() {}
    function nl0(L, O, _, k, y) {
      if (y) {
        if (typeof k === "function") {
          var d = k;
          k = function() {
            var U1 = mk(o);
            d.call(U1);
          };
        }
        var o = VX0(O, k, L, sU, null, !1, !1, "", aX0);
        L._reactRootContainer = o, VC(o.current, L);
        var H0 = L.nodeType === p$ ? L.parentNode : L;
        return Ej(H0), LF(), o;
      } else {
        var O0;
        while (O0 = L.lastChild)
          L.removeChild(O0);
        if (typeof k === "function") {
          var I0 = k;
          k = function() {
            var U1 = mk(g0);
            I0.call(U1);
          };
        }
        var g0 = _X0(L, sU, null, !1, !1, "", aX0);
        L._reactRootContainer = g0, VC(g0.current, L);
        var R1 = L.nodeType === p$ ? L.parentNode : L;
        return Ej(R1), LF(function() {
          NT(O, g0, _, k);
        }), g0;
      }
    }
    function il0(L, O) {
      if (L !== null && typeof L !== "function")
        Y("%s(...): Expected the last optional `callback` argument to be a function. Instead received: %s.", O, L);
    }
    function uk(L, O, _, k, y) {
      sX0(_), il0(y === void 0 ? null : y, "render");
      var d = _._reactRootContainer, o;
      if (!d)
        o = nl0(_, O, L, y, k);
      else {
        if (o = d, typeof y === "function") {
          var H0 = y;
          y = function() {
            var O0 = mk(o);
            H0.call(O0);
          };
        }
        NT(O, o, L, y);
      }
      return mk(o);
    }
    var rX0 = !1;
    function ol0(L) {
      {
        if (!rX0)
          rX0 = !0, Y("findDOMNode is deprecated and will be removed in the next major release. Instead, add a ref directly to the element you want to reference. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-find-node");
        var O = ll0.current;
        if (O !== null && O.stateNode !== null) {
          var _ = O.stateNode._warnedAboutRefsInRender;
          if (!_)
            Y("%s is accessing findDOMNode inside its render(). render() should be a pure function of props and state. It should never access something that requires stale data from the previous render, such as refs. Move this logic to componentDidMount and componentDidUpdate instead.", y6(O.type) || "A component");
          O.stateNode._warnedAboutRefsInRender = !0;
        }
      }
      if (L == null)
        return null;
      if (L.nodeType === J5)
        return L;
      return vl0(L, "findDOMNode");
    }
    function sl0(L, O, _) {
      if (Y("ReactDOM.hydrate is no longer supported in React 18. Use hydrateRoot instead. Until you switch to the new API, your app will behave as if it's running React 17. Learn more: https://reactjs.org/link/switch-to-createroot"), !qT(O))
        throw new Error("Target container is not a DOM element.");
      {
        var k = Vj(O) && O._reactRootContainer === void 0;
        if (k)
          Y("You are calling ReactDOM.hydrate() on a container that was previously passed to ReactDOMClient.createRoot(). This is not supported. Did you mean to call hydrateRoot(container, element)?");
      }
      return uk(null, L, O, !0, _);
    }
    function al0(L, O, _) {
      if (Y("ReactDOM.render is no longer supported in React 18. Use createRoot instead. Until you switch to the new API, your app will behave as if it's running React 17. Learn more: https://reactjs.org/link/switch-to-createroot"), !qT(O))
        throw new Error("Target container is not a DOM element.");
      {
        var k = Vj(O) && O._reactRootContainer === void 0;
        if (k)
          Y("You are calling ReactDOM.render() on a container that was previously passed to ReactDOMClient.createRoot(). This is not supported. Did you mean to call root.render(element)?");
      }
      return uk(null, L, O, !1, _);
    }
    function rl0(L, O, _, k) {
      if (Y("ReactDOM.unstable_renderSubtreeIntoContainer() is no longer supported in React 18. Consider using a portal instead. Until you switch to the createRoot API, your app will behave as if it's running React 17. Learn more: https://reactjs.org/link/switch-to-createroot"), !qT(_))
        throw new Error("Target container is not a DOM element.");
      if (L == null || !mx0(L))
        throw new Error("parentComponent must be a valid React Component");
      return uk(L, O, _, !1, k);
    }
    var tX0 = !1;
    function tl0(L) {
      if (!tX0)
        tX0 = !0, Y("unmountComponentAtNode is deprecated and will be removed in the next major release. Switch to the createRoot API. Learn more: https://reactjs.org/link/switch-to-createroot");
      if (!qT(L))
        throw new Error("unmountComponentAtNode(...): Target container is not a DOM element.");
      {
        var O = Vj(L) && L._reactRootContainer === void 0;
        if (O)
          Y("You are calling ReactDOM.unmountComponentAtNode() on a container that was previously passed to ReactDOMClient.createRoot(). This is not supported. Did you mean to call root.unmount()?");
      }
      if (L._reactRootContainer) {
        {
          var _ = bc(L), k = _ && !iU(_);
          if (k)
            Y("unmountComponentAtNode(): The node you're attempting to unmount was rendered by another copy of React.");
        }
        return LF(function() {
          uk(null, null, L, !1, function() {
            L._reactRootContainer = null, l70(L);
          });
        }), !0;
      } else {
        {
          var y = bc(L), d = !!(y && iU(y)), o = L.nodeType === J5 && qT(L.parentNode) && !!L.parentNode._reactRootContainer;
          if (d)
            Y("unmountComponentAtNode(): The node you're attempting to unmount was rendered by React and is not a top-level container. %s", o ? "You may have accidentally passed in a React root node instead of its container." : "Instead, have the parent component update its state and rerender in order to remove this component.");
        }
        return !1;
      }
    }
    if (cy0(Sl0), ny0(fl0), iy0(hl0), oy0(IG), sy0(dy0), typeof Map !== "function" || Map.prototype == null || typeof Map.prototype.forEach !== "function" || typeof Set !== "function" || Set.prototype == null || typeof Set.prototype.clear !== "function" || typeof Set.prototype.forEach !== "function")
      Y("React depends on Map and Set built-in types. Make sure that you load a polyfill in older browsers. https://reactjs.org/link/react-polyfills");
    Px0(am0), vx0(Uc, cc0, LF);
    function el0(L, O) {
      var _ = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : null;
      if (!pk(O))
        throw new Error("Target container is not a DOM element.");
      return kl0(L, O, null, _);
    }
    function Zn0(L, O, _, k) {
      return rl0(L, O, _, k);
    }
    var xc = {
      usingClientEntryPoint: !1,
      Events: [iU, $D, IC, G90, H90, Uc]
    };
    function Jn0(L, O) {
      if (!xc.usingClientEntryPoint)
        Y('You are importing createRoot from "react-dom" which is not supported. You should instead import it from "react-dom/client".');
      return pl0(L, O);
    }
    function $n0(L, O, _) {
      if (!xc.usingClientEntryPoint)
        Y('You are importing hydrateRoot from "react-dom" which is not supported. You should instead import it from "react-dom/client".');
      return cl0(L, O, _);
    }
    function Xn0(L) {
      if (QX0())
        Y("flushSync was called from inside a lifecycle method. React cannot flush when React is already rendering. Consider moving this call to a scheduler task or micro task.");
      return LF(L);
    }
    var Yn0 = dl0({
      findFiberByHostInstance: WO,
      bundleType: 1,
      version: Cc,
      rendererPackageName: "react-dom"
    });
    if (!Yn0 && $0 && window.top === window.self) {
      if (navigator.userAgent.indexOf("Chrome") > -1 && navigator.userAgent.indexOf("Edge") === -1 || navigator.userAgent.indexOf("Firefox") > -1) {
        var eX0 = window.location.protocol;
        if (/^(https?|file):$/.test(eX0))
          console.info("%cDownload the React DevTools for a better development experience: https://reactjs.org/link/react-devtools" + (eX0 === "file:" ? `
You might need to use a local HTTP server (instead of file://): https://reactjs.org/link/react-devtools-faq` : ""), "font-weight:bold");
      }
    }
    if (Un0.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = xc, Un0.createPortal = el0, Un0.createRoot = Jn0, Un0.findDOMNode = ol0, Un0.flushSync = Xn0, Un0.hydrate = sl0, Un0.hydrateRoot = $n0, Un0.render = al0, Un0.unmountComponentAtNode = tl0, Un0.unstable_batchedUpdates = Uc, Un0.unstable_renderSubtreeIntoContainer = Zn0, Un0.version = Cc, typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== "undefined" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop === "function")
      __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error);
  })();
});

// node_modules/react-dom/index.js
var XY0 = SX((BP1, $Y0) => {
  var Ln0 = t2(JY0(), 1);
  $Y0.exports = Ln0;
});

// node_modules/react-dom/client.js
var gc = SX((Rn0) => {
  var ID = t2(XY0(), 1);
  VD = ID.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED, Rn0.createRoot = function(Z, J) {
    VD.usingClientEntryPoint = !0;
    try {
      return ID.createRoot(Z, J);
    } finally {
      VD.usingClientEntryPoint = !1;
    }
  }, Rn0.hydrateRoot = function(Z, J, $) {
    VD.usingClientEntryPoint = !0;
    try {
      return ID.hydrateRoot(Z, J, $);
    } finally {
      VD.usingClientEntryPoint = !1;
    }
  };
  var VD;
});

// node_modules/react-is/cjs/react-is.development.js
var YY0 = SX((En0) => {
  (function() {
    var Z = typeof Symbol === "function" && Symbol.for, J = Z ? Symbol.for("react.element") : 60103, $ = Z ? Symbol.for("react.portal") : 60106, X = Z ? Symbol.for("react.fragment") : 60107, Y = Z ? Symbol.for("react.strict_mode") : 60108, Q = Z ? Symbol.for("react.profiler") : 60114, W = Z ? Symbol.for("react.provider") : 60109, K = Z ? Symbol.for("react.context") : 60110, G = Z ? Symbol.for("react.async_mode") : 60111, H = Z ? Symbol.for("react.concurrent_mode") : 60111, N = Z ? Symbol.for("react.forward_ref") : 60112, q = Z ? Symbol.for("react.suspense") : 60113, U = Z ? Symbol.for("react.suspense_list") : 60120, F = Z ? Symbol.for("react.memo") : 60115, E = Z ? Symbol.for("react.lazy") : 60116, R = Z ? Symbol.for("react.block") : 60121, z = Z ? Symbol.for("react.fundamental") : 60117, D = Z ? Symbol.for("react.responder") : 60118, A = Z ? Symbol.for("react.scope") : 60119;
    function B(R0) {
      return typeof R0 === "string" || typeof R0 === "function" || R0 === X || R0 === H || R0 === Q || R0 === Y || R0 === q || R0 === U || typeof R0 === "object" && R0 !== null && (R0.$$typeof === E || R0.$$typeof === F || R0.$$typeof === W || R0.$$typeof === K || R0.$$typeof === N || R0.$$typeof === z || R0.$$typeof === D || R0.$$typeof === A || R0.$$typeof === R);
    }
    function T(R0) {
      if (typeof R0 === "object" && R0 !== null) {
        var X0 = R0.$$typeof;
        switch (X0) {
          case J:
            var E0 = R0.type;
            switch (E0) {
              case G:
              case H:
              case X:
              case Q:
              case Y:
              case q:
                return E0;
              default:
                var V0 = E0 && E0.$$typeof;
                switch (V0) {
                  case K:
                  case N:
                  case E:
                  case F:
                  case W:
                    return V0;
                  default:
                    return X0;
                }
            }
          case $:
            return X0;
        }
      }
      return;
    }
    var w = G, V = H, P = K, I = W, S = J, f = N, v = X, h = E, x = F, b = $, g = Q, m = Y, i = q, r = !1;
    function Y0(R0) {
      if (!r)
        r = !0, console.warn("The ReactIs.isAsyncMode() alias has been deprecated, and will be removed in React 17+. Update your code to use ReactIs.isConcurrentMode() instead. It has the exact same API.");
      return c(R0) || T(R0) === G;
    }
    function c(R0) {
      return T(R0) === H;
    }
    function n(R0) {
      return T(R0) === K;
    }
    function l(R0) {
      return T(R0) === W;
    }
    function u(R0) {
      return typeof R0 === "object" && R0 !== null && R0.$$typeof === J;
    }
    function G0(R0) {
      return T(R0) === N;
    }
    function F0(R0) {
      return T(R0) === X;
    }
    function t(R0) {
      return T(R0) === E;
    }
    function Z0(R0) {
      return T(R0) === F;
    }
    function U0(R0) {
      return T(R0) === $;
    }
    function a(R0) {
      return T(R0) === Q;
    }
    function Q0(R0) {
      return T(R0) === Y;
    }
    function $0(R0) {
      return T(R0) === q;
    }
    En0.AsyncMode = w, En0.ConcurrentMode = V, En0.ContextConsumer = P, En0.ContextProvider = I, En0.Element = S, En0.ForwardRef = f, En0.Fragment = v, En0.Lazy = h, En0.Memo = x, En0.Portal = b, En0.Profiler = g, En0.StrictMode = m, En0.Suspense = i, En0.isAsyncMode = Y0, En0.isConcurrentMode = c, En0.isContextConsumer = n, En0.isContextProvider = l, En0.isElement = u, En0.isForwardRef = G0, En0.isFragment = F0, En0.isLazy = t, En0.isMemo = Z0, En0.isPortal = U0, En0.isProfiler = a, En0.isStrictMode = Q0, En0.isSuspense = $0, En0.isValidElementType = B, En0.typeOf = T;
  })();
});

// node_modules/hoist-non-react-statics/dist/hoist-non-react-statics.cjs.js
var qY0 = SX((JC1, NY0) => {
  var PD = t2(YY0(), 1), On0 = {
    childContextTypes: !0,
    contextType: !0,
    contextTypes: !0,
    defaultProps: !0,
    displayName: !0,
    getDefaultProps: !0,
    getDerivedStateFromError: !0,
    getDerivedStateFromProps: !0,
    mixins: !0,
    propTypes: !0,
    type: !0
  }, zn0 = {
    name: !0,
    length: !0,
    prototype: !0,
    caller: !0,
    callee: !0,
    arguments: !0,
    arity: !0
  }, Dn0 = {
    $$typeof: !0,
    render: !0,
    defaultProps: !0,
    displayName: !0,
    propTypes: !0
  }, GY0 = {
    $$typeof: !0,
    compare: !0,
    defaultProps: !0,
    displayName: !0,
    propTypes: !0,
    type: !0
  }, mc = {};
  mc[PD.ForwardRef] = Dn0;
  mc[PD.Memo] = GY0;
  function QY0(Z) {
    if (PD.isMemo(Z))
      return GY0;
    return mc[Z.$$typeof] || On0;
  }
  var { defineProperty: Mn0, getOwnPropertyNames: An0, getOwnPropertySymbols: WY0, getOwnPropertyDescriptor: Bn0, getPrototypeOf: wn0, prototype: KY0 } = Object;
  function HY0(Z, J, $) {
    if (typeof J !== "string") {
      if (KY0) {
        var X = wn0(J);
        if (X && X !== KY0)
          HY0(Z, X, $);
      }
      var Y = An0(J);
      if (WY0)
        Y = Y.concat(WY0(J));
      var Q = QY0(Z), W = QY0(J);
      for (var K = 0;K < Y.length; ++K) {
        var G = Y[K];
        if (!zn0[G] && !($ && $[G]) && !(W && W[G]) && !(Q && Q[G])) {
          var H = Bn0(J, G);
          try {
            Mn0(Z, G, H);
          } catch (N) {}
        }
      }
    }
    return Z;
  }
  NY0.exports = HY0;
});

// node_modules/object-assign/index.js
var LY0 = SX(($C1, UY0) => {
  var FY0 = Object.getOwnPropertySymbols, jn0 = Object.prototype.hasOwnProperty, Tn0 = Object.prototype.propertyIsEnumerable;
  function _n0(Z) {
    if (Z === null || Z === void 0)
      throw new TypeError("Object.assign cannot be called with null or undefined");
    return Object(Z);
  }
  function Vn0() {
    try {
      if (!Object.assign)
        return !1;
      var Z = new String("abc");
      if (Z[5] = "de", Object.getOwnPropertyNames(Z)[0] === "5")
        return !1;
      var J = {};
      for (var $ = 0;$ < 10; $++)
        J["_" + String.fromCharCode($)] = $;
      var X = Object.getOwnPropertyNames(J).map(function(Q) {
        return J[Q];
      });
      if (X.join("") !== "0123456789")
        return !1;
      var Y = {};
      if ("abcdefghijklmnopqrst".split("").forEach(function(Q) {
        Y[Q] = Q;
      }), Object.keys(Object.assign({}, Y)).join("") !== "abcdefghijklmnopqrst")
        return !1;
      return !0;
    } catch (Q) {
      return !1;
    }
  }
  UY0.exports = Vn0() ? Object.assign : function(Z, J) {
    var $, X = _n0(Z), Y;
    for (var Q = 1;Q < arguments.length; Q++) {
      $ = Object(arguments[Q]);
      for (var W in $)
        if (jn0.call($, W))
          X[W] = $[W];
      if (FY0) {
        Y = FY0($);
        for (var K = 0;K < Y.length; K++)
          if (Tn0.call($, Y[K]))
            X[Y[K]] = $[Y[K]];
      }
    }
    return X;
  };
});

// node_modules/prop-types/lib/ReactPropTypesSecret.js
var EY0 = SX((XC1, RY0) => {
  var In0 = "SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";
  RY0.exports = In0;
});

// node_modules/prop-types/lib/has.js
var zY0 = SX((YC1, OY0) => {
  OY0.exports = Function.call.bind(Object.prototype.hasOwnProperty);
});

// node_modules/prop-types/checkPropTypes.js
var AY0 = SX((QC1, MY0) => {
  var dc = function() {};
  pc = EY0(), LT = {}, uc = zY0(), dc = function(Z) {
    var J = "Warning: " + Z;
    if (typeof console !== "undefined")
      console.error(J);
    try {
      throw new Error(J);
    } catch ($) {}
  };
  var pc, LT, uc;
  function DY0(Z, J, $, X, Y) {
    for (var Q in Z)
      if (uc(Z, Q)) {
        var W;
        try {
          if (typeof Z[Q] !== "function") {
            var K = Error((X || "React class") + ": " + $ + " type `" + Q + "` is invalid; it must be a function, usually from the `prop-types` package, but received `" + typeof Z[Q] + "`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");
            throw K.name = "Invariant Violation", K;
          }
          W = Z[Q](J, Q, X, $, null, pc);
        } catch (H) {
          W = H;
        }
        if (W && !(W instanceof Error))
          dc((X || "React class") + ": type specification of " + $ + " `" + Q + "` is invalid; the type checker function must return `null` or an `Error` but returned a " + typeof W + ". You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).");
        if (W instanceof Error && !(W.message in LT)) {
          LT[W.message] = !0;
          var G = Y ? Y() : "";
          dc("Failed " + $ + " type: " + W.message + (G != null ? G : ""));
        }
      }
  }
  DY0.resetWarningCache = function() {
    LT = {};
  };
  MY0.exports = DY0;
});

// node_modules/streamlit-component-lib/node_modules/react/cjs/react.development.js
var BY0 = SX((Pn0) => {
  (function() {
    var Z = LY0(), J = AY0(), $ = "16.14.0", X = typeof Symbol === "function" && Symbol.for, Y = X ? Symbol.for("react.element") : 60103, Q = X ? Symbol.for("react.portal") : 60106, W = X ? Symbol.for("react.fragment") : 60107, K = X ? Symbol.for("react.strict_mode") : 60108, G = X ? Symbol.for("react.profiler") : 60114, H = X ? Symbol.for("react.provider") : 60109, N = X ? Symbol.for("react.context") : 60110, q = X ? Symbol.for("react.concurrent_mode") : 60111, U = X ? Symbol.for("react.forward_ref") : 60112, F = X ? Symbol.for("react.suspense") : 60113, E = X ? Symbol.for("react.suspense_list") : 60120, R = X ? Symbol.for("react.memo") : 60115, z = X ? Symbol.for("react.lazy") : 60116, D = X ? Symbol.for("react.block") : 60121, A = X ? Symbol.for("react.fundamental") : 60117, B = X ? Symbol.for("react.responder") : 60118, T = X ? Symbol.for("react.scope") : 60119, w = typeof Symbol === "function" && Symbol.iterator, V = "@@iterator";
    function P(v0) {
      if (v0 === null || typeof v0 !== "object")
        return null;
      var E1 = w && v0[w] || v0[V];
      if (typeof E1 === "function")
        return E1;
      return null;
    }
    var I = {
      current: null
    }, S = {
      suspense: null
    }, f = {
      current: null
    }, v = /^(.*)[\\\/]/;
    function h(v0, E1, c1) {
      var L2 = "";
      if (E1) {
        var N8 = E1.fileName, yZ = N8.replace(v, "");
        if (/^index\./.test(yZ)) {
          var _6 = N8.match(v);
          if (_6) {
            var JZ = _6[1];
            if (JZ) {
              var gJ = JZ.replace(v, "");
              yZ = gJ + "/" + yZ;
            }
          }
        }
        L2 = " (at " + yZ + ":" + E1.lineNumber + ")";
      } else if (c1)
        L2 = " (created by " + c1 + ")";
      return `
    in ` + (v0 || "Unknown") + L2;
    }
    var x = 1;
    function b(v0) {
      return v0._status === x ? v0._result : null;
    }
    function g(v0, E1, c1) {
      var L2 = E1.displayName || E1.name || "";
      return v0.displayName || (L2 !== "" ? c1 + "(" + L2 + ")" : c1);
    }
    function m(v0) {
      if (v0 == null)
        return null;
      if (typeof v0.tag === "number")
        u("Received an unexpected object in getComponentName(). This is likely a bug in React. Please file an issue.");
      if (typeof v0 === "function")
        return v0.displayName || v0.name || null;
      if (typeof v0 === "string")
        return v0;
      switch (v0) {
        case W:
          return "Fragment";
        case Q:
          return "Portal";
        case G:
          return "Profiler";
        case K:
          return "StrictMode";
        case F:
          return "Suspense";
        case E:
          return "SuspenseList";
      }
      if (typeof v0 === "object")
        switch (v0.$$typeof) {
          case N:
            return "Context.Consumer";
          case H:
            return "Context.Provider";
          case U:
            return g(v0, v0.render, "ForwardRef");
          case R:
            return m(v0.type);
          case D:
            return m(v0.render);
          case z: {
            var E1 = v0, c1 = b(E1);
            if (c1)
              return m(c1);
            break;
          }
        }
      return null;
    }
    var i = {}, r = null;
    function Y0(v0) {
      r = v0;
    }
    i.getCurrentStack = null, i.getStackAddendum = function() {
      var v0 = "";
      if (r) {
        var E1 = m(r.type), c1 = r._owner;
        v0 += h(E1, r._source, c1 && m(c1.type));
      }
      var L2 = i.getCurrentStack;
      if (L2)
        v0 += L2() || "";
      return v0;
    };
    var c = {
      current: !1
    }, n = {
      ReactCurrentDispatcher: I,
      ReactCurrentBatchConfig: S,
      ReactCurrentOwner: f,
      IsSomeRendererActing: c,
      assign: Z
    };
    Z(n, {
      ReactDebugCurrentFrame: i,
      ReactComponentTreeHook: {}
    });
    function l(v0) {
      {
        for (var E1 = arguments.length, c1 = new Array(E1 > 1 ? E1 - 1 : 0), L2 = 1;L2 < E1; L2++)
          c1[L2 - 1] = arguments[L2];
        G0("warn", v0, c1);
      }
    }
    function u(v0) {
      {
        for (var E1 = arguments.length, c1 = new Array(E1 > 1 ? E1 - 1 : 0), L2 = 1;L2 < E1; L2++)
          c1[L2 - 1] = arguments[L2];
        G0("error", v0, c1);
      }
    }
    function G0(v0, E1, c1) {
      {
        var L2 = c1.length > 0 && typeof c1[c1.length - 1] === "string" && c1[c1.length - 1].indexOf(`
    in`) === 0;
        if (!L2) {
          var N8 = n.ReactDebugCurrentFrame, yZ = N8.getStackAddendum();
          if (yZ !== "")
            E1 += "%s", c1 = c1.concat([yZ]);
        }
        var _6 = c1.map(function(y6) {
          return "" + y6;
        });
        _6.unshift("Warning: " + E1), Function.prototype.apply.call(console[v0], console, _6);
        try {
          var JZ = 0, gJ = "Warning: " + E1.replace(/%s/g, function() {
            return c1[JZ++];
          });
          throw new Error(gJ);
        } catch (y6) {}
      }
    }
    var F0 = {};
    function t(v0, E1) {
      {
        var c1 = v0.constructor, L2 = c1 && (c1.displayName || c1.name) || "ReactClass", N8 = L2 + "." + E1;
        if (F0[N8])
          return;
        u("Can't call %s on a component that is not yet mounted. This is a no-op, but it might indicate a bug in your application. Instead, assign to `this.state` directly or define a `state = {};` class property with the desired state in the %s component.", E1, L2), F0[N8] = !0;
      }
    }
    var Z0 = {
      isMounted: function(v0) {
        return !1;
      },
      enqueueForceUpdate: function(v0, E1, c1) {
        t(v0, "forceUpdate");
      },
      enqueueReplaceState: function(v0, E1, c1, L2) {
        t(v0, "replaceState");
      },
      enqueueSetState: function(v0, E1, c1, L2) {
        t(v0, "setState");
      }
    }, U0 = {};
    Object.freeze(U0);
    function a(v0, E1, c1) {
      this.props = v0, this.context = E1, this.refs = U0, this.updater = c1 || Z0;
    }
    a.prototype.isReactComponent = {}, a.prototype.setState = function(v0, E1) {
      if (!(typeof v0 === "object" || typeof v0 === "function" || v0 == null))
        throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");
      this.updater.enqueueSetState(this, v0, E1, "setState");
    }, a.prototype.forceUpdate = function(v0) {
      this.updater.enqueueForceUpdate(this, v0, "forceUpdate");
    };
    {
      var Q0 = {
        isMounted: ["isMounted", "Instead, make sure to clean up subscriptions and pending requests in componentWillUnmount to prevent memory leaks."],
        replaceState: ["replaceState", "Refactor your code to use setState instead (see https://github.com/facebook/react/issues/3236)."]
      }, $0 = function(v0, E1) {
        Object.defineProperty(a.prototype, v0, {
          get: function() {
            l("%s(...) is deprecated in plain JavaScript React classes. %s", E1[0], E1[1]);
            return;
          }
        });
      };
      for (var R0 in Q0)
        if (Q0.hasOwnProperty(R0))
          $0(R0, Q0[R0]);
    }
    function X0() {}
    X0.prototype = a.prototype;
    function E0(v0, E1, c1) {
      this.props = v0, this.context = E1, this.refs = U0, this.updater = c1 || Z0;
    }
    var V0 = E0.prototype = new X0;
    V0.constructor = E0, Z(V0, a.prototype), V0.isPureReactComponent = !0;
    function u0() {
      var v0 = {
        current: null
      };
      return Object.seal(v0), v0;
    }
    var N0 = Object.prototype.hasOwnProperty, q0 = {
      key: !0,
      ref: !0,
      __self: !0,
      __source: !0
    }, A0, S0, a0;
    a0 = {};
    function D1(v0) {
      if (N0.call(v0, "ref")) {
        var E1 = Object.getOwnPropertyDescriptor(v0, "ref").get;
        if (E1 && E1.isReactWarning)
          return !1;
      }
      return v0.ref !== void 0;
    }
    function Y1(v0) {
      if (N0.call(v0, "key")) {
        var E1 = Object.getOwnPropertyDescriptor(v0, "key").get;
        if (E1 && E1.isReactWarning)
          return !1;
      }
      return v0.key !== void 0;
    }
    function u1(v0, E1) {
      var c1 = function() {
        if (!A0)
          A0 = !0, u("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://fb.me/react-special-props)", E1);
      };
      c1.isReactWarning = !0, Object.defineProperty(v0, "key", {
        get: c1,
        configurable: !0
      });
    }
    function b0(v0, E1) {
      var c1 = function() {
        if (!S0)
          S0 = !0, u("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://fb.me/react-special-props)", E1);
      };
      c1.isReactWarning = !0, Object.defineProperty(v0, "ref", {
        get: c1,
        configurable: !0
      });
    }
    function x0(v0) {
      if (typeof v0.ref === "string" && f.current && v0.__self && f.current.stateNode !== v0.__self) {
        var E1 = m(f.current.type);
        if (!a0[E1])
          u('Component "%s" contains the string ref "%s". Support for string refs will be removed in a future major release. This case cannot be automatically converted to an arrow function. We ask you to manually fix this case by using useRef() or createRef() instead. Learn more about using refs safely here: https://fb.me/react-strict-mode-string-ref', m(f.current.type), v0.ref), a0[E1] = !0;
      }
    }
    var m0 = function(v0, E1, c1, L2, N8, yZ, _6) {
      var JZ = {
        $$typeof: Y,
        type: v0,
        key: E1,
        ref: c1,
        props: _6,
        _owner: yZ
      };
      if (JZ._store = {}, Object.defineProperty(JZ._store, "validated", {
        configurable: !1,
        enumerable: !1,
        writable: !0,
        value: !1
      }), Object.defineProperty(JZ, "_self", {
        configurable: !1,
        enumerable: !1,
        writable: !1,
        value: L2
      }), Object.defineProperty(JZ, "_source", {
        configurable: !1,
        enumerable: !1,
        writable: !1,
        value: N8
      }), Object.freeze)
        Object.freeze(JZ.props), Object.freeze(JZ);
      return JZ;
    };
    function e0(v0, E1, c1) {
      var L2, N8 = {}, yZ = null, _6 = null, JZ = null, gJ = null;
      if (E1 != null) {
        if (D1(E1))
          _6 = E1.ref, x0(E1);
        if (Y1(E1))
          yZ = "" + E1.key;
        JZ = E1.__self === void 0 ? null : E1.__self, gJ = E1.__source === void 0 ? null : E1.__source;
        for (L2 in E1)
          if (N0.call(E1, L2) && !q0.hasOwnProperty(L2))
            N8[L2] = E1[L2];
      }
      var y6 = arguments.length - 2;
      if (y6 === 1)
        N8.children = c1;
      else if (y6 > 1) {
        var uY = Array(y6);
        for (var jX = 0;jX < y6; jX++)
          uY[jX] = arguments[jX + 2];
        if (Object.freeze)
          Object.freeze(uY);
        N8.children = uY;
      }
      if (v0 && v0.defaultProps) {
        var D6 = v0.defaultProps;
        for (L2 in D6)
          if (N8[L2] === void 0)
            N8[L2] = D6[L2];
      }
      if (yZ || _6) {
        var HW = typeof v0 === "function" ? v0.displayName || v0.name || "Unknown" : v0;
        if (yZ)
          u1(N8, HW);
        if (_6)
          b0(N8, HW);
      }
      return m0(v0, yZ, _6, JZ, gJ, f.current, N8);
    }
    function p(v0, E1) {
      var c1 = m0(v0.type, E1, v0.ref, v0._self, v0._source, v0._owner, v0.props);
      return c1;
    }
    function J0(v0, E1, c1) {
      if (v0 === null || v0 === void 0)
        throw Error("React.cloneElement(...): The argument must be a React element, but you passed " + v0 + ".");
      var L2, N8 = Z({}, v0.props), yZ = v0.key, _6 = v0.ref, JZ = v0._self, gJ = v0._source, y6 = v0._owner;
      if (E1 != null) {
        if (D1(E1))
          _6 = E1.ref, y6 = f.current;
        if (Y1(E1))
          yZ = "" + E1.key;
        var uY;
        if (v0.type && v0.type.defaultProps)
          uY = v0.type.defaultProps;
        for (L2 in E1)
          if (N0.call(E1, L2) && !q0.hasOwnProperty(L2))
            if (E1[L2] === void 0 && uY !== void 0)
              N8[L2] = uY[L2];
            else
              N8[L2] = E1[L2];
      }
      var jX = arguments.length - 2;
      if (jX === 1)
        N8.children = c1;
      else if (jX > 1) {
        var D6 = Array(jX);
        for (var HW = 0;HW < jX; HW++)
          D6[HW] = arguments[HW + 2];
        N8.children = D6;
      }
      return m0(v0.type, yZ, _6, JZ, gJ, y6, N8);
    }
    function T0(v0) {
      return typeof v0 === "object" && v0 !== null && v0.$$typeof === Y;
    }
    var o0 = ".", y0 = ":";
    function $1(v0) {
      var E1 = /[=:]/g, c1 = {
        "=": "=0",
        ":": "=2"
      }, L2 = ("" + v0).replace(E1, function(N8) {
        return c1[N8];
      });
      return "$" + L2;
    }
    var F1 = !1, A1 = /\/+/g;
    function P1(v0) {
      return ("" + v0).replace(A1, "$&/");
    }
    var S1 = 10, _1 = [];
    function a1(v0, E1, c1, L2) {
      if (_1.length) {
        var N8 = _1.pop();
        return N8.result = v0, N8.keyPrefix = E1, N8.func = c1, N8.context = L2, N8.count = 0, N8;
      } else
        return {
          result: v0,
          keyPrefix: E1,
          func: c1,
          context: L2,
          count: 0
        };
    }
    function U2(v0) {
      if (v0.result = null, v0.keyPrefix = null, v0.func = null, v0.context = null, v0.count = 0, _1.length < S1)
        _1.push(v0);
    }
    function G2(v0, E1, c1, L2) {
      var N8 = typeof v0;
      if (N8 === "undefined" || N8 === "boolean")
        v0 = null;
      var yZ = !1;
      if (v0 === null)
        yZ = !0;
      else
        switch (N8) {
          case "string":
          case "number":
            yZ = !0;
            break;
          case "object":
            switch (v0.$$typeof) {
              case Y:
              case Q:
                yZ = !0;
            }
        }
      if (yZ)
        return c1(L2, v0, E1 === "" ? o0 + v2(v0, 0) : E1), 1;
      var _6, JZ, gJ = 0, y6 = E1 === "" ? o0 : E1 + y0;
      if (Array.isArray(v0))
        for (var uY = 0;uY < v0.length; uY++)
          _6 = v0[uY], JZ = y6 + v2(_6, uY), gJ += G2(_6, JZ, c1, L2);
      else {
        var jX = P(v0);
        if (typeof jX === "function") {
          if (jX === v0.entries) {
            if (!F1)
              l("Using Maps as children is deprecated and will be removed in a future major release. Consider converting children to an array of keyed ReactElements instead.");
            F1 = !0;
          }
          var D6 = jX.call(v0), HW, sX = 0;
          while (!(HW = D6.next()).done)
            _6 = HW.value, JZ = y6 + v2(_6, sX++), gJ += G2(_6, JZ, c1, L2);
        } else if (N8 === "object") {
          var nH = "";
          nH = " If you meant to render a collection of children, use an array instead." + i.getStackAddendum();
          var TG = "" + v0;
          throw Error("Objects are not valid as a React child (found: " + (TG === "[object Object]" ? "object with keys {" + Object.keys(v0).join(", ") + "}" : TG) + ")." + nH);
        }
      }
      return gJ;
    }
    function P2(v0, E1, c1) {
      if (v0 == null)
        return 0;
      return G2(v0, "", E1, c1);
    }
    function v2(v0, E1) {
      if (typeof v0 === "object" && v0 !== null && v0.key != null)
        return $1(v0.key);
      return E1.toString(36);
    }
    function O8(v0, E1, c1) {
      var { func: L2, context: N8 } = v0;
      L2.call(N8, E1, v0.count++);
    }
    function n8(v0, E1, c1) {
      if (v0 == null)
        return v0;
      var L2 = a1(null, null, E1, c1);
      P2(v0, O8, L2), U2(L2);
    }
    function z6(v0, E1, c1) {
      var { result: L2, keyPrefix: N8, func: yZ, context: _6 } = v0, JZ = yZ.call(_6, E1, v0.count++);
      if (Array.isArray(JZ))
        L8(JZ, L2, c1, function(gJ) {
          return gJ;
        });
      else if (JZ != null) {
        if (T0(JZ))
          JZ = p(JZ, N8 + (JZ.key && (!E1 || E1.key !== JZ.key) ? P1(JZ.key) + "/" : "") + c1);
        L2.push(JZ);
      }
    }
    function L8(v0, E1, c1, L2, N8) {
      var yZ = "";
      if (c1 != null)
        yZ = P1(c1) + "/";
      var _6 = a1(E1, yZ, L2, N8);
      P2(v0, z6, _6), U2(_6);
    }
    function R8(v0, E1, c1) {
      if (v0 == null)
        return v0;
      var L2 = [];
      return L8(v0, L2, null, E1, c1), L2;
    }
    function w0(v0) {
      return P2(v0, function() {
        return null;
      }, null);
    }
    function P0(v0) {
      var E1 = [];
      return L8(v0, E1, null, function(c1) {
        return c1;
      }), E1;
    }
    function l0(v0) {
      if (!T0(v0))
        throw Error("React.Children.only expected to receive a single React element child.");
      return v0;
    }
    function z1(v0, E1) {
      if (E1 === void 0)
        E1 = null;
      else if (E1 !== null && typeof E1 !== "function")
        u("createContext: Expected the optional second argument to be a function. Instead received: %s", E1);
      var c1 = {
        $$typeof: N,
        _calculateChangedBits: E1,
        _currentValue: v0,
        _currentValue2: v0,
        _threadCount: 0,
        Provider: null,
        Consumer: null
      };
      c1.Provider = {
        $$typeof: H,
        _context: c1
      };
      var L2 = !1, N8 = !1;
      {
        var yZ = {
          $$typeof: N,
          _context: c1,
          _calculateChangedBits: c1._calculateChangedBits
        };
        Object.defineProperties(yZ, {
          Provider: {
            get: function() {
              if (!N8)
                N8 = !0, u("Rendering <Context.Consumer.Provider> is not supported and will be removed in a future major release. Did you mean to render <Context.Provider> instead?");
              return c1.Provider;
            },
            set: function(_6) {
              c1.Provider = _6;
            }
          },
          _currentValue: {
            get: function() {
              return c1._currentValue;
            },
            set: function(_6) {
              c1._currentValue = _6;
            }
          },
          _currentValue2: {
            get: function() {
              return c1._currentValue2;
            },
            set: function(_6) {
              c1._currentValue2 = _6;
            }
          },
          _threadCount: {
            get: function() {
              return c1._threadCount;
            },
            set: function(_6) {
              c1._threadCount = _6;
            }
          },
          Consumer: {
            get: function() {
              if (!L2)
                L2 = !0, u("Rendering <Context.Consumer.Consumer> is not supported and will be removed in a future major release. Did you mean to render <Context.Consumer> instead?");
              return c1.Consumer;
            }
          }
        }), c1.Consumer = yZ;
      }
      return c1._currentRenderer = null, c1._currentRenderer2 = null, c1;
    }
    function J2(v0) {
      var E1 = {
        $$typeof: z,
        _ctor: v0,
        _status: -1,
        _result: null
      };
      {
        var c1, L2;
        Object.defineProperties(E1, {
          defaultProps: {
            configurable: !0,
            get: function() {
              return c1;
            },
            set: function(N8) {
              u("React.lazy(...): It is not supported to assign `defaultProps` to a lazy component import. Either specify them where the component is defined, or create a wrapping component around it."), c1 = N8, Object.defineProperty(E1, "defaultProps", {
                enumerable: !0
              });
            }
          },
          propTypes: {
            configurable: !0,
            get: function() {
              return L2;
            },
            set: function(N8) {
              u("React.lazy(...): It is not supported to assign `propTypes` to a lazy component import. Either specify them where the component is defined, or create a wrapping component around it."), L2 = N8, Object.defineProperty(E1, "propTypes", {
                enumerable: !0
              });
            }
          }
        });
      }
      return E1;
    }
    function N2(v0) {
      {
        if (v0 != null && v0.$$typeof === R)
          u("forwardRef requires a render function but received a `memo` component. Instead of forwardRef(memo(...)), use memo(forwardRef(...)).");
        else if (typeof v0 !== "function")
          u("forwardRef requires a render function but was given %s.", v0 === null ? "null" : typeof v0);
        else if (v0.length !== 0 && v0.length !== 2)
          u("forwardRef render functions accept exactly two parameters: props and ref. %s", v0.length === 1 ? "Did you forget to use the ref parameter?" : "Any additional parameter will be undefined.");
        if (v0 != null) {
          if (v0.defaultProps != null || v0.propTypes != null)
            u("forwardRef render functions do not support propTypes or defaultProps. Did you accidentally pass a React component?");
        }
      }
      return {
        $$typeof: U,
        render: v0
      };
    }
    function X8(v0) {
      return typeof v0 === "string" || typeof v0 === "function" || v0 === W || v0 === q || v0 === G || v0 === K || v0 === F || v0 === E || typeof v0 === "object" && v0 !== null && (v0.$$typeof === z || v0.$$typeof === R || v0.$$typeof === H || v0.$$typeof === N || v0.$$typeof === U || v0.$$typeof === A || v0.$$typeof === B || v0.$$typeof === T || v0.$$typeof === D);
    }
    function c0(v0, E1) {
      if (!X8(v0))
        u("memo: The first argument must be a component. Instead received: %s", v0 === null ? "null" : typeof v0);
      return {
        $$typeof: R,
        type: v0,
        compare: E1 === void 0 ? null : E1
      };
    }
    function M1() {
      var v0 = I.current;
      if (v0 === null)
        throw Error(`Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:
1. You might have mismatching versions of React and the renderer (such as React DOM)
2. You might be breaking the Rules of Hooks
3. You might have more than one copy of React in the same app
See https://fb.me/react-invalid-hook-call for tips about how to debug and fix this problem.`);
      return v0;
    }
    function g1(v0, E1) {
      var c1 = M1();
      {
        if (E1 !== void 0)
          u("useContext() second argument is reserved for future use in React. Passing it is not supported. You passed: %s.%s", E1, typeof E1 === "number" && Array.isArray(arguments[2]) ? `

Did you call array.map(useContext)? Calling Hooks inside a loop is not supported. Learn more at https://fb.me/rules-of-hooks` : "");
        if (v0._context !== void 0) {
          var L2 = v0._context;
          if (L2.Consumer === v0)
            u("Calling useContext(Context.Consumer) is not supported, may cause bugs, and will be removed in a future major release. Did you mean to call useContext(Context) instead?");
          else if (L2.Provider === v0)
            u("Calling useContext(Context.Provider) is not supported. Did you mean to call useContext(Context) instead?");
        }
      }
      return c1.useContext(v0, E1);
    }
    function l2(v0) {
      var E1 = M1();
      return E1.useState(v0);
    }
    function d8(v0, E1, c1) {
      var L2 = M1();
      return L2.useReducer(v0, E1, c1);
    }
    function I1(v0) {
      var E1 = M1();
      return E1.useRef(v0);
    }
    function W2(v0, E1) {
      var c1 = M1();
      return c1.useEffect(v0, E1);
    }
    function z2(v0, E1) {
      var c1 = M1();
      return c1.useLayoutEffect(v0, E1);
    }
    function p8(v0, E1) {
      var c1 = M1();
      return c1.useCallback(v0, E1);
    }
    function W6(v0, E1) {
      var c1 = M1();
      return c1.useMemo(v0, E1);
    }
    function v6(v0, E1, c1) {
      var L2 = M1();
      return L2.useImperativeHandle(v0, E1, c1);
    }
    function AZ(v0, E1) {
      {
        var c1 = M1();
        return c1.useDebugValue(v0, E1);
      }
    }
    var L1 = !1;
    function q2() {
      if (f.current) {
        var v0 = m(f.current.type);
        if (v0)
          return `

Check the render method of \`` + v0 + "`.";
      }
      return "";
    }
    function s2(v0) {
      if (v0 !== void 0) {
        var E1 = v0.fileName.replace(/^.*[\\\/]/, ""), c1 = v0.lineNumber;
        return `

Check your code at ` + E1 + ":" + c1 + ".";
      }
      return "";
    }
    function d0(v0) {
      if (v0 !== null && v0 !== void 0)
        return s2(v0.__source);
      return "";
    }
    var d1 = {};
    function A2(v0) {
      var E1 = q2();
      if (!E1) {
        var c1 = typeof v0 === "string" ? v0 : v0.displayName || v0.name;
        if (c1)
          E1 = `

Check the top-level render call using <` + c1 + ">.";
      }
      return E1;
    }
    function B8(v0, E1) {
      if (!v0._store || v0._store.validated || v0.key != null)
        return;
      v0._store.validated = !0;
      var c1 = A2(E1);
      if (d1[c1])
        return;
      d1[c1] = !0;
      var L2 = "";
      if (v0 && v0._owner && v0._owner !== f.current)
        L2 = " It was passed a child from " + m(v0._owner.type) + ".";
      Y0(v0), u('Each child in a list should have a unique "key" prop.%s%s See https://fb.me/react-warning-keys for more information.', c1, L2), Y0(null);
    }
    function Z6(v0, E1) {
      if (typeof v0 !== "object")
        return;
      if (Array.isArray(v0))
        for (var c1 = 0;c1 < v0.length; c1++) {
          var L2 = v0[c1];
          if (T0(L2))
            B8(L2, E1);
        }
      else if (T0(v0)) {
        if (v0._store)
          v0._store.validated = !0;
      } else if (v0) {
        var N8 = P(v0);
        if (typeof N8 === "function") {
          if (N8 !== v0.entries) {
            var yZ = N8.call(v0), _6;
            while (!(_6 = yZ.next()).done)
              if (T0(_6.value))
                B8(_6.value, E1);
          }
        }
      }
    }
    function t6(v0) {
      {
        var E1 = v0.type;
        if (E1 === null || E1 === void 0 || typeof E1 === "string")
          return;
        var c1 = m(E1), L2;
        if (typeof E1 === "function")
          L2 = E1.propTypes;
        else if (typeof E1 === "object" && (E1.$$typeof === U || E1.$$typeof === R))
          L2 = E1.propTypes;
        else
          return;
        if (L2)
          Y0(v0), J(L2, v0.props, "prop", c1, i.getStackAddendum), Y0(null);
        else if (E1.PropTypes !== void 0 && !L1)
          L1 = !0, u("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?", c1 || "Unknown");
        if (typeof E1.getDefaultProps === "function" && !E1.getDefaultProps.isReactClassApproved)
          u("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.");
      }
    }
    function D2(v0) {
      {
        Y0(v0);
        var E1 = Object.keys(v0.props);
        for (var c1 = 0;c1 < E1.length; c1++) {
          var L2 = E1[c1];
          if (L2 !== "children" && L2 !== "key") {
            u("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.", L2);
            break;
          }
        }
        if (v0.ref !== null)
          u("Invalid attribute `ref` supplied to `React.Fragment`.");
        Y0(null);
      }
    }
    function vZ(v0, E1, c1) {
      var L2 = X8(v0);
      if (!L2) {
        var N8 = "";
        if (v0 === void 0 || typeof v0 === "object" && v0 !== null && Object.keys(v0).length === 0)
          N8 += " You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.";
        var yZ = d0(E1);
        if (yZ)
          N8 += yZ;
        else
          N8 += q2();
        var _6;
        if (v0 === null)
          _6 = "null";
        else if (Array.isArray(v0))
          _6 = "array";
        else if (v0 !== void 0 && v0.$$typeof === Y)
          _6 = "<" + (m(v0.type) || "Unknown") + " />", N8 = " Did you accidentally export a JSX literal instead of a component?";
        else
          _6 = typeof v0;
        u("React.createElement: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s", _6, N8);
      }
      var JZ = e0.apply(this, arguments);
      if (JZ == null)
        return JZ;
      if (L2)
        for (var gJ = 2;gJ < arguments.length; gJ++)
          Z6(arguments[gJ], v0);
      if (v0 === W)
        D2(JZ);
      else
        t6(JZ);
      return JZ;
    }
    var c6 = !1;
    function HZ(v0) {
      var E1 = vZ.bind(null, v0);
      E1.type = v0;
      {
        if (!c6)
          c6 = !0, l("React.createFactory() is deprecated and will be removed in a future major release. Consider using JSX or use React.createElement() directly instead.");
        Object.defineProperty(E1, "type", {
          enumerable: !1,
          get: function() {
            return l("Factory.type is deprecated. Access the class directly before passing it to createFactory."), Object.defineProperty(this, "type", {
              value: v0
            }), v0;
          }
        });
      }
      return E1;
    }
    function pY(v0, E1, c1) {
      var L2 = J0.apply(this, arguments);
      for (var N8 = 2;N8 < arguments.length; N8++)
        Z6(arguments[N8], L2.type);
      return t6(L2), L2;
    }
    try {
      var GW = Object.freeze({}), lH = /* @__PURE__ */ new Map([[GW, null]]), MJ = /* @__PURE__ */ new Set([GW]);
      lH.set(0, 0), MJ.add(0);
    } catch (v0) {}
    var q7 = vZ, BX = pY, wX = HZ, v7 = {
      map: R8,
      forEach: n8,
      count: w0,
      toArray: P0,
      only: l0
    };
    Pn0.Children = v7, Pn0.Component = a, Pn0.Fragment = W, Pn0.Profiler = G, Pn0.PureComponent = E0, Pn0.StrictMode = K, Pn0.Suspense = F, Pn0.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = n, Pn0.cloneElement = BX, Pn0.createContext = z1, Pn0.createElement = q7, Pn0.createFactory = wX, Pn0.createRef = u0, Pn0.forwardRef = N2, Pn0.isValidElement = T0, Pn0.lazy = J2, Pn0.memo = c0, Pn0.useCallback = p8, Pn0.useContext = g1, Pn0.useDebugValue = AZ, Pn0.useEffect = W2, Pn0.useImperativeHandle = v6, Pn0.useLayoutEffect = z2, Pn0.useMemo = W6, Pn0.useReducer = d8, Pn0.useRef = I1, Pn0.useState = l2, Pn0.version = $;
  })();
});

// node_modules/react/cjs/react-jsx-runtime.development.js
var PZ = SX((CE1) => {
  var Z10 = t2(J7(), 1);
  (function() {
    var Z = Symbol.for("react.element"), J = Symbol.for("react.portal"), $ = Symbol.for("react.fragment"), X = Symbol.for("react.strict_mode"), Y = Symbol.for("react.profiler"), Q = Symbol.for("react.provider"), W = Symbol.for("react.context"), K = Symbol.for("react.forward_ref"), G = Symbol.for("react.suspense"), H = Symbol.for("react.suspense_list"), N = Symbol.for("react.memo"), q = Symbol.for("react.lazy"), U = Symbol.for("react.offscreen"), F = Symbol.iterator, E = "@@iterator";
    function R(c0) {
      if (c0 === null || typeof c0 !== "object")
        return null;
      var M1 = F && c0[F] || c0[E];
      if (typeof M1 === "function")
        return M1;
      return null;
    }
    var z = Z10.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
    function D(c0) {
      {
        for (var M1 = arguments.length, g1 = new Array(M1 > 1 ? M1 - 1 : 0), l2 = 1;l2 < M1; l2++)
          g1[l2 - 1] = arguments[l2];
        A("error", c0, g1);
      }
    }
    function A(c0, M1, g1) {
      {
        var l2 = z.ReactDebugCurrentFrame, d8 = l2.getStackAddendum();
        if (d8 !== "")
          M1 += "%s", g1 = g1.concat([d8]);
        var I1 = g1.map(function(W2) {
          return String(W2);
        });
        I1.unshift("Warning: " + M1), Function.prototype.apply.call(console[c0], console, I1);
      }
    }
    var B = !1, T = !1, w = !1, V = !1, P = !1, I;
    I = Symbol.for("react.module.reference");
    function S(c0) {
      if (typeof c0 === "string" || typeof c0 === "function")
        return !0;
      if (c0 === $ || c0 === Y || P || c0 === X || c0 === G || c0 === H || V || c0 === U || B || T || w)
        return !0;
      if (typeof c0 === "object" && c0 !== null) {
        if (c0.$$typeof === q || c0.$$typeof === N || c0.$$typeof === Q || c0.$$typeof === W || c0.$$typeof === K || c0.$$typeof === I || c0.getModuleId !== void 0)
          return !0;
      }
      return !1;
    }
    function f(c0, M1, g1) {
      var l2 = c0.displayName;
      if (l2)
        return l2;
      var d8 = M1.displayName || M1.name || "";
      return d8 !== "" ? g1 + "(" + d8 + ")" : g1;
    }
    function v(c0) {
      return c0.displayName || "Context";
    }
    function h(c0) {
      if (c0 == null)
        return null;
      if (typeof c0.tag === "number")
        D("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue.");
      if (typeof c0 === "function")
        return c0.displayName || c0.name || null;
      if (typeof c0 === "string")
        return c0;
      switch (c0) {
        case $:
          return "Fragment";
        case J:
          return "Portal";
        case Y:
          return "Profiler";
        case X:
          return "StrictMode";
        case G:
          return "Suspense";
        case H:
          return "SuspenseList";
      }
      if (typeof c0 === "object")
        switch (c0.$$typeof) {
          case W:
            var M1 = c0;
            return v(M1) + ".Consumer";
          case Q:
            var g1 = c0;
            return v(g1._context) + ".Provider";
          case K:
            return f(c0, c0.render, "ForwardRef");
          case N:
            var l2 = c0.displayName || null;
            if (l2 !== null)
              return l2;
            return h(c0.type) || "Memo";
          case q: {
            var d8 = c0, I1 = d8._payload, W2 = d8._init;
            try {
              return h(W2(I1));
            } catch (z2) {
              return null;
            }
          }
        }
      return null;
    }
    var x = Object.assign, b = 0, g, m, i, r, Y0, c, n;
    function l() {}
    l.__reactDisabledLog = !0;
    function u() {
      {
        if (b === 0) {
          g = console.log, m = console.info, i = console.warn, r = console.error, Y0 = console.group, c = console.groupCollapsed, n = console.groupEnd;
          var c0 = {
            configurable: !0,
            enumerable: !0,
            value: l,
            writable: !0
          };
          Object.defineProperties(console, {
            info: c0,
            log: c0,
            warn: c0,
            error: c0,
            group: c0,
            groupCollapsed: c0,
            groupEnd: c0
          });
        }
        b++;
      }
    }
    function G0() {
      {
        if (b--, b === 0) {
          var c0 = {
            configurable: !0,
            enumerable: !0,
            writable: !0
          };
          Object.defineProperties(console, {
            log: x({}, c0, {
              value: g
            }),
            info: x({}, c0, {
              value: m
            }),
            warn: x({}, c0, {
              value: i
            }),
            error: x({}, c0, {
              value: r
            }),
            group: x({}, c0, {
              value: Y0
            }),
            groupCollapsed: x({}, c0, {
              value: c
            }),
            groupEnd: x({}, c0, {
              value: n
            })
          });
        }
        if (b < 0)
          D("disabledDepth fell below zero. This is a bug in React. Please file an issue.");
      }
    }
    var F0 = z.ReactCurrentDispatcher, t;
    function Z0(c0, M1, g1) {
      {
        if (t === void 0)
          try {
            throw Error();
          } catch (d8) {
            var l2 = d8.stack.trim().match(/\n( *(at )?)/);
            t = l2 && l2[1] || "";
          }
        return `
` + t + c0;
      }
    }
    var U0 = !1, a;
    {
      var Q0 = typeof WeakMap === "function" ? WeakMap : Map;
      a = new Q0;
    }
    function $0(c0, M1) {
      if (!c0 || U0)
        return "";
      {
        var g1 = a.get(c0);
        if (g1 !== void 0)
          return g1;
      }
      var l2;
      U0 = !0;
      var d8 = Error.prepareStackTrace;
      Error.prepareStackTrace = void 0;
      var I1;
      I1 = F0.current, F0.current = null, u();
      try {
        if (M1) {
          var W2 = function() {
            throw Error();
          };
          if (Object.defineProperty(W2.prototype, "props", {
            set: function() {
              throw Error();
            }
          }), typeof Reflect === "object" && Reflect.construct) {
            try {
              Reflect.construct(W2, []);
            } catch (s2) {
              l2 = s2;
            }
            Reflect.construct(c0, [], W2);
          } else {
            try {
              W2.call();
            } catch (s2) {
              l2 = s2;
            }
            c0.call(W2.prototype);
          }
        } else {
          try {
            throw Error();
          } catch (s2) {
            l2 = s2;
          }
          c0();
        }
      } catch (s2) {
        if (s2 && l2 && typeof s2.stack === "string") {
          var z2 = s2.stack.split(`
`), p8 = l2.stack.split(`
`), W6 = z2.length - 1, v6 = p8.length - 1;
          while (W6 >= 1 && v6 >= 0 && z2[W6] !== p8[v6])
            v6--;
          for (;W6 >= 1 && v6 >= 0; W6--, v6--)
            if (z2[W6] !== p8[v6]) {
              if (W6 !== 1 || v6 !== 1)
                do
                  if (W6--, v6--, v6 < 0 || z2[W6] !== p8[v6]) {
                    var AZ = `
` + z2[W6].replace(" at new ", " at ");
                    if (c0.displayName && AZ.includes("<anonymous>"))
                      AZ = AZ.replace("<anonymous>", c0.displayName);
                    if (typeof c0 === "function")
                      a.set(c0, AZ);
                    return AZ;
                  }
                while (W6 >= 1 && v6 >= 0);
              break;
            }
        }
      } finally {
        U0 = !1, F0.current = I1, G0(), Error.prepareStackTrace = d8;
      }
      var L1 = c0 ? c0.displayName || c0.name : "", q2 = L1 ? Z0(L1) : "";
      if (typeof c0 === "function")
        a.set(c0, q2);
      return q2;
    }
    function R0(c0, M1, g1) {
      return $0(c0, !1);
    }
    function X0(c0) {
      var M1 = c0.prototype;
      return !!(M1 && M1.isReactComponent);
    }
    function E0(c0, M1, g1) {
      if (c0 == null)
        return "";
      if (typeof c0 === "function")
        return $0(c0, X0(c0));
      if (typeof c0 === "string")
        return Z0(c0);
      switch (c0) {
        case G:
          return Z0("Suspense");
        case H:
          return Z0("SuspenseList");
      }
      if (typeof c0 === "object")
        switch (c0.$$typeof) {
          case K:
            return R0(c0.render);
          case N:
            return E0(c0.type, M1, g1);
          case q: {
            var l2 = c0, d8 = l2._payload, I1 = l2._init;
            try {
              return E0(I1(d8), M1, g1);
            } catch (W2) {}
          }
        }
      return "";
    }
    var V0 = Object.prototype.hasOwnProperty, u0 = {}, N0 = z.ReactDebugCurrentFrame;
    function q0(c0) {
      if (c0) {
        var M1 = c0._owner, g1 = E0(c0.type, c0._source, M1 ? M1.type : null);
        N0.setExtraStackFrame(g1);
      } else
        N0.setExtraStackFrame(null);
    }
    function A0(c0, M1, g1, l2, d8) {
      {
        var I1 = Function.call.bind(V0);
        for (var W2 in c0)
          if (I1(c0, W2)) {
            var z2 = void 0;
            try {
              if (typeof c0[W2] !== "function") {
                var p8 = Error((l2 || "React class") + ": " + g1 + " type `" + W2 + "` is invalid; it must be a function, usually from the `prop-types` package, but received `" + typeof c0[W2] + "`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");
                throw p8.name = "Invariant Violation", p8;
              }
              z2 = c0[W2](M1, W2, l2, g1, null, "SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED");
            } catch (W6) {
              z2 = W6;
            }
            if (z2 && !(z2 instanceof Error))
              q0(d8), D("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).", l2 || "React class", g1, W2, typeof z2), q0(null);
            if (z2 instanceof Error && !(z2.message in u0))
              u0[z2.message] = !0, q0(d8), D("Failed %s type: %s", g1, z2.message), q0(null);
          }
      }
    }
    var S0 = Array.isArray;
    function a0(c0) {
      return S0(c0);
    }
    function D1(c0) {
      {
        var M1 = typeof Symbol === "function" && Symbol.toStringTag, g1 = M1 && c0[Symbol.toStringTag] || c0.constructor.name || "Object";
        return g1;
      }
    }
    function Y1(c0) {
      try {
        return u1(c0), !1;
      } catch (M1) {
        return !0;
      }
    }
    function u1(c0) {
      return "" + c0;
    }
    function b0(c0) {
      if (Y1(c0))
        return D("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.", D1(c0)), u1(c0);
    }
    var x0 = z.ReactCurrentOwner, m0 = {
      key: !0,
      ref: !0,
      __self: !0,
      __source: !0
    }, e0, p, J0;
    J0 = {};
    function T0(c0) {
      if (V0.call(c0, "ref")) {
        var M1 = Object.getOwnPropertyDescriptor(c0, "ref").get;
        if (M1 && M1.isReactWarning)
          return !1;
      }
      return c0.ref !== void 0;
    }
    function o0(c0) {
      if (V0.call(c0, "key")) {
        var M1 = Object.getOwnPropertyDescriptor(c0, "key").get;
        if (M1 && M1.isReactWarning)
          return !1;
      }
      return c0.key !== void 0;
    }
    function y0(c0, M1) {
      if (typeof c0.ref === "string" && x0.current && M1 && x0.current.stateNode !== M1) {
        var g1 = h(x0.current.type);
        if (!J0[g1])
          D('Component "%s" contains the string ref "%s". Support for string refs will be removed in a future major release. This case cannot be automatically converted to an arrow function. We ask you to manually fix this case by using useRef() or createRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref', h(x0.current.type), c0.ref), J0[g1] = !0;
      }
    }
    function $1(c0, M1) {
      {
        var g1 = function() {
          if (!e0)
            e0 = !0, D("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)", M1);
        };
        g1.isReactWarning = !0, Object.defineProperty(c0, "key", {
          get: g1,
          configurable: !0
        });
      }
    }
    function F1(c0, M1) {
      {
        var g1 = function() {
          if (!p)
            p = !0, D("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)", M1);
        };
        g1.isReactWarning = !0, Object.defineProperty(c0, "ref", {
          get: g1,
          configurable: !0
        });
      }
    }
    var A1 = function(c0, M1, g1, l2, d8, I1, W2) {
      var z2 = {
        $$typeof: Z,
        type: c0,
        key: M1,
        ref: g1,
        props: W2,
        _owner: I1
      };
      if (z2._store = {}, Object.defineProperty(z2._store, "validated", {
        configurable: !1,
        enumerable: !1,
        writable: !0,
        value: !1
      }), Object.defineProperty(z2, "_self", {
        configurable: !1,
        enumerable: !1,
        writable: !1,
        value: l2
      }), Object.defineProperty(z2, "_source", {
        configurable: !1,
        enumerable: !1,
        writable: !1,
        value: d8
      }), Object.freeze)
        Object.freeze(z2.props), Object.freeze(z2);
      return z2;
    };
    function P1(c0, M1, g1, l2, d8) {
      {
        var I1, W2 = {}, z2 = null, p8 = null;
        if (g1 !== void 0)
          b0(g1), z2 = "" + g1;
        if (o0(M1))
          b0(M1.key), z2 = "" + M1.key;
        if (T0(M1))
          p8 = M1.ref, y0(M1, d8);
        for (I1 in M1)
          if (V0.call(M1, I1) && !m0.hasOwnProperty(I1))
            W2[I1] = M1[I1];
        if (c0 && c0.defaultProps) {
          var W6 = c0.defaultProps;
          for (I1 in W6)
            if (W2[I1] === void 0)
              W2[I1] = W6[I1];
        }
        if (z2 || p8) {
          var v6 = typeof c0 === "function" ? c0.displayName || c0.name || "Unknown" : c0;
          if (z2)
            $1(W2, v6);
          if (p8)
            F1(W2, v6);
        }
        return A1(c0, z2, p8, d8, l2, x0.current, W2);
      }
    }
    var { ReactCurrentOwner: S1, ReactDebugCurrentFrame: _1 } = z;
    function a1(c0) {
      if (c0) {
        var M1 = c0._owner, g1 = E0(c0.type, c0._source, M1 ? M1.type : null);
        _1.setExtraStackFrame(g1);
      } else
        _1.setExtraStackFrame(null);
    }
    var U2 = !1;
    function G2(c0) {
      return typeof c0 === "object" && c0 !== null && c0.$$typeof === Z;
    }
    function P2() {
      {
        if (S1.current) {
          var c0 = h(S1.current.type);
          if (c0)
            return `

Check the render method of \`` + c0 + "`.";
        }
        return "";
      }
    }
    function v2(c0) {
      {
        if (c0 !== void 0) {
          var M1 = c0.fileName.replace(/^.*[\\\/]/, ""), g1 = c0.lineNumber;
          return `

Check your code at ` + M1 + ":" + g1 + ".";
        }
        return "";
      }
    }
    var O8 = {};
    function n8(c0) {
      {
        var M1 = P2();
        if (!M1) {
          var g1 = typeof c0 === "string" ? c0 : c0.displayName || c0.name;
          if (g1)
            M1 = `

Check the top-level render call using <` + g1 + ">.";
        }
        return M1;
      }
    }
    function z6(c0, M1) {
      {
        if (!c0._store || c0._store.validated || c0.key != null)
          return;
        c0._store.validated = !0;
        var g1 = n8(M1);
        if (O8[g1])
          return;
        O8[g1] = !0;
        var l2 = "";
        if (c0 && c0._owner && c0._owner !== S1.current)
          l2 = " It was passed a child from " + h(c0._owner.type) + ".";
        a1(c0), D('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.', g1, l2), a1(null);
      }
    }
    function L8(c0, M1) {
      {
        if (typeof c0 !== "object")
          return;
        if (a0(c0))
          for (var g1 = 0;g1 < c0.length; g1++) {
            var l2 = c0[g1];
            if (G2(l2))
              z6(l2, M1);
          }
        else if (G2(c0)) {
          if (c0._store)
            c0._store.validated = !0;
        } else if (c0) {
          var d8 = R(c0);
          if (typeof d8 === "function") {
            if (d8 !== c0.entries) {
              var I1 = d8.call(c0), W2;
              while (!(W2 = I1.next()).done)
                if (G2(W2.value))
                  z6(W2.value, M1);
            }
          }
        }
      }
    }
    function R8(c0) {
      {
        var M1 = c0.type;
        if (M1 === null || M1 === void 0 || typeof M1 === "string")
          return;
        var g1;
        if (typeof M1 === "function")
          g1 = M1.propTypes;
        else if (typeof M1 === "object" && (M1.$$typeof === K || M1.$$typeof === N))
          g1 = M1.propTypes;
        else
          return;
        if (g1) {
          var l2 = h(M1);
          A0(g1, c0.props, "prop", l2, c0);
        } else if (M1.PropTypes !== void 0 && !U2) {
          U2 = !0;
          var d8 = h(M1);
          D("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?", d8 || "Unknown");
        }
        if (typeof M1.getDefaultProps === "function" && !M1.getDefaultProps.isReactClassApproved)
          D("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.");
      }
    }
    function w0(c0) {
      {
        var M1 = Object.keys(c0.props);
        for (var g1 = 0;g1 < M1.length; g1++) {
          var l2 = M1[g1];
          if (l2 !== "children" && l2 !== "key") {
            a1(c0), D("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.", l2), a1(null);
            break;
          }
        }
        if (c0.ref !== null)
          a1(c0), D("Invalid attribute `ref` supplied to `React.Fragment`."), a1(null);
      }
    }
    var P0 = {};
    function l0(c0, M1, g1, l2, d8, I1) {
      {
        var W2 = S(c0);
        if (!W2) {
          var z2 = "";
          if (c0 === void 0 || typeof c0 === "object" && c0 !== null && Object.keys(c0).length === 0)
            z2 += " You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.";
          var p8 = v2(d8);
          if (p8)
            z2 += p8;
          else
            z2 += P2();
          var W6;
          if (c0 === null)
            W6 = "null";
          else if (a0(c0))
            W6 = "array";
          else if (c0 !== void 0 && c0.$$typeof === Z)
            W6 = "<" + (h(c0.type) || "Unknown") + " />", z2 = " Did you accidentally export a JSX literal instead of a component?";
          else
            W6 = typeof c0;
          D("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s", W6, z2);
        }
        var v6 = P1(c0, M1, g1, d8, I1);
        if (v6 == null)
          return v6;
        if (W2) {
          var AZ = M1.children;
          if (AZ !== void 0)
            if (l2)
              if (a0(AZ)) {
                for (var L1 = 0;L1 < AZ.length; L1++)
                  L8(AZ[L1], c0);
                if (Object.freeze)
                  Object.freeze(AZ);
              } else
                D("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");
            else
              L8(AZ, c0);
        }
        if (V0.call(M1, "key")) {
          var q2 = h(c0), s2 = Object.keys(M1).filter(function(A2) {
            return A2 !== "key";
          }), d0 = s2.length > 0 ? "{key: someKey, " + s2.join(": ..., ") + ": ...}" : "{key: someKey}";
          if (!P0[q2 + d0]) {
            var d1 = s2.length > 0 ? "{" + s2.join(": ..., ") + ": ...}" : "{}";
            D(`A props object containing a "key" prop is being spread into JSX:
  let props = %s;
  <%s {...props} />
React keys must be passed directly to JSX without using spread:
  let props = %s;
  <%s key={someKey} {...props} />`, d0, q2, d1, q2), P0[q2 + d0] = !0;
          }
        }
        if (c0 === $)
          w0(v6);
        else
          R8(v6);
        return v6;
      }
    }
    function z1(c0, M1, g1) {
      return l0(c0, M1, g1, !0);
    }
    function J2(c0, M1, g1) {
      return l0(c0, M1, g1, !1);
    }
    var N2 = J2, X8 = z1;
    CE1.Fragment = $, CE1.jsx = N2, CE1.jsxs = X8;
  })();
});

// node_modules/inline-style-parser/index.js
var iI0 = SX(($G8, nI0) => {
  var pI0 = /\/\*[^*]*\*+([^/*][^*]*\*+)*\//g, Fz1 = /\n/g, Uz1 = /^\s*/, Lz1 = /^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/, Rz1 = /^:\s*/, Ez1 = /^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/, Oz1 = /^[;\s]*/, zz1 = /^\s+|\s+$/g, Dz1 = `
`, uI0 = "/", cI0 = "*", tz = "", Mz1 = "comment", Az1 = "declaration";
  nI0.exports = function(Z, J) {
    if (typeof Z !== "string")
      throw new TypeError("First argument must be a string");
    if (!Z)
      return [];
    J = J || {};
    var $ = 1, X = 1;
    function Y(R) {
      var z = R.match(Fz1);
      if (z)
        $ += z.length;
      var D = R.lastIndexOf(Dz1);
      X = ~D ? R.length - D : X + R.length;
    }
    function Q() {
      var R = { line: $, column: X };
      return function(z) {
        return z.position = new W(R), N(), z;
      };
    }
    function W(R) {
      this.start = R, this.end = { line: $, column: X }, this.source = J.source;
    }
    W.prototype.content = Z;
    var K = [];
    function G(R) {
      var z = new Error(J.source + ":" + $ + ":" + X + ": " + R);
      if (z.reason = R, z.filename = J.source, z.line = $, z.column = X, z.source = Z, J.silent)
        K.push(z);
      else
        throw z;
    }
    function H(R) {
      var z = R.exec(Z);
      if (!z)
        return;
      var D = z[0];
      return Y(D), Z = Z.slice(D.length), z;
    }
    function N() {
      H(Uz1);
    }
    function q(R) {
      var z;
      R = R || [];
      while (z = U())
        if (z !== !1)
          R.push(z);
      return R;
    }
    function U() {
      var R = Q();
      if (uI0 != Z.charAt(0) || cI0 != Z.charAt(1))
        return;
      var z = 2;
      while (tz != Z.charAt(z) && (cI0 != Z.charAt(z) || uI0 != Z.charAt(z + 1)))
        ++z;
      if (z += 2, tz === Z.charAt(z - 1))
        return G("End of comment missing");
      var D = Z.slice(2, z - 2);
      return X += 2, Y(D), Z = Z.slice(z), X += 2, R({
        type: Mz1,
        comment: D
      });
    }
    function F() {
      var R = Q(), z = H(Lz1);
      if (!z)
        return;
      if (U(), !H(Rz1))
        return G("property missing ':'");
      var D = H(Ez1), A = R({
        type: Az1,
        property: lI0(z[0].replace(pI0, tz)),
        value: D ? lI0(D[0].replace(pI0, tz)) : tz
      });
      return H(Oz1), A;
    }
    function E() {
      var R = [];
      q(R);
      var z;
      while (z = F())
        if (z !== !1)
          R.push(z), q(R);
      return R;
    }
    return N(), E();
  };
  function lI0(Z) {
    return Z ? Z.replace(zz1, tz) : tz;
  }
});

// node_modules/style-to-object/cjs/index.js
var oI0 = SX((mI) => {
  var Bz1 = mI && mI.__importDefault || function(Z) {
    return Z && Z.__esModule ? Z : { default: Z };
  };
  Object.defineProperty(mI, "__esModule", { value: !0 });
  mI.default = jz1;
  var wz1 = Bz1(iI0());
  function jz1(Z, J) {
    var $ = null;
    if (!Z || typeof Z !== "string")
      return $;
    var X = (0, wz1.default)(Z), Y = typeof J === "function";
    return X.forEach(function(Q) {
      if (Q.type !== "declaration")
        return;
      var { property: W, value: K } = Q;
      if (Y)
        J(W, K, Q);
      else if (K)
        $ = $ || {}, $[W] = K;
    }), $;
  }
});

// node_modules/micromark/node_modules/debug/node_modules/ms/index.js
var jP0 = SX((vF8, wP0) => {
  var VB = 1000, IB = VB * 60, PB = IB * 60, Q4 = PB * 24, XD1 = Q4 * 7, YD1 = Q4 * 365.25;
  wP0.exports = function(Z, J) {
    J = J || {};
    var $ = typeof Z;
    if ($ === "string" && Z.length > 0)
      return QD1(Z);
    else if ($ === "number" && isFinite(Z))
      return J.long ? KD1(Z) : WD1(Z);
    throw new Error("val is not a non-empty string or a valid number. val=" + JSON.stringify(Z));
  };
  function QD1(Z) {
    if (Z = String(Z), Z.length > 100)
      return;
    var J = /^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(Z);
    if (!J)
      return;
    var $ = parseFloat(J[1]), X = (J[2] || "ms").toLowerCase();
    switch (X) {
      case "years":
      case "year":
      case "yrs":
      case "yr":
      case "y":
        return $ * YD1;
      case "weeks":
      case "week":
      case "w":
        return $ * XD1;
      case "days":
      case "day":
      case "d":
        return $ * Q4;
      case "hours":
      case "hour":
      case "hrs":
      case "hr":
      case "h":
        return $ * PB;
      case "minutes":
      case "minute":
      case "mins":
      case "min":
      case "m":
        return $ * IB;
      case "seconds":
      case "second":
      case "secs":
      case "sec":
      case "s":
        return $ * VB;
      case "milliseconds":
      case "millisecond":
      case "msecs":
      case "msec":
      case "ms":
        return $;
      default:
        return;
    }
  }
  function WD1(Z) {
    var J = Math.abs(Z);
    if (J >= Q4)
      return Math.round(Z / Q4) + "d";
    if (J >= PB)
      return Math.round(Z / PB) + "h";
    if (J >= IB)
      return Math.round(Z / IB) + "m";
    if (J >= VB)
      return Math.round(Z / VB) + "s";
    return Z + "ms";
  }
  function KD1(Z) {
    var J = Math.abs(Z);
    if (J >= Q4)
      return uy(Z, J, Q4, "day");
    if (J >= PB)
      return uy(Z, J, PB, "hour");
    if (J >= IB)
      return uy(Z, J, IB, "minute");
    if (J >= VB)
      return uy(Z, J, VB, "second");
    return Z + " ms";
  }
  function uy(Z, J, $, X) {
    var Y = J >= $ * 1.5;
    return Math.round(Z / $) + " " + X + (Y ? "s" : "");
  }
});

// node_modules/micromark/node_modules/debug/src/common.js
var _P0 = SX((SF8, TP0) => {
  function GD1(Z) {
    $.debug = $, $.default = $, $.coerce = G, $.disable = Q, $.enable = Y, $.enabled = W, $.humanize = jP0(), $.destroy = H, Object.keys(Z).forEach((N) => {
      $[N] = Z[N];
    }), $.names = [], $.skips = [], $.formatters = {};
    function J(N) {
      let q = 0;
      for (let U = 0;U < N.length; U++)
        q = (q << 5) - q + N.charCodeAt(U), q |= 0;
      return $.colors[Math.abs(q) % $.colors.length];
    }
    $.selectColor = J;
    function $(N) {
      let q, U = null, F, E;
      function R(...z) {
        if (!R.enabled)
          return;
        let D = R, A = Number(/* @__PURE__ */ new Date), B = A - (q || A);
        if (D.diff = B, D.prev = q, D.curr = A, q = A, z[0] = $.coerce(z[0]), typeof z[0] !== "string")
          z.unshift("%O");
        let T = 0;
        z[0] = z[0].replace(/%([a-zA-Z%])/g, (V, P) => {
          if (V === "%%")
            return "%";
          T++;
          let I = $.formatters[P];
          if (typeof I === "function") {
            let S = z[T];
            V = I.call(D, S), z.splice(T, 1), T--;
          }
          return V;
        }), $.formatArgs.call(D, z), (D.log || $.log).apply(D, z);
      }
      if (R.namespace = N, R.useColors = $.useColors(), R.color = $.selectColor(N), R.extend = X, R.destroy = $.destroy, Object.defineProperty(R, "enabled", {
        enumerable: !0,
        configurable: !1,
        get: () => {
          if (U !== null)
            return U;
          if (F !== $.namespaces)
            F = $.namespaces, E = $.enabled(N);
          return E;
        },
        set: (z) => {
          U = z;
        }
      }), typeof $.init === "function")
        $.init(R);
      return R;
    }
    function X(N, q) {
      let U = $(this.namespace + (typeof q === "undefined" ? ":" : q) + N);
      return U.log = this.log, U;
    }
    function Y(N) {
      $.save(N), $.namespaces = N, $.names = [], $.skips = [];
      let q, U = (typeof N === "string" ? N : "").split(/[\s,]+/), F = U.length;
      for (q = 0;q < F; q++) {
        if (!U[q])
          continue;
        if (N = U[q].replace(/\*/g, ".*?"), N[0] === "-")
          $.skips.push(new RegExp("^" + N.slice(1) + "$"));
        else
          $.names.push(new RegExp("^" + N + "$"));
      }
    }
    function Q() {
      let N = [
        ...$.names.map(K),
        ...$.skips.map(K).map((q) => "-" + q)
      ].join(",");
      return $.enable(""), N;
    }
    function W(N) {
      if (N[N.length - 1] === "*")
        return !0;
      let q, U;
      for (q = 0, U = $.skips.length;q < U; q++)
        if ($.skips[q].test(N))
          return !1;
      for (q = 0, U = $.names.length;q < U; q++)
        if ($.names[q].test(N))
          return !0;
      return !1;
    }
    function K(N) {
      return N.toString().substring(2, N.toString().length - 2).replace(/\.\*\?$/, "*");
    }
    function G(N) {
      if (N instanceof Error)
        return N.stack || N.message;
      return N;
    }
    function H() {
      console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");
    }
    return $.enable($.load()), $;
  }
  TP0.exports = GD1;
});

// node_modules/micromark/node_modules/debug/src/browser.js
var IP0 = SX((VP0, ly) => {
  VP0.formatArgs = ND1;
  VP0.save = qD1;
  VP0.load = FD1;
  VP0.useColors = HD1;
  VP0.storage = UD1();
  VP0.destroy = (() => {
    let Z = !1;
    return () => {
      if (!Z)
        Z = !0, console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.");
    };
  })();
  VP0.colors = [
    "#0000CC",
    "#0000FF",
    "#0033CC",
    "#0033FF",
    "#0066CC",
    "#0066FF",
    "#0099CC",
    "#0099FF",
    "#00CC00",
    "#00CC33",
    "#00CC66",
    "#00CC99",
    "#00CCCC",
    "#00CCFF",
    "#3300CC",
    "#3300FF",
    "#3333CC",
    "#3333FF",
    "#3366CC",
    "#3366FF",
    "#3399CC",
    "#3399FF",
    "#33CC00",
    "#33CC33",
    "#33CC66",
    "#33CC99",
    "#33CCCC",
    "#33CCFF",
    "#6600CC",
    "#6600FF",
    "#6633CC",
    "#6633FF",
    "#66CC00",
    "#66CC33",
    "#9900CC",
    "#9900FF",
    "#9933CC",
    "#9933FF",
    "#99CC00",
    "#99CC33",
    "#CC0000",
    "#CC0033",
    "#CC0066",
    "#CC0099",
    "#CC00CC",
    "#CC00FF",
    "#CC3300",
    "#CC3333",
    "#CC3366",
    "#CC3399",
    "#CC33CC",
    "#CC33FF",
    "#CC6600",
    "#CC6633",
    "#CC9900",
    "#CC9933",
    "#CCCC00",
    "#CCCC33",
    "#FF0000",
    "#FF0033",
    "#FF0066",
    "#FF0099",
    "#FF00CC",
    "#FF00FF",
    "#FF3300",
    "#FF3333",
    "#FF3366",
    "#FF3399",
    "#FF33CC",
    "#FF33FF",
    "#FF6600",
    "#FF6633",
    "#FF9900",
    "#FF9933",
    "#FFCC00",
    "#FFCC33"
  ];
  function HD1() {
    if (typeof window !== "undefined" && window.process && (window.process.type === "renderer" || window.process.__nwjs))
      return !0;
    if (typeof navigator !== "undefined" && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))
      return !1;
    let Z;
    return typeof document !== "undefined" && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance || typeof window !== "undefined" && window.console && (window.console.firebug || window.console.exception && window.console.table) || typeof navigator !== "undefined" && navigator.userAgent && (Z = navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)) && parseInt(Z[1], 10) >= 31 || typeof navigator !== "undefined" && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/);
  }
  function ND1(Z) {
    if (Z[0] = (this.useColors ? "%c" : "") + this.namespace + (this.useColors ? " %c" : " ") + Z[0] + (this.useColors ? "%c " : " ") + "+" + ly.exports.humanize(this.diff), !this.useColors)
      return;
    let J = "color: " + this.color;
    Z.splice(1, 0, J, "color: inherit");
    let $ = 0, X = 0;
    Z[0].replace(/%[a-zA-Z%]/g, (Y) => {
      if (Y === "%%")
        return;
      if ($++, Y === "%c")
        X = $;
    }), Z.splice(X, 0, J);
  }
  VP0.log = console.debug || console.log || (() => {});
  function qD1(Z) {
    try {
      if (Z)
        VP0.storage.setItem("debug", Z);
      else
        VP0.storage.removeItem("debug");
    } catch (J) {}
  }
  function FD1() {
    let Z;
    try {
      Z = VP0.storage.getItem("debug");
    } catch (J) {}
    if (!Z && typeof process !== "undefined" && "env" in process)
      Z = process.env.DEBUG;
    return Z;
  }
  function UD1() {
    try {
      return localStorage;
    } catch (Z) {}
  }
  ly.exports = _P0()(VP0);
  var { formatters: LD1 } = ly.exports;
  LD1.j = function(Z) {
    try {
      return JSON.stringify(Z);
    } catch (J) {
      return "[UnexpectedJSONParseError]: " + J.message;
    }
  };
});

// node_modules/extend/index.js
var wC0 = SX((OR8, BC0) => {
  var Yg = Object.prototype.hasOwnProperty, AC0 = Object.prototype.toString, RC0 = Object.defineProperty, EC0 = Object.getOwnPropertyDescriptor, OC0 = function Z(J) {
    if (typeof Array.isArray === "function")
      return Array.isArray(J);
    return AC0.call(J) === "[object Array]";
  }, zC0 = function Z(J) {
    if (!J || AC0.call(J) !== "[object Object]")
      return !1;
    var $ = Yg.call(J, "constructor"), X = J.constructor && J.constructor.prototype && Yg.call(J.constructor.prototype, "isPrototypeOf");
    if (J.constructor && !$ && !X)
      return !1;
    var Y;
    for (Y in J)
      ;
    return typeof Y === "undefined" || Yg.call(J, Y);
  }, DC0 = function Z(J, $) {
    if (RC0 && $.name === "__proto__")
      RC0(J, $.name, {
        enumerable: !0,
        configurable: !0,
        value: $.newValue,
        writable: !0
      });
    else
      J[$.name] = $.newValue;
  }, MC0 = function Z(J, $) {
    if ($ === "__proto__") {
      if (!Yg.call(J, $))
        return;
      else if (EC0)
        return EC0(J, $).value;
    }
    return J[$];
  };
  BC0.exports = function Z() {
    var J, $, X, Y, Q, W, K = arguments[0], G = 1, H = arguments.length, N = !1;
    if (typeof K === "boolean")
      N = K, K = arguments[1] || {}, G = 2;
    if (K == null || typeof K !== "object" && typeof K !== "function")
      K = {};
    for (;G < H; ++G)
      if (J = arguments[G], J != null) {
        for ($ in J)
          if (X = MC0(K, $), Y = MC0(J, $), K !== Y) {
            if (N && Y && (zC0(Y) || (Q = OC0(Y)))) {
              if (Q)
                Q = !1, W = X && OC0(X) ? X : [];
              else
                W = X && zC0(X) ? X : {};
              DC0(K, { name: $, newValue: Z(N, W, Y) });
            } else if (typeof Y !== "undefined")
              DC0(K, { name: $, newValue: Y });
          }
      }
    return K;
  };
});

// src/index.tsx
var fw = t2(J7(), 1), gb0 = t2(gc(), 1);

// node_modules/streamlit-component-lib/dist/StreamlitReact.js
var AW0 = t2(qY0(), 1), hO = t2(BY0(), 1);

// node_modules/apache-arrow/node_modules/tslib/tslib.es6.mjs
function jY0(Z, J) {
  var $ = {};
  for (var X in Z)
    if (Object.prototype.hasOwnProperty.call(Z, X) && J.indexOf(X) < 0)
      $[X] = Z[X];
  if (Z != null && typeof Object.getOwnPropertySymbols === "function") {
    for (var Y = 0, X = Object.getOwnPropertySymbols(Z);Y < X.length; Y++)
      if (J.indexOf(X[Y]) < 0 && Object.prototype.propertyIsEnumerable.call(Z, X[Y]))
        $[X[Y]] = Z[X[Y]];
  }
  return $;
}
function j8(Z, J, $, X) {
  function Y(Q) {
    return Q instanceof $ ? Q : new $(function(W) {
      W(Q);
    });
  }
  return new ($ || ($ = Promise))(function(Q, W) {
    function K(N) {
      try {
        H(X.next(N));
      } catch (q) {
        W(q);
      }
    }
    function G(N) {
      try {
        H(X.throw(N));
      } catch (q) {
        W(q);
      }
    }
    function H(N) {
      N.done ? Q(N.value) : Y(N.value).then(K, G);
    }
    H((X = X.apply(Z, J || [])).next());
  });
}
function wY0(Z) {
  var J = typeof Symbol === "function" && Symbol.iterator, $ = J && Z[J], X = 0;
  if ($)
    return $.call(Z);
  if (Z && typeof Z.length === "number")
    return {
      next: function() {
        if (Z && X >= Z.length)
          Z = void 0;
        return { value: Z && Z[X++], done: !Z };
      }
    };
  throw new TypeError(J ? "Object is not iterable." : "Symbol.iterator is not defined.");
}
function NZ(Z) {
  return this instanceof NZ ? (this.v = Z, this) : new NZ(Z);
}
function JK(Z, J, $) {
  if (!Symbol.asyncIterator)
    throw new TypeError("Symbol.asyncIterator is not defined.");
  var X = $.apply(Z, J || []), Y, Q = [];
  return Y = Object.create((typeof AsyncIterator === "function" ? AsyncIterator : Object).prototype), K("next"), K("throw"), K("return", W), Y[Symbol.asyncIterator] = function() {
    return this;
  }, Y;
  function W(F) {
    return function(E) {
      return Promise.resolve(E).then(F, q);
    };
  }
  function K(F, E) {
    if (X[F]) {
      if (Y[F] = function(R) {
        return new Promise(function(z, D) {
          Q.push([F, R, z, D]) > 1 || G(F, R);
        });
      }, E)
        Y[F] = E(Y[F]);
    }
  }
  function G(F, E) {
    try {
      H(X[F](E));
    } catch (R) {
      U(Q[0][3], R);
    }
  }
  function H(F) {
    F.value instanceof NZ ? Promise.resolve(F.value.v).then(N, q) : U(Q[0][2], F);
  }
  function N(F) {
    G("next", F);
  }
  function q(F) {
    G("throw", F);
  }
  function U(F, E) {
    if (F(E), Q.shift(), Q.length)
      G(Q[0][0], Q[0][1]);
  }
}
function CD(Z) {
  var J, $;
  return J = {}, X("next"), X("throw", function(Y) {
    throw Y;
  }), X("return"), J[Symbol.iterator] = function() {
    return this;
  }, J;
  function X(Y, Q) {
    J[Y] = Z[Y] ? function(W) {
      return ($ = !$) ? { value: NZ(Z[Y](W)), done: !1 } : Q ? Q(W) : W;
    } : Q;
  }
}
function mG(Z) {
  if (!Symbol.asyncIterator)
    throw new TypeError("Symbol.asyncIterator is not defined.");
  var J = Z[Symbol.asyncIterator], $;
  return J ? J.call(Z) : (Z = typeof wY0 === "function" ? wY0(Z) : Z[Symbol.iterator](), $ = {}, X("next"), X("throw"), X("return"), $[Symbol.asyncIterator] = function() {
    return this;
  }, $);
  function X(Q) {
    $[Q] = Z[Q] && function(W) {
      return new Promise(function(K, G) {
        W = Z[Q](W), Y(K, G, W.done, W.value);
      });
    };
  }
  function Y(Q, W, K, G) {
    Promise.resolve(G).then(function(H) {
      Q({ value: H, done: K });
    }, W);
  }
}

// node_modules/apache-arrow/util/buffer.mjs
var sc = {};
y9(sc, {
  toUint8ClampedArrayIterator: () => an0,
  toUint8ClampedArrayAsyncIterator: () => Yi0,
  toUint8ClampedArray: () => pn0,
  toUint8ArrayIterator: () => nc,
  toUint8ArrayAsyncIterator: () => ic,
  toUint8Array: () => YZ,
  toUint32ArrayIterator: () => in0,
  toUint32ArrayAsyncIterator: () => Ji0,
  toUint32Array: () => yn0,
  toUint16ArrayIterator: () => nn0,
  toUint16ArrayAsyncIterator: () => Zi0,
  toUint16Array: () => xn0,
  toInt8ArrayIterator: () => un0,
  toInt8ArrayAsyncIterator: () => rn0,
  toInt8Array: () => fn0,
  toInt32ArrayIterator: () => ln0,
  toInt32ArrayAsyncIterator: () => en0,
  toInt32Array: () => wO,
  toInt16ArrayIterator: () => cn0,
  toInt16ArrayAsyncIterator: () => tn0,
  toInt16Array: () => hn0,
  toFloat64ArrayIterator: () => sn0,
  toFloat64ArrayAsyncIterator: () => Xi0,
  toFloat64Array: () => dn0,
  toFloat32ArrayIterator: () => on0,
  toFloat32ArrayAsyncIterator: () => $i0,
  toFloat32Array: () => mn0,
  toBigUint64Array: () => gn0,
  toBigInt64Array: () => bn0,
  toArrayBufferViewIterator: () => KN,
  toArrayBufferViewAsyncIterator: () => pG,
  toArrayBufferView: () => gZ,
  rebaseValueOffsets: () => OT,
  memcpy: () => kD,
  joinUint8Arrays: () => XK,
  compareArrayLike: () => oc
});

// node_modules/apache-arrow/util/utf8.mjs
var Cn0 = new TextDecoder("utf-8"), RT = (Z) => Cn0.decode(Z), kn0 = /* @__PURE__ */ new TextEncoder, HL = (Z) => kn0.encode(Z);

// node_modules/apache-arrow/util/compat.mjs
var [xC1, lk] = (() => {
  let Z = () => {
    throw new Error("BigInt is not available in this environment");
  };
  function J() {
    throw Z();
  }
  return J.asIntN = () => {
    throw Z();
  }, J.asUintN = () => {
    throw Z();
  }, typeof BigInt !== "undefined" ? [BigInt, !0] : [J, !1];
})(), [aK, yC1] = (() => {
  let Z = () => {
    throw new Error("BigInt64Array is not available in this environment");
  };

  class J {
    static get BYTES_PER_ELEMENT() {
      return 8;
    }
    static of() {
      throw Z();
    }
    static from() {
      throw Z();
    }
    constructor() {
      throw Z();
    }
  }
  return typeof BigInt64Array !== "undefined" ? [BigInt64Array, !0] : [J, !1];
})(), [rK, gC1] = (() => {
  let Z = () => {
    throw new Error("BigUint64Array is not available in this environment");
  };

  class J {
    static get BYTES_PER_ELEMENT() {
      return 8;
    }
    static of() {
      throw Z();
    }
    static from() {
      throw Z();
    }
    constructor() {
      throw Z();
    }
  }
  return typeof BigUint64Array !== "undefined" ? [BigUint64Array, !0] : [J, !1];
})();
var vn0 = (Z) => typeof Z === "number", TY0 = (Z) => typeof Z === "boolean", fX = (Z) => typeof Z === "function", OW = (Z) => Z != null && Object(Z) === Z, $K = (Z) => {
  return OW(Z) && fX(Z.then);
};
var dG = (Z) => {
  return OW(Z) && fX(Z[Symbol.iterator]);
}, tK = (Z) => {
  return OW(Z) && fX(Z[Symbol.asyncIterator]);
}, nk = (Z) => {
  return OW(Z) && OW(Z.schema);
};
var ik = (Z) => {
  return OW(Z) && "done" in Z && "value" in Z;
};
var ok = (Z) => {
  return OW(Z) && fX(Z.stat) && vn0(Z.fd);
};
var sk = (Z) => {
  return OW(Z) && ET(Z.body);
}, ak = (Z) => ("_getDOMStream" in Z) && ("_getNodeStream" in Z), _Y0 = (Z) => {
  return OW(Z) && fX(Z.abort) && fX(Z.getWriter) && !ak(Z);
}, ET = (Z) => {
  return OW(Z) && fX(Z.cancel) && fX(Z.getReader) && !ak(Z);
}, VY0 = (Z) => {
  return OW(Z) && fX(Z.end) && fX(Z.write) && TY0(Z.writable) && !ak(Z);
}, rk = (Z) => {
  return OW(Z) && fX(Z.read) && fX(Z.pipe) && TY0(Z.readable) && !ak(Z);
}, IY0 = (Z) => {
  return OW(Z) && fX(Z.clear) && fX(Z.bytes) && fX(Z.position) && fX(Z.setPosition) && fX(Z.capacity) && fX(Z.getBufferIdentifier) && fX(Z.createLong);
};

// node_modules/apache-arrow/util/buffer.mjs
var lc = typeof SharedArrayBuffer !== "undefined" ? SharedArrayBuffer : ArrayBuffer;
function Sn0(Z) {
  let J = Z[0] ? [Z[0]] : [], $, X, Y, Q;
  for (let W, K, G = 0, H = 0, N = Z.length;++G < N; ) {
    if (W = J[H], K = Z[G], !W || !K || W.buffer !== K.buffer || K.byteOffset < W.byteOffset) {
      K && (J[++H] = K);
      continue;
    }
    if ({ byteOffset: $, byteLength: Y } = W, { byteOffset: X, byteLength: Q } = K, $ + Y < X || X + Q < $) {
      K && (J[++H] = K);
      continue;
    }
    J[H] = new Uint8Array(W.buffer, $, X - $ + Q);
  }
  return J;
}
function kD(Z, J, $ = 0, X = J.byteLength) {
  let Y = Z.byteLength, Q = new Uint8Array(Z.buffer, Z.byteOffset, Y), W = new Uint8Array(J.buffer, J.byteOffset, Math.min(X, Y));
  return Q.set(W, $), Z;
}
function XK(Z, J) {
  let $ = Sn0(Z), X = $.reduce((N, q) => N + q.byteLength, 0), Y, Q, W, K = 0, G = -1, H = Math.min(J || Number.POSITIVE_INFINITY, X);
  for (let N = $.length;++G < N; ) {
    if (Y = $[G], Q = Y.subarray(0, Math.min(Y.length, H - K)), H <= K + Q.length) {
      if (Q.length < Y.length)
        $[G] = Y.subarray(Q.length);
      else if (Q.length === Y.length)
        G++;
      W ? kD(W, Q, K) : W = Q;
      break;
    }
    kD(W || (W = new Uint8Array(H)), Q, K), K += Q.length;
  }
  return [W || new Uint8Array(0), $.slice(G), X - (W ? W.byteLength : 0)];
}
function gZ(Z, J) {
  let $ = ik(J) ? J.value : J;
  if ($ instanceof Z) {
    if (Z === Uint8Array)
      return new Z($.buffer, $.byteOffset, $.byteLength);
    return $;
  }
  if (!$)
    return new Z(0);
  if (typeof $ === "string")
    $ = HL($);
  if ($ instanceof ArrayBuffer)
    return new Z($);
  if ($ instanceof lc)
    return new Z($);
  if (IY0($))
    return gZ(Z, $.bytes());
  return !ArrayBuffer.isView($) ? Z.from($) : $.byteLength <= 0 ? new Z(0) : new Z($.buffer, $.byteOffset, $.byteLength / Z.BYTES_PER_ELEMENT);
}
var fn0 = (Z) => gZ(Int8Array, Z), hn0 = (Z) => gZ(Int16Array, Z), wO = (Z) => gZ(Int32Array, Z), bn0 = (Z) => gZ(aK, Z), YZ = (Z) => gZ(Uint8Array, Z), xn0 = (Z) => gZ(Uint16Array, Z), yn0 = (Z) => gZ(Uint32Array, Z), gn0 = (Z) => gZ(rK, Z), mn0 = (Z) => gZ(Float32Array, Z), dn0 = (Z) => gZ(Float64Array, Z), pn0 = (Z) => gZ(Uint8ClampedArray, Z), cc = (Z) => {
  return Z.next(), Z;
};
function* KN(Z, J) {
  let $ = function* (Y) {
    yield Y;
  }, X = typeof J === "string" ? $(J) : ArrayBuffer.isView(J) ? $(J) : J instanceof ArrayBuffer ? $(J) : J instanceof lc ? $(J) : !dG(J) ? $(J) : J;
  return yield* cc(function* (Y) {
    let Q = null;
    do
      Q = Y.next(yield gZ(Z, Q));
    while (!Q.done);
  }(X[Symbol.iterator]())), new Z;
}
var un0 = (Z) => KN(Int8Array, Z), cn0 = (Z) => KN(Int16Array, Z), ln0 = (Z) => KN(Int32Array, Z), nc = (Z) => KN(Uint8Array, Z), nn0 = (Z) => KN(Uint16Array, Z), in0 = (Z) => KN(Uint32Array, Z), on0 = (Z) => KN(Float32Array, Z), sn0 = (Z) => KN(Float64Array, Z), an0 = (Z) => KN(Uint8ClampedArray, Z);
function pG(Z, J) {
  return JK(this, arguments, function* $() {
    if ($K(J))
      return yield NZ(yield NZ(yield* CD(mG(pG(Z, yield NZ(J))))));
    let X = function(W) {
      return JK(this, arguments, function* () {
        yield yield NZ(yield NZ(W));
      });
    }, Y = function(W) {
      return JK(this, arguments, function* () {
        yield NZ(yield* CD(mG(cc(function* (K) {
          let G = null;
          do
            G = K.next(yield G === null || G === void 0 ? void 0 : G.value);
          while (!G.done);
        }(W[Symbol.iterator]())))));
      });
    }, Q = typeof J === "string" ? X(J) : ArrayBuffer.isView(J) ? X(J) : J instanceof ArrayBuffer ? X(J) : J instanceof lc ? X(J) : dG(J) ? Y(J) : !tK(J) ? X(J) : J;
    return yield NZ(yield* CD(mG(cc(function(W) {
      return JK(this, arguments, function* () {
        let K = null;
        do
          K = yield NZ(W.next(yield yield NZ(gZ(Z, K))));
        while (!K.done);
      });
    }(Q[Symbol.asyncIterator]()))))), yield NZ(new Z);
  });
}
var rn0 = (Z) => pG(Int8Array, Z), tn0 = (Z) => pG(Int16Array, Z), en0 = (Z) => pG(Int32Array, Z), ic = (Z) => pG(Uint8Array, Z), Zi0 = (Z) => pG(Uint16Array, Z), Ji0 = (Z) => pG(Uint32Array, Z), $i0 = (Z) => pG(Float32Array, Z), Xi0 = (Z) => pG(Float64Array, Z), Yi0 = (Z) => pG(Uint8ClampedArray, Z);
function OT(Z, J, $) {
  if (Z !== 0) {
    $ = $.slice(0, J + 1);
    for (let X = -1;++X <= J; )
      $[X] += Z;
  }
  return $;
}
function oc(Z, J) {
  let $ = 0, X = Z.length;
  if (X !== J.length)
    return !1;
  if (X > 0)
    do
      if (Z[$] !== J[$])
        return !1;
    while (++$ < X);
  return !0;
}

// node_modules/apache-arrow/io/adapters.mjs
var ZQ = {
  fromIterable(Z) {
    return tk(Qi0(Z));
  },
  fromAsyncIterable(Z) {
    return tk(Wi0(Z));
  },
  fromDOMStream(Z) {
    return tk(Ki0(Z));
  },
  fromNodeStream(Z) {
    return tk(Gi0(Z));
  },
  toDOMStream(Z, J) {
    throw new Error('"toDOMStream" not available in this environment');
  },
  toNodeStream(Z, J) {
    throw new Error('"toNodeStream" not available in this environment');
  }
}, tk = (Z) => {
  return Z.next(), Z;
};
function* Qi0(Z) {
  let J, $ = !1, X = [], Y, Q, W, K = 0;
  function G() {
    if (Q === "peek")
      return XK(X, W)[0];
    return [Y, X, K] = XK(X, W), Y;
  }
  ({ cmd: Q, size: W } = yield null);
  let H = nc(Z)[Symbol.iterator]();
  try {
    do {
      if ({ done: J, value: Y } = Number.isNaN(W - K) ? H.next() : H.next(W - K), !J && Y.byteLength > 0)
        X.push(Y), K += Y.byteLength;
      if (J || W <= K)
        do
          ({ cmd: Q, size: W } = yield G());
        while (W < K);
    } while (!J);
  } catch (N) {
    ($ = !0) && typeof H.throw === "function" && H.throw(N);
  } finally {
    $ === !1 && typeof H.return === "function" && H.return(null);
  }
  return null;
}
function Wi0(Z) {
  return JK(this, arguments, function* J() {
    let $, X = !1, Y = [], Q, W, K, G = 0;
    function H() {
      if (W === "peek")
        return XK(Y, K)[0];
      return [Q, Y, G] = XK(Y, K), Q;
    }
    ({ cmd: W, size: K } = yield yield NZ(null));
    let N = ic(Z)[Symbol.asyncIterator]();
    try {
      do {
        if ({ done: $, value: Q } = Number.isNaN(K - G) ? yield NZ(N.next()) : yield NZ(N.next(K - G)), !$ && Q.byteLength > 0)
          Y.push(Q), G += Q.byteLength;
        if ($ || K <= G)
          do
            ({ cmd: W, size: K } = yield yield NZ(H()));
          while (K < G);
      } while (!$);
    } catch (q) {
      (X = !0) && typeof N.throw === "function" && (yield NZ(N.throw(q)));
    } finally {
      X === !1 && typeof N.return === "function" && (yield NZ(N.return(new Uint8Array(0))));
    }
    return yield NZ(null);
  });
}
function Ki0(Z) {
  return JK(this, arguments, function* J() {
    let $ = !1, X = !1, Y = [], Q, W, K, G = 0;
    function H() {
      if (W === "peek")
        return XK(Y, K)[0];
      return [Q, Y, G] = XK(Y, K), Q;
    }
    ({ cmd: W, size: K } = yield yield NZ(null));
    let N = new PY0(Z);
    try {
      do {
        if ({ done: $, value: Q } = Number.isNaN(K - G) ? yield NZ(N.read()) : yield NZ(N.read(K - G)), !$ && Q.byteLength > 0)
          Y.push(YZ(Q)), G += Q.byteLength;
        if ($ || K <= G)
          do
            ({ cmd: W, size: K } = yield yield NZ(H()));
          while (K < G);
      } while (!$);
    } catch (q) {
      (X = !0) && (yield NZ(N.cancel(q)));
    } finally {
      X === !1 ? yield NZ(N.cancel()) : Z.locked && N.releaseLock();
    }
    return yield NZ(null);
  });
}

class PY0 {
  constructor(Z) {
    this.source = Z, this.reader = null, this.reader = this.source.getReader(), this.reader.closed.catch(() => {});
  }
  get closed() {
    return this.reader ? this.reader.closed.catch(() => {}) : Promise.resolve();
  }
  releaseLock() {
    if (this.reader)
      this.reader.releaseLock();
    this.reader = null;
  }
  cancel(Z) {
    return j8(this, void 0, void 0, function* () {
      let { reader: J, source: $ } = this;
      J && (yield J.cancel(Z).catch(() => {})), $ && ($.locked && this.releaseLock());
    });
  }
  read(Z) {
    return j8(this, void 0, void 0, function* () {
      if (Z === 0)
        return { done: this.reader == null, value: new Uint8Array(0) };
      let J = yield this.reader.read();
      return !J.done && (J.value = YZ(J)), J;
    });
  }
}
var ac = (Z, J) => {
  let $ = (Y) => X([J, Y]), X;
  return [J, $, new Promise((Y) => (X = Y) && Z.once(J, $))];
};
function Gi0(Z) {
  return JK(this, arguments, function* J() {
    let $ = [], X = "error", Y = !1, Q = null, W, K, G = 0, H = [], N;
    function q() {
      if (W === "peek")
        return XK(H, K)[0];
      return [N, H, G] = XK(H, K), N;
    }
    if ({ cmd: W, size: K } = yield yield NZ(null), Z.isTTY)
      return yield yield NZ(new Uint8Array(0)), yield NZ(null);
    try {
      $[0] = ac(Z, "end"), $[1] = ac(Z, "error");
      do {
        if ($[2] = ac(Z, "readable"), [X, Q] = yield NZ(Promise.race($.map((F) => F[2]))), X === "error")
          break;
        if (!(Y = X === "end")) {
          if (!Number.isFinite(K - G))
            N = YZ(Z.read());
          else if (N = YZ(Z.read(K - G)), N.byteLength < K - G)
            N = YZ(Z.read());
          if (N.byteLength > 0)
            H.push(N), G += N.byteLength;
        }
        if (Y || K <= G)
          do
            ({ cmd: W, size: K } = yield yield NZ(q()));
          while (K < G);
      } while (!Y);
    } finally {
      yield NZ(U($, X === "error" ? Q : null));
    }
    return yield NZ(null);
    function U(F, E) {
      return N = H = null, new Promise((R, z) => {
        for (let [D, A] of F)
          Z.off(D, A);
        try {
          let D = Z.destroy;
          D && D.call(Z, E), E = void 0;
        } catch (D) {
          E = D || E;
        } finally {
          E != null ? z(E) : R();
        }
      });
    }
  });
}

// node_modules/apache-arrow/enum.mjs
var JY;
(function(Z) {
  Z[Z.V1 = 0] = "V1", Z[Z.V2 = 1] = "V2", Z[Z.V3 = 2] = "V3", Z[Z.V4 = 3] = "V4", Z[Z.V5 = 4] = "V5";
})(JY || (JY = {}));
var pJ;
(function(Z) {
  Z[Z.Sparse = 0] = "Sparse", Z[Z.Dense = 1] = "Dense";
})(pJ || (pJ = {}));
var NJ;
(function(Z) {
  Z[Z.HALF = 0] = "HALF", Z[Z.SINGLE = 1] = "SINGLE", Z[Z.DOUBLE = 2] = "DOUBLE";
})(NJ || (NJ = {}));
var JQ;
(function(Z) {
  Z[Z.DAY = 0] = "DAY", Z[Z.MILLISECOND = 1] = "MILLISECOND";
})(JQ || (JQ = {}));
var aZ;
(function(Z) {
  Z[Z.SECOND = 0] = "SECOND", Z[Z.MILLISECOND = 1] = "MILLISECOND", Z[Z.MICROSECOND = 2] = "MICROSECOND", Z[Z.NANOSECOND = 3] = "NANOSECOND";
})(aZ || (aZ = {}));
var zW;
(function(Z) {
  Z[Z.YEAR_MONTH = 0] = "YEAR_MONTH", Z[Z.DAY_TIME = 1] = "DAY_TIME", Z[Z.MONTH_DAY_NANO = 2] = "MONTH_DAY_NANO";
})(zW || (zW = {}));
var P9;
(function(Z) {
  Z[Z.NONE = 0] = "NONE", Z[Z.Schema = 1] = "Schema", Z[Z.DictionaryBatch = 2] = "DictionaryBatch", Z[Z.RecordBatch = 3] = "RecordBatch", Z[Z.Tensor = 4] = "Tensor", Z[Z.SparseTensor = 5] = "SparseTensor";
})(P9 || (P9 = {}));
var j1;
(function(Z) {
  Z[Z.NONE = 0] = "NONE", Z[Z.Null = 1] = "Null", Z[Z.Int = 2] = "Int", Z[Z.Float = 3] = "Float", Z[Z.Binary = 4] = "Binary", Z[Z.Utf8 = 5] = "Utf8", Z[Z.Bool = 6] = "Bool", Z[Z.Decimal = 7] = "Decimal", Z[Z.Date = 8] = "Date", Z[Z.Time = 9] = "Time", Z[Z.Timestamp = 10] = "Timestamp", Z[Z.Interval = 11] = "Interval", Z[Z.List = 12] = "List", Z[Z.Struct = 13] = "Struct", Z[Z.Union = 14] = "Union", Z[Z.FixedSizeBinary = 15] = "FixedSizeBinary", Z[Z.FixedSizeList = 16] = "FixedSizeList", Z[Z.Map = 17] = "Map", Z[Z.Dictionary = -1] = "Dictionary", Z[Z.Int8 = -2] = "Int8", Z[Z.Int16 = -3] = "Int16", Z[Z.Int32 = -4] = "Int32", Z[Z.Int64 = -5] = "Int64", Z[Z.Uint8 = -6] = "Uint8", Z[Z.Uint16 = -7] = "Uint16", Z[Z.Uint32 = -8] = "Uint32", Z[Z.Uint64 = -9] = "Uint64", Z[Z.Float16 = -10] = "Float16", Z[Z.Float32 = -11] = "Float32", Z[Z.Float64 = -12] = "Float64", Z[Z.DateDay = -13] = "DateDay", Z[Z.DateMillisecond = -14] = "DateMillisecond", Z[Z.TimestampSecond = -15] = "TimestampSecond", Z[Z.TimestampMillisecond = -16] = "TimestampMillisecond", Z[Z.TimestampMicrosecond = -17] = "TimestampMicrosecond", Z[Z.TimestampNanosecond = -18] = "TimestampNanosecond", Z[Z.TimeSecond = -19] = "TimeSecond", Z[Z.TimeMillisecond = -20] = "TimeMillisecond", Z[Z.TimeMicrosecond = -21] = "TimeMicrosecond", Z[Z.TimeNanosecond = -22] = "TimeNanosecond", Z[Z.DenseUnion = -23] = "DenseUnion", Z[Z.SparseUnion = -24] = "SparseUnion", Z[Z.IntervalDayTime = -25] = "IntervalDayTime", Z[Z.IntervalYearMonth = -26] = "IntervalYearMonth";
})(j1 || (j1 = {}));
var eK;
(function(Z) {
  Z[Z.OFFSET = 0] = "OFFSET", Z[Z.DATA = 1] = "DATA", Z[Z.VALIDITY = 2] = "VALIDITY", Z[Z.TYPE = 3] = "TYPE";
})(eK || (eK = {}));

// node_modules/apache-arrow/util/vector.mjs
var Dl = {};
y9(Dl, {
  createElementComparator: () => ML,
  clampRange: () => AT,
  clampIndex: () => ei0
});

// node_modules/apache-arrow/util/pretty.mjs
var Hi0 = void 0;
function uG(Z) {
  if (Z === null)
    return "null";
  if (Z === Hi0)
    return "undefined";
  switch (typeof Z) {
    case "number":
      return `${Z}`;
    case "bigint":
      return `${Z}`;
    case "string":
      return `"${Z}"`;
  }
  if (typeof Z[Symbol.toPrimitive] === "function")
    return Z[Symbol.toPrimitive]("string");
  if (ArrayBuffer.isView(Z)) {
    if (Z instanceof aK || Z instanceof rK)
      return `[${[...Z].map((J) => uG(J))}]`;
    return `[${Z}]`;
  }
  return ArrayBuffer.isView(Z) ? `[${Z}]` : JSON.stringify(Z, (J, $) => typeof $ === "bigint" ? `${$}` : $);
}

// node_modules/apache-arrow/util/bn.mjs
var tc = {};
y9(tc, {
  isArrowBigNumSymbol: () => CY0,
  bignumToString: () => NL,
  bignumToBigInt: () => ek,
  BN: () => DT
});
var CY0 = Symbol.for("isArrowBigNum");
function cG(Z, ...J) {
  if (J.length === 0)
    return Object.setPrototypeOf(gZ(this.TypedArray, Z), this.constructor.prototype);
  return Object.setPrototypeOf(new this.TypedArray(Z, ...J), this.constructor.prototype);
}
cG.prototype[CY0] = !0;
cG.prototype.toJSON = function() {
  return `"${NL(this)}"`;
};
cG.prototype.valueOf = function() {
  return kY0(this);
};
cG.prototype.toString = function() {
  return NL(this);
};
cG.prototype[Symbol.toPrimitive] = function(Z = "default") {
  switch (Z) {
    case "number":
      return kY0(this);
    case "string":
      return NL(this);
    case "default":
      return ek(this);
  }
  return NL(this);
};
function vD(...Z) {
  return cG.apply(this, Z);
}
function SD(...Z) {
  return cG.apply(this, Z);
}
function zT(...Z) {
  return cG.apply(this, Z);
}
Object.setPrototypeOf(vD.prototype, Object.create(Int32Array.prototype));
Object.setPrototypeOf(SD.prototype, Object.create(Uint32Array.prototype));
Object.setPrototypeOf(zT.prototype, Object.create(Uint32Array.prototype));
Object.assign(vD.prototype, cG.prototype, { constructor: vD, signed: !0, TypedArray: Int32Array, BigIntArray: aK });
Object.assign(SD.prototype, cG.prototype, { constructor: SD, signed: !1, TypedArray: Uint32Array, BigIntArray: rK });
Object.assign(zT.prototype, cG.prototype, { constructor: zT, signed: !0, TypedArray: Uint32Array, BigIntArray: rK });
function kY0(Z) {
  let { buffer: J, byteOffset: $, length: X, signed: Y } = Z, Q = new rK(J, $, X), W = Y && Q[Q.length - 1] & BigInt(1) << BigInt(63), K = W ? BigInt(1) : BigInt(0), G = BigInt(0);
  if (!W)
    for (let H of Q)
      K += H * (BigInt(1) << BigInt(32) * G++);
  else {
    for (let H of Q)
      K += ~H * (BigInt(1) << BigInt(32) * G++);
    K *= BigInt(-1);
  }
  return K;
}
var NL, ek;
if (!lk)
  NL = rc, ek = NL;
else
  ek = (Z) => Z.byteLength === 8 ? new Z.BigIntArray(Z.buffer, Z.byteOffset, 1)[0] : rc(Z), NL = (Z) => Z.byteLength === 8 ? `${new Z.BigIntArray(Z.buffer, Z.byteOffset, 1)[0]}` : rc(Z);
function rc(Z) {
  let J = "", $ = new Uint32Array(2), X = new Uint16Array(Z.buffer, Z.byteOffset, Z.byteLength / 2), Y = new Uint32Array((X = new Uint16Array(X).reverse()).buffer), Q = -1, W = X.length - 1;
  do {
    for ($[0] = X[Q = 0];Q < W; )
      X[Q++] = $[1] = $[0] / 10, $[0] = ($[0] - $[1] * 10 << 16) + X[Q];
    X[Q] = $[1] = $[0] / 10, $[0] = $[0] - $[1] * 10, J = `${$[0]}${J}`;
  } while (Y[0] || Y[1] || Y[2] || Y[3]);
  return J !== null && J !== void 0 ? J : "0";
}

class DT {
  static new(Z, J) {
    switch (J) {
      case !0:
        return new vD(Z);
      case !1:
        return new SD(Z);
    }
    switch (Z.constructor) {
      case Int8Array:
      case Int16Array:
      case Int32Array:
      case aK:
        return new vD(Z);
    }
    if (Z.byteLength === 16)
      return new zT(Z);
    return new SD(Z);
  }
  static signed(Z) {
    return new vD(Z);
  }
  static unsigned(Z) {
    return new SD(Z);
  }
  static decimal(Z) {
    return new zT(Z);
  }
  constructor(Z, J) {
    return DT.new(Z, J);
  }
}

// node_modules/apache-arrow/type.mjs
var vY0, SY0, fY0, hY0, bY0, xY0, yY0, gY0, mY0, dY0, pY0, uY0, cY0, lY0, nY0, iY0, oY0, sY0, aY0;

class L6 {
  static isNull(Z) {
    return (Z === null || Z === void 0 ? void 0 : Z.typeId) === j1.Null;
  }
  static isInt(Z) {
    return (Z === null || Z === void 0 ? void 0 : Z.typeId) === j1.Int;
  }
  static isFloat(Z) {
    return (Z === null || Z === void 0 ? void 0 : Z.typeId) === j1.Float;
  }
  static isBinary(Z) {
    return (Z === null || Z === void 0 ? void 0 : Z.typeId) === j1.Binary;
  }
  static isUtf8(Z) {
    return (Z === null || Z === void 0 ? void 0 : Z.typeId) === j1.Utf8;
  }
  static isBool(Z) {
    return (Z === null || Z === void 0 ? void 0 : Z.typeId) === j1.Bool;
  }
  static isDecimal(Z) {
    return (Z === null || Z === void 0 ? void 0 : Z.typeId) === j1.Decimal;
  }
  static isDate(Z) {
    return (Z === null || Z === void 0 ? void 0 : Z.typeId) === j1.Date;
  }
  static isTime(Z) {
    return (Z === null || Z === void 0 ? void 0 : Z.typeId) === j1.Time;
  }
  static isTimestamp(Z) {
    return (Z === null || Z === void 0 ? void 0 : Z.typeId) === j1.Timestamp;
  }
  static isInterval(Z) {
    return (Z === null || Z === void 0 ? void 0 : Z.typeId) === j1.Interval;
  }
  static isList(Z) {
    return (Z === null || Z === void 0 ? void 0 : Z.typeId) === j1.List;
  }
  static isStruct(Z) {
    return (Z === null || Z === void 0 ? void 0 : Z.typeId) === j1.Struct;
  }
  static isUnion(Z) {
    return (Z === null || Z === void 0 ? void 0 : Z.typeId) === j1.Union;
  }
  static isFixedSizeBinary(Z) {
    return (Z === null || Z === void 0 ? void 0 : Z.typeId) === j1.FixedSizeBinary;
  }
  static isFixedSizeList(Z) {
    return (Z === null || Z === void 0 ? void 0 : Z.typeId) === j1.FixedSizeList;
  }
  static isMap(Z) {
    return (Z === null || Z === void 0 ? void 0 : Z.typeId) === j1.Map;
  }
  static isDictionary(Z) {
    return (Z === null || Z === void 0 ? void 0 : Z.typeId) === j1.Dictionary;
  }
  static isDenseUnion(Z) {
    return L6.isUnion(Z) && Z.mode === pJ.Dense;
  }
  static isSparseUnion(Z) {
    return L6.isUnion(Z) && Z.mode === pJ.Sparse;
  }
  get typeId() {
    return j1.NONE;
  }
}
vY0 = Symbol.toStringTag;
L6[vY0] = ((Z) => {
  return Z.children = null, Z.ArrayType = Array, Z[Symbol.toStringTag] = "DataType";
})(L6.prototype);

class K5 extends L6 {
  toString() {
    return "Null";
  }
  get typeId() {
    return j1.Null;
  }
}
SY0 = Symbol.toStringTag;
K5[SY0] = ((Z) => Z[Symbol.toStringTag] = "Null")(K5.prototype);

class l$ extends L6 {
  constructor(Z, J) {
    super();
    this.isSigned = Z, this.bitWidth = J;
  }
  get typeId() {
    return j1.Int;
  }
  get ArrayType() {
    switch (this.bitWidth) {
      case 8:
        return this.isSigned ? Int8Array : Uint8Array;
      case 16:
        return this.isSigned ? Int16Array : Uint16Array;
      case 32:
        return this.isSigned ? Int32Array : Uint32Array;
      case 64:
        return this.isSigned ? aK : rK;
    }
    throw new Error(`Unrecognized ${this[Symbol.toStringTag]} type`);
  }
  toString() {
    return `${this.isSigned ? "I" : "Ui"}nt${this.bitWidth}`;
  }
}
fY0 = Symbol.toStringTag;
l$[fY0] = ((Z) => {
  return Z.isSigned = null, Z.bitWidth = null, Z[Symbol.toStringTag] = "Int";
})(l$.prototype);
class ec extends l$ {
  constructor() {
    super(!0, 8);
  }
  get ArrayType() {
    return Int8Array;
  }
}

class Zl extends l$ {
  constructor() {
    super(!0, 16);
  }
  get ArrayType() {
    return Int16Array;
  }
}

class OF extends l$ {
  constructor() {
    super(!0, 32);
  }
  get ArrayType() {
    return Int32Array;
  }
}

class Jl extends l$ {
  constructor() {
    super(!0, 64);
  }
  get ArrayType() {
    return aK;
  }
}

class $l extends l$ {
  constructor() {
    super(!1, 8);
  }
  get ArrayType() {
    return Uint8Array;
  }
}

class Xl extends l$ {
  constructor() {
    super(!1, 16);
  }
  get ArrayType() {
    return Uint16Array;
  }
}

class Yl extends l$ {
  constructor() {
    super(!1, 32);
  }
  get ArrayType() {
    return Uint32Array;
  }
}

class Ql extends l$ {
  constructor() {
    super(!1, 64);
  }
  get ArrayType() {
    return rK;
  }
}
Object.defineProperty(ec.prototype, "ArrayType", { value: Int8Array });
Object.defineProperty(Zl.prototype, "ArrayType", { value: Int16Array });
Object.defineProperty(OF.prototype, "ArrayType", { value: Int32Array });
Object.defineProperty(Jl.prototype, "ArrayType", { value: aK });
Object.defineProperty($l.prototype, "ArrayType", { value: Uint8Array });
Object.defineProperty(Xl.prototype, "ArrayType", { value: Uint16Array });
Object.defineProperty(Yl.prototype, "ArrayType", { value: Uint32Array });
Object.defineProperty(Ql.prototype, "ArrayType", { value: rK });

class YK extends L6 {
  constructor(Z) {
    super();
    this.precision = Z;
  }
  get typeId() {
    return j1.Float;
  }
  get ArrayType() {
    switch (this.precision) {
      case NJ.HALF:
        return Uint16Array;
      case NJ.SINGLE:
        return Float32Array;
      case NJ.DOUBLE:
        return Float64Array;
    }
    throw new Error(`Unrecognized ${this[Symbol.toStringTag]} type`);
  }
  toString() {
    return `Float${this.precision << 5 || 16}`;
  }
}
hY0 = Symbol.toStringTag;
YK[hY0] = ((Z) => {
  return Z.precision = null, Z[Symbol.toStringTag] = "Float";
})(YK.prototype);

class Wl extends YK {
  constructor() {
    super(NJ.HALF);
  }
}

class Kl extends YK {
  constructor() {
    super(NJ.SINGLE);
  }
}

class Gl extends YK {
  constructor() {
    super(NJ.DOUBLE);
  }
}
Object.defineProperty(Wl.prototype, "ArrayType", { value: Uint16Array });
Object.defineProperty(Kl.prototype, "ArrayType", { value: Float32Array });
Object.defineProperty(Gl.prototype, "ArrayType", { value: Float64Array });

class qL extends L6 {
  constructor() {
    super();
  }
  get typeId() {
    return j1.Binary;
  }
  toString() {
    return "Binary";
  }
}
bY0 = Symbol.toStringTag;
qL[bY0] = ((Z) => {
  return Z.ArrayType = Uint8Array, Z[Symbol.toStringTag] = "Binary";
})(qL.prototype);

class FL extends L6 {
  constructor() {
    super();
  }
  get typeId() {
    return j1.Utf8;
  }
  toString() {
    return "Utf8";
  }
}
xY0 = Symbol.toStringTag;
FL[xY0] = ((Z) => {
  return Z.ArrayType = Uint8Array, Z[Symbol.toStringTag] = "Utf8";
})(FL.prototype);

class UL extends L6 {
  constructor() {
    super();
  }
  get typeId() {
    return j1.Bool;
  }
  toString() {
    return "Bool";
  }
}
yY0 = Symbol.toStringTag;
UL[yY0] = ((Z) => {
  return Z.ArrayType = Uint8Array, Z[Symbol.toStringTag] = "Bool";
})(UL.prototype);

class LL extends L6 {
  constructor(Z, J, $ = 128) {
    super();
    this.scale = Z, this.precision = J, this.bitWidth = $;
  }
  get typeId() {
    return j1.Decimal;
  }
  toString() {
    return `Decimal[${this.precision}e${this.scale > 0 ? "+" : ""}${this.scale}]`;
  }
}
gY0 = Symbol.toStringTag;
LL[gY0] = ((Z) => {
  return Z.scale = null, Z.precision = null, Z.ArrayType = Uint32Array, Z[Symbol.toStringTag] = "Decimal";
})(LL.prototype);

class RL extends L6 {
  constructor(Z) {
    super();
    this.unit = Z;
  }
  get typeId() {
    return j1.Date;
  }
  toString() {
    return `Date${(this.unit + 1) * 32}<${JQ[this.unit]}>`;
  }
}
mY0 = Symbol.toStringTag;
RL[mY0] = ((Z) => {
  return Z.unit = null, Z.ArrayType = Int32Array, Z[Symbol.toStringTag] = "Date";
})(RL.prototype);
class GN extends L6 {
  constructor(Z, J) {
    super();
    this.unit = Z, this.bitWidth = J;
  }
  get typeId() {
    return j1.Time;
  }
  toString() {
    return `Time${this.bitWidth}<${aZ[this.unit]}>`;
  }
  get ArrayType() {
    switch (this.bitWidth) {
      case 32:
        return Int32Array;
      case 64:
        return aK;
    }
    throw new Error(`Unrecognized ${this[Symbol.toStringTag]} type`);
  }
}
dY0 = Symbol.toStringTag;
GN[dY0] = ((Z) => {
  return Z.unit = null, Z.bitWidth = null, Z[Symbol.toStringTag] = "Time";
})(GN.prototype);
class EL extends L6 {
  constructor(Z, J) {
    super();
    this.unit = Z, this.timezone = J;
  }
  get typeId() {
    return j1.Timestamp;
  }
  toString() {
    return `Timestamp<${aZ[this.unit]}${this.timezone ? `, ${this.timezone}` : ""}>`;
  }
}
pY0 = Symbol.toStringTag;
EL[pY0] = ((Z) => {
  return Z.unit = null, Z.timezone = null, Z.ArrayType = Int32Array, Z[Symbol.toStringTag] = "Timestamp";
})(EL.prototype);
class OL extends L6 {
  constructor(Z) {
    super();
    this.unit = Z;
  }
  get typeId() {
    return j1.Interval;
  }
  toString() {
    return `Interval<${zW[this.unit]}>`;
  }
}
uY0 = Symbol.toStringTag;
OL[uY0] = ((Z) => {
  return Z.unit = null, Z.ArrayType = Int32Array, Z[Symbol.toStringTag] = "Interval";
})(OL.prototype);
class HN extends L6 {
  constructor(Z) {
    super();
    this.children = [Z];
  }
  get typeId() {
    return j1.List;
  }
  toString() {
    return `List<${this.valueType}>`;
  }
  get valueType() {
    return this.children[0].type;
  }
  get valueField() {
    return this.children[0];
  }
  get ArrayType() {
    return this.valueType.ArrayType;
  }
}
cY0 = Symbol.toStringTag;
HN[cY0] = ((Z) => {
  return Z.children = null, Z[Symbol.toStringTag] = "List";
})(HN.prototype);

class qJ extends L6 {
  constructor(Z) {
    super();
    this.children = Z;
  }
  get typeId() {
    return j1.Struct;
  }
  toString() {
    return `Struct<{${this.children.map((Z) => `${Z.name}:${Z.type}`).join(", ")}}>`;
  }
}
lY0 = Symbol.toStringTag;
qJ[lY0] = ((Z) => {
  return Z.children = null, Z[Symbol.toStringTag] = "Struct";
})(qJ.prototype);

class NN extends L6 {
  constructor(Z, J, $) {
    super();
    this.mode = Z, this.children = $, this.typeIds = J = Int32Array.from(J), this.typeIdToChildIndex = J.reduce((X, Y, Q) => (X[Y] = Q) && X || X, Object.create(null));
  }
  get typeId() {
    return j1.Union;
  }
  toString() {
    return `${this[Symbol.toStringTag]}<${this.children.map((Z) => `${Z.type}`).join(" | ")}>`;
  }
}
nY0 = Symbol.toStringTag;
NN[nY0] = ((Z) => {
  return Z.mode = null, Z.typeIds = null, Z.children = null, Z.typeIdToChildIndex = null, Z.ArrayType = Int8Array, Z[Symbol.toStringTag] = "Union";
})(NN.prototype);
class zL extends L6 {
  constructor(Z) {
    super();
    this.byteWidth = Z;
  }
  get typeId() {
    return j1.FixedSizeBinary;
  }
  toString() {
    return `FixedSizeBinary[${this.byteWidth}]`;
  }
}
iY0 = Symbol.toStringTag;
zL[iY0] = ((Z) => {
  return Z.byteWidth = null, Z.ArrayType = Uint8Array, Z[Symbol.toStringTag] = "FixedSizeBinary";
})(zL.prototype);

class qN extends L6 {
  constructor(Z, J) {
    super();
    this.listSize = Z, this.children = [J];
  }
  get typeId() {
    return j1.FixedSizeList;
  }
  get valueType() {
    return this.children[0].type;
  }
  get valueField() {
    return this.children[0];
  }
  get ArrayType() {
    return this.valueType.ArrayType;
  }
  toString() {
    return `FixedSizeList[${this.listSize}]<${this.valueType}>`;
  }
}
oY0 = Symbol.toStringTag;
qN[oY0] = ((Z) => {
  return Z.children = null, Z.listSize = null, Z[Symbol.toStringTag] = "FixedSizeList";
})(qN.prototype);

class FN extends L6 {
  constructor(Z, J = !1) {
    super();
    this.children = [Z], this.keysSorted = J;
  }
  get typeId() {
    return j1.Map;
  }
  get keyType() {
    return this.children[0].type.children[0].type;
  }
  get valueType() {
    return this.children[0].type.children[1].type;
  }
  get childType() {
    return this.children[0].type;
  }
  toString() {
    return `Map<{${this.children[0].type.children.map((Z) => `${Z.name}:${Z.type}`).join(", ")}}>`;
  }
}
sY0 = Symbol.toStringTag;
FN[sY0] = ((Z) => {
  return Z.children = null, Z.keysSorted = null, Z[Symbol.toStringTag] = "Map_";
})(FN.prototype);
var Ni0 = ((Z) => () => ++Z)(-1);

class Z3 extends L6 {
  constructor(Z, J, $, X) {
    super();
    this.indices = J, this.dictionary = Z, this.isOrdered = X || !1, this.id = $ == null ? Ni0() : typeof $ === "number" ? $ : $.low;
  }
  get typeId() {
    return j1.Dictionary;
  }
  get children() {
    return this.dictionary.children;
  }
  get valueType() {
    return this.dictionary;
  }
  get ArrayType() {
    return this.dictionary.ArrayType;
  }
  toString() {
    return `Dictionary<${this.indices}, ${this.dictionary}>`;
  }
}
aY0 = Symbol.toStringTag;
Z3[aY0] = ((Z) => {
  return Z.id = null, Z.indices = null, Z.isOrdered = null, Z.dictionary = null, Z[Symbol.toStringTag] = "Dictionary";
})(Z3.prototype);
function QK(Z) {
  let J = Z;
  switch (Z.typeId) {
    case j1.Decimal:
      return Z.bitWidth / 32;
    case j1.Timestamp:
      return 2;
    case j1.Date:
      return 1 + J.unit;
    case j1.Interval:
      return 1 + J.unit;
    case j1.FixedSizeList:
      return J.listSize;
    case j1.FixedSizeBinary:
      return J.byteWidth;
    default:
      return 1;
  }
}

// node_modules/apache-arrow/visitor.mjs
class g6 {
  visitMany(Z, ...J) {
    return Z.map(($, X) => this.visit($, ...J.map((Y) => Y[X])));
  }
  visit(...Z) {
    return this.getVisitFn(Z[0], !1).apply(this, Z);
  }
  getVisitFn(Z, J = !0) {
    return qi0(this, Z, J);
  }
  getVisitFnByTypeId(Z, J = !0) {
    return fD(this, Z, J);
  }
  visitNull(Z, ...J) {
    return null;
  }
  visitBool(Z, ...J) {
    return null;
  }
  visitInt(Z, ...J) {
    return null;
  }
  visitFloat(Z, ...J) {
    return null;
  }
  visitUtf8(Z, ...J) {
    return null;
  }
  visitBinary(Z, ...J) {
    return null;
  }
  visitFixedSizeBinary(Z, ...J) {
    return null;
  }
  visitDate(Z, ...J) {
    return null;
  }
  visitTimestamp(Z, ...J) {
    return null;
  }
  visitTime(Z, ...J) {
    return null;
  }
  visitDecimal(Z, ...J) {
    return null;
  }
  visitList(Z, ...J) {
    return null;
  }
  visitStruct(Z, ...J) {
    return null;
  }
  visitUnion(Z, ...J) {
    return null;
  }
  visitDictionary(Z, ...J) {
    return null;
  }
  visitInterval(Z, ...J) {
    return null;
  }
  visitFixedSizeList(Z, ...J) {
    return null;
  }
  visitMap(Z, ...J) {
    return null;
  }
}
function qi0(Z, J, $ = !0) {
  if (typeof J === "number")
    return fD(Z, J, $);
  if (typeof J === "string" && J in j1)
    return fD(Z, j1[J], $);
  if (J && J instanceof L6)
    return fD(Z, rY0(J), $);
  if ((J === null || J === void 0 ? void 0 : J.type) && J.type instanceof L6)
    return fD(Z, rY0(J.type), $);
  return fD(Z, j1.NONE, $);
}
function fD(Z, J, $ = !0) {
  let X = null;
  switch (J) {
    case j1.Null:
      X = Z.visitNull;
      break;
    case j1.Bool:
      X = Z.visitBool;
      break;
    case j1.Int:
      X = Z.visitInt;
      break;
    case j1.Int8:
      X = Z.visitInt8 || Z.visitInt;
      break;
    case j1.Int16:
      X = Z.visitInt16 || Z.visitInt;
      break;
    case j1.Int32:
      X = Z.visitInt32 || Z.visitInt;
      break;
    case j1.Int64:
      X = Z.visitInt64 || Z.visitInt;
      break;
    case j1.Uint8:
      X = Z.visitUint8 || Z.visitInt;
      break;
    case j1.Uint16:
      X = Z.visitUint16 || Z.visitInt;
      break;
    case j1.Uint32:
      X = Z.visitUint32 || Z.visitInt;
      break;
    case j1.Uint64:
      X = Z.visitUint64 || Z.visitInt;
      break;
    case j1.Float:
      X = Z.visitFloat;
      break;
    case j1.Float16:
      X = Z.visitFloat16 || Z.visitFloat;
      break;
    case j1.Float32:
      X = Z.visitFloat32 || Z.visitFloat;
      break;
    case j1.Float64:
      X = Z.visitFloat64 || Z.visitFloat;
      break;
    case j1.Utf8:
      X = Z.visitUtf8;
      break;
    case j1.Binary:
      X = Z.visitBinary;
      break;
    case j1.FixedSizeBinary:
      X = Z.visitFixedSizeBinary;
      break;
    case j1.Date:
      X = Z.visitDate;
      break;
    case j1.DateDay:
      X = Z.visitDateDay || Z.visitDate;
      break;
    case j1.DateMillisecond:
      X = Z.visitDateMillisecond || Z.visitDate;
      break;
    case j1.Timestamp:
      X = Z.visitTimestamp;
      break;
    case j1.TimestampSecond:
      X = Z.visitTimestampSecond || Z.visitTimestamp;
      break;
    case j1.TimestampMillisecond:
      X = Z.visitTimestampMillisecond || Z.visitTimestamp;
      break;
    case j1.TimestampMicrosecond:
      X = Z.visitTimestampMicrosecond || Z.visitTimestamp;
      break;
    case j1.TimestampNanosecond:
      X = Z.visitTimestampNanosecond || Z.visitTimestamp;
      break;
    case j1.Time:
      X = Z.visitTime;
      break;
    case j1.TimeSecond:
      X = Z.visitTimeSecond || Z.visitTime;
      break;
    case j1.TimeMillisecond:
      X = Z.visitTimeMillisecond || Z.visitTime;
      break;
    case j1.TimeMicrosecond:
      X = Z.visitTimeMicrosecond || Z.visitTime;
      break;
    case j1.TimeNanosecond:
      X = Z.visitTimeNanosecond || Z.visitTime;
      break;
    case j1.Decimal:
      X = Z.visitDecimal;
      break;
    case j1.List:
      X = Z.visitList;
      break;
    case j1.Struct:
      X = Z.visitStruct;
      break;
    case j1.Union:
      X = Z.visitUnion;
      break;
    case j1.DenseUnion:
      X = Z.visitDenseUnion || Z.visitUnion;
      break;
    case j1.SparseUnion:
      X = Z.visitSparseUnion || Z.visitUnion;
      break;
    case j1.Dictionary:
      X = Z.visitDictionary;
      break;
    case j1.Interval:
      X = Z.visitInterval;
      break;
    case j1.IntervalDayTime:
      X = Z.visitIntervalDayTime || Z.visitInterval;
      break;
    case j1.IntervalYearMonth:
      X = Z.visitIntervalYearMonth || Z.visitInterval;
      break;
    case j1.FixedSizeList:
      X = Z.visitFixedSizeList;
      break;
    case j1.Map:
      X = Z.visitMap;
      break;
  }
  if (typeof X === "function")
    return X;
  if (!$)
    return () => null;
  throw new Error(`Unrecognized type '${j1[J]}'`);
}
function rY0(Z) {
  switch (Z.typeId) {
    case j1.Null:
      return j1.Null;
    case j1.Int: {
      let { bitWidth: J, isSigned: $ } = Z;
      switch (J) {
        case 8:
          return $ ? j1.Int8 : j1.Uint8;
        case 16:
          return $ ? j1.Int16 : j1.Uint16;
        case 32:
          return $ ? j1.Int32 : j1.Uint32;
        case 64:
          return $ ? j1.Int64 : j1.Uint64;
      }
      return j1.Int;
    }
    case j1.Float:
      switch (Z.precision) {
        case NJ.HALF:
          return j1.Float16;
        case NJ.SINGLE:
          return j1.Float32;
        case NJ.DOUBLE:
          return j1.Float64;
      }
      return j1.Float;
    case j1.Binary:
      return j1.Binary;
    case j1.Utf8:
      return j1.Utf8;
    case j1.Bool:
      return j1.Bool;
    case j1.Decimal:
      return j1.Decimal;
    case j1.Time:
      switch (Z.unit) {
        case aZ.SECOND:
          return j1.TimeSecond;
        case aZ.MILLISECOND:
          return j1.TimeMillisecond;
        case aZ.MICROSECOND:
          return j1.TimeMicrosecond;
        case aZ.NANOSECOND:
          return j1.TimeNanosecond;
      }
      return j1.Time;
    case j1.Timestamp:
      switch (Z.unit) {
        case aZ.SECOND:
          return j1.TimestampSecond;
        case aZ.MILLISECOND:
          return j1.TimestampMillisecond;
        case aZ.MICROSECOND:
          return j1.TimestampMicrosecond;
        case aZ.NANOSECOND:
          return j1.TimestampNanosecond;
      }
      return j1.Timestamp;
    case j1.Date:
      switch (Z.unit) {
        case JQ.DAY:
          return j1.DateDay;
        case JQ.MILLISECOND:
          return j1.DateMillisecond;
      }
      return j1.Date;
    case j1.Interval:
      switch (Z.unit) {
        case zW.DAY_TIME:
          return j1.IntervalDayTime;
        case zW.YEAR_MONTH:
          return j1.IntervalYearMonth;
      }
      return j1.Interval;
    case j1.Map:
      return j1.Map;
    case j1.List:
      return j1.List;
    case j1.Struct:
      return j1.Struct;
    case j1.Union:
      switch (Z.mode) {
        case pJ.Dense:
          return j1.DenseUnion;
        case pJ.Sparse:
          return j1.SparseUnion;
      }
      return j1.Union;
    case j1.FixedSizeBinary:
      return j1.FixedSizeBinary;
    case j1.FixedSizeList:
      return j1.FixedSizeList;
    case j1.Dictionary:
      return j1.Dictionary;
  }
  throw new Error(`Unrecognized type '${j1[Z.typeId]}'`);
}
g6.prototype.visitInt8 = null;
g6.prototype.visitInt16 = null;
g6.prototype.visitInt32 = null;
g6.prototype.visitInt64 = null;
g6.prototype.visitUint8 = null;
g6.prototype.visitUint16 = null;
g6.prototype.visitUint32 = null;
g6.prototype.visitUint64 = null;
g6.prototype.visitFloat16 = null;
g6.prototype.visitFloat32 = null;
g6.prototype.visitFloat64 = null;
g6.prototype.visitDateDay = null;
g6.prototype.visitDateMillisecond = null;
g6.prototype.visitTimestampSecond = null;
g6.prototype.visitTimestampMillisecond = null;
g6.prototype.visitTimestampMicrosecond = null;
g6.prototype.visitTimestampNanosecond = null;
g6.prototype.visitTimeSecond = null;
g6.prototype.visitTimeMillisecond = null;
g6.prototype.visitTimeMicrosecond = null;
g6.prototype.visitTimeNanosecond = null;
g6.prototype.visitDenseUnion = null;
g6.prototype.visitSparseUnion = null;
g6.prototype.visitIntervalDayTime = null;
g6.prototype.visitIntervalYearMonth = null;

// node_modules/apache-arrow/util/math.mjs
var Hl = {};
y9(Hl, {
  uint16ToFloat64: () => Zv,
  float64ToUint16: () => MT
});
var tY0 = new Float64Array(1), hD = new Uint32Array(tY0.buffer);
function Zv(Z) {
  let J = (Z & 31744) >> 10, $ = (Z & 1023) / 1024, X = Math.pow(-1, (Z & 32768) >> 15);
  switch (J) {
    case 31:
      return X * ($ ? Number.NaN : 1 / 0);
    case 0:
      return X * ($ ? 0.00006103515625 * $ : 0);
  }
  return X * Math.pow(2, J - 15) * (1 + $);
}
function MT(Z) {
  if (Z !== Z)
    return 32256;
  tY0[0] = Z;
  let J = (hD[1] & 2147483648) >> 16 & 65535, $ = hD[1] & 2146435072, X = 0;
  if ($ >= 1089470464)
    if (hD[0] > 0)
      $ = 31744;
    else
      $ = ($ & 2080374784) >> 16, X = (hD[1] & 1048575) >> 10;
  else if ($ <= 1056964608)
    X = 1048576 + (hD[1] & 1048575), X = 1048576 + (X << ($ >> 20) - 998) >> 21, $ = 0;
  else
    $ = $ - 1056964608 >> 10, X = (hD[1] & 1048575) + 512 >> 10;
  return J | $ | X & 65535;
}

// node_modules/apache-arrow/visitor/set.mjs
class qZ extends g6 {
}
function VZ(Z) {
  return (J, $, X) => {
    if (J.setValid($, X != null))
      return Z(J, $, X);
  };
}
var Fi0 = (Z, J, $) => {
  Z[J] = Math.trunc($ / 86400000);
}, Nl = (Z, J, $) => {
  Z[J] = Math.trunc($ % 4294967296), Z[J + 1] = Math.trunc($ / 4294967296);
}, Ui0 = (Z, J, $) => {
  Z[J] = Math.trunc($ * 1000 % 4294967296), Z[J + 1] = Math.trunc($ * 1000 / 4294967296);
}, Li0 = (Z, J, $) => {
  Z[J] = Math.trunc($ * 1e6 % 4294967296), Z[J + 1] = Math.trunc($ * 1e6 / 4294967296);
}, eY0 = (Z, J, $, X) => {
  if ($ + 1 < J.length) {
    let { [$]: Y, [$ + 1]: Q } = J;
    Z.set(X.subarray(0, Q - Y), Y);
  }
}, Ri0 = ({ offset: Z, values: J }, $, X) => {
  let Y = Z + $;
  X ? J[Y >> 3] |= 1 << Y % 8 : J[Y >> 3] &= ~(1 << Y % 8);
}, zF = ({ values: Z }, J, $) => {
  Z[J] = $;
}, ql = ({ values: Z }, J, $) => {
  Z[J] = $;
}, ZQ0 = ({ values: Z }, J, $) => {
  Z[J] = MT($);
}, Ei0 = (Z, J, $) => {
  switch (Z.type.precision) {
    case NJ.HALF:
      return ZQ0(Z, J, $);
    case NJ.SINGLE:
    case NJ.DOUBLE:
      return ql(Z, J, $);
  }
}, Jv = ({ values: Z }, J, $) => {
  Fi0(Z, J, $.valueOf());
}, $v = ({ values: Z }, J, $) => {
  Nl(Z, J * 2, $.valueOf());
}, Fl = ({ stride: Z, values: J }, $, X) => {
  J.set(X.subarray(0, Z), Z * $);
}, Oi0 = ({ values: Z, valueOffsets: J }, $, X) => eY0(Z, J, $, X), zi0 = ({ values: Z, valueOffsets: J }, $, X) => {
  eY0(Z, J, $, HL(X));
}, Ul = (Z, J, $) => {
  Z.type.unit === JQ.DAY ? Jv(Z, J, $) : $v(Z, J, $);
}, Xv = ({ values: Z }, J, $) => Nl(Z, J * 2, $ / 1000), Yv = ({ values: Z }, J, $) => Nl(Z, J * 2, $), Qv = ({ values: Z }, J, $) => Ui0(Z, J * 2, $), Wv = ({ values: Z }, J, $) => Li0(Z, J * 2, $), Ll = (Z, J, $) => {
  switch (Z.type.unit) {
    case aZ.SECOND:
      return Xv(Z, J, $);
    case aZ.MILLISECOND:
      return Yv(Z, J, $);
    case aZ.MICROSECOND:
      return Qv(Z, J, $);
    case aZ.NANOSECOND:
      return Wv(Z, J, $);
  }
}, Kv = ({ values: Z }, J, $) => {
  Z[J] = $;
}, Gv = ({ values: Z }, J, $) => {
  Z[J] = $;
}, Hv = ({ values: Z }, J, $) => {
  Z[J] = $;
}, Nv = ({ values: Z }, J, $) => {
  Z[J] = $;
}, Rl = (Z, J, $) => {
  switch (Z.type.unit) {
    case aZ.SECOND:
      return Kv(Z, J, $);
    case aZ.MILLISECOND:
      return Gv(Z, J, $);
    case aZ.MICROSECOND:
      return Hv(Z, J, $);
    case aZ.NANOSECOND:
      return Nv(Z, J, $);
  }
}, El = ({ values: Z, stride: J }, $, X) => {
  Z.set(X.subarray(0, J), J * $);
}, Di0 = (Z, J, $) => {
  let X = Z.children[0], Y = Z.valueOffsets, Q = $Q.getVisitFn(X);
  if (Array.isArray($))
    for (let W = -1, K = Y[J], G = Y[J + 1];K < G; )
      Q(X, K++, $[++W]);
  else
    for (let W = -1, K = Y[J], G = Y[J + 1];K < G; )
      Q(X, K++, $.get(++W));
}, Mi0 = (Z, J, $) => {
  let X = Z.children[0], { valueOffsets: Y } = Z, Q = $Q.getVisitFn(X), { [J]: W, [J + 1]: K } = Y, G = $ instanceof Map ? $.entries() : Object.entries($);
  for (let H of G)
    if (Q(X, W, H), ++W >= K)
      break;
}, Ai0 = (Z, J) => ($, X, Y, Q) => X && $(X, Z, J[Q]), Bi0 = (Z, J) => ($, X, Y, Q) => X && $(X, Z, J.get(Q)), wi0 = (Z, J) => ($, X, Y, Q) => X && $(X, Z, J.get(Y.name)), ji0 = (Z, J) => ($, X, Y, Q) => X && $(X, Z, J[Y.name]), Ti0 = (Z, J, $) => {
  let X = Z.type.children.map((Q) => $Q.getVisitFn(Q.type)), Y = $ instanceof Map ? wi0(J, $) : $ instanceof wZ ? Bi0(J, $) : Array.isArray($) ? Ai0(J, $) : ji0(J, $);
  Z.type.children.forEach((Q, W) => Y(X[W], Z.children[W], Q, W));
}, _i0 = (Z, J, $) => {
  Z.type.mode === pJ.Dense ? JQ0(Z, J, $) : $Q0(Z, J, $);
}, JQ0 = (Z, J, $) => {
  let X = Z.type.typeIdToChildIndex[Z.typeIds[J]], Y = Z.children[X];
  $Q.visit(Y, Z.valueOffsets[J], $);
}, $Q0 = (Z, J, $) => {
  let X = Z.type.typeIdToChildIndex[Z.typeIds[J]], Y = Z.children[X];
  $Q.visit(Y, J, $);
}, Vi0 = (Z, J, $) => {
  var X;
  (X = Z.dictionary) === null || X === void 0 || X.set(Z.values[J], $);
}, Ol = (Z, J, $) => {
  Z.type.unit === zW.DAY_TIME ? qv(Z, J, $) : Fv(Z, J, $);
}, qv = ({ values: Z }, J, $) => {
  Z.set($.subarray(0, 2), 2 * J);
}, Fv = ({ values: Z }, J, $) => {
  Z[J] = $[0] * 12 + $[1] % 12;
}, Ii0 = (Z, J, $) => {
  let { stride: X } = Z, Y = Z.children[0], Q = $Q.getVisitFn(Y);
  if (Array.isArray($))
    for (let W = -1, K = J * X;++W < X; )
      Q(Y, K + W, $[W]);
  else
    for (let W = -1, K = J * X;++W < X; )
      Q(Y, K + W, $.get(W));
};
qZ.prototype.visitBool = VZ(Ri0);
qZ.prototype.visitInt = VZ(zF);
qZ.prototype.visitInt8 = VZ(zF);
qZ.prototype.visitInt16 = VZ(zF);
qZ.prototype.visitInt32 = VZ(zF);
qZ.prototype.visitInt64 = VZ(zF);
qZ.prototype.visitUint8 = VZ(zF);
qZ.prototype.visitUint16 = VZ(zF);
qZ.prototype.visitUint32 = VZ(zF);
qZ.prototype.visitUint64 = VZ(zF);
qZ.prototype.visitFloat = VZ(Ei0);
qZ.prototype.visitFloat16 = VZ(ZQ0);
qZ.prototype.visitFloat32 = VZ(ql);
qZ.prototype.visitFloat64 = VZ(ql);
qZ.prototype.visitUtf8 = VZ(zi0);
qZ.prototype.visitBinary = VZ(Oi0);
qZ.prototype.visitFixedSizeBinary = VZ(Fl);
qZ.prototype.visitDate = VZ(Ul);
qZ.prototype.visitDateDay = VZ(Jv);
qZ.prototype.visitDateMillisecond = VZ($v);
qZ.prototype.visitTimestamp = VZ(Ll);
qZ.prototype.visitTimestampSecond = VZ(Xv);
qZ.prototype.visitTimestampMillisecond = VZ(Yv);
qZ.prototype.visitTimestampMicrosecond = VZ(Qv);
qZ.prototype.visitTimestampNanosecond = VZ(Wv);
qZ.prototype.visitTime = VZ(Rl);
qZ.prototype.visitTimeSecond = VZ(Kv);
qZ.prototype.visitTimeMillisecond = VZ(Gv);
qZ.prototype.visitTimeMicrosecond = VZ(Hv);
qZ.prototype.visitTimeNanosecond = VZ(Nv);
qZ.prototype.visitDecimal = VZ(El);
qZ.prototype.visitList = VZ(Di0);
qZ.prototype.visitStruct = VZ(Ti0);
qZ.prototype.visitUnion = VZ(_i0);
qZ.prototype.visitDenseUnion = VZ(JQ0);
qZ.prototype.visitSparseUnion = VZ($Q0);
qZ.prototype.visitDictionary = VZ(Vi0);
qZ.prototype.visitInterval = VZ(Ol);
qZ.prototype.visitIntervalDayTime = VZ(qv);
qZ.prototype.visitIntervalYearMonth = VZ(Fv);
qZ.prototype.visitFixedSizeList = VZ(Ii0);
qZ.prototype.visitMap = VZ(Mi0);
var $Q = new qZ;

// node_modules/apache-arrow/row/struct.mjs
var lG = Symbol.for("parent"), bD = Symbol.for("rowIndex");

class jO {
  constructor(Z, J) {
    return this[lG] = Z, this[bD] = J, new Proxy(this, new YQ0);
  }
  toArray() {
    return Object.values(this.toJSON());
  }
  toJSON() {
    let Z = this[bD], J = this[lG], $ = J.type.children, X = {};
    for (let Y = -1, Q = $.length;++Y < Q; )
      X[$[Y].name] = n$.visit(J.children[Y], Z);
    return X;
  }
  toString() {
    return `{${[...this].map(([Z, J]) => `${uG(Z)}: ${uG(J)}`).join(", ")}}`;
  }
  [Symbol.for("nodejs.util.inspect.custom")]() {
    return this.toString();
  }
  [Symbol.iterator]() {
    return new XQ0(this[lG], this[bD]);
  }
}

class XQ0 {
  constructor(Z, J) {
    this.childIndex = 0, this.children = Z.children, this.rowIndex = J, this.childFields = Z.type.children, this.numChildren = this.childFields.length;
  }
  [Symbol.iterator]() {
    return this;
  }
  next() {
    let Z = this.childIndex;
    if (Z < this.numChildren)
      return this.childIndex = Z + 1, {
        done: !1,
        value: [
          this.childFields[Z].name,
          n$.visit(this.children[Z], this.rowIndex)
        ]
      };
    return { done: !0, value: null };
  }
}
Object.defineProperties(jO.prototype, {
  [Symbol.toStringTag]: { enumerable: !1, configurable: !1, value: "Row" },
  [lG]: { writable: !0, enumerable: !1, configurable: !1, value: null },
  [bD]: { writable: !0, enumerable: !1, configurable: !1, value: -1 }
});

class YQ0 {
  isExtensible() {
    return !1;
  }
  deleteProperty() {
    return !1;
  }
  preventExtensions() {
    return !0;
  }
  ownKeys(Z) {
    return Z[lG].type.children.map((J) => J.name);
  }
  has(Z, J) {
    return Z[lG].type.children.findIndex(($) => $.name === J) !== -1;
  }
  getOwnPropertyDescriptor(Z, J) {
    if (Z[lG].type.children.findIndex(($) => $.name === J) !== -1)
      return { writable: !0, enumerable: !0, configurable: !0 };
    return;
  }
  get(Z, J) {
    if (Reflect.has(Z, J))
      return Z[J];
    let $ = Z[lG].type.children.findIndex((X) => X.name === J);
    if ($ !== -1) {
      let X = n$.visit(Z[lG].children[$], Z[bD]);
      return Reflect.set(Z, J, X), X;
    }
  }
  set(Z, J, $) {
    let X = Z[lG].type.children.findIndex((Y) => Y.name === J);
    if (X !== -1)
      return $Q.visit(Z[lG].children[X], Z[bD], $), Reflect.set(Z, J, $);
    else if (Reflect.has(Z, J) || typeof J === "symbol")
      return Reflect.set(Z, J, $);
    return !1;
  }
}

// node_modules/apache-arrow/visitor/get.mjs
class QZ extends g6 {
}
function jZ(Z) {
  return (J, $) => J.getValid($) ? Z(J, $) : null;
}
var Pi0 = (Z, J) => 86400000 * Z[J], zl = (Z, J) => 4294967296 * Z[J + 1] + (Z[J] >>> 0), Ci0 = (Z, J) => 4294967296 * (Z[J + 1] / 1000) + (Z[J] >>> 0) / 1000, ki0 = (Z, J) => 4294967296 * (Z[J + 1] / 1e6) + (Z[J] >>> 0) / 1e6, QQ0 = (Z) => new Date(Z), vi0 = (Z, J) => QQ0(Pi0(Z, J)), Si0 = (Z, J) => QQ0(zl(Z, J)), fi0 = (Z, J) => null, WQ0 = (Z, J, $) => {
  if ($ + 1 >= J.length)
    return null;
  let X = J[$], Y = J[$ + 1];
  return Z.subarray(X, Y);
}, hi0 = ({ offset: Z, values: J }, $) => {
  let X = Z + $;
  return (J[X >> 3] & 1 << X % 8) !== 0;
}, KQ0 = ({ values: Z }, J) => vi0(Z, J), GQ0 = ({ values: Z }, J) => Si0(Z, J * 2), DL = ({ stride: Z, values: J }, $) => J[Z * $], bi0 = ({ stride: Z, values: J }, $) => Zv(J[Z * $]), HQ0 = ({ values: Z }, J) => Z[J], xi0 = ({ stride: Z, values: J }, $) => J.subarray(Z * $, Z * ($ + 1)), yi0 = ({ values: Z, valueOffsets: J }, $) => WQ0(Z, J, $), gi0 = ({ values: Z, valueOffsets: J }, $) => {
  let X = WQ0(Z, J, $);
  return X !== null ? RT(X) : null;
}, mi0 = ({ values: Z }, J) => Z[J], di0 = ({ type: Z, values: J }, $) => Z.precision !== NJ.HALF ? J[$] : Zv(J[$]), pi0 = (Z, J) => Z.type.unit === JQ.DAY ? KQ0(Z, J) : GQ0(Z, J), NQ0 = ({ values: Z }, J) => 1000 * zl(Z, J * 2), qQ0 = ({ values: Z }, J) => zl(Z, J * 2), FQ0 = ({ values: Z }, J) => Ci0(Z, J * 2), UQ0 = ({ values: Z }, J) => ki0(Z, J * 2), ui0 = (Z, J) => {
  switch (Z.type.unit) {
    case aZ.SECOND:
      return NQ0(Z, J);
    case aZ.MILLISECOND:
      return qQ0(Z, J);
    case aZ.MICROSECOND:
      return FQ0(Z, J);
    case aZ.NANOSECOND:
      return UQ0(Z, J);
  }
}, LQ0 = ({ values: Z }, J) => Z[J], RQ0 = ({ values: Z }, J) => Z[J], EQ0 = ({ values: Z }, J) => Z[J], OQ0 = ({ values: Z }, J) => Z[J], ci0 = (Z, J) => {
  switch (Z.type.unit) {
    case aZ.SECOND:
      return LQ0(Z, J);
    case aZ.MILLISECOND:
      return RQ0(Z, J);
    case aZ.MICROSECOND:
      return EQ0(Z, J);
    case aZ.NANOSECOND:
      return OQ0(Z, J);
  }
}, li0 = ({ values: Z, stride: J }, $) => DT.decimal(Z.subarray(J * $, J * ($ + 1))), ni0 = (Z, J) => {
  let { valueOffsets: $, stride: X, children: Y } = Z, { [J * X]: Q, [J * X + 1]: W } = $, G = Y[0].slice(Q, W - Q);
  return new wZ([G]);
}, ii0 = (Z, J) => {
  let { valueOffsets: $, children: X } = Z, { [J]: Y, [J + 1]: Q } = $, W = X[0];
  return new DF(W.slice(Y, Q - Y));
}, oi0 = (Z, J) => {
  return new jO(Z, J);
}, si0 = (Z, J) => {
  return Z.type.mode === pJ.Dense ? zQ0(Z, J) : DQ0(Z, J);
}, zQ0 = (Z, J) => {
  let $ = Z.type.typeIdToChildIndex[Z.typeIds[J]], X = Z.children[$];
  return n$.visit(X, Z.valueOffsets[J]);
}, DQ0 = (Z, J) => {
  let $ = Z.type.typeIdToChildIndex[Z.typeIds[J]], X = Z.children[$];
  return n$.visit(X, J);
}, ai0 = (Z, J) => {
  var $;
  return ($ = Z.dictionary) === null || $ === void 0 ? void 0 : $.get(Z.values[J]);
}, ri0 = (Z, J) => Z.type.unit === zW.DAY_TIME ? MQ0(Z, J) : AQ0(Z, J), MQ0 = ({ values: Z }, J) => Z.subarray(2 * J, 2 * (J + 1)), AQ0 = ({ values: Z }, J) => {
  let $ = Z[J], X = new Int32Array(2);
  return X[0] = Math.trunc($ / 12), X[1] = Math.trunc($ % 12), X;
}, ti0 = (Z, J) => {
  let { stride: $, children: X } = Z, Q = X[0].slice(J * $, $);
  return new wZ([Q]);
};
QZ.prototype.visitNull = jZ(fi0);
QZ.prototype.visitBool = jZ(hi0);
QZ.prototype.visitInt = jZ(mi0);
QZ.prototype.visitInt8 = jZ(DL);
QZ.prototype.visitInt16 = jZ(DL);
QZ.prototype.visitInt32 = jZ(DL);
QZ.prototype.visitInt64 = jZ(HQ0);
QZ.prototype.visitUint8 = jZ(DL);
QZ.prototype.visitUint16 = jZ(DL);
QZ.prototype.visitUint32 = jZ(DL);
QZ.prototype.visitUint64 = jZ(HQ0);
QZ.prototype.visitFloat = jZ(di0);
QZ.prototype.visitFloat16 = jZ(bi0);
QZ.prototype.visitFloat32 = jZ(DL);
QZ.prototype.visitFloat64 = jZ(DL);
QZ.prototype.visitUtf8 = jZ(gi0);
QZ.prototype.visitBinary = jZ(yi0);
QZ.prototype.visitFixedSizeBinary = jZ(xi0);
QZ.prototype.visitDate = jZ(pi0);
QZ.prototype.visitDateDay = jZ(KQ0);
QZ.prototype.visitDateMillisecond = jZ(GQ0);
QZ.prototype.visitTimestamp = jZ(ui0);
QZ.prototype.visitTimestampSecond = jZ(NQ0);
QZ.prototype.visitTimestampMillisecond = jZ(qQ0);
QZ.prototype.visitTimestampMicrosecond = jZ(FQ0);
QZ.prototype.visitTimestampNanosecond = jZ(UQ0);
QZ.prototype.visitTime = jZ(ci0);
QZ.prototype.visitTimeSecond = jZ(LQ0);
QZ.prototype.visitTimeMillisecond = jZ(RQ0);
QZ.prototype.visitTimeMicrosecond = jZ(EQ0);
QZ.prototype.visitTimeNanosecond = jZ(OQ0);
QZ.prototype.visitDecimal = jZ(li0);
QZ.prototype.visitList = jZ(ni0);
QZ.prototype.visitStruct = jZ(oi0);
QZ.prototype.visitUnion = jZ(si0);
QZ.prototype.visitDenseUnion = jZ(zQ0);
QZ.prototype.visitSparseUnion = jZ(DQ0);
QZ.prototype.visitDictionary = jZ(ai0);
QZ.prototype.visitInterval = jZ(ri0);
QZ.prototype.visitIntervalDayTime = jZ(MQ0);
QZ.prototype.visitIntervalYearMonth = jZ(AQ0);
QZ.prototype.visitFixedSizeList = jZ(ti0);
QZ.prototype.visitMap = jZ(ii0);
var n$ = new QZ;

// node_modules/apache-arrow/row/map.mjs
var J3 = Symbol.for("keys"), xD = Symbol.for("vals");

class DF {
  constructor(Z) {
    return this[J3] = new wZ([Z.children[0]]).memoize(), this[xD] = Z.children[1], new Proxy(this, new wQ0);
  }
  [Symbol.iterator]() {
    return new BQ0(this[J3], this[xD]);
  }
  get size() {
    return this[J3].length;
  }
  toArray() {
    return Object.values(this.toJSON());
  }
  toJSON() {
    let Z = this[J3], J = this[xD], $ = {};
    for (let X = -1, Y = Z.length;++X < Y; )
      $[Z.get(X)] = n$.visit(J, X);
    return $;
  }
  toString() {
    return `{${[...this].map(([Z, J]) => `${uG(Z)}: ${uG(J)}`).join(", ")}}`;
  }
  [Symbol.for("nodejs.util.inspect.custom")]() {
    return this.toString();
  }
}

class BQ0 {
  constructor(Z, J) {
    this.keys = Z, this.vals = J, this.keyIndex = 0, this.numKeys = Z.length;
  }
  [Symbol.iterator]() {
    return this;
  }
  next() {
    let Z = this.keyIndex;
    if (Z === this.numKeys)
      return { done: !0, value: null };
    return this.keyIndex++, {
      done: !1,
      value: [
        this.keys.get(Z),
        n$.visit(this.vals, Z)
      ]
    };
  }
}

class wQ0 {
  isExtensible() {
    return !1;
  }
  deleteProperty() {
    return !1;
  }
  preventExtensions() {
    return !0;
  }
  ownKeys(Z) {
    return Z[J3].toArray().map(String);
  }
  has(Z, J) {
    return Z[J3].includes(J);
  }
  getOwnPropertyDescriptor(Z, J) {
    if (Z[J3].indexOf(J) !== -1)
      return { writable: !0, enumerable: !0, configurable: !0 };
    return;
  }
  get(Z, J) {
    if (Reflect.has(Z, J))
      return Z[J];
    let $ = Z[J3].indexOf(J);
    if ($ !== -1) {
      let X = n$.visit(Reflect.get(Z, xD), $);
      return Reflect.set(Z, J, X), X;
    }
  }
  set(Z, J, $) {
    let X = Z[J3].indexOf(J);
    if (X !== -1)
      return $Q.visit(Reflect.get(Z, xD), X, $), Reflect.set(Z, J, $);
    else if (Reflect.has(Z, J))
      return Reflect.set(Z, J, $);
    return !1;
  }
}
Object.defineProperties(DF.prototype, {
  [Symbol.toStringTag]: { enumerable: !1, configurable: !1, value: "Row" },
  [J3]: { writable: !0, enumerable: !1, configurable: !1, value: null },
  [xD]: { writable: !0, enumerable: !1, configurable: !1, value: null }
});

// node_modules/apache-arrow/util/vector.mjs
function ei0(Z, J, $) {
  let X = Z.length, Y = J > -1 ? J : X + J % X;
  return $ ? $(Z, Y) : Y;
}
var jQ0;
function AT(Z, J, $, X) {
  let { length: Y = 0 } = Z, Q = typeof J !== "number" ? 0 : J, W = typeof $ !== "number" ? Y : $;
  return Q < 0 && (Q = (Q % Y + Y) % Y), W < 0 && (W = (W % Y + Y) % Y), W < Q && (jQ0 = Q, Q = W, W = jQ0), W > Y && (W = Y), X ? X(Z, Q, W) : [Q, W];
}
var TQ0 = (Z) => Z !== Z;
function ML(Z) {
  if (typeof Z !== "object" || Z === null) {
    if (TQ0(Z))
      return TQ0;
    return ($) => $ === Z;
  }
  if (Z instanceof Date) {
    let $ = Z.valueOf();
    return (X) => X instanceof Date ? X.valueOf() === $ : !1;
  }
  if (ArrayBuffer.isView(Z))
    return ($) => $ ? oc(Z, $) : !1;
  if (Z instanceof Map)
    return Jo0(Z);
  if (Array.isArray(Z))
    return Zo0(Z);
  if (Z instanceof wZ)
    return $o0(Z);
  return Xo0(Z, !0);
}
function Zo0(Z) {
  let J = [];
  for (let $ = -1, X = Z.length;++$ < X; )
    J[$] = ML(Z[$]);
  return Uv(J);
}
function Jo0(Z) {
  let J = -1, $ = [];
  for (let X of Z.values())
    $[++J] = ML(X);
  return Uv($);
}
function $o0(Z) {
  let J = [];
  for (let $ = -1, X = Z.length;++$ < X; )
    J[$] = ML(Z.get($));
  return Uv(J);
}
function Xo0(Z, J = !1) {
  let $ = Object.keys(Z);
  if (!J && $.length === 0)
    return () => !1;
  let X = [];
  for (let Y = -1, Q = $.length;++Y < Q; )
    X[Y] = ML(Z[$[Y]]);
  return Uv(X, $);
}
function Uv(Z, J) {
  return ($) => {
    if (!$ || typeof $ !== "object")
      return !1;
    switch ($.constructor) {
      case Array:
        return Yo0(Z, $);
      case Map:
        return _Q0(Z, $, $.keys());
      case DF:
      case jO:
      case Object:
      case void 0:
        return _Q0(Z, $, J || Object.keys($));
    }
    return $ instanceof wZ ? Qo0(Z, $) : !1;
  };
}
function Yo0(Z, J) {
  let $ = Z.length;
  if (J.length !== $)
    return !1;
  for (let X = -1;++X < $; )
    if (!Z[X](J[X]))
      return !1;
  return !0;
}
function Qo0(Z, J) {
  let $ = Z.length;
  if (J.length !== $)
    return !1;
  for (let X = -1;++X < $; )
    if (!Z[X](J.get(X)))
      return !1;
  return !0;
}
function _Q0(Z, J, $) {
  let X = $[Symbol.iterator](), Y = J instanceof Map ? J.keys() : Object.keys(J)[Symbol.iterator](), Q = J instanceof Map ? J.values() : Object.values(J)[Symbol.iterator](), W = 0, K = Z.length, G = Q.next(), H = X.next(), N = Y.next();
  for (;W < K && !H.done && !N.done && !G.done; ++W, H = X.next(), N = Y.next(), G = Q.next())
    if (H.value !== N.value || !Z[W](G.value))
      break;
  if (W === K && H.done && N.done && G.done)
    return !0;
  return X.return && X.return(), Y.return && Y.return(), Q.return && Q.return(), !1;
}

// node_modules/apache-arrow/util/bit.mjs
var Ml = {};
y9(Ml, {
  truncateBitmap: () => yD,
  setBool: () => Wo0,
  popcnt_uint32: () => Lv,
  popcnt_bit_range: () => BT,
  popcnt_array: () => IQ0,
  packBools: () => TO,
  getBool: () => Rv,
  getBit: () => VQ0,
  BitIterator: () => gD
});
function Rv(Z, J, $, X) {
  return ($ & 1 << X) !== 0;
}
function VQ0(Z, J, $, X) {
  return ($ & 1 << X) >> X;
}
function Wo0(Z, J, $) {
  return $ ? !!(Z[J >> 3] |= 1 << J % 8) || !0 : !(Z[J >> 3] &= ~(1 << J % 8)) && !1;
}
function yD(Z, J, $) {
  let X = $.byteLength + 7 & -8;
  if (Z > 0 || $.byteLength < X) {
    let Y = new Uint8Array(X);
    return Y.set(Z % 8 === 0 ? $.subarray(Z >> 3) : TO(new gD($, Z, J, null, Rv)).subarray(0, X)), Y;
  }
  return $;
}
function TO(Z) {
  let J = [], $ = 0, X = 0, Y = 0;
  for (let W of Z)
    if (W && (Y |= 1 << X), ++X === 8)
      J[$++] = Y, Y = X = 0;
  if ($ === 0 || X > 0)
    J[$++] = Y;
  let Q = new Uint8Array(J.length + 7 & -8);
  return Q.set(J), Q;
}

class gD {
  constructor(Z, J, $, X, Y) {
    this.bytes = Z, this.length = $, this.context = X, this.get = Y, this.bit = J % 8, this.byteIndex = J >> 3, this.byte = Z[this.byteIndex++], this.index = 0;
  }
  next() {
    if (this.index < this.length) {
      if (this.bit === 8)
        this.bit = 0, this.byte = this.bytes[this.byteIndex++];
      return {
        value: this.get(this.context, this.index++, this.byte, this.bit++)
      };
    }
    return { done: !0, value: null };
  }
  [Symbol.iterator]() {
    return this;
  }
}
function BT(Z, J, $) {
  if ($ - J <= 0)
    return 0;
  if ($ - J < 8) {
    let Q = 0;
    for (let W of new gD(Z, J, $ - J, Z, VQ0))
      Q += W;
    return Q;
  }
  let X = $ >> 3 << 3, Y = J + (J % 8 === 0 ? 0 : 8 - J % 8);
  return BT(Z, J, Y) + BT(Z, X, $) + IQ0(Z, Y >> 3, X - Y >> 3);
}
function IQ0(Z, J, $) {
  let X = 0, Y = Math.trunc(J), Q = new DataView(Z.buffer, Z.byteOffset, Z.byteLength), W = $ === void 0 ? Z.byteLength : Y + $;
  while (W - Y >= 4)
    X += Lv(Q.getUint32(Y)), Y += 4;
  while (W - Y >= 2)
    X += Lv(Q.getUint16(Y)), Y += 2;
  while (W - Y >= 1)
    X += Lv(Q.getUint8(Y)), Y += 1;
  return X;
}
function Lv(Z) {
  let J = Math.trunc(Z);
  return J = J - (J >>> 1 & 1431655765), J = (J & 858993459) + (J >>> 2 & 858993459), (J + (J >>> 4) & 252645135) * 16843009 >>> 24;
}

// node_modules/apache-arrow/data.mjs
var Ko0 = -1;

class O7 {
  constructor(Z, J, $, X, Y, Q = [], W) {
    this.type = Z, this.children = Q, this.dictionary = W, this.offset = Math.floor(Math.max(J || 0, 0)), this.length = Math.floor(Math.max($ || 0, 0)), this._nullCount = Math.floor(Math.max(X || 0, -1));
    let K;
    if (Y instanceof O7)
      this.stride = Y.stride, this.values = Y.values, this.typeIds = Y.typeIds, this.nullBitmap = Y.nullBitmap, this.valueOffsets = Y.valueOffsets;
    else if (this.stride = QK(Z), Y)
      (K = Y[0]) && (this.valueOffsets = K), (K = Y[1]) && (this.values = K), (K = Y[2]) && (this.nullBitmap = K), (K = Y[3]) && (this.typeIds = K);
    this.nullable = this._nullCount !== 0 && this.nullBitmap && this.nullBitmap.byteLength > 0;
  }
  get typeId() {
    return this.type.typeId;
  }
  get ArrayType() {
    return this.type.ArrayType;
  }
  get buffers() {
    return [this.valueOffsets, this.values, this.nullBitmap, this.typeIds];
  }
  get byteLength() {
    let Z = 0, { valueOffsets: J, values: $, nullBitmap: X, typeIds: Y } = this;
    return J && (Z += J.byteLength), $ && (Z += $.byteLength), X && (Z += X.byteLength), Y && (Z += Y.byteLength), this.children.reduce((Q, W) => Q + W.byteLength, Z);
  }
  get nullCount() {
    let Z = this._nullCount, J;
    if (Z <= Ko0 && (J = this.nullBitmap))
      this._nullCount = Z = this.length - BT(J, this.offset, this.offset + this.length);
    return Z;
  }
  getValid(Z) {
    if (this.nullable && this.nullCount > 0) {
      let J = this.offset + Z;
      return (this.nullBitmap[J >> 3] & 1 << J % 8) !== 0;
    }
    return !0;
  }
  setValid(Z, J) {
    if (!this.nullable)
      return J;
    if (!this.nullBitmap || this.nullBitmap.byteLength <= Z >> 3) {
      let { nullBitmap: K } = this._changeLengthAndBackfillNullBitmap(this.length);
      Object.assign(this, { nullBitmap: K, _nullCount: 0 });
    }
    let { nullBitmap: $, offset: X } = this, Y = X + Z >> 3, Q = (X + Z) % 8, W = $[Y] >> Q & 1;
    return J ? W === 0 && ($[Y] |= 1 << Q, this._nullCount = this.nullCount + 1) : W === 1 && ($[Y] &= ~(1 << Q), this._nullCount = this.nullCount - 1), J;
  }
  clone(Z = this.type, J = this.offset, $ = this.length, X = this._nullCount, Y = this, Q = this.children) {
    return new O7(Z, J, $, X, Y, Q, this.dictionary);
  }
  slice(Z, J) {
    let { stride: $, typeId: X, children: Y } = this, Q = +(this._nullCount === 0) - 1, W = X === 16 ? $ : 1, K = this._sliceBuffers(Z, J, $, X);
    return this.clone(this.type, this.offset + Z, J, Q, K, Y.length === 0 || this.valueOffsets ? Y : this._sliceChildren(Y, W * Z, W * J));
  }
  _changeLengthAndBackfillNullBitmap(Z) {
    if (this.typeId === j1.Null)
      return this.clone(this.type, 0, Z, 0);
    let { length: J, nullCount: $ } = this, X = new Uint8Array((Z + 63 & -64) >> 3).fill(255, 0, J >> 3);
    if (X[J >> 3] = (1 << J - (J & -8)) - 1, $ > 0)
      X.set(yD(this.offset, J, this.nullBitmap), 0);
    let Y = this.buffers;
    return Y[eK.VALIDITY] = X, this.clone(this.type, 0, Z, $ + (Z - J), Y);
  }
  _sliceBuffers(Z, J, $, X) {
    let Y, { buffers: Q } = this;
    return (Y = Q[eK.TYPE]) && (Q[eK.TYPE] = Y.subarray(Z, Z + J)), (Y = Q[eK.OFFSET]) && (Q[eK.OFFSET] = Y.subarray(Z, Z + J + 1)) || (Y = Q[eK.DATA]) && (Q[eK.DATA] = X === 6 ? Y : Y.subarray($ * Z, $ * (Z + J))), Q;
  }
  _sliceChildren(Z, J, $) {
    return Z.map((X) => X.slice(J, $));
  }
}
O7.prototype.children = Object.freeze([]);

class wT extends g6 {
  visit(Z) {
    return this.getVisitFn(Z.type).call(this, Z);
  }
  visitNull(Z) {
    let { ["type"]: J, ["offset"]: $ = 0, ["length"]: X = 0 } = Z;
    return new O7(J, $, X, 0);
  }
  visitBool(Z) {
    let { ["type"]: J, ["offset"]: $ = 0 } = Z, X = YZ(Z.nullBitmap), Y = gZ(J.ArrayType, Z.data), { ["length"]: Q = Y.length >> 3, ["nullCount"]: W = Z.nullBitmap ? -1 : 0 } = Z;
    return new O7(J, $, Q, W, [void 0, Y, X]);
  }
  visitInt(Z) {
    let { ["type"]: J, ["offset"]: $ = 0 } = Z, X = YZ(Z.nullBitmap), Y = gZ(J.ArrayType, Z.data), { ["length"]: Q = Y.length, ["nullCount"]: W = Z.nullBitmap ? -1 : 0 } = Z;
    return new O7(J, $, Q, W, [void 0, Y, X]);
  }
  visitFloat(Z) {
    let { ["type"]: J, ["offset"]: $ = 0 } = Z, X = YZ(Z.nullBitmap), Y = gZ(J.ArrayType, Z.data), { ["length"]: Q = Y.length, ["nullCount"]: W = Z.nullBitmap ? -1 : 0 } = Z;
    return new O7(J, $, Q, W, [void 0, Y, X]);
  }
  visitUtf8(Z) {
    let { ["type"]: J, ["offset"]: $ = 0 } = Z, X = YZ(Z.data), Y = YZ(Z.nullBitmap), Q = wO(Z.valueOffsets), { ["length"]: W = Q.length - 1, ["nullCount"]: K = Z.nullBitmap ? -1 : 0 } = Z;
    return new O7(J, $, W, K, [Q, X, Y]);
  }
  visitBinary(Z) {
    let { ["type"]: J, ["offset"]: $ = 0 } = Z, X = YZ(Z.data), Y = YZ(Z.nullBitmap), Q = wO(Z.valueOffsets), { ["length"]: W = Q.length - 1, ["nullCount"]: K = Z.nullBitmap ? -1 : 0 } = Z;
    return new O7(J, $, W, K, [Q, X, Y]);
  }
  visitFixedSizeBinary(Z) {
    let { ["type"]: J, ["offset"]: $ = 0 } = Z, X = YZ(Z.nullBitmap), Y = gZ(J.ArrayType, Z.data), { ["length"]: Q = Y.length / QK(J), ["nullCount"]: W = Z.nullBitmap ? -1 : 0 } = Z;
    return new O7(J, $, Q, W, [void 0, Y, X]);
  }
  visitDate(Z) {
    let { ["type"]: J, ["offset"]: $ = 0 } = Z, X = YZ(Z.nullBitmap), Y = gZ(J.ArrayType, Z.data), { ["length"]: Q = Y.length / QK(J), ["nullCount"]: W = Z.nullBitmap ? -1 : 0 } = Z;
    return new O7(J, $, Q, W, [void 0, Y, X]);
  }
  visitTimestamp(Z) {
    let { ["type"]: J, ["offset"]: $ = 0 } = Z, X = YZ(Z.nullBitmap), Y = gZ(J.ArrayType, Z.data), { ["length"]: Q = Y.length / QK(J), ["nullCount"]: W = Z.nullBitmap ? -1 : 0 } = Z;
    return new O7(J, $, Q, W, [void 0, Y, X]);
  }
  visitTime(Z) {
    let { ["type"]: J, ["offset"]: $ = 0 } = Z, X = YZ(Z.nullBitmap), Y = gZ(J.ArrayType, Z.data), { ["length"]: Q = Y.length / QK(J), ["nullCount"]: W = Z.nullBitmap ? -1 : 0 } = Z;
    return new O7(J, $, Q, W, [void 0, Y, X]);
  }
  visitDecimal(Z) {
    let { ["type"]: J, ["offset"]: $ = 0 } = Z, X = YZ(Z.nullBitmap), Y = gZ(J.ArrayType, Z.data), { ["length"]: Q = Y.length / QK(J), ["nullCount"]: W = Z.nullBitmap ? -1 : 0 } = Z;
    return new O7(J, $, Q, W, [void 0, Y, X]);
  }
  visitList(Z) {
    let { ["type"]: J, ["offset"]: $ = 0, ["child"]: X } = Z, Y = YZ(Z.nullBitmap), Q = wO(Z.valueOffsets), { ["length"]: W = Q.length - 1, ["nullCount"]: K = Z.nullBitmap ? -1 : 0 } = Z;
    return new O7(J, $, W, K, [Q, void 0, Y], [X]);
  }
  visitStruct(Z) {
    let { ["type"]: J, ["offset"]: $ = 0, ["children"]: X = [] } = Z, Y = YZ(Z.nullBitmap), { length: Q = X.reduce((K, { length: G }) => Math.max(K, G), 0), nullCount: W = Z.nullBitmap ? -1 : 0 } = Z;
    return new O7(J, $, Q, W, [void 0, void 0, Y], X);
  }
  visitUnion(Z) {
    let { ["type"]: J, ["offset"]: $ = 0, ["children"]: X = [] } = Z, Y = YZ(Z.nullBitmap), Q = gZ(J.ArrayType, Z.typeIds), { ["length"]: W = Q.length, ["nullCount"]: K = Z.nullBitmap ? -1 : 0 } = Z;
    if (L6.isSparseUnion(J))
      return new O7(J, $, W, K, [void 0, void 0, Y, Q], X);
    let G = wO(Z.valueOffsets);
    return new O7(J, $, W, K, [G, void 0, Y, Q], X);
  }
  visitDictionary(Z) {
    let { ["type"]: J, ["offset"]: $ = 0 } = Z, X = YZ(Z.nullBitmap), Y = gZ(J.indices.ArrayType, Z.data), { ["dictionary"]: Q = new wZ([new wT().visit({ type: J.dictionary })]) } = Z, { ["length"]: W = Y.length, ["nullCount"]: K = Z.nullBitmap ? -1 : 0 } = Z;
    return new O7(J, $, W, K, [void 0, Y, X], [], Q);
  }
  visitInterval(Z) {
    let { ["type"]: J, ["offset"]: $ = 0 } = Z, X = YZ(Z.nullBitmap), Y = gZ(J.ArrayType, Z.data), { ["length"]: Q = Y.length / QK(J), ["nullCount"]: W = Z.nullBitmap ? -1 : 0 } = Z;
    return new O7(J, $, Q, W, [void 0, Y, X]);
  }
  visitFixedSizeList(Z) {
    let { ["type"]: J, ["offset"]: $ = 0, ["child"]: X = new wT().visit({ type: J.valueType }) } = Z, Y = YZ(Z.nullBitmap), { ["length"]: Q = X.length / QK(J), ["nullCount"]: W = Z.nullBitmap ? -1 : 0 } = Z;
    return new O7(J, $, Q, W, [void 0, void 0, Y], [X]);
  }
  visitMap(Z) {
    let { ["type"]: J, ["offset"]: $ = 0, ["child"]: X = new wT().visit({ type: J.childType }) } = Z, Y = YZ(Z.nullBitmap), Q = wO(Z.valueOffsets), { ["length"]: W = Q.length - 1, ["nullCount"]: K = Z.nullBitmap ? -1 : 0 } = Z;
    return new O7(J, $, W, K, [Q, void 0, Y], [X]);
  }
}
function FZ(Z) {
  return new wT().visit(Z);
}

// node_modules/apache-arrow/util/chunk.mjs
class Ev {
  constructor(Z = 0, J) {
    this.numChunks = Z, this.getChunkIterator = J, this.chunkIndex = 0, this.chunkIterator = this.getChunkIterator(0);
  }
  next() {
    while (this.chunkIndex < this.numChunks) {
      let Z = this.chunkIterator.next();
      if (!Z.done)
        return Z;
      if (++this.chunkIndex < this.numChunks)
        this.chunkIterator = this.getChunkIterator(this.chunkIndex);
    }
    return { done: !0, value: null };
  }
  [Symbol.iterator]() {
    return this;
  }
}
function Ov(Z) {
  return Z.reduce((J, $) => J + $.nullCount, 0);
}
function zv(Z) {
  return Z.reduce((J, $, X) => {
    return J[X + 1] = J[X] + $.length, J;
  }, new Uint32Array(Z.length + 1));
}
function Dv(Z, J, $, X) {
  let Y = [];
  for (let Q = -1, W = Z.length;++Q < W; ) {
    let K = Z[Q], G = J[Q], { length: H } = K;
    if (G >= X)
      break;
    if ($ >= G + H)
      continue;
    if (G >= $ && G + H <= X) {
      Y.push(K);
      continue;
    }
    let N = Math.max(0, $ - G), q = Math.min(X - G, H);
    Y.push(K.slice(N, q - N));
  }
  if (Y.length === 0)
    Y.push(Z[0].slice(0, 0));
  return Y;
}
function Al(Z, J, $, X) {
  let Y = 0, Q = 0, W = J.length - 1;
  do {
    if (Y >= W - 1)
      return $ < J[W] ? X(Z, Y, $ - J[Y]) : null;
    Q = Y + Math.trunc((W - Y) * 0.5), $ < J[Q] ? W = Q : Y = Q;
  } while (Y < W);
}
function jT(Z, J) {
  return Z.getValid(J);
}
function AL(Z) {
  function J($, X, Y) {
    return Z($[X], Y);
  }
  return function($) {
    let X = this.data;
    return Al(X, this._offsets, $, J);
  };
}
function Mv(Z) {
  let J;
  function $(X, Y, Q) {
    return Z(X[Y], Q, J);
  }
  return function(X, Y) {
    let Q = this.data;
    J = Y;
    let W = Al(Q, this._offsets, X, $);
    return J = void 0, W;
  };
}
function Av(Z) {
  let J;
  function $(X, Y, Q) {
    let W = Q, K = 0, G = 0;
    for (let H = Y - 1, N = X.length;++H < N; ) {
      let q = X[H];
      if (~(K = Z(q, J, W)))
        return G + K;
      W = 0, G += q.length;
    }
    return -1;
  }
  return function(X, Y) {
    J = X;
    let Q = this.data, W = typeof Y !== "number" ? $(Q, 0, 0) : Al(Q, this._offsets, Y, $);
    return J = void 0, W;
  };
}

// node_modules/apache-arrow/visitor/indexof.mjs
class WZ extends g6 {
}
function Go0(Z, J) {
  return J === null && Z.length > 0 ? 0 : -1;
}
function Ho0(Z, J) {
  let { nullBitmap: $ } = Z;
  if (!$ || Z.nullCount <= 0)
    return -1;
  let X = 0;
  for (let Y of new gD($, Z.offset + (J || 0), Z.length, $, Rv)) {
    if (!Y)
      return X;
    ++X;
  }
  return -1;
}
function mZ(Z, J, $) {
  if (J === void 0)
    return -1;
  if (J === null)
    return Ho0(Z, $);
  let X = n$.getVisitFn(Z), Y = ML(J);
  for (let Q = ($ || 0) - 1, W = Z.length;++Q < W; )
    if (Y(X(Z, Q)))
      return Q;
  return -1;
}
function PQ0(Z, J, $) {
  let X = n$.getVisitFn(Z), Y = ML(J);
  for (let Q = ($ || 0) - 1, W = Z.length;++Q < W; )
    if (Y(X(Z, Q)))
      return Q;
  return -1;
}
WZ.prototype.visitNull = Go0;
WZ.prototype.visitBool = mZ;
WZ.prototype.visitInt = mZ;
WZ.prototype.visitInt8 = mZ;
WZ.prototype.visitInt16 = mZ;
WZ.prototype.visitInt32 = mZ;
WZ.prototype.visitInt64 = mZ;
WZ.prototype.visitUint8 = mZ;
WZ.prototype.visitUint16 = mZ;
WZ.prototype.visitUint32 = mZ;
WZ.prototype.visitUint64 = mZ;
WZ.prototype.visitFloat = mZ;
WZ.prototype.visitFloat16 = mZ;
WZ.prototype.visitFloat32 = mZ;
WZ.prototype.visitFloat64 = mZ;
WZ.prototype.visitUtf8 = mZ;
WZ.prototype.visitBinary = mZ;
WZ.prototype.visitFixedSizeBinary = mZ;
WZ.prototype.visitDate = mZ;
WZ.prototype.visitDateDay = mZ;
WZ.prototype.visitDateMillisecond = mZ;
WZ.prototype.visitTimestamp = mZ;
WZ.prototype.visitTimestampSecond = mZ;
WZ.prototype.visitTimestampMillisecond = mZ;
WZ.prototype.visitTimestampMicrosecond = mZ;
WZ.prototype.visitTimestampNanosecond = mZ;
WZ.prototype.visitTime = mZ;
WZ.prototype.visitTimeSecond = mZ;
WZ.prototype.visitTimeMillisecond = mZ;
WZ.prototype.visitTimeMicrosecond = mZ;
WZ.prototype.visitTimeNanosecond = mZ;
WZ.prototype.visitDecimal = mZ;
WZ.prototype.visitList = mZ;
WZ.prototype.visitStruct = mZ;
WZ.prototype.visitUnion = mZ;
WZ.prototype.visitDenseUnion = PQ0;
WZ.prototype.visitSparseUnion = PQ0;
WZ.prototype.visitDictionary = mZ;
WZ.prototype.visitInterval = mZ;
WZ.prototype.visitIntervalDayTime = mZ;
WZ.prototype.visitIntervalYearMonth = mZ;
WZ.prototype.visitFixedSizeList = mZ;
WZ.prototype.visitMap = mZ;
var _O = new WZ;

// node_modules/apache-arrow/visitor/iterator.mjs
class KZ extends g6 {
}
function TZ(Z) {
  let { type: J } = Z;
  if (Z.nullCount === 0 && Z.stride === 1 && (J.typeId === j1.Timestamp || J instanceof l$ && J.bitWidth !== 64 || J instanceof GN && J.bitWidth !== 64 || J instanceof YK && J.precision !== NJ.HALF))
    return new Ev(Z.data.length, (X) => {
      let Y = Z.data[X];
      return Y.values.subarray(0, Y.length)[Symbol.iterator]();
    });
  let $ = 0;
  return new Ev(Z.data.length, (X) => {
    let Q = Z.data[X].length, W = Z.slice($, $ + Q);
    return $ += Q, new CQ0(W);
  });
}

class CQ0 {
  constructor(Z) {
    this.vector = Z, this.index = 0;
  }
  next() {
    if (this.index < this.vector.length)
      return {
        value: this.vector.get(this.index++)
      };
    return { done: !0, value: null };
  }
  [Symbol.iterator]() {
    return this;
  }
}
KZ.prototype.visitNull = TZ;
KZ.prototype.visitBool = TZ;
KZ.prototype.visitInt = TZ;
KZ.prototype.visitInt8 = TZ;
KZ.prototype.visitInt16 = TZ;
KZ.prototype.visitInt32 = TZ;
KZ.prototype.visitInt64 = TZ;
KZ.prototype.visitUint8 = TZ;
KZ.prototype.visitUint16 = TZ;
KZ.prototype.visitUint32 = TZ;
KZ.prototype.visitUint64 = TZ;
KZ.prototype.visitFloat = TZ;
KZ.prototype.visitFloat16 = TZ;
KZ.prototype.visitFloat32 = TZ;
KZ.prototype.visitFloat64 = TZ;
KZ.prototype.visitUtf8 = TZ;
KZ.prototype.visitBinary = TZ;
KZ.prototype.visitFixedSizeBinary = TZ;
KZ.prototype.visitDate = TZ;
KZ.prototype.visitDateDay = TZ;
KZ.prototype.visitDateMillisecond = TZ;
KZ.prototype.visitTimestamp = TZ;
KZ.prototype.visitTimestampSecond = TZ;
KZ.prototype.visitTimestampMillisecond = TZ;
KZ.prototype.visitTimestampMicrosecond = TZ;
KZ.prototype.visitTimestampNanosecond = TZ;
KZ.prototype.visitTime = TZ;
KZ.prototype.visitTimeSecond = TZ;
KZ.prototype.visitTimeMillisecond = TZ;
KZ.prototype.visitTimeMicrosecond = TZ;
KZ.prototype.visitTimeNanosecond = TZ;
KZ.prototype.visitDecimal = TZ;
KZ.prototype.visitList = TZ;
KZ.prototype.visitStruct = TZ;
KZ.prototype.visitUnion = TZ;
KZ.prototype.visitDenseUnion = TZ;
KZ.prototype.visitSparseUnion = TZ;
KZ.prototype.visitDictionary = TZ;
KZ.prototype.visitInterval = TZ;
KZ.prototype.visitIntervalDayTime = TZ;
KZ.prototype.visitIntervalYearMonth = TZ;
KZ.prototype.visitFixedSizeList = TZ;
KZ.prototype.visitMap = TZ;
var mD = new KZ;

// node_modules/apache-arrow/visitor/bytelength.mjs
var No0 = (Z, J) => Z + J;

class MF extends g6 {
  visitNull(Z, J) {
    return 0;
  }
  visitInt(Z, J) {
    return Z.type.bitWidth / 8;
  }
  visitFloat(Z, J) {
    return Z.type.ArrayType.BYTES_PER_ELEMENT;
  }
  visitBool(Z, J) {
    return 0.125;
  }
  visitDecimal(Z, J) {
    return Z.type.bitWidth / 8;
  }
  visitDate(Z, J) {
    return (Z.type.unit + 1) * 4;
  }
  visitTime(Z, J) {
    return Z.type.bitWidth / 8;
  }
  visitTimestamp(Z, J) {
    return Z.type.unit === aZ.SECOND ? 4 : 8;
  }
  visitInterval(Z, J) {
    return (Z.type.unit + 1) * 4;
  }
  visitStruct(Z, J) {
    return Z.children.reduce(($, X) => $ + WK.visit(X, J), 0);
  }
  visitFixedSizeBinary(Z, J) {
    return Z.type.byteWidth;
  }
  visitMap(Z, J) {
    return 8 + Z.children.reduce(($, X) => $ + WK.visit(X, J), 0);
  }
  visitDictionary(Z, J) {
    var $;
    return Z.type.indices.bitWidth / 8 + ((($ = Z.dictionary) === null || $ === void 0 ? void 0 : $.getByteLength(Z.values[J])) || 0);
  }
}
var qo0 = ({ valueOffsets: Z }, J) => {
  return 8 + (Z[J + 1] - Z[J]);
}, Fo0 = ({ valueOffsets: Z }, J) => {
  return 8 + (Z[J + 1] - Z[J]);
}, Uo0 = ({ valueOffsets: Z, stride: J, children: $ }, X) => {
  let Y = $[0], { [X * J]: Q } = Z, { [X * J + 1]: W } = Z, K = WK.getVisitFn(Y.type), G = Y.slice(Q, W - Q), H = 8;
  for (let N = -1, q = W - Q;++N < q; )
    H += K(G, N);
  return H;
}, Lo0 = ({ stride: Z, children: J }, $) => {
  let X = J[0], Y = X.slice($ * Z, Z), Q = WK.getVisitFn(X.type), W = 0;
  for (let K = -1, G = Y.length;++K < G; )
    W += Q(Y, K);
  return W;
}, Ro0 = (Z, J) => {
  return Z.type.mode === pJ.Dense ? kQ0(Z, J) : vQ0(Z, J);
}, kQ0 = ({ type: Z, children: J, typeIds: $, valueOffsets: X }, Y) => {
  let Q = Z.typeIdToChildIndex[$[Y]];
  return 8 + WK.visit(J[Q], X[Y]);
}, vQ0 = ({ children: Z }, J) => {
  return 4 + WK.visitMany(Z, Z.map(() => J)).reduce(No0, 0);
};
MF.prototype.visitUtf8 = qo0;
MF.prototype.visitBinary = Fo0;
MF.prototype.visitList = Uo0;
MF.prototype.visitFixedSizeList = Lo0;
MF.prototype.visitUnion = Ro0;
MF.prototype.visitDenseUnion = kQ0;
MF.prototype.visitSparseUnion = vQ0;
var WK = new MF;

// node_modules/apache-arrow/vector.mjs
var SQ0, fQ0 = {}, hQ0 = {};

class wZ {
  constructor(Z) {
    var J, $, X;
    let Y = Z[0] instanceof wZ ? Z.flatMap((W) => W.data) : Z;
    if (Y.length === 0 || Y.some((W) => !(W instanceof O7)))
      throw new TypeError("Vector constructor expects an Array of Data instances.");
    let Q = (J = Y[0]) === null || J === void 0 ? void 0 : J.type;
    switch (Y.length) {
      case 0:
        this._offsets = [0];
        break;
      case 1: {
        let { get: W, set: K, indexOf: G, byteLength: H } = fQ0[Q.typeId], N = Y[0];
        this.isValid = (q) => jT(N, q), this.get = (q) => W(N, q), this.set = (q, U) => K(N, q, U), this.indexOf = (q) => G(N, q), this.getByteLength = (q) => H(N, q), this._offsets = [0, N.length];
        break;
      }
      default:
        Object.setPrototypeOf(this, hQ0[Q.typeId]), this._offsets = zv(Y);
        break;
    }
    this.data = Y, this.type = Q, this.stride = QK(Q), this.numChildren = (X = ($ = Q.children) === null || $ === void 0 ? void 0 : $.length) !== null && X !== void 0 ? X : 0, this.length = this._offsets[this._offsets.length - 1];
  }
  get byteLength() {
    if (this._byteLength === -1)
      this._byteLength = this.data.reduce((Z, J) => Z + J.byteLength, 0);
    return this._byteLength;
  }
  get nullCount() {
    if (this._nullCount === -1)
      this._nullCount = Ov(this.data);
    return this._nullCount;
  }
  get ArrayType() {
    return this.type.ArrayType;
  }
  get [Symbol.toStringTag]() {
    return `${this.VectorName}<${this.type[Symbol.toStringTag]}>`;
  }
  get VectorName() {
    return `${j1[this.type.typeId]}Vector`;
  }
  isValid(Z) {
    return !1;
  }
  get(Z) {
    return null;
  }
  set(Z, J) {
    return;
  }
  indexOf(Z, J) {
    return -1;
  }
  includes(Z, J) {
    return this.indexOf(Z, J) > 0;
  }
  getByteLength(Z) {
    return 0;
  }
  [Symbol.iterator]() {
    return mD.visit(this);
  }
  concat(...Z) {
    return new wZ(this.data.concat(Z.flatMap((J) => J.data).flat(Number.POSITIVE_INFINITY)));
  }
  slice(Z, J) {
    return new wZ(AT(this, Z, J, ({ data: $, _offsets: X }, Y, Q) => Dv($, X, Y, Q)));
  }
  toJSON() {
    return [...this];
  }
  toArray() {
    let { type: Z, data: J, length: $, stride: X, ArrayType: Y } = this;
    switch (Z.typeId) {
      case j1.Int:
      case j1.Float:
      case j1.Decimal:
      case j1.Time:
      case j1.Timestamp:
        switch (J.length) {
          case 0:
            return new Y;
          case 1:
            return J[0].values.subarray(0, $ * X);
          default:
            return J.reduce((Q, { values: W, length: K }) => {
              return Q.array.set(W.subarray(0, K * X), Q.offset), Q.offset += K * X, Q;
            }, { array: new Y($ * X), offset: 0 }).array;
        }
    }
    return [...this];
  }
  toString() {
    return `[${[...this].join(",")}]`;
  }
  getChild(Z) {
    var J;
    return this.getChildAt((J = this.type.children) === null || J === void 0 ? void 0 : J.findIndex(($) => $.name === Z));
  }
  getChildAt(Z) {
    if (Z > -1 && Z < this.numChildren)
      return new wZ(this.data.map(({ children: J }) => J[Z]));
    return null;
  }
  get isMemoized() {
    if (L6.isDictionary(this.type))
      return this.data[0].dictionary.isMemoized;
    return !1;
  }
  memoize() {
    if (L6.isDictionary(this.type)) {
      let Z = new Bv(this.data[0].dictionary), J = this.data.map(($) => {
        let X = $.clone();
        return X.dictionary = Z, X;
      });
      return new wZ(J);
    }
    return new Bv(this);
  }
  unmemoize() {
    if (L6.isDictionary(this.type) && this.isMemoized) {
      let Z = this.data[0].dictionary.unmemoize(), J = this.data.map(($) => {
        let X = $.clone();
        return X.dictionary = Z, X;
      });
      return new wZ(J);
    }
    return this;
  }
}
SQ0 = Symbol.toStringTag;
wZ[SQ0] = ((Z) => {
  Z.type = L6.prototype, Z.data = [], Z.length = 0, Z.stride = 1, Z.numChildren = 0, Z._nullCount = -1, Z._byteLength = -1, Z._offsets = new Uint32Array([0]), Z[Symbol.isConcatSpreadable] = !0;
  let J = Object.keys(j1).map(($) => j1[$]).filter(($) => typeof $ === "number" && $ !== j1.NONE);
  for (let $ of J) {
    let X = n$.getVisitFnByTypeId($), Y = $Q.getVisitFnByTypeId($), Q = _O.getVisitFnByTypeId($), W = WK.getVisitFnByTypeId($);
    fQ0[$] = { get: X, set: Y, indexOf: Q, byteLength: W }, hQ0[$] = Object.create(Z, {
      ["isValid"]: { value: AL(jT) },
      ["get"]: { value: AL(n$.getVisitFnByTypeId($)) },
      ["set"]: { value: Mv($Q.getVisitFnByTypeId($)) },
      ["indexOf"]: { value: Av(_O.getVisitFnByTypeId($)) },
      ["getByteLength"]: { value: AL(WK.getVisitFnByTypeId($)) }
    });
  }
  return "Vector";
})(wZ.prototype);

class Bv extends wZ {
  constructor(Z) {
    super(Z.data);
    let J = this.get, $ = this.set, X = this.slice, Y = new Array(this.length);
    Object.defineProperty(this, "get", {
      value(Q) {
        let W = Y[Q];
        if (W !== void 0)
          return W;
        let K = J.call(this, Q);
        return Y[Q] = K, K;
      }
    }), Object.defineProperty(this, "set", {
      value(Q, W) {
        $.call(this, Q, W), Y[Q] = W;
      }
    }), Object.defineProperty(this, "slice", {
      value: (Q, W) => new Bv(X.call(this, Q, W))
    }), Object.defineProperty(this, "isMemoized", { value: !0 }), Object.defineProperty(this, "unmemoize", {
      value: () => new wZ(this.data)
    }), Object.defineProperty(this, "memoize", {
      value: () => this
    });
  }
}

// node_modules/apache-arrow/builder/valid.mjs
function bQ0(Z) {
  if (!Z || Z.length <= 0)
    return function X(Y) {
      return !0;
    };
  let J = "", $ = Z.filter((X) => X === X);
  if ($.length > 0)
    J = `
    switch (x) {${$.map((X) => `
        case ${Eo0(X)}:`).join("")}
            return false;
    }`;
  if (Z.length !== $.length)
    J = `if (x !== x) return false;
${J}`;
  return new Function("x", `${J}
return true;`);
}
function Eo0(Z) {
  if (typeof Z !== "bigint")
    return uG(Z);
  else if (lk)
    return `${uG(Z)}n`;
  return `"${uG(Z)}"`;
}

// node_modules/apache-arrow/builder/buffer.mjs
var Bl = (Z, J) => (Math.ceil(Z) * J + 63 & -64 || 64) / J, Oo0 = (Z, J = 0) => Z.length >= J ? Z.subarray(0, J) : kD(new Z.constructor(J), Z, 0);

class VO {
  constructor(Z, J = 1) {
    this.buffer = Z, this.stride = J, this.BYTES_PER_ELEMENT = Z.BYTES_PER_ELEMENT, this.ArrayType = Z.constructor, this._resize(this.length = Math.ceil(Z.length / J));
  }
  get byteLength() {
    return Math.ceil(this.length * this.stride) * this.BYTES_PER_ELEMENT;
  }
  get reservedLength() {
    return this.buffer.length / this.stride;
  }
  get reservedByteLength() {
    return this.buffer.byteLength;
  }
  set(Z, J) {
    return this;
  }
  append(Z) {
    return this.set(this.length, Z);
  }
  reserve(Z) {
    if (Z > 0) {
      this.length += Z;
      let J = this.stride, $ = this.length * J, X = this.buffer.length;
      if ($ >= X)
        this._resize(X === 0 ? Bl($ * 1, this.BYTES_PER_ELEMENT) : Bl($ * 2, this.BYTES_PER_ELEMENT));
    }
    return this;
  }
  flush(Z = this.length) {
    Z = Bl(Z * this.stride, this.BYTES_PER_ELEMENT);
    let J = Oo0(this.buffer, Z);
    return this.clear(), J;
  }
  clear() {
    return this.length = 0, this._resize(0), this;
  }
  _resize(Z) {
    return this.buffer = kD(new this.ArrayType(Z), this.buffer);
  }
}
VO.prototype.offset = 0;

class BL extends VO {
  last() {
    return this.get(this.length - 1);
  }
  get(Z) {
    return this.buffer[Z];
  }
  set(Z, J) {
    return this.reserve(Z - this.length + 1), this.buffer[Z * this.stride] = J, this;
  }
}

class TT extends BL {
  constructor(Z = new Uint8Array(0)) {
    super(Z, 0.125);
    this.numValid = 0;
  }
  get numInvalid() {
    return this.length - this.numValid;
  }
  get(Z) {
    return this.buffer[Z >> 3] >> Z % 8 & 1;
  }
  set(Z, J) {
    let { buffer: $ } = this.reserve(Z - this.length + 1), X = Z >> 3, Y = Z % 8, Q = $[X] >> Y & 1;
    return J ? Q === 0 && ($[X] |= 1 << Y, ++this.numValid) : Q === 1 && ($[X] &= ~(1 << Y), --this.numValid), this;
  }
  clear() {
    return this.numValid = 0, super.clear();
  }
}

class _T extends BL {
  constructor(Z = new Int32Array(1)) {
    super(Z, 1);
  }
  append(Z) {
    return this.set(this.length - 1, Z);
  }
  set(Z, J) {
    let $ = this.length - 1, X = this.reserve(Z - $ + 1).buffer;
    if ($ < Z++)
      X.fill(X[$], $, Z);
    return X[Z] = X[Z - 1] + J, this;
  }
  flush(Z = this.length - 1) {
    if (Z > this.length)
      this.set(Z - 1, 0);
    return super.flush(Z + 1);
  }
}

// node_modules/apache-arrow/builder.mjs
class AJ {
  constructor({ type: Z, nullValues: J }) {
    if (this.length = 0, this.finished = !1, this.type = Z, this.children = [], this.nullValues = J, this.stride = QK(Z), this._nulls = new TT, J && J.length > 0)
      this._isValid = bQ0(J);
  }
  static throughNode(Z) {
    throw new Error('"throughNode" not available in this environment');
  }
  static throughDOM(Z) {
    throw new Error('"throughDOM" not available in this environment');
  }
  toVector() {
    return new wZ([this.flush()]);
  }
  get ArrayType() {
    return this.type.ArrayType;
  }
  get nullCount() {
    return this._nulls.numInvalid;
  }
  get numChildren() {
    return this.children.length;
  }
  get byteLength() {
    let Z = 0, { _offsets: J, _values: $, _nulls: X, _typeIds: Y, children: Q } = this;
    return J && (Z += J.byteLength), $ && (Z += $.byteLength), X && (Z += X.byteLength), Y && (Z += Y.byteLength), Q.reduce((W, K) => W + K.byteLength, Z);
  }
  get reservedLength() {
    return this._nulls.reservedLength;
  }
  get reservedByteLength() {
    let Z = 0;
    return this._offsets && (Z += this._offsets.reservedByteLength), this._values && (Z += this._values.reservedByteLength), this._nulls && (Z += this._nulls.reservedByteLength), this._typeIds && (Z += this._typeIds.reservedByteLength), this.children.reduce((J, $) => J + $.reservedByteLength, Z);
  }
  get valueOffsets() {
    return this._offsets ? this._offsets.buffer : null;
  }
  get values() {
    return this._values ? this._values.buffer : null;
  }
  get nullBitmap() {
    return this._nulls ? this._nulls.buffer : null;
  }
  get typeIds() {
    return this._typeIds ? this._typeIds.buffer : null;
  }
  append(Z) {
    return this.set(this.length, Z);
  }
  isValid(Z) {
    return this._isValid(Z);
  }
  set(Z, J) {
    if (this.setValid(Z, this.isValid(J)))
      this.setValue(Z, J);
    return this;
  }
  setValue(Z, J) {
    this._setValue(this, Z, J);
  }
  setValid(Z, J) {
    return this.length = this._nulls.set(Z, +J).length, J;
  }
  addChild(Z, J = `${this.numChildren}`) {
    throw new Error(`Cannot append children to non-nested type "${this.type}"`);
  }
  getChildAt(Z) {
    return this.children[Z] || null;
  }
  flush() {
    let Z, J, $, X, { type: Y, length: Q, nullCount: W, _typeIds: K, _offsets: G, _values: H, _nulls: N } = this;
    if (J = K === null || K === void 0 ? void 0 : K.flush(Q))
      X = G === null || G === void 0 ? void 0 : G.flush(Q);
    else if (X = G === null || G === void 0 ? void 0 : G.flush(Q))
      Z = H === null || H === void 0 ? void 0 : H.flush(G.last());
    else
      Z = H === null || H === void 0 ? void 0 : H.flush(Q);
    if (W > 0)
      $ = N === null || N === void 0 ? void 0 : N.flush(Q);
    let q = this.children.map((U) => U.flush());
    return this.clear(), FZ({
      type: Y,
      length: Q,
      nullCount: W,
      children: q,
      child: q[0],
      data: Z,
      typeIds: J,
      nullBitmap: $,
      valueOffsets: X
    });
  }
  finish() {
    this.finished = !0;
    for (let Z of this.children)
      Z.finish();
    return this;
  }
  clear() {
    var Z, J, $, X;
    this.length = 0, (Z = this._nulls) === null || Z === void 0 || Z.clear(), (J = this._values) === null || J === void 0 || J.clear(), ($ = this._offsets) === null || $ === void 0 || $.clear(), (X = this._typeIds) === null || X === void 0 || X.clear();
    for (let Y of this.children)
      Y.clear();
    return this;
  }
}
AJ.prototype.length = 1;
AJ.prototype.stride = 1;
AJ.prototype.children = null;
AJ.prototype.finished = !1;
AJ.prototype.nullValues = null;
AJ.prototype._isValid = () => !0;

class XQ extends AJ {
  constructor(Z) {
    super(Z);
    this._values = new BL(new this.ArrayType(0), this.stride);
  }
  setValue(Z, J) {
    let $ = this._values;
    return $.reserve(Z - $.length + 1), super.setValue(Z, J);
  }
}

class AF extends AJ {
  constructor(Z) {
    super(Z);
    this._pendingLength = 0, this._offsets = new _T;
  }
  setValue(Z, J) {
    let $ = this._pending || (this._pending = /* @__PURE__ */ new Map), X = $.get(Z);
    X && (this._pendingLength -= X.length), this._pendingLength += J instanceof DF ? J[J3].length : J.length, $.set(Z, J);
  }
  setValid(Z, J) {
    if (!super.setValid(Z, J))
      return (this._pending || (this._pending = /* @__PURE__ */ new Map)).set(Z, void 0), !1;
    return !0;
  }
  clear() {
    return this._pendingLength = 0, this._pending = void 0, super.clear();
  }
  flush() {
    return this._flush(), super.flush();
  }
  finish() {
    return this._flush(), super.finish();
  }
  _flush() {
    let Z = this._pending, J = this._pendingLength;
    if (this._pendingLength = 0, this._pending = void 0, Z && Z.size > 0)
      this._flushPending(Z, J);
    return this;
  }
}

// node_modules/apache-arrow/fb/block.mjs
class dD {
  constructor() {
    this.bb = null, this.bb_pos = 0;
  }
  __init(Z, J) {
    return this.bb_pos = Z, this.bb = J, this;
  }
  offset() {
    return this.bb.readInt64(this.bb_pos);
  }
  metaDataLength() {
    return this.bb.readInt32(this.bb_pos + 8);
  }
  bodyLength() {
    return this.bb.readInt64(this.bb_pos + 16);
  }
  static sizeOf() {
    return 24;
  }
  static createBlock(Z, J, $, X) {
    return Z.prep(8, 24), Z.writeInt64(X), Z.pad(4), Z.writeInt32($), Z.writeInt64(J), Z.offset();
  }
}

// node_modules/flatbuffers/mjs/constants.js
var VT = 2, KK = 4, $3 = 4, K6 = 4;
// node_modules/flatbuffers/mjs/utils.js
var UN = new Int32Array(2), wv = new Float32Array(UN.buffer), jv = new Float64Array(UN.buffer), pD = new Uint16Array(new Uint8Array([1, 0]).buffer)[0] === 1;
// node_modules/flatbuffers/mjs/long.js
class $Y {
  constructor(Z, J) {
    this.low = Z | 0, this.high = J | 0;
  }
  static create(Z, J) {
    return Z == 0 && J == 0 ? $Y.ZERO : new $Y(Z, J);
  }
  toFloat64() {
    return (this.low >>> 0) + this.high * 4294967296;
  }
  equals(Z) {
    return this.low == Z.low && this.high == Z.high;
  }
}
$Y.ZERO = new $Y(0, 0);
// node_modules/flatbuffers/mjs/encoding.js
var IT;
(function(Z) {
  Z[Z.UTF8_BYTES = 1] = "UTF8_BYTES", Z[Z.UTF16_STRING = 2] = "UTF16_STRING";
})(IT || (IT = {}));
// node_modules/flatbuffers/mjs/byte-buffer.js
class GK {
  constructor(Z) {
    this.bytes_ = Z, this.position_ = 0;
  }
  static allocate(Z) {
    return new GK(new Uint8Array(Z));
  }
  clear() {
    this.position_ = 0;
  }
  bytes() {
    return this.bytes_;
  }
  position() {
    return this.position_;
  }
  setPosition(Z) {
    this.position_ = Z;
  }
  capacity() {
    return this.bytes_.length;
  }
  readInt8(Z) {
    return this.readUint8(Z) << 24 >> 24;
  }
  readUint8(Z) {
    return this.bytes_[Z];
  }
  readInt16(Z) {
    return this.readUint16(Z) << 16 >> 16;
  }
  readUint16(Z) {
    return this.bytes_[Z] | this.bytes_[Z + 1] << 8;
  }
  readInt32(Z) {
    return this.bytes_[Z] | this.bytes_[Z + 1] << 8 | this.bytes_[Z + 2] << 16 | this.bytes_[Z + 3] << 24;
  }
  readUint32(Z) {
    return this.readInt32(Z) >>> 0;
  }
  readInt64(Z) {
    return new $Y(this.readInt32(Z), this.readInt32(Z + 4));
  }
  readUint64(Z) {
    return new $Y(this.readUint32(Z), this.readUint32(Z + 4));
  }
  readFloat32(Z) {
    return UN[0] = this.readInt32(Z), wv[0];
  }
  readFloat64(Z) {
    return UN[pD ? 0 : 1] = this.readInt32(Z), UN[pD ? 1 : 0] = this.readInt32(Z + 4), jv[0];
  }
  writeInt8(Z, J) {
    this.bytes_[Z] = J;
  }
  writeUint8(Z, J) {
    this.bytes_[Z] = J;
  }
  writeInt16(Z, J) {
    this.bytes_[Z] = J, this.bytes_[Z + 1] = J >> 8;
  }
  writeUint16(Z, J) {
    this.bytes_[Z] = J, this.bytes_[Z + 1] = J >> 8;
  }
  writeInt32(Z, J) {
    this.bytes_[Z] = J, this.bytes_[Z + 1] = J >> 8, this.bytes_[Z + 2] = J >> 16, this.bytes_[Z + 3] = J >> 24;
  }
  writeUint32(Z, J) {
    this.bytes_[Z] = J, this.bytes_[Z + 1] = J >> 8, this.bytes_[Z + 2] = J >> 16, this.bytes_[Z + 3] = J >> 24;
  }
  writeInt64(Z, J) {
    this.writeInt32(Z, J.low), this.writeInt32(Z + 4, J.high);
  }
  writeUint64(Z, J) {
    this.writeUint32(Z, J.low), this.writeUint32(Z + 4, J.high);
  }
  writeFloat32(Z, J) {
    wv[0] = J, this.writeInt32(Z, UN[0]);
  }
  writeFloat64(Z, J) {
    jv[0] = J, this.writeInt32(Z, UN[pD ? 0 : 1]), this.writeInt32(Z + 4, UN[pD ? 1 : 0]);
  }
  getBufferIdentifier() {
    if (this.bytes_.length < this.position_ + KK + $3)
      throw new Error("FlatBuffers: ByteBuffer is too short to contain an identifier.");
    let Z = "";
    for (let J = 0;J < $3; J++)
      Z += String.fromCharCode(this.readInt8(this.position_ + KK + J));
    return Z;
  }
  __offset(Z, J) {
    let $ = Z - this.readInt32(Z);
    return J < this.readInt16($) ? this.readInt16($ + J) : 0;
  }
  __union(Z, J) {
    return Z.bb_pos = J + this.readInt32(J), Z.bb = this, Z;
  }
  __string(Z, J) {
    Z += this.readInt32(Z);
    let $ = this.readInt32(Z), X = "", Y = 0;
    if (Z += KK, J === IT.UTF8_BYTES)
      return this.bytes_.subarray(Z, Z + $);
    while (Y < $) {
      let Q, W = this.readUint8(Z + Y++);
      if (W < 192)
        Q = W;
      else {
        let K = this.readUint8(Z + Y++);
        if (W < 224)
          Q = (W & 31) << 6 | K & 63;
        else {
          let G = this.readUint8(Z + Y++);
          if (W < 240)
            Q = (W & 15) << 12 | (K & 63) << 6 | G & 63;
          else {
            let H = this.readUint8(Z + Y++);
            Q = (W & 7) << 18 | (K & 63) << 12 | (G & 63) << 6 | H & 63;
          }
        }
      }
      if (Q < 65536)
        X += String.fromCharCode(Q);
      else
        Q -= 65536, X += String.fromCharCode((Q >> 10) + 55296, (Q & 1023) + 56320);
    }
    return X;
  }
  __union_with_string(Z, J) {
    if (typeof Z === "string")
      return this.__string(J);
    return this.__union(Z, J);
  }
  __indirect(Z) {
    return Z + this.readInt32(Z);
  }
  __vector(Z) {
    return Z + this.readInt32(Z) + KK;
  }
  __vector_len(Z) {
    return this.readInt32(Z + this.readInt32(Z));
  }
  __has_identifier(Z) {
    if (Z.length != $3)
      throw new Error("FlatBuffers: file identifier must be length " + $3);
    for (let J = 0;J < $3; J++)
      if (Z.charCodeAt(J) != this.readInt8(this.position() + KK + J))
        return !1;
    return !0;
  }
  createLong(Z, J) {
    return $Y.create(Z, J);
  }
  createScalarList(Z, J) {
    let $ = [];
    for (let X = 0;X < J; ++X)
      if (Z(X) !== null)
        $.push(Z(X));
    return $;
  }
  createObjList(Z, J) {
    let $ = [];
    for (let X = 0;X < J; ++X) {
      let Y = Z(X);
      if (Y !== null)
        $.push(Y.unpack());
    }
    return $;
  }
}

// node_modules/flatbuffers/mjs/builder.js
class IO {
  constructor(Z) {
    this.minalign = 1, this.vtable = null, this.vtable_in_use = 0, this.isNested = !1, this.object_start = 0, this.vtables = [], this.vector_num_elems = 0, this.force_defaults = !1, this.string_maps = null;
    let J;
    if (!Z)
      J = 1024;
    else
      J = Z;
    this.bb = GK.allocate(J), this.space = J;
  }
  clear() {
    this.bb.clear(), this.space = this.bb.capacity(), this.minalign = 1, this.vtable = null, this.vtable_in_use = 0, this.isNested = !1, this.object_start = 0, this.vtables = [], this.vector_num_elems = 0, this.force_defaults = !1, this.string_maps = null;
  }
  forceDefaults(Z) {
    this.force_defaults = Z;
  }
  dataBuffer() {
    return this.bb;
  }
  asUint8Array() {
    return this.bb.bytes().subarray(this.bb.position(), this.bb.position() + this.offset());
  }
  prep(Z, J) {
    if (Z > this.minalign)
      this.minalign = Z;
    let $ = ~(this.bb.capacity() - this.space + J) + 1 & Z - 1;
    while (this.space < $ + Z + J) {
      let X = this.bb.capacity();
      this.bb = IO.growByteBuffer(this.bb), this.space += this.bb.capacity() - X;
    }
    this.pad($);
  }
  pad(Z) {
    for (let J = 0;J < Z; J++)
      this.bb.writeInt8(--this.space, 0);
  }
  writeInt8(Z) {
    this.bb.writeInt8(this.space -= 1, Z);
  }
  writeInt16(Z) {
    this.bb.writeInt16(this.space -= 2, Z);
  }
  writeInt32(Z) {
    this.bb.writeInt32(this.space -= 4, Z);
  }
  writeInt64(Z) {
    this.bb.writeInt64(this.space -= 8, Z);
  }
  writeFloat32(Z) {
    this.bb.writeFloat32(this.space -= 4, Z);
  }
  writeFloat64(Z) {
    this.bb.writeFloat64(this.space -= 8, Z);
  }
  addInt8(Z) {
    this.prep(1, 0), this.writeInt8(Z);
  }
  addInt16(Z) {
    this.prep(2, 0), this.writeInt16(Z);
  }
  addInt32(Z) {
    this.prep(4, 0), this.writeInt32(Z);
  }
  addInt64(Z) {
    this.prep(8, 0), this.writeInt64(Z);
  }
  addFloat32(Z) {
    this.prep(4, 0), this.writeFloat32(Z);
  }
  addFloat64(Z) {
    this.prep(8, 0), this.writeFloat64(Z);
  }
  addFieldInt8(Z, J, $) {
    if (this.force_defaults || J != $)
      this.addInt8(J), this.slot(Z);
  }
  addFieldInt16(Z, J, $) {
    if (this.force_defaults || J != $)
      this.addInt16(J), this.slot(Z);
  }
  addFieldInt32(Z, J, $) {
    if (this.force_defaults || J != $)
      this.addInt32(J), this.slot(Z);
  }
  addFieldInt64(Z, J, $) {
    if (this.force_defaults || !J.equals($))
      this.addInt64(J), this.slot(Z);
  }
  addFieldFloat32(Z, J, $) {
    if (this.force_defaults || J != $)
      this.addFloat32(J), this.slot(Z);
  }
  addFieldFloat64(Z, J, $) {
    if (this.force_defaults || J != $)
      this.addFloat64(J), this.slot(Z);
  }
  addFieldOffset(Z, J, $) {
    if (this.force_defaults || J != $)
      this.addOffset(J), this.slot(Z);
  }
  addFieldStruct(Z, J, $) {
    if (J != $)
      this.nested(J), this.slot(Z);
  }
  nested(Z) {
    if (Z != this.offset())
      throw new Error("FlatBuffers: struct must be serialized inline.");
  }
  notNested() {
    if (this.isNested)
      throw new Error("FlatBuffers: object serialization must not be nested.");
  }
  slot(Z) {
    if (this.vtable !== null)
      this.vtable[Z] = this.offset();
  }
  offset() {
    return this.bb.capacity() - this.space;
  }
  static growByteBuffer(Z) {
    let J = Z.capacity();
    if (J & 3221225472)
      throw new Error("FlatBuffers: cannot grow buffer beyond 2 gigabytes.");
    let $ = J << 1, X = GK.allocate($);
    return X.setPosition($ - J), X.bytes().set(Z.bytes(), $ - J), X;
  }
  addOffset(Z) {
    this.prep(KK, 0), this.writeInt32(this.offset() - Z + KK);
  }
  startObject(Z) {
    if (this.notNested(), this.vtable == null)
      this.vtable = [];
    this.vtable_in_use = Z;
    for (let J = 0;J < Z; J++)
      this.vtable[J] = 0;
    this.isNested = !0, this.object_start = this.offset();
  }
  endObject() {
    if (this.vtable == null || !this.isNested)
      throw new Error("FlatBuffers: endObject called without startObject");
    this.addInt32(0);
    let Z = this.offset(), J = this.vtable_in_use - 1;
    for (;J >= 0 && this.vtable[J] == 0; J--)
      ;
    let $ = J + 1;
    for (;J >= 0; J--)
      this.addInt16(this.vtable[J] != 0 ? Z - this.vtable[J] : 0);
    let X = 2;
    this.addInt16(Z - this.object_start);
    let Y = ($ + X) * VT;
    this.addInt16(Y);
    let Q = 0, W = this.space;
    Z:
      for (J = 0;J < this.vtables.length; J++) {
        let K = this.bb.capacity() - this.vtables[J];
        if (Y == this.bb.readInt16(K)) {
          for (let G = VT;G < Y; G += VT)
            if (this.bb.readInt16(W + G) != this.bb.readInt16(K + G))
              continue Z;
          Q = this.vtables[J];
          break;
        }
      }
    if (Q)
      this.space = this.bb.capacity() - Z, this.bb.writeInt32(this.space, Q - Z);
    else
      this.vtables.push(this.offset()), this.bb.writeInt32(this.bb.capacity() - Z, this.offset() - Z);
    return this.isNested = !1, Z;
  }
  finish(Z, J, $) {
    let X = $ ? K6 : 0;
    if (J) {
      let Y = J;
      if (this.prep(this.minalign, KK + $3 + X), Y.length != $3)
        throw new Error("FlatBuffers: file identifier must be length " + $3);
      for (let Q = $3 - 1;Q >= 0; Q--)
        this.writeInt8(Y.charCodeAt(Q));
    }
    if (this.prep(this.minalign, KK + X), this.addOffset(Z), X)
      this.addInt32(this.bb.capacity() - this.space);
    this.bb.setPosition(this.space);
  }
  finishSizePrefixed(Z, J) {
    this.finish(Z, J, !0);
  }
  requiredField(Z, J) {
    let $ = this.bb.capacity() - Z, X = $ - this.bb.readInt32($);
    if (this.bb.readInt16(X + J) == 0)
      throw new Error("FlatBuffers: field " + J + " must be set");
  }
  startVector(Z, J, $) {
    this.notNested(), this.vector_num_elems = J, this.prep(KK, Z * J), this.prep($, Z * J);
  }
  endVector() {
    return this.writeInt32(this.vector_num_elems), this.offset();
  }
  createSharedString(Z) {
    if (!Z)
      return 0;
    if (!this.string_maps)
      this.string_maps = /* @__PURE__ */ new Map;
    if (this.string_maps.has(Z))
      return this.string_maps.get(Z);
    let J = this.createString(Z);
    return this.string_maps.set(Z, J), J;
  }
  createString(Z) {
    if (!Z)
      return 0;
    let J;
    if (Z instanceof Uint8Array)
      J = Z;
    else {
      J = [];
      let $ = 0;
      while ($ < Z.length) {
        let X, Y = Z.charCodeAt($++);
        if (Y < 55296 || Y >= 56320)
          X = Y;
        else {
          let Q = Z.charCodeAt($++);
          X = (Y << 10) + Q + -56613888;
        }
        if (X < 128)
          J.push(X);
        else {
          if (X < 2048)
            J.push(X >> 6 & 31 | 192);
          else {
            if (X < 65536)
              J.push(X >> 12 & 15 | 224);
            else
              J.push(X >> 18 & 7 | 240, X >> 12 & 63 | 128);
            J.push(X >> 6 & 63 | 128);
          }
          J.push(X & 63 | 128);
        }
      }
    }
    this.addInt8(0), this.startVector(1, J.length, 1), this.bb.setPosition(this.space -= J.length);
    for (let $ = 0, X = this.space, Y = this.bb.bytes();$ < J.length; $++)
      Y[X++] = J[$];
    return this.endVector();
  }
  createLong(Z, J) {
    return $Y.create(Z, J);
  }
  createObjectOffset(Z) {
    if (Z === null)
      return 0;
    if (typeof Z === "string")
      return this.createString(Z);
    else
      return Z.pack(this);
  }
  createObjectOffsetList(Z) {
    let J = [];
    for (let $ = 0;$ < Z.length; ++$) {
      let X = Z[$];
      if (X !== null)
        J.push(this.createObjectOffset(X));
      else
        throw new Error("FlatBuffers: Argument for createObjectOffsetList cannot contain null.");
    }
    return J;
  }
  createStructOffsetList(Z, J) {
    return J(this, Z.length), this.createObjectOffsetList(Z), this.endVector();
  }
}
// node_modules/apache-arrow/fb/key-value.mjs
class BJ {
  constructor() {
    this.bb = null, this.bb_pos = 0;
  }
  __init(Z, J) {
    return this.bb_pos = Z, this.bb = J, this;
  }
  static getRootAsKeyValue(Z, J) {
    return (J || new BJ).__init(Z.readInt32(Z.position()) + Z.position(), Z);
  }
  static getSizePrefixedRootAsKeyValue(Z, J) {
    return Z.setPosition(Z.position() + K6), (J || new BJ).__init(Z.readInt32(Z.position()) + Z.position(), Z);
  }
  key(Z) {
    let J = this.bb.__offset(this.bb_pos, 4);
    return J ? this.bb.__string(this.bb_pos + J, Z) : null;
  }
  value(Z) {
    let J = this.bb.__offset(this.bb_pos, 6);
    return J ? this.bb.__string(this.bb_pos + J, Z) : null;
  }
  static startKeyValue(Z) {
    Z.startObject(2);
  }
  static addKey(Z, J) {
    Z.addFieldOffset(0, J, 0);
  }
  static addValue(Z, J) {
    Z.addFieldOffset(1, J, 0);
  }
  static endKeyValue(Z) {
    return Z.endObject();
  }
  static createKeyValue(Z, J, $) {
    return BJ.startKeyValue(Z), BJ.addKey(Z, J), BJ.addValue(Z, $), BJ.endKeyValue(Z);
  }
}

// node_modules/apache-arrow/fb/metadata-version.mjs
var wL;
(function(Z) {
  Z[Z.V1 = 0] = "V1", Z[Z.V2 = 1] = "V2", Z[Z.V3 = 2] = "V3", Z[Z.V4 = 3] = "V4", Z[Z.V5 = 4] = "V5";
})(wL || (wL = {}));

// node_modules/apache-arrow/fb/endianness.mjs
var jL;
(function(Z) {
  Z[Z.Little = 0] = "Little", Z[Z.Big = 1] = "Big";
})(jL || (jL = {}));

// node_modules/apache-arrow/fb/dictionary-kind.mjs
var PT;
(function(Z) {
  Z[Z.DenseArray = 0] = "DenseArray";
})(PT || (PT = {}));

// node_modules/apache-arrow/fb/int.mjs
class _Q {
  constructor() {
    this.bb = null, this.bb_pos = 0;
  }
  __init(Z, J) {
    return this.bb_pos = Z, this.bb = J, this;
  }
  static getRootAsInt(Z, J) {
    return (J || new _Q).__init(Z.readInt32(Z.position()) + Z.position(), Z);
  }
  static getSizePrefixedRootAsInt(Z, J) {
    return Z.setPosition(Z.position() + K6), (J || new _Q).__init(Z.readInt32(Z.position()) + Z.position(), Z);
  }
  bitWidth() {
    let Z = this.bb.__offset(this.bb_pos, 4);
    return Z ? this.bb.readInt32(this.bb_pos + Z) : 0;
  }
  isSigned() {
    let Z = this.bb.__offset(this.bb_pos, 6);
    return Z ? !!this.bb.readInt8(this.bb_pos + Z) : !1;
  }
  static startInt(Z) {
    Z.startObject(2);
  }
  static addBitWidth(Z, J) {
    Z.addFieldInt32(0, J, 0);
  }
  static addIsSigned(Z, J) {
    Z.addFieldInt8(1, +J, 0);
  }
  static endInt(Z) {
    return Z.endObject();
  }
  static createInt(Z, J, $) {
    return _Q.startInt(Z), _Q.addBitWidth(Z, J), _Q.addIsSigned(Z, $), _Q.endInt(Z);
  }
}

// node_modules/apache-arrow/fb/dictionary-encoding.mjs
class nG {
  constructor() {
    this.bb = null, this.bb_pos = 0;
  }
  __init(Z, J) {
    return this.bb_pos = Z, this.bb = J, this;
  }
  static getRootAsDictionaryEncoding(Z, J) {
    return (J || new nG).__init(Z.readInt32(Z.position()) + Z.position(), Z);
  }
  static getSizePrefixedRootAsDictionaryEncoding(Z, J) {
    return Z.setPosition(Z.position() + K6), (J || new nG).__init(Z.readInt32(Z.position()) + Z.position(), Z);
  }
  id() {
    let Z = this.bb.__offset(this.bb_pos, 4);
    return Z ? this.bb.readInt64(this.bb_pos + Z) : this.bb.createLong(0, 0);
  }
  indexType(Z) {
    let J = this.bb.__offset(this.bb_pos, 6);
    return J ? (Z || new _Q).__init(this.bb.__indirect(this.bb_pos + J), this.bb) : null;
  }
  isOrdered() {
    let Z = this.bb.__offset(this.bb_pos, 8);
    return Z ? !!this.bb.readInt8(this.bb_pos + Z) : !1;
  }
  dictionaryKind() {
    let Z = this.bb.__offset(this.bb_pos, 10);
    return Z ? this.bb.readInt16(this.bb_pos + Z) : PT.DenseArray;
  }
  static startDictionaryEncoding(Z) {
    Z.startObject(4);
  }
  static addId(Z, J) {
    Z.addFieldInt64(0, J, Z.createLong(0, 0));
  }
  static addIndexType(Z, J) {
    Z.addFieldOffset(1, J, 0);
  }
  static addIsOrdered(Z, J) {
    Z.addFieldInt8(2, +J, 0);
  }
  static addDictionaryKind(Z, J) {
    Z.addFieldInt16(3, J, PT.DenseArray);
  }
  static endDictionaryEncoding(Z) {
    return Z.endObject();
  }
}

// node_modules/apache-arrow/fb/binary.mjs
class TL {
  constructor() {
    this.bb = null, this.bb_pos = 0;
  }
  __init(Z, J) {
    return this.bb_pos = Z, this.bb = J, this;
  }
  static getRootAsBinary(Z, J) {
    return (J || new TL).__init(Z.readInt32(Z.position()) + Z.position(), Z);
  }
  static getSizePrefixedRootAsBinary(Z, J) {
    return Z.setPosition(Z.position() + K6), (J || new TL).__init(Z.readInt32(Z.position()) + Z.position(), Z);
  }
  static startBinary(Z) {
    Z.startObject(0);
  }
  static endBinary(Z) {
    return Z.endObject();
  }
  static createBinary(Z) {
    return TL.startBinary(Z), TL.endBinary(Z);
  }
}

// node_modules/apache-arrow/fb/bool.mjs
class _L {
  constructor() {
    this.bb = null, this.bb_pos = 0;
  }
  __init(Z, J) {
    return this.bb_pos = Z, this.bb = J, this;
  }
  static getRootAsBool(Z, J) {
    return (J || new _L).__init(Z.readInt32(Z.position()) + Z.position(), Z);
  }
  static getSizePrefixedRootAsBool(Z, J) {
    return Z.setPosition(Z.position() + K6), (J || new _L).__init(Z.readInt32(Z.position()) + Z.position(), Z);
  }
  static startBool(Z) {
    Z.startObject(0);
  }
  static endBool(Z) {
    return Z.endObject();
  }
  static createBool(Z) {
    return _L.startBool(Z), _L.endBool(Z);
  }
}

// node_modules/apache-arrow/fb/date-unit.mjs
var CT;
(function(Z) {
  Z[Z.DAY = 0] = "DAY", Z[Z.MILLISECOND = 1] = "MILLISECOND";
})(CT || (CT = {}));

// node_modules/apache-arrow/fb/date.mjs
class X3 {
  constructor() {
    this.bb = null, this.bb_pos = 0;
  }
  __init(Z, J) {
    return this.bb_pos = Z, this.bb = J, this;
  }
  static getRootAsDate(Z, J) {
    return (J || new X3).__init(Z.readInt32(Z.position()) + Z.position(), Z);
  }
  static getSizePrefixedRootAsDate(Z, J) {
    return Z.setPosition(Z.position() + K6), (J || new X3).__init(Z.readInt32(Z.position()) + Z.position(), Z);
  }
  unit() {
    let Z = this.bb.__offset(this.bb_pos, 4);
    return Z ? this.bb.readInt16(this.bb_pos + Z) : CT.MILLISECOND;
  }
  static startDate(Z) {
    Z.startObject(1);
  }
  static addUnit(Z, J) {
    Z.addFieldInt16(0, J, CT.MILLISECOND);
  }
  static endDate(Z) {
    return Z.endObject();
  }
  static createDate(Z, J) {
    return X3.startDate(Z), X3.addUnit(Z, J), X3.endDate(Z);
  }
}

// node_modules/apache-arrow/fb/decimal.mjs
class VQ {
  constructor() {
    this.bb = null, this.bb_pos = 0;
  }
  __init(Z, J) {
    return this.bb_pos = Z, this.bb = J, this;
  }
  static getRootAsDecimal(Z, J) {
    return (J || new VQ).__init(Z.readInt32(Z.position()) + Z.position(), Z);
  }
  static getSizePrefixedRootAsDecimal(Z, J) {
    return Z.setPosition(Z.position() + K6), (J || new VQ).__init(Z.readInt32(Z.position()) + Z.position(), Z);
  }
  precision() {
    let Z = this.bb.__offset(this.bb_pos, 4);
    return Z ? this.bb.readInt32(this.bb_pos + Z) : 0;
  }
  scale() {
    let Z = this.bb.__offset(this.bb_pos, 6);
    return Z ? this.bb.readInt32(this.bb_pos + Z) : 0;
  }
  bitWidth() {
    let Z = this.bb.__offset(this.bb_pos, 8);
    return Z ? this.bb.readInt32(this.bb_pos + Z) : 128;
  }
  static startDecimal(Z) {
    Z.startObject(3);
  }
  static addPrecision(Z, J) {
    Z.addFieldInt32(0, J, 0);
  }
  static addScale(Z, J) {
    Z.addFieldInt32(1, J, 0);
  }
  static addBitWidth(Z, J) {
    Z.addFieldInt32(2, J, 128);
  }
  static endDecimal(Z) {
    return Z.endObject();
  }
  static createDecimal(Z, J, $, X) {
    return VQ.startDecimal(Z), VQ.addPrecision(Z, J), VQ.addScale(Z, $), VQ.addBitWidth(Z, X), VQ.endDecimal(Z);
  }
}

// node_modules/apache-arrow/fb/time-unit.mjs
var VL;
(function(Z) {
  Z[Z.SECOND = 0] = "SECOND", Z[Z.MILLISECOND = 1] = "MILLISECOND", Z[Z.MICROSECOND = 2] = "MICROSECOND", Z[Z.NANOSECOND = 3] = "NANOSECOND";
})(VL || (VL = {}));

// node_modules/apache-arrow/fb/fixed-size-binary.mjs
class Y3 {
  constructor() {
    this.bb = null, this.bb_pos = 0;
  }
  __init(Z, J) {
    return this.bb_pos = Z, this.bb = J, this;
  }
  static getRootAsFixedSizeBinary(Z, J) {
    return (J || new Y3).__init(Z.readInt32(Z.position()) + Z.position(), Z);
  }
  static getSizePrefixedRootAsFixedSizeBinary(Z, J) {
    return Z.setPosition(Z.position() + K6), (J || new Y3).__init(Z.readInt32(Z.position()) + Z.position(), Z);
  }
  byteWidth() {
    let Z = this.bb.__offset(this.bb_pos, 4);
    return Z ? this.bb.readInt32(this.bb_pos + Z) : 0;
  }
  static startFixedSizeBinary(Z) {
    Z.startObject(1);
  }
  static addByteWidth(Z, J) {
    Z.addFieldInt32(0, J, 0);
  }
  static endFixedSizeBinary(Z) {
    return Z.endObject();
  }
  static createFixedSizeBinary(Z, J) {
    return Y3.startFixedSizeBinary(Z), Y3.addByteWidth(Z, J), Y3.endFixedSizeBinary(Z);
  }
}

// node_modules/apache-arrow/fb/fixed-size-list.mjs
class Q3 {
  constructor() {
    this.bb = null, this.bb_pos = 0;
  }
  __init(Z, J) {
    return this.bb_pos = Z, this.bb = J, this;
  }
  static getRootAsFixedSizeList(Z, J) {
    return (J || new Q3).__init(Z.readInt32(Z.position()) + Z.position(), Z);
  }
  static getSizePrefixedRootAsFixedSizeList(Z, J) {
    return Z.setPosition(Z.position() + K6), (J || new Q3).__init(Z.readInt32(Z.position()) + Z.position(), Z);
  }
  listSize() {
    let Z = this.bb.__offset(this.bb_pos, 4);
    return Z ? this.bb.readInt32(this.bb_pos + Z) : 0;
  }
  static startFixedSizeList(Z) {
    Z.startObject(1);
  }
  static addListSize(Z, J) {
    Z.addFieldInt32(0, J, 0);
  }
  static endFixedSizeList(Z) {
    return Z.endObject();
  }
  static createFixedSizeList(Z, J) {
    return Q3.startFixedSizeList(Z), Q3.addListSize(Z, J), Q3.endFixedSizeList(Z);
  }
}

// node_modules/apache-arrow/fb/precision.mjs
var kT;
(function(Z) {
  Z[Z.HALF = 0] = "HALF", Z[Z.SINGLE = 1] = "SINGLE", Z[Z.DOUBLE = 2] = "DOUBLE";
})(kT || (kT = {}));

// node_modules/apache-arrow/fb/floating-point.mjs
class W3 {
  constructor() {
    this.bb = null, this.bb_pos = 0;
  }
  __init(Z, J) {
    return this.bb_pos = Z, this.bb = J, this;
  }
  static getRootAsFloatingPoint(Z, J) {
    return (J || new W3).__init(Z.readInt32(Z.position()) + Z.position(), Z);
  }
  static getSizePrefixedRootAsFloatingPoint(Z, J) {
    return Z.setPosition(Z.position() + K6), (J || new W3).__init(Z.readInt32(Z.position()) + Z.position(), Z);
  }
  precision() {
    let Z = this.bb.__offset(this.bb_pos, 4);
    return Z ? this.bb.readInt16(this.bb_pos + Z) : kT.HALF;
  }
  static startFloatingPoint(Z) {
    Z.startObject(1);
  }
  static addPrecision(Z, J) {
    Z.addFieldInt16(0, J, kT.HALF);
  }
  static endFloatingPoint(Z) {
    return Z.endObject();
  }
  static createFloatingPoint(Z, J) {
    return W3.startFloatingPoint(Z), W3.addPrecision(Z, J), W3.endFloatingPoint(Z);
  }
}

// node_modules/apache-arrow/fb/interval-unit.mjs
var vT;
(function(Z) {
  Z[Z.YEAR_MONTH = 0] = "YEAR_MONTH", Z[Z.DAY_TIME = 1] = "DAY_TIME", Z[Z.MONTH_DAY_NANO = 2] = "MONTH_DAY_NANO";
})(vT || (vT = {}));

// node_modules/apache-arrow/fb/interval.mjs
class K3 {
  constructor() {
    this.bb = null, this.bb_pos = 0;
  }
  __init(Z, J) {
    return this.bb_pos = Z, this.bb = J, this;
  }
  static getRootAsInterval(Z, J) {
    return (J || new K3).__init(Z.readInt32(Z.position()) + Z.position(), Z);
  }
  static getSizePrefixedRootAsInterval(Z, J) {
    return Z.setPosition(Z.position() + K6), (J || new K3).__init(Z.readInt32(Z.position()) + Z.position(), Z);
  }
  unit() {
    let Z = this.bb.__offset(this.bb_pos, 4);
    return Z ? this.bb.readInt16(this.bb_pos + Z) : vT.YEAR_MONTH;
  }
  static startInterval(Z) {
    Z.startObject(1);
  }
  static addUnit(Z, J) {
    Z.addFieldInt16(0, J, vT.YEAR_MONTH);
  }
  static endInterval(Z) {
    return Z.endObject();
  }
  static createInterval(Z, J) {
    return K3.startInterval(Z), K3.addUnit(Z, J), K3.endInterval(Z);
  }
}

// node_modules/apache-arrow/fb/list.mjs
class IL {
  constructor() {
    this.bb = null, this.bb_pos = 0;
  }
  __init(Z, J) {
    return this.bb_pos = Z, this.bb = J, this;
  }
  static getRootAsList(Z, J) {
    return (J || new IL).__init(Z.readInt32(Z.position()) + Z.position(), Z);
  }
  static getSizePrefixedRootAsList(Z, J) {
    return Z.setPosition(Z.position() + K6), (J || new IL).__init(Z.readInt32(Z.position()) + Z.position(), Z);
  }
  static startList(Z) {
    Z.startObject(0);
  }
  static endList(Z) {
    return Z.endObject();
  }
  static createList(Z) {
    return IL.startList(Z), IL.endList(Z);
  }
}

// node_modules/apache-arrow/fb/map.mjs
class G3 {
  constructor() {
    this.bb = null, this.bb_pos = 0;
  }
  __init(Z, J) {
    return this.bb_pos = Z, this.bb = J, this;
  }
  static getRootAsMap(Z, J) {
    return (J || new G3).__init(Z.readInt32(Z.position()) + Z.position(), Z);
  }
  static getSizePrefixedRootAsMap(Z, J) {
    return Z.setPosition(Z.position() + K6), (J || new G3).__init(Z.readInt32(Z.position()) + Z.position(), Z);
  }
  keysSorted() {
    let Z = this.bb.__offset(this.bb_pos, 4);
    return Z ? !!this.bb.readInt8(this.bb_pos + Z) : !1;
  }
  static startMap(Z) {
    Z.startObject(1);
  }
  static addKeysSorted(Z, J) {
    Z.addFieldInt8(0, +J, 0);
  }
  static endMap(Z) {
    return Z.endObject();
  }
  static createMap(Z, J) {
    return G3.startMap(Z), G3.addKeysSorted(Z, J), G3.endMap(Z);
  }
}

// node_modules/apache-arrow/fb/null.mjs
class PL {
  constructor() {
    this.bb = null, this.bb_pos = 0;
  }
  __init(Z, J) {
    return this.bb_pos = Z, this.bb = J, this;
  }
  static getRootAsNull(Z, J) {
    return (J || new PL).__init(Z.readInt32(Z.position()) + Z.position(), Z);
  }
  static getSizePrefixedRootAsNull(Z, J) {
    return Z.setPosition(Z.position() + K6), (J || new PL).__init(Z.readInt32(Z.position()) + Z.position(), Z);
  }
  static startNull(Z) {
    Z.startObject(0);
  }
  static endNull(Z) {
    return Z.endObject();
  }
  static createNull(Z) {
    return PL.startNull(Z), PL.endNull(Z);
  }
}

// node_modules/apache-arrow/fb/struct_.mjs
class CL {
  constructor() {
    this.bb = null, this.bb_pos = 0;
  }
  __init(Z, J) {
    return this.bb_pos = Z, this.bb = J, this;
  }
  static getRootAsStruct_(Z, J) {
    return (J || new CL).__init(Z.readInt32(Z.position()) + Z.position(), Z);
  }
  static getSizePrefixedRootAsStruct_(Z, J) {
    return Z.setPosition(Z.position() + K6), (J || new CL).__init(Z.readInt32(Z.position()) + Z.position(), Z);
  }
  static startStruct_(Z) {
    Z.startObject(0);
  }
  static endStruct_(Z) {
    return Z.endObject();
  }
  static createStruct_(Z) {
    return CL.startStruct_(Z), CL.endStruct_(Z);
  }
}

// node_modules/apache-arrow/fb/time.mjs
class G5 {
  constructor() {
    this.bb = null, this.bb_pos = 0;
  }
  __init(Z, J) {
    return this.bb_pos = Z, this.bb = J, this;
  }
  static getRootAsTime(Z, J) {
    return (J || new G5).__init(Z.readInt32(Z.position()) + Z.position(), Z);
  }
  static getSizePrefixedRootAsTime(Z, J) {
    return Z.setPosition(Z.position() + K6), (J || new G5).__init(Z.readInt32(Z.position()) + Z.position(), Z);
  }
  unit() {
    let Z = this.bb.__offset(this.bb_pos, 4);
    return Z ? this.bb.readInt16(this.bb_pos + Z) : VL.MILLISECOND;
  }
  bitWidth() {
    let Z = this.bb.__offset(this.bb_pos, 6);
    return Z ? this.bb.readInt32(this.bb_pos + Z) : 32;
  }
  static startTime(Z) {
    Z.startObject(2);
  }
  static addUnit(Z, J) {
    Z.addFieldInt16(0, J, VL.MILLISECOND);
  }
  static addBitWidth(Z, J) {
    Z.addFieldInt32(1, J, 32);
  }
  static endTime(Z) {
    return Z.endObject();
  }
  static createTime(Z, J, $) {
    return G5.startTime(Z), G5.addUnit(Z, J), G5.addBitWidth(Z, $), G5.endTime(Z);
  }
}

// node_modules/apache-arrow/fb/timestamp.mjs
class H5 {
  constructor() {
    this.bb = null, this.bb_pos = 0;
  }
  __init(Z, J) {
    return this.bb_pos = Z, this.bb = J, this;
  }
  static getRootAsTimestamp(Z, J) {
    return (J || new H5).__init(Z.readInt32(Z.position()) + Z.position(), Z);
  }
  static getSizePrefixedRootAsTimestamp(Z, J) {
    return Z.setPosition(Z.position() + K6), (J || new H5).__init(Z.readInt32(Z.position()) + Z.position(), Z);
  }
  unit() {
    let Z = this.bb.__offset(this.bb_pos, 4);
    return Z ? this.bb.readInt16(this.bb_pos + Z) : VL.SECOND;
  }
  timezone(Z) {
    let J = this.bb.__offset(this.bb_pos, 6);
    return J ? this.bb.__string(this.bb_pos + J, Z) : null;
  }
  static startTimestamp(Z) {
    Z.startObject(2);
  }
  static addUnit(Z, J) {
    Z.addFieldInt16(0, J, VL.SECOND);
  }
  static addTimezone(Z, J) {
    Z.addFieldOffset(1, J, 0);
  }
  static endTimestamp(Z) {
    return Z.endObject();
  }
  static createTimestamp(Z, J, $) {
    return H5.startTimestamp(Z), H5.addUnit(Z, J), H5.addTimezone(Z, $), H5.endTimestamp(Z);
  }
}

// node_modules/apache-arrow/fb/union-mode.mjs
var ST;
(function(Z) {
  Z[Z.Sparse = 0] = "Sparse", Z[Z.Dense = 1] = "Dense";
})(ST || (ST = {}));

// node_modules/apache-arrow/fb/union.mjs
class IQ {
  constructor() {
    this.bb = null, this.bb_pos = 0;
  }
  __init(Z, J) {
    return this.bb_pos = Z, this.bb = J, this;
  }
  static getRootAsUnion(Z, J) {
    return (J || new IQ).__init(Z.readInt32(Z.position()) + Z.position(), Z);
  }
  static getSizePrefixedRootAsUnion(Z, J) {
    return Z.setPosition(Z.position() + K6), (J || new IQ).__init(Z.readInt32(Z.position()) + Z.position(), Z);
  }
  mode() {
    let Z = this.bb.__offset(this.bb_pos, 4);
    return Z ? this.bb.readInt16(this.bb_pos + Z) : ST.Sparse;
  }
  typeIds(Z) {
    let J = this.bb.__offset(this.bb_pos, 6);
    return J ? this.bb.readInt32(this.bb.__vector(this.bb_pos + J) + Z * 4) : 0;
  }
  typeIdsLength() {
    let Z = this.bb.__offset(this.bb_pos, 6);
    return Z ? this.bb.__vector_len(this.bb_pos + Z) : 0;
  }
  typeIdsArray() {
    let Z = this.bb.__offset(this.bb_pos, 6);
    return Z ? new Int32Array(this.bb.bytes().buffer, this.bb.bytes().byteOffset + this.bb.__vector(this.bb_pos + Z), this.bb.__vector_len(this.bb_pos + Z)) : null;
  }
  static startUnion(Z) {
    Z.startObject(2);
  }
  static addMode(Z, J) {
    Z.addFieldInt16(0, J, ST.Sparse);
  }
  static addTypeIds(Z, J) {
    Z.addFieldOffset(1, J, 0);
  }
  static createTypeIdsVector(Z, J) {
    Z.startVector(4, J.length, 4);
    for (let $ = J.length - 1;$ >= 0; $--)
      Z.addInt32(J[$]);
    return Z.endVector();
  }
  static startTypeIdsVector(Z, J) {
    Z.startVector(4, J, 4);
  }
  static endUnion(Z) {
    return Z.endObject();
  }
  static createUnion(Z, J, $) {
    return IQ.startUnion(Z), IQ.addMode(Z, J), IQ.addTypeIds(Z, $), IQ.endUnion(Z);
  }
}

// node_modules/apache-arrow/fb/utf8.mjs
class kL {
  constructor() {
    this.bb = null, this.bb_pos = 0;
  }
  __init(Z, J) {
    return this.bb_pos = Z, this.bb = J, this;
  }
  static getRootAsUtf8(Z, J) {
    return (J || new kL).__init(Z.readInt32(Z.position()) + Z.position(), Z);
  }
  static getSizePrefixedRootAsUtf8(Z, J) {
    return Z.setPosition(Z.position() + K6), (J || new kL).__init(Z.readInt32(Z.position()) + Z.position(), Z);
  }
  static startUtf8(Z) {
    Z.startObject(0);
  }
  static endUtf8(Z) {
    return Z.endObject();
  }
  static createUtf8(Z) {
    return kL.startUtf8(Z), kL.endUtf8(Z);
  }
}

// node_modules/apache-arrow/fb/type.mjs
var FJ;
(function(Z) {
  Z[Z.NONE = 0] = "NONE", Z[Z.Null = 1] = "Null", Z[Z.Int = 2] = "Int", Z[Z.FloatingPoint = 3] = "FloatingPoint", Z[Z.Binary = 4] = "Binary", Z[Z.Utf8 = 5] = "Utf8", Z[Z.Bool = 6] = "Bool", Z[Z.Decimal = 7] = "Decimal", Z[Z.Date = 8] = "Date", Z[Z.Time = 9] = "Time", Z[Z.Timestamp = 10] = "Timestamp", Z[Z.Interval = 11] = "Interval", Z[Z.List = 12] = "List", Z[Z.Struct_ = 13] = "Struct_", Z[Z.Union = 14] = "Union", Z[Z.FixedSizeBinary = 15] = "FixedSizeBinary", Z[Z.FixedSizeList = 16] = "FixedSizeList", Z[Z.Map = 17] = "Map", Z[Z.Duration = 18] = "Duration", Z[Z.LargeBinary = 19] = "LargeBinary", Z[Z.LargeUtf8 = 20] = "LargeUtf8", Z[Z.LargeList = 21] = "LargeList";
})(FJ || (FJ = {}));

// node_modules/apache-arrow/fb/field.mjs
class XY {
  constructor() {
    this.bb = null, this.bb_pos = 0;
  }
  __init(Z, J) {
    return this.bb_pos = Z, this.bb = J, this;
  }
  static getRootAsField(Z, J) {
    return (J || new XY).__init(Z.readInt32(Z.position()) + Z.position(), Z);
  }
  static getSizePrefixedRootAsField(Z, J) {
    return Z.setPosition(Z.position() + K6), (J || new XY).__init(Z.readInt32(Z.position()) + Z.position(), Z);
  }
  name(Z) {
    let J = this.bb.__offset(this.bb_pos, 4);
    return J ? this.bb.__string(this.bb_pos + J, Z) : null;
  }
  nullable() {
    let Z = this.bb.__offset(this.bb_pos, 6);
    return Z ? !!this.bb.readInt8(this.bb_pos + Z) : !1;
  }
  typeType() {
    let Z = this.bb.__offset(this.bb_pos, 8);
    return Z ? this.bb.readUint8(this.bb_pos + Z) : FJ.NONE;
  }
  type(Z) {
    let J = this.bb.__offset(this.bb_pos, 10);
    return J ? this.bb.__union(Z, this.bb_pos + J) : null;
  }
  dictionary(Z) {
    let J = this.bb.__offset(this.bb_pos, 12);
    return J ? (Z || new nG).__init(this.bb.__indirect(this.bb_pos + J), this.bb) : null;
  }
  children(Z, J) {
    let $ = this.bb.__offset(this.bb_pos, 14);
    return $ ? (J || new XY).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos + $) + Z * 4), this.bb) : null;
  }
  childrenLength() {
    let Z = this.bb.__offset(this.bb_pos, 14);
    return Z ? this.bb.__vector_len(this.bb_pos + Z) : 0;
  }
  customMetadata(Z, J) {
    let $ = this.bb.__offset(this.bb_pos, 16);
    return $ ? (J || new BJ).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos + $) + Z * 4), this.bb) : null;
  }
  customMetadataLength() {
    let Z = this.bb.__offset(this.bb_pos, 16);
    return Z ? this.bb.__vector_len(this.bb_pos + Z) : 0;
  }
  static startField(Z) {
    Z.startObject(7);
  }
  static addName(Z, J) {
    Z.addFieldOffset(0, J, 0);
  }
  static addNullable(Z, J) {
    Z.addFieldInt8(1, +J, 0);
  }
  static addTypeType(Z, J) {
    Z.addFieldInt8(2, J, FJ.NONE);
  }
  static addType(Z, J) {
    Z.addFieldOffset(3, J, 0);
  }
  static addDictionary(Z, J) {
    Z.addFieldOffset(4, J, 0);
  }
  static addChildren(Z, J) {
    Z.addFieldOffset(5, J, 0);
  }
  static createChildrenVector(Z, J) {
    Z.startVector(4, J.length, 4);
    for (let $ = J.length - 1;$ >= 0; $--)
      Z.addOffset(J[$]);
    return Z.endVector();
  }
  static startChildrenVector(Z, J) {
    Z.startVector(4, J, 4);
  }
  static addCustomMetadata(Z, J) {
    Z.addFieldOffset(6, J, 0);
  }
  static createCustomMetadataVector(Z, J) {
    Z.startVector(4, J.length, 4);
    for (let $ = J.length - 1;$ >= 0; $--)
      Z.addOffset(J[$]);
    return Z.endVector();
  }
  static startCustomMetadataVector(Z, J) {
    Z.startVector(4, J, 4);
  }
  static endField(Z) {
    return Z.endObject();
  }
}

// node_modules/apache-arrow/fb/schema.mjs
class P$ {
  constructor() {
    this.bb = null, this.bb_pos = 0;
  }
  __init(Z, J) {
    return this.bb_pos = Z, this.bb = J, this;
  }
  static getRootAsSchema(Z, J) {
    return (J || new P$).__init(Z.readInt32(Z.position()) + Z.position(), Z);
  }
  static getSizePrefixedRootAsSchema(Z, J) {
    return Z.setPosition(Z.position() + K6), (J || new P$).__init(Z.readInt32(Z.position()) + Z.position(), Z);
  }
  endianness() {
    let Z = this.bb.__offset(this.bb_pos, 4);
    return Z ? this.bb.readInt16(this.bb_pos + Z) : jL.Little;
  }
  fields(Z, J) {
    let $ = this.bb.__offset(this.bb_pos, 6);
    return $ ? (J || new XY).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos + $) + Z * 4), this.bb) : null;
  }
  fieldsLength() {
    let Z = this.bb.__offset(this.bb_pos, 6);
    return Z ? this.bb.__vector_len(this.bb_pos + Z) : 0;
  }
  customMetadata(Z, J) {
    let $ = this.bb.__offset(this.bb_pos, 8);
    return $ ? (J || new BJ).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos + $) + Z * 4), this.bb) : null;
  }
  customMetadataLength() {
    let Z = this.bb.__offset(this.bb_pos, 8);
    return Z ? this.bb.__vector_len(this.bb_pos + Z) : 0;
  }
  features(Z) {
    let J = this.bb.__offset(this.bb_pos, 10);
    return J ? this.bb.readInt64(this.bb.__vector(this.bb_pos + J) + Z * 8) : this.bb.createLong(0, 0);
  }
  featuresLength() {
    let Z = this.bb.__offset(this.bb_pos, 10);
    return Z ? this.bb.__vector_len(this.bb_pos + Z) : 0;
  }
  static startSchema(Z) {
    Z.startObject(4);
  }
  static addEndianness(Z, J) {
    Z.addFieldInt16(0, J, jL.Little);
  }
  static addFields(Z, J) {
    Z.addFieldOffset(1, J, 0);
  }
  static createFieldsVector(Z, J) {
    Z.startVector(4, J.length, 4);
    for (let $ = J.length - 1;$ >= 0; $--)
      Z.addOffset(J[$]);
    return Z.endVector();
  }
  static startFieldsVector(Z, J) {
    Z.startVector(4, J, 4);
  }
  static addCustomMetadata(Z, J) {
    Z.addFieldOffset(2, J, 0);
  }
  static createCustomMetadataVector(Z, J) {
    Z.startVector(4, J.length, 4);
    for (let $ = J.length - 1;$ >= 0; $--)
      Z.addOffset(J[$]);
    return Z.endVector();
  }
  static startCustomMetadataVector(Z, J) {
    Z.startVector(4, J, 4);
  }
  static addFeatures(Z, J) {
    Z.addFieldOffset(3, J, 0);
  }
  static createFeaturesVector(Z, J) {
    Z.startVector(8, J.length, 8);
    for (let $ = J.length - 1;$ >= 0; $--)
      Z.addInt64(J[$]);
    return Z.endVector();
  }
  static startFeaturesVector(Z, J) {
    Z.startVector(8, J, 8);
  }
  static endSchema(Z) {
    return Z.endObject();
  }
  static finishSchemaBuffer(Z, J) {
    Z.finish(J);
  }
  static finishSizePrefixedSchemaBuffer(Z, J) {
    Z.finish(J, void 0, !0);
  }
  static createSchema(Z, J, $, X, Y) {
    return P$.startSchema(Z), P$.addEndianness(Z, J), P$.addFields(Z, $), P$.addCustomMetadata(Z, X), P$.addFeatures(Z, Y), P$.endSchema(Z);
  }
}

// node_modules/apache-arrow/fb/footer.mjs
class N5 {
  constructor() {
    this.bb = null, this.bb_pos = 0;
  }
  __init(Z, J) {
    return this.bb_pos = Z, this.bb = J, this;
  }
  static getRootAsFooter(Z, J) {
    return (J || new N5).__init(Z.readInt32(Z.position()) + Z.position(), Z);
  }
  static getSizePrefixedRootAsFooter(Z, J) {
    return Z.setPosition(Z.position() + K6), (J || new N5).__init(Z.readInt32(Z.position()) + Z.position(), Z);
  }
  version() {
    let Z = this.bb.__offset(this.bb_pos, 4);
    return Z ? this.bb.readInt16(this.bb_pos + Z) : wL.V1;
  }
  schema(Z) {
    let J = this.bb.__offset(this.bb_pos, 6);
    return J ? (Z || new P$).__init(this.bb.__indirect(this.bb_pos + J), this.bb) : null;
  }
  dictionaries(Z, J) {
    let $ = this.bb.__offset(this.bb_pos, 8);
    return $ ? (J || new dD).__init(this.bb.__vector(this.bb_pos + $) + Z * 24, this.bb) : null;
  }
  dictionariesLength() {
    let Z = this.bb.__offset(this.bb_pos, 8);
    return Z ? this.bb.__vector_len(this.bb_pos + Z) : 0;
  }
  recordBatches(Z, J) {
    let $ = this.bb.__offset(this.bb_pos, 10);
    return $ ? (J || new dD).__init(this.bb.__vector(this.bb_pos + $) + Z * 24, this.bb) : null;
  }
  recordBatchesLength() {
    let Z = this.bb.__offset(this.bb_pos, 10);
    return Z ? this.bb.__vector_len(this.bb_pos + Z) : 0;
  }
  customMetadata(Z, J) {
    let $ = this.bb.__offset(this.bb_pos, 12);
    return $ ? (J || new BJ).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos + $) + Z * 4), this.bb) : null;
  }
  customMetadataLength() {
    let Z = this.bb.__offset(this.bb_pos, 12);
    return Z ? this.bb.__vector_len(this.bb_pos + Z) : 0;
  }
  static startFooter(Z) {
    Z.startObject(5);
  }
  static addVersion(Z, J) {
    Z.addFieldInt16(0, J, wL.V1);
  }
  static addSchema(Z, J) {
    Z.addFieldOffset(1, J, 0);
  }
  static addDictionaries(Z, J) {
    Z.addFieldOffset(2, J, 0);
  }
  static startDictionariesVector(Z, J) {
    Z.startVector(24, J, 8);
  }
  static addRecordBatches(Z, J) {
    Z.addFieldOffset(3, J, 0);
  }
  static startRecordBatchesVector(Z, J) {
    Z.startVector(24, J, 8);
  }
  static addCustomMetadata(Z, J) {
    Z.addFieldOffset(4, J, 0);
  }
  static createCustomMetadataVector(Z, J) {
    Z.startVector(4, J.length, 4);
    for (let $ = J.length - 1;$ >= 0; $--)
      Z.addOffset(J[$]);
    return Z.endVector();
  }
  static startCustomMetadataVector(Z, J) {
    Z.startVector(4, J, 4);
  }
  static endFooter(Z) {
    return Z.endObject();
  }
  static finishFooterBuffer(Z, J) {
    Z.finish(J);
  }
  static finishSizePrefixedFooterBuffer(Z, J) {
    Z.finish(J, void 0, !0);
  }
}

// node_modules/apache-arrow/schema.mjs
class U9 {
  constructor(Z = [], J, $) {
    if (this.fields = Z || [], this.metadata = J || /* @__PURE__ */ new Map, !$)
      $ = wl(Z);
    this.dictionaries = $;
  }
  get [Symbol.toStringTag]() {
    return "Schema";
  }
  get names() {
    return this.fields.map((Z) => Z.name);
  }
  toString() {
    return `Schema<{ ${this.fields.map((Z, J) => `${J}: ${Z}`).join(", ")} }>`;
  }
  select(Z) {
    let J = new Set(Z), $ = this.fields.filter((X) => J.has(X.name));
    return new U9($, this.metadata);
  }
  selectAt(Z) {
    let J = Z.map(($) => this.fields[$]).filter(Boolean);
    return new U9(J, this.metadata);
  }
  assign(...Z) {
    let J = Z[0] instanceof U9 ? Z[0] : Array.isArray(Z[0]) ? new U9(Z[0]) : new U9(Z), $ = [...this.fields], X = Tv(Tv(/* @__PURE__ */ new Map, this.metadata), J.metadata), Y = J.fields.filter((W) => {
      let K = $.findIndex((G) => G.name === W.name);
      return ~K ? ($[K] = W.clone({
        metadata: Tv(Tv(/* @__PURE__ */ new Map, $[K].metadata), W.metadata)
      })) && !1 : !0;
    }), Q = wl(Y, /* @__PURE__ */ new Map);
    return new U9([...$, ...Y], X, new Map([...this.dictionaries, ...Q]));
  }
}
U9.prototype.fields = null;
U9.prototype.metadata = null;
U9.prototype.dictionaries = null;

class SZ {
  constructor(Z, J, $ = !1, X) {
    this.name = Z, this.type = J, this.nullable = $, this.metadata = X || /* @__PURE__ */ new Map;
  }
  static new(...Z) {
    let [J, $, X, Y] = Z;
    if (Z[0] && typeof Z[0] === "object")
      ({ name: J } = Z[0]), $ === void 0 && ($ = Z[0].type), X === void 0 && (X = Z[0].nullable), Y === void 0 && (Y = Z[0].metadata);
    return new SZ(`${J}`, $, X, Y);
  }
  get typeId() {
    return this.type.typeId;
  }
  get [Symbol.toStringTag]() {
    return "Field";
  }
  toString() {
    return `${this.name}: ${this.type}`;
  }
  clone(...Z) {
    let [J, $, X, Y] = Z;
    return !Z[0] || typeof Z[0] !== "object" ? [J = this.name, $ = this.type, X = this.nullable, Y = this.metadata] = Z : { name: J = this.name, type: $ = this.type, nullable: X = this.nullable, metadata: Y = this.metadata } = Z[0], SZ.new(J, $, X, Y);
  }
}
SZ.prototype.type = null;
SZ.prototype.name = null;
SZ.prototype.nullable = null;
SZ.prototype.metadata = null;
function Tv(Z, J) {
  return new Map([...Z || /* @__PURE__ */ new Map, ...J || /* @__PURE__ */ new Map]);
}
function wl(Z, J = /* @__PURE__ */ new Map) {
  for (let $ = -1, X = Z.length;++$ < X; ) {
    let Q = Z[$].type;
    if (L6.isDictionary(Q)) {
      if (!J.has(Q.id))
        J.set(Q.id, Q.dictionary);
      else if (J.get(Q.id) !== Q.dictionary)
        throw new Error("Cannot create Schema containing two different dictionaries with the same Id");
    }
    if (Q.children && Q.children.length > 0)
      wl(Q.children, J);
  }
  return J;
}

// node_modules/apache-arrow/ipc/metadata/file.mjs
var xQ0 = $Y, zo0 = IO, Do0 = GK;

class vL {
  constructor(Z, J = JY.V4, $, X) {
    this.schema = Z, this.version = J, $ && (this._recordBatches = $), X && (this._dictionaryBatches = X);
  }
  static decode(Z) {
    Z = new Do0(YZ(Z));
    let J = N5.getRootAsFooter(Z), $ = U9.decode(J.schema());
    return new yQ0($, J);
  }
  static encode(Z) {
    let J = new zo0, $ = U9.encode(J, Z.schema);
    N5.startRecordBatchesVector(J, Z.numRecordBatches);
    for (let Q of [...Z.recordBatches()].slice().reverse())
      BF.encode(J, Q);
    let X = J.endVector();
    N5.startDictionariesVector(J, Z.numDictionaries);
    for (let Q of [...Z.dictionaryBatches()].slice().reverse())
      BF.encode(J, Q);
    let Y = J.endVector();
    return N5.startFooter(J), N5.addSchema(J, $), N5.addVersion(J, JY.V4), N5.addRecordBatches(J, X), N5.addDictionaries(J, Y), N5.finishFooterBuffer(J, N5.endFooter(J)), J.asUint8Array();
  }
  get numRecordBatches() {
    return this._recordBatches.length;
  }
  get numDictionaries() {
    return this._dictionaryBatches.length;
  }
  *recordBatches() {
    for (let Z, J = -1, $ = this.numRecordBatches;++J < $; )
      if (Z = this.getRecordBatch(J))
        yield Z;
  }
  *dictionaryBatches() {
    for (let Z, J = -1, $ = this.numDictionaries;++J < $; )
      if (Z = this.getDictionaryBatch(J))
        yield Z;
  }
  getRecordBatch(Z) {
    return Z >= 0 && Z < this.numRecordBatches && this._recordBatches[Z] || null;
  }
  getDictionaryBatch(Z) {
    return Z >= 0 && Z < this.numDictionaries && this._dictionaryBatches[Z] || null;
  }
}
class yQ0 extends vL {
  constructor(Z, J) {
    super(Z, J.version());
    this._footer = J;
  }
  get numRecordBatches() {
    return this._footer.recordBatchesLength();
  }
  get numDictionaries() {
    return this._footer.dictionariesLength();
  }
  getRecordBatch(Z) {
    if (Z >= 0 && Z < this.numRecordBatches) {
      let J = this._footer.recordBatches(Z);
      if (J)
        return BF.decode(J);
    }
    return null;
  }
  getDictionaryBatch(Z) {
    if (Z >= 0 && Z < this.numDictionaries) {
      let J = this._footer.dictionaries(Z);
      if (J)
        return BF.decode(J);
    }
    return null;
  }
}

class BF {
  constructor(Z, J, $) {
    this.metaDataLength = Z, this.offset = typeof $ === "number" ? $ : $.low, this.bodyLength = typeof J === "number" ? J : J.low;
  }
  static decode(Z) {
    return new BF(Z.metaDataLength(), Z.bodyLength(), Z.offset());
  }
  static encode(Z, J) {
    let { metaDataLength: $ } = J, X = new xQ0(J.offset, 0), Y = new xQ0(J.bodyLength, 0);
    return dD.createBlock(Z, X, $, Y);
  }
}

// node_modules/apache-arrow/io/interfaces.mjs
var a7 = Object.freeze({ done: !0, value: void 0 });

class _v {
  constructor(Z) {
    this._json = Z;
  }
  get schema() {
    return this._json.schema;
  }
  get batches() {
    return this._json.batches || [];
  }
  get dictionaries() {
    return this._json.dictionaries || [];
  }
}

class uD {
  tee() {
    return this._getDOMStream().tee();
  }
  pipe(Z, J) {
    return this._getNodeStream().pipe(Z, J);
  }
  pipeTo(Z, J) {
    return this._getDOMStream().pipeTo(Z, J);
  }
  pipeThrough(Z, J) {
    return this._getDOMStream().pipeThrough(Z, J);
  }
  _getDOMStream() {
    return this._DOMStream || (this._DOMStream = this.toDOMStream());
  }
  _getNodeStream() {
    return this._nodeStream || (this._nodeStream = this.toNodeStream());
  }
}

class jl extends uD {
  constructor() {
    super();
    this._values = [], this.resolvers = [], this._closedPromise = new Promise((Z) => this._closedPromiseResolve = Z);
  }
  get closed() {
    return this._closedPromise;
  }
  cancel(Z) {
    return j8(this, void 0, void 0, function* () {
      yield this.return(Z);
    });
  }
  write(Z) {
    if (this._ensureOpen())
      this.resolvers.length <= 0 ? this._values.push(Z) : this.resolvers.shift().resolve({ done: !1, value: Z });
  }
  abort(Z) {
    if (this._closedPromiseResolve)
      this.resolvers.length <= 0 ? this._error = { error: Z } : this.resolvers.shift().reject({ done: !0, value: Z });
  }
  close() {
    if (this._closedPromiseResolve) {
      let { resolvers: Z } = this;
      while (Z.length > 0)
        Z.shift().resolve(a7);
      this._closedPromiseResolve(), this._closedPromiseResolve = void 0;
    }
  }
  [Symbol.asyncIterator]() {
    return this;
  }
  toDOMStream(Z) {
    return ZQ.toDOMStream(this._closedPromiseResolve || this._error ? this : this._values, Z);
  }
  toNodeStream(Z) {
    return ZQ.toNodeStream(this._closedPromiseResolve || this._error ? this : this._values, Z);
  }
  throw(Z) {
    return j8(this, void 0, void 0, function* () {
      return yield this.abort(Z), a7;
    });
  }
  return(Z) {
    return j8(this, void 0, void 0, function* () {
      return yield this.close(), a7;
    });
  }
  read(Z) {
    return j8(this, void 0, void 0, function* () {
      return (yield this.next(Z, "read")).value;
    });
  }
  peek(Z) {
    return j8(this, void 0, void 0, function* () {
      return (yield this.next(Z, "peek")).value;
    });
  }
  next(...Z) {
    if (this._values.length > 0)
      return Promise.resolve({ done: !1, value: this._values.shift() });
    else if (this._error)
      return Promise.reject({ done: !0, value: this._error.error });
    else if (!this._closedPromiseResolve)
      return Promise.resolve(a7);
    else
      return new Promise((J, $) => {
        this.resolvers.push({ resolve: J, reject: $ });
      });
  }
  _ensureOpen() {
    if (this._closedPromiseResolve)
      return !0;
    throw new Error("AsyncQueue is closed");
  }
}

// node_modules/apache-arrow/io/stream.mjs
class wF extends jl {
  write(Z) {
    if ((Z = YZ(Z)).byteLength > 0)
      return super.write(Z);
  }
  toString(Z = !1) {
    return Z ? RT(this.toUint8Array(!0)) : this.toUint8Array(!1).then(RT);
  }
  toUint8Array(Z = !1) {
    return Z ? XK(this._values)[0] : (() => j8(this, void 0, void 0, function* () {
      var J, $;
      let X = [], Y = 0;
      try {
        for (var Q = mG(this), W;W = yield Q.next(), !W.done; ) {
          let K = W.value;
          X.push(K), Y += K.byteLength;
        }
      } catch (K) {
        J = { error: K };
      } finally {
        try {
          if (W && !W.done && ($ = Q.return))
            yield $.call(Q);
        } finally {
          if (J)
            throw J.error;
        }
      }
      return XK(X, Y)[0];
    }))();
  }
}

class jF {
  constructor(Z) {
    if (Z)
      this.source = new gQ0(ZQ.fromIterable(Z));
  }
  [Symbol.iterator]() {
    return this;
  }
  next(Z) {
    return this.source.next(Z);
  }
  throw(Z) {
    return this.source.throw(Z);
  }
  return(Z) {
    return this.source.return(Z);
  }
  peek(Z) {
    return this.source.peek(Z);
  }
  read(Z) {
    return this.source.read(Z);
  }
}

class H3 {
  constructor(Z) {
    if (Z instanceof H3)
      this.source = Z.source;
    else if (Z instanceof wF)
      this.source = new SL(ZQ.fromAsyncIterable(Z));
    else if (rk(Z))
      this.source = new SL(ZQ.fromNodeStream(Z));
    else if (ET(Z))
      this.source = new SL(ZQ.fromDOMStream(Z));
    else if (sk(Z))
      this.source = new SL(ZQ.fromDOMStream(Z.body));
    else if (dG(Z))
      this.source = new SL(ZQ.fromIterable(Z));
    else if ($K(Z))
      this.source = new SL(ZQ.fromAsyncIterable(Z));
    else if (tK(Z))
      this.source = new SL(ZQ.fromAsyncIterable(Z));
  }
  [Symbol.asyncIterator]() {
    return this;
  }
  next(Z) {
    return this.source.next(Z);
  }
  throw(Z) {
    return this.source.throw(Z);
  }
  return(Z) {
    return this.source.return(Z);
  }
  get closed() {
    return this.source.closed;
  }
  cancel(Z) {
    return this.source.cancel(Z);
  }
  peek(Z) {
    return this.source.peek(Z);
  }
  read(Z) {
    return this.source.read(Z);
  }
}

class gQ0 {
  constructor(Z) {
    this.source = Z;
  }
  cancel(Z) {
    this.return(Z);
  }
  peek(Z) {
    return this.next(Z, "peek").value;
  }
  read(Z) {
    return this.next(Z, "read").value;
  }
  next(Z, J = "read") {
    return this.source.next({ cmd: J, size: Z });
  }
  throw(Z) {
    return Object.create(this.source.throw && this.source.throw(Z) || a7);
  }
  return(Z) {
    return Object.create(this.source.return && this.source.return(Z) || a7);
  }
}

class SL {
  constructor(Z) {
    this.source = Z, this._closedPromise = new Promise((J) => this._closedPromiseResolve = J);
  }
  cancel(Z) {
    return j8(this, void 0, void 0, function* () {
      yield this.return(Z);
    });
  }
  get closed() {
    return this._closedPromise;
  }
  read(Z) {
    return j8(this, void 0, void 0, function* () {
      return (yield this.next(Z, "read")).value;
    });
  }
  peek(Z) {
    return j8(this, void 0, void 0, function* () {
      return (yield this.next(Z, "peek")).value;
    });
  }
  next(Z, J = "read") {
    return j8(this, void 0, void 0, function* () {
      return yield this.source.next({ cmd: J, size: Z });
    });
  }
  throw(Z) {
    return j8(this, void 0, void 0, function* () {
      let J = this.source.throw && (yield this.source.throw(Z)) || a7;
      return this._closedPromiseResolve && this._closedPromiseResolve(), this._closedPromiseResolve = void 0, Object.create(J);
    });
  }
  return(Z) {
    return j8(this, void 0, void 0, function* () {
      let J = this.source.return && (yield this.source.return(Z)) || a7;
      return this._closedPromiseResolve && this._closedPromiseResolve(), this._closedPromiseResolve = void 0, Object.create(J);
    });
  }
}

// node_modules/apache-arrow/io/file.mjs
class Vv extends jF {
  constructor(Z, J) {
    super();
    this.position = 0, this.buffer = YZ(Z), this.size = typeof J === "undefined" ? this.buffer.byteLength : J;
  }
  readInt32(Z) {
    let { buffer: J, byteOffset: $ } = this.readAt(Z, 4);
    return new DataView(J, $).getInt32(0, !0);
  }
  seek(Z) {
    return this.position = Math.min(Z, this.size), Z < this.size;
  }
  read(Z) {
    let { buffer: J, size: $, position: X } = this;
    if (J && X < $) {
      if (typeof Z !== "number")
        Z = Number.POSITIVE_INFINITY;
      return this.position = Math.min($, X + Math.min($ - X, Z)), J.subarray(X, this.position);
    }
    return null;
  }
  readAt(Z, J) {
    let $ = this.buffer, X = Math.min(this.size, Z + J);
    return $ ? $.subarray(Z, X) : new Uint8Array(J);
  }
  close() {
    this.buffer && (this.buffer = null);
  }
  throw(Z) {
    return this.close(), { done: !0, value: Z };
  }
  return(Z) {
    return this.close(), { done: !0, value: Z };
  }
}

class PO extends H3 {
  constructor(Z, J) {
    super();
    if (this.position = 0, this._handle = Z, typeof J === "number")
      this.size = J;
    else
      this._pending = (() => j8(this, void 0, void 0, function* () {
        this.size = (yield Z.stat()).size, delete this._pending;
      }))();
  }
  readInt32(Z) {
    return j8(this, void 0, void 0, function* () {
      let { buffer: J, byteOffset: $ } = yield this.readAt(Z, 4);
      return new DataView(J, $).getInt32(0, !0);
    });
  }
  seek(Z) {
    return j8(this, void 0, void 0, function* () {
      return this._pending && (yield this._pending), this.position = Math.min(Z, this.size), Z < this.size;
    });
  }
  read(Z) {
    return j8(this, void 0, void 0, function* () {
      this._pending && (yield this._pending);
      let { _handle: J, size: $, position: X } = this;
      if (J && X < $) {
        if (typeof Z !== "number")
          Z = Number.POSITIVE_INFINITY;
        let Y = X, Q = 0, W = 0, K = Math.min($, Y + Math.min($ - Y, Z)), G = new Uint8Array(Math.max(0, (this.position = K) - Y));
        while ((Y += W) < K && (Q += W) < G.byteLength)
          ({ bytesRead: W } = yield J.read(G, Q, G.byteLength - Q, Y));
        return G;
      }
      return null;
    });
  }
  readAt(Z, J) {
    return j8(this, void 0, void 0, function* () {
      this._pending && (yield this._pending);
      let { _handle: $, size: X } = this;
      if ($ && Z + J < X) {
        let Y = Math.min(X, Z + J), Q = new Uint8Array(Y - Z);
        return (yield $.read(Q, 0, J, Z)).buffer;
      }
      return new Uint8Array(J);
    });
  }
  close() {
    return j8(this, void 0, void 0, function* () {
      let Z = this._handle;
      this._handle = null, Z && (yield Z.close());
    });
  }
  throw(Z) {
    return j8(this, void 0, void 0, function* () {
      return yield this.close(), { done: !0, value: Z };
    });
  }
  return(Z) {
    return j8(this, void 0, void 0, function* () {
      return yield this.close(), { done: !0, value: Z };
    });
  }
}

// node_modules/apache-arrow/util/int.mjs
var _l = {};
y9(_l, {
  Uint64: () => z7,
  Int64: () => PQ,
  Int128: () => N3,
  BaseInt64: () => Iv
});
function cD(Z) {
  if (Z < 0)
    Z = 4294967295 + Z + 1;
  return `0x${Z.toString(16)}`;
}
var lD = 8, Tl = [
  1,
  10,
  100,
  1000,
  1e4,
  1e5,
  1e6,
  1e7,
  1e8
];

class Iv {
  constructor(Z) {
    this.buffer = Z;
  }
  high() {
    return this.buffer[1];
  }
  low() {
    return this.buffer[0];
  }
  _times(Z) {
    let J = new Uint32Array([
      this.buffer[1] >>> 16,
      this.buffer[1] & 65535,
      this.buffer[0] >>> 16,
      this.buffer[0] & 65535
    ]), $ = new Uint32Array([
      Z.buffer[1] >>> 16,
      Z.buffer[1] & 65535,
      Z.buffer[0] >>> 16,
      Z.buffer[0] & 65535
    ]), X = J[3] * $[3];
    this.buffer[0] = X & 65535;
    let Y = X >>> 16;
    return X = J[2] * $[3], Y += X, X = J[3] * $[2] >>> 0, Y += X, this.buffer[0] += Y << 16, this.buffer[1] = Y >>> 0 < X ? 65536 : 0, this.buffer[1] += Y >>> 16, this.buffer[1] += J[1] * $[3] + J[2] * $[2] + J[3] * $[1], this.buffer[1] += J[0] * $[3] + J[1] * $[2] + J[2] * $[1] + J[3] * $[0] << 16, this;
  }
  _plus(Z) {
    let J = this.buffer[0] + Z.buffer[0] >>> 0;
    if (this.buffer[1] += Z.buffer[1], J < this.buffer[0] >>> 0)
      ++this.buffer[1];
    this.buffer[0] = J;
  }
  lessThan(Z) {
    return this.buffer[1] < Z.buffer[1] || this.buffer[1] === Z.buffer[1] && this.buffer[0] < Z.buffer[0];
  }
  equals(Z) {
    return this.buffer[1] === Z.buffer[1] && this.buffer[0] == Z.buffer[0];
  }
  greaterThan(Z) {
    return Z.lessThan(this);
  }
  hex() {
    return `${cD(this.buffer[1])} ${cD(this.buffer[0])}`;
  }
}

class z7 extends Iv {
  times(Z) {
    return this._times(Z), this;
  }
  plus(Z) {
    return this._plus(Z), this;
  }
  static from(Z, J = new Uint32Array(2)) {
    return z7.fromString(typeof Z === "string" ? Z : Z.toString(), J);
  }
  static fromNumber(Z, J = new Uint32Array(2)) {
    return z7.fromString(Z.toString(), J);
  }
  static fromString(Z, J = new Uint32Array(2)) {
    let $ = Z.length, X = new z7(J);
    for (let Y = 0;Y < $; ) {
      let Q = lD < $ - Y ? lD : $ - Y, W = new z7(new Uint32Array([Number.parseInt(Z.slice(Y, Y + Q), 10), 0])), K = new z7(new Uint32Array([Tl[Q], 0]));
      X.times(K), X.plus(W), Y += Q;
    }
    return X;
  }
  static convertArray(Z) {
    let J = new Uint32Array(Z.length * 2);
    for (let $ = -1, X = Z.length;++$ < X; )
      z7.from(Z[$], new Uint32Array(J.buffer, J.byteOffset + 2 * $ * 4, 2));
    return J;
  }
  static multiply(Z, J) {
    return new z7(new Uint32Array(Z.buffer)).times(J);
  }
  static add(Z, J) {
    return new z7(new Uint32Array(Z.buffer)).plus(J);
  }
}

class PQ extends Iv {
  negate() {
    if (this.buffer[0] = ~this.buffer[0] + 1, this.buffer[1] = ~this.buffer[1], this.buffer[0] == 0)
      ++this.buffer[1];
    return this;
  }
  times(Z) {
    return this._times(Z), this;
  }
  plus(Z) {
    return this._plus(Z), this;
  }
  lessThan(Z) {
    let J = this.buffer[1] << 0, $ = Z.buffer[1] << 0;
    return J < $ || J === $ && this.buffer[0] < Z.buffer[0];
  }
  static from(Z, J = new Uint32Array(2)) {
    return PQ.fromString(typeof Z === "string" ? Z : Z.toString(), J);
  }
  static fromNumber(Z, J = new Uint32Array(2)) {
    return PQ.fromString(Z.toString(), J);
  }
  static fromString(Z, J = new Uint32Array(2)) {
    let $ = Z.startsWith("-"), X = Z.length, Y = new PQ(J);
    for (let Q = $ ? 1 : 0;Q < X; ) {
      let W = lD < X - Q ? lD : X - Q, K = new PQ(new Uint32Array([Number.parseInt(Z.slice(Q, Q + W), 10), 0])), G = new PQ(new Uint32Array([Tl[W], 0]));
      Y.times(G), Y.plus(K), Q += W;
    }
    return $ ? Y.negate() : Y;
  }
  static convertArray(Z) {
    let J = new Uint32Array(Z.length * 2);
    for (let $ = -1, X = Z.length;++$ < X; )
      PQ.from(Z[$], new Uint32Array(J.buffer, J.byteOffset + 2 * $ * 4, 2));
    return J;
  }
  static multiply(Z, J) {
    return new PQ(new Uint32Array(Z.buffer)).times(J);
  }
  static add(Z, J) {
    return new PQ(new Uint32Array(Z.buffer)).plus(J);
  }
}

class N3 {
  constructor(Z) {
    this.buffer = Z;
  }
  high() {
    return new PQ(new Uint32Array(this.buffer.buffer, this.buffer.byteOffset + 8, 2));
  }
  low() {
    return new PQ(new Uint32Array(this.buffer.buffer, this.buffer.byteOffset, 2));
  }
  negate() {
    if (this.buffer[0] = ~this.buffer[0] + 1, this.buffer[1] = ~this.buffer[1], this.buffer[2] = ~this.buffer[2], this.buffer[3] = ~this.buffer[3], this.buffer[0] == 0)
      ++this.buffer[1];
    if (this.buffer[1] == 0)
      ++this.buffer[2];
    if (this.buffer[2] == 0)
      ++this.buffer[3];
    return this;
  }
  times(Z) {
    let J = new z7(new Uint32Array([this.buffer[3], 0])), $ = new z7(new Uint32Array([this.buffer[2], 0])), X = new z7(new Uint32Array([this.buffer[1], 0])), Y = new z7(new Uint32Array([this.buffer[0], 0])), Q = new z7(new Uint32Array([Z.buffer[3], 0])), W = new z7(new Uint32Array([Z.buffer[2], 0])), K = new z7(new Uint32Array([Z.buffer[1], 0])), G = new z7(new Uint32Array([Z.buffer[0], 0])), H = z7.multiply(Y, G);
    this.buffer[0] = H.low();
    let N = new z7(new Uint32Array([H.high(), 0]));
    return H = z7.multiply(X, G), N.plus(H), H = z7.multiply(Y, K), N.plus(H), this.buffer[1] = N.low(), this.buffer[3] = N.lessThan(H) ? 1 : 0, this.buffer[2] = N.high(), new z7(new Uint32Array(this.buffer.buffer, this.buffer.byteOffset + 8, 2)).plus(z7.multiply($, G)).plus(z7.multiply(X, K)).plus(z7.multiply(Y, W)), this.buffer[3] += z7.multiply(J, G).plus(z7.multiply($, K)).plus(z7.multiply(X, W)).plus(z7.multiply(Y, Q)).low(), this;
  }
  plus(Z) {
    let J = new Uint32Array(4);
    if (J[3] = this.buffer[3] + Z.buffer[3] >>> 0, J[2] = this.buffer[2] + Z.buffer[2] >>> 0, J[1] = this.buffer[1] + Z.buffer[1] >>> 0, J[0] = this.buffer[0] + Z.buffer[0] >>> 0, J[0] < this.buffer[0] >>> 0)
      ++J[1];
    if (J[1] < this.buffer[1] >>> 0)
      ++J[2];
    if (J[2] < this.buffer[2] >>> 0)
      ++J[3];
    return this.buffer[3] = J[3], this.buffer[2] = J[2], this.buffer[1] = J[1], this.buffer[0] = J[0], this;
  }
  hex() {
    return `${cD(this.buffer[3])} ${cD(this.buffer[2])} ${cD(this.buffer[1])} ${cD(this.buffer[0])}`;
  }
  static multiply(Z, J) {
    return new N3(new Uint32Array(Z.buffer)).times(J);
  }
  static add(Z, J) {
    return new N3(new Uint32Array(Z.buffer)).plus(J);
  }
  static from(Z, J = new Uint32Array(4)) {
    return N3.fromString(typeof Z === "string" ? Z : Z.toString(), J);
  }
  static fromNumber(Z, J = new Uint32Array(4)) {
    return N3.fromString(Z.toString(), J);
  }
  static fromString(Z, J = new Uint32Array(4)) {
    let $ = Z.startsWith("-"), X = Z.length, Y = new N3(J);
    for (let Q = $ ? 1 : 0;Q < X; ) {
      let W = lD < X - Q ? lD : X - Q, K = new N3(new Uint32Array([Number.parseInt(Z.slice(Q, Q + W), 10), 0, 0, 0])), G = new N3(new Uint32Array([Tl[W], 0, 0, 0]));
      Y.times(G), Y.plus(K), Q += W;
    }
    return $ ? Y.negate() : Y;
  }
  static convertArray(Z) {
    let J = new Uint32Array(Z.length * 4);
    for (let $ = -1, X = Z.length;++$ < X; )
      N3.from(Z[$], new Uint32Array(J.buffer, J.byteOffset + 16 * $, 4));
    return J;
  }
}

// node_modules/apache-arrow/visitor/vectorloader.mjs
class Pv extends g6 {
  constructor(Z, J, $, X) {
    super();
    this.nodesIndex = -1, this.buffersIndex = -1, this.bytes = Z, this.nodes = J, this.buffers = $, this.dictionaries = X;
  }
  visit(Z) {
    return super.visit(Z instanceof SZ ? Z.type : Z);
  }
  visitNull(Z, { length: J } = this.nextFieldNode()) {
    return FZ({ type: Z, length: J });
  }
  visitBool(Z, { length: J, nullCount: $ } = this.nextFieldNode()) {
    return FZ({ type: Z, length: J, nullCount: $, nullBitmap: this.readNullBitmap(Z, $), data: this.readData(Z) });
  }
  visitInt(Z, { length: J, nullCount: $ } = this.nextFieldNode()) {
    return FZ({ type: Z, length: J, nullCount: $, nullBitmap: this.readNullBitmap(Z, $), data: this.readData(Z) });
  }
  visitFloat(Z, { length: J, nullCount: $ } = this.nextFieldNode()) {
    return FZ({ type: Z, length: J, nullCount: $, nullBitmap: this.readNullBitmap(Z, $), data: this.readData(Z) });
  }
  visitUtf8(Z, { length: J, nullCount: $ } = this.nextFieldNode()) {
    return FZ({ type: Z, length: J, nullCount: $, nullBitmap: this.readNullBitmap(Z, $), valueOffsets: this.readOffsets(Z), data: this.readData(Z) });
  }
  visitBinary(Z, { length: J, nullCount: $ } = this.nextFieldNode()) {
    return FZ({ type: Z, length: J, nullCount: $, nullBitmap: this.readNullBitmap(Z, $), valueOffsets: this.readOffsets(Z), data: this.readData(Z) });
  }
  visitFixedSizeBinary(Z, { length: J, nullCount: $ } = this.nextFieldNode()) {
    return FZ({ type: Z, length: J, nullCount: $, nullBitmap: this.readNullBitmap(Z, $), data: this.readData(Z) });
  }
  visitDate(Z, { length: J, nullCount: $ } = this.nextFieldNode()) {
    return FZ({ type: Z, length: J, nullCount: $, nullBitmap: this.readNullBitmap(Z, $), data: this.readData(Z) });
  }
  visitTimestamp(Z, { length: J, nullCount: $ } = this.nextFieldNode()) {
    return FZ({ type: Z, length: J, nullCount: $, nullBitmap: this.readNullBitmap(Z, $), data: this.readData(Z) });
  }
  visitTime(Z, { length: J, nullCount: $ } = this.nextFieldNode()) {
    return FZ({ type: Z, length: J, nullCount: $, nullBitmap: this.readNullBitmap(Z, $), data: this.readData(Z) });
  }
  visitDecimal(Z, { length: J, nullCount: $ } = this.nextFieldNode()) {
    return FZ({ type: Z, length: J, nullCount: $, nullBitmap: this.readNullBitmap(Z, $), data: this.readData(Z) });
  }
  visitList(Z, { length: J, nullCount: $ } = this.nextFieldNode()) {
    return FZ({ type: Z, length: J, nullCount: $, nullBitmap: this.readNullBitmap(Z, $), valueOffsets: this.readOffsets(Z), child: this.visit(Z.children[0]) });
  }
  visitStruct(Z, { length: J, nullCount: $ } = this.nextFieldNode()) {
    return FZ({ type: Z, length: J, nullCount: $, nullBitmap: this.readNullBitmap(Z, $), children: this.visitMany(Z.children) });
  }
  visitUnion(Z) {
    return Z.mode === pJ.Sparse ? this.visitSparseUnion(Z) : this.visitDenseUnion(Z);
  }
  visitDenseUnion(Z, { length: J, nullCount: $ } = this.nextFieldNode()) {
    return FZ({ type: Z, length: J, nullCount: $, nullBitmap: this.readNullBitmap(Z, $), typeIds: this.readTypeIds(Z), valueOffsets: this.readOffsets(Z), children: this.visitMany(Z.children) });
  }
  visitSparseUnion(Z, { length: J, nullCount: $ } = this.nextFieldNode()) {
    return FZ({ type: Z, length: J, nullCount: $, nullBitmap: this.readNullBitmap(Z, $), typeIds: this.readTypeIds(Z), children: this.visitMany(Z.children) });
  }
  visitDictionary(Z, { length: J, nullCount: $ } = this.nextFieldNode()) {
    return FZ({ type: Z, length: J, nullCount: $, nullBitmap: this.readNullBitmap(Z, $), data: this.readData(Z.indices), dictionary: this.readDictionary(Z) });
  }
  visitInterval(Z, { length: J, nullCount: $ } = this.nextFieldNode()) {
    return FZ({ type: Z, length: J, nullCount: $, nullBitmap: this.readNullBitmap(Z, $), data: this.readData(Z) });
  }
  visitFixedSizeList(Z, { length: J, nullCount: $ } = this.nextFieldNode()) {
    return FZ({ type: Z, length: J, nullCount: $, nullBitmap: this.readNullBitmap(Z, $), child: this.visit(Z.children[0]) });
  }
  visitMap(Z, { length: J, nullCount: $ } = this.nextFieldNode()) {
    return FZ({ type: Z, length: J, nullCount: $, nullBitmap: this.readNullBitmap(Z, $), valueOffsets: this.readOffsets(Z), child: this.visit(Z.children[0]) });
  }
  nextFieldNode() {
    return this.nodes[++this.nodesIndex];
  }
  nextBufferRange() {
    return this.buffers[++this.buffersIndex];
  }
  readNullBitmap(Z, J, $ = this.nextBufferRange()) {
    return J > 0 && this.readData(Z, $) || new Uint8Array(0);
  }
  readOffsets(Z, J) {
    return this.readData(Z, J);
  }
  readTypeIds(Z, J) {
    return this.readData(Z, J);
  }
  readData(Z, { length: J, offset: $ } = this.nextBufferRange()) {
    return this.bytes.subarray($, $ + J);
  }
  readDictionary(Z) {
    return this.dictionaries.get(Z.id);
  }
}

class Vl extends Pv {
  constructor(Z, J, $, X) {
    super(new Uint8Array(0), J, $, X);
    this.sources = Z;
  }
  readNullBitmap(Z, J, { offset: $ } = this.nextBufferRange()) {
    return J <= 0 ? new Uint8Array(0) : TO(this.sources[$]);
  }
  readOffsets(Z, { offset: J } = this.nextBufferRange()) {
    return gZ(Uint8Array, gZ(Int32Array, this.sources[J]));
  }
  readTypeIds(Z, { offset: J } = this.nextBufferRange()) {
    return gZ(Uint8Array, gZ(Z.ArrayType, this.sources[J]));
  }
  readData(Z, { offset: J } = this.nextBufferRange()) {
    let { sources: $ } = this;
    if (L6.isTimestamp(Z))
      return gZ(Uint8Array, PQ.convertArray($[J]));
    else if ((L6.isInt(Z) || L6.isTime(Z)) && Z.bitWidth === 64)
      return gZ(Uint8Array, PQ.convertArray($[J]));
    else if (L6.isDate(Z) && Z.unit === JQ.MILLISECOND)
      return gZ(Uint8Array, PQ.convertArray($[J]));
    else if (L6.isDecimal(Z))
      return gZ(Uint8Array, N3.convertArray($[J]));
    else if (L6.isBinary(Z) || L6.isFixedSizeBinary(Z))
      return Mo0($[J]);
    else if (L6.isBool(Z))
      return TO($[J]);
    else if (L6.isUtf8(Z))
      return HL($[J].join(""));
    return gZ(Uint8Array, gZ(Z.ArrayType, $[J].map((X) => +X)));
  }
}
function Mo0(Z) {
  let J = Z.join(""), $ = new Uint8Array(J.length / 2);
  for (let X = 0;X < J.length; X += 2)
    $[X >> 1] = Number.parseInt(J.slice(X, X + 2), 16);
  return $;
}

// node_modules/apache-arrow/builder/binary.mjs
class fT extends AF {
  constructor(Z) {
    super(Z);
    this._values = new VO(new Uint8Array(0));
  }
  get byteLength() {
    let Z = this._pendingLength + this.length * 4;
    return this._offsets && (Z += this._offsets.byteLength), this._values && (Z += this._values.byteLength), this._nulls && (Z += this._nulls.byteLength), Z;
  }
  setValue(Z, J) {
    return super.setValue(Z, YZ(J));
  }
  _flushPending(Z, J) {
    let $ = this._offsets, X = this._values.reserve(J).buffer, Y = 0;
    for (let [Q, W] of Z)
      if (W === void 0)
        $.set(Q, 0);
      else {
        let K = W.length;
        X.set(W, Y), $.set(Q, K), Y += K;
      }
  }
}

// node_modules/apache-arrow/builder/bool.mjs
class Il extends AJ {
  constructor(Z) {
    super(Z);
    this._values = new TT;
  }
  setValue(Z, J) {
    this._values.set(Z, +J);
  }
}

// node_modules/apache-arrow/builder/date.mjs
class nD extends XQ {
}
nD.prototype._setValue = Ul;

class Cv extends nD {
}
Cv.prototype._setValue = Jv;

class kv extends nD {
}
kv.prototype._setValue = $v;

// node_modules/apache-arrow/builder/decimal.mjs
class vv extends XQ {
}
vv.prototype._setValue = El;

// node_modules/apache-arrow/builder/dictionary.mjs
class Pl extends AJ {
  constructor({ type: Z, nullValues: J, dictionaryHashFunction: $ }) {
    super({ type: new Z3(Z.dictionary, Z.indices, Z.id, Z.isOrdered) });
    if (this._nulls = null, this._dictionaryOffset = 0, this._keysToIndices = Object.create(null), this.indices = CO({ type: this.type.indices, nullValues: J }), this.dictionary = CO({ type: this.type.dictionary, nullValues: null }), typeof $ === "function")
      this.valueToKey = $;
  }
  get values() {
    return this.indices.values;
  }
  get nullCount() {
    return this.indices.nullCount;
  }
  get nullBitmap() {
    return this.indices.nullBitmap;
  }
  get byteLength() {
    return this.indices.byteLength + this.dictionary.byteLength;
  }
  get reservedLength() {
    return this.indices.reservedLength + this.dictionary.reservedLength;
  }
  get reservedByteLength() {
    return this.indices.reservedByteLength + this.dictionary.reservedByteLength;
  }
  isValid(Z) {
    return this.indices.isValid(Z);
  }
  setValid(Z, J) {
    let $ = this.indices;
    return J = $.setValid(Z, J), this.length = $.length, J;
  }
  setValue(Z, J) {
    let $ = this._keysToIndices, X = this.valueToKey(J), Y = $[X];
    if (Y === void 0)
      $[X] = Y = this._dictionaryOffset + this.dictionary.append(J).length - 1;
    return this.indices.setValue(Z, Y);
  }
  flush() {
    let Z = this.type, J = this._dictionary, $ = this.dictionary.toVector(), X = this.indices.flush().clone(Z);
    return X.dictionary = J ? J.concat($) : $, this.finished || (this._dictionaryOffset += $.length), this._dictionary = X.dictionary, this.clear(), X;
  }
  finish() {
    return this.indices.finish(), this.dictionary.finish(), this._dictionaryOffset = 0, this._keysToIndices = Object.create(null), super.finish();
  }
  clear() {
    return this.indices.clear(), this.dictionary.clear(), super.clear();
  }
  valueToKey(Z) {
    return typeof Z === "string" ? Z : `${Z}`;
  }
}

// node_modules/apache-arrow/builder/fixedsizebinary.mjs
class Sv extends XQ {
}
Sv.prototype._setValue = Fl;

// node_modules/apache-arrow/builder/fixedsizelist.mjs
class Cl extends AJ {
  setValue(Z, J) {
    let [$] = this.children, X = Z * this.stride;
    for (let Y = -1, Q = J.length;++Y < Q; )
      $.set(X + Y, J[Y]);
  }
  addChild(Z, J = "0") {
    if (this.numChildren > 0)
      throw new Error("FixedSizeListBuilder can only have one child.");
    let $ = this.children.push(Z);
    return this.type = new qN(this.type.listSize, new SZ(J, Z.type, !0)), $;
  }
}

// node_modules/apache-arrow/builder/float.mjs
class iD extends XQ {
  setValue(Z, J) {
    this._values.set(Z, J);
  }
}

class kl extends iD {
  setValue(Z, J) {
    super.setValue(Z, MT(J));
  }
}

class vl extends iD {
}

class Sl extends iD {
}

// node_modules/apache-arrow/builder/interval.mjs
class oD extends XQ {
}
oD.prototype._setValue = Ol;

class fv extends oD {
}
fv.prototype._setValue = qv;

class hv extends oD {
}
hv.prototype._setValue = Fv;

// node_modules/apache-arrow/builder/int.mjs
class iG extends XQ {
  setValue(Z, J) {
    this._values.set(Z, J);
  }
}

class fl extends iG {
}

class hl extends iG {
}

class bl extends iG {
}

class xl extends iG {
}

class yl extends iG {
}

class gl extends iG {
}

class ml extends iG {
}

class dl extends iG {
}

// node_modules/apache-arrow/builder/list.mjs
class pl extends AF {
  constructor(Z) {
    super(Z);
    this._offsets = new _T;
  }
  addChild(Z, J = "0") {
    if (this.numChildren > 0)
      throw new Error("ListBuilder can only have one child.");
    return this.children[this.numChildren] = Z, this.type = new HN(new SZ(J, Z.type, !0)), this.numChildren - 1;
  }
  _flushPending(Z) {
    let J = this._offsets, [$] = this.children;
    for (let [X, Y] of Z)
      if (typeof Y === "undefined")
        J.set(X, 0);
      else {
        let Q = Y.length, W = J.set(X, Q).buffer[X];
        for (let K = -1;++K < Q; )
          $.set(W + K, Y[K]);
      }
  }
}

// node_modules/apache-arrow/builder/map.mjs
class ul extends AF {
  set(Z, J) {
    return super.set(Z, J);
  }
  setValue(Z, J) {
    let $ = J instanceof Map ? J : new Map(Object.entries(J)), X = this._pending || (this._pending = /* @__PURE__ */ new Map), Y = X.get(Z);
    Y && (this._pendingLength -= Y.size), this._pendingLength += $.size, X.set(Z, $);
  }
  addChild(Z, J = `${this.numChildren}`) {
    if (this.numChildren > 0)
      throw new Error("ListBuilder can only have one child.");
    return this.children[this.numChildren] = Z, this.type = new FN(new SZ(J, Z.type, !0), this.type.keysSorted), this.numChildren - 1;
  }
  _flushPending(Z) {
    let J = this._offsets, [$] = this.children;
    for (let [X, Y] of Z)
      if (Y === void 0)
        J.set(X, 0);
      else {
        let { [X]: Q, [X + 1]: W } = J.set(X, Y.size).buffer;
        for (let K of Y.entries())
          if ($.set(Q, K), ++Q >= W)
            break;
      }
  }
}

// node_modules/apache-arrow/builder/null.mjs
class cl extends AJ {
  setValue(Z, J) {}
  setValid(Z, J) {
    return this.length = Math.max(Z + 1, this.length), J;
  }
}

// node_modules/apache-arrow/builder/struct.mjs
class ll extends AJ {
  setValue(Z, J) {
    let { children: $, type: X } = this;
    switch (Array.isArray(J) || J.constructor) {
      case !0:
        return X.children.forEach((Y, Q) => $[Q].set(Z, J[Q]));
      case Map:
        return X.children.forEach((Y, Q) => $[Q].set(Z, J.get(Y.name)));
      default:
        return X.children.forEach((Y, Q) => $[Q].set(Z, J[Y.name]));
    }
  }
  setValid(Z, J) {
    if (!super.setValid(Z, J))
      this.children.forEach(($) => $.setValid(Z, J));
    return J;
  }
  addChild(Z, J = `${this.numChildren}`) {
    let $ = this.children.push(Z);
    return this.type = new qJ([...this.type.children, new SZ(J, Z.type, !0)]), $;
  }
}

// node_modules/apache-arrow/builder/timestamp.mjs
class fL extends XQ {
}
fL.prototype._setValue = Ll;

class bv extends fL {
}
bv.prototype._setValue = Xv;

class xv extends fL {
}
xv.prototype._setValue = Yv;

class yv extends fL {
}
yv.prototype._setValue = Qv;

class gv extends fL {
}
gv.prototype._setValue = Wv;

// node_modules/apache-arrow/builder/time.mjs
class hL extends XQ {
}
hL.prototype._setValue = Rl;

class mv extends hL {
}
mv.prototype._setValue = Kv;

class dv extends hL {
}
dv.prototype._setValue = Gv;

class pv extends hL {
}
pv.prototype._setValue = Hv;

class uv extends hL {
}
uv.prototype._setValue = Nv;

// node_modules/apache-arrow/builder/union.mjs
class hT extends AJ {
  constructor(Z) {
    super(Z);
    if (this._typeIds = new BL(new Int8Array(0), 1), typeof Z.valueToChildTypeId === "function")
      this._valueToChildTypeId = Z.valueToChildTypeId;
  }
  get typeIdToChildIndex() {
    return this.type.typeIdToChildIndex;
  }
  append(Z, J) {
    return this.set(this.length, Z, J);
  }
  set(Z, J, $) {
    if ($ === void 0)
      $ = this._valueToChildTypeId(this, J, Z);
    if (this.setValid(Z, this.isValid(J)))
      this.setValue(Z, J, $);
    return this;
  }
  setValue(Z, J, $) {
    this._typeIds.set(Z, $);
    let X = this.type.typeIdToChildIndex[$], Y = this.children[X];
    Y === null || Y === void 0 || Y.set(Z, J);
  }
  addChild(Z, J = `${this.children.length}`) {
    let $ = this.children.push(Z), { type: { children: X, mode: Y, typeIds: Q } } = this, W = [...X, new SZ(J, Z.type)];
    return this.type = new NN(Y, [...Q, $], W), $;
  }
  _valueToChildTypeId(Z, J, $) {
    throw new Error("Cannot map UnionBuilder value to child typeId. Pass the `childTypeId` as the second argument to unionBuilder.append(), or supply a `valueToChildTypeId` function as part of the UnionBuilder constructor options.");
  }
}

class nl extends hT {
}

class il extends hT {
  constructor(Z) {
    super(Z);
    this._offsets = new BL(new Int32Array(0));
  }
  setValue(Z, J, $) {
    let X = this._typeIds.set(Z, $).buffer[Z], Y = this.getChildAt(this.type.typeIdToChildIndex[X]), Q = this._offsets.set(Z, Y.length).buffer[Z];
    Y === null || Y === void 0 || Y.set(Q, J);
  }
}

// node_modules/apache-arrow/builder/utf8.mjs
class cv extends AF {
  constructor(Z) {
    super(Z);
    this._values = new VO(new Uint8Array(0));
  }
  get byteLength() {
    let Z = this._pendingLength + this.length * 4;
    return this._offsets && (Z += this._offsets.byteLength), this._values && (Z += this._values.byteLength), this._nulls && (Z += this._nulls.byteLength), Z;
  }
  setValue(Z, J) {
    return super.setValue(Z, HL(J));
  }
  _flushPending(Z, J) {}
}
cv.prototype._flushPending = fT.prototype._flushPending;

// node_modules/apache-arrow/visitor/builderctor.mjs
class mQ0 extends g6 {
  visitNull() {
    return cl;
  }
  visitBool() {
    return Il;
  }
  visitInt() {
    return iG;
  }
  visitInt8() {
    return fl;
  }
  visitInt16() {
    return hl;
  }
  visitInt32() {
    return bl;
  }
  visitInt64() {
    return xl;
  }
  visitUint8() {
    return yl;
  }
  visitUint16() {
    return gl;
  }
  visitUint32() {
    return ml;
  }
  visitUint64() {
    return dl;
  }
  visitFloat() {
    return iD;
  }
  visitFloat16() {
    return kl;
  }
  visitFloat32() {
    return vl;
  }
  visitFloat64() {
    return Sl;
  }
  visitUtf8() {
    return cv;
  }
  visitBinary() {
    return fT;
  }
  visitFixedSizeBinary() {
    return Sv;
  }
  visitDate() {
    return nD;
  }
  visitDateDay() {
    return Cv;
  }
  visitDateMillisecond() {
    return kv;
  }
  visitTimestamp() {
    return fL;
  }
  visitTimestampSecond() {
    return bv;
  }
  visitTimestampMillisecond() {
    return xv;
  }
  visitTimestampMicrosecond() {
    return yv;
  }
  visitTimestampNanosecond() {
    return gv;
  }
  visitTime() {
    return hL;
  }
  visitTimeSecond() {
    return mv;
  }
  visitTimeMillisecond() {
    return dv;
  }
  visitTimeMicrosecond() {
    return pv;
  }
  visitTimeNanosecond() {
    return uv;
  }
  visitDecimal() {
    return vv;
  }
  visitList() {
    return pl;
  }
  visitStruct() {
    return ll;
  }
  visitUnion() {
    return hT;
  }
  visitDenseUnion() {
    return il;
  }
  visitSparseUnion() {
    return nl;
  }
  visitDictionary() {
    return Pl;
  }
  visitInterval() {
    return oD;
  }
  visitIntervalDayTime() {
    return fv;
  }
  visitIntervalYearMonth() {
    return hv;
  }
  visitFixedSizeList() {
    return Cl;
  }
  visitMap() {
    return ul;
  }
}
var dQ0 = new mQ0;

// node_modules/apache-arrow/visitor/typecomparator.mjs
class GZ extends g6 {
  compareSchemas(Z, J) {
    return Z === J || J instanceof Z.constructor && this.compareManyFields(Z.fields, J.fields);
  }
  compareManyFields(Z, J) {
    return Z === J || Array.isArray(Z) && Array.isArray(J) && Z.length === J.length && Z.every(($, X) => this.compareFields($, J[X]));
  }
  compareFields(Z, J) {
    return Z === J || J instanceof Z.constructor && Z.name === J.name && Z.nullable === J.nullable && this.visit(Z.type, J.type);
  }
}
function q5(Z, J) {
  return J instanceof Z.constructor;
}
function bT(Z, J) {
  return Z === J || q5(Z, J);
}
function TF(Z, J) {
  return Z === J || q5(Z, J) && Z.bitWidth === J.bitWidth && Z.isSigned === J.isSigned;
}
function lv(Z, J) {
  return Z === J || q5(Z, J) && Z.precision === J.precision;
}
function Ao0(Z, J) {
  return Z === J || q5(Z, J) && Z.byteWidth === J.byteWidth;
}
function ol(Z, J) {
  return Z === J || q5(Z, J) && Z.unit === J.unit;
}
function xT(Z, J) {
  return Z === J || q5(Z, J) && Z.unit === J.unit && Z.timezone === J.timezone;
}
function yT(Z, J) {
  return Z === J || q5(Z, J) && Z.unit === J.unit && Z.bitWidth === J.bitWidth;
}
function Bo0(Z, J) {
  return Z === J || q5(Z, J) && Z.children.length === J.children.length && LN.compareManyFields(Z.children, J.children);
}
function wo0(Z, J) {
  return Z === J || q5(Z, J) && Z.children.length === J.children.length && LN.compareManyFields(Z.children, J.children);
}
function sl(Z, J) {
  return Z === J || q5(Z, J) && Z.mode === J.mode && Z.typeIds.every(($, X) => $ === J.typeIds[X]) && LN.compareManyFields(Z.children, J.children);
}
function jo0(Z, J) {
  return Z === J || q5(Z, J) && Z.id === J.id && Z.isOrdered === J.isOrdered && LN.visit(Z.indices, J.indices) && LN.visit(Z.dictionary, J.dictionary);
}
function al(Z, J) {
  return Z === J || q5(Z, J) && Z.unit === J.unit;
}
function To0(Z, J) {
  return Z === J || q5(Z, J) && Z.listSize === J.listSize && Z.children.length === J.children.length && LN.compareManyFields(Z.children, J.children);
}
function _o0(Z, J) {
  return Z === J || q5(Z, J) && Z.keysSorted === J.keysSorted && Z.children.length === J.children.length && LN.compareManyFields(Z.children, J.children);
}
GZ.prototype.visitNull = bT;
GZ.prototype.visitBool = bT;
GZ.prototype.visitInt = TF;
GZ.prototype.visitInt8 = TF;
GZ.prototype.visitInt16 = TF;
GZ.prototype.visitInt32 = TF;
GZ.prototype.visitInt64 = TF;
GZ.prototype.visitUint8 = TF;
GZ.prototype.visitUint16 = TF;
GZ.prototype.visitUint32 = TF;
GZ.prototype.visitUint64 = TF;
GZ.prototype.visitFloat = lv;
GZ.prototype.visitFloat16 = lv;
GZ.prototype.visitFloat32 = lv;
GZ.prototype.visitFloat64 = lv;
GZ.prototype.visitUtf8 = bT;
GZ.prototype.visitBinary = bT;
GZ.prototype.visitFixedSizeBinary = Ao0;
GZ.prototype.visitDate = ol;
GZ.prototype.visitDateDay = ol;
GZ.prototype.visitDateMillisecond = ol;
GZ.prototype.visitTimestamp = xT;
GZ.prototype.visitTimestampSecond = xT;
GZ.prototype.visitTimestampMillisecond = xT;
GZ.prototype.visitTimestampMicrosecond = xT;
GZ.prototype.visitTimestampNanosecond = xT;
GZ.prototype.visitTime = yT;
GZ.prototype.visitTimeSecond = yT;
GZ.prototype.visitTimeMillisecond = yT;
GZ.prototype.visitTimeMicrosecond = yT;
GZ.prototype.visitTimeNanosecond = yT;
GZ.prototype.visitDecimal = bT;
GZ.prototype.visitList = Bo0;
GZ.prototype.visitStruct = wo0;
GZ.prototype.visitUnion = sl;
GZ.prototype.visitDenseUnion = sl;
GZ.prototype.visitSparseUnion = sl;
GZ.prototype.visitDictionary = jo0;
GZ.prototype.visitInterval = al;
GZ.prototype.visitIntervalDayTime = al;
GZ.prototype.visitIntervalYearMonth = al;
GZ.prototype.visitFixedSizeList = To0;
GZ.prototype.visitMap = _o0;
var LN = new GZ;
function kO(Z, J) {
  return LN.compareSchemas(Z, J);
}
function pQ0(Z, J) {
  return LN.compareFields(Z, J);
}
function uQ0(Z, J) {
  return LN.visit(Z, J);
}

// node_modules/apache-arrow/factories.mjs
function CO(Z) {
  let J = Z.type, $ = new (dQ0.getVisitFn(J)())(Z);
  if (J.children && J.children.length > 0) {
    let X = Z.children || [], Y = { nullValues: Z.nullValues }, Q = Array.isArray(X) ? (W, K) => X[K] || Y : ({ name: W }) => X[W] || Y;
    for (let [W, K] of J.children.entries()) {
      let { type: G } = K, H = Q(K, W);
      $.children.push(CO(Object.assign(Object.assign({}, H), { type: G })));
    }
  }
  return $;
}

// node_modules/apache-arrow/util/recordbatch.mjs
function nv(Z, J) {
  return Vo0(Z, J.map(($) => $.data.concat()));
}
function Vo0(Z, J) {
  let $ = [...Z.fields], X = [], Y = { numBatches: J.reduce((q, U) => Math.max(q, U.length), 0) }, Q = 0, W = 0, K = -1, G = J.length, H, N = [];
  while (Y.numBatches-- > 0) {
    for (W = Number.POSITIVE_INFINITY, K = -1;++K < G; )
      N[K] = H = J[K].shift(), W = Math.min(W, H ? H.length : W);
    if (Number.isFinite(W)) {
      if (N = Io0($, W, N, J, Y), W > 0)
        X[Q++] = FZ({
          type: new qJ($),
          length: W,
          nullCount: 0,
          children: N.slice()
        });
    }
  }
  return [
    Z = Z.assign($),
    X.map((q) => new UJ(Z, q))
  ];
}
function Io0(Z, J, $, X, Y) {
  var Q;
  let W = (J + 63 & -64) >> 3;
  for (let K = -1, G = X.length;++K < G; ) {
    let H = $[K], N = H === null || H === void 0 ? void 0 : H.length;
    if (N >= J)
      if (N === J)
        $[K] = H;
      else
        $[K] = H.slice(0, J), Y.numBatches = Math.max(Y.numBatches, X[K].unshift(H.slice(J, N - J)));
    else {
      let q = Z[K];
      Z[K] = q.clone({ nullable: !0 }), $[K] = (Q = H === null || H === void 0 ? void 0 : H._changeLengthAndBackfillNullBitmap(J)) !== null && Q !== void 0 ? Q : FZ({
        type: q.type,
        length: J,
        nullCount: J,
        nullBitmap: new Uint8Array(W)
      });
    }
  }
  return $;
}

// node_modules/apache-arrow/table.mjs
var cQ0;

class hX {
  constructor(...Z) {
    var J, $;
    if (Z.length === 0)
      return this.batches = [], this.schema = new U9([]), this._offsets = [0], this;
    let X, Y;
    if (Z[0] instanceof U9)
      X = Z.shift();
    if (Z[Z.length - 1] instanceof Uint32Array)
      Y = Z.pop();
    let Q = (K) => {
      if (K) {
        if (K instanceof UJ)
          return [K];
        else if (K instanceof hX)
          return K.batches;
        else if (K instanceof O7) {
          if (K.type instanceof qJ)
            return [new UJ(new U9(K.type.children), K)];
        } else if (Array.isArray(K))
          return K.flatMap((G) => Q(G));
        else if (typeof K[Symbol.iterator] === "function")
          return [...K].flatMap((G) => Q(G));
        else if (typeof K === "object") {
          let G = Object.keys(K), H = G.map((U) => new wZ([K[U]])), N = new U9(G.map((U, F) => new SZ(String(U), H[F].type))), [, q] = nv(N, H);
          return q.length === 0 ? [new UJ(K)] : q;
        }
      }
      return [];
    }, W = Z.flatMap((K) => Q(K));
    if (X = ($ = X !== null && X !== void 0 ? X : (J = W[0]) === null || J === void 0 ? void 0 : J.schema) !== null && $ !== void 0 ? $ : new U9([]), !(X instanceof U9))
      throw new TypeError("Table constructor expects a [Schema, RecordBatch[]] pair.");
    for (let K of W) {
      if (!(K instanceof UJ))
        throw new TypeError("Table constructor expects a [Schema, RecordBatch[]] pair.");
      if (!kO(X, K.schema))
        throw new TypeError("Table and inner RecordBatch schemas must be equivalent.");
    }
    this.schema = X, this.batches = W, this._offsets = Y !== null && Y !== void 0 ? Y : zv(this.data);
  }
  get data() {
    return this.batches.map(({ data: Z }) => Z);
  }
  get numCols() {
    return this.schema.fields.length;
  }
  get numRows() {
    return this.data.reduce((Z, J) => Z + J.length, 0);
  }
  get nullCount() {
    if (this._nullCount === -1)
      this._nullCount = Ov(this.data);
    return this._nullCount;
  }
  isValid(Z) {
    return !1;
  }
  get(Z) {
    return null;
  }
  set(Z, J) {
    return;
  }
  indexOf(Z, J) {
    return -1;
  }
  getByteLength(Z) {
    return 0;
  }
  [Symbol.iterator]() {
    if (this.batches.length > 0)
      return mD.visit(new wZ(this.data));
    return new Array(0)[Symbol.iterator]();
  }
  toArray() {
    return [...this];
  }
  toString() {
    return `[
  ${this.toArray().join(`,
  `)}
]`;
  }
  concat(...Z) {
    let J = this.schema, $ = this.data.concat(Z.flatMap(({ data: X }) => X));
    return new hX(J, $.map((X) => new UJ(J, X)));
  }
  slice(Z, J) {
    let $ = this.schema;
    [Z, J] = AT({ length: this.numRows }, Z, J);
    let X = Dv(this.data, this._offsets, Z, J);
    return new hX($, X.map((Y) => new UJ($, Y)));
  }
  getChild(Z) {
    return this.getChildAt(this.schema.fields.findIndex((J) => J.name === Z));
  }
  getChildAt(Z) {
    if (Z > -1 && Z < this.schema.fields.length) {
      let J = this.data.map(($) => $.children[Z]);
      if (J.length === 0) {
        let { type: $ } = this.schema.fields[Z], X = FZ({ type: $, length: 0, nullCount: 0 });
        J.push(X._changeLengthAndBackfillNullBitmap(this.numRows));
      }
      return new wZ(J);
    }
    return null;
  }
  setChild(Z, J) {
    var $;
    return this.setChildAt(($ = this.schema.fields) === null || $ === void 0 ? void 0 : $.findIndex((X) => X.name === Z), J);
  }
  setChildAt(Z, J) {
    let $ = this.schema, X = [...this.batches];
    if (Z > -1 && Z < this.numCols) {
      if (!J)
        J = new wZ([FZ({ type: new K5, length: this.numRows })]);
      let Y = $.fields.slice(), Q = Y[Z].clone({ type: J.type }), W = this.schema.fields.map((K, G) => this.getChildAt(G));
      [Y[Z], W[Z]] = [Q, J], [$, X] = nv($, W);
    }
    return new hX($, X);
  }
  select(Z) {
    let J = this.schema.fields.reduce(($, X, Y) => $.set(X.name, Y), /* @__PURE__ */ new Map);
    return this.selectAt(Z.map(($) => J.get($)).filter(($) => $ > -1));
  }
  selectAt(Z) {
    let J = this.schema.selectAt(Z), $ = this.batches.map((X) => X.selectAt(Z));
    return new hX(J, $);
  }
  assign(Z) {
    let J = this.schema.fields, [$, X] = Z.schema.fields.reduce((W, K, G) => {
      let [H, N] = W, q = J.findIndex((U) => U.name === K.name);
      return ~q ? N[q] = G : H.push(G), W;
    }, [[], []]), Y = this.schema.assign(Z.schema), Q = [
      ...J.map((W, K) => [K, X[K]]).map(([W, K]) => K === void 0 ? this.getChildAt(W) : Z.getChildAt(K)),
      ...$.map((W) => Z.getChildAt(W))
    ].filter(Boolean);
    return new hX(...nv(Y, Q));
  }
}
cQ0 = Symbol.toStringTag;
hX[cQ0] = ((Z) => {
  return Z.schema = null, Z.batches = [], Z._offsets = new Uint32Array([0]), Z._nullCount = -1, Z[Symbol.isConcatSpreadable] = !0, Z.isValid = AL(jT), Z.get = AL(n$.getVisitFn(j1.Struct)), Z.set = Mv($Q.getVisitFn(j1.Struct)), Z.indexOf = Av(_O.getVisitFn(j1.Struct)), Z.getByteLength = AL(WK.getVisitFn(j1.Struct)), "Table";
})(hX.prototype);

// node_modules/apache-arrow/recordbatch.mjs
var nQ0;

class UJ {
  constructor(...Z) {
    switch (Z.length) {
      case 2: {
        if ([this.schema] = Z, !(this.schema instanceof U9))
          throw new TypeError("RecordBatch constructor expects a [Schema, Data] pair.");
        if ([
          ,
          this.data = FZ({
            nullCount: 0,
            type: new qJ(this.schema.fields),
            children: this.schema.fields.map((J) => FZ({ type: J.type, nullCount: 0 }))
          })
        ] = Z, !(this.data instanceof O7))
          throw new TypeError("RecordBatch constructor expects a [Schema, Data] pair.");
        [this.schema, this.data] = lQ0(this.schema, this.data.children);
        break;
      }
      case 1: {
        let [J] = Z, { fields: $, children: X, length: Y } = Object.keys(J).reduce((K, G, H) => {
          return K.children[H] = J[G], K.length = Math.max(K.length, J[G].length), K.fields[H] = SZ.new({ name: G, type: J[G].type, nullable: !0 }), K;
        }, {
          length: 0,
          fields: new Array,
          children: new Array
        }), Q = new U9($), W = FZ({ type: new qJ($), length: Y, children: X, nullCount: 0 });
        [this.schema, this.data] = lQ0(Q, W.children, Y);
        break;
      }
      default:
        throw new TypeError("RecordBatch constructor expects an Object mapping names to child Data, or a [Schema, Data] pair.");
    }
  }
  get dictionaries() {
    return this._dictionaries || (this._dictionaries = iQ0(this.schema.fields, this.data.children));
  }
  get numCols() {
    return this.schema.fields.length;
  }
  get numRows() {
    return this.data.length;
  }
  get nullCount() {
    return this.data.nullCount;
  }
  isValid(Z) {
    return this.data.getValid(Z);
  }
  get(Z) {
    return n$.visit(this.data, Z);
  }
  set(Z, J) {
    return $Q.visit(this.data, Z, J);
  }
  indexOf(Z, J) {
    return _O.visit(this.data, Z, J);
  }
  getByteLength(Z) {
    return WK.visit(this.data, Z);
  }
  [Symbol.iterator]() {
    return mD.visit(new wZ([this.data]));
  }
  toArray() {
    return [...this];
  }
  concat(...Z) {
    return new hX(this.schema, [this, ...Z]);
  }
  slice(Z, J) {
    let [$] = new wZ([this.data]).slice(Z, J).data;
    return new UJ(this.schema, $);
  }
  getChild(Z) {
    var J;
    return this.getChildAt((J = this.schema.fields) === null || J === void 0 ? void 0 : J.findIndex(($) => $.name === Z));
  }
  getChildAt(Z) {
    if (Z > -1 && Z < this.schema.fields.length)
      return new wZ([this.data.children[Z]]);
    return null;
  }
  setChild(Z, J) {
    var $;
    return this.setChildAt(($ = this.schema.fields) === null || $ === void 0 ? void 0 : $.findIndex((X) => X.name === Z), J);
  }
  setChildAt(Z, J) {
    let $ = this.schema, X = this.data;
    if (Z > -1 && Z < this.numCols) {
      if (!J)
        J = new wZ([FZ({ type: new K5, length: this.numRows })]);
      let Y = $.fields.slice(), Q = X.children.slice(), W = Y[Z].clone({ type: J.type });
      [Y[Z], Q[Z]] = [W, J.data[0]], $ = new U9(Y, new Map(this.schema.metadata)), X = FZ({ type: new qJ(Y), children: Q });
    }
    return new UJ($, X);
  }
  select(Z) {
    let J = this.schema.select(Z), $ = new qJ(J.fields), X = [];
    for (let Y of Z) {
      let Q = this.schema.fields.findIndex((W) => W.name === Y);
      if (~Q)
        X[Q] = this.data.children[Q];
    }
    return new UJ(J, FZ({ type: $, length: this.numRows, children: X }));
  }
  selectAt(Z) {
    let J = this.schema.selectAt(Z), $ = Z.map((Y) => this.data.children[Y]).filter(Boolean), X = FZ({ type: new qJ(J.fields), length: this.numRows, children: $ });
    return new UJ(J, X);
  }
}
nQ0 = Symbol.toStringTag;
UJ[nQ0] = ((Z) => {
  return Z._nullCount = -1, Z[Symbol.isConcatSpreadable] = !0, "RecordBatch";
})(UJ.prototype);
function lQ0(Z, J, $ = J.reduce((X, Y) => Math.max(X, Y.length), 0)) {
  var X;
  let Y = [...Z.fields], Q = [...J], W = ($ + 63 & -64) >> 3;
  for (let [K, G] of Z.fields.entries()) {
    let H = J[K];
    if (!H || H.length !== $)
      Y[K] = G.clone({ nullable: !0 }), Q[K] = (X = H === null || H === void 0 ? void 0 : H._changeLengthAndBackfillNullBitmap($)) !== null && X !== void 0 ? X : FZ({
        type: G.type,
        length: $,
        nullCount: $,
        nullBitmap: new Uint8Array(W)
      });
  }
  return [
    Z.assign(Y),
    FZ({ type: new qJ(Y), length: $, children: Q })
  ];
}
function iQ0(Z, J, $ = /* @__PURE__ */ new Map) {
  for (let X = -1, Y = Z.length;++X < Y; ) {
    let W = Z[X].type, K = J[X];
    if (L6.isDictionary(W)) {
      if (!$.has(W.id)) {
        if (K.dictionary)
          $.set(W.id, K.dictionary);
      } else if ($.get(W.id) !== K.dictionary)
        throw new Error("Cannot create Schema containing two different dictionaries with the same Id");
    }
    if (W.children && W.children.length > 0)
      iQ0(W.children, K.children, $);
  }
  return $;
}

class sD extends UJ {
  constructor(Z) {
    let J = Z.fields.map((X) => FZ({ type: X.type })), $ = FZ({ type: new qJ(Z.fields), nullCount: 0, children: J });
    super(Z, $);
  }
}

// node_modules/apache-arrow/fb/body-compression-method.mjs
var gT;
(function(Z) {
  Z[Z.BUFFER = 0] = "BUFFER";
})(gT || (gT = {}));

// node_modules/apache-arrow/fb/compression-type.mjs
var mT;
(function(Z) {
  Z[Z.LZ4_FRAME = 0] = "LZ4_FRAME", Z[Z.ZSTD = 1] = "ZSTD";
})(mT || (mT = {}));

// node_modules/apache-arrow/fb/body-compression.mjs
class _F {
  constructor() {
    this.bb = null, this.bb_pos = 0;
  }
  __init(Z, J) {
    return this.bb_pos = Z, this.bb = J, this;
  }
  static getRootAsBodyCompression(Z, J) {
    return (J || new _F).__init(Z.readInt32(Z.position()) + Z.position(), Z);
  }
  static getSizePrefixedRootAsBodyCompression(Z, J) {
    return Z.setPosition(Z.position() + K6), (J || new _F).__init(Z.readInt32(Z.position()) + Z.position(), Z);
  }
  codec() {
    let Z = this.bb.__offset(this.bb_pos, 4);
    return Z ? this.bb.readInt8(this.bb_pos + Z) : mT.LZ4_FRAME;
  }
  method() {
    let Z = this.bb.__offset(this.bb_pos, 6);
    return Z ? this.bb.readInt8(this.bb_pos + Z) : gT.BUFFER;
  }
  static startBodyCompression(Z) {
    Z.startObject(2);
  }
  static addCodec(Z, J) {
    Z.addFieldInt8(0, J, mT.LZ4_FRAME);
  }
  static addMethod(Z, J) {
    Z.addFieldInt8(1, J, gT.BUFFER);
  }
  static endBodyCompression(Z) {
    return Z.endObject();
  }
  static createBodyCompression(Z, J, $) {
    return _F.startBodyCompression(Z), _F.addCodec(Z, J), _F.addMethod(Z, $), _F.endBodyCompression(Z);
  }
}

// node_modules/apache-arrow/fb/buffer.mjs
class dT {
  constructor() {
    this.bb = null, this.bb_pos = 0;
  }
  __init(Z, J) {
    return this.bb_pos = Z, this.bb = J, this;
  }
  offset() {
    return this.bb.readInt64(this.bb_pos);
  }
  length() {
    return this.bb.readInt64(this.bb_pos + 8);
  }
  static sizeOf() {
    return 16;
  }
  static createBuffer(Z, J, $) {
    return Z.prep(8, 16), Z.writeInt64($), Z.writeInt64(J), Z.offset();
  }
}

// node_modules/apache-arrow/fb/field-node.mjs
class pT {
  constructor() {
    this.bb = null, this.bb_pos = 0;
  }
  __init(Z, J) {
    return this.bb_pos = Z, this.bb = J, this;
  }
  length() {
    return this.bb.readInt64(this.bb_pos);
  }
  nullCount() {
    return this.bb.readInt64(this.bb_pos + 8);
  }
  static sizeOf() {
    return 16;
  }
  static createFieldNode(Z, J, $) {
    return Z.prep(8, 16), Z.writeInt64($), Z.writeInt64(J), Z.offset();
  }
}

// node_modules/apache-arrow/fb/record-batch.mjs
class F5 {
  constructor() {
    this.bb = null, this.bb_pos = 0;
  }
  __init(Z, J) {
    return this.bb_pos = Z, this.bb = J, this;
  }
  static getRootAsRecordBatch(Z, J) {
    return (J || new F5).__init(Z.readInt32(Z.position()) + Z.position(), Z);
  }
  static getSizePrefixedRootAsRecordBatch(Z, J) {
    return Z.setPosition(Z.position() + K6), (J || new F5).__init(Z.readInt32(Z.position()) + Z.position(), Z);
  }
  length() {
    let Z = this.bb.__offset(this.bb_pos, 4);
    return Z ? this.bb.readInt64(this.bb_pos + Z) : this.bb.createLong(0, 0);
  }
  nodes(Z, J) {
    let $ = this.bb.__offset(this.bb_pos, 6);
    return $ ? (J || new pT).__init(this.bb.__vector(this.bb_pos + $) + Z * 16, this.bb) : null;
  }
  nodesLength() {
    let Z = this.bb.__offset(this.bb_pos, 6);
    return Z ? this.bb.__vector_len(this.bb_pos + Z) : 0;
  }
  buffers(Z, J) {
    let $ = this.bb.__offset(this.bb_pos, 8);
    return $ ? (J || new dT).__init(this.bb.__vector(this.bb_pos + $) + Z * 16, this.bb) : null;
  }
  buffersLength() {
    let Z = this.bb.__offset(this.bb_pos, 8);
    return Z ? this.bb.__vector_len(this.bb_pos + Z) : 0;
  }
  compression(Z) {
    let J = this.bb.__offset(this.bb_pos, 10);
    return J ? (Z || new _F).__init(this.bb.__indirect(this.bb_pos + J), this.bb) : null;
  }
  static startRecordBatch(Z) {
    Z.startObject(4);
  }
  static addLength(Z, J) {
    Z.addFieldInt64(0, J, Z.createLong(0, 0));
  }
  static addNodes(Z, J) {
    Z.addFieldOffset(1, J, 0);
  }
  static startNodesVector(Z, J) {
    Z.startVector(16, J, 8);
  }
  static addBuffers(Z, J) {
    Z.addFieldOffset(2, J, 0);
  }
  static startBuffersVector(Z, J) {
    Z.startVector(16, J, 8);
  }
  static addCompression(Z, J) {
    Z.addFieldOffset(3, J, 0);
  }
  static endRecordBatch(Z) {
    return Z.endObject();
  }
}

// node_modules/apache-arrow/fb/dictionary-batch.mjs
class RN {
  constructor() {
    this.bb = null, this.bb_pos = 0;
  }
  __init(Z, J) {
    return this.bb_pos = Z, this.bb = J, this;
  }
  static getRootAsDictionaryBatch(Z, J) {
    return (J || new RN).__init(Z.readInt32(Z.position()) + Z.position(), Z);
  }
  static getSizePrefixedRootAsDictionaryBatch(Z, J) {
    return Z.setPosition(Z.position() + K6), (J || new RN).__init(Z.readInt32(Z.position()) + Z.position(), Z);
  }
  id() {
    let Z = this.bb.__offset(this.bb_pos, 4);
    return Z ? this.bb.readInt64(this.bb_pos + Z) : this.bb.createLong(0, 0);
  }
  data(Z) {
    let J = this.bb.__offset(this.bb_pos, 6);
    return J ? (Z || new F5).__init(this.bb.__indirect(this.bb_pos + J), this.bb) : null;
  }
  isDelta() {
    let Z = this.bb.__offset(this.bb_pos, 8);
    return Z ? !!this.bb.readInt8(this.bb_pos + Z) : !1;
  }
  static startDictionaryBatch(Z) {
    Z.startObject(3);
  }
  static addId(Z, J) {
    Z.addFieldInt64(0, J, Z.createLong(0, 0));
  }
  static addData(Z, J) {
    Z.addFieldOffset(1, J, 0);
  }
  static addIsDelta(Z, J) {
    Z.addFieldInt8(2, +J, 0);
  }
  static endDictionaryBatch(Z) {
    return Z.endObject();
  }
}

// node_modules/apache-arrow/fb/message-header.mjs
var aD;
(function(Z) {
  Z[Z.NONE = 0] = "NONE", Z[Z.Schema = 1] = "Schema", Z[Z.DictionaryBatch = 2] = "DictionaryBatch", Z[Z.RecordBatch = 3] = "RecordBatch", Z[Z.Tensor = 4] = "Tensor", Z[Z.SparseTensor = 5] = "SparseTensor";
})(aD || (aD = {}));

// node_modules/apache-arrow/fb/message.mjs
class bX {
  constructor() {
    this.bb = null, this.bb_pos = 0;
  }
  __init(Z, J) {
    return this.bb_pos = Z, this.bb = J, this;
  }
  static getRootAsMessage(Z, J) {
    return (J || new bX).__init(Z.readInt32(Z.position()) + Z.position(), Z);
  }
  static getSizePrefixedRootAsMessage(Z, J) {
    return Z.setPosition(Z.position() + K6), (J || new bX).__init(Z.readInt32(Z.position()) + Z.position(), Z);
  }
  version() {
    let Z = this.bb.__offset(this.bb_pos, 4);
    return Z ? this.bb.readInt16(this.bb_pos + Z) : wL.V1;
  }
  headerType() {
    let Z = this.bb.__offset(this.bb_pos, 6);
    return Z ? this.bb.readUint8(this.bb_pos + Z) : aD.NONE;
  }
  header(Z) {
    let J = this.bb.__offset(this.bb_pos, 8);
    return J ? this.bb.__union(Z, this.bb_pos + J) : null;
  }
  bodyLength() {
    let Z = this.bb.__offset(this.bb_pos, 10);
    return Z ? this.bb.readInt64(this.bb_pos + Z) : this.bb.createLong(0, 0);
  }
  customMetadata(Z, J) {
    let $ = this.bb.__offset(this.bb_pos, 12);
    return $ ? (J || new BJ).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos + $) + Z * 4), this.bb) : null;
  }
  customMetadataLength() {
    let Z = this.bb.__offset(this.bb_pos, 12);
    return Z ? this.bb.__vector_len(this.bb_pos + Z) : 0;
  }
  static startMessage(Z) {
    Z.startObject(5);
  }
  static addVersion(Z, J) {
    Z.addFieldInt16(0, J, wL.V1);
  }
  static addHeaderType(Z, J) {
    Z.addFieldInt8(1, J, aD.NONE);
  }
  static addHeader(Z, J) {
    Z.addFieldOffset(2, J, 0);
  }
  static addBodyLength(Z, J) {
    Z.addFieldInt64(3, J, Z.createLong(0, 0));
  }
  static addCustomMetadata(Z, J) {
    Z.addFieldOffset(4, J, 0);
  }
  static createCustomMetadataVector(Z, J) {
    Z.startVector(4, J.length, 4);
    for (let $ = J.length - 1;$ >= 0; $--)
      Z.addOffset(J[$]);
    return Z.endVector();
  }
  static startCustomMetadataVector(Z, J) {
    Z.startVector(4, J, 4);
  }
  static endMessage(Z) {
    return Z.endObject();
  }
  static finishMessageBuffer(Z, J) {
    Z.finish(J);
  }
  static finishSizePrefixedMessageBuffer(Z, J) {
    Z.finish(J, void 0, !0);
  }
  static createMessage(Z, J, $, X, Y, Q) {
    return bX.startMessage(Z), bX.addVersion(Z, J), bX.addHeaderType(Z, $), bX.addHeader(Z, X), bX.addBodyLength(Z, Y), bX.addCustomMetadata(Z, Q), bX.endMessage(Z);
  }
}

// node_modules/apache-arrow/visitor/typeassembler.mjs
var Co0 = $Y;

class oQ0 extends g6 {
  visit(Z, J) {
    return Z == null || J == null ? void 0 : super.visit(Z, J);
  }
  visitNull(Z, J) {
    return PL.startNull(J), PL.endNull(J);
  }
  visitInt(Z, J) {
    return _Q.startInt(J), _Q.addBitWidth(J, Z.bitWidth), _Q.addIsSigned(J, Z.isSigned), _Q.endInt(J);
  }
  visitFloat(Z, J) {
    return W3.startFloatingPoint(J), W3.addPrecision(J, Z.precision), W3.endFloatingPoint(J);
  }
  visitBinary(Z, J) {
    return TL.startBinary(J), TL.endBinary(J);
  }
  visitBool(Z, J) {
    return _L.startBool(J), _L.endBool(J);
  }
  visitUtf8(Z, J) {
    return kL.startUtf8(J), kL.endUtf8(J);
  }
  visitDecimal(Z, J) {
    return VQ.startDecimal(J), VQ.addScale(J, Z.scale), VQ.addPrecision(J, Z.precision), VQ.addBitWidth(J, Z.bitWidth), VQ.endDecimal(J);
  }
  visitDate(Z, J) {
    return X3.startDate(J), X3.addUnit(J, Z.unit), X3.endDate(J);
  }
  visitTime(Z, J) {
    return G5.startTime(J), G5.addUnit(J, Z.unit), G5.addBitWidth(J, Z.bitWidth), G5.endTime(J);
  }
  visitTimestamp(Z, J) {
    let $ = Z.timezone && J.createString(Z.timezone) || void 0;
    if (H5.startTimestamp(J), H5.addUnit(J, Z.unit), $ !== void 0)
      H5.addTimezone(J, $);
    return H5.endTimestamp(J);
  }
  visitInterval(Z, J) {
    return K3.startInterval(J), K3.addUnit(J, Z.unit), K3.endInterval(J);
  }
  visitList(Z, J) {
    return IL.startList(J), IL.endList(J);
  }
  visitStruct(Z, J) {
    return CL.startStruct_(J), CL.endStruct_(J);
  }
  visitUnion(Z, J) {
    IQ.startTypeIdsVector(J, Z.typeIds.length);
    let $ = IQ.createTypeIdsVector(J, Z.typeIds);
    return IQ.startUnion(J), IQ.addMode(J, Z.mode), IQ.addTypeIds(J, $), IQ.endUnion(J);
  }
  visitDictionary(Z, J) {
    let $ = this.visit(Z.indices, J);
    if (nG.startDictionaryEncoding(J), nG.addId(J, new Co0(Z.id, 0)), nG.addIsOrdered(J, Z.isOrdered), $ !== void 0)
      nG.addIndexType(J, $);
    return nG.endDictionaryEncoding(J);
  }
  visitFixedSizeBinary(Z, J) {
    return Y3.startFixedSizeBinary(J), Y3.addByteWidth(J, Z.byteWidth), Y3.endFixedSizeBinary(J);
  }
  visitFixedSizeList(Z, J) {
    return Q3.startFixedSizeList(J), Q3.addListSize(J, Z.listSize), Q3.endFixedSizeList(J);
  }
  visitMap(Z, J) {
    return G3.startMap(J), G3.addKeysSorted(J, Z.keysSorted), G3.endMap(J);
  }
}
var iv = new oQ0;

// node_modules/apache-arrow/ipc/metadata/json.mjs
function tQ0(Z, J = /* @__PURE__ */ new Map) {
  return new U9(ko0(Z, J), ov(Z.customMetadata), J);
}
function rl(Z) {
  return new CQ(Z.count, ZW0(Z.columns), JW0(Z.columns));
}
function eQ0(Z) {
  return new NK(rl(Z.data), Z.id, Z.isDelta);
}
function ko0(Z, J) {
  return (Z.fields || []).filter(Boolean).map(($) => SZ.fromJSON($, J));
}
function sQ0(Z, J) {
  return (Z.children || []).filter(Boolean).map(($) => SZ.fromJSON($, J));
}
function ZW0(Z) {
  return (Z || []).reduce((J, $) => [
    ...J,
    new EN($.count, vo0($.VALIDITY)),
    ...ZW0($.children)
  ], []);
}
function JW0(Z, J = []) {
  for (let $ = -1, X = (Z || []).length;++$ < X; ) {
    let Y = Z[$];
    Y.VALIDITY && J.push(new HK(J.length, Y.VALIDITY.length)), Y.TYPE && J.push(new HK(J.length, Y.TYPE.length)), Y.OFFSET && J.push(new HK(J.length, Y.OFFSET.length)), Y.DATA && J.push(new HK(J.length, Y.DATA.length)), J = JW0(Y.children, J);
  }
  return J;
}
function vo0(Z) {
  return (Z || []).reduce((J, $) => J + +($ === 0), 0);
}
function $W0(Z, J) {
  let $, X, Y, Q, W, K;
  if (!J || !(Q = Z.dictionary))
    W = rQ0(Z, sQ0(Z, J)), Y = new SZ(Z.name, W, Z.nullable, ov(Z.customMetadata));
  else if (!J.has($ = Q.id))
    X = (X = Q.indexType) ? aQ0(X) : new OF, J.set($, W = rQ0(Z, sQ0(Z, J))), K = new Z3(W, X, $, Q.isOrdered), Y = new SZ(Z.name, K, Z.nullable, ov(Z.customMetadata));
  else
    X = (X = Q.indexType) ? aQ0(X) : new OF, K = new Z3(J.get($), X, $, Q.isOrdered), Y = new SZ(Z.name, K, Z.nullable, ov(Z.customMetadata));
  return Y || null;
}
function ov(Z) {
  return new Map(Object.entries(Z || {}));
}
function aQ0(Z) {
  return new l$(Z.isSigned, Z.bitWidth);
}
function rQ0(Z, J) {
  let $ = Z.type.name;
  switch ($) {
    case "NONE":
      return new K5;
    case "null":
      return new K5;
    case "binary":
      return new qL;
    case "utf8":
      return new FL;
    case "bool":
      return new UL;
    case "list":
      return new HN((J || [])[0]);
    case "struct":
      return new qJ(J || []);
    case "struct_":
      return new qJ(J || []);
  }
  switch ($) {
    case "int": {
      let X = Z.type;
      return new l$(X.isSigned, X.bitWidth);
    }
    case "floatingpoint": {
      let X = Z.type;
      return new YK(NJ[X.precision]);
    }
    case "decimal": {
      let X = Z.type;
      return new LL(X.scale, X.precision, X.bitWidth);
    }
    case "date": {
      let X = Z.type;
      return new RL(JQ[X.unit]);
    }
    case "time": {
      let X = Z.type;
      return new GN(aZ[X.unit], X.bitWidth);
    }
    case "timestamp": {
      let X = Z.type;
      return new EL(aZ[X.unit], X.timezone);
    }
    case "interval": {
      let X = Z.type;
      return new OL(zW[X.unit]);
    }
    case "union": {
      let X = Z.type;
      return new NN(pJ[X.mode], X.typeIds || [], J || []);
    }
    case "fixedsizebinary": {
      let X = Z.type;
      return new zL(X.byteWidth);
    }
    case "fixedsizelist": {
      let X = Z.type;
      return new qN(X.listSize, (J || [])[0]);
    }
    case "map": {
      let X = Z.type;
      return new FN((J || [])[0], X.keysSorted);
    }
  }
  throw new Error(`Unrecognized type: "${$}"`);
}

// node_modules/apache-arrow/ipc/metadata/message.mjs
var vO = $Y, So0 = IO, fo0 = GK;

class YY {
  constructor(Z, J, $, X) {
    this._version = J, this._headerType = $, this.body = new Uint8Array(0), X && (this._createHeader = () => X), this._bodyLength = typeof Z === "number" ? Z : Z.low;
  }
  static fromJSON(Z, J) {
    let $ = new YY(0, JY.V4, J);
    return $._createHeader = ho0(Z, J), $;
  }
  static decode(Z) {
    Z = new fo0(YZ(Z));
    let J = bX.getRootAsMessage(Z), $ = J.bodyLength(), X = J.version(), Y = J.headerType(), Q = new YY($, X, Y);
    return Q._createHeader = bo0(J, Y), Q;
  }
  static encode(Z) {
    let J = new So0, $ = -1;
    if (Z.isSchema())
      $ = U9.encode(J, Z.header());
    else if (Z.isRecordBatch())
      $ = CQ.encode(J, Z.header());
    else if (Z.isDictionaryBatch())
      $ = NK.encode(J, Z.header());
    return bX.startMessage(J), bX.addVersion(J, JY.V4), bX.addHeader(J, $), bX.addHeaderType(J, Z.headerType), bX.addBodyLength(J, new vO(Z.bodyLength, 0)), bX.finishMessageBuffer(J, bX.endMessage(J)), J.asUint8Array();
  }
  static from(Z, J = 0) {
    if (Z instanceof U9)
      return new YY(0, JY.V4, P9.Schema, Z);
    if (Z instanceof CQ)
      return new YY(J, JY.V4, P9.RecordBatch, Z);
    if (Z instanceof NK)
      return new YY(J, JY.V4, P9.DictionaryBatch, Z);
    throw new Error(`Unrecognized Message header: ${Z}`);
  }
  get type() {
    return this.headerType;
  }
  get version() {
    return this._version;
  }
  get headerType() {
    return this._headerType;
  }
  get bodyLength() {
    return this._bodyLength;
  }
  header() {
    return this._createHeader();
  }
  isSchema() {
    return this.headerType === P9.Schema;
  }
  isRecordBatch() {
    return this.headerType === P9.RecordBatch;
  }
  isDictionaryBatch() {
    return this.headerType === P9.DictionaryBatch;
  }
}

class CQ {
  constructor(Z, J, $) {
    this._nodes = J, this._buffers = $, this._length = typeof Z === "number" ? Z : Z.low;
  }
  get nodes() {
    return this._nodes;
  }
  get length() {
    return this._length;
  }
  get buffers() {
    return this._buffers;
  }
}

class NK {
  constructor(Z, J, $ = !1) {
    this._data = Z, this._isDelta = $, this._id = typeof J === "number" ? J : J.low;
  }
  get id() {
    return this._id;
  }
  get data() {
    return this._data;
  }
  get isDelta() {
    return this._isDelta;
  }
  get length() {
    return this.data.length;
  }
  get nodes() {
    return this.data.nodes;
  }
  get buffers() {
    return this.data.buffers;
  }
}

class HK {
  constructor(Z, J) {
    this.offset = typeof Z === "number" ? Z : Z.low, this.length = typeof J === "number" ? J : J.low;
  }
}

class EN {
  constructor(Z, J) {
    this.length = typeof Z === "number" ? Z : Z.low, this.nullCount = typeof J === "number" ? J : J.low;
  }
}
function ho0(Z, J) {
  return () => {
    switch (J) {
      case P9.Schema:
        return U9.fromJSON(Z);
      case P9.RecordBatch:
        return CQ.fromJSON(Z);
      case P9.DictionaryBatch:
        return NK.fromJSON(Z);
    }
    throw new Error(`Unrecognized Message type: { name: ${P9[J]}, type: ${J} }`);
  };
}
function bo0(Z, J) {
  return () => {
    switch (J) {
      case P9.Schema:
        return U9.decode(Z.header(new P$));
      case P9.RecordBatch:
        return CQ.decode(Z.header(new F5), Z.version());
      case P9.DictionaryBatch:
        return NK.decode(Z.header(new RN), Z.version());
    }
    throw new Error(`Unrecognized Message type: { name: ${P9[J]}, type: ${J} }`);
  };
}
SZ.encode = io0;
SZ.decode = lo0;
SZ.fromJSON = $W0;
U9.encode = no0;
U9.decode = xo0;
U9.fromJSON = tQ0;
CQ.encode = oo0;
CQ.decode = yo0;
CQ.fromJSON = rl;
NK.encode = so0;
NK.decode = go0;
NK.fromJSON = eQ0;
EN.encode = ao0;
EN.decode = do0;
HK.encode = ro0;
HK.decode = mo0;
function xo0(Z, J = /* @__PURE__ */ new Map) {
  let $ = co0(Z, J);
  return new U9($, sv(Z), J);
}
function yo0(Z, J = JY.V4) {
  if (Z.compression() !== null)
    throw new Error("Record batch compression not implemented");
  return new CQ(Z.length(), po0(Z), uo0(Z, J));
}
function go0(Z, J = JY.V4) {
  return new NK(CQ.decode(Z.data(), J), Z.id(), Z.isDelta());
}
function mo0(Z) {
  return new HK(Z.offset(), Z.length());
}
function do0(Z) {
  return new EN(Z.length(), Z.nullCount());
}
function po0(Z) {
  let J = [];
  for (let $, X = -1, Y = -1, Q = Z.nodesLength();++X < Q; )
    if ($ = Z.nodes(X))
      J[++Y] = EN.decode($);
  return J;
}
function uo0(Z, J) {
  let $ = [];
  for (let X, Y = -1, Q = -1, W = Z.buffersLength();++Y < W; )
    if (X = Z.buffers(Y)) {
      if (J < JY.V4)
        X.bb_pos += 8 * (Y + 1);
      $[++Q] = HK.decode(X);
    }
  return $;
}
function co0(Z, J) {
  let $ = [];
  for (let X, Y = -1, Q = -1, W = Z.fieldsLength();++Y < W; )
    if (X = Z.fields(Y))
      $[++Q] = SZ.decode(X, J);
  return $;
}
function XW0(Z, J) {
  let $ = [];
  for (let X, Y = -1, Q = -1, W = Z.childrenLength();++Y < W; )
    if (X = Z.children(Y))
      $[++Q] = SZ.decode(X, J);
  return $;
}
function lo0(Z, J) {
  let $, X, Y, Q, W, K;
  if (!J || !(K = Z.dictionary()))
    Y = QW0(Z, XW0(Z, J)), X = new SZ(Z.name(), Y, Z.nullable(), sv(Z));
  else if (!J.has($ = K.id().low))
    Q = (Q = K.indexType()) ? YW0(Q) : new OF, J.set($, Y = QW0(Z, XW0(Z, J))), W = new Z3(Y, Q, $, K.isOrdered()), X = new SZ(Z.name(), W, Z.nullable(), sv(Z));
  else
    Q = (Q = K.indexType()) ? YW0(Q) : new OF, W = new Z3(J.get($), Q, $, K.isOrdered()), X = new SZ(Z.name(), W, Z.nullable(), sv(Z));
  return X || null;
}
function sv(Z) {
  let J = /* @__PURE__ */ new Map;
  if (Z) {
    for (let $, X, Y = -1, Q = Math.trunc(Z.customMetadataLength());++Y < Q; )
      if (($ = Z.customMetadata(Y)) && (X = $.key()) != null)
        J.set(X, $.value());
  }
  return J;
}
function YW0(Z) {
  return new l$(Z.isSigned(), Z.bitWidth());
}
function QW0(Z, J) {
  let $ = Z.typeType();
  switch ($) {
    case FJ.NONE:
      return new K5;
    case FJ.Null:
      return new K5;
    case FJ.Binary:
      return new qL;
    case FJ.Utf8:
      return new FL;
    case FJ.Bool:
      return new UL;
    case FJ.List:
      return new HN((J || [])[0]);
    case FJ.Struct_:
      return new qJ(J || []);
  }
  switch ($) {
    case FJ.Int: {
      let X = Z.type(new _Q);
      return new l$(X.isSigned(), X.bitWidth());
    }
    case FJ.FloatingPoint: {
      let X = Z.type(new W3);
      return new YK(X.precision());
    }
    case FJ.Decimal: {
      let X = Z.type(new VQ);
      return new LL(X.scale(), X.precision(), X.bitWidth());
    }
    case FJ.Date: {
      let X = Z.type(new X3);
      return new RL(X.unit());
    }
    case FJ.Time: {
      let X = Z.type(new G5);
      return new GN(X.unit(), X.bitWidth());
    }
    case FJ.Timestamp: {
      let X = Z.type(new H5);
      return new EL(X.unit(), X.timezone());
    }
    case FJ.Interval: {
      let X = Z.type(new K3);
      return new OL(X.unit());
    }
    case FJ.Union: {
      let X = Z.type(new IQ);
      return new NN(X.mode(), X.typeIdsArray() || [], J || []);
    }
    case FJ.FixedSizeBinary: {
      let X = Z.type(new Y3);
      return new zL(X.byteWidth());
    }
    case FJ.FixedSizeList: {
      let X = Z.type(new Q3);
      return new qN(X.listSize(), (J || [])[0]);
    }
    case FJ.Map: {
      let X = Z.type(new G3);
      return new FN((J || [])[0], X.keysSorted());
    }
  }
  throw new Error(`Unrecognized type: "${FJ[$]}" (${$})`);
}
function no0(Z, J) {
  let $ = J.fields.map((Q) => SZ.encode(Z, Q));
  P$.startFieldsVector(Z, $.length);
  let X = P$.createFieldsVector(Z, $), Y = !(J.metadata && J.metadata.size > 0) ? -1 : P$.createCustomMetadataVector(Z, [...J.metadata].map(([Q, W]) => {
    let K = Z.createString(`${Q}`), G = Z.createString(`${W}`);
    return BJ.startKeyValue(Z), BJ.addKey(Z, K), BJ.addValue(Z, G), BJ.endKeyValue(Z);
  }));
  if (P$.startSchema(Z), P$.addFields(Z, X), P$.addEndianness(Z, to0 ? jL.Little : jL.Big), Y !== -1)
    P$.addCustomMetadata(Z, Y);
  return P$.endSchema(Z);
}
function io0(Z, J) {
  let $ = -1, X = -1, Y = -1, Q = J.type, W = J.typeId;
  if (!L6.isDictionary(Q))
    X = iv.visit(Q, Z);
  else
    W = Q.dictionary.typeId, Y = iv.visit(Q, Z), X = iv.visit(Q.dictionary, Z);
  let K = (Q.children || []).map((N) => SZ.encode(Z, N)), G = XY.createChildrenVector(Z, K), H = !(J.metadata && J.metadata.size > 0) ? -1 : XY.createCustomMetadataVector(Z, [...J.metadata].map(([N, q]) => {
    let U = Z.createString(`${N}`), F = Z.createString(`${q}`);
    return BJ.startKeyValue(Z), BJ.addKey(Z, U), BJ.addValue(Z, F), BJ.endKeyValue(Z);
  }));
  if (J.name)
    $ = Z.createString(J.name);
  if (XY.startField(Z), XY.addType(Z, X), XY.addTypeType(Z, W), XY.addChildren(Z, G), XY.addNullable(Z, !!J.nullable), $ !== -1)
    XY.addName(Z, $);
  if (Y !== -1)
    XY.addDictionary(Z, Y);
  if (H !== -1)
    XY.addCustomMetadata(Z, H);
  return XY.endField(Z);
}
function oo0(Z, J) {
  let $ = J.nodes || [], X = J.buffers || [];
  F5.startNodesVector(Z, $.length);
  for (let W of $.slice().reverse())
    EN.encode(Z, W);
  let Y = Z.endVector();
  F5.startBuffersVector(Z, X.length);
  for (let W of X.slice().reverse())
    HK.encode(Z, W);
  let Q = Z.endVector();
  return F5.startRecordBatch(Z), F5.addLength(Z, new vO(J.length, 0)), F5.addNodes(Z, Y), F5.addBuffers(Z, Q), F5.endRecordBatch(Z);
}
function so0(Z, J) {
  let $ = CQ.encode(Z, J.data);
  return RN.startDictionaryBatch(Z), RN.addId(Z, new vO(J.id, 0)), RN.addIsDelta(Z, J.isDelta), RN.addData(Z, $), RN.endDictionaryBatch(Z);
}
function ao0(Z, J) {
  return pT.createFieldNode(Z, new vO(J.length, 0), new vO(J.nullCount, 0));
}
function ro0(Z, J) {
  return dT.createBuffer(Z, new vO(J.offset, 0), new vO(J.length, 0));
}
var to0 = (() => {
  let Z = new ArrayBuffer(2);
  return new DataView(Z).setInt16(0, 256, !0), new Int16Array(Z)[0] === 256;
})();

// node_modules/apache-arrow/ipc/message.mjs
var el = (Z) => `Expected ${P9[Z]} Message in stream, but was null or length 0.`, Zn = (Z) => `Header pointer of flatbuffer-encoded ${P9[Z]} Message is null or length 0.`, WW0 = (Z, J) => `Expected to read ${Z} metadata bytes, but only read ${J}.`, KW0 = (Z, J) => `Expected to read ${Z} bytes for message body, but only read ${J}.`;

class uT {
  constructor(Z) {
    this.source = Z instanceof jF ? Z : new jF(Z);
  }
  [Symbol.iterator]() {
    return this;
  }
  next() {
    let Z;
    if ((Z = this.readMetadataLength()).done)
      return a7;
    if (Z.value === -1 && (Z = this.readMetadataLength()).done)
      return a7;
    if ((Z = this.readMetadata(Z.value)).done)
      return a7;
    return Z;
  }
  throw(Z) {
    return this.source.throw(Z);
  }
  return(Z) {
    return this.source.return(Z);
  }
  readMessage(Z) {
    let J;
    if ((J = this.next()).done)
      return null;
    if (Z != null && J.value.headerType !== Z)
      throw new Error(el(Z));
    return J.value;
  }
  readMessageBody(Z) {
    if (Z <= 0)
      return new Uint8Array(0);
    let J = YZ(this.source.read(Z));
    if (J.byteLength < Z)
      throw new Error(KW0(Z, J.byteLength));
    return J.byteOffset % 8 === 0 && J.byteOffset + J.byteLength <= J.buffer.byteLength ? J : J.slice();
  }
  readSchema(Z = !1) {
    let J = P9.Schema, $ = this.readMessage(J), X = $ === null || $ === void 0 ? void 0 : $.header();
    if (Z && !X)
      throw new Error(Zn(J));
    return X;
  }
  readMetadataLength() {
    let Z = this.source.read(tv), J = Z && new GK(Z), $ = (J === null || J === void 0 ? void 0 : J.readInt32(0)) || 0;
    return { done: $ === 0, value: $ };
  }
  readMetadata(Z) {
    let J = this.source.read(Z);
    if (!J)
      return a7;
    if (J.byteLength < Z)
      throw new Error(WW0(Z, J.byteLength));
    return { done: !1, value: YY.decode(J) };
  }
}

class av {
  constructor(Z, J) {
    this.source = Z instanceof H3 ? Z : ok(Z) ? new PO(Z, J) : new H3(Z);
  }
  [Symbol.asyncIterator]() {
    return this;
  }
  next() {
    return j8(this, void 0, void 0, function* () {
      let Z;
      if ((Z = yield this.readMetadataLength()).done)
        return a7;
      if (Z.value === -1 && (Z = yield this.readMetadataLength()).done)
        return a7;
      if ((Z = yield this.readMetadata(Z.value)).done)
        return a7;
      return Z;
    });
  }
  throw(Z) {
    return j8(this, void 0, void 0, function* () {
      return yield this.source.throw(Z);
    });
  }
  return(Z) {
    return j8(this, void 0, void 0, function* () {
      return yield this.source.return(Z);
    });
  }
  readMessage(Z) {
    return j8(this, void 0, void 0, function* () {
      let J;
      if ((J = yield this.next()).done)
        return null;
      if (Z != null && J.value.headerType !== Z)
        throw new Error(el(Z));
      return J.value;
    });
  }
  readMessageBody(Z) {
    return j8(this, void 0, void 0, function* () {
      if (Z <= 0)
        return new Uint8Array(0);
      let J = YZ(yield this.source.read(Z));
      if (J.byteLength < Z)
        throw new Error(KW0(Z, J.byteLength));
      return J.byteOffset % 8 === 0 && J.byteOffset + J.byteLength <= J.buffer.byteLength ? J : J.slice();
    });
  }
  readSchema(Z = !1) {
    return j8(this, void 0, void 0, function* () {
      let J = P9.Schema, $ = yield this.readMessage(J), X = $ === null || $ === void 0 ? void 0 : $.header();
      if (Z && !X)
        throw new Error(Zn(J));
      return X;
    });
  }
  readMetadataLength() {
    return j8(this, void 0, void 0, function* () {
      let Z = yield this.source.read(tv), J = Z && new GK(Z), $ = (J === null || J === void 0 ? void 0 : J.readInt32(0)) || 0;
      return { done: $ === 0, value: $ };
    });
  }
  readMetadata(Z) {
    return j8(this, void 0, void 0, function* () {
      let J = yield this.source.read(Z);
      if (!J)
        return a7;
      if (J.byteLength < Z)
        throw new Error(WW0(Z, J.byteLength));
      return { done: !1, value: YY.decode(J) };
    });
  }
}

class rv extends uT {
  constructor(Z) {
    super(new Uint8Array(0));
    this._schema = !1, this._body = [], this._batchIndex = 0, this._dictionaryIndex = 0, this._json = Z instanceof _v ? Z : new _v(Z);
  }
  next() {
    let { _json: Z } = this;
    if (!this._schema)
      return this._schema = !0, { done: !1, value: YY.fromJSON(Z.schema, P9.Schema) };
    if (this._dictionaryIndex < Z.dictionaries.length) {
      let J = Z.dictionaries[this._dictionaryIndex++];
      return this._body = J.data.columns, { done: !1, value: YY.fromJSON(J, P9.DictionaryBatch) };
    }
    if (this._batchIndex < Z.batches.length) {
      let J = Z.batches[this._batchIndex++];
      return this._body = J.columns, { done: !1, value: YY.fromJSON(J, P9.RecordBatch) };
    }
    return this._body = [], a7;
  }
  readMessageBody(Z) {
    return J(this._body);
    function J($) {
      return ($ || []).reduce((X, Y) => [
        ...X,
        ...Y.VALIDITY && [Y.VALIDITY] || [],
        ...Y.TYPE && [Y.TYPE] || [],
        ...Y.OFFSET && [Y.OFFSET] || [],
        ...Y.DATA && [Y.DATA] || [],
        ...J(Y.children)
      ], []);
    }
  }
  readMessage(Z) {
    let J;
    if ((J = this.next()).done)
      return null;
    if (Z != null && J.value.headerType !== Z)
      throw new Error(el(Z));
    return J.value;
  }
  readSchema() {
    let Z = P9.Schema, J = this.readMessage(Z), $ = J === null || J === void 0 ? void 0 : J.header();
    if (!J || !$)
      throw new Error(Zn(Z));
    return $;
  }
}
var tv = 4, tl = "ARROW1", rD = new Uint8Array(tl.length);
for (let Z = 0;Z < tl.length; Z += 1)
  rD[Z] = tl.codePointAt(Z);
function ev(Z, J = 0) {
  for (let $ = -1, X = rD.length;++$ < X; )
    if (rD[$] !== Z[J + $])
      return !1;
  return !0;
}
var tD = rD.length, Jn = tD + tv, GW0 = tD * 2 + tv;

// node_modules/apache-arrow/ipc/reader.mjs
class DW extends uD {
  constructor(Z) {
    super();
    this._impl = Z;
  }
  get closed() {
    return this._impl.closed;
  }
  get schema() {
    return this._impl.schema;
  }
  get autoDestroy() {
    return this._impl.autoDestroy;
  }
  get dictionaries() {
    return this._impl.dictionaries;
  }
  get numDictionaries() {
    return this._impl.numDictionaries;
  }
  get numRecordBatches() {
    return this._impl.numRecordBatches;
  }
  get footer() {
    return this._impl.isFile() ? this._impl.footer : null;
  }
  isSync() {
    return this._impl.isSync();
  }
  isAsync() {
    return this._impl.isAsync();
  }
  isFile() {
    return this._impl.isFile();
  }
  isStream() {
    return this._impl.isStream();
  }
  next() {
    return this._impl.next();
  }
  throw(Z) {
    return this._impl.throw(Z);
  }
  return(Z) {
    return this._impl.return(Z);
  }
  cancel() {
    return this._impl.cancel();
  }
  reset(Z) {
    return this._impl.reset(Z), this._DOMStream = void 0, this._nodeStream = void 0, this;
  }
  open(Z) {
    let J = this._impl.open(Z);
    return $K(J) ? J.then(() => this) : this;
  }
  readRecordBatch(Z) {
    return this._impl.isFile() ? this._impl.readRecordBatch(Z) : null;
  }
  [Symbol.iterator]() {
    return this._impl[Symbol.iterator]();
  }
  [Symbol.asyncIterator]() {
    return this._impl[Symbol.asyncIterator]();
  }
  toDOMStream() {
    return ZQ.toDOMStream(this.isSync() ? { [Symbol.iterator]: () => this } : { [Symbol.asyncIterator]: () => this });
  }
  toNodeStream() {
    return ZQ.toNodeStream(this.isSync() ? { [Symbol.iterator]: () => this } : { [Symbol.asyncIterator]: () => this }, { objectMode: !0 });
  }
  static throughNode(Z) {
    throw new Error('"throughNode" not available in this environment');
  }
  static throughDOM(Z, J) {
    throw new Error('"throughDOM" not available in this environment');
  }
  static from(Z) {
    if (Z instanceof DW)
      return Z;
    else if (nk(Z))
      return Zs0(Z);
    else if (ok(Z))
      return Xs0(Z);
    else if ($K(Z))
      return (() => j8(this, void 0, void 0, function* () {
        return yield DW.from(yield Z);
      }))();
    else if (sk(Z) || ET(Z) || rk(Z) || tK(Z))
      return $s0(new H3(Z));
    return Js0(new jF(Z));
  }
  static readAll(Z) {
    if (Z instanceof DW)
      return Z.isSync() ? HW0(Z) : NW0(Z);
    else if (nk(Z) || ArrayBuffer.isView(Z) || dG(Z) || ik(Z))
      return HW0(Z);
    return NW0(Z);
  }
}

class bL extends DW {
  constructor(Z) {
    super(Z);
    this._impl = Z;
  }
  readAll() {
    return [...this];
  }
  [Symbol.iterator]() {
    return this._impl[Symbol.iterator]();
  }
  [Symbol.asyncIterator]() {
    return JK(this, arguments, function* Z() {
      yield NZ(yield* CD(mG(this[Symbol.iterator]())));
    });
  }
}

class eD extends DW {
  constructor(Z) {
    super(Z);
    this._impl = Z;
  }
  readAll() {
    var Z, J;
    return j8(this, void 0, void 0, function* () {
      let $ = new Array;
      try {
        for (var X = mG(this), Y;Y = yield X.next(), !Y.done; ) {
          let Q = Y.value;
          $.push(Q);
        }
      } catch (Q) {
        Z = { error: Q };
      } finally {
        try {
          if (Y && !Y.done && (J = X.return))
            yield J.call(X);
        } finally {
          if (Z)
            throw Z.error;
        }
      }
      return $;
    });
  }
  [Symbol.iterator]() {
    throw new Error("AsyncRecordBatchStreamReader is not Iterable");
  }
  [Symbol.asyncIterator]() {
    return this._impl[Symbol.asyncIterator]();
  }
}

class ZM extends bL {
  constructor(Z) {
    super(Z);
    this._impl = Z;
  }
}

class $n extends eD {
  constructor(Z) {
    super(Z);
    this._impl = Z;
  }
}

class Xn {
  constructor(Z = /* @__PURE__ */ new Map) {
    this.closed = !1, this.autoDestroy = !0, this._dictionaryIndex = 0, this._recordBatchIndex = 0, this.dictionaries = Z;
  }
  get numDictionaries() {
    return this._dictionaryIndex;
  }
  get numRecordBatches() {
    return this._recordBatchIndex;
  }
  isSync() {
    return !1;
  }
  isAsync() {
    return !1;
  }
  isFile() {
    return !1;
  }
  isStream() {
    return !1;
  }
  reset(Z) {
    return this._dictionaryIndex = 0, this._recordBatchIndex = 0, this.schema = Z, this.dictionaries = /* @__PURE__ */ new Map, this;
  }
  _loadRecordBatch(Z, J) {
    let $ = this._loadVectors(Z, J, this.schema.fields), X = FZ({ type: new qJ(this.schema.fields), length: Z.length, children: $ });
    return new UJ(this.schema, X);
  }
  _loadDictionaryBatch(Z, J) {
    let { id: $, isDelta: X } = Z, { dictionaries: Y, schema: Q } = this, W = Y.get($);
    if (X || !W) {
      let K = Q.dictionaries.get($), G = this._loadVectors(Z.data, J, [K]);
      return (W && X ? W.concat(new wZ(G)) : new wZ(G)).memoize();
    }
    return W.memoize();
  }
  _loadVectors(Z, J, $) {
    return new Pv(J, Z.nodes, Z.buffers, this.dictionaries).visitMany($);
  }
}

class cT extends Xn {
  constructor(Z, J) {
    super(J);
    this._reader = !nk(Z) ? new uT(this._handle = Z) : new rv(this._handle = Z);
  }
  isSync() {
    return !0;
  }
  isStream() {
    return !0;
  }
  [Symbol.iterator]() {
    return this;
  }
  cancel() {
    if (!this.closed && (this.closed = !0))
      this.reset()._reader.return(), this._reader = null, this.dictionaries = null;
  }
  open(Z) {
    if (!this.closed) {
      if (this.autoDestroy = UW0(this, Z), !(this.schema || (this.schema = this._reader.readSchema())))
        this.cancel();
    }
    return this;
  }
  throw(Z) {
    if (!this.closed && this.autoDestroy && (this.closed = !0))
      return this.reset()._reader.throw(Z);
    return a7;
  }
  return(Z) {
    if (!this.closed && this.autoDestroy && (this.closed = !0))
      return this.reset()._reader.return(Z);
    return a7;
  }
  next() {
    if (this.closed)
      return a7;
    let Z, { _reader: J } = this;
    while (Z = this._readNextMessageAndValidate())
      if (Z.isSchema())
        this.reset(Z.header());
      else if (Z.isRecordBatch()) {
        this._recordBatchIndex++;
        let $ = Z.header(), X = J.readMessageBody(Z.bodyLength);
        return { done: !1, value: this._loadRecordBatch($, X) };
      } else if (Z.isDictionaryBatch()) {
        this._dictionaryIndex++;
        let $ = Z.header(), X = J.readMessageBody(Z.bodyLength), Y = this._loadDictionaryBatch($, X);
        this.dictionaries.set($.id, Y);
      }
    if (this.schema && this._recordBatchIndex === 0)
      return this._recordBatchIndex++, { done: !1, value: new sD(this.schema) };
    return this.return();
  }
  _readNextMessageAndValidate(Z) {
    return this._reader.readMessage(Z);
  }
}

class lT extends Xn {
  constructor(Z, J) {
    super(J);
    this._reader = new av(this._handle = Z);
  }
  isAsync() {
    return !0;
  }
  isStream() {
    return !0;
  }
  [Symbol.asyncIterator]() {
    return this;
  }
  cancel() {
    return j8(this, void 0, void 0, function* () {
      if (!this.closed && (this.closed = !0))
        yield this.reset()._reader.return(), this._reader = null, this.dictionaries = null;
    });
  }
  open(Z) {
    return j8(this, void 0, void 0, function* () {
      if (!this.closed) {
        if (this.autoDestroy = UW0(this, Z), !(this.schema || (this.schema = yield this._reader.readSchema())))
          yield this.cancel();
      }
      return this;
    });
  }
  throw(Z) {
    return j8(this, void 0, void 0, function* () {
      if (!this.closed && this.autoDestroy && (this.closed = !0))
        return yield this.reset()._reader.throw(Z);
      return a7;
    });
  }
  return(Z) {
    return j8(this, void 0, void 0, function* () {
      if (!this.closed && this.autoDestroy && (this.closed = !0))
        return yield this.reset()._reader.return(Z);
      return a7;
    });
  }
  next() {
    return j8(this, void 0, void 0, function* () {
      if (this.closed)
        return a7;
      let Z, { _reader: J } = this;
      while (Z = yield this._readNextMessageAndValidate())
        if (Z.isSchema())
          yield this.reset(Z.header());
        else if (Z.isRecordBatch()) {
          this._recordBatchIndex++;
          let $ = Z.header(), X = yield J.readMessageBody(Z.bodyLength);
          return { done: !1, value: this._loadRecordBatch($, X) };
        } else if (Z.isDictionaryBatch()) {
          this._dictionaryIndex++;
          let $ = Z.header(), X = yield J.readMessageBody(Z.bodyLength), Y = this._loadDictionaryBatch($, X);
          this.dictionaries.set($.id, Y);
        }
      if (this.schema && this._recordBatchIndex === 0)
        return this._recordBatchIndex++, { done: !1, value: new sD(this.schema) };
      return yield this.return();
    });
  }
  _readNextMessageAndValidate(Z) {
    return j8(this, void 0, void 0, function* () {
      return yield this._reader.readMessage(Z);
    });
  }
}

class Yn extends cT {
  constructor(Z, J) {
    super(Z instanceof Vv ? Z : new Vv(Z), J);
  }
  get footer() {
    return this._footer;
  }
  get numDictionaries() {
    return this._footer ? this._footer.numDictionaries : 0;
  }
  get numRecordBatches() {
    return this._footer ? this._footer.numRecordBatches : 0;
  }
  isSync() {
    return !0;
  }
  isFile() {
    return !0;
  }
  open(Z) {
    if (!this.closed && !this._footer) {
      this.schema = (this._footer = this._readFooter()).schema;
      for (let J of this._footer.dictionaryBatches())
        J && this._readDictionaryBatch(this._dictionaryIndex++);
    }
    return super.open(Z);
  }
  readRecordBatch(Z) {
    var J;
    if (this.closed)
      return null;
    if (!this._footer)
      this.open();
    let $ = (J = this._footer) === null || J === void 0 ? void 0 : J.getRecordBatch(Z);
    if ($ && this._handle.seek($.offset)) {
      let X = this._reader.readMessage(P9.RecordBatch);
      if (X === null || X === void 0 ? void 0 : X.isRecordBatch()) {
        let Y = X.header(), Q = this._reader.readMessageBody(X.bodyLength);
        return this._loadRecordBatch(Y, Q);
      }
    }
    return null;
  }
  _readDictionaryBatch(Z) {
    var J;
    let $ = (J = this._footer) === null || J === void 0 ? void 0 : J.getDictionaryBatch(Z);
    if ($ && this._handle.seek($.offset)) {
      let X = this._reader.readMessage(P9.DictionaryBatch);
      if (X === null || X === void 0 ? void 0 : X.isDictionaryBatch()) {
        let Y = X.header(), Q = this._reader.readMessageBody(X.bodyLength), W = this._loadDictionaryBatch(Y, Q);
        this.dictionaries.set(Y.id, W);
      }
    }
  }
  _readFooter() {
    let { _handle: Z } = this, J = Z.size - Jn, $ = Z.readInt32(J), X = Z.readAt(J - $, $);
    return vL.decode(X);
  }
  _readNextMessageAndValidate(Z) {
    var J;
    if (!this._footer)
      this.open();
    if (this._footer && this._recordBatchIndex < this.numRecordBatches) {
      let $ = (J = this._footer) === null || J === void 0 ? void 0 : J.getRecordBatch(this._recordBatchIndex);
      if ($ && this._handle.seek($.offset))
        return this._reader.readMessage(Z);
    }
    return null;
  }
}

class qW0 extends lT {
  constructor(Z, ...J) {
    let $ = typeof J[0] !== "number" ? J.shift() : void 0, X = J[0] instanceof Map ? J.shift() : void 0;
    super(Z instanceof PO ? Z : new PO(Z, $), X);
  }
  get footer() {
    return this._footer;
  }
  get numDictionaries() {
    return this._footer ? this._footer.numDictionaries : 0;
  }
  get numRecordBatches() {
    return this._footer ? this._footer.numRecordBatches : 0;
  }
  isFile() {
    return !0;
  }
  isAsync() {
    return !0;
  }
  open(Z) {
    let J = Object.create(null, {
      open: { get: () => super.open }
    });
    return j8(this, void 0, void 0, function* () {
      if (!this.closed && !this._footer) {
        this.schema = (this._footer = yield this._readFooter()).schema;
        for (let $ of this._footer.dictionaryBatches())
          $ && (yield this._readDictionaryBatch(this._dictionaryIndex++));
      }
      return yield J.open.call(this, Z);
    });
  }
  readRecordBatch(Z) {
    var J;
    return j8(this, void 0, void 0, function* () {
      if (this.closed)
        return null;
      if (!this._footer)
        yield this.open();
      let $ = (J = this._footer) === null || J === void 0 ? void 0 : J.getRecordBatch(Z);
      if ($ && (yield this._handle.seek($.offset))) {
        let X = yield this._reader.readMessage(P9.RecordBatch);
        if (X === null || X === void 0 ? void 0 : X.isRecordBatch()) {
          let Y = X.header(), Q = yield this._reader.readMessageBody(X.bodyLength);
          return this._loadRecordBatch(Y, Q);
        }
      }
      return null;
    });
  }
  _readDictionaryBatch(Z) {
    var J;
    return j8(this, void 0, void 0, function* () {
      let $ = (J = this._footer) === null || J === void 0 ? void 0 : J.getDictionaryBatch(Z);
      if ($ && (yield this._handle.seek($.offset))) {
        let X = yield this._reader.readMessage(P9.DictionaryBatch);
        if (X === null || X === void 0 ? void 0 : X.isDictionaryBatch()) {
          let Y = X.header(), Q = yield this._reader.readMessageBody(X.bodyLength), W = this._loadDictionaryBatch(Y, Q);
          this.dictionaries.set(Y.id, W);
        }
      }
    });
  }
  _readFooter() {
    return j8(this, void 0, void 0, function* () {
      let { _handle: Z } = this;
      Z._pending && (yield Z._pending);
      let J = Z.size - Jn, $ = yield Z.readInt32(J), X = yield Z.readAt(J - $, $);
      return vL.decode(X);
    });
  }
  _readNextMessageAndValidate(Z) {
    return j8(this, void 0, void 0, function* () {
      if (!this._footer)
        yield this.open();
      if (this._footer && this._recordBatchIndex < this.numRecordBatches) {
        let J = this._footer.getRecordBatch(this._recordBatchIndex);
        if (J && (yield this._handle.seek(J.offset)))
          return yield this._reader.readMessage(Z);
      }
      return null;
    });
  }
}

class FW0 extends cT {
  constructor(Z, J) {
    super(Z, J);
  }
  _loadVectors(Z, J, $) {
    return new Vl(J, Z.nodes, Z.buffers, this.dictionaries).visitMany($);
  }
}
function UW0(Z, J) {
  return J && typeof J.autoDestroy === "boolean" ? J.autoDestroy : Z.autoDestroy;
}
function* HW0(Z) {
  let J = DW.from(Z);
  try {
    if (!J.open({ autoDestroy: !1 }).closed)
      do
        yield J;
      while (!J.reset().open().closed);
  } finally {
    J.cancel();
  }
}
function NW0(Z) {
  return JK(this, arguments, function* J() {
    let $ = yield NZ(DW.from(Z));
    try {
      if (!(yield NZ($.open({ autoDestroy: !1 }))).closed)
        do
          yield yield NZ($);
        while (!(yield NZ($.reset().open())).closed);
    } finally {
      yield NZ($.cancel());
    }
  });
}
function Zs0(Z) {
  return new bL(new FW0(Z));
}
function Js0(Z) {
  let J = Z.peek(tD + 7 & -8);
  return J && J.byteLength >= 4 ? !ev(J) ? new bL(new cT(Z)) : new ZM(new Yn(Z.read())) : new bL(new cT(function* () {}()));
}
function $s0(Z) {
  return j8(this, void 0, void 0, function* () {
    let J = yield Z.peek(tD + 7 & -8);
    return J && J.byteLength >= 4 ? !ev(J) ? new eD(new lT(Z)) : new ZM(new Yn(yield Z.read())) : new eD(new lT(function() {
      return JK(this, arguments, function* () {});
    }()));
  });
}
function Xs0(Z) {
  return j8(this, void 0, void 0, function* () {
    let { size: J } = yield Z.stat(), $ = new PO(Z, J);
    if (J >= GW0 && ev(yield $.readAt(0, tD + 7 & -8)))
      return new $n(new qW0($));
    return new eD(new lT($));
  });
}

// node_modules/apache-arrow/visitor/vectorassembler.mjs
class C$ extends g6 {
  constructor() {
    super();
    this._byteLength = 0, this._nodes = [], this._buffers = [], this._bufferRegions = [];
  }
  static assemble(...Z) {
    let J = (X) => X.flatMap((Y) => Array.isArray(Y) ? J(Y) : Y instanceof UJ ? Y.data.children : Y.data), $ = new C$;
    return $.visitMany(J(Z)), $;
  }
  visit(Z) {
    if (Z instanceof wZ)
      return this.visitMany(Z.data), this;
    let { type: J } = Z;
    if (!L6.isDictionary(J)) {
      let { length: $, nullCount: X } = Z;
      if ($ > 2147483647)
        throw new RangeError("Cannot write arrays larger than 2^31 - 1 in length");
      if (!L6.isNull(J))
        oG.call(this, X <= 0 ? new Uint8Array(0) : yD(Z.offset, $, Z.nullBitmap));
      this.nodes.push(new EN($, X));
    }
    return super.visit(Z);
  }
  visitNull(Z) {
    return this;
  }
  visitDictionary(Z) {
    return this.visit(Z.clone(Z.type.indices));
  }
  get nodes() {
    return this._nodes;
  }
  get buffers() {
    return this._buffers;
  }
  get byteLength() {
    return this._byteLength;
  }
  get bufferRegions() {
    return this._bufferRegions;
  }
}
function oG(Z) {
  let J = Z.byteLength + 7 & -8;
  return this.buffers.push(Z), this.bufferRegions.push(new HK(this._byteLength, J)), this._byteLength += J, this;
}
function Ys0(Z) {
  let { type: J, length: $, typeIds: X, valueOffsets: Y } = Z;
  if (oG.call(this, X), J.mode === pJ.Sparse)
    return Qn.call(this, Z);
  else if (J.mode === pJ.Dense)
    if (Z.offset <= 0)
      return oG.call(this, Y), Qn.call(this, Z);
    else {
      let Q = X.reduce((N, q) => Math.max(N, q), X[0]), W = new Int32Array(Q + 1), K = new Int32Array(Q + 1).fill(-1), G = new Int32Array($), H = OT(-Y[0], $, Y);
      for (let N, q, U = -1;++U < $; ) {
        if ((q = K[N = X[U]]) === -1)
          q = K[N] = H[N];
        G[U] = H[U] - q, ++W[N];
      }
      oG.call(this, G);
      for (let N, q = -1, U = J.children.length;++q < U; )
        if (N = Z.children[q]) {
          let F = J.typeIds[q], E = Math.min($, W[F]);
          this.visit(N.slice(K[F], E));
        }
    }
  return this;
}
function Qs0(Z) {
  let J;
  if (Z.nullCount >= Z.length)
    return oG.call(this, new Uint8Array(0));
  else if ((J = Z.values) instanceof Uint8Array)
    return oG.call(this, yD(Z.offset, Z.length, J));
  return oG.call(this, TO(Z.values));
}
function xL(Z) {
  return oG.call(this, Z.values.subarray(0, Z.length * Z.stride));
}
function LW0(Z) {
  let { length: J, values: $, valueOffsets: X } = Z, Y = X[0], Q = X[J], W = Math.min(Q - Y, $.byteLength - Y);
  return oG.call(this, OT(-X[0], J, X)), oG.call(this, $.subarray(Y, Y + W)), this;
}
function Wn(Z) {
  let { length: J, valueOffsets: $ } = Z;
  if ($)
    oG.call(this, OT($[0], J, $));
  return this.visit(Z.children[0]);
}
function Qn(Z) {
  return this.visitMany(Z.type.children.map((J, $) => Z.children[$]).filter(Boolean))[0];
}
C$.prototype.visitBool = Qs0;
C$.prototype.visitInt = xL;
C$.prototype.visitFloat = xL;
C$.prototype.visitUtf8 = LW0;
C$.prototype.visitBinary = LW0;
C$.prototype.visitFixedSizeBinary = xL;
C$.prototype.visitDate = xL;
C$.prototype.visitTimestamp = xL;
C$.prototype.visitTime = xL;
C$.prototype.visitDecimal = xL;
C$.prototype.visitList = Wn;
C$.prototype.visitStruct = Qn;
C$.prototype.visitUnion = Ys0;
C$.prototype.visitInterval = xL;
C$.prototype.visitFixedSizeList = Wn;
C$.prototype.visitMap = Wn;

// node_modules/apache-arrow/ipc/writer.mjs
class JM extends uD {
  constructor(Z) {
    super();
    this._position = 0, this._started = !1, this._sink = new wF, this._schema = null, this._dictionaryBlocks = [], this._recordBatchBlocks = [], this._dictionaryDeltaOffsets = /* @__PURE__ */ new Map, OW(Z) || (Z = { autoDestroy: !0, writeLegacyIpcFormat: !1 }), this._autoDestroy = typeof Z.autoDestroy === "boolean" ? Z.autoDestroy : !0, this._writeLegacyIpcFormat = typeof Z.writeLegacyIpcFormat === "boolean" ? Z.writeLegacyIpcFormat : !1;
  }
  static throughNode(Z) {
    throw new Error('"throughNode" not available in this environment');
  }
  static throughDOM(Z, J) {
    throw new Error('"throughDOM" not available in this environment');
  }
  toString(Z = !1) {
    return this._sink.toString(Z);
  }
  toUint8Array(Z = !1) {
    return this._sink.toUint8Array(Z);
  }
  writeAll(Z) {
    if ($K(Z))
      return Z.then((J) => this.writeAll(J));
    else if (tK(Z))
      return Gn(this, Z);
    return Kn(this, Z);
  }
  get closed() {
    return this._sink.closed;
  }
  [Symbol.asyncIterator]() {
    return this._sink[Symbol.asyncIterator]();
  }
  toDOMStream(Z) {
    return this._sink.toDOMStream(Z);
  }
  toNodeStream(Z) {
    return this._sink.toNodeStream(Z);
  }
  close() {
    return this.reset()._sink.close();
  }
  abort(Z) {
    return this.reset()._sink.abort(Z);
  }
  finish() {
    return this._autoDestroy ? this.close() : this.reset(this._sink, this._schema), this;
  }
  reset(Z = this._sink, J = null) {
    if (Z === this._sink || Z instanceof wF)
      this._sink = Z;
    else if (this._sink = new wF, Z && _Y0(Z))
      this.toDOMStream({ type: "bytes" }).pipeTo(Z);
    else if (Z && VY0(Z))
      this.toNodeStream({ objectMode: !1 }).pipe(Z);
    if (this._started && this._schema)
      this._writeFooter(this._schema);
    if (this._started = !1, this._dictionaryBlocks = [], this._recordBatchBlocks = [], this._dictionaryDeltaOffsets = /* @__PURE__ */ new Map, !J || !kO(J, this._schema))
      if (J == null)
        this._position = 0, this._schema = null;
      else
        this._started = !0, this._schema = J, this._writeSchema(J);
    return this;
  }
  write(Z) {
    let J = null;
    if (!this._sink)
      throw new Error("RecordBatchWriter is closed");
    else if (Z == null)
      return this.finish() && void 0;
    else if (Z instanceof hX && !(J = Z.schema))
      return this.finish() && void 0;
    else if (Z instanceof UJ && !(J = Z.schema))
      return this.finish() && void 0;
    if (J && !kO(J, this._schema)) {
      if (this._started && this._autoDestroy)
        return this.close();
      this.reset(this._sink, J);
    }
    if (Z instanceof UJ) {
      if (!(Z instanceof sD))
        this._writeRecordBatch(Z);
    } else if (Z instanceof hX)
      this.writeAll(Z.batches);
    else if (dG(Z))
      this.writeAll(Z);
  }
  _writeMessage(Z, J = 8) {
    let $ = J - 1, X = YY.encode(Z), Y = X.byteLength, Q = !this._writeLegacyIpcFormat ? 8 : 4, W = Y + Q + $ & ~$, K = W - Y - Q;
    if (Z.headerType === P9.RecordBatch)
      this._recordBatchBlocks.push(new BF(W, Z.bodyLength, this._position));
    else if (Z.headerType === P9.DictionaryBatch)
      this._dictionaryBlocks.push(new BF(W, Z.bodyLength, this._position));
    if (!this._writeLegacyIpcFormat)
      this._write(Int32Array.of(-1));
    if (this._write(Int32Array.of(W - Q)), Y > 0)
      this._write(X);
    return this._writePadding(K);
  }
  _write(Z) {
    if (this._started) {
      let J = YZ(Z);
      if (J && J.byteLength > 0)
        this._sink.write(J), this._position += J.byteLength;
    }
    return this;
  }
  _writeSchema(Z) {
    return this._writeMessage(YY.from(Z));
  }
  _writeFooter(Z) {
    return this._writeLegacyIpcFormat ? this._write(Int32Array.of(0)) : this._write(Int32Array.of(-1, 0));
  }
  _writeMagic() {
    return this._write(rD);
  }
  _writePadding(Z) {
    return Z > 0 ? this._write(new Uint8Array(Z)) : this;
  }
  _writeRecordBatch(Z) {
    let { byteLength: J, nodes: $, bufferRegions: X, buffers: Y } = C$.assemble(Z), Q = new CQ(Z.numRows, $, X), W = YY.from(Q, J);
    return this._writeDictionaries(Z)._writeMessage(W)._writeBodyBuffers(Y);
  }
  _writeDictionaryBatch(Z, J, $ = !1) {
    this._dictionaryDeltaOffsets.set(J, Z.length + (this._dictionaryDeltaOffsets.get(J) || 0));
    let { byteLength: X, nodes: Y, bufferRegions: Q, buffers: W } = C$.assemble(new wZ([Z])), K = new CQ(Z.length, Y, Q), G = new NK(K, J, $), H = YY.from(G, X);
    return this._writeMessage(H)._writeBodyBuffers(W);
  }
  _writeBodyBuffers(Z) {
    let J, $, X;
    for (let Y = -1, Q = Z.length;++Y < Q; )
      if ((J = Z[Y]) && ($ = J.byteLength) > 0) {
        if (this._write(J), (X = ($ + 7 & -8) - $) > 0)
          this._writePadding(X);
      }
    return this;
  }
  _writeDictionaries(Z) {
    for (let [J, $] of Z.dictionaries) {
      let X = this._dictionaryDeltaOffsets.get(J) || 0;
      if (X === 0 || ($ = $ === null || $ === void 0 ? void 0 : $.slice(X)).length > 0)
        for (let Y of $.data)
          this._writeDictionaryBatch(Y, J, X > 0), X += Y.length;
    }
    return this;
  }
}

class SO extends JM {
  static writeAll(Z, J) {
    let $ = new SO(J);
    if ($K(Z))
      return Z.then((X) => $.writeAll(X));
    else if (tK(Z))
      return Gn($, Z);
    return Kn($, Z);
  }
}

class fO extends JM {
  static writeAll(Z) {
    let J = new fO;
    if ($K(Z))
      return Z.then(($) => J.writeAll($));
    else if (tK(Z))
      return Gn(J, Z);
    return Kn(J, Z);
  }
  constructor() {
    super();
    this._autoDestroy = !0;
  }
  _writeSchema(Z) {
    return this._writeMagic()._writePadding(2);
  }
  _writeFooter(Z) {
    let J = vL.encode(new vL(Z, JY.V4, this._recordBatchBlocks, this._dictionaryBlocks));
    return super._writeFooter(Z)._write(J)._write(Int32Array.of(J.byteLength))._writeMagic();
  }
}
function Kn(Z, J) {
  let $ = J;
  if (J instanceof hX)
    $ = J.batches, Z.reset(void 0, J.schema);
  for (let X of $)
    Z.write(X);
  return Z.finish();
}
function Gn(Z, J) {
  var $, X, Y, Q;
  return j8(this, void 0, void 0, function* () {
    try {
      for ($ = mG(J);X = yield $.next(), !X.done; ) {
        let W = X.value;
        Z.write(W);
      }
    } catch (W) {
      Y = { error: W };
    } finally {
      try {
        if (X && !X.done && (Q = $.return))
          yield Q.call($);
      } finally {
        if (Y)
          throw Y.error;
      }
    }
    return Z.finish();
  });
}

// node_modules/apache-arrow/io/whatwg/iterable.mjs
function RW0(Z, J) {
  if (tK(Z))
    return Ks0(Z, J);
  if (dG(Z))
    return Ws0(Z, J);
  throw new Error("toDOMStream() must be called with an Iterable or AsyncIterable");
}
function Ws0(Z, J) {
  let $ = null, X = (J === null || J === void 0 ? void 0 : J.type) === "bytes" || !1, Y = (J === null || J === void 0 ? void 0 : J.highWaterMark) || Math.pow(2, 24);
  return new ReadableStream(Object.assign(Object.assign({}, J), {
    start(W) {
      Q(W, $ || ($ = Z[Symbol.iterator]()));
    },
    pull(W) {
      $ ? Q(W, $) : W.close();
    },
    cancel() {
      (($ === null || $ === void 0 ? void 0 : $.return) && $.return() || !0) && ($ = null);
    }
  }), Object.assign({ highWaterMark: X ? Y : void 0 }, J));
  function Q(W, K) {
    let G, H = null, N = W.desiredSize || null;
    while (!(H = K.next(X ? N : null)).done) {
      if (ArrayBuffer.isView(H.value) && (G = YZ(H.value)))
        N != null && X && (N = N - G.byteLength + 1), H.value = G;
      if (W.enqueue(H.value), N != null && --N <= 0)
        return;
    }
    W.close();
  }
}
function Ks0(Z, J) {
  let $ = null, X = (J === null || J === void 0 ? void 0 : J.type) === "bytes" || !1, Y = (J === null || J === void 0 ? void 0 : J.highWaterMark) || Math.pow(2, 24);
  return new ReadableStream(Object.assign(Object.assign({}, J), {
    start(W) {
      return j8(this, void 0, void 0, function* () {
        yield Q(W, $ || ($ = Z[Symbol.asyncIterator]()));
      });
    },
    pull(W) {
      return j8(this, void 0, void 0, function* () {
        $ ? yield Q(W, $) : W.close();
      });
    },
    cancel() {
      return j8(this, void 0, void 0, function* () {
        (($ === null || $ === void 0 ? void 0 : $.return) && (yield $.return()) || !0) && ($ = null);
      });
    }
  }), Object.assign({ highWaterMark: X ? Y : void 0 }, J));
  function Q(W, K) {
    return j8(this, void 0, void 0, function* () {
      let G, H = null, N = W.desiredSize || null;
      while (!(H = yield K.next(X ? N : null)).done) {
        if (ArrayBuffer.isView(H.value) && (G = YZ(H.value)))
          N != null && X && (N = N - G.byteLength + 1), H.value = G;
        if (W.enqueue(H.value), N != null && --N <= 0)
          return;
      }
      W.close();
    });
  }
}

// node_modules/apache-arrow/io/whatwg/builder.mjs
function zW0(Z) {
  return new DW0(Z);
}

class DW0 {
  constructor(Z) {
    this._numChunks = 0, this._finished = !1, this._bufferedSize = 0;
    let { ["readableStrategy"]: J, ["writableStrategy"]: $, ["queueingStrategy"]: X = "count" } = Z, Y = jY0(Z, ["readableStrategy", "writableStrategy", "queueingStrategy"]);
    this._controller = null, this._builder = CO(Y), this._getSize = X !== "bytes" ? EW0 : OW0;
    let { ["highWaterMark"]: Q = X === "bytes" ? Math.pow(2, 14) : 1000 } = Object.assign({}, J), { ["highWaterMark"]: W = X === "bytes" ? Math.pow(2, 14) : 1000 } = Object.assign({}, $);
    this.readable = new ReadableStream({
      ["cancel"]: () => {
        this._builder.clear();
      },
      ["pull"]: (K) => {
        this._maybeFlush(this._builder, this._controller = K);
      },
      ["start"]: (K) => {
        this._maybeFlush(this._builder, this._controller = K);
      }
    }, {
      highWaterMark: Q,
      size: X !== "bytes" ? EW0 : OW0
    }), this.writable = new WritableStream({
      ["abort"]: () => {
        this._builder.clear();
      },
      ["write"]: () => {
        this._maybeFlush(this._builder, this._controller);
      },
      ["close"]: () => {
        this._maybeFlush(this._builder.finish(), this._controller);
      }
    }, {
      highWaterMark: W,
      size: (K) => this._writeValueAndReturnChunkSize(K)
    });
  }
  _writeValueAndReturnChunkSize(Z) {
    let J = this._bufferedSize;
    return this._bufferedSize = this._getSize(this._builder.append(Z)), this._bufferedSize - J;
  }
  _maybeFlush(Z, J) {
    if (J == null)
      return;
    if (this._bufferedSize >= J.desiredSize)
      ++this._numChunks && this._enqueue(J, Z.toVector());
    if (Z.finished) {
      if (Z.length > 0 || this._numChunks === 0)
        ++this._numChunks && this._enqueue(J, Z.toVector());
      if (!this._finished && (this._finished = !0))
        this._enqueue(J, null);
    }
  }
  _enqueue(Z, J) {
    this._bufferedSize = 0, this._controller = null, J == null ? Z.close() : Z.enqueue(J);
  }
}
var EW0 = (Z) => {
  var J;
  return (J = Z === null || Z === void 0 ? void 0 : Z.length) !== null && J !== void 0 ? J : 0;
}, OW0 = (Z) => {
  var J;
  return (J = Z === null || Z === void 0 ? void 0 : Z.byteLength) !== null && J !== void 0 ? J : 0;
};

// node_modules/apache-arrow/io/whatwg/reader.mjs
function ZS(Z, J) {
  let $ = new wF, X = null, Y = new ReadableStream({
    cancel() {
      return j8(this, void 0, void 0, function* () {
        yield $.close();
      });
    },
    start(K) {
      return j8(this, void 0, void 0, function* () {
        yield W(K, X || (X = yield Q()));
      });
    },
    pull(K) {
      return j8(this, void 0, void 0, function* () {
        X ? yield W(K, X) : K.close();
      });
    }
  });
  return { writable: new WritableStream($, Object.assign({ highWaterMark: Math.pow(2, 14) }, Z)), readable: Y };
  function Q() {
    return j8(this, void 0, void 0, function* () {
      return yield (yield DW.from($)).open(J);
    });
  }
  function W(K, G) {
    return j8(this, void 0, void 0, function* () {
      let H = K.desiredSize, N = null;
      while (!(N = yield G.next()).done)
        if (K.enqueue(N.value), H != null && --H <= 0)
          return;
      K.close();
    });
  }
}

// node_modules/apache-arrow/io/whatwg/writer.mjs
function JS(Z, J) {
  let $ = new this(Z), X = new H3($), Y = new ReadableStream({
    cancel() {
      return j8(this, void 0, void 0, function* () {
        yield X.cancel();
      });
    },
    pull(W) {
      return j8(this, void 0, void 0, function* () {
        yield Q(W);
      });
    },
    start(W) {
      return j8(this, void 0, void 0, function* () {
        yield Q(W);
      });
    }
  }, Object.assign({ highWaterMark: Math.pow(2, 14) }, J));
  return { writable: new WritableStream($, Z), readable: Y };
  function Q(W) {
    return j8(this, void 0, void 0, function* () {
      let K = null, G = W.desiredSize;
      while (K = yield X.read(G || null))
        if (W.enqueue(K), G != null && (G -= K.byteLength) <= 0)
          return;
      W.close();
    });
  }
}
// node_modules/apache-arrow/ipc/serialization.mjs
function yL(Z) {
  let J = DW.from(Z);
  if ($K(J))
    return J.then(($) => yL($));
  if (J.isAsync())
    return J.readAll().then(($) => new hX($));
  return new hX(J.readAll());
}
function $M(Z, J = "stream") {
  return (J === "stream" ? SO : fO).writeAll(Z).toUint8Array(!0);
}
// node_modules/apache-arrow/Arrow.mjs
var Gs0 = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, tc), _l), Ml), Hl), sc), Dl), {
  compareSchemas: kO,
  compareFields: pQ0,
  compareTypes: uQ0
});
// node_modules/apache-arrow/Arrow.dom.mjs
ZQ.toDOMStream = RW0;
AJ.throughDOM = zW0;
DW.throughDOM = ZS;
ZM.throughDOM = ZS;
bL.throughDOM = ZS;
JM.throughDOM = JS;
fO.throughDOM = JS;
SO.throughDOM = JS;

// node_modules/streamlit-component-lib/dist/ArrowTable.js
var $S = function() {
  function Z(J, $, X, Y) {
    var Q = this;
    this.getCell = function(W, K) {
      var G = W < Q.headerRows && K < Q.headerColumns, H = W >= Q.headerRows && K < Q.headerColumns, N = W < Q.headerRows && K >= Q.headerColumns;
      if (G) {
        var q = ["blank"];
        if (K > 0)
          q.push("level" + W);
        return {
          type: "blank",
          classNames: q.join(" "),
          content: ""
        };
      } else if (N) {
        var U = K - Q.headerColumns, q = [
          "col_heading",
          "level" + W,
          "col" + U
        ];
        return {
          type: "columns",
          classNames: q.join(" "),
          content: Q.getContent(Q.columnsTable, U, W)
        };
      } else if (H) {
        var F = W - Q.headerRows, q = [
          "row_heading",
          "level" + K,
          "row" + F
        ];
        return {
          type: "index",
          id: "T_".concat(Q.uuid, "level").concat(K, "_row").concat(F),
          classNames: q.join(" "),
          content: Q.getContent(Q.indexTable, F, K)
        };
      } else {
        var F = W - Q.headerRows, U = K - Q.headerColumns, q = [
          "data",
          "row" + F,
          "col" + U
        ], E = Q.styler ? Q.getContent(Q.styler.displayValuesTable, F, U) : Q.getContent(Q.dataTable, F, U);
        return {
          type: "data",
          id: "T_".concat(Q.uuid, "row").concat(F, "_col").concat(U),
          classNames: q.join(" "),
          content: E
        };
      }
    }, this.getContent = function(W, K, G) {
      var H = W.getChildAt(G);
      if (H === null)
        return "";
      var N = Q.getColumnTypeId(W, G);
      switch (N) {
        case j1.Timestamp:
          return Q.nanosToDate(H.get(K));
        default:
          return H.get(K);
      }
    }, this.dataTable = yL(J), this.indexTable = yL($), this.columnsTable = yL(X), this.styler = Y ? {
      caption: Y.caption,
      displayValuesTable: yL(Y.displayValues),
      styles: Y.styles,
      uuid: Y.uuid
    } : void 0;
  }
  return Object.defineProperty(Z.prototype, "rows", {
    get: function() {
      return this.indexTable.numRows + this.columnsTable.numCols;
    },
    enumerable: !1,
    configurable: !0
  }), Object.defineProperty(Z.prototype, "columns", {
    get: function() {
      return this.indexTable.numCols + this.columnsTable.numRows;
    },
    enumerable: !1,
    configurable: !0
  }), Object.defineProperty(Z.prototype, "headerRows", {
    get: function() {
      return this.rows - this.dataRows;
    },
    enumerable: !1,
    configurable: !0
  }), Object.defineProperty(Z.prototype, "headerColumns", {
    get: function() {
      return this.columns - this.dataColumns;
    },
    enumerable: !1,
    configurable: !0
  }), Object.defineProperty(Z.prototype, "dataRows", {
    get: function() {
      return this.dataTable.numRows;
    },
    enumerable: !1,
    configurable: !0
  }), Object.defineProperty(Z.prototype, "dataColumns", {
    get: function() {
      return this.dataTable.numCols;
    },
    enumerable: !1,
    configurable: !0
  }), Object.defineProperty(Z.prototype, "uuid", {
    get: function() {
      return this.styler && this.styler.uuid;
    },
    enumerable: !1,
    configurable: !0
  }), Object.defineProperty(Z.prototype, "caption", {
    get: function() {
      return this.styler && this.styler.caption;
    },
    enumerable: !1,
    configurable: !0
  }), Object.defineProperty(Z.prototype, "styles", {
    get: function() {
      return this.styler && this.styler.styles;
    },
    enumerable: !1,
    configurable: !0
  }), Object.defineProperty(Z.prototype, "table", {
    get: function() {
      return this.dataTable;
    },
    enumerable: !1,
    configurable: !0
  }), Object.defineProperty(Z.prototype, "index", {
    get: function() {
      return this.indexTable;
    },
    enumerable: !1,
    configurable: !0
  }), Object.defineProperty(Z.prototype, "columnTable", {
    get: function() {
      return this.columnsTable;
    },
    enumerable: !1,
    configurable: !0
  }), Z.prototype.serialize = function() {
    return {
      data: $M(this.dataTable),
      index: $M(this.indexTable),
      columns: $M(this.columnsTable)
    };
  }, Z.prototype.getColumnTypeId = function(J, $) {
    return J.schema.fields[$].type.typeId;
  }, Z.prototype.nanosToDate = function(J) {
    return new Date(J / 1e6);
  }, Z;
}();

// node_modules/streamlit-component-lib/dist/streamlit.js
var nT = function() {
  return nT = Object.assign || function(Z) {
    for (var J, $ = 1, X = arguments.length;$ < X; $++) {
      J = arguments[$];
      for (var Y in J)
        if (Object.prototype.hasOwnProperty.call(J, Y))
          Z[Y] = J[Y];
    }
    return Z;
  }, nT.apply(this, arguments);
}, iT;
(function(Z) {
  Z.COMPONENT_READY = "streamlit:componentReady", Z.SET_COMPONENT_VALUE = "streamlit:setComponentValue", Z.SET_FRAME_HEIGHT = "streamlit:setFrameHeight";
})(iT || (iT = {}));
var U5 = function() {
  function Z() {}
  return Z.API_VERSION = 1, Z.RENDER_EVENT = "streamlit:render", Z.events = new EventTarget, Z.registeredMessageListener = !1, Z.setComponentReady = function() {
    if (!Z.registeredMessageListener)
      window.addEventListener("message", Z.onMessageEvent), Z.registeredMessageListener = !0;
    Z.sendBackMsg(iT.COMPONENT_READY, {
      apiVersion: Z.API_VERSION
    });
  }, Z.setFrameHeight = function(J) {
    if (J === void 0)
      J = document.body.scrollHeight;
    if (J === Z.lastFrameHeight)
      return;
    Z.lastFrameHeight = J, Z.sendBackMsg(iT.SET_FRAME_HEIGHT, { height: J });
  }, Z.setComponentValue = function(J) {
    var $;
    if (J instanceof $S)
      $ = "dataframe", J = J.serialize();
    else if (Ns0(J))
      $ = "bytes", J = new Uint8Array(J.buffer);
    else if (J instanceof ArrayBuffer)
      $ = "bytes", J = new Uint8Array(J);
    else
      $ = "json";
    Z.sendBackMsg(iT.SET_COMPONENT_VALUE, {
      value: J,
      dataType: $
    });
  }, Z.onMessageEvent = function(J) {
    var $ = J.data.type;
    switch ($) {
      case Z.RENDER_EVENT:
        Z.onRenderMessage(J.data);
        break;
    }
  }, Z.onRenderMessage = function(J) {
    var $ = J.args;
    if ($ == null)
      console.error("Got null args in onRenderMessage. This should never happen"), $ = {};
    var X = J.dfs && J.dfs.length > 0 ? Z.argsDataframeToObject(J.dfs) : {};
    $ = nT(nT({}, $), X);
    var Y = Boolean(J.disabled), Q = J.theme;
    if (Q)
      Hs0(Q);
    var W = { disabled: Y, args: $, theme: Q }, K = new CustomEvent(Z.RENDER_EVENT, {
      detail: W
    });
    Z.events.dispatchEvent(K);
  }, Z.argsDataframeToObject = function(J) {
    var $ = J.map(function(X) {
      var { key: Y, value: Q } = X;
      return [Y, Z.toArrowTable(Q)];
    });
    return Object.fromEntries($);
  }, Z.toArrowTable = function(J) {
    var $, X = ($ = J.data, $.data), Y = $.index, Q = $.columns, W = $.styler;
    return new $S(X, Y, Q, W);
  }, Z.sendBackMsg = function(J, $) {
    window.parent.postMessage(nT({ isStreamlitMessage: !0, type: J }, $), "*");
  }, Z;
}(), Hs0 = function(Z) {
  var J = document.createElement("style");
  document.head.appendChild(J), J.innerHTML = `
    :root {
      --primary-color: `.concat(Z.primaryColor, `;
      --background-color: `).concat(Z.backgroundColor, `;
      --secondary-background-color: `).concat(Z.secondaryBackgroundColor, `;
      --text-color: `).concat(Z.textColor, `;
      --font: `).concat(Z.font, `;
    }

    body {
      background-color: var(--background-color);
      color: var(--text-color);
    }
  `);
};
function Ns0(Z) {
  var J = !1;
  try {
    J = Z instanceof BigInt64Array || Z instanceof BigUint64Array;
  } catch ($) {}
  return Z instanceof Int8Array || Z instanceof Uint8Array || Z instanceof Uint8ClampedArray || Z instanceof Int16Array || Z instanceof Uint16Array || Z instanceof Int32Array || Z instanceof Uint32Array || Z instanceof Float32Array || Z instanceof Float64Array || J;
}

// node_modules/streamlit-component-lib/dist/StreamlitReact.js
var MW0 = function() {
  var Z = function(J, $) {
    return Z = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(X, Y) {
      X.__proto__ = Y;
    } || function(X, Y) {
      for (var Q in Y)
        if (Object.prototype.hasOwnProperty.call(Y, Q))
          X[Q] = Y[Q];
    }, Z(J, $);
  };
  return function(J, $) {
    if (typeof $ !== "function" && $ !== null)
      throw new TypeError("Class extends value " + String($) + " is not a constructor or null");
    Z(J, $);
    function X() {
      this.constructor = J;
    }
    J.prototype = $ === null ? Object.create($) : (X.prototype = $.prototype, new X);
  };
}(), Hn = function(Z) {
  MW0(J, Z);
  function J() {
    return Z !== null && Z.apply(this, arguments) || this;
  }
  return J.prototype.componentDidMount = function() {
    U5.setFrameHeight();
  }, J.prototype.componentDidUpdate = function() {
    U5.setFrameHeight();
  }, J;
}(hO.default.PureComponent);
function Nn(Z) {
  var J = function($) {
    MW0(X, $);
    function X(Y) {
      var Q = $.call(this, Y) || this;
      return Q.componentDidMount = function() {
        U5.events.addEventListener(U5.RENDER_EVENT, Q.onRenderEvent), U5.setComponentReady();
      }, Q.componentDidUpdate = function() {
        if (Q.state.componentError != null)
          U5.setFrameHeight();
      }, Q.componentWillUnmount = function() {
        U5.events.removeEventListener(U5.RENDER_EVENT, Q.onRenderEvent);
      }, Q.onRenderEvent = function(W) {
        Q.setState({ renderData: W.detail });
      }, Q.state = {
        renderData: void 0,
        componentError: void 0
      }, Q;
    }
    return X.prototype.render = function() {
      if (this.state.componentError != null)
        return hO.default.createElement("div", null, hO.default.createElement("h1", null, "Component Error"), hO.default.createElement("span", null, this.state.componentError.message));
      if (this.state.renderData == null)
        return null;
      return hO.default.createElement(Z, { width: window.innerWidth, disabled: this.state.renderData.disabled, args: this.state.renderData.args, theme: this.state.renderData.theme });
    }, X.getDerivedStateFromError = function(Y) {
      return { componentError: Y };
    }, X;
  }(hO.default.PureComponent);
  return AW0.default(J, Z);
}
// src/StreamlitWrapper.tsx
var cH = t2(J7(), 1);

// src/MolstarCustomComponent.tsx
var xU = t2(J7(), 1);

// node_modules/molstar/lib/mol-util/bit-flags.js
var r7;
(function(Z) {
  function J(Y) {
    return Y;
  }
  Z.create = J;
  function $(Y, Q) {
    return (Y & Q) !== 0;
  }
  Z.has = $;
  function X(Y, Q) {
    return !!Q && (Y & Q) === Q;
  }
  Z.hasAll = X;
})(r7 || (r7 = {}));

// node_modules/molstar/lib/mol-util/string-builder.js
var UZ;
(function(Z) {
  function J(w = 512) {
    return {
      current: [],
      offset: 0,
      capacity: w,
      chunks: []
    };
  }
  Z.create = J;
  function $(w) {
    if (!w.chunks.length) {
      if (w.current.length === w.offset)
        return w.current.join("");
      return w.current.splice(0, w.offset).join("");
    }
    if (w.offset > 0)
      w.chunks[w.chunks.length] = w.current.length === w.offset ? w.current.join("") : w.current.slice(0, w.offset).join("");
    return w.chunks.join("");
  }
  Z.getString = $;
  function X(w) {
    let V = 0;
    for (let P of w.chunks)
      V += P.length;
    for (let P = 0;P < w.offset; P++)
      V += w.current[P].length;
    return V;
  }
  Z.getSize = X;
  function Y(w) {
    if (w.offset > 0) {
      if (w.current.length === w.offset)
        w.chunks[w.chunks.length] = w.current.join("");
      else
        w.chunks[w.chunks.length] = w.current.slice(0, w.offset).join("");
      w.offset = 0;
    }
    return w.chunks;
  }
  Z.getChunks = Y;
  let Q;
  (function(w) {
    w[w.Count = 512] = "Count";
  })(Q || (Q = {}));
  let W = [];
  (function() {
    let w = "";
    for (let V = 0;V < Q.Count; V++)
      W[V] = w, w = w + " ";
  })();
  function K(w) {
    q(w, `
`);
  }
  Z.newline = K;
  function G(w, V) {
    if (V > 0)
      q(w, W[V]);
  }
  Z.whitespace = G;
  function H(w) {
    q(w, " ");
  }
  Z.whitespace1 = H;
  function N(w, V) {
    if (!V)
      return;
    if (w.offset === w.capacity)
      w.chunks[w.chunks.length] = w.current.join(""), w.offset = 0;
    w.current[w.offset++] = V;
  }
  Z.write = N;
  function q(w, V) {
    if (w.offset === w.capacity)
      w.chunks[w.chunks.length] = w.current.join(""), w.offset = 0;
    w.current[w.offset++] = V;
  }
  Z.writeSafe = q;
  function U(w, V, P) {
    if (!V) {
      G(w, P);
      return;
    }
    let I = P - V.length;
    G(w, I), q(w, V);
  }
  Z.writePadLeft = U;
  function F(w, V, P) {
    if (!V) {
      G(w, P);
      return;
    }
    let I = P - V.length;
    q(w, V), G(w, I);
  }
  Z.writePadRight = F;
  function E(w, V) {
    q(w, "" + V);
  }
  Z.writeInteger = E;
  function R(w, V) {
    q(w, "" + V + " ");
  }
  Z.writeIntegerAndSpace = R;
  function z(w, V, P) {
    let I = "" + V, S = P - I.length;
    G(w, S), q(w, I);
  }
  Z.writeIntegerPadLeft = z;
  function D(w, V, P) {
    let I = "" + V, S = P - I.length;
    q(w, I), G(w, S);
  }
  Z.writeIntegerPadRight = D;
  function A(w, V, P) {
    q(w, "" + Math.round(P * V) / P);
  }
  Z.writeFloat = A;
  function B(w, V, P, I) {
    let S = "" + Math.round(P * V) / P, f = I - S.length;
    G(w, f), q(w, S);
  }
  Z.writeFloatPadLeft = B;
  function T(w, V, P, I) {
    let S = "" + Math.round(P * V) / P, f = I - S.length;
    q(w, S), G(w, f);
  }
  Z.writeFloatPadRight = T;
})(UZ || (UZ = {}));

// node_modules/molstar/lib/mol-util/now.js
var m6 = function() {
  if (typeof window !== "undefined" && window.performance) {
    let Z = window.performance;
    return () => Z.now();
  } else if (typeof process !== "undefined" && process.hrtime !== "undefined" && typeof process.hrtime === "function")
    return () => {
      let Z = process.hrtime();
      return Z[0] * 1000 + Z[1] / 1e6;
    };
  else if (Date.now)
    return () => Date.now();
  else
    return () => +/* @__PURE__ */ new Date;
}();
function XM(Z, J = !0) {
  if (isNaN(Z))
    return "n/a";
  let $ = Math.floor(Z / 3600000), X = Math.floor(Z / 60000 % 60), Y = Math.floor(Z / 1000 % 60), Q = Math.floor(Z % 1000).toString();
  while (Q.length < 3)
    Q = "0" + Q;
  while (!J && Q.length > 1 && Q[Q.length - 1] === "0")
    Q = Q.substr(0, Q.length - 1);
  if ($ > 0)
    return `${$}h${X}m${Y}.${Q}s`;
  if (X > 0)
    return `${X}m${Y}.${Q}s`;
  if (Y > 0)
    return `${Y}.${Q}s`;
  return `${Z.toFixed(0)}ms`;
}

// node_modules/molstar/lib/mol-util/uuid.js
var R6;
(function(Z) {
  let J = typeof btoa !== "undefined" ? btoa : (W) => Buffer.from(W).toString("base64"), $ = [];
  function X() {
    let W = +/* @__PURE__ */ new Date + m6();
    for (let K = 0;K < 16; K++)
      $[K] = String.fromCharCode((W + Math.random() * 255) % 255 | 0), W = Math.floor(W / 255);
    return J($.join("")).replace(/\+/g, "-").replace(/\//g, "_").substr(0, 22);
  }
  Z.create22 = X;
  function Y() {
    let W = +/* @__PURE__ */ new Date + m6();
    return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(G) {
      let H = (W + Math.random() * 16) % 16 | 0;
      return W = Math.floor(W / 16), (G === "x" ? H : H & 3 | 8).toString(16);
    });
  }
  Z.createv4 = Y;
  function Q(W) {
    return typeof W === "string";
  }
  Z.is = Q;
})(R6 || (R6 = {}));

// node_modules/molstar/lib/mol-util/mask.js
function qs0(Z, J) {
  return Z - J;
}
function Fs0(Z) {
  return Array.prototype.sort.call(Z, qs0), Z;
}
var qn;
(function(Z) {

  class J {
    has(F) {
      return !1;
    }
    forEach(F, E) {
      return E;
    }
    constructor() {
      this.size = 0;
    }
  }

  class $ {
    has(F) {
      return F === this.idx;
    }
    forEach(F, E) {
      return F(this.idx, E), E;
    }
    constructor(F) {
      this.idx = F, this.size = 1;
    }
  }

  class X {
    has(F) {
      return F < this.length && !!this.mask[F];
    }
    _forEach(F, E) {
      for (let R = 0;R < this.length; R++)
        if (this.mask[R])
          F(R, E);
    }
    forEach(F, E) {
      return this._forEach(F, E), E;
    }
    constructor(F, E) {
      this.mask = F, this.size = E, this.length = F.length;
    }
  }

  class Y {
    has(F) {
      return !0;
    }
    _forEach(F, E) {
      for (let R = 0;R < this.size; R++)
        F(R, E);
    }
    forEach(F, E) {
      return this._forEach(F, E), E;
    }
    constructor(F) {
      this.size = F;
    }
  }

  class Q {
    has(F) {
      return this.set.has(F);
    }
    _forEach(F, E) {
      for (let R of this.flatten())
        F(R, E);
    }
    flatten() {
      if (this._flat)
        return this._flat;
      let F = new Int32Array(this.size), E = 0;
      return this.set.forEach((R) => F[E++] = R), Fs0(F), this._flat = F, this._flat;
    }
    forEach(F, E) {
      return this._forEach(F, E), E;
    }
    constructor(F) {
      this.set = F, this._flat = void 0, this.size = F.size;
    }
  }
  function W(F) {
    return new Y(F);
  }
  Z.always = W, Z.never = new J;
  function K(F) {
    return new Q(F);
  }
  Z.ofSet = K;
  function G(F) {
    return new $(F);
  }
  Z.singleton = G;
  function H(F) {
    let E = F.length;
    if (E === 0)
      return new J;
    if (E === 1)
      return new $(F[0]);
    let R = 0;
    for (let A of F)
      if (A > R)
        R = A;
    if (E === R)
      return new Y(E);
    if (E / R < 0.08333333333333333) {
      let A = /* @__PURE__ */ new Set;
      for (let B of F)
        A.add(B);
      return new Q(A);
    }
    let D = new Int8Array(R + 1);
    for (let A of F)
      D[A] = 1;
    return new X(D, F.length);
  }
  Z.ofUniqueIndices = H;
  function N(F, E) {
    return new X(F, E);
  }
  Z.ofMask = N;
  function q(F, E) {
    for (let R of E)
      if (F.has(R))
        return !0;
    return !1;
  }
  Z.hasAny = q;
  function U(F, E) {
    let R = 0, z = 0;
    if (E.forEach((D) => {
      if (!F.has(D)) {
        if (R++, D > z)
          z = D;
      }
    }), R / z < 0.08333333333333333) {
      let D = /* @__PURE__ */ new Set;
      return E.forEach((A) => {
        if (!F.has(A))
          D.add(A);
      }), K(D);
    } else {
      let D = new Uint8Array(z + 1);
      return E.forEach((A) => {
        if (!F.has(A))
          D[A] = 1;
      }), N(D, R);
    }
  }
  Z.complement = U;
})(qn || (qn = {}));

// node_modules/molstar/lib/mol-util/id-factory.js
function $7(Z = 0, J = Number.MAX_SAFE_INTEGER) {
  let $ = Z;
  return () => {
    let X = $;
    return $ = ($ + 1) % J, X;
  };
}

// node_modules/molstar/lib/mol-util/value-cell.js
var oT;
(function(Z) {
  function J(X) {
    return { ref: X };
  }
  Z.create = J;
  function $(X, Y) {
    return X.ref = Y, X;
  }
  Z.set = $;
})(oT || (oT = {}));
var Us0 = $7(0, 2147483647), ON;
(function(Z) {
  function J(X, Y) {
    return { id: Us0(), version: 0, value: X, metadata: Y };
  }
  Z.create = J;
  function $(X, Y) {
    return { id: X.id, version: X.version + 1, value: Y, metadata: X.metadata };
  }
  Z.withValue = $;
})(ON || (ON = {}));
var C;
(function(Z) {
  function J(Q, W) {
    return oT.create(ON.create(Q, W));
  }
  Z.create = J;
  function $(Q, W) {
    return oT.set(Q, ON.withValue(Q.ref, W));
  }
  Z.update = $;
  function X(Q, W) {
    return oT.set(Q, W);
  }
  Z.set = X;
  function Y(Q, W) {
    return Q.ref.value !== W ? $(Q, W) : Q;
  }
  Z.updateIfChanged = Y;
})(C || (C = {}));
// node_modules/molstar/lib/mol-util/index.js
var xX = function() {};
function bO(Z, J) {
  let $ = Math.pow(10, J);
  return Math.round($ * Z) / $;
}
function b7(Z, J) {
  let $ = Z.length;
  if ($ !== J.length)
    return !1;
  for (let X = 0;X < $; X++)
    if (Z[X] !== J[X])
      return !1;
  return !0;
}
var wW0 = Object.prototype.hasOwnProperty;
function QY(Z, J) {
  if (Z === J)
    return !0;
  let $ = Array.isArray(Z), X = Array.isArray(J);
  if ($ && X) {
    if (Z.length !== J.length)
      return !1;
    for (let Y = 0;Y < Z.length; Y++)
      if (!QY(Z[Y], J[Y]))
        return !1;
    return !0;
  }
  if ($ !== X)
    return !1;
  if (Z && J && typeof Z === "object" && typeof J === "object") {
    let Y = Object.keys(Z);
    if (Y.length !== Object.keys(J).length)
      return !1;
    let Q = Z instanceof Date, W = J instanceof Date;
    if (Q && W)
      return Z.getTime() === J.getTime();
    if (Q !== W)
      return !1;
    let K = Z instanceof RegExp, G = J instanceof RegExp;
    if (K && G)
      return Z.toString() === J.toString();
    if (K !== G)
      return !1;
    for (let H = 0;H < Y.length; H++)
      if (!wW0.call(J, Y[H]))
        return !1;
    for (let H = 0;H < Y.length; H++)
      if (!QY(Z[Y[H]], J[Y[H]]))
        return !1;
    return !0;
  }
  return !1;
}
function xO(Z, J) {
  if (Z === J)
    return !0;
  let $ = Array.isArray(Z), X = Array.isArray(J);
  if ($ && X)
    return Ls0(Z, J);
  if ($ !== X)
    return !1;
  if (Z && J && typeof Z === "object" && typeof J === "object")
    return zN(Z, J);
  return !1;
}
function zN(Z, J) {
  if (Z === J)
    return !0;
  if (!Z || !J)
    return !1;
  let $ = Object.keys(Z);
  if (Object.keys(J).length !== $.length)
    return !1;
  for (let X of $)
    if (!wW0.call(Z, X) || Z[X] !== J[X])
      return !1;
  return !0;
}
function Ls0(Z, J) {
  if (Z === J)
    return !0;
  if (!Z || !J)
    return !1;
  if (Z.length !== J.length)
    return !1;
  for (let $ = 0, X = Z.length;$ < X; ++$)
    if (Z[$] !== J[$])
      return !1;
  return !0;
}
function t7(Z, J) {
  return Z !== void 0 ? Z : J;
}
function BW0(Z) {
  return (Z < 10 ? "0" : "") + Z;
}
function jW0(Z) {
  let J = Z.getHours(), $ = Z.getMinutes(), X = Z.getSeconds();
  return `${J}:${BW0($)}:${BW0(X)}`;
}

// node_modules/molstar/lib/mol-state/object.js
var LZ;
(function(Z) {
  function J() {
    return (Y) => $(Y);
  }
  Z.factory = J;
  function $(Y) {
    var Q;
    return Q = class W {
      static is(K) {
        return !!K && Y === K.type;
      }
      constructor(K, G) {
        this.data = K, this.id = R6.create22(), this.type = Y, this.label = G && G.label || Y.name, this.description = G && G.description;
      }
    }, Q.type = Y, Q;
  }
  Z.create = $;
  function X(Y, Q) {
    if (!Y.tags)
      return !1;
    for (let W of Y.tags)
      if (W === Q)
        return !0;
    return !1;
  }
  Z.hasTag = X, Z.Null = {
    id: R6.create22(),
    type: { name: "Null", typeClass: "Null" },
    data: void 0,
    label: "Null"
  };
})(LZ || (LZ = {}));
var YM;
(function(Z) {
  function J(X) {
    let Y = X;
    return !!Y && !!Y.transform && !!Y.parent && !!Y.status;
  }
  Z.is = J;
  function $(X, Y) {
    let Q = typeof Y === "string" ? Y : Z.is(Y) ? Y.transform.ref : Y.ref;
    return X.cells.get(Q);
  }
  Z.resolve = $;
})(YM || (YM = {}));
class sT {
  get cell() {
    var Z;
    return (Z = this.state) === null || Z === void 0 ? void 0 : Z.cells.get(this.ref);
  }
  get obj() {
    var Z, J;
    return (J = (Z = this.state) === null || Z === void 0 ? void 0 : Z.cells.get(this.ref)) === null || J === void 0 ? void 0 : J.obj;
  }
  get data() {
    var Z;
    return (Z = this.obj) === null || Z === void 0 ? void 0 : Z.data;
  }
  update(Z, J) {
    if (!this.state)
      throw new Error("To use update() from StateObjectSelector, 'state' must be defined.");
    if (!J)
      J = this.state.build();
    return (J || this.state.build()).to(this).update(Z), J;
  }
  checkValid() {
    if (!this.state)
      throw new Error("Unassigned State.");
    let Z = this.cell;
    if (!Z)
      throw new Error("Not created at all. Did you await/then the corresponding state update?");
    if (Z.status === "ok")
      return !0;
    if (Z.status === "error")
      throw new Error(Z.errorText);
    if (Z.obj === LZ.Null)
      throw new Error("The object is Null.");
    throw new Error("Unresolved. Did you await/then the corresponding state update?");
  }
  get isOk() {
    let Z = this.cell;
    return Z && Z.status === "ok" && Z.obj !== LZ.Null;
  }
  constructor(Z, J) {
    this.ref = Z, this.state = J;
  }
}
var X7;
(function(Z) {
  function J(Y) {
    var Q;
    if (!Y)
      return;
    if (typeof Y === "string")
      return Y;
    if (YM.is(Y))
      return Y.transform.ref;
    return (Q = Y.cell) === null || Q === void 0 ? void 0 : Q.transform.ref;
  }
  Z.resolveRef = J;
  function $(Y, Q) {
    if (!Q)
      return;
    if (YM.is(Q))
      return Q;
    if (typeof Q === "string")
      return Y.cells.get(Q);
    return Q.cell;
  }
  Z.resolve = $;
  function X(Y, Q) {
    let W = $(Y, Q);
    if (!W || !W.obj || W.status !== "ok")
      return;
    return W;
  }
  Z.resolveAndCheck = X;
})(X7 || (X7 = {}));
// node_modules/immutable/dist/immutable.es.js
var GS = "@@__IMMUTABLE_INDEXED__@@";
function F3(Z) {
  return Boolean(Z && Z[GS]);
}
var HS = "@@__IMMUTABLE_KEYED__@@";
function wJ(Z) {
  return Boolean(Z && Z[HS]);
}
function Vn(Z) {
  return wJ(Z) || F3(Z);
}
var sW0 = "@@__IMMUTABLE_ITERABLE__@@";
function RK(Z) {
  return Boolean(Z && Z[sW0]);
}
var kQ = function Z(J) {
  return RK(J) ? J : L5(J);
}, U3 = /* @__PURE__ */ function(Z) {
  function J($) {
    return wJ($) ? $ : cL($);
  }
  if (Z)
    J.__proto__ = Z;
  return J.prototype = Object.create(Z && Z.prototype), J.prototype.constructor = J, J;
}(kQ), gO = /* @__PURE__ */ function(Z) {
  function J($) {
    return F3($) ? $ : sG($);
  }
  if (Z)
    J.__proto__ = Z;
  return J.prototype = Object.create(Z && Z.prototype), J.prototype.constructor = J, J;
}(kQ), UM = /* @__PURE__ */ function(Z) {
  function J($) {
    return RK($) && !Vn($) ? $ : EM($);
  }
  if (Z)
    J.__proto__ = Z;
  return J.prototype = Object.create(Z && Z.prototype), J.prototype.constructor = J, J;
}(kQ);
kQ.Keyed = U3;
kQ.Indexed = gO;
kQ.Set = UM;
var LM = 0, EK = 1, OK = 2, zn = typeof Symbol === "function" && Symbol.iterator, aW0 = "@@iterator", FS = zn || aW0, g9 = function Z(J) {
  this.next = J;
};
g9.prototype.toString = function Z() {
  return "[Iterator]";
};
g9.KEYS = LM;
g9.VALUES = EK;
g9.ENTRIES = OK;
g9.prototype.inspect = g9.prototype.toSource = function() {
  return this.toString();
};
g9.prototype[FS] = function() {
  return this;
};
function jJ(Z, J, $, X) {
  var Y = Z === LM ? J : Z === EK ? $ : [J, $];
  return X ? X.value = Y : X = {
    value: Y,
    done: !1
  }, X;
}
function AW() {
  return { value: void 0, done: !0 };
}
function rW0(Z) {
  if (Array.isArray(Z))
    return !0;
  return !!US(Z);
}
function TW0(Z) {
  return !!(Z && typeof Z.next === "function");
}
function Dn(Z) {
  var J = US(Z);
  return J && J.call(Z);
}
function US(Z) {
  var J = Z && (zn && Z[zn] || Z[aW0]);
  if (typeof J === "function")
    return J;
}
function Rs0(Z) {
  var J = US(Z);
  return J && J === Z.entries;
}
function Es0(Z) {
  var J = US(Z);
  return J && J === Z.keys;
}
var K_ = "delete", y7 = 5, UK = 1 << y7, MW = UK - 1, w9 = {};
function Mn() {
  return { value: !1 };
}
function q3(Z) {
  if (Z)
    Z.value = !0;
}
function In() {}
function QM(Z) {
  if (Z.size === void 0)
    Z.size = Z.__iterate(tW0);
  return Z.size;
}
function dL(Z, J) {
  if (typeof J !== "number") {
    var $ = J >>> 0;
    if ("" + $ !== J || $ === 4294967295)
      return NaN;
    J = $;
  }
  return J < 0 ? QM(Z) + J : J;
}
function tW0() {
  return !0;
}
function LS(Z, J, $) {
  return (Z === 0 && !Z50(Z) || $ !== void 0 && Z <= -$) && (J === void 0 || $ !== void 0 && J >= $);
}
function G_(Z, J) {
  return eW0(Z, J, 0);
}
function RS(Z, J) {
  return eW0(Z, J, J);
}
function eW0(Z, J, $) {
  return Z === void 0 ? $ : Z50(Z) ? J === 1 / 0 ? J : Math.max(0, J + Z) | 0 : J === void 0 || J === Z ? Z : Math.min(J, Z) | 0;
}
function Z50(Z) {
  return Z < 0 || Z === 0 && 1 / Z === -1 / 0;
}
var J50 = "@@__IMMUTABLE_RECORD__@@";
function mO(Z) {
  return Boolean(Z && Z[J50]);
}
function BN(Z) {
  return RK(Z) || mO(Z);
}
var pL = "@@__IMMUTABLE_ORDERED__@@";
function AN(Z) {
  return Boolean(Z && Z[pL]);
}
var $50 = "@@__IMMUTABLE_SEQ__@@";
function Pn(Z) {
  return Boolean(Z && Z[$50]);
}
var RM = Object.prototype.hasOwnProperty;
function X50(Z) {
  if (Array.isArray(Z) || typeof Z === "string")
    return !0;
  return Z && typeof Z === "object" && Number.isInteger(Z.length) && Z.length >= 0 && (Z.length === 0 ? Object.keys(Z).length === 1 : Z.hasOwnProperty(Z.length - 1));
}
var L5 = /* @__PURE__ */ function(Z) {
  function J($) {
    return $ === void 0 || $ === null ? kn() : BN($) ? $.toSeq() : zs0($);
  }
  if (Z)
    J.__proto__ = Z;
  return J.prototype = Object.create(Z && Z.prototype), J.prototype.constructor = J, J.prototype.toSeq = function $() {
    return this;
  }, J.prototype.toString = function $() {
    return this.__toString("Seq {", "}");
  }, J.prototype.cacheResult = function $() {
    if (!this._cache && this.__iterateUncached)
      this._cache = this.entrySeq().toArray(), this.size = this._cache.length;
    return this;
  }, J.prototype.__iterate = function $(X, Y) {
    var Q = this._cache;
    if (Q) {
      var W = Q.length, K = 0;
      while (K !== W) {
        var G = Q[Y ? W - ++K : K++];
        if (X(G[1], G[0], this) === !1)
          break;
      }
      return K;
    }
    return this.__iterateUncached(X, Y);
  }, J.prototype.__iterator = function $(X, Y) {
    var Q = this._cache;
    if (Q) {
      var W = Q.length, K = 0;
      return new g9(function() {
        if (K === W)
          return AW();
        var G = Q[Y ? W - ++K : K++];
        return jJ(X, G[0], G[1]);
      });
    }
    return this.__iteratorUncached(X, Y);
  }, J;
}(kQ), cL = /* @__PURE__ */ function(Z) {
  function J($) {
    return $ === void 0 || $ === null ? kn().toKeyedSeq() : RK($) ? wJ($) ? $.toSeq() : $.fromEntrySeq() : mO($) ? $.toSeq() : vn($);
  }
  if (Z)
    J.__proto__ = Z;
  return J.prototype = Object.create(Z && Z.prototype), J.prototype.constructor = J, J.prototype.toKeyedSeq = function $() {
    return this;
  }, J;
}(L5), sG = /* @__PURE__ */ function(Z) {
  function J($) {
    return $ === void 0 || $ === null ? kn() : RK($) ? wJ($) ? $.entrySeq() : $.toIndexedSeq() : mO($) ? $.toSeq().entrySeq() : Y50($);
  }
  if (Z)
    J.__proto__ = Z;
  return J.prototype = Object.create(Z && Z.prototype), J.prototype.constructor = J, J.of = function $() {
    return J(arguments);
  }, J.prototype.toIndexedSeq = function $() {
    return this;
  }, J.prototype.toString = function $() {
    return this.__toString("Seq [", "]");
  }, J;
}(L5), EM = /* @__PURE__ */ function(Z) {
  function J($) {
    return (RK($) && !Vn($) ? $ : sG($)).toSetSeq();
  }
  if (Z)
    J.__proto__ = Z;
  return J.prototype = Object.create(Z && Z.prototype), J.prototype.constructor = J, J.of = function $() {
    return J(arguments);
  }, J.prototype.toSetSeq = function $() {
    return this;
  }, J;
}(L5);
L5.isSeq = Pn;
L5.Keyed = cL;
L5.Set = EM;
L5.Indexed = sG;
L5.prototype[$50] = !0;
var WM = /* @__PURE__ */ function(Z) {
  function J($) {
    this._array = $, this.size = $.length;
  }
  if (Z)
    J.__proto__ = Z;
  return J.prototype = Object.create(Z && Z.prototype), J.prototype.constructor = J, J.prototype.get = function $(X, Y) {
    return this.has(X) ? this._array[dL(this, X)] : Y;
  }, J.prototype.__iterate = function $(X, Y) {
    var Q = this._array, W = Q.length, K = 0;
    while (K !== W) {
      var G = Y ? W - ++K : K++;
      if (X(Q[G], G, this) === !1)
        break;
    }
    return K;
  }, J.prototype.__iterator = function $(X, Y) {
    var Q = this._array, W = Q.length, K = 0;
    return new g9(function() {
      if (K === W)
        return AW();
      var G = Y ? W - ++K : K++;
      return jJ(X, G, Q[G]);
    });
  }, J;
}(sG), Cn = /* @__PURE__ */ function(Z) {
  function J($) {
    var X = Object.keys($).concat(Object.getOwnPropertySymbols ? Object.getOwnPropertySymbols($) : []);
    this._object = $, this._keys = X, this.size = X.length;
  }
  if (Z)
    J.__proto__ = Z;
  return J.prototype = Object.create(Z && Z.prototype), J.prototype.constructor = J, J.prototype.get = function $(X, Y) {
    if (Y !== void 0 && !this.has(X))
      return Y;
    return this._object[X];
  }, J.prototype.has = function $(X) {
    return RM.call(this._object, X);
  }, J.prototype.__iterate = function $(X, Y) {
    var Q = this._object, W = this._keys, K = W.length, G = 0;
    while (G !== K) {
      var H = W[Y ? K - ++G : G++];
      if (X(Q[H], H, this) === !1)
        break;
    }
    return G;
  }, J.prototype.__iterator = function $(X, Y) {
    var Q = this._object, W = this._keys, K = W.length, G = 0;
    return new g9(function() {
      if (G === K)
        return AW();
      var H = W[Y ? K - ++G : G++];
      return jJ(X, H, Q[H]);
    });
  }, J;
}(cL);
Cn.prototype[pL] = !0;
var Os0 = /* @__PURE__ */ function(Z) {
  function J($) {
    this._collection = $, this.size = $.length || $.size;
  }
  if (Z)
    J.__proto__ = Z;
  return J.prototype = Object.create(Z && Z.prototype), J.prototype.constructor = J, J.prototype.__iterateUncached = function $(X, Y) {
    if (Y)
      return this.cacheResult().__iterate(X, Y);
    var Q = this._collection, W = Dn(Q), K = 0;
    if (TW0(W)) {
      var G;
      while (!(G = W.next()).done)
        if (X(G.value, K++, this) === !1)
          break;
    }
    return K;
  }, J.prototype.__iteratorUncached = function $(X, Y) {
    if (Y)
      return this.cacheResult().__iterator(X, Y);
    var Q = this._collection, W = Dn(Q);
    if (!TW0(W))
      return new g9(AW);
    var K = 0;
    return new g9(function() {
      var G = W.next();
      return G.done ? G : jJ(X, K++, G.value);
    });
  }, J;
}(sG), _W0;
function kn() {
  return _W0 || (_W0 = new WM([]));
}
function vn(Z) {
  var J = Sn(Z);
  if (J)
    return J.fromEntrySeq();
  if (typeof Z === "object")
    return new Cn(Z);
  throw new TypeError("Expected Array or collection object of [k, v] entries, or keyed object: " + Z);
}
function Y50(Z) {
  var J = Sn(Z);
  if (J)
    return J;
  throw new TypeError("Expected Array or collection object of values: " + Z);
}
function zs0(Z) {
  var J = Sn(Z);
  if (J)
    return Rs0(Z) ? J.fromEntrySeq() : Es0(Z) ? J.toSetSeq() : J;
  if (typeof Z === "object")
    return new Cn(Z);
  throw new TypeError("Expected Array or collection object of values, or keyed object: " + Z);
}
function Sn(Z) {
  return X50(Z) ? new WM(Z) : rW0(Z) ? new Os0(Z) : void 0;
}
function H_() {
  return this.__ensureOwner();
}
function N_() {
  return this.__ownerID ? this : this.__ensureOwner(new In);
}
var aT = typeof Math.imul === "function" && Math.imul(4294967295, 2) === -2 ? Math.imul : function Z(J, $) {
  J |= 0, $ |= 0;
  var X = J & 65535, Y = $ & 65535;
  return X * Y + ((J >>> 16) * Y + X * ($ >>> 16) << 16 >>> 0) | 0;
};
function ES(Z) {
  return Z >>> 1 & 1073741824 | Z & 3221225471;
}
var Ds0 = Object.prototype.valueOf;
function qK(Z) {
  if (Z == null)
    return VW0(Z);
  if (typeof Z.hashCode === "function")
    return ES(Z.hashCode(Z));
  var J = Ts0(Z);
  if (J == null)
    return VW0(J);
  switch (typeof J) {
    case "boolean":
      return J ? 1108378657 : 1108378656;
    case "number":
      return Ms0(J);
    case "string":
      return J.length > _s0 ? As0(J) : An(J);
    case "object":
    case "function":
      return ws0(J);
    case "symbol":
      return Bs0(J);
    default:
      if (typeof J.toString === "function")
        return An(J.toString());
      throw new Error("Value type " + typeof J + " cannot be hashed.");
  }
}
function VW0(Z) {
  return Z === null ? 1108378658 : 1108378659;
}
function Ms0(Z) {
  if (Z !== Z || Z === 1 / 0)
    return 0;
  var J = Z | 0;
  if (J !== Z)
    J ^= Z * 4294967295;
  while (Z > 4294967295)
    Z /= 4294967295, J ^= Z;
  return ES(J);
}
function As0(Z) {
  var J = Ln[Z];
  if (J === void 0) {
    if (J = An(Z), Un === Vs0)
      Un = 0, Ln = {};
    Un++, Ln[Z] = J;
  }
  return J;
}
function An(Z) {
  var J = 0;
  for (var $ = 0;$ < Z.length; $++)
    J = 31 * J + Z.charCodeAt($) | 0;
  return ES(J);
}
function Bs0(Z) {
  var J = CW0[Z];
  if (J !== void 0)
    return J;
  return J = Q50(), CW0[Z] = J, J;
}
function ws0(Z) {
  var J;
  if (Bn) {
    if (J = wn.get(Z), J !== void 0)
      return J;
  }
  if (J = Z[yO], J !== void 0)
    return J;
  if (!PW0) {
    if (J = Z.propertyIsEnumerable && Z.propertyIsEnumerable[yO], J !== void 0)
      return J;
    if (J = js0(Z), J !== void 0)
      return J;
  }
  if (J = Q50(), Bn)
    wn.set(Z, J);
  else if (IW0 !== void 0 && IW0(Z) === !1)
    throw new Error("Non-extensible objects are not allowed as keys.");
  else if (PW0)
    Object.defineProperty(Z, yO, {
      enumerable: !1,
      configurable: !1,
      writable: !1,
      value: J
    });
  else if (Z.propertyIsEnumerable !== void 0 && Z.propertyIsEnumerable === Z.constructor.prototype.propertyIsEnumerable)
    Z.propertyIsEnumerable = function() {
      return this.constructor.prototype.propertyIsEnumerable.apply(this, arguments);
    }, Z.propertyIsEnumerable[yO] = J;
  else if (Z.nodeType !== void 0)
    Z[yO] = J;
  else
    throw new Error("Unable to set a non-enumerable property on object.");
  return J;
}
var IW0 = Object.isExtensible, PW0 = function() {
  try {
    return Object.defineProperty({}, "@", {}), !0;
  } catch (Z) {
    return !1;
  }
}();
function js0(Z) {
  if (Z && Z.nodeType > 0)
    switch (Z.nodeType) {
      case 1:
        return Z.uniqueID;
      case 9:
        return Z.documentElement && Z.documentElement.uniqueID;
    }
}
function Ts0(Z) {
  return Z.valueOf !== Ds0 && typeof Z.valueOf === "function" ? Z.valueOf(Z) : Z;
}
function Q50() {
  var Z = ++Fn;
  if (Fn & 1073741824)
    Fn = 0;
  return Z;
}
var Bn = typeof WeakMap === "function", wn;
if (Bn)
  wn = /* @__PURE__ */ new WeakMap;
var CW0 = Object.create(null), Fn = 0, yO = "__immutablehash__";
if (typeof Symbol === "function")
  yO = Symbol(yO);
var _s0 = 16, Vs0 = 255, Un = 0, Ln = {}, OS = /* @__PURE__ */ function(Z) {
  function J($, X) {
    this._iter = $, this._useKeys = X, this.size = $.size;
  }
  if (Z)
    J.__proto__ = Z;
  return J.prototype = Object.create(Z && Z.prototype), J.prototype.constructor = J, J.prototype.get = function $(X, Y) {
    return this._iter.get(X, Y);
  }, J.prototype.has = function $(X) {
    return this._iter.has(X);
  }, J.prototype.valueSeq = function $() {
    return this._iter.valueSeq();
  }, J.prototype.reverse = function $() {
    var X = this, Y = fn(this, !0);
    if (!this._useKeys)
      Y.valueSeq = function() {
        return X._iter.toSeq().reverse();
      };
    return Y;
  }, J.prototype.map = function $(X, Y) {
    var Q = this, W = N50(this, X, Y);
    if (!this._useKeys)
      W.valueSeq = function() {
        return Q._iter.toSeq().map(X, Y);
      };
    return W;
  }, J.prototype.__iterate = function $(X, Y) {
    var Q = this;
    return this._iter.__iterate(function(W, K) {
      return X(W, K, Q);
    }, Y);
  }, J.prototype.__iterator = function $(X, Y) {
    return this._iter.__iterator(X, Y);
  }, J;
}(cL);
OS.prototype[pL] = !0;
var W50 = /* @__PURE__ */ function(Z) {
  function J($) {
    this._iter = $, this.size = $.size;
  }
  if (Z)
    J.__proto__ = Z;
  return J.prototype = Object.create(Z && Z.prototype), J.prototype.constructor = J, J.prototype.includes = function $(X) {
    return this._iter.includes(X);
  }, J.prototype.__iterate = function $(X, Y) {
    var Q = this, W = 0;
    return Y && QM(this), this._iter.__iterate(function(K) {
      return X(K, Y ? Q.size - ++W : W++, Q);
    }, Y);
  }, J.prototype.__iterator = function $(X, Y) {
    var Q = this, W = this._iter.__iterator(EK, Y), K = 0;
    return Y && QM(this), new g9(function() {
      var G = W.next();
      return G.done ? G : jJ(X, Y ? Q.size - ++K : K++, G.value, G);
    });
  }, J;
}(sG), K50 = /* @__PURE__ */ function(Z) {
  function J($) {
    this._iter = $, this.size = $.size;
  }
  if (Z)
    J.__proto__ = Z;
  return J.prototype = Object.create(Z && Z.prototype), J.prototype.constructor = J, J.prototype.has = function $(X) {
    return this._iter.includes(X);
  }, J.prototype.__iterate = function $(X, Y) {
    var Q = this;
    return this._iter.__iterate(function(W) {
      return X(W, W, Q);
    }, Y);
  }, J.prototype.__iterator = function $(X, Y) {
    var Q = this._iter.__iterator(EK, Y);
    return new g9(function() {
      var W = Q.next();
      return W.done ? W : jJ(X, W.value, W.value, W);
    });
  }, J;
}(EM), G50 = /* @__PURE__ */ function(Z) {
  function J($) {
    this._iter = $, this.size = $.size;
  }
  if (Z)
    J.__proto__ = Z;
  return J.prototype = Object.create(Z && Z.prototype), J.prototype.constructor = J, J.prototype.entrySeq = function $() {
    return this._iter.toSeq();
  }, J.prototype.__iterate = function $(X, Y) {
    var Q = this;
    return this._iter.__iterate(function(W) {
      if (W) {
        vW0(W);
        var K = RK(W);
        return X(K ? W.get(1) : W[1], K ? W.get(0) : W[0], Q);
      }
    }, Y);
  }, J.prototype.__iterator = function $(X, Y) {
    var Q = this._iter.__iterator(EK, Y);
    return new g9(function() {
      while (!0) {
        var W = Q.next();
        if (W.done)
          return W;
        var K = W.value;
        if (K) {
          vW0(K);
          var G = RK(K);
          return jJ(X, G ? K.get(0) : K[0], G ? K.get(1) : K[1], W);
        }
      }
    });
  }, J;
}(cL);
W50.prototype.cacheResult = OS.prototype.cacheResult = K50.prototype.cacheResult = G50.prototype.cacheResult = xn;
function H50(Z) {
  var J = wN(Z);
  return J._iter = Z, J.size = Z.size, J.flip = function() {
    return Z;
  }, J.reverse = function() {
    var $ = Z.reverse.apply(this);
    return $.flip = function() {
      return Z.reverse();
    }, $;
  }, J.has = function($) {
    return Z.includes($);
  }, J.includes = function($) {
    return Z.has($);
  }, J.cacheResult = xn, J.__iterateUncached = function($, X) {
    var Y = this;
    return Z.__iterate(function(Q, W) {
      return $(W, Q, Y) !== !1;
    }, X);
  }, J.__iteratorUncached = function($, X) {
    if ($ === OK) {
      var Y = Z.__iterator($, X);
      return new g9(function() {
        var Q = Y.next();
        if (!Q.done) {
          var W = Q.value[0];
          Q.value[0] = Q.value[1], Q.value[1] = W;
        }
        return Q;
      });
    }
    return Z.__iterator($ === EK ? LM : EK, X);
  }, J;
}
function N50(Z, J, $) {
  var X = wN(Z);
  return X.size = Z.size, X.has = function(Y) {
    return Z.has(Y);
  }, X.get = function(Y, Q) {
    var W = Z.get(Y, w9);
    return W === w9 ? Q : J.call($, W, Y, Z);
  }, X.__iterateUncached = function(Y, Q) {
    var W = this;
    return Z.__iterate(function(K, G, H) {
      return Y(J.call($, K, G, H), G, W) !== !1;
    }, Q);
  }, X.__iteratorUncached = function(Y, Q) {
    var W = Z.__iterator(OK, Q);
    return new g9(function() {
      var K = W.next();
      if (K.done)
        return K;
      var G = K.value, H = G[0];
      return jJ(Y, H, J.call($, G[1], H, Z), K);
    });
  }, X;
}
function fn(Z, J) {
  var $ = this, X = wN(Z);
  if (X._iter = Z, X.size = Z.size, X.reverse = function() {
    return Z;
  }, Z.flip)
    X.flip = function() {
      var Y = H50(Z);
      return Y.reverse = function() {
        return Z.flip();
      }, Y;
    };
  return X.get = function(Y, Q) {
    return Z.get(J ? Y : -1 - Y, Q);
  }, X.has = function(Y) {
    return Z.has(J ? Y : -1 - Y);
  }, X.includes = function(Y) {
    return Z.includes(Y);
  }, X.cacheResult = xn, X.__iterate = function(Y, Q) {
    var W = this, K = 0;
    return Q && QM(Z), Z.__iterate(function(G, H) {
      return Y(G, J ? H : Q ? W.size - ++K : K++, W);
    }, !Q);
  }, X.__iterator = function(Y, Q) {
    var W = 0;
    Q && QM(Z);
    var K = Z.__iterator(OK, !Q);
    return new g9(function() {
      var G = K.next();
      if (G.done)
        return G;
      var H = G.value;
      return jJ(Y, J ? H[0] : Q ? $.size - ++W : W++, H[1], G);
    });
  }, X;
}
function q50(Z, J, $, X) {
  var Y = wN(Z);
  if (X)
    Y.has = function(Q) {
      var W = Z.get(Q, w9);
      return W !== w9 && !!J.call($, W, Q, Z);
    }, Y.get = function(Q, W) {
      var K = Z.get(Q, w9);
      return K !== w9 && J.call($, K, Q, Z) ? K : W;
    };
  return Y.__iterateUncached = function(Q, W) {
    var K = this, G = 0;
    return Z.__iterate(function(H, N, q) {
      if (J.call($, H, N, q))
        return G++, Q(H, X ? N : G - 1, K);
    }, W), G;
  }, Y.__iteratorUncached = function(Q, W) {
    var K = Z.__iterator(OK, W), G = 0;
    return new g9(function() {
      while (!0) {
        var H = K.next();
        if (H.done)
          return H;
        var N = H.value, q = N[0], U = N[1];
        if (J.call($, U, q, Z))
          return jJ(Q, X ? q : G++, U, H);
      }
    });
  }, Y;
}
function Is0(Z, J, $) {
  var X = DK().asMutable();
  return Z.__iterate(function(Y, Q) {
    X.update(J.call($, Y, Q, Z), 0, function(W) {
      return W + 1;
    });
  }), X.asImmutable();
}
function Ps0(Z, J, $) {
  var X = wJ(Z), Y = (AN(Z) ? o$() : DK()).asMutable();
  Z.__iterate(function(W, K) {
    Y.update(J.call($, W, K, Z), function(G) {
      return G = G || [], G.push(X ? [K, W] : W), G;
    });
  });
  var Q = bn(Z);
  return Y.map(function(W) {
    return x7(Z, Q(W));
  }).asImmutable();
}
function Cs0(Z, J, $) {
  var X = wJ(Z), Y = [[], []];
  Z.__iterate(function(W, K) {
    Y[J.call($, W, K, Z) ? 1 : 0].push(X ? [K, W] : W);
  });
  var Q = bn(Z);
  return Y.map(function(W) {
    return x7(Z, Q(W));
  });
}
function hn(Z, J, $, X) {
  var Y = Z.size;
  if (LS(J, $, Y))
    return Z;
  if (typeof Y === "undefined" && (J < 0 || $ < 0))
    return hn(Z.toSeq().cacheResult(), J, $, X);
  var Q = G_(J, Y), W = RS($, Y), K = W - Q, G;
  if (K === K)
    G = K < 0 ? 0 : K;
  var H = wN(Z);
  if (H.size = G === 0 ? G : Z.size && G || void 0, !X && Pn(Z) && G >= 0)
    H.get = function(N, q) {
      return N = dL(this, N), N >= 0 && N < G ? Z.get(N + Q, q) : q;
    };
  return H.__iterateUncached = function(N, q) {
    var U = this;
    if (G === 0)
      return 0;
    if (q)
      return this.cacheResult().__iterate(N, q);
    var F = 0, E = !0, R = 0;
    return Z.__iterate(function(z, D) {
      if (!(E && (E = F++ < Q)))
        return R++, N(z, X ? D : R - 1, U) !== !1 && R !== G;
    }), R;
  }, H.__iteratorUncached = function(N, q) {
    if (G !== 0 && q)
      return this.cacheResult().__iterator(N, q);
    if (G === 0)
      return new g9(AW);
    var U = Z.__iterator(N, q), F = 0, E = 0;
    return new g9(function() {
      while (F++ < Q)
        U.next();
      if (++E > G)
        return AW();
      var R = U.next();
      if (X || N === EK || R.done)
        return R;
      if (N === LM)
        return jJ(N, E - 1, void 0, R);
      return jJ(N, E - 1, R.value[1], R);
    });
  }, H;
}
function ks0(Z, J, $) {
  var X = wN(Z);
  return X.__iterateUncached = function(Y, Q) {
    var W = this;
    if (Q)
      return this.cacheResult().__iterate(Y, Q);
    var K = 0;
    return Z.__iterate(function(G, H, N) {
      return J.call($, G, H, N) && ++K && Y(G, H, W);
    }), K;
  }, X.__iteratorUncached = function(Y, Q) {
    var W = this;
    if (Q)
      return this.cacheResult().__iterator(Y, Q);
    var K = Z.__iterator(OK, Q), G = !0;
    return new g9(function() {
      if (!G)
        return AW();
      var H = K.next();
      if (H.done)
        return H;
      var N = H.value, q = N[0], U = N[1];
      if (!J.call($, U, q, W))
        return G = !1, AW();
      return Y === OK ? H : jJ(Y, q, U, H);
    });
  }, X;
}
function F50(Z, J, $, X) {
  var Y = wN(Z);
  return Y.__iterateUncached = function(Q, W) {
    var K = this;
    if (W)
      return this.cacheResult().__iterate(Q, W);
    var G = !0, H = 0;
    return Z.__iterate(function(N, q, U) {
      if (!(G && (G = J.call($, N, q, U))))
        return H++, Q(N, X ? q : H - 1, K);
    }), H;
  }, Y.__iteratorUncached = function(Q, W) {
    var K = this;
    if (W)
      return this.cacheResult().__iterator(Q, W);
    var G = Z.__iterator(OK, W), H = !0, N = 0;
    return new g9(function() {
      var q, U, F;
      do {
        if (q = G.next(), q.done) {
          if (X || Q === EK)
            return q;
          if (Q === LM)
            return jJ(Q, N++, void 0, q);
          return jJ(Q, N++, q.value[1], q);
        }
        var E = q.value;
        U = E[0], F = E[1], H && (H = J.call($, F, U, K));
      } while (H);
      return Q === OK ? q : jJ(Q, U, F, q);
    });
  }, Y;
}
var vs0 = /* @__PURE__ */ function(Z) {
  function J($) {
    this._wrappedIterables = $.flatMap(function(X) {
      if (X._wrappedIterables)
        return X._wrappedIterables;
      return [X];
    }), this.size = this._wrappedIterables.reduce(function(X, Y) {
      if (X !== void 0) {
        var Q = Y.size;
        if (Q !== void 0)
          return X + Q;
      }
    }, 0), this[HS] = this._wrappedIterables[0][HS], this[GS] = this._wrappedIterables[0][GS], this[pL] = this._wrappedIterables[0][pL];
  }
  if (Z)
    J.__proto__ = Z;
  return J.prototype = Object.create(Z && Z.prototype), J.prototype.constructor = J, J.prototype.__iterateUncached = function $(X, Y) {
    if (this._wrappedIterables.length === 0)
      return;
    if (Y)
      return this.cacheResult().__iterate(X, Y);
    var Q = 0, W = wJ(this), K = W ? OK : EK, G = this._wrappedIterables[Q].__iterator(K, Y), H = !0, N = 0;
    while (H) {
      var q = G.next();
      while (q.done) {
        if (Q++, Q === this._wrappedIterables.length)
          return N;
        G = this._wrappedIterables[Q].__iterator(K, Y), q = G.next();
      }
      var U = W ? X(q.value[1], q.value[0], this) : X(q.value, N, this);
      H = U !== !1, N++;
    }
    return N;
  }, J.prototype.__iteratorUncached = function $(X, Y) {
    var Q = this;
    if (this._wrappedIterables.length === 0)
      return new g9(AW);
    if (Y)
      return this.cacheResult().__iterator(X, Y);
    var W = 0, K = this._wrappedIterables[W].__iterator(X, Y);
    return new g9(function() {
      var G = K.next();
      while (G.done) {
        if (W++, W === Q._wrappedIterables.length)
          return G;
        K = Q._wrappedIterables[W].__iterator(X, Y), G = K.next();
      }
      return G;
    });
  }, J;
}(L5);
function Ss0(Z, J) {
  var $ = wJ(Z), X = [Z].concat(J).map(function(Q) {
    if (!RK(Q))
      Q = $ ? vn(Q) : Y50(Array.isArray(Q) ? Q : [Q]);
    else if ($)
      Q = U3(Q);
    return Q;
  }).filter(function(Q) {
    return Q.size !== 0;
  });
  if (X.length === 0)
    return Z;
  if (X.length === 1) {
    var Y = X[0];
    if (Y === Z || $ && wJ(Y) || F3(Z) && F3(Y))
      return Y;
  }
  return new vs0(X);
}
function U50(Z, J, $) {
  var X = wN(Z);
  return X.__iterateUncached = function(Y, Q) {
    if (Q)
      return this.cacheResult().__iterate(Y, Q);
    var W = 0, K = !1;
    function G(H, N) {
      H.__iterate(function(q, U) {
        if ((!J || N < J) && RK(q))
          G(q, N + 1);
        else if (W++, Y(q, $ ? U : W - 1, X) === !1)
          K = !0;
        return !K;
      }, Q);
    }
    return G(Z, 0), W;
  }, X.__iteratorUncached = function(Y, Q) {
    if (Q)
      return this.cacheResult().__iterator(Y, Q);
    var W = Z.__iterator(Y, Q), K = [], G = 0;
    return new g9(function() {
      while (W) {
        var H = W.next();
        if (H.done !== !1) {
          W = K.pop();
          continue;
        }
        var N = H.value;
        if (Y === OK)
          N = N[1];
        if ((!J || K.length < J) && RK(N))
          K.push(W), W = N.__iterator(Y, Q);
        else
          return $ ? H : jJ(Y, G++, N, H);
      }
      return AW();
    });
  }, X;
}
function fs0(Z, J, $) {
  var X = bn(Z);
  return Z.toSeq().map(function(Y, Q) {
    return X(J.call($, Y, Q, Z));
  }).flatten(!0);
}
function hs0(Z, J) {
  var $ = wN(Z);
  return $.size = Z.size && Z.size * 2 - 1, $.__iterateUncached = function(X, Y) {
    var Q = this, W = 0;
    return Z.__iterate(function(K) {
      return (!W || X(J, W++, Q) !== !1) && X(K, W++, Q) !== !1;
    }, Y), W;
  }, $.__iteratorUncached = function(X, Y) {
    var Q = Z.__iterator(EK, Y), W = 0, K;
    return new g9(function() {
      if (!K || W % 2) {
        if (K = Q.next(), K.done)
          return K;
      }
      return W % 2 ? jJ(X, W++, J) : jJ(X, W++, K.value, K);
    });
  }, $;
}
function KM(Z, J, $) {
  if (!J)
    J = L50;
  var X = wJ(Z), Y = 0, Q = Z.toSeq().map(function(W, K) {
    return [K, W, Y++, $ ? $(W, K, Z) : W];
  }).valueSeq().toArray();
  return Q.sort(function(W, K) {
    return J(W[3], K[3]) || W[2] - K[2];
  }).forEach(X ? function(W, K) {
    Q[K].length = 2;
  } : function(W, K) {
    Q[K] = W[1];
  }), X ? cL(Q) : F3(Z) ? sG(Q) : EM(Q);
}
function XS(Z, J, $) {
  if (!J)
    J = L50;
  if ($) {
    var X = Z.toSeq().map(function(Y, Q) {
      return [Y, $(Y, Q, Z)];
    }).reduce(function(Y, Q) {
      return kW0(J, Y[1], Q[1]) ? Q : Y;
    });
    return X && X[0];
  }
  return Z.reduce(function(Y, Q) {
    return kW0(J, Y, Q) ? Q : Y;
  });
}
function kW0(Z, J, $) {
  var X = Z($, J);
  return X === 0 && $ !== J && ($ === void 0 || $ === null || $ !== $) || X > 0;
}
function YS(Z, J, $, X) {
  var Y = wN(Z), Q = new WM($).map(function(W) {
    return W.size;
  });
  return Y.size = X ? Q.max() : Q.min(), Y.__iterate = function(W, K) {
    var G = this.__iterator(EK, K), H, N = 0;
    while (!(H = G.next()).done)
      if (W(H.value, N++, this) === !1)
        break;
    return N;
  }, Y.__iteratorUncached = function(W, K) {
    var G = $.map(function(q) {
      return q = kQ(q), Dn(K ? q.reverse() : q);
    }), H = 0, N = !1;
    return new g9(function() {
      var q;
      if (!N)
        q = G.map(function(U) {
          return U.next();
        }), N = X ? q.every(function(U) {
          return U.done;
        }) : q.some(function(U) {
          return U.done;
        });
      if (N)
        return AW();
      return jJ(W, H++, J.apply(null, q.map(function(U) {
        return U.value;
      })));
    });
  }, Y;
}
function x7(Z, J) {
  return Z === J ? Z : Pn(Z) ? J : Z.constructor(J);
}
function vW0(Z) {
  if (Z !== Object(Z))
    throw new TypeError("Expected [K, V] tuple: " + Z);
}
function bn(Z) {
  return wJ(Z) ? U3 : F3(Z) ? gO : UM;
}
function wN(Z) {
  return Object.create((wJ(Z) ? cL : F3(Z) ? sG : EM).prototype);
}
function xn() {
  if (this._iter.cacheResult)
    return this._iter.cacheResult(), this.size = this._iter.size, this;
  return L5.prototype.cacheResult.call(this);
}
function L50(Z, J) {
  if (Z === void 0 && J === void 0)
    return 0;
  if (Z === void 0)
    return 1;
  if (J === void 0)
    return -1;
  return Z > J ? 1 : Z < J ? -1 : 0;
}
function SW0(Z) {
  return Boolean(Z && typeof Z.equals === "function" && typeof Z.hashCode === "function");
}
function LK(Z, J) {
  if (Z === J || Z !== Z && J !== J)
    return !0;
  if (!Z || !J)
    return !1;
  if (typeof Z.valueOf === "function" && typeof J.valueOf === "function") {
    if (Z = Z.valueOf(), J = J.valueOf(), Z === J || Z !== Z && J !== J)
      return !0;
    if (!Z || !J)
      return !1;
  }
  return !!(SW0(Z) && SW0(J) && Z.equals(J));
}
function R50(Z, J, $, X) {
  return OM(Z, [J], $, X);
}
function E50() {
  var Z = [], J = arguments.length;
  while (J--)
    Z[J] = arguments[J];
  return z50(this, Z);
}
function O50(Z) {
  var J = [], $ = arguments.length - 1;
  while ($-- > 0)
    J[$] = arguments[$ + 1];
  if (typeof Z !== "function")
    throw new TypeError("Invalid merger function: " + Z);
  return z50(this, J, Z);
}
function z50(Z, J, $) {
  var X = [];
  for (var Y = 0;Y < J.length; Y++) {
    var Q = U3(J[Y]);
    if (Q.size !== 0)
      X.push(Q);
  }
  if (X.length === 0)
    return Z;
  if (Z.toSeq().size === 0 && !Z.__ownerID && X.length === 1)
    return mO(Z) ? Z : Z.constructor(X[0]);
  return Z.withMutations(function(W) {
    var K = $ ? function(H, N) {
      R50(W, N, w9, function(q) {
        return q === w9 ? H : $(q, H, N);
      });
    } : function(H, N) {
      W.set(N, H);
    };
    for (var G = 0;G < X.length; G++)
      X[G].forEach(K);
  });
}
var bs0 = Object.prototype.toString;
function xs0(Z) {
  if (!Z || typeof Z !== "object" || bs0.call(Z) !== "[object Object]")
    return !1;
  var J = Object.getPrototypeOf(Z);
  if (J === null)
    return !0;
  var $ = J, X = Object.getPrototypeOf(J);
  while (X !== null)
    $ = X, X = Object.getPrototypeOf($);
  return $ === J;
}
function uL(Z) {
  return typeof Z === "object" && (BN(Z) || Array.isArray(Z) || xs0(Z));
}
function DN(Z, J) {
  J = J || 0;
  var $ = Math.max(0, Z.length - J), X = new Array($);
  for (var Y = 0;Y < $; Y++)
    X[Y] = Z[Y + J];
  return X;
}
function NS(Z) {
  if (Array.isArray(Z))
    return DN(Z);
  var J = {};
  for (var $ in Z)
    if (RM.call(Z, $))
      J[$] = Z[$];
  return J;
}
function yn(Z, J, $) {
  return gn(Z, J, ys0($));
}
function gn(Z, J, $) {
  if (!uL(Z))
    throw new TypeError("Cannot merge into non-data-structure value: " + Z);
  if (BN(Z))
    return typeof $ === "function" && Z.mergeWith ? Z.mergeWith.apply(Z, [$].concat(J)) : Z.merge ? Z.merge.apply(Z, J) : Z.concat.apply(Z, J);
  var X = Array.isArray(Z), Y = Z, Q = X ? gO : U3, W = X ? function(G) {
    if (Y === Z)
      Y = NS(Y);
    Y.push(G);
  } : function(G, H) {
    var N = RM.call(Y, H), q = N && $ ? $(Y[H], G, H) : G;
    if (!N || q !== Y[H]) {
      if (Y === Z)
        Y = NS(Y);
      Y[H] = q;
    }
  };
  for (var K = 0;K < J.length; K++)
    Q(J[K]).forEach(W);
  return Y;
}
function ys0(Z) {
  function J($, X, Y) {
    return uL($) && uL(X) && gs0($, X) ? gn($, [X], J) : Z ? Z($, X, Y) : X;
  }
  return J;
}
function gs0(Z, J) {
  var $ = L5(Z), X = L5(J);
  return F3($) === F3(X) && wJ($) === wJ(X);
}
function D50() {
  var Z = [], J = arguments.length;
  while (J--)
    Z[J] = arguments[J];
  return yn(this, Z);
}
function M50(Z) {
  var J = [], $ = arguments.length - 1;
  while ($-- > 0)
    J[$] = arguments[$ + 1];
  return yn(this, J, Z);
}
function mn(Z) {
  var J = [], $ = arguments.length - 1;
  while ($-- > 0)
    J[$] = arguments[$ + 1];
  return OM(this, Z, MN(), function(X) {
    return yn(X, J);
  });
}
function dn(Z) {
  var J = [], $ = arguments.length - 1;
  while ($-- > 0)
    J[$] = arguments[$ + 1];
  return OM(this, Z, MN(), function(X) {
    return gn(X, J);
  });
}
function ms0(Z, J, $) {
  return OM(Z, J, w9, function() {
    return $;
  });
}
function pn(Z, J) {
  return ms0(this, Z, J);
}
function un(Z, J, $) {
  return arguments.length === 1 ? Z(this) : R50(this, Z, J, $);
}
function cn(Z, J, $) {
  return OM(this, Z, J, $);
}
function ln() {
  return this.__altered;
}
function q_(Z) {
  var J = this.asMutable();
  return Z(J), J.wasAltered() ? J.__ensureOwner(this.__ownerID) : this;
}
var A50 = "@@__IMMUTABLE_MAP__@@";
function nn(Z) {
  return Boolean(Z && Z[A50]);
}
function Z_(Z, J) {
  if (!Z)
    throw new Error(J);
}
function FK(Z) {
  Z_(Z !== 1 / 0, "Cannot perform this action with an infinite size.");
}
var DK = /* @__PURE__ */ function(Z) {
  function J($) {
    return $ === void 0 || $ === null ? MN() : nn($) && !AN($) ? $ : MN().withMutations(function(X) {
      var Y = Z($);
      FK(Y.size), Y.forEach(function(Q, W) {
        return X.set(W, Q);
      });
    });
  }
  if (Z)
    J.__proto__ = Z;
  return J.prototype = Object.create(Z && Z.prototype), J.prototype.constructor = J, J.prototype.toString = function $() {
    return this.__toString("Map {", "}");
  }, J.prototype.get = function $(X, Y) {
    return this._root ? this._root.get(0, void 0, X, Y) : Y;
  }, J.prototype.set = function $(X, Y) {
    return bW0(this, X, Y);
  }, J.prototype.remove = function $(X) {
    return bW0(this, X, w9);
  }, J.prototype.deleteAll = function $(X) {
    var Y = kQ(X);
    if (Y.size === 0)
      return this;
    return this.withMutations(function(Q) {
      Y.forEach(function(W) {
        return Q.remove(W);
      });
    });
  }, J.prototype.clear = function $() {
    if (this.size === 0)
      return this;
    if (this.__ownerID)
      return this.size = 0, this._root = null, this.__hash = void 0, this.__altered = !0, this;
    return MN();
  }, J.prototype.sort = function $(X) {
    return o$(KM(this, X));
  }, J.prototype.sortBy = function $(X, Y) {
    return o$(KM(this, Y, X));
  }, J.prototype.map = function $(X, Y) {
    var Q = this;
    return this.withMutations(function(W) {
      W.forEach(function(K, G) {
        W.set(G, X.call(Y, K, G, Q));
      });
    });
  }, J.prototype.__iterator = function $(X, Y) {
    return new ds0(this, X, Y);
  }, J.prototype.__iterate = function $(X, Y) {
    var Q = this, W = 0;
    return this._root && this._root.iterate(function(K) {
      return W++, X(K[1], K[0], Q);
    }, Y), W;
  }, J.prototype.__ensureOwner = function $(X) {
    if (X === this.__ownerID)
      return this;
    if (!X) {
      if (this.size === 0)
        return MN();
      return this.__ownerID = X, this.__altered = !1, this;
    }
    return on(this.size, this._root, X, this.__hash);
  }, J;
}(U3);
DK.isMap = nn;
var LJ = DK.prototype;
LJ[A50] = !0;
LJ[K_] = LJ.remove;
LJ.removeAll = LJ.deleteAll;
LJ.setIn = pn;
LJ.removeIn = LJ.deleteIn = rn;
LJ.update = un;
LJ.updateIn = cn;
LJ.merge = LJ.concat = E50;
LJ.mergeWith = O50;
LJ.mergeDeep = D50;
LJ.mergeDeepWith = M50;
LJ.mergeIn = dn;
LJ.mergeDeepIn = mn;
LJ.withMutations = q_;
LJ.wasAltered = ln;
LJ.asImmutable = H_;
LJ["@@transducer/init"] = LJ.asMutable = N_;
LJ["@@transducer/step"] = function(Z, J) {
  return Z.set(J[0], J[1]);
};
LJ["@@transducer/result"] = function(Z) {
  return Z.asImmutable();
};
var $_ = function Z(J, $) {
  this.ownerID = J, this.entries = $;
};
$_.prototype.get = function Z(J, $, X, Y) {
  var Q = this.entries;
  for (var W = 0, K = Q.length;W < K; W++)
    if (LK(X, Q[W][0]))
      return Q[W][1];
  return Y;
};
$_.prototype.update = function Z(J, $, X, Y, Q, W, K) {
  var G = Q === w9, H = this.entries, N = 0, q = H.length;
  for (;N < q; N++)
    if (LK(Y, H[N][0]))
      break;
  var U = N < q;
  if (U ? H[N][1] === Q : G)
    return this;
  if (q3(K), (G || !U) && q3(W), G && H.length === 1)
    return;
  if (!U && !G && H.length >= is0)
    return ps0(J, H, Y, Q);
  var F = J && J === this.ownerID, E = F ? H : DN(H);
  if (U)
    if (G)
      N === q - 1 ? E.pop() : E[N] = E.pop();
    else
      E[N] = [Y, Q];
  else
    E.push([Y, Q]);
  if (F)
    return this.entries = E, this;
  return new $_(J, E);
};
var GM = function Z(J, $, X) {
  this.ownerID = J, this.bitmap = $, this.nodes = X;
};
GM.prototype.get = function Z(J, $, X, Y) {
  if ($ === void 0)
    $ = qK(X);
  var Q = 1 << ((J === 0 ? $ : $ >>> J) & MW), W = this.bitmap;
  return (W & Q) === 0 ? Y : this.nodes[B50(W & Q - 1)].get(J + y7, $, X, Y);
};
GM.prototype.update = function Z(J, $, X, Y, Q, W, K) {
  if (X === void 0)
    X = qK(Y);
  var G = ($ === 0 ? X : X >>> $) & MW, H = 1 << G, N = this.bitmap, q = (N & H) !== 0;
  if (!q && Q === w9)
    return this;
  var U = B50(N & H - 1), F = this.nodes, E = q ? F[U] : void 0, R = sn(E, J, $ + y7, X, Y, Q, W, K);
  if (R === E)
    return this;
  if (!q && R && F.length >= os0)
    return cs0(J, F, N, G, R);
  if (q && !R && F.length === 2 && xW0(F[U ^ 1]))
    return F[U ^ 1];
  if (q && R && F.length === 1 && xW0(R))
    return R;
  var z = J && J === this.ownerID, D = q ? R ? N : N ^ H : N | H, A = q ? R ? w50(F, U, R, z) : ns0(F, U, z) : ls0(F, U, R, z);
  if (z)
    return this.bitmap = D, this.nodes = A, this;
  return new GM(J, D, A);
};
var X_ = function Z(J, $, X) {
  this.ownerID = J, this.count = $, this.nodes = X;
};
X_.prototype.get = function Z(J, $, X, Y) {
  if ($ === void 0)
    $ = qK(X);
  var Q = (J === 0 ? $ : $ >>> J) & MW, W = this.nodes[Q];
  return W ? W.get(J + y7, $, X, Y) : Y;
};
X_.prototype.update = function Z(J, $, X, Y, Q, W, K) {
  if (X === void 0)
    X = qK(Y);
  var G = ($ === 0 ? X : X >>> $) & MW, H = Q === w9, N = this.nodes, q = N[G];
  if (H && !q)
    return this;
  var U = sn(q, J, $ + y7, X, Y, Q, W, K);
  if (U === q)
    return this;
  var F = this.count;
  if (!q)
    F++;
  else if (!U) {
    if (F--, F < ss0)
      return us0(J, N, F, G);
  }
  var E = J && J === this.ownerID, R = w50(N, G, U, E);
  if (E)
    return this.count = F, this.nodes = R, this;
  return new X_(J, F, R);
};
var HM = function Z(J, $, X) {
  this.ownerID = J, this.keyHash = $, this.entries = X;
};
HM.prototype.get = function Z(J, $, X, Y) {
  var Q = this.entries;
  for (var W = 0, K = Q.length;W < K; W++)
    if (LK(X, Q[W][0]))
      return Q[W][1];
  return Y;
};
HM.prototype.update = function Z(J, $, X, Y, Q, W, K) {
  if (X === void 0)
    X = qK(Y);
  var G = Q === w9;
  if (X !== this.keyHash) {
    if (G)
      return this;
    return q3(K), q3(W), an(this, J, $, X, [Y, Q]);
  }
  var H = this.entries, N = 0, q = H.length;
  for (;N < q; N++)
    if (LK(Y, H[N][0]))
      break;
  var U = N < q;
  if (U ? H[N][1] === Q : G)
    return this;
  if (q3(K), (G || !U) && q3(W), G && q === 2)
    return new VF(J, this.keyHash, H[N ^ 1]);
  var F = J && J === this.ownerID, E = F ? H : DN(H);
  if (U)
    if (G)
      N === q - 1 ? E.pop() : E[N] = E.pop();
    else
      E[N] = [Y, Q];
  else
    E.push([Y, Q]);
  if (F)
    return this.entries = E, this;
  return new HM(J, this.keyHash, E);
};
var VF = function Z(J, $, X) {
  this.ownerID = J, this.keyHash = $, this.entry = X;
};
VF.prototype.get = function Z(J, $, X, Y) {
  return LK(X, this.entry[0]) ? this.entry[1] : Y;
};
VF.prototype.update = function Z(J, $, X, Y, Q, W, K) {
  var G = Q === w9, H = LK(Y, this.entry[0]);
  if (H ? Q === this.entry[1] : G)
    return this;
  if (q3(K), G) {
    q3(W);
    return;
  }
  if (H) {
    if (J && J === this.ownerID)
      return this.entry[1] = Q, this;
    return new VF(J, this.keyHash, [Y, Q]);
  }
  return q3(W), an(this, J, $, qK(Y), [Y, Q]);
};
$_.prototype.iterate = HM.prototype.iterate = function(Z, J) {
  var $ = this.entries;
  for (var X = 0, Y = $.length - 1;X <= Y; X++)
    if (Z($[J ? Y - X : X]) === !1)
      return !1;
};
GM.prototype.iterate = X_.prototype.iterate = function(Z, J) {
  var $ = this.nodes;
  for (var X = 0, Y = $.length - 1;X <= Y; X++) {
    var Q = $[J ? Y - X : X];
    if (Q && Q.iterate(Z, J) === !1)
      return !1;
  }
};
VF.prototype.iterate = function(Z, J) {
  return Z(this.entry);
};
var ds0 = /* @__PURE__ */ function(Z) {
  function J($, X, Y) {
    this._type = X, this._reverse = Y, this._stack = $._root && fW0($._root);
  }
  if (Z)
    J.__proto__ = Z;
  return J.prototype = Object.create(Z && Z.prototype), J.prototype.constructor = J, J.prototype.next = function $() {
    var X = this._type, Y = this._stack;
    while (Y) {
      var Q = Y.node, W = Y.index++, K = void 0;
      if (Q.entry) {
        if (W === 0)
          return Rn(X, Q.entry);
      } else if (Q.entries) {
        if (K = Q.entries.length - 1, W <= K)
          return Rn(X, Q.entries[this._reverse ? K - W : W]);
      } else if (K = Q.nodes.length - 1, W <= K) {
        var G = Q.nodes[this._reverse ? K - W : W];
        if (G) {
          if (G.entry)
            return Rn(X, G.entry);
          Y = this._stack = fW0(G, Y);
        }
        continue;
      }
      Y = this._stack = this._stack.__prev;
    }
    return AW();
  }, J;
}(g9);
function Rn(Z, J) {
  return jJ(Z, J[0], J[1]);
}
function fW0(Z, J) {
  return {
    node: Z,
    index: 0,
    __prev: J
  };
}
function on(Z, J, $, X) {
  var Y = Object.create(LJ);
  return Y.size = Z, Y._root = J, Y.__ownerID = $, Y.__hash = X, Y.__altered = !1, Y;
}
var hW0;
function MN() {
  return hW0 || (hW0 = on(0));
}
function bW0(Z, J, $) {
  var X, Y;
  if (!Z._root) {
    if ($ === w9)
      return Z;
    Y = 1, X = new $_(Z.__ownerID, [[J, $]]);
  } else {
    var Q = Mn(), W = Mn();
    if (X = sn(Z._root, Z.__ownerID, 0, void 0, J, $, Q, W), !W.value)
      return Z;
    Y = Z.size + (Q.value ? $ === w9 ? -1 : 1 : 0);
  }
  if (Z.__ownerID)
    return Z.size = Y, Z._root = X, Z.__hash = void 0, Z.__altered = !0, Z;
  return X ? on(Y, X) : MN();
}
function sn(Z, J, $, X, Y, Q, W, K) {
  if (!Z) {
    if (Q === w9)
      return Z;
    return q3(K), q3(W), new VF(J, X, [Y, Q]);
  }
  return Z.update(J, $, X, Y, Q, W, K);
}
function xW0(Z) {
  return Z.constructor === VF || Z.constructor === HM;
}
function an(Z, J, $, X, Y) {
  if (Z.keyHash === X)
    return new HM(J, X, [Z.entry, Y]);
  var Q = ($ === 0 ? Z.keyHash : Z.keyHash >>> $) & MW, W = ($ === 0 ? X : X >>> $) & MW, K, G = Q === W ? [an(Z, J, $ + y7, X, Y)] : (K = new VF(J, X, Y), Q < W ? [Z, K] : [K, Z]);
  return new GM(J, 1 << Q | 1 << W, G);
}
function ps0(Z, J, $, X) {
  if (!Z)
    Z = new In;
  var Y = new VF(Z, qK($), [$, X]);
  for (var Q = 0;Q < J.length; Q++) {
    var W = J[Q];
    Y = Y.update(Z, 0, void 0, W[0], W[1]);
  }
  return Y;
}
function us0(Z, J, $, X) {
  var Y = 0, Q = 0, W = new Array($);
  for (var K = 0, G = 1, H = J.length;K < H; K++, G <<= 1) {
    var N = J[K];
    if (N !== void 0 && K !== X)
      Y |= G, W[Q++] = N;
  }
  return new GM(Z, Y, W);
}
function cs0(Z, J, $, X, Y) {
  var Q = 0, W = new Array(UK);
  for (var K = 0;$ !== 0; K++, $ >>>= 1)
    W[K] = $ & 1 ? J[Q++] : void 0;
  return W[X] = Y, new X_(Z, Q + 1, W);
}
function B50(Z) {
  return Z -= Z >> 1 & 1431655765, Z = (Z & 858993459) + (Z >> 2 & 858993459), Z = Z + (Z >> 4) & 252645135, Z += Z >> 8, Z += Z >> 16, Z & 127;
}
function w50(Z, J, $, X) {
  var Y = X ? Z : DN(Z);
  return Y[J] = $, Y;
}
function ls0(Z, J, $, X) {
  var Y = Z.length + 1;
  if (X && J + 1 === Y)
    return Z[J] = $, Z;
  var Q = new Array(Y), W = 0;
  for (var K = 0;K < Y; K++)
    if (K === J)
      Q[K] = $, W = -1;
    else
      Q[K] = Z[K + W];
  return Q;
}
function ns0(Z, J, $) {
  var X = Z.length - 1;
  if ($ && J === X)
    return Z.pop(), Z;
  var Y = new Array(X), Q = 0;
  for (var W = 0;W < X; W++) {
    if (W === J)
      Q = 1;
    Y[W] = Z[W + Q];
  }
  return Y;
}
var is0 = UK / 4, os0 = UK / 2, ss0 = UK / 4;
function j50(Z) {
  if (X50(Z) && typeof Z !== "string")
    return Z;
  if (AN(Z))
    return Z.toArray();
  throw new TypeError("Invalid keyPath: expected Ordered Collection or Array: " + Z);
}
function Y_(Z) {
  try {
    return typeof Z === "string" ? JSON.stringify(Z) : String(Z);
  } catch (J) {
    return JSON.stringify(Z);
  }
}
function as0(Z, J) {
  return BN(Z) ? Z.has(J) : uL(Z) && RM.call(Z, J);
}
function T50(Z, J, $) {
  return BN(Z) ? Z.get(J, $) : !as0(Z, J) ? $ : typeof Z.get === "function" ? Z.get(J) : Z[J];
}
function rs0(Z, J) {
  if (!uL(Z))
    throw new TypeError("Cannot update non-data-structure value: " + Z);
  if (BN(Z)) {
    if (!Z.remove)
      throw new TypeError("Cannot update immutable value without .remove() method: " + Z);
    return Z.remove(J);
  }
  if (!RM.call(Z, J))
    return Z;
  var $ = NS(Z);
  if (Array.isArray($))
    $.splice(J, 1);
  else
    delete $[J];
  return $;
}
function ts0(Z, J, $) {
  if (!uL(Z))
    throw new TypeError("Cannot update non-data-structure value: " + Z);
  if (BN(Z)) {
    if (!Z.set)
      throw new TypeError("Cannot update immutable value without .set() method: " + Z);
    return Z.set(J, $);
  }
  if (RM.call(Z, J) && $ === Z[J])
    return Z;
  var X = NS(Z);
  return X[J] = $, X;
}
function OM(Z, J, $, X) {
  if (!X)
    X = $, $ = void 0;
  var Y = _50(BN(Z), Z, j50(J), 0, $, X);
  return Y === w9 ? $ : Y;
}
function _50(Z, J, $, X, Y, Q) {
  var W = J === w9;
  if (X === $.length) {
    var K = W ? Y : J, G = Q(K);
    return G === K ? J : G;
  }
  if (!W && !uL(J))
    throw new TypeError("Cannot update within non-data-structure value in path [" + Array.from($).slice(0, X).map(Y_) + "]: " + J);
  var H = $[X], N = W ? w9 : T50(J, H, w9), q = _50(N === w9 ? Z : BN(N), N, $, X + 1, Y, Q);
  return q === N ? J : q === w9 ? rs0(J, H) : ts0(W ? Z ? MN() : {} : J, H, q);
}
function es0(Z, J) {
  return OM(Z, J, function() {
    return w9;
  });
}
function rn(Z) {
  return es0(this, Z);
}
var V50 = "@@__IMMUTABLE_LIST__@@";
function I50(Z) {
  return Boolean(Z && Z[V50]);
}
var jN = /* @__PURE__ */ function(Z) {
  function J($) {
    var X = KS();
    if ($ === void 0 || $ === null)
      return X;
    if (I50($))
      return $;
    var Y = Z($), Q = Y.size;
    if (Q === 0)
      return X;
    if (FK(Q), Q > 0 && Q < UK)
      return Q_(0, Q, y7, null, new mL(Y.toArray()));
    return X.withMutations(function(W) {
      W.setSize(Q), Y.forEach(function(K, G) {
        return W.set(G, K);
      });
    });
  }
  if (Z)
    J.__proto__ = Z;
  return J.prototype = Object.create(Z && Z.prototype), J.prototype.constructor = J, J.of = function $() {
    return this(arguments);
  }, J.prototype.toString = function $() {
    return this.__toString("List [", "]");
  }, J.prototype.get = function $(X, Y) {
    if (X = dL(this, X), X >= 0 && X < this.size) {
      X += this._origin;
      var Q = P50(this, X);
      return Q && Q.array[X & MW];
    }
    return Y;
  }, J.prototype.set = function $(X, Y) {
    return Za0(this, X, Y);
  }, J.prototype.remove = function $(X) {
    return !this.has(X) ? this : X === 0 ? this.shift() : X === this.size - 1 ? this.pop() : this.splice(X, 1);
  }, J.prototype.insert = function $(X, Y) {
    return this.splice(X, 0, Y);
  }, J.prototype.clear = function $() {
    if (this.size === 0)
      return this;
    if (this.__ownerID)
      return this.size = this._origin = this._capacity = 0, this._level = y7, this._root = this._tail = this.__hash = void 0, this.__altered = !0, this;
    return KS();
  }, J.prototype.push = function $() {
    var X = arguments, Y = this.size;
    return this.withMutations(function(Q) {
      gL(Q, 0, Y + X.length);
      for (var W = 0;W < X.length; W++)
        Q.set(Y + W, X[W]);
    });
  }, J.prototype.pop = function $() {
    return gL(this, 0, -1);
  }, J.prototype.unshift = function $() {
    var X = arguments;
    return this.withMutations(function(Y) {
      gL(Y, -X.length);
      for (var Q = 0;Q < X.length; Q++)
        Y.set(Q, X[Q]);
    });
  }, J.prototype.shift = function $() {
    return gL(this, 1);
  }, J.prototype.shuffle = function $(X) {
    if (X === void 0)
      X = Math.random;
    return this.withMutations(function(Y) {
      var Q = Y.size, W, K;
      while (Q)
        W = Math.floor(X() * Q--), K = Y.get(W), Y.set(W, Y.get(Q)), Y.set(Q, K);
    });
  }, J.prototype.concat = function $() {
    var X = arguments, Y = [];
    for (var Q = 0;Q < arguments.length; Q++) {
      var W = X[Q], K = Z(typeof W !== "string" && rW0(W) ? W : [W]);
      if (K.size !== 0)
        Y.push(K);
    }
    if (Y.length === 0)
      return this;
    if (this.size === 0 && !this.__ownerID && Y.length === 1)
      return this.constructor(Y[0]);
    return this.withMutations(function(G) {
      Y.forEach(function(H) {
        return H.forEach(function(N) {
          return G.push(N);
        });
      });
    });
  }, J.prototype.setSize = function $(X) {
    return gL(this, 0, X);
  }, J.prototype.map = function $(X, Y) {
    var Q = this;
    return this.withMutations(function(W) {
      for (var K = 0;K < Q.size; K++)
        W.set(K, X.call(Y, W.get(K), K, Q));
    });
  }, J.prototype.slice = function $(X, Y) {
    var Q = this.size;
    if (LS(X, Y, Q))
      return this;
    return gL(this, G_(X, Q), RS(Y, Q));
  }, J.prototype.__iterator = function $(X, Y) {
    var Q = Y ? this.size : 0, W = yW0(this, Y);
    return new g9(function() {
      var K = W();
      return K === J_ ? AW() : jJ(X, Y ? --Q : Q++, K);
    });
  }, J.prototype.__iterate = function $(X, Y) {
    var Q = Y ? this.size : 0, W = yW0(this, Y), K;
    while ((K = W()) !== J_)
      if (X(K, Y ? --Q : Q++, this) === !1)
        break;
    return Q;
  }, J.prototype.__ensureOwner = function $(X) {
    if (X === this.__ownerID)
      return this;
    if (!X) {
      if (this.size === 0)
        return KS();
      return this.__ownerID = X, this.__altered = !1, this;
    }
    return Q_(this._origin, this._capacity, this._level, this._root, this._tail, X, this.__hash);
  }, J;
}(gO);
jN.isList = I50;
var i$ = jN.prototype;
i$[V50] = !0;
i$[K_] = i$.remove;
i$.merge = i$.concat;
i$.setIn = pn;
i$.deleteIn = i$.removeIn = rn;
i$.update = un;
i$.updateIn = cn;
i$.mergeIn = dn;
i$.mergeDeepIn = mn;
i$.withMutations = q_;
i$.wasAltered = ln;
i$.asImmutable = H_;
i$["@@transducer/init"] = i$.asMutable = N_;
i$["@@transducer/step"] = function(Z, J) {
  return Z.push(J);
};
i$["@@transducer/result"] = function(Z) {
  return Z.asImmutable();
};
var mL = function Z(J, $) {
  this.array = J, this.ownerID = $;
};
mL.prototype.removeBefore = function Z(J, $, X) {
  if ((X & (1 << $ + y7) - 1) === 0 || this.array.length === 0)
    return this;
  var Y = X >>> $ & MW;
  if (Y >= this.array.length)
    return new mL([], J);
  var Q = Y === 0, W;
  if ($ > 0) {
    var K = this.array[Y];
    if (W = K && K.removeBefore(J, $ - y7, X), W === K && Q)
      return this;
  }
  if (Q && !W)
    return this;
  var G = NM(this, J);
  if (!Q)
    for (var H = 0;H < Y; H++)
      G.array[H] = void 0;
  if (W)
    G.array[Y] = W;
  return G;
};
mL.prototype.removeAfter = function Z(J, $, X) {
  if (X === ($ ? 1 << $ + y7 : UK) || this.array.length === 0)
    return this;
  var Y = X - 1 >>> $ & MW;
  if (Y >= this.array.length)
    return this;
  var Q;
  if ($ > 0) {
    var W = this.array[Y];
    if (Q = W && W.removeAfter(J, $ - y7, X), Q === W && Y === this.array.length - 1)
      return this;
  }
  var K = NM(this, J);
  if (K.array.splice(Y + 1), Q)
    K.array[Y] = Q;
  return K;
};
var J_ = {};
function yW0(Z, J) {
  var { _origin: $, _capacity: X } = Z, Y = W_(X), Q = Z._tail;
  return W(Z._root, Z._level, 0);
  function W(H, N, q) {
    return N === 0 ? K(H, q) : G(H, N, q);
  }
  function K(H, N) {
    var q = N === Y ? Q && Q.array : H && H.array, U = N > $ ? 0 : $ - N, F = X - N;
    if (F > UK)
      F = UK;
    return function() {
      if (U === F)
        return J_;
      var E = J ? --F : U++;
      return q && q[E];
    };
  }
  function G(H, N, q) {
    var U, F = H && H.array, E = q > $ ? 0 : $ - q >> N, R = (X - q >> N) + 1;
    if (R > UK)
      R = UK;
    return function() {
      while (!0) {
        if (U) {
          var z = U();
          if (z !== J_)
            return z;
          U = null;
        }
        if (E === R)
          return J_;
        var D = J ? --R : E++;
        U = W(F && F[D], N - y7, q + (D << N));
      }
    };
  }
}
function Q_(Z, J, $, X, Y, Q, W) {
  var K = Object.create(i$);
  return K.size = J - Z, K._origin = Z, K._capacity = J, K._level = $, K._root = X, K._tail = Y, K.__ownerID = Q, K.__hash = W, K.__altered = !1, K;
}
function KS() {
  return Q_(0, 0, y7);
}
function Za0(Z, J, $) {
  if (J = dL(Z, J), J !== J)
    return Z;
  if (J >= Z.size || J < 0)
    return Z.withMutations(function(W) {
      J < 0 ? gL(W, J).set(0, $) : gL(W, 0, J + 1).set(J, $);
    });
  J += Z._origin;
  var { _tail: X, _root: Y } = Z, Q = Mn();
  if (J >= W_(Z._capacity))
    X = jn(X, Z.__ownerID, 0, J, $, Q);
  else
    Y = jn(Y, Z.__ownerID, Z._level, J, $, Q);
  if (!Q.value)
    return Z;
  if (Z.__ownerID)
    return Z._root = Y, Z._tail = X, Z.__hash = void 0, Z.__altered = !0, Z;
  return Q_(Z._origin, Z._capacity, Z._level, Y, X);
}
function jn(Z, J, $, X, Y, Q) {
  var W = X >>> $ & MW, K = Z && W < Z.array.length;
  if (!K && Y === void 0)
    return Z;
  var G;
  if ($ > 0) {
    var H = Z && Z.array[W], N = jn(H, J, $ - y7, X, Y, Q);
    if (N === H)
      return Z;
    return G = NM(Z, J), G.array[W] = N, G;
  }
  if (K && Z.array[W] === Y)
    return Z;
  if (Q)
    q3(Q);
  if (G = NM(Z, J), Y === void 0 && W === G.array.length - 1)
    G.array.pop();
  else
    G.array[W] = Y;
  return G;
}
function NM(Z, J) {
  if (J && Z && J === Z.ownerID)
    return Z;
  return new mL(Z ? Z.array.slice() : [], J);
}
function P50(Z, J) {
  if (J >= W_(Z._capacity))
    return Z._tail;
  if (J < 1 << Z._level + y7) {
    var { _root: $, _level: X } = Z;
    while ($ && X > 0)
      $ = $.array[J >>> X & MW], X -= y7;
    return $;
  }
}
function gL(Z, J, $) {
  if (J !== void 0)
    J |= 0;
  if ($ !== void 0)
    $ |= 0;
  var X = Z.__ownerID || new In, Y = Z._origin, Q = Z._capacity, W = Y + J, K = $ === void 0 ? Q : $ < 0 ? Q + $ : Y + $;
  if (W === Y && K === Q)
    return Z;
  if (W >= K)
    return Z.clear();
  var { _level: G, _root: H } = Z, N = 0;
  while (W + N < 0)
    H = new mL(H && H.array.length ? [void 0, H] : [], X), G += y7, N += 1 << G;
  if (N)
    W += N, Y += N, K += N, Q += N;
  var q = W_(Q), U = W_(K);
  while (U >= 1 << G + y7)
    H = new mL(H && H.array.length ? [H] : [], X), G += y7;
  var F = Z._tail, E = U < q ? P50(Z, K - 1) : U > q ? new mL([], X) : F;
  if (F && U > q && W < Q && F.array.length) {
    H = NM(H, X);
    var R = H;
    for (var z = G;z > y7; z -= y7) {
      var D = q >>> z & MW;
      R = R.array[D] = NM(R.array[D], X);
    }
    R.array[q >>> y7 & MW] = F;
  }
  if (K < Q)
    E = E && E.removeAfter(X, 0, K);
  if (W >= U)
    W -= U, K -= U, G = y7, H = null, E = E && E.removeBefore(X, 0, W);
  else if (W > Y || U < q) {
    N = 0;
    while (H) {
      var A = W >>> G & MW;
      if (A !== U >>> G & MW)
        break;
      if (A)
        N += (1 << G) * A;
      G -= y7, H = H.array[A];
    }
    if (H && W > Y)
      H = H.removeBefore(X, G, W - N);
    if (H && U < q)
      H = H.removeAfter(X, G, U - N);
    if (N)
      W -= N, K -= N;
  }
  if (Z.__ownerID)
    return Z.size = K - W, Z._origin = W, Z._capacity = K, Z._level = G, Z._root = H, Z._tail = E, Z.__hash = void 0, Z.__altered = !0, Z;
  return Q_(W, K, G, H, E);
}
function W_(Z) {
  return Z < UK ? 0 : Z - 1 >>> y7 << y7;
}
function C50(Z) {
  return nn(Z) && AN(Z);
}
var o$ = /* @__PURE__ */ function(Z) {
  function J($) {
    return $ === void 0 || $ === null ? rT() : C50($) ? $ : rT().withMutations(function(X) {
      var Y = U3($);
      FK(Y.size), Y.forEach(function(Q, W) {
        return X.set(W, Q);
      });
    });
  }
  if (Z)
    J.__proto__ = Z;
  return J.prototype = Object.create(Z && Z.prototype), J.prototype.constructor = J, J.of = function $() {
    return this(arguments);
  }, J.prototype.toString = function $() {
    return this.__toString("OrderedMap {", "}");
  }, J.prototype.get = function $(X, Y) {
    var Q = this._map.get(X);
    return Q !== void 0 ? this._list.get(Q)[1] : Y;
  }, J.prototype.clear = function $() {
    if (this.size === 0)
      return this;
    if (this.__ownerID)
      return this.size = 0, this._map.clear(), this._list.clear(), this.__altered = !0, this;
    return rT();
  }, J.prototype.set = function $(X, Y) {
    return mW0(this, X, Y);
  }, J.prototype.remove = function $(X) {
    return mW0(this, X, w9);
  }, J.prototype.__iterate = function $(X, Y) {
    var Q = this;
    return this._list.__iterate(function(W) {
      return W && X(W[1], W[0], Q);
    }, Y);
  }, J.prototype.__iterator = function $(X, Y) {
    return this._list.fromEntrySeq().__iterator(X, Y);
  }, J.prototype.__ensureOwner = function $(X) {
    if (X === this.__ownerID)
      return this;
    var Y = this._map.__ensureOwner(X), Q = this._list.__ensureOwner(X);
    if (!X) {
      if (this.size === 0)
        return rT();
      return this.__ownerID = X, this.__altered = !1, this._map = Y, this._list = Q, this;
    }
    return tn(Y, Q, X, this.__hash);
  }, J;
}(DK);
o$.isOrderedMap = C50;
o$.prototype[pL] = !0;
o$.prototype[K_] = o$.prototype.remove;
function tn(Z, J, $, X) {
  var Y = Object.create(o$.prototype);
  return Y.size = Z ? Z.size : 0, Y._map = Z, Y._list = J, Y.__ownerID = $, Y.__hash = X, Y.__altered = !1, Y;
}
var gW0;
function rT() {
  return gW0 || (gW0 = tn(MN(), KS()));
}
function mW0(Z, J, $) {
  var { _map: X, _list: Y } = Z, Q = X.get(J), W = Q !== void 0, K, G;
  if ($ === w9) {
    if (!W)
      return Z;
    if (Y.size >= UK && Y.size >= X.size * 2) {
      if (G = Y.filter(function(H, N) {
        return H !== void 0 && Q !== N;
      }), K = G.toKeyedSeq().map(function(H) {
        return H[0];
      }).flip().toMap(), Z.__ownerID)
        K.__ownerID = G.__ownerID = Z.__ownerID;
    } else
      K = X.remove(J), G = Q === Y.size - 1 ? Y.pop() : Y.set(Q, void 0);
  } else if (W) {
    if ($ === Y.get(Q)[1])
      return Z;
    K = X, G = Y.set(Q, [J, $]);
  } else
    K = X.set(J, Y.size), G = Y.set(Y.size, [J, $]);
  if (Z.__ownerID)
    return Z.size = K.size, Z._map = K, Z._list = G, Z.__hash = void 0, Z.__altered = !0, Z;
  return tn(K, G);
}
var k50 = "@@__IMMUTABLE_STACK__@@";
function Tn(Z) {
  return Boolean(Z && Z[k50]);
}
var en = /* @__PURE__ */ function(Z) {
  function J($) {
    return $ === void 0 || $ === null ? QS() : Tn($) ? $ : QS().pushAll($);
  }
  if (Z)
    J.__proto__ = Z;
  return J.prototype = Object.create(Z && Z.prototype), J.prototype.constructor = J, J.of = function $() {
    return this(arguments);
  }, J.prototype.toString = function $() {
    return this.__toString("Stack [", "]");
  }, J.prototype.get = function $(X, Y) {
    var Q = this._head;
    X = dL(this, X);
    while (Q && X--)
      Q = Q.next;
    return Q ? Q.value : Y;
  }, J.prototype.peek = function $() {
    return this._head && this._head.value;
  }, J.prototype.push = function $() {
    var X = arguments;
    if (arguments.length === 0)
      return this;
    var Y = this.size + arguments.length, Q = this._head;
    for (var W = arguments.length - 1;W >= 0; W--)
      Q = {
        value: X[W],
        next: Q
      };
    if (this.__ownerID)
      return this.size = Y, this._head = Q, this.__hash = void 0, this.__altered = !0, this;
    return tT(Y, Q);
  }, J.prototype.pushAll = function $(X) {
    if (X = Z(X), X.size === 0)
      return this;
    if (this.size === 0 && Tn(X))
      return X;
    FK(X.size);
    var Y = this.size, Q = this._head;
    if (X.__iterate(function(W) {
      Y++, Q = {
        value: W,
        next: Q
      };
    }, !0), this.__ownerID)
      return this.size = Y, this._head = Q, this.__hash = void 0, this.__altered = !0, this;
    return tT(Y, Q);
  }, J.prototype.pop = function $() {
    return this.slice(1);
  }, J.prototype.clear = function $() {
    if (this.size === 0)
      return this;
    if (this.__ownerID)
      return this.size = 0, this._head = void 0, this.__hash = void 0, this.__altered = !0, this;
    return QS();
  }, J.prototype.slice = function $(X, Y) {
    if (LS(X, Y, this.size))
      return this;
    var Q = G_(X, this.size), W = RS(Y, this.size);
    if (W !== this.size)
      return Z.prototype.slice.call(this, X, Y);
    var K = this.size - Q, G = this._head;
    while (Q--)
      G = G.next;
    if (this.__ownerID)
      return this.size = K, this._head = G, this.__hash = void 0, this.__altered = !0, this;
    return tT(K, G);
  }, J.prototype.__ensureOwner = function $(X) {
    if (X === this.__ownerID)
      return this;
    if (!X) {
      if (this.size === 0)
        return QS();
      return this.__ownerID = X, this.__altered = !1, this;
    }
    return tT(this.size, this._head, X, this.__hash);
  }, J.prototype.__iterate = function $(X, Y) {
    var Q = this;
    if (Y)
      return new WM(this.toArray()).__iterate(function(G, H) {
        return X(G, H, Q);
      }, Y);
    var W = 0, K = this._head;
    while (K) {
      if (X(K.value, W++, this) === !1)
        break;
      K = K.next;
    }
    return W;
  }, J.prototype.__iterator = function $(X, Y) {
    if (Y)
      return new WM(this.toArray()).__iterator(X, Y);
    var Q = 0, W = this._head;
    return new g9(function() {
      if (W) {
        var K = W.value;
        return W = W.next, jJ(X, Q++, K);
      }
      return AW();
    });
  }, J;
}(gO);
en.isStack = Tn;
var BW = en.prototype;
BW[k50] = !0;
BW.shift = BW.pop;
BW.unshift = BW.push;
BW.unshiftAll = BW.pushAll;
BW.withMutations = q_;
BW.wasAltered = ln;
BW.asImmutable = H_;
BW["@@transducer/init"] = BW.asMutable = N_;
BW["@@transducer/step"] = function(Z, J) {
  return Z.unshift(J);
};
BW["@@transducer/result"] = function(Z) {
  return Z.asImmutable();
};
function tT(Z, J, $, X) {
  var Y = Object.create(BW);
  return Y.size = Z, Y._head = J, Y.__ownerID = $, Y.__hash = X, Y.__altered = !1, Y;
}
var dW0;
function QS() {
  return dW0 || (dW0 = tT(0));
}
function pW0(Z, J, $, X, Y, Q) {
  return FK(Z.size), Z.__iterate(function(W, K, G) {
    if (Y)
      Y = !1, $ = W;
    else
      $ = J.call(X, $, W, K, G);
  }, Q), $;
}
function Ja0(Z, J) {
  return J;
}
function $a0(Z, J) {
  return [J, Z];
}
function En(Z) {
  return function() {
    var J = [], $ = arguments.length;
    while ($--)
      J[$] = arguments[$];
    return !Z.apply(this, J);
  };
}
function uW0(Z) {
  return function() {
    var J = [], $ = arguments.length;
    while ($--)
      J[$] = arguments[$];
    return -Z.apply(this, J);
  };
}
function cW0(Z, J) {
  return Z < J ? 1 : Z > J ? -1 : 0;
}
function v50(Z, J) {
  if (Z === J)
    return !0;
  if (!RK(J) || Z.size !== void 0 && J.size !== void 0 && Z.size !== J.size || Z.__hash !== void 0 && J.__hash !== void 0 && Z.__hash !== J.__hash || wJ(Z) !== wJ(J) || F3(Z) !== F3(J) || AN(Z) !== AN(J))
    return !1;
  if (Z.size === 0 && J.size === 0)
    return !0;
  var $ = !Vn(Z);
  if (AN(Z)) {
    var X = Z.entries();
    return J.every(function(G, H) {
      var N = X.next().value;
      return N && LK(N[1], G) && ($ || LK(N[0], H));
    }) && X.next().done;
  }
  var Y = !1;
  if (Z.size === void 0)
    if (J.size === void 0) {
      if (typeof Z.cacheResult === "function")
        Z.cacheResult();
    } else {
      Y = !0;
      var Q = Z;
      Z = J, J = Q;
    }
  var W = !0, K = J.__iterate(function(G, H) {
    if ($ ? !Z.has(G) : Y ? !LK(G, Z.get(H, w9)) : !LK(Z.get(H, w9), G))
      return W = !1, !1;
  });
  return W && Z.size === K;
}
var Xa0 = /* @__PURE__ */ function(Z) {
  function J($, X, Y) {
    if (Y === void 0)
      Y = 1;
    if (!(this instanceof J))
      return new J($, X, Y);
    if (Z_(Y !== 0, "Cannot step a Range by 0"), Z_($ !== void 0, "You must define a start value when using Range"), Z_(X !== void 0, "You must define an end value when using Range"), Y = Math.abs(Y), X < $)
      Y = -Y;
    if (this._start = $, this._end = X, this._step = Y, this.size = Math.max(0, Math.ceil((X - $) / Y - 1) + 1), this.size === 0) {
      if (On)
        return On;
      On = this;
    }
  }
  if (Z)
    J.__proto__ = Z;
  return J.prototype = Object.create(Z && Z.prototype), J.prototype.constructor = J, J.prototype.toString = function $() {
    return this.size === 0 ? "Range []" : "Range [ " + this._start + "..." + this._end + (this._step !== 1 ? " by " + this._step : "") + " ]";
  }, J.prototype.get = function $(X, Y) {
    return this.has(X) ? this._start + dL(this, X) * this._step : Y;
  }, J.prototype.includes = function $(X) {
    var Y = (X - this._start) / this._step;
    return Y >= 0 && Y < this.size && Y === Math.floor(Y);
  }, J.prototype.slice = function $(X, Y) {
    if (LS(X, Y, this.size))
      return this;
    if (X = G_(X, this.size), Y = RS(Y, this.size), Y <= X)
      return new J(0, 0);
    return new J(this.get(X, this._end), this.get(Y, this._end), this._step);
  }, J.prototype.indexOf = function $(X) {
    var Y = X - this._start;
    if (Y % this._step === 0) {
      var Q = Y / this._step;
      if (Q >= 0 && Q < this.size)
        return Q;
    }
    return -1;
  }, J.prototype.lastIndexOf = function $(X) {
    return this.indexOf(X);
  }, J.prototype.__iterate = function $(X, Y) {
    var Q = this.size, W = this._step, K = Y ? this._start + (Q - 1) * W : this._start, G = 0;
    while (G !== Q) {
      if (X(K, Y ? Q - ++G : G++, this) === !1)
        break;
      K += Y ? -W : W;
    }
    return G;
  }, J.prototype.__iterator = function $(X, Y) {
    var Q = this.size, W = this._step, K = Y ? this._start + (Q - 1) * W : this._start, G = 0;
    return new g9(function() {
      if (G === Q)
        return AW();
      var H = K;
      return K += Y ? -W : W, jJ(X, Y ? Q - ++G : G++, H);
    });
  }, J.prototype.equals = function $(X) {
    return X instanceof J ? this._start === X._start && this._end === X._end && this._step === X._step : v50(this, X);
  }, J;
}(sG), On, S50 = "@@__IMMUTABLE_SET__@@";
function Zi(Z) {
  return Boolean(Z && Z[S50]);
}
var zS = /* @__PURE__ */ function(Z) {
  function J($) {
    return $ === void 0 || $ === null ? eT() : Zi($) && !AN($) ? $ : eT().withMutations(function(X) {
      var Y = Z($);
      FK(Y.size), Y.forEach(function(Q) {
        return X.add(Q);
      });
    });
  }
  if (Z)
    J.__proto__ = Z;
  return J.prototype = Object.create(Z && Z.prototype), J.prototype.constructor = J, J.of = function $() {
    return this(arguments);
  }, J.fromKeys = function $(X) {
    return this(U3(X).keySeq());
  }, J.intersect = function $(X) {
    return X = kQ(X).toArray(), X.length ? YQ.intersect.apply(J(X.pop()), X) : eT();
  }, J.union = function $(X) {
    return X = kQ(X).toArray(), X.length ? YQ.union.apply(J(X.pop()), X) : eT();
  }, J.prototype.toString = function $() {
    return this.__toString("Set {", "}");
  }, J.prototype.has = function $(X) {
    return this._map.has(X);
  }, J.prototype.add = function $(X) {
    return WS(this, this._map.set(X, X));
  }, J.prototype.remove = function $(X) {
    return WS(this, this._map.remove(X));
  }, J.prototype.clear = function $() {
    return WS(this, this._map.clear());
  }, J.prototype.map = function $(X, Y) {
    var Q = this, W = !1, K = WS(this, this._map.mapEntries(function(G) {
      var H = G[1], N = X.call(Y, H, H, Q);
      if (N !== H)
        W = !0;
      return [N, N];
    }, Y));
    return W ? K : this;
  }, J.prototype.union = function $() {
    var X = [], Y = arguments.length;
    while (Y--)
      X[Y] = arguments[Y];
    if (X = X.filter(function(Q) {
      return Q.size !== 0;
    }), X.length === 0)
      return this;
    if (this.size === 0 && !this.__ownerID && X.length === 1)
      return this.constructor(X[0]);
    return this.withMutations(function(Q) {
      for (var W = 0;W < X.length; W++)
        if (typeof X[W] === "string")
          Q.add(X[W]);
        else
          Z(X[W]).forEach(function(K) {
            return Q.add(K);
          });
    });
  }, J.prototype.intersect = function $() {
    var X = [], Y = arguments.length;
    while (Y--)
      X[Y] = arguments[Y];
    if (X.length === 0)
      return this;
    X = X.map(function(W) {
      return Z(W);
    });
    var Q = [];
    return this.forEach(function(W) {
      if (!X.every(function(K) {
        return K.includes(W);
      }))
        Q.push(W);
    }), this.withMutations(function(W) {
      Q.forEach(function(K) {
        W.remove(K);
      });
    });
  }, J.prototype.subtract = function $() {
    var X = [], Y = arguments.length;
    while (Y--)
      X[Y] = arguments[Y];
    if (X.length === 0)
      return this;
    X = X.map(function(W) {
      return Z(W);
    });
    var Q = [];
    return this.forEach(function(W) {
      if (X.some(function(K) {
        return K.includes(W);
      }))
        Q.push(W);
    }), this.withMutations(function(W) {
      Q.forEach(function(K) {
        W.remove(K);
      });
    });
  }, J.prototype.sort = function $(X) {
    return zK(KM(this, X));
  }, J.prototype.sortBy = function $(X, Y) {
    return zK(KM(this, Y, X));
  }, J.prototype.wasAltered = function $() {
    return this._map.wasAltered();
  }, J.prototype.__iterate = function $(X, Y) {
    var Q = this;
    return this._map.__iterate(function(W) {
      return X(W, W, Q);
    }, Y);
  }, J.prototype.__iterator = function $(X, Y) {
    return this._map.__iterator(X, Y);
  }, J.prototype.__ensureOwner = function $(X) {
    if (X === this.__ownerID)
      return this;
    var Y = this._map.__ensureOwner(X);
    if (!X) {
      if (this.size === 0)
        return this.__empty();
      return this.__ownerID = X, this._map = Y, this;
    }
    return this.__make(Y, X);
  }, J;
}(UM);
zS.isSet = Zi;
var YQ = zS.prototype;
YQ[S50] = !0;
YQ[K_] = YQ.remove;
YQ.merge = YQ.concat = YQ.union;
YQ.withMutations = q_;
YQ.asImmutable = H_;
YQ["@@transducer/init"] = YQ.asMutable = N_;
YQ["@@transducer/step"] = function(Z, J) {
  return Z.add(J);
};
YQ["@@transducer/result"] = function(Z) {
  return Z.asImmutable();
};
YQ.__empty = eT;
YQ.__make = f50;
function WS(Z, J) {
  if (Z.__ownerID)
    return Z.size = J.size, Z._map = J, Z;
  return J === Z._map ? Z : J.size === 0 ? Z.__empty() : Z.__make(J);
}
function f50(Z, J) {
  var $ = Object.create(YQ);
  return $.size = Z ? Z.size : 0, $._map = Z, $.__ownerID = J, $;
}
var lW0;
function eT() {
  return lW0 || (lW0 = f50(MN()));
}
function h50(Z, J, $) {
  var X = j50(J), Y = 0;
  while (Y !== X.length)
    if (Z = T50(Z, X[Y++], w9), Z === w9)
      return $;
  return Z;
}
function b50(Z, J) {
  return h50(this, Z, J);
}
function Ya0(Z, J) {
  return h50(Z, J, w9) !== w9;
}
function Qa0(Z) {
  return Ya0(this, Z);
}
function x50() {
  FK(this.size);
  var Z = {};
  return this.__iterate(function(J, $) {
    Z[$] = J;
  }), Z;
}
function qS(Z) {
  if (!Z || typeof Z !== "object")
    return Z;
  if (!RK(Z)) {
    if (!uL(Z))
      return Z;
    Z = L5(Z);
  }
  if (wJ(Z)) {
    var J = {};
    return Z.__iterate(function(X, Y) {
      J[Y] = qS(X);
    }), J;
  }
  var $ = [];
  return Z.__iterate(function(X) {
    $.push(qS(X));
  }), $;
}
function Wa0(Z) {
  if (Z.size === 1 / 0)
    return 0;
  var J = AN(Z), $ = wJ(Z), X = J ? 1 : 0;
  return Z.__iterate($ ? J ? function(Y, Q) {
    X = 31 * X + nW0(qK(Y), qK(Q)) | 0;
  } : function(Y, Q) {
    X = X + nW0(qK(Y), qK(Q)) | 0;
  } : J ? function(Y) {
    X = 31 * X + qK(Y) | 0;
  } : function(Y) {
    X = X + qK(Y) | 0;
  }), Ka0(Z.size, X);
}
function Ka0(Z, J) {
  return J = aT(J, 3432918353), J = aT(J << 15 | J >>> -15, 461845907), J = aT(J << 13 | J >>> -13, 5), J = (J + 3864292196 | 0) ^ Z, J = aT(J ^ J >>> 16, 2246822507), J = aT(J ^ J >>> 13, 3266489909), J = ES(J ^ J >>> 16), J;
}
function nW0(Z, J) {
  return Z ^ J + 2654435769 + (Z << 6) + (Z >> 2) | 0;
}
function dO(Z, J) {
  var $ = function(X) {
    Z.prototype[X] = J[X];
  };
  return Object.keys(J).forEach($), Object.getOwnPropertySymbols && Object.getOwnPropertySymbols(J).forEach($), Z;
}
kQ.Iterator = g9;
dO(kQ, {
  toArray: function Z() {
    FK(this.size);
    var J = new Array(this.size || 0), $ = wJ(this), X = 0;
    return this.__iterate(function(Y, Q) {
      J[X++] = $ ? [Q, Y] : Y;
    }), J;
  },
  toIndexedSeq: function Z() {
    return new W50(this);
  },
  toJS: function Z() {
    return qS(this);
  },
  toKeyedSeq: function Z() {
    return new OS(this, !0);
  },
  toMap: function Z() {
    return DK(this.toKeyedSeq());
  },
  toObject: x50,
  toOrderedMap: function Z() {
    return o$(this.toKeyedSeq());
  },
  toOrderedSet: function Z() {
    return zK(wJ(this) ? this.valueSeq() : this);
  },
  toSet: function Z() {
    return zS(wJ(this) ? this.valueSeq() : this);
  },
  toSetSeq: function Z() {
    return new K50(this);
  },
  toSeq: function Z() {
    return F3(this) ? this.toIndexedSeq() : wJ(this) ? this.toKeyedSeq() : this.toSetSeq();
  },
  toStack: function Z() {
    return en(wJ(this) ? this.valueSeq() : this);
  },
  toList: function Z() {
    return jN(wJ(this) ? this.valueSeq() : this);
  },
  toString: function Z() {
    return "[Collection]";
  },
  __toString: function Z(J, $) {
    if (this.size === 0)
      return J + $;
    return J + " " + this.toSeq().map(this.__toStringMapper).join(", ") + " " + $;
  },
  concat: function Z() {
    var J = [], $ = arguments.length;
    while ($--)
      J[$] = arguments[$];
    return x7(this, Ss0(this, J));
  },
  includes: function Z(J) {
    return this.some(function($) {
      return LK($, J);
    });
  },
  entries: function Z() {
    return this.__iterator(OK);
  },
  every: function Z(J, $) {
    FK(this.size);
    var X = !0;
    return this.__iterate(function(Y, Q, W) {
      if (!J.call($, Y, Q, W))
        return X = !1, !1;
    }), X;
  },
  filter: function Z(J, $) {
    return x7(this, q50(this, J, $, !0));
  },
  partition: function Z(J, $) {
    return Cs0(this, J, $);
  },
  find: function Z(J, $, X) {
    var Y = this.findEntry(J, $);
    return Y ? Y[1] : X;
  },
  forEach: function Z(J, $) {
    return FK(this.size), this.__iterate($ ? J.bind($) : J);
  },
  join: function Z(J) {
    FK(this.size), J = J !== void 0 ? "" + J : ",";
    var $ = "", X = !0;
    return this.__iterate(function(Y) {
      X ? X = !1 : $ += J, $ += Y !== null && Y !== void 0 ? Y.toString() : "";
    }), $;
  },
  keys: function Z() {
    return this.__iterator(LM);
  },
  map: function Z(J, $) {
    return x7(this, N50(this, J, $));
  },
  reduce: function Z(J, $, X) {
    return pW0(this, J, $, X, arguments.length < 2, !1);
  },
  reduceRight: function Z(J, $, X) {
    return pW0(this, J, $, X, arguments.length < 2, !0);
  },
  reverse: function Z() {
    return x7(this, fn(this, !0));
  },
  slice: function Z(J, $) {
    return x7(this, hn(this, J, $, !0));
  },
  some: function Z(J, $) {
    FK(this.size);
    var X = !1;
    return this.__iterate(function(Y, Q, W) {
      if (J.call($, Y, Q, W))
        return X = !0, !1;
    }), X;
  },
  sort: function Z(J) {
    return x7(this, KM(this, J));
  },
  values: function Z() {
    return this.__iterator(EK);
  },
  butLast: function Z() {
    return this.slice(0, -1);
  },
  isEmpty: function Z() {
    return this.size !== void 0 ? this.size === 0 : !this.some(function() {
      return !0;
    });
  },
  count: function Z(J, $) {
    return QM(J ? this.toSeq().filter(J, $) : this);
  },
  countBy: function Z(J, $) {
    return Is0(this, J, $);
  },
  equals: function Z(J) {
    return v50(this, J);
  },
  entrySeq: function Z() {
    var J = this;
    if (J._cache)
      return new WM(J._cache);
    var $ = J.toSeq().map($a0).toIndexedSeq();
    return $.fromEntrySeq = function() {
      return J.toSeq();
    }, $;
  },
  filterNot: function Z(J, $) {
    return this.filter(En(J), $);
  },
  findEntry: function Z(J, $, X) {
    var Y = X;
    return this.__iterate(function(Q, W, K) {
      if (J.call($, Q, W, K))
        return Y = [W, Q], !1;
    }), Y;
  },
  findKey: function Z(J, $) {
    var X = this.findEntry(J, $);
    return X && X[0];
  },
  findLast: function Z(J, $, X) {
    return this.toKeyedSeq().reverse().find(J, $, X);
  },
  findLastEntry: function Z(J, $, X) {
    return this.toKeyedSeq().reverse().findEntry(J, $, X);
  },
  findLastKey: function Z(J, $) {
    return this.toKeyedSeq().reverse().findKey(J, $);
  },
  first: function Z(J) {
    return this.find(tW0, null, J);
  },
  flatMap: function Z(J, $) {
    return x7(this, fs0(this, J, $));
  },
  flatten: function Z(J) {
    return x7(this, U50(this, J, !0));
  },
  fromEntrySeq: function Z() {
    return new G50(this);
  },
  get: function Z(J, $) {
    return this.find(function(X, Y) {
      return LK(Y, J);
    }, void 0, $);
  },
  getIn: b50,
  groupBy: function Z(J, $) {
    return Ps0(this, J, $);
  },
  has: function Z(J) {
    return this.get(J, w9) !== w9;
  },
  hasIn: Qa0,
  isSubset: function Z(J) {
    return J = typeof J.includes === "function" ? J : kQ(J), this.every(function($) {
      return J.includes($);
    });
  },
  isSuperset: function Z(J) {
    return J = typeof J.isSubset === "function" ? J : kQ(J), J.isSubset(this);
  },
  keyOf: function Z(J) {
    return this.findKey(function($) {
      return LK($, J);
    });
  },
  keySeq: function Z() {
    return this.toSeq().map(Ja0).toIndexedSeq();
  },
  last: function Z(J) {
    return this.toSeq().reverse().first(J);
  },
  lastKeyOf: function Z(J) {
    return this.toKeyedSeq().reverse().keyOf(J);
  },
  max: function Z(J) {
    return XS(this, J);
  },
  maxBy: function Z(J, $) {
    return XS(this, $, J);
  },
  min: function Z(J) {
    return XS(this, J ? uW0(J) : cW0);
  },
  minBy: function Z(J, $) {
    return XS(this, $ ? uW0($) : cW0, J);
  },
  rest: function Z() {
    return this.slice(1);
  },
  skip: function Z(J) {
    return J === 0 ? this : this.slice(Math.max(0, J));
  },
  skipLast: function Z(J) {
    return J === 0 ? this : this.slice(0, -Math.max(0, J));
  },
  skipWhile: function Z(J, $) {
    return x7(this, F50(this, J, $, !0));
  },
  skipUntil: function Z(J, $) {
    return this.skipWhile(En(J), $);
  },
  sortBy: function Z(J, $) {
    return x7(this, KM(this, $, J));
  },
  take: function Z(J) {
    return this.slice(0, Math.max(0, J));
  },
  takeLast: function Z(J) {
    return this.slice(-Math.max(0, J));
  },
  takeWhile: function Z(J, $) {
    return x7(this, ks0(this, J, $));
  },
  takeUntil: function Z(J, $) {
    return this.takeWhile(En(J), $);
  },
  update: function Z(J) {
    return J(this);
  },
  valueSeq: function Z() {
    return this.toIndexedSeq();
  },
  hashCode: function Z() {
    return this.__hash || (this.__hash = Wa0(this));
  }
});
var vQ = kQ.prototype;
vQ[sW0] = !0;
vQ[FS] = vQ.values;
vQ.toJSON = vQ.toArray;
vQ.__toStringMapper = Y_;
vQ.inspect = vQ.toSource = function() {
  return this.toString();
};
vQ.chain = vQ.flatMap;
vQ.contains = vQ.includes;
dO(U3, {
  flip: function Z() {
    return x7(this, H50(this));
  },
  mapEntries: function Z(J, $) {
    var X = this, Y = 0;
    return x7(this, this.toSeq().map(function(Q, W) {
      return J.call($, [W, Q], Y++, X);
    }).fromEntrySeq());
  },
  mapKeys: function Z(J, $) {
    var X = this;
    return x7(this, this.toSeq().flip().map(function(Y, Q) {
      return J.call($, Y, Q, X);
    }).flip());
  }
});
var F_ = U3.prototype;
F_[HS] = !0;
F_[FS] = vQ.entries;
F_.toJSON = x50;
F_.__toStringMapper = function(Z, J) {
  return Y_(J) + ": " + Y_(Z);
};
dO(gO, {
  toKeyedSeq: function Z() {
    return new OS(this, !1);
  },
  filter: function Z(J, $) {
    return x7(this, q50(this, J, $, !1));
  },
  findIndex: function Z(J, $) {
    var X = this.findEntry(J, $);
    return X ? X[0] : -1;
  },
  indexOf: function Z(J) {
    var $ = this.keyOf(J);
    return $ === void 0 ? -1 : $;
  },
  lastIndexOf: function Z(J) {
    var $ = this.lastKeyOf(J);
    return $ === void 0 ? -1 : $;
  },
  reverse: function Z() {
    return x7(this, fn(this, !1));
  },
  slice: function Z(J, $) {
    return x7(this, hn(this, J, $, !1));
  },
  splice: function Z(J, $) {
    var X = arguments.length;
    if ($ = Math.max($ || 0, 0), X === 0 || X === 2 && !$)
      return this;
    J = G_(J, J < 0 ? this.count() : this.size);
    var Y = this.slice(0, J);
    return x7(this, X === 1 ? Y : Y.concat(DN(arguments, 2), this.slice(J + $)));
  },
  findLastIndex: function Z(J, $) {
    var X = this.findLastEntry(J, $);
    return X ? X[0] : -1;
  },
  first: function Z(J) {
    return this.get(0, J);
  },
  flatten: function Z(J) {
    return x7(this, U50(this, J, !1));
  },
  get: function Z(J, $) {
    return J = dL(this, J), J < 0 || this.size === 1 / 0 || this.size !== void 0 && J > this.size ? $ : this.find(function(X, Y) {
      return Y === J;
    }, void 0, $);
  },
  has: function Z(J) {
    return J = dL(this, J), J >= 0 && (this.size !== void 0 ? this.size === 1 / 0 || J < this.size : this.indexOf(J) !== -1);
  },
  interpose: function Z(J) {
    return x7(this, hs0(this, J));
  },
  interleave: function Z() {
    var J = [this].concat(DN(arguments)), $ = YS(this.toSeq(), sG.of, J), X = $.flatten(!0);
    if ($.size)
      X.size = $.size * J.length;
    return x7(this, X);
  },
  keySeq: function Z() {
    return Xa0(0, this.size);
  },
  last: function Z(J) {
    return this.get(-1, J);
  },
  skipWhile: function Z(J, $) {
    return x7(this, F50(this, J, $, !1));
  },
  zip: function Z() {
    var J = [this].concat(DN(arguments));
    return x7(this, YS(this, iW0, J));
  },
  zipAll: function Z() {
    var J = [this].concat(DN(arguments));
    return x7(this, YS(this, iW0, J, !0));
  },
  zipWith: function Z(J) {
    var $ = DN(arguments);
    return $[0] = this, x7(this, YS(this, J, $));
  }
});
var zM = gO.prototype;
zM[GS] = !0;
zM[pL] = !0;
dO(UM, {
  get: function Z(J, $) {
    return this.has(J) ? J : $;
  },
  includes: function Z(J) {
    return this.has(J);
  },
  keySeq: function Z() {
    return this.valueSeq();
  }
});
var qM = UM.prototype;
qM.has = vQ.includes;
qM.contains = qM.includes;
qM.keys = qM.values;
dO(cL, F_);
dO(sG, zM);
dO(EM, qM);
function iW0() {
  return DN(arguments);
}
function y50(Z) {
  return Zi(Z) && AN(Z);
}
var zK = /* @__PURE__ */ function(Z) {
  function J($) {
    return $ === void 0 || $ === null ? _n() : y50($) ? $ : _n().withMutations(function(X) {
      var Y = UM($);
      FK(Y.size), Y.forEach(function(Q) {
        return X.add(Q);
      });
    });
  }
  if (Z)
    J.__proto__ = Z;
  return J.prototype = Object.create(Z && Z.prototype), J.prototype.constructor = J, J.of = function $() {
    return this(arguments);
  }, J.fromKeys = function $(X) {
    return this(U3(X).keySeq());
  }, J.prototype.toString = function $() {
    return this.__toString("OrderedSet {", "}");
  }, J;
}(zS);
zK.isOrderedSet = y50;
var pO = zK.prototype;
pO[pL] = !0;
pO.zip = zM.zip;
pO.zipWith = zM.zipWith;
pO.zipAll = zM.zipAll;
pO.__empty = _n;
pO.__make = g50;
function g50(Z, J) {
  var $ = Object.create(pO);
  return $.size = Z ? Z.size : 0, $._map = Z, $.__ownerID = J, $;
}
var oW0;
function _n() {
  return oW0 || (oW0 = g50(rT()));
}
function Ga0(Z) {
  if (mO(Z))
    throw new Error("Can not call `Record` with an immutable Record as default values. Use a plain javascript object instead.");
  if (BN(Z))
    throw new Error("Can not call `Record` with an immutable Collection as default values. Use a plain javascript object instead.");
  if (Z === null || typeof Z !== "object")
    throw new Error("Can not call `Record` with a non-object as default values. Use a plain javascript object instead.");
}
var WY = function Z(J, $) {
  var X;
  Ga0(J);
  var Y = function W(K) {
    var G = this;
    if (K instanceof Y)
      return K;
    if (!(this instanceof Y))
      return new Y(K);
    if (!X) {
      X = !0;
      var H = Object.keys(J), N = Q._indices = {};
      Q._name = $, Q._keys = H, Q._defaultValues = J;
      for (var q = 0;q < H.length; q++) {
        var U = H[q];
        if (N[U] = q, Q[U])
          typeof console === "object" && console.warn && console.warn("Cannot define " + $i(this) + ' with property "' + U + '" since that property name is part of the Record API.');
        else
          Ha0(Q, U);
      }
    }
    return this.__ownerID = void 0, this._values = jN().withMutations(function(F) {
      F.setSize(G._keys.length), U3(K).forEach(function(E, R) {
        F.set(G._indices[R], E === G._defaultValues[R] ? void 0 : E);
      });
    }), this;
  }, Q = Y.prototype = Object.create(e7);
  if (Q.constructor = Y, $)
    Y.displayName = $;
  return Y;
};
WY.prototype.toString = function Z() {
  var J = $i(this) + " { ", $ = this._keys, X;
  for (var Y = 0, Q = $.length;Y !== Q; Y++)
    X = $[Y], J += (Y ? ", " : "") + X + ": " + Y_(this.get(X));
  return J + " }";
};
WY.prototype.equals = function Z(J) {
  return this === J || mO(J) && FM(this).equals(FM(J));
};
WY.prototype.hashCode = function Z() {
  return FM(this).hashCode();
};
WY.prototype.has = function Z(J) {
  return this._indices.hasOwnProperty(J);
};
WY.prototype.get = function Z(J, $) {
  if (!this.has(J))
    return $;
  var X = this._indices[J], Y = this._values.get(X);
  return Y === void 0 ? this._defaultValues[J] : Y;
};
WY.prototype.set = function Z(J, $) {
  if (this.has(J)) {
    var X = this._values.set(this._indices[J], $ === this._defaultValues[J] ? void 0 : $);
    if (X !== this._values && !this.__ownerID)
      return Ji(this, X);
  }
  return this;
};
WY.prototype.remove = function Z(J) {
  return this.set(J);
};
WY.prototype.clear = function Z() {
  var J = this._values.clear().setSize(this._keys.length);
  return this.__ownerID ? this : Ji(this, J);
};
WY.prototype.wasAltered = function Z() {
  return this._values.wasAltered();
};
WY.prototype.toSeq = function Z() {
  return FM(this);
};
WY.prototype.toJS = function Z() {
  return qS(this);
};
WY.prototype.entries = function Z() {
  return this.__iterator(OK);
};
WY.prototype.__iterator = function Z(J, $) {
  return FM(this).__iterator(J, $);
};
WY.prototype.__iterate = function Z(J, $) {
  return FM(this).__iterate(J, $);
};
WY.prototype.__ensureOwner = function Z(J) {
  if (J === this.__ownerID)
    return this;
  var $ = this._values.__ensureOwner(J);
  if (!J)
    return this.__ownerID = J, this._values = $, this;
  return Ji(this, $, J);
};
WY.isRecord = mO;
WY.getDescriptiveName = $i;
var e7 = WY.prototype;
e7[J50] = !0;
e7[K_] = e7.remove;
e7.deleteIn = e7.removeIn = rn;
e7.getIn = b50;
e7.hasIn = vQ.hasIn;
e7.merge = E50;
e7.mergeWith = O50;
e7.mergeIn = dn;
e7.mergeDeep = D50;
e7.mergeDeepWith = M50;
e7.mergeDeepIn = mn;
e7.setIn = pn;
e7.update = un;
e7.updateIn = cn;
e7.withMutations = q_;
e7.asMutable = N_;
e7.asImmutable = H_;
e7[FS] = e7.entries;
e7.toJSON = e7.toObject = vQ.toObject;
e7.inspect = e7.toSource = function() {
  return this.toString();
};
function Ji(Z, J, $) {
  var X = Object.create(Object.getPrototypeOf(Z));
  return X._values = J, X.__ownerID = $, X;
}
function $i(Z) {
  return Z.constructor.displayName || Z.constructor.name || "Record";
}
function FM(Z) {
  return vn(Z._keys.map(function(J) {
    return [J, Z.get(J)];
  }));
}
function Ha0(Z, J) {
  try {
    Object.defineProperty(Z, J, {
      get: function() {
        return this.get(J);
      },
      set: function($) {
        Z_(this.__ownerID, "Cannot set on an immutable record."), this.set(J, $);
      }
    });
  } catch ($) {}
}

// node_modules/molstar/lib/mol-math/linear-algebra/3d/vec2.js
function h0() {
  return h0.zero();
}
(function(Z) {
  function J() {
    let h = [0.1, 0];
    return h[0] = 0, h;
  }
  Z.zero = J;
  function $(h) {
    let x = J();
    return x[0] = h[0], x[1] = h[1], x;
  }
  Z.clone = $;
  function X(h) {
    return Q(h.x, h.y);
  }
  Z.fromObj = X;
  function Y(h) {
    return { x: h[0], y: h[1] };
  }
  Z.toObj = Y;
  function Q(h, x) {
    let b = J();
    return b[0] = h, b[1] = x, b;
  }
  Z.create = Q;
  function W(h) {
    return Number.isNaN(h[0]) || Number.isNaN(h[1]);
  }
  Z.hasNaN = W;
  function K(h, x, b) {
    return x[b + 0] = h[0], x[b + 1] = h[1], x;
  }
  Z.toArray = K;
  function G(h, x, b) {
    return h[0] = x[b + 0], h[1] = x[b + 1], h;
  }
  Z.fromArray = G;
  function H(h, x) {
    return h[0] = x[0], h[1] = x[1], h;
  }
  Z.copy = H;
  function N(h, x, b) {
    return h[0] = x, h[1] = b, h;
  }
  Z.set = N;
  function q(h, x, b) {
    return h[0] = x[0] + b[0], h[1] = x[1] + b[1], h;
  }
  Z.add = q;
  function U(h, x, b) {
    return h[0] = x[0] - b[0], h[1] = x[1] - b[1], h;
  }
  Z.sub = U;
  function F(h, x, b) {
    return h[0] = x[0] * b[0], h[1] = x[1] * b[1], h;
  }
  Z.mul = F;
  function E(h, x, b) {
    return h[0] = x[0] / b[0], h[1] = x[1] / b[1], h;
  }
  Z.div = E;
  function R(h, x, b) {
    return h[0] = x[0] * b, h[1] = x[1] * b, h;
  }
  Z.scale = R;
  function z(h, x) {
    return h[0] = Math.round(x[0]), h[1] = Math.round(x[1]), h;
  }
  Z.round = z;
  function D(h, x) {
    return h[0] = Math.ceil(x[0]), h[1] = Math.ceil(x[1]), h;
  }
  Z.ceil = D;
  function A(h, x) {
    return h[0] = Math.floor(x[0]), h[1] = Math.floor(x[1]), h;
  }
  Z.floor = A;
  function B(h, x) {
    let b = x[0] - h[0], g = x[1] - h[1];
    return Math.sqrt(b * b + g * g);
  }
  Z.distance = B;
  function T(h, x) {
    let b = x[0] - h[0], g = x[1] - h[1];
    return b * b + g * g;
  }
  Z.squaredDistance = T;
  function w(h) {
    let x = h[0], b = h[1];
    return Math.sqrt(x * x + b * b);
  }
  Z.magnitude = w;
  function V(h) {
    let x = h[0], b = h[1];
    return x * x + b * b;
  }
  Z.squaredMagnitude = V;
  function P(h, x, b) {
    return R(h, S(h, x), b);
  }
  Z.setMagnitude = P;
  function I(h, x) {
    return h[0] = 1 / x[0], h[1] = 1 / x[1], h;
  }
  Z.inverse = I;
  function S(h, x) {
    let b = x[0], g = x[1], m = b * b + g * g;
    if (m > 0)
      m = 1 / Math.sqrt(m), h[0] = x[0] * m, h[1] = x[1] * m;
    return h;
  }
  Z.normalize = S;
  function f(h, x) {
    return h[0] === x[0] && h[1] === x[1];
  }
  Z.areEqual = f;
  function v(h, x) {
    return `[${h[0].toPrecision(x)} ${h[1].toPrecision(x)}}]`;
  }
  Z.toString = v;
})(h0 || (h0 = {}));

// node_modules/molstar/lib/mol-math/linear-algebra/3d/common.js
var u8 = 0.000001;
function dZ(Z, J, $) {
  return Math.abs(Z - J) <= $;
}

// node_modules/molstar/lib/mol-math/linear-algebra/3d/mat3.js
function h2() {
  return h2.zero();
}
(function(Z) {
  function J() {
    let a = [0.1, 0, 0, 0, 0, 0, 0, 0, 0];
    return a[0] = 0, a;
  }
  Z.zero = J;
  function $() {
    let a = J();
    return a[0] = 1, a[1] = 0, a[2] = 0, a[3] = 0, a[4] = 1, a[5] = 0, a[6] = 0, a[7] = 0, a[8] = 1, a;
  }
  Z.identity = $;
  function X(a) {
    return a[0] = 1, a[1] = 0, a[2] = 0, a[3] = 0, a[4] = 1, a[5] = 0, a[6] = 0, a[7] = 0, a[8] = 1, a;
  }
  Z.setIdentity = X;
  function Y(a, Q0, $0) {
    return Q0[$0 + 0] = a[0], Q0[$0 + 1] = a[1], Q0[$0 + 2] = a[2], Q0[$0 + 3] = a[3], Q0[$0 + 4] = a[4], Q0[$0 + 5] = a[5], Q0[$0 + 6] = a[6], Q0[$0 + 7] = a[7], Q0[$0 + 8] = a[8], Q0;
  }
  Z.toArray = Y;
  function Q(a, Q0, $0) {
    return a[0] = Q0[$0 + 0], a[1] = Q0[$0 + 1], a[2] = Q0[$0 + 2], a[3] = Q0[$0 + 3], a[4] = Q0[$0 + 4], a[5] = Q0[$0 + 5], a[6] = Q0[$0 + 6], a[7] = Q0[$0 + 7], a[8] = Q0[$0 + 8], a;
  }
  Z.fromArray = Q;
  function W(a, Q0, $0, R0) {
    return a[0] = Q0[0], a[1] = Q0[1], a[2] = Q0[2], a[3] = $0[0], a[4] = $0[1], a[5] = $0[2], a[6] = R0[0], a[7] = R0[1], a[8] = R0[2], a;
  }
  Z.fromColumns = W;
  function K(a, Q0) {
    return a[0] = Q0[0], a[1] = Q0[1], a[2] = Q0[2], a[3] = Q0[4], a[4] = Q0[5], a[5] = Q0[6], a[6] = Q0[8], a[7] = Q0[9], a[8] = Q0[10], a;
  }
  Z.fromMat4 = K;
  let G = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
  function H(a, Q0, $0) {
    return e.fromEuler(G, Q0, $0), K(a, G);
  }
  Z.fromEuler = H;
  function N(a, Q0, $0) {
    return e.fromRotation(G, Q0, $0), K(a, G);
  }
  Z.fromRotation = N;
  function q(a, Q0, $0, R0, X0, E0, V0, u0, N0) {
    let q0 = J();
    return q0[0] = a, q0[1] = Q0, q0[2] = $0, q0[3] = R0, q0[4] = X0, q0[5] = E0, q0[6] = V0, q0[7] = u0, q0[8] = N0, q0;
  }
  Z.create = q;
  let U = $();
  function F(a, Q0) {
    return z(a, U, typeof Q0 === "undefined" ? u8 : Q0);
  }
  Z.isIdentity = F;
  function E(a) {
    for (let Q0 = 0;Q0 < 9; Q0++)
      if (Number.isNaN(a[Q0]))
        return !0;
    return !1;
  }
  Z.hasNaN = E;
  function R(a) {
    return B(J(), a);
  }
  Z.clone = R;
  function z(a, Q0, $0) {
    for (let R0 = 0;R0 < 9; R0++)
      if (Math.abs(a[R0] - Q0[R0]) > $0)
        return !1;
    return !0;
  }
  Z.areEqual = z;
  function D(a, Q0, $0, R0) {
    a[3 * $0 + Q0] = R0;
  }
  Z.setValue = D;
  function A(a, Q0, $0) {
    return a[3 * $0 + Q0];
  }
  Z.getValue = A;
  function B(a, Q0) {
    return a[0] = Q0[0], a[1] = Q0[1], a[2] = Q0[2], a[3] = Q0[3], a[4] = Q0[4], a[5] = Q0[5], a[6] = Q0[6], a[7] = Q0[7], a[8] = Q0[8], a;
  }
  Z.copy = B;
  function T(a, Q0) {
    if (a === Q0) {
      let $0 = Q0[1], R0 = Q0[2], X0 = Q0[5];
      a[1] = Q0[3], a[2] = Q0[6], a[3] = $0, a[5] = Q0[7], a[6] = R0, a[7] = X0;
    } else
      a[0] = Q0[0], a[1] = Q0[3], a[2] = Q0[6], a[3] = Q0[1], a[4] = Q0[4], a[5] = Q0[7], a[6] = Q0[2], a[7] = Q0[5], a[8] = Q0[8];
    return a;
  }
  Z.transpose = T;
  function w(a, Q0) {
    let $0 = Q0[0], R0 = Q0[1], X0 = Q0[2], E0 = Q0[3], V0 = Q0[4], u0 = Q0[5], N0 = Q0[6], q0 = Q0[7], A0 = Q0[8], S0 = A0 * V0 - u0 * q0, a0 = -A0 * E0 + u0 * N0, D1 = q0 * E0 - V0 * N0, Y1 = $0 * S0 + R0 * a0 + X0 * D1;
    if (!Y1)
      return console.warn("non-invertible matrix.", Q0), a;
    return Y1 = 1 / Y1, a[0] = S0 * Y1, a[1] = (-A0 * R0 + X0 * q0) * Y1, a[2] = (u0 * R0 - X0 * V0) * Y1, a[3] = a0 * Y1, a[4] = (A0 * $0 - X0 * N0) * Y1, a[5] = (-u0 * $0 + X0 * E0) * Y1, a[6] = D1 * Y1, a[7] = (-q0 * $0 + R0 * N0) * Y1, a[8] = (V0 * $0 - R0 * E0) * Y1, a;
  }
  Z.invert = w;
  function V(a, Q0) {
    if (a === Q0)
      a[3] = Q0[1], a[6] = Q0[2], a[7] = Q0[5];
    else
      a[0] = Q0[0], a[1] = Q0[1], a[2] = Q0[2], a[3] = Q0[1], a[4] = Q0[4], a[5] = Q0[5], a[6] = Q0[2], a[7] = Q0[5], a[8] = Q0[8];
    return a;
  }
  Z.symmtricFromUpper = V;
  function P(a, Q0) {
    if (a === Q0)
      a[1] = Q0[3], a[2] = Q0[6], a[5] = Q0[7];
    else
      a[0] = Q0[0], a[1] = Q0[3], a[2] = Q0[6], a[3] = Q0[3], a[4] = Q0[4], a[5] = Q0[7], a[6] = Q0[6], a[7] = Q0[7], a[8] = Q0[8];
    return a;
  }
  Z.symmtricFromLower = P;
  function I(a) {
    let Q0 = a[0], $0 = a[1], R0 = a[2], X0 = a[3], E0 = a[4], V0 = a[5], u0 = a[6], N0 = a[7], q0 = a[8], A0 = q0 * E0 - V0 * N0, S0 = -q0 * X0 + V0 * u0, a0 = N0 * X0 - E0 * u0;
    return Q0 * A0 + $0 * S0 + R0 * a0;
  }
  Z.determinant = I;
  function S(a) {
    return a[0] + a[4] + a[8];
  }
  Z.trace = S;
  function f(a, Q0, $0) {
    return a[0] = Q0[0] - $0[0], a[1] = Q0[1] - $0[1], a[2] = Q0[2] - $0[2], a[3] = Q0[3] - $0[3], a[4] = Q0[4] - $0[4], a[5] = Q0[5] - $0[5], a[6] = Q0[6] - $0[6], a[7] = Q0[7] - $0[7], a[8] = Q0[8] - $0[8], a;
  }
  Z.sub = f;
  function v(a, Q0, $0) {
    return a[0] = Q0[0] + $0[0], a[1] = Q0[1] + $0[1], a[2] = Q0[2] + $0[2], a[3] = Q0[3] + $0[3], a[4] = Q0[4] + $0[4], a[5] = Q0[5] + $0[5], a[6] = Q0[6] + $0[6], a[7] = Q0[7] + $0[7], a[8] = Q0[8] + $0[8], a;
  }
  Z.add = v;
  function h(a, Q0, $0) {
    let R0 = Q0[0], X0 = Q0[1], E0 = Q0[2], V0 = Q0[3], u0 = Q0[4], N0 = Q0[5], q0 = Q0[6], A0 = Q0[7], S0 = Q0[8], a0 = $0[0], D1 = $0[1], Y1 = $0[2], u1 = $0[3], b0 = $0[4], x0 = $0[5], m0 = $0[6], e0 = $0[7], p = $0[8];
    return a[0] = a0 * R0 + D1 * V0 + Y1 * q0, a[1] = a0 * X0 + D1 * u0 + Y1 * A0, a[2] = a0 * E0 + D1 * N0 + Y1 * S0, a[3] = u1 * R0 + b0 * V0 + x0 * q0, a[4] = u1 * X0 + b0 * u0 + x0 * A0, a[5] = u1 * E0 + b0 * N0 + x0 * S0, a[6] = m0 * R0 + e0 * V0 + p * q0, a[7] = m0 * X0 + e0 * u0 + p * A0, a[8] = m0 * E0 + e0 * N0 + p * S0, a;
  }
  Z.mul = h;
  function x(a, Q0, $0) {
    return a[0] = Q0[0] - $0, a[1] = Q0[1] - $0, a[2] = Q0[2] - $0, a[3] = Q0[3] - $0, a[4] = Q0[4] - $0, a[5] = Q0[5] - $0, a[6] = Q0[6] - $0, a[7] = Q0[7] - $0, a[8] = Q0[8] - $0, a;
  }
  Z.subScalar = x;
  function b(a, Q0, $0) {
    return a[0] = Q0[0] + $0, a[1] = Q0[1] + $0, a[2] = Q0[2] + $0, a[3] = Q0[3] + $0, a[4] = Q0[4] + $0, a[5] = Q0[5] + $0, a[6] = Q0[6] + $0, a[7] = Q0[7] + $0, a[8] = Q0[8] + $0, a;
  }
  Z.addScalar = b;
  function g(a, Q0, $0) {
    return a[0] = Q0[0] * $0, a[1] = Q0[1] * $0, a[2] = Q0[2] * $0, a[3] = Q0[3] * $0, a[4] = Q0[4] * $0, a[5] = Q0[5] * $0, a[6] = Q0[6] * $0, a[7] = Q0[7] * $0, a[8] = Q0[8] * $0, a;
  }
  Z.mulScalar = g;
  let m = Math.PI / 3, i = J();
  function r(a, Q0) {
    let $0 = Q0[1] * Q0[1] + Q0[2] * Q0[2] + Q0[5] * Q0[5];
    if ($0 === 0)
      a[0] = Q0[0], a[1] = Q0[4], a[2] = Q0[8];
    else {
      let R0 = S(Q0) / 3, X0 = Q0[0] - R0, E0 = Q0[4] - R0, V0 = Q0[8] - R0, u0 = X0 * X0 + E0 * E0 + V0 * V0 + 2 * $0, N0 = Math.sqrt(u0 / 6);
      g(i, Z.Identity, R0), f(i, Q0, i), g(i, i, 1 / N0);
      let q0 = I(i) / 2, A0 = q0 <= -1 ? m : q0 >= 1 ? 0 : Math.acos(q0) / 3;
      a[0] = R0 + 2 * N0 * Math.cos(A0), a[2] = R0 + 2 * N0 * Math.cos(A0 + 2 * m), a[1] = 3 * R0 - a[0] - a[2];
    }
    return a;
  }
  Z.symmetricEigenvalues = r;
  let Y0 = [0.1, 0, 0], c = [0.1, 0, 0], n = [0.1, 0, 0], l = [0.1, 0, 0], u = [0.1, 0, 0], G0 = [0.1, 0, 0];
  function F0(a, Q0, $0) {
    M.set(Y0, Q0[0] - $0, Q0[1], Q0[2]), M.set(c, Q0[1], Q0[4] - $0, Q0[5]), M.set(n, Q0[2], Q0[5], Q0[8] - $0), M.cross(l, Y0, c), M.cross(u, Y0, n), M.cross(G0, c, n);
    let R0 = M.dot(l, l), X0 = M.dot(u, u), E0 = M.dot(G0, G0), V0 = R0, u0 = 0;
    if (X0 > V0)
      V0 = X0, u0 = 1;
    if (E0 > V0)
      u0 = 2;
    if (u0 === 0)
      M.scale(a, l, 1 / Math.sqrt(R0));
    else if (u0 === 1)
      M.scale(a, u, 1 / Math.sqrt(X0));
    else
      M.scale(a, G0, 1 / Math.sqrt(E0));
    return a;
  }
  Z.eigenvector = F0;
  function t(a, Q0) {
    return K(a, Q0), w(a, a), T(a, a), a;
  }
  Z.directionTransform = t, Z.Identity = $();
  function Z0(a, Q0) {
    return a[0] * Q0[0] + a[1] * Q0[1] + a[2] * Q0[2] + a[3] * Q0[3] + a[4] * Q0[4] + a[5] * Q0[5] + a[6] * Q0[6] + a[7] * Q0[7] + a[8] * Q0[8];
  }
  Z.innerProduct = Z0;
  function U0(a, Q0) {
    let $0 = Q0[0], R0 = Q0[1], X0 = Q0[2], E0 = Q0[4], V0 = Q0[5], u0 = Q0[6], N0 = Q0[8], q0 = Q0[9], A0 = Q0[10];
    return a[0] = V0 * A0 - u0 * q0, a[1] = u0 * N0 - E0 * A0, a[2] = E0 * q0 - V0 * N0, a[3] = q0 * X0 - A0 * R0, a[4] = A0 * $0 - N0 * X0, a[5] = N0 * R0 - q0 * $0, a[6] = R0 * u0 - X0 * V0, a[7] = X0 * E0 - $0 * u0, a[8] = $0 * V0 - R0 * E0, a;
  }
  Z.adjointFromMat4 = U0;
})(h2 || (h2 = {}));

// node_modules/molstar/lib/mol-util/type-helpers.js
function uO(Z) {
  return Object.keys(Z);
}
function T8(Z) {
  throw new Error("unreachable");
}
function lL(Z) {
  return typeof (Z === null || Z === void 0 ? void 0 : Z.then) === "function";
}

// node_modules/molstar/lib/mol-math/interpolate.js
function aG(Z, J, $) {
  return (Z - J) / ($ - J);
}
function x8(Z, J, $) {
  return Math.max(J, Math.min($, Z));
}
function Na0(Z) {
  return x8(Z, 0, 1);
}
function pZ(Z, J, $) {
  return Z + (J - Z) * $;
}
function DM(Z, J, $, X, Y, Q) {
  let W = ($ - Z) * Q, K = (X - J) * Q, G = Y * Y, H = Y * G;
  return (2 * J - 2 * $ + W + K) * H + (-3 * J + 3 * $ - 2 * W - K) * G + W * Y + J;
}
function DS(Z, J, $, X) {
  let Y = 1 - X;
  return Y * Y * Z + 2 * Y * X * J + X * X * $;
}
function MS(Z, J, $) {
  return $ = Na0(aG($, Z, J)), $ * $ * (3 - 2 * $);
}

// node_modules/molstar/lib/mol-math/linear-algebra/3d/quat.js
function k8() {
  return k8.zero();
}
(function(Z) {
  function J() {
    let X0 = [0.1, 0, 0, 0];
    return X0[0] = 0, X0;
  }
  Z.zero = J;
  function $() {
    let X0 = J();
    return X0[3] = 1, X0;
  }
  Z.identity = $;
  function X(X0) {
    X0[0] = 0, X0[1] = 0, X0[2] = 0, X0[3] = 1;
  }
  Z.setIdentity = X;
  function Y(X0) {
    return Number.isNaN(X0[0]) || Number.isNaN(X0[1]) || Number.isNaN(X0[2]) || Number.isNaN(X0[3]);
  }
  Z.hasNaN = Y;
  function Q(X0, E0, V0, u0) {
    let N0 = $();
    return N0[0] = X0, N0[1] = E0, N0[2] = V0, N0[3] = u0, N0;
  }
  Z.create = Q;
  function W(X0, E0, V0) {
    V0 = V0 * 0.5;
    let u0 = Math.sin(V0);
    return X0[0] = u0 * E0[0], X0[1] = u0 * E0[1], X0[2] = u0 * E0[2], X0[3] = Math.cos(V0), X0;
  }
  Z.setAxisAngle = W;
  function K(X0, E0) {
    let V0 = Math.acos(E0[3]) * 2, u0 = Math.sin(V0 / 2);
    if (u0 !== 0)
      X0[0] = E0[0] / u0, X0[1] = E0[1] / u0, X0[2] = E0[2] / u0;
    else
      X0[0] = 1, X0[1] = 0, X0[2] = 0;
    return V0;
  }
  Z.getAxisAngle = K;
  function G(X0, E0, V0) {
    let u0 = E0[0], N0 = E0[1], q0 = E0[2], A0 = E0[3], S0 = V0[0], a0 = V0[1], D1 = V0[2], Y1 = V0[3];
    return X0[0] = u0 * Y1 + A0 * S0 + N0 * D1 - q0 * a0, X0[1] = N0 * Y1 + A0 * a0 + q0 * S0 - u0 * D1, X0[2] = q0 * Y1 + A0 * D1 + u0 * a0 - N0 * S0, X0[3] = A0 * Y1 - u0 * S0 - N0 * a0 - q0 * D1, X0;
  }
  Z.multiply = G;
  function H(X0, E0, V0) {
    V0 *= 0.5;
    let u0 = E0[0], N0 = E0[1], q0 = E0[2], A0 = E0[3], S0 = Math.sin(V0), a0 = Math.cos(V0);
    return X0[0] = u0 * a0 + A0 * S0, X0[1] = N0 * a0 + q0 * S0, X0[2] = q0 * a0 - N0 * S0, X0[3] = A0 * a0 - u0 * S0, X0;
  }
  Z.rotateX = H;
  function N(X0, E0, V0) {
    V0 *= 0.5;
    let u0 = E0[0], N0 = E0[1], q0 = E0[2], A0 = E0[3], S0 = Math.sin(V0), a0 = Math.cos(V0);
    return X0[0] = u0 * a0 - q0 * S0, X0[1] = N0 * a0 + A0 * S0, X0[2] = q0 * a0 + u0 * S0, X0[3] = A0 * a0 - N0 * S0, X0;
  }
  Z.rotateY = N;
  function q(X0, E0, V0) {
    V0 *= 0.5;
    let u0 = E0[0], N0 = E0[1], q0 = E0[2], A0 = E0[3], S0 = Math.sin(V0), a0 = Math.cos(V0);
    return X0[0] = u0 * a0 + N0 * S0, X0[1] = N0 * a0 - u0 * S0, X0[2] = q0 * a0 + A0 * S0, X0[3] = A0 * a0 - q0 * S0, X0;
  }
  Z.rotateZ = q;
  function U(X0, E0) {
    let V0 = E0[0], u0 = E0[1], N0 = E0[2];
    return X0[0] = V0, X0[1] = u0, X0[2] = N0, X0[3] = Math.sqrt(Math.abs(1 - V0 * V0 - u0 * u0 - N0 * N0)), X0;
  }
  Z.calculateW = U;
  function F(X0, E0, V0, u0) {
    let N0 = E0[0], q0 = E0[1], A0 = E0[2], S0 = E0[3], a0 = V0[0], D1 = V0[1], Y1 = V0[2], u1 = V0[3], b0, x0, m0, e0, p;
    if (x0 = N0 * a0 + q0 * D1 + A0 * Y1 + S0 * u1, x0 < 0)
      x0 = -x0, a0 = -a0, D1 = -D1, Y1 = -Y1, u1 = -u1;
    if (1 - x0 > 0.000001)
      b0 = Math.acos(x0), m0 = Math.sin(b0), e0 = Math.sin((1 - u0) * b0) / m0, p = Math.sin(u0 * b0) / m0;
    else
      e0 = 1 - u0, p = u0;
    return X0[0] = e0 * N0 + p * a0, X0[1] = e0 * q0 + p * D1, X0[2] = e0 * A0 + p * Y1, X0[3] = e0 * S0 + p * u1, X0;
  }
  Z.slerp = F;
  function E(X0, E0) {
    let V0 = E0[0], u0 = E0[1], N0 = E0[2], q0 = E0[3], A0 = V0 * V0 + u0 * u0 + N0 * N0 + q0 * q0, S0 = A0 ? 1 / A0 : 0;
    return X0[0] = -V0 * S0, X0[1] = -u0 * S0, X0[2] = -N0 * S0, X0[3] = q0 * S0, X0;
  }
  Z.invert = E;
  function R(X0, E0) {
    return X0[0] = -E0[0], X0[1] = -E0[1], X0[2] = -E0[2], X0[3] = E0[3], X0;
  }
  Z.conjugate = R;
  function z(X0, E0) {
    return X0[0] * E0[0] + X0[1] * E0[1] + X0[2] * E0[2] + X0[3] * E0[3];
  }
  Z.dot = z;
  function D(X0, E0) {
    let V0 = E0[0] + E0[4] + E0[8], u0;
    if (V0 > 0)
      u0 = Math.sqrt(V0 + 1), X0[3] = 0.5 * u0, u0 = 0.5 / u0, X0[0] = (E0[5] - E0[7]) * u0, X0[1] = (E0[6] - E0[2]) * u0, X0[2] = (E0[1] - E0[3]) * u0;
    else {
      let N0 = 0;
      if (E0[4] > E0[0])
        N0 = 1;
      if (E0[8] > E0[N0 * 3 + N0])
        N0 = 2;
      let q0 = (N0 + 1) % 3, A0 = (N0 + 2) % 3;
      u0 = Math.sqrt(E0[N0 * 3 + N0] - E0[q0 * 3 + q0] - E0[A0 * 3 + A0] + 1), X0[N0] = 0.5 * u0, u0 = 0.5 / u0, X0[3] = (E0[q0 * 3 + A0] - E0[A0 * 3 + q0]) * u0, X0[q0] = (E0[q0 * 3 + N0] + E0[N0 * 3 + q0]) * u0, X0[A0] = (E0[A0 * 3 + N0] + E0[N0 * 3 + A0]) * u0;
    }
    return X0;
  }
  Z.fromMat3 = D;
  let A = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
  function B(X0, E0) {
    return h2.fromMat4(A, E0), D(X0, A);
  }
  Z.fromMat4 = B;
  function T(X0, E0, V0) {
    let [u0, N0, q0] = E0, A0 = Math.cos(u0 / 2), S0 = Math.cos(N0 / 2), a0 = Math.cos(q0 / 2), D1 = Math.sin(u0 / 2), Y1 = Math.sin(N0 / 2), u1 = Math.sin(q0 / 2);
    switch (V0) {
      case "XYZ":
        X0[0] = D1 * S0 * a0 + A0 * Y1 * u1, X0[1] = A0 * Y1 * a0 - D1 * S0 * u1, X0[2] = A0 * S0 * u1 + D1 * Y1 * a0, X0[3] = A0 * S0 * a0 - D1 * Y1 * u1;
        break;
      case "YXZ":
        X0[0] = D1 * S0 * a0 + A0 * Y1 * u1, X0[1] = A0 * Y1 * a0 - D1 * S0 * u1, X0[2] = A0 * S0 * u1 - D1 * Y1 * a0, X0[3] = A0 * S0 * a0 + D1 * Y1 * u1;
        break;
      case "ZXY":
        X0[0] = D1 * S0 * a0 - A0 * Y1 * u1, X0[1] = A0 * Y1 * a0 + D1 * S0 * u1, X0[2] = A0 * S0 * u1 + D1 * Y1 * a0, X0[3] = A0 * S0 * a0 - D1 * Y1 * u1;
        break;
      case "ZYX":
        X0[0] = D1 * S0 * a0 - A0 * Y1 * u1, X0[1] = A0 * Y1 * a0 + D1 * S0 * u1, X0[2] = A0 * S0 * u1 - D1 * Y1 * a0, X0[3] = A0 * S0 * a0 + D1 * Y1 * u1;
        break;
      case "YZX":
        X0[0] = D1 * S0 * a0 + A0 * Y1 * u1, X0[1] = A0 * Y1 * a0 + D1 * S0 * u1, X0[2] = A0 * S0 * u1 - D1 * Y1 * a0, X0[3] = A0 * S0 * a0 - D1 * Y1 * u1;
        break;
      case "XZY":
        X0[0] = D1 * S0 * a0 - A0 * Y1 * u1, X0[1] = A0 * Y1 * a0 - D1 * S0 * u1, X0[2] = A0 * S0 * u1 + D1 * Y1 * a0, X0[3] = A0 * S0 * a0 + D1 * Y1 * u1;
        break;
      default:
        T8(V0);
    }
    return X0;
  }
  Z.fromEuler = T;
  let w = [0, 0, 0];
  function V(X0, E0, V0) {
    let u0 = M.dot(E0, V0) + 1;
    if (u0 < u8)
      if (u0 = 0, Math.abs(E0[0]) > Math.abs(E0[2]))
        M.set(w, -E0[1], E0[0], 0);
      else
        M.set(w, 0, -E0[2], E0[1]);
    else
      M.cross(w, E0, V0);
    return X0[0] = w[0], X0[1] = w[1], X0[2] = w[2], X0[3] = u0, l(X0, X0), X0;
  }
  Z.fromUnitVec3 = V;
  let P = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
  function I(X0, E0, V0, u0) {
    return e.fromBasis(P, E0, V0, u0), B(X0, P);
  }
  Z.fromBasis = I;
  function S(X0) {
    let E0 = J();
    return E0[0] = X0[0], E0[1] = X0[1], E0[2] = X0[2], E0[3] = X0[3], E0;
  }
  Z.clone = S;
  function f(X0) {
    return Q(X0.x, X0.y, X0.z, X0.w);
  }
  Z.fromObj = f;
  function v(X0) {
    return { x: X0[0], y: X0[1], z: X0[2], w: X0[3] };
  }
  Z.toObj = v;
  function h(X0, E0, V0) {
    return E0[V0 + 0] = X0[0], E0[V0 + 1] = X0[1], E0[V0 + 2] = X0[2], E0[V0 + 3] = X0[3], E0;
  }
  Z.toArray = h;
  function x(X0, E0, V0) {
    return X0[0] = E0[V0 + 0], X0[1] = E0[V0 + 1], X0[2] = E0[V0 + 2], X0[3] = E0[V0 + 3], X0;
  }
  Z.fromArray = x;
  function b(X0, E0) {
    return X0[0] = E0[0], X0[1] = E0[1], X0[2] = E0[2], X0[3] = E0[3], X0;
  }
  Z.copy = b;
  function g(X0, E0, V0, u0, N0) {
    return X0[0] = E0, X0[1] = V0, X0[2] = u0, X0[3] = N0, X0;
  }
  Z.set = g;
  function m(X0, E0) {
    return X0[0] === E0[0] && X0[1] === E0[1] && X0[2] === E0[2] && X0[3] === E0[3];
  }
  Z.exactEquals = m;
  function i(X0, E0) {
    let V0 = X0[0], u0 = X0[1], N0 = X0[2], q0 = X0[3], A0 = E0[0], S0 = E0[1], a0 = E0[2], D1 = E0[3];
    return Math.abs(V0 - A0) <= u8 * Math.max(1, Math.abs(V0), Math.abs(A0)) && Math.abs(u0 - S0) <= u8 * Math.max(1, Math.abs(u0), Math.abs(S0)) && Math.abs(N0 - a0) <= u8 * Math.max(1, Math.abs(N0), Math.abs(a0)) && Math.abs(q0 - D1) <= u8 * Math.max(1, Math.abs(q0), Math.abs(D1));
  }
  Z.equals = i;
  function r(X0, E0, V0) {
    return X0[0] = E0[0] + V0[0], X0[1] = E0[1] + V0[1], X0[2] = E0[2] + V0[2], X0[3] = E0[3] + V0[3], X0;
  }
  Z.add = r;
  function Y0(X0) {
    let E0 = X0[0], V0 = X0[1], u0 = X0[2], N0 = X0[3];
    return Math.sqrt(E0 * E0 + V0 * V0 + u0 * u0 + N0 * N0);
  }
  Z.magnitude = Y0;
  function c(X0) {
    let E0 = X0[0], V0 = X0[1], u0 = X0[2], N0 = X0[3];
    return E0 * E0 + V0 * V0 + u0 * u0 + N0 * N0;
  }
  Z.squaredMagnitude = c;
  function n(X0, E0) {
    return 2 * Math.acos(Math.abs(x8(z(X0, E0), -1, 1)));
  }
  Z.angle = n;
  function l(X0, E0) {
    let V0 = E0[0], u0 = E0[1], N0 = E0[2], q0 = E0[3], A0 = V0 * V0 + u0 * u0 + N0 * N0 + q0 * q0;
    if (A0 > 0)
      A0 = 1 / Math.sqrt(A0), X0[0] = V0 * A0, X0[1] = u0 * A0, X0[2] = N0 * A0, X0[3] = q0 * A0;
    return X0;
  }
  Z.normalize = l;
  let u = [0, 0, 0], G0 = [1, 0, 0], F0 = [0, 1, 0];
  function t(X0, E0, V0) {
    let u0 = M.dot(E0, V0);
    if (u0 < -0.999999) {
      if (M.cross(u, G0, E0), M.magnitude(u) < 0.000001)
        M.cross(u, F0, E0);
      return M.normalize(u, u), W(X0, u, Math.PI), X0;
    } else if (u0 > 0.999999)
      return X0[0] = 0, X0[1] = 0, X0[2] = 0, X0[3] = 1, X0;
    else
      return M.cross(u, E0, V0), X0[0] = u[0], X0[1] = u[1], X0[2] = u[2], X0[3] = 1 + u0, l(X0, X0);
  }
  Z.rotationTo = t;
  let Z0 = J(), U0 = J();
  function a(X0, E0, V0, u0, N0, q0) {
    return F(Z0, E0, N0, q0), F(U0, V0, u0, q0), F(X0, Z0, U0, 2 * q0 * (1 - q0)), X0;
  }
  Z.sqlerp = a;
  let Q0 = [0, 0, 0, 0, 0, 0, 0, 0, 0];
  function $0(X0, E0, V0, u0) {
    return Q0[0] = V0[0], Q0[3] = V0[1], Q0[6] = V0[2], Q0[1] = u0[0], Q0[4] = u0[1], Q0[7] = u0[2], Q0[2] = -E0[0], Q0[5] = -E0[1], Q0[8] = -E0[2], l(X0, D(X0, Q0));
  }
  Z.setAxes = $0;
  function R0(X0, E0) {
    return `[${X0[0].toPrecision(E0)} ${X0[1].toPrecision(E0)} ${X0[2].toPrecision(E0)}  ${X0[3].toPrecision(E0)}]`;
  }
  Z.toString = R0, Z.Identity = $();
})(k8 || (k8 = {}));

// node_modules/molstar/lib/mol-math/misc.js
var cO = Math.PI / 2, m50 = Math.PI / 180;
function _8(Z) {
  return Z * m50;
}
function k$(Z) {
  return Z / m50;
}
function nL(Z) {
  return Z !== 0 && (Z & Z - 1) === 0;
}
function d50(...Z) {
  let J = 0, $ = 0;
  for (let X = 0, Y = Z.length;X < Y; ++X) {
    let Q = Z[X], W = Math.abs(Q);
    if (W > $)
      J = Q, $ = W;
  }
  return J;
}
function AS(Z, J) {
  return Z * J;
}
function BS(Z) {
  let J = 0, $ = 0, X = 0, Y = -1, Q = Z * 2 + 1, W = Q / 2, K = [];
  for (let G = Math.pow(Q, 2);G > 0; --G) {
    if (-W < J && J <= W && (-W < $ && $ <= W))
      K.push([J, $]);
    if (J === $ || J < 0 && J === -$ || J > 0 && J === 1 - $) {
      let H = X;
      X = -Y, Y = H;
    }
    J += X, $ += Y;
  }
  return K;
}

// node_modules/molstar/lib/mol-math/linear-algebra/3d/mat4.js
function e() {
  return e.zero();
}
(function(Z) {
  function J() {
    let p = [0.1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
    return p[0] = 0, p;
  }
  Z.zero = J;
  function $() {
    let p = J();
    return p[0] = 1, p[1] = 0, p[2] = 0, p[3] = 0, p[4] = 0, p[5] = 1, p[6] = 0, p[7] = 0, p[8] = 0, p[9] = 0, p[10] = 1, p[11] = 0, p[12] = 0, p[13] = 0, p[14] = 0, p[15] = 1, p;
  }
  Z.identity = $;
  function X(p) {
    return p[0] = 1, p[1] = 0, p[2] = 0, p[3] = 0, p[4] = 0, p[5] = 1, p[6] = 0, p[7] = 0, p[8] = 0, p[9] = 0, p[10] = 1, p[11] = 0, p[12] = 0, p[13] = 0, p[14] = 0, p[15] = 1, p;
  }
  Z.setIdentity = X;
  function Y(p) {
    for (let J0 = 0;J0 < 16; J0++)
      if (p[J0] !== 0)
        return !1;
    return !0;
  }
  Z.isZero = Y;
  function Q(p) {
    for (let J0 = 0;J0 < 16; J0++)
      p[J0] = 0;
    return p;
  }
  Z.setZero = Q;
  function W(p) {
    let J0 = J();
    for (let T0 = 0;T0 < 4; T0++) {
      let o0 = p[T0];
      for (let y0 = 0;y0 < 4; y0++)
        J0[4 * y0 + T0] = o0[y0];
    }
    return J0;
  }
  Z.ofRows = W;
  let K = $();
  function G(p, J0) {
    return N(p, K, typeof J0 === "undefined" ? u8 : J0);
  }
  Z.isIdentity = G;
  function H(p) {
    for (let J0 = 0;J0 < 16; J0++)
      if (Number.isNaN(p[J0]))
        return !0;
    return !1;
  }
  Z.hasNaN = H;
  function N(p, J0, T0) {
    for (let o0 = 0;o0 < 16; o0++)
      if (Math.abs(p[o0] - J0[o0]) > T0)
        return !1;
    return !0;
  }
  Z.areEqual = N;
  function q(p, J0, T0, o0) {
    p[4 * T0 + J0] = o0;
  }
  Z.setValue = q;
  function U(p, J0, T0) {
    return p[4 * T0 + J0];
  }
  Z.getValue = U;
  function F(p, J0, T0) {
    return J0[T0 + 0] = p[0], J0[T0 + 1] = p[1], J0[T0 + 2] = p[2], J0[T0 + 3] = p[3], J0[T0 + 4] = p[4], J0[T0 + 5] = p[5], J0[T0 + 6] = p[6], J0[T0 + 7] = p[7], J0[T0 + 8] = p[8], J0[T0 + 9] = p[9], J0[T0 + 10] = p[10], J0[T0 + 11] = p[11], J0[T0 + 12] = p[12], J0[T0 + 13] = p[13], J0[T0 + 14] = p[14], J0[T0 + 15] = p[15], J0;
  }
  Z.toArray = F;
  function E(p, J0, T0) {
    return p[0] = J0[T0 + 0], p[1] = J0[T0 + 1], p[2] = J0[T0 + 2], p[3] = J0[T0 + 3], p[4] = J0[T0 + 4], p[5] = J0[T0 + 5], p[6] = J0[T0 + 6], p[7] = J0[T0 + 7], p[8] = J0[T0 + 8], p[9] = J0[T0 + 9], p[10] = J0[T0 + 10], p[11] = J0[T0 + 11], p[12] = J0[T0 + 12], p[13] = J0[T0 + 13], p[14] = J0[T0 + 14], p[15] = J0[T0 + 15], p;
  }
  Z.fromArray = E;
  function R(p, J0, T0, o0) {
    return Q(p), q(p, 0, 0, J0[0]), q(p, 1, 0, J0[1]), q(p, 2, 0, J0[2]), q(p, 0, 1, T0[0]), q(p, 1, 1, T0[1]), q(p, 2, 1, T0[2]), q(p, 0, 2, o0[0]), q(p, 1, 2, o0[1]), q(p, 2, 2, o0[2]), q(p, 3, 3, 1), p;
  }
  Z.fromBasis = R;
  function z(p, J0) {
    return p[0] = J0[0], p[1] = J0[1], p[2] = J0[2], p[3] = J0[3], p[4] = J0[4], p[5] = J0[5], p[6] = J0[6], p[7] = J0[7], p[8] = J0[8], p[9] = J0[9], p[10] = J0[10], p[11] = J0[11], p[12] = J0[12], p[13] = J0[13], p[14] = J0[14], p[15] = J0[15], p;
  }
  Z.copy = z;
  function D(p) {
    return z(J(), p);
  }
  Z.clone = D;
  function A(p, J0) {
    return p[0] = J0[12], p[1] = J0[13], p[2] = J0[14], p;
  }
  Z.getTranslation = A;
  function B(p, J0) {
    let T0 = J0[0], o0 = J0[1], y0 = J0[2], $1 = J0[4], F1 = J0[5], A1 = J0[6], P1 = J0[8], S1 = J0[9], _1 = J0[10];
    return p[0] = Math.sqrt(T0 * T0 + o0 * o0 + y0 * y0), p[1] = Math.sqrt($1 * $1 + F1 * F1 + A1 * A1), p[2] = Math.sqrt(P1 * P1 + S1 * S1 + _1 * _1), p;
  }
  Z.getScaling = B;
  function T(p, J0) {
    let T0 = J0[0] + J0[5] + J0[10], o0 = 0;
    if (T0 > 0)
      o0 = Math.sqrt(T0 + 1) * 2, p[3] = 0.25 * o0, p[0] = (J0[6] - J0[9]) / o0, p[1] = (J0[8] - J0[2]) / o0, p[2] = (J0[1] - J0[4]) / o0;
    else if (J0[0] > J0[5] && J0[0] > J0[10])
      o0 = Math.sqrt(1 + J0[0] - J0[5] - J0[10]) * 2, p[3] = (J0[6] - J0[9]) / o0, p[0] = 0.25 * o0, p[1] = (J0[1] + J0[4]) / o0, p[2] = (J0[8] + J0[2]) / o0;
    else if (J0[5] > J0[10])
      o0 = Math.sqrt(1 + J0[5] - J0[0] - J0[10]) * 2, p[3] = (J0[8] - J0[2]) / o0, p[0] = (J0[1] + J0[4]) / o0, p[1] = 0.25 * o0, p[2] = (J0[6] + J0[9]) / o0;
    else
      o0 = Math.sqrt(1 + J0[10] - J0[0] - J0[5]) * 2, p[3] = (J0[1] - J0[4]) / o0, p[0] = (J0[8] + J0[2]) / o0, p[1] = (J0[6] + J0[9]) / o0, p[2] = 0.25 * o0;
    return p;
  }
  Z.getRotation = T;
  function w(p, J0) {
    let T0 = 1 / Math.sqrt(J0[0] * J0[0] + J0[1] * J0[1] + J0[2] * J0[2]), o0 = 1 / Math.sqrt(J0[4] * J0[4] + J0[5] * J0[5] + J0[6] * J0[6]), y0 = 1 / Math.sqrt(J0[8] * J0[8] + J0[9] * J0[9] + J0[10] * J0[10]);
    return p[0] = J0[0] * T0, p[1] = J0[1] * T0, p[2] = J0[2] * T0, p[3] = 0, p[4] = J0[4] * o0, p[5] = J0[5] * o0, p[6] = J0[6] * o0, p[7] = 0, p[8] = J0[8] * y0, p[9] = J0[9] * y0, p[10] = J0[10] * y0, p[11] = 0, p[12] = 0, p[13] = 0, p[14] = 0, p[15] = 1, p;
  }
  Z.extractRotation = w;
  function V(p, J0) {
    if (p === J0) {
      let T0 = J0[1], o0 = J0[2], y0 = J0[3], $1 = J0[6], F1 = J0[7], A1 = J0[11];
      p[1] = J0[4], p[2] = J0[8], p[3] = J0[12], p[4] = T0, p[6] = J0[9], p[7] = J0[13], p[8] = o0, p[9] = $1, p[11] = J0[14], p[12] = y0, p[13] = F1, p[14] = A1;
    } else
      p[0] = J0[0], p[1] = J0[4], p[2] = J0[8], p[3] = J0[12], p[4] = J0[1], p[5] = J0[5], p[6] = J0[9], p[7] = J0[13], p[8] = J0[2], p[9] = J0[6], p[10] = J0[10], p[11] = J0[14], p[12] = J0[3], p[13] = J0[7], p[14] = J0[11], p[15] = J0[15];
    return p;
  }
  Z.transpose = V;
  function P(p, J0) {
    let T0 = J0[0], o0 = J0[1], y0 = J0[2], $1 = J0[3], F1 = J0[4], A1 = J0[5], P1 = J0[6], S1 = J0[7], _1 = J0[8], a1 = J0[9], U2 = J0[10], G2 = J0[11], P2 = J0[12], v2 = J0[13], O8 = J0[14], n8 = J0[15], z6 = T0 * A1 - o0 * F1, L8 = T0 * P1 - y0 * F1, R8 = T0 * S1 - $1 * F1, w0 = o0 * P1 - y0 * A1, P0 = o0 * S1 - $1 * A1, l0 = y0 * S1 - $1 * P1, z1 = _1 * v2 - a1 * P2, J2 = _1 * O8 - U2 * P2, N2 = _1 * n8 - G2 * P2, X8 = a1 * O8 - U2 * v2, c0 = a1 * n8 - G2 * v2, M1 = U2 * n8 - G2 * O8, g1 = z6 * M1 - L8 * c0 + R8 * X8 + w0 * N2 - P0 * J2 + l0 * z1;
    if (!g1)
      return !1;
    return g1 = 1 / g1, p[0] = (A1 * M1 - P1 * c0 + S1 * X8) * g1, p[1] = (y0 * c0 - o0 * M1 - $1 * X8) * g1, p[2] = (v2 * l0 - O8 * P0 + n8 * w0) * g1, p[3] = (U2 * P0 - a1 * l0 - G2 * w0) * g1, p[4] = (P1 * N2 - F1 * M1 - S1 * J2) * g1, p[5] = (T0 * M1 - y0 * N2 + $1 * J2) * g1, p[6] = (O8 * R8 - P2 * l0 - n8 * L8) * g1, p[7] = (_1 * l0 - U2 * R8 + G2 * L8) * g1, p[8] = (F1 * c0 - A1 * N2 + S1 * z1) * g1, p[9] = (o0 * N2 - T0 * c0 - $1 * z1) * g1, p[10] = (P2 * P0 - v2 * R8 + n8 * z6) * g1, p[11] = (a1 * R8 - _1 * P0 - G2 * z6) * g1, p[12] = (A1 * J2 - F1 * X8 - P1 * z1) * g1, p[13] = (T0 * X8 - o0 * J2 + y0 * z1) * g1, p[14] = (v2 * L8 - P2 * w0 - O8 * z6) * g1, p[15] = (_1 * w0 - a1 * L8 + U2 * z6) * g1, !0;
  }
  Z.tryInvert = P;
  function I(p, J0) {
    if (!P(p, J0))
      console.warn("non-invertible matrix.", J0);
    return p;
  }
  Z.invert = I;
  function S(p, J0, T0) {
    let o0 = J0[0], y0 = J0[1], $1 = J0[2], F1 = J0[3], A1 = J0[4], P1 = J0[5], S1 = J0[6], _1 = J0[7], a1 = J0[8], U2 = J0[9], G2 = J0[10], P2 = J0[11], v2 = J0[12], O8 = J0[13], n8 = J0[14], z6 = J0[15], L8 = T0[0], R8 = T0[1], w0 = T0[2], P0 = T0[3];
    return p[0] = L8 * o0 + R8 * A1 + w0 * a1 + P0 * v2, p[1] = L8 * y0 + R8 * P1 + w0 * U2 + P0 * O8, p[2] = L8 * $1 + R8 * S1 + w0 * G2 + P0 * n8, p[3] = L8 * F1 + R8 * _1 + w0 * P2 + P0 * z6, L8 = T0[4], R8 = T0[5], w0 = T0[6], P0 = T0[7], p[4] = L8 * o0 + R8 * A1 + w0 * a1 + P0 * v2, p[5] = L8 * y0 + R8 * P1 + w0 * U2 + P0 * O8, p[6] = L8 * $1 + R8 * S1 + w0 * G2 + P0 * n8, p[7] = L8 * F1 + R8 * _1 + w0 * P2 + P0 * z6, L8 = T0[8], R8 = T0[9], w0 = T0[10], P0 = T0[11], p[8] = L8 * o0 + R8 * A1 + w0 * a1 + P0 * v2, p[9] = L8 * y0 + R8 * P1 + w0 * U2 + P0 * O8, p[10] = L8 * $1 + R8 * S1 + w0 * G2 + P0 * n8, p[11] = L8 * F1 + R8 * _1 + w0 * P2 + P0 * z6, L8 = T0[12], R8 = T0[13], w0 = T0[14], P0 = T0[15], p[12] = L8 * o0 + R8 * A1 + w0 * a1 + P0 * v2, p[13] = L8 * y0 + R8 * P1 + w0 * U2 + P0 * O8, p[14] = L8 * $1 + R8 * S1 + w0 * G2 + P0 * n8, p[15] = L8 * F1 + R8 * _1 + w0 * P2 + P0 * z6, p;
  }
  Z.mul = S;
  function f(p, J0, T0, o0, y0, $1) {
    let F1 = J0[0 + y0], A1 = J0[1 + y0], P1 = J0[2 + y0], S1 = J0[3 + y0], _1 = J0[4 + y0], a1 = J0[5 + y0], U2 = J0[6 + y0], G2 = J0[7 + y0], P2 = J0[8 + y0], v2 = J0[9 + y0], O8 = J0[10 + y0], n8 = J0[11 + y0], z6 = J0[12 + y0], L8 = J0[13 + y0], R8 = J0[14 + y0], w0 = J0[15 + y0], P0 = T0[0 + $1], l0 = T0[1 + $1], z1 = T0[2 + $1], J2 = T0[3 + $1];
    return p[0 + o0] = P0 * F1 + l0 * _1 + z1 * P2 + J2 * z6, p[1 + o0] = P0 * A1 + l0 * a1 + z1 * v2 + J2 * L8, p[2 + o0] = P0 * P1 + l0 * U2 + z1 * O8 + J2 * R8, p[3 + o0] = P0 * S1 + l0 * G2 + z1 * n8 + J2 * w0, P0 = T0[4 + $1], l0 = T0[5 + $1], z1 = T0[6 + $1], J2 = T0[7 + $1], p[4 + o0] = P0 * F1 + l0 * _1 + z1 * P2 + J2 * z6, p[5 + o0] = P0 * A1 + l0 * a1 + z1 * v2 + J2 * L8, p[6 + o0] = P0 * P1 + l0 * U2 + z1 * O8 + J2 * R8, p[7 + o0] = P0 * S1 + l0 * G2 + z1 * n8 + J2 * w0, P0 = T0[8 + $1], l0 = T0[9 + $1], z1 = T0[10 + $1], J2 = T0[11 + $1], p[8 + o0] = P0 * F1 + l0 * _1 + z1 * P2 + J2 * z6, p[9 + o0] = P0 * A1 + l0 * a1 + z1 * v2 + J2 * L8, p[10 + o0] = P0 * P1 + l0 * U2 + z1 * O8 + J2 * R8, p[11 + o0] = P0 * S1 + l0 * G2 + z1 * n8 + J2 * w0, P0 = T0[12 + $1], l0 = T0[13 + $1], z1 = T0[14 + $1], J2 = T0[15 + $1], p[12 + o0] = P0 * F1 + l0 * _1 + z1 * P2 + J2 * z6, p[13 + o0] = P0 * A1 + l0 * a1 + z1 * v2 + J2 * L8, p[14 + o0] = P0 * P1 + l0 * U2 + z1 * O8 + J2 * R8, p[15 + o0] = P0 * S1 + l0 * G2 + z1 * n8 + J2 * w0, p;
  }
  Z.mulOffset = f;
  function v(p, J0, T0, o0) {
    return S(p, S(p, J0, T0), o0);
  }
  Z.mul3 = v;
  function h(p, J0, T0) {
    let o0 = T0[0], y0 = T0[1], $1 = T0[2], F1, A1, P1, S1, _1, a1, U2, G2, P2, v2, O8, n8;
    if (J0 === p)
      p[12] = J0[0] * o0 + J0[4] * y0 + J0[8] * $1 + J0[12], p[13] = J0[1] * o0 + J0[5] * y0 + J0[9] * $1 + J0[13], p[14] = J0[2] * o0 + J0[6] * y0 + J0[10] * $1 + J0[14], p[15] = J0[3] * o0 + J0[7] * y0 + J0[11] * $1 + J0[15];
    else
      F1 = J0[0], A1 = J0[1], P1 = J0[2], S1 = J0[3], _1 = J0[4], a1 = J0[5], U2 = J0[6], G2 = J0[7], P2 = J0[8], v2 = J0[9], O8 = J0[10], n8 = J0[11], p[0] = F1, p[1] = A1, p[2] = P1, p[3] = S1, p[4] = _1, p[5] = a1, p[6] = U2, p[7] = G2, p[8] = P2, p[9] = v2, p[10] = O8, p[11] = n8, p[12] = F1 * o0 + _1 * y0 + P2 * $1 + J0[12], p[13] = A1 * o0 + a1 * y0 + v2 * $1 + J0[13], p[14] = P1 * o0 + U2 * y0 + O8 * $1 + J0[14], p[15] = S1 * o0 + G2 * y0 + n8 * $1 + J0[15];
    return p;
  }
  Z.translate = h;
  function x(p, J0) {
    return p[0] = 1, p[1] = 0, p[2] = 0, p[3] = 0, p[4] = 0, p[5] = 1, p[6] = 0, p[7] = 0, p[8] = 0, p[9] = 0, p[10] = 1, p[11] = 0, p[12] = J0[0], p[13] = J0[1], p[14] = J0[2], p[15] = 1, p;
  }
  Z.fromTranslation = x;
  function b(p, J0) {
    return p[12] = J0[0], p[13] = J0[1], p[14] = J0[2], p;
  }
  Z.setTranslation = b;
  function g(p, J0, T0, o0) {
    return p[0] = T0[0], p[4] = T0[1], p[8] = T0[2], p[1] = o0[0], p[5] = o0[1], p[9] = o0[2], p[2] = J0[0], p[6] = J0[1], p[10] = J0[2], p;
  }
  Z.setAxes = g;
  function m(p, J0, T0, o0) {
    let y0 = o0[0], $1 = o0[1], F1 = o0[2], A1 = Math.sqrt(y0 * y0 + $1 * $1 + F1 * F1);
    if (Math.abs(A1) < u8)
      return $();
    A1 = 1 / A1, y0 *= A1, $1 *= A1, F1 *= A1;
    let P1 = Math.sin(T0), S1 = Math.cos(T0), _1 = 1 - S1, a1 = J0[0], U2 = J0[1], G2 = J0[2], P2 = J0[3], v2 = J0[4], O8 = J0[5], n8 = J0[6], z6 = J0[7], L8 = J0[8], R8 = J0[9], w0 = J0[10], P0 = J0[11], l0 = y0 * y0 * _1 + S1, z1 = $1 * y0 * _1 + F1 * P1, J2 = F1 * y0 * _1 - $1 * P1, N2 = y0 * $1 * _1 - F1 * P1, X8 = $1 * $1 * _1 + S1, c0 = F1 * $1 * _1 + y0 * P1, M1 = y0 * F1 * _1 + $1 * P1, g1 = $1 * F1 * _1 - y0 * P1, l2 = F1 * F1 * _1 + S1;
    if (p[0] = a1 * l0 + v2 * z1 + L8 * J2, p[1] = U2 * l0 + O8 * z1 + R8 * J2, p[2] = G2 * l0 + n8 * z1 + w0 * J2, p[3] = P2 * l0 + z6 * z1 + P0 * J2, p[4] = a1 * N2 + v2 * X8 + L8 * c0, p[5] = U2 * N2 + O8 * X8 + R8 * c0, p[6] = G2 * N2 + n8 * X8 + w0 * c0, p[7] = P2 * N2 + z6 * X8 + P0 * c0, p[8] = a1 * M1 + v2 * g1 + L8 * l2, p[9] = U2 * M1 + O8 * g1 + R8 * l2, p[10] = G2 * M1 + n8 * g1 + w0 * l2, p[11] = P2 * M1 + z6 * g1 + P0 * l2, J0 !== p)
      p[12] = J0[12], p[13] = J0[13], p[14] = J0[14], p[15] = J0[15];
    return p;
  }
  Z.rotate = m;
  function i(p, J0, T0) {
    let o0 = T0[0], y0 = T0[1], $1 = T0[2], F1 = Math.sqrt(o0 * o0 + y0 * y0 + $1 * $1);
    if (Math.abs(F1) < u8)
      return X(p);
    F1 = 1 / F1, o0 *= F1, y0 *= F1, $1 *= F1;
    let A1 = Math.sin(J0), P1 = Math.cos(J0), S1 = 1 - P1;
    return p[0] = o0 * o0 * S1 + P1, p[1] = y0 * o0 * S1 + $1 * A1, p[2] = $1 * o0 * S1 - y0 * A1, p[3] = 0, p[4] = o0 * y0 * S1 - $1 * A1, p[5] = y0 * y0 * S1 + P1, p[6] = $1 * y0 * S1 + o0 * A1, p[7] = 0, p[8] = o0 * $1 * S1 + y0 * A1, p[9] = y0 * $1 * S1 - o0 * A1, p[10] = $1 * $1 * S1 + P1, p[11] = 0, p[12] = 0, p[13] = 0, p[14] = 0, p[15] = 1, p;
  }
  Z.fromRotation = i;
  function r(p, J0, T0) {
    let o0 = T0[0], y0 = T0[1], $1 = T0[2];
    return p[0] = J0[0] * o0, p[1] = J0[1] * o0, p[2] = J0[2] * o0, p[3] = J0[3] * o0, p[4] = J0[4] * y0, p[5] = J0[5] * y0, p[6] = J0[6] * y0, p[7] = J0[7] * y0, p[8] = J0[8] * $1, p[9] = J0[9] * $1, p[10] = J0[10] * $1, p[11] = J0[11] * $1, p[12] = J0[12], p[13] = J0[13], p[14] = J0[14], p[15] = J0[15], p;
  }
  Z.scale = r;
  function Y0(p, J0, T0) {
    return p[0] = J0[0] * T0, p[1] = J0[1] * T0, p[2] = J0[2] * T0, p[3] = J0[3] * T0, p[4] = J0[4] * T0, p[5] = J0[5] * T0, p[6] = J0[6] * T0, p[7] = J0[7] * T0, p[8] = J0[8] * T0, p[9] = J0[9] * T0, p[10] = J0[10] * T0, p[11] = J0[11] * T0, p[12] = J0[12], p[13] = J0[13], p[14] = J0[14], p[15] = J0[15], p;
  }
  Z.scaleUniformly = Y0;
  function c(p, J0) {
    return p[0] = J0[0], p[1] = 0, p[2] = 0, p[3] = 0, p[4] = 0, p[5] = J0[1], p[6] = 0, p[7] = 0, p[8] = 0, p[9] = 0, p[10] = J0[2], p[11] = 0, p[12] = 0, p[13] = 0, p[14] = 0, p[15] = 1, p;
  }
  Z.fromScaling = c;
  function n(p, J0) {
    return p[0] = J0, p[1] = 0, p[2] = 0, p[3] = 0, p[4] = 0, p[5] = J0, p[6] = 0, p[7] = 0, p[8] = 0, p[9] = 0, p[10] = J0, p[11] = 0, p[12] = 0, p[13] = 0, p[14] = 0, p[15] = 1, p;
  }
  Z.fromUniformScaling = n;
  let l = [0, 0, 0], u = [0, 0, 0];
  function G0(p, J0, T0) {
    let o0 = M.cross(l, J0, M.unitX);
    if (M.dot(o0, o0) < u8)
      M.cross(o0, J0, M.unitY);
    M.normalize(o0, o0);
    let y0 = M.cross(u, J0, o0);
    return M.normalize(y0, y0), g(p, J0, o0, y0), p[12] = T0[0], p[13] = T0[1], p[14] = T0[2], p[15] = 1, p;
  }
  Z.fromPlane = G0;
  function F0(p, J0) {
    return p[0] = J0[0], p[1] = J0[1], p[2] = J0[2], p[4] = J0[3], p[5] = J0[4], p[6] = J0[5], p[8] = J0[6], p[9] = J0[7], p[10] = J0[8], p;
  }
  Z.fromMat3 = F0;
  function t(p, J0, T0, o0) {
    let [y0, $1, F1, A1] = T0, P1 = y0 + y0, S1 = $1 + $1, _1 = F1 + F1, a1 = y0 * P1, U2 = y0 * S1, G2 = y0 * _1, P2 = $1 * S1, v2 = $1 * _1, O8 = F1 * _1, n8 = A1 * P1, z6 = A1 * S1, L8 = A1 * _1, [R8, w0, P0] = o0;
    return p[0] = (1 - (P2 + O8)) * R8, p[1] = (U2 + L8) * R8, p[2] = (G2 - z6) * R8, p[3] = 0, p[4] = (U2 - L8) * w0, p[5] = (1 - (a1 + O8)) * w0, p[6] = (v2 + n8) * w0, p[7] = 0, p[8] = (G2 + z6) * P0, p[9] = (v2 - n8) * P0, p[10] = (1 - (a1 + P2)) * P0, p[11] = 0, p[12] = J0[0], p[13] = J0[1], p[14] = J0[2], p[15] = 1, p;
  }
  Z.compose = t;
  let Z0 = [0, 0, 0], U0 = J();
  function a(p, J0, T0, o0) {
    let y0 = M.magnitude(M.set(Z0, p[0], p[1], p[2])), $1 = M.magnitude(M.set(Z0, p[4], p[5], p[6])), F1 = M.magnitude(M.set(Z0, p[8], p[9], p[10]));
    if (R0(p) < 0)
      y0 = -y0;
    J0[0] = p[12], J0[1] = p[13], J0[2] = p[14], z(U0, p);
    let P1 = 1 / y0, S1 = 1 / $1, _1 = 1 / F1;
    return U0[0] *= P1, U0[1] *= P1, U0[2] *= P1, U0[4] *= S1, U0[5] *= S1, U0[6] *= S1, U0[8] *= _1, U0[9] *= _1, U0[10] *= _1, T(T0, U0), o0[0] = y0, o0[1] = $1, o0[2] = F1, p;
  }
  Z.decompose = a;
  function Q0(p) {
    let J0 = M(), T0 = k8(), o0 = M();
    return a(p, J0, T0, o0), { position: J0, quaternion: T0, scale: o0 };
  }
  Z.getDecomposition = Q0;
  function $0(p) {
    let J0 = "";
    for (let T0 = 0;T0 < 4; T0++) {
      for (let o0 = 0;o0 < 4; o0++)
        if (J0 += p[4 * o0 + T0].toString(), o0 < 3)
          J0 += " ";
      if (T0 < 3)
        J0 += `
`;
    }
    return J0;
  }
  Z.makeTable = $0;
  function R0(p) {
    let J0 = p[0], T0 = p[1], o0 = p[2], y0 = p[3], $1 = p[4], F1 = p[5], A1 = p[6], P1 = p[7], S1 = p[8], _1 = p[9], a1 = p[10], U2 = p[11], G2 = p[12], P2 = p[13], v2 = p[14], O8 = p[15], n8 = J0 * F1 - T0 * $1, z6 = J0 * A1 - o0 * $1, L8 = J0 * P1 - y0 * $1, R8 = T0 * A1 - o0 * F1, w0 = T0 * P1 - y0 * F1, P0 = o0 * P1 - y0 * A1, l0 = S1 * P2 - _1 * G2, z1 = S1 * v2 - a1 * G2, J2 = S1 * O8 - U2 * G2, N2 = _1 * v2 - a1 * P2, X8 = _1 * O8 - U2 * P2, c0 = a1 * O8 - U2 * v2;
    return n8 * c0 - z6 * X8 + L8 * N2 + R8 * J2 - w0 * z1 + P0 * l0;
  }
  Z.determinant = R0;
  function X0(p, J0) {
    return E0(p, typeof J0 !== "undefined" ? J0 : u8);
  }
  Z.isRotationAndTranslation = X0;
  function E0(p, J0) {
    let T0 = p[0], o0 = p[1], y0 = p[2], $1 = p[3], F1 = p[4], A1 = p[5], P1 = p[6], S1 = p[7], _1 = p[8], a1 = p[9], U2 = p[10], G2 = p[11], P2 = p[15];
    if (!dZ(P2, 1, J0) || !dZ($1, 0, J0) || !dZ(S1, 0, J0) || !dZ(G2, 0, J0))
      return !1;
    let v2 = Math.abs(T0 * (A1 * U2 - P1 * a1) - o0 * (F1 * U2 - P1 * _1) + y0 * (F1 * a1 - A1 * _1));
    if (!dZ(v2, 1, J0))
      return !1;
    return !0;
  }
  function V0(p, J0) {
    return u0(p, typeof J0 !== "undefined" ? J0 : u8);
  }
  Z.isTranslationAndUniformScaling = V0;
  function u0(p, J0) {
    let T0 = p[0];
    return dZ(p[1], 0, J0) && dZ(p[2], 0, J0) && dZ(p[3], 0, J0) && dZ(p[4], 0, J0) && dZ(p[5], T0, J0) && dZ(p[6], 0, J0) && dZ(p[7], 0, J0) && dZ(p[8], 0, J0) && dZ(p[9], 0, J0) && dZ(p[10], T0, J0) && dZ(p[11], 0, J0) && dZ(p[15], 1, J0);
  }
  function N0(p, J0) {
    let T0 = J0[0], o0 = J0[1], y0 = J0[2], $1 = J0[3], F1 = T0 + T0, A1 = o0 + o0, P1 = y0 + y0, S1 = T0 * F1, _1 = o0 * F1, a1 = o0 * A1, U2 = y0 * F1, G2 = y0 * A1, P2 = y0 * P1, v2 = $1 * F1, O8 = $1 * A1, n8 = $1 * P1;
    return p[0] = 1 - a1 - P2, p[1] = _1 + n8, p[2] = U2 - O8, p[3] = 0, p[4] = _1 - n8, p[5] = 1 - S1 - P2, p[6] = G2 + v2, p[7] = 0, p[8] = U2 + O8, p[9] = G2 - v2, p[10] = 1 - S1 - a1, p[11] = 0, p[12] = 0, p[13] = 0, p[14] = 0, p[15] = 1, p;
  }
  Z.fromQuat = N0;
  function q0(p, J0, T0) {
    let o0 = J0[0], y0 = J0[1], $1 = J0[2], F1 = Math.cos(o0), A1 = Math.sin(o0), P1 = Math.cos(y0), S1 = Math.sin(y0), _1 = Math.cos($1), a1 = Math.sin($1);
    if (T0 === "XYZ") {
      let U2 = F1 * _1, G2 = F1 * a1, P2 = A1 * _1, v2 = A1 * a1;
      p[0] = P1 * _1, p[4] = -P1 * a1, p[8] = S1, p[1] = G2 + P2 * S1, p[5] = U2 - v2 * S1, p[9] = -A1 * P1, p[2] = v2 - U2 * S1, p[6] = P2 + G2 * S1, p[10] = F1 * P1;
    } else if (T0 === "YXZ") {
      let U2 = P1 * _1, G2 = P1 * a1, P2 = S1 * _1, v2 = S1 * a1;
      p[0] = U2 + v2 * A1, p[4] = P2 * A1 - G2, p[8] = F1 * S1, p[1] = F1 * a1, p[5] = F1 * _1, p[9] = -A1, p[2] = G2 * A1 - P2, p[6] = v2 + U2 * A1, p[10] = F1 * P1;
    } else if (T0 === "ZXY") {
      let U2 = P1 * _1, G2 = P1 * a1, P2 = S1 * _1, v2 = S1 * a1;
      p[0] = U2 - v2 * A1, p[4] = -F1 * a1, p[8] = P2 + G2 * A1, p[1] = G2 + P2 * A1, p[5] = F1 * _1, p[9] = v2 - U2 * A1, p[2] = -F1 * S1, p[6] = A1, p[10] = F1 * P1;
    } else if (T0 === "ZYX") {
      let U2 = F1 * _1, G2 = F1 * a1, P2 = A1 * _1, v2 = A1 * a1;
      p[0] = P1 * _1, p[4] = P2 * S1 - G2, p[8] = U2 * S1 + v2, p[1] = P1 * a1, p[5] = v2 * S1 + U2, p[9] = G2 * S1 - P2, p[2] = -S1, p[6] = A1 * P1, p[10] = F1 * P1;
    } else if (T0 === "YZX") {
      let U2 = F1 * P1, G2 = F1 * S1, P2 = A1 * P1, v2 = A1 * S1;
      p[0] = P1 * _1, p[4] = v2 - U2 * a1, p[8] = P2 * a1 + G2, p[1] = a1, p[5] = F1 * _1, p[9] = -A1 * _1, p[2] = -S1 * _1, p[6] = G2 * a1 + P2, p[10] = U2 - v2 * a1;
    } else if (T0 === "XZY") {
      let U2 = F1 * P1, G2 = F1 * S1, P2 = A1 * P1, v2 = A1 * S1;
      p[0] = P1 * _1, p[4] = -a1, p[8] = S1 * _1, p[1] = U2 * a1 + v2, p[5] = F1 * _1, p[9] = G2 * a1 - P2, p[2] = P2 * a1 - G2, p[6] = A1 * _1, p[10] = v2 * a1 + U2;
    }
    return p[3] = 0, p[7] = 0, p[11] = 0, p[12] = 0, p[13] = 0, p[14] = 0, p[15] = 1, p;
  }
  Z.fromEuler = q0;
  function A0(p, J0, T0, o0, y0, $1, F1) {
    let A1 = 2 * $1 / (T0 - J0), P1 = 2 * $1 / (o0 - y0), S1 = (T0 + J0) / (T0 - J0), _1 = (o0 + y0) / (o0 - y0), a1 = -(F1 + $1) / (F1 - $1), U2 = -2 * F1 * $1 / (F1 - $1);
    return p[0] = A1, p[1] = 0, p[2] = 0, p[3] = 0, p[4] = 0, p[5] = P1, p[6] = 0, p[7] = 0, p[8] = S1, p[9] = _1, p[10] = a1, p[11] = -1, p[12] = 0, p[13] = 0, p[14] = U2, p[15] = 0, p;
  }
  Z.perspective = A0;
  function S0(p, J0, T0, o0, y0, $1, F1) {
    let A1 = 1 / (T0 - J0), P1 = 1 / (o0 - y0), S1 = 1 / (F1 - $1), _1 = (T0 + J0) * A1, a1 = (o0 + y0) * P1, U2 = (F1 + $1) * S1;
    return p[0] = 2 * A1, p[1] = 0, p[2] = 0, p[3] = 0, p[4] = 0, p[5] = 2 * P1, p[6] = 0, p[7] = 0, p[8] = 0, p[9] = 0, p[10] = -2 * S1, p[11] = 0, p[12] = -_1, p[13] = -a1, p[14] = -U2, p[15] = 1, p;
  }
  Z.ortho = S0;
  function a0(p, J0, T0, o0) {
    let y0, $1, F1, A1, P1, S1, _1, a1, U2, G2, P2 = J0[0], v2 = J0[1], O8 = J0[2], n8 = o0[0], z6 = o0[1], L8 = o0[2], R8 = T0[0], w0 = T0[1], P0 = T0[2];
    if (Math.abs(P2 - R8) < u8 && Math.abs(v2 - w0) < u8 && Math.abs(O8 - P0) < u8)
      return X(p);
    if (_1 = P2 - R8, a1 = v2 - w0, U2 = O8 - P0, G2 = 1 / Math.sqrt(_1 * _1 + a1 * a1 + U2 * U2), _1 *= G2, a1 *= G2, U2 *= G2, y0 = z6 * U2 - L8 * a1, $1 = L8 * _1 - n8 * U2, F1 = n8 * a1 - z6 * _1, G2 = Math.sqrt(y0 * y0 + $1 * $1 + F1 * F1), !G2)
      y0 = 0, $1 = 0, F1 = 0;
    else
      G2 = 1 / G2, y0 *= G2, $1 *= G2, F1 *= G2;
    if (A1 = a1 * F1 - U2 * $1, P1 = U2 * y0 - _1 * F1, S1 = _1 * $1 - a1 * y0, G2 = Math.sqrt(A1 * A1 + P1 * P1 + S1 * S1), !G2)
      A1 = 0, P1 = 0, S1 = 0;
    else
      G2 = 1 / G2, A1 *= G2, P1 *= G2, S1 *= G2;
    return p[0] = y0, p[1] = A1, p[2] = _1, p[3] = 0, p[4] = $1, p[5] = P1, p[6] = a1, p[7] = 0, p[8] = F1, p[9] = S1, p[10] = U2, p[11] = 0, p[12] = -(y0 * P2 + $1 * v2 + F1 * O8), p[13] = -(A1 * P2 + P1 * v2 + S1 * O8), p[14] = -(_1 * P2 + a1 * v2 + U2 * O8), p[15] = 1, p;
  }
  Z.lookAt = a0;
  function D1(p, J0, T0, o0) {
    let y0 = J0[0], $1 = J0[1], F1 = J0[2], A1 = o0[0], P1 = o0[1], S1 = o0[2], _1 = y0 - T0[0], a1 = $1 - T0[1], U2 = F1 - T0[2], G2 = _1 * _1 + a1 * a1 + U2 * U2;
    if (G2 > 0)
      G2 = 1 / Math.sqrt(G2), _1 *= G2, a1 *= G2, U2 *= G2;
    let P2 = P1 * U2 - S1 * a1, v2 = S1 * _1 - A1 * U2, O8 = A1 * a1 - P1 * _1;
    if (G2 = P2 * P2 + v2 * v2 + O8 * O8, G2 > 0)
      G2 = 1 / Math.sqrt(G2), P2 *= G2, v2 *= G2, O8 *= G2;
    return p[0] = P2, p[1] = v2, p[2] = O8, p[3] = 0, p[4] = a1 * O8 - U2 * v2, p[5] = U2 * P2 - _1 * O8, p[6] = _1 * v2 - a1 * P2, p[7] = 0, p[8] = _1, p[9] = a1, p[10] = U2, p[11] = 0, p[12] = y0, p[13] = $1, p[14] = F1, p[15] = 1, p;
  }
  Z.targetTo = D1;
  function Y1(p, J0) {
    Q(p);
    for (let T0 = 0;T0 < 4; T0++) {
      let o0 = J0[T0];
      q(p, T0, o0, 1);
    }
    return p;
  }
  Z.fromPermutation = Y1;
  function u1(p) {
    let J0 = p[0] * p[0] + p[1] * p[1] + p[2] * p[2], T0 = p[4] * p[4] + p[5] * p[5] + p[6] * p[6], o0 = p[8] * p[8] + p[9] * p[9] + p[10] * p[10];
    return Math.sqrt(Math.max(J0, T0, o0));
  }
  Z.getMaxScaleOnAxis = u1;
  function b0(p) {
    return {
      x: M.create(p[0], p[1], p[2]),
      y: M.create(p[4], p[5], p[6]),
      z: M.create(p[8], p[9], p[10])
    };
  }
  Z.extractBasis = b0;
  let x0 = [1, 0, 0], m0 = [0, 1, 0], e0 = [0, 0, 1];
  Z.rotX90 = i(J(), _8(90), x0), Z.rotX180 = i(J(), _8(180), x0), Z.rotY90 = i(J(), _8(90), m0), Z.rotY180 = i(J(), _8(180), m0), Z.rotY270 = i(J(), _8(270), m0), Z.rotZ90 = i(J(), _8(90), e0), Z.rotZ180 = i(J(), _8(180), e0), Z.rotXY90 = S(J(), Z.rotX90, Z.rotY90), Z.rotZY90 = S(J(), Z.rotZ90, Z.rotY90), Z.rotZYZ90 = S(J(), Z.rotZY90, Z.rotZ90), Z.rotZ90X180 = S(J(), Z.rotZ90, Z.rotX180), Z.rotY90Z180 = S(J(), Z.rotY90, Z.rotZ180), Z.id = $();
})(e || (e = {}));

// node_modules/molstar/lib/mol-math/linear-algebra/3d/vec3.js
var Xi = isFinite;
function M() {
  return M.zero();
}
(function(Z) {
  function J() {
    let w0 = [0.1, 0, 0];
    return w0[0] = 0, w0;
  }
  Z.zero = J;
  function $(w0) {
    let P0 = J();
    return P0[0] = w0[0], P0[1] = w0[1], P0[2] = w0[2], P0;
  }
  Z.clone = $;
  function X(w0) {
    return Xi(w0[0]) && Xi(w0[1]) && Xi(w0[2]);
  }
  Z.isFinite = X;
  function Y(w0) {
    return Number.isInteger(w0[0]) && Number.isInteger(w0[1]) && Number.isInteger(w0[2]);
  }
  Z.isInteger = Y;
  function Q(w0) {
    return Number.isNaN(w0[0]) || Number.isNaN(w0[1]) || Number.isNaN(w0[2]);
  }
  Z.hasNaN = Q;
  function W(w0) {
    return w0[0] = NaN, w0[1] = NaN, w0[2] = NaN, w0;
  }
  Z.setNaN = W;
  function K(w0) {
    return q(w0.x, w0.y, w0.z);
  }
  Z.fromObj = K;
  function G(w0) {
    return { x: w0[0], y: w0[1], z: w0[2] };
  }
  Z.toObj = G;
  function H(w0, P0, l0) {
    return w0[0] = P0[l0 + 0], w0[1] = P0[l0 + 1], w0[2] = P0[l0 + 2], w0;
  }
  Z.fromArray = H;
  function N(w0, P0, l0) {
    return P0[l0 + 0] = w0[0], P0[l0 + 1] = w0[1], P0[l0 + 2] = w0[2], P0;
  }
  Z.toArray = N;
  function q(w0, P0, l0) {
    let z1 = J();
    return z1[0] = w0, z1[1] = P0, z1[2] = l0, z1;
  }
  Z.create = q;
  function U(w0) {
    let P0 = J();
    return P0[0] = w0[0], P0[1] = w0[1], P0[2] = w0[2], P0;
  }
  Z.ofArray = U;
  function F(w0, P0, l0, z1) {
    return w0[0] = P0, w0[1] = l0, w0[2] = z1, w0;
  }
  Z.set = F;
  function E(w0, P0) {
    return w0[0] = P0[0], w0[1] = P0[1], w0[2] = P0[2], w0;
  }
  Z.copy = E;
  function R(w0, P0, l0) {
    return w0[0] = P0[0] + l0[0], w0[1] = P0[1] + l0[1], w0[2] = P0[2] + l0[2], w0;
  }
  Z.add = R;
  function z(w0, P0, l0) {
    return w0[0] = P0[0] - l0[0], w0[1] = P0[1] - l0[1], w0[2] = P0[2] - l0[2], w0;
  }
  Z.sub = z;
  function D(w0, P0, l0) {
    return w0[0] = P0[0] * l0[0], w0[1] = P0[1] * l0[1], w0[2] = P0[2] * l0[2], w0;
  }
  Z.mul = D;
  function A(w0, P0, l0) {
    return w0[0] = P0[0] / l0[0], w0[1] = P0[1] / l0[1], w0[2] = P0[2] / l0[2], w0;
  }
  Z.div = A;
  function B(w0, P0, l0) {
    return w0[0] = P0[0] * l0, w0[1] = P0[1] * l0, w0[2] = P0[2] * l0, w0;
  }
  Z.scale = B;
  function T(w0, P0, l0, z1) {
    return w0[0] = P0[0] + l0[0] * z1, w0[1] = P0[1] + l0[1] * z1, w0[2] = P0[2] + l0[2] * z1, w0;
  }
  Z.scaleAndAdd = T;
  function w(w0, P0, l0, z1) {
    return w0[0] = P0[0] - l0[0] * z1, w0[1] = P0[1] - l0[1] * z1, w0[2] = P0[2] - l0[2] * z1, w0;
  }
  Z.scaleAndSub = w;
  function V(w0, P0, l0) {
    return w0[0] = P0[0] + l0, w0[1] = P0[1] + l0, w0[2] = P0[2] + l0, w0;
  }
  Z.addScalar = V;
  function P(w0, P0, l0) {
    return w0[0] = P0[0] - l0, w0[1] = P0[1] - l0, w0[2] = P0[2] - l0, w0;
  }
  Z.subScalar = P;
  function I(w0, P0) {
    return w0[0] = Math.round(P0[0]), w0[1] = Math.round(P0[1]), w0[2] = Math.round(P0[2]), w0;
  }
  Z.round = I;
  function S(w0, P0) {
    return w0[0] = Math.ceil(P0[0]), w0[1] = Math.ceil(P0[1]), w0[2] = Math.ceil(P0[2]), w0;
  }
  Z.ceil = S;
  function f(w0, P0) {
    return w0[0] = Math.floor(P0[0]), w0[1] = Math.floor(P0[1]), w0[2] = Math.floor(P0[2]), w0;
  }
  Z.floor = f;
  function v(w0, P0) {
    return w0[0] = Math.trunc(P0[0]), w0[1] = Math.trunc(P0[1]), w0[2] = Math.trunc(P0[2]), w0;
  }
  Z.trunc = v;
  function h(w0, P0) {
    return w0[0] = Math.abs(P0[0]), w0[1] = Math.abs(P0[1]), w0[2] = Math.abs(P0[2]), w0;
  }
  Z.abs = h;
  function x(w0, P0, l0) {
    return w0[0] = Math.min(P0[0], l0[0]), w0[1] = Math.min(P0[1], l0[1]), w0[2] = Math.min(P0[2], l0[2]), w0;
  }
  Z.min = x;
  function b(w0, P0, l0) {
    return w0[0] = Math.max(P0[0], l0[0]), w0[1] = Math.max(P0[1], l0[1]), w0[2] = Math.max(P0[2], l0[2]), w0;
  }
  Z.max = b;
  function g(w0, P0, l0, z1) {
    return w0[0] = Math.max(l0[0], Math.min(z1[0], P0[0])), w0[1] = Math.max(l0[1], Math.min(z1[1], P0[1])), w0[2] = Math.max(l0[2], Math.min(z1[2], P0[2])), w0;
  }
  Z.clamp = g;
  function m(w0, P0) {
    let l0 = P0[0] - w0[0], z1 = P0[1] - w0[1], J2 = P0[2] - w0[2];
    return Math.sqrt(l0 * l0 + z1 * z1 + J2 * J2);
  }
  Z.distance = m;
  function i(w0, P0) {
    let l0 = P0[0] - w0[0], z1 = P0[1] - w0[1], J2 = P0[2] - w0[2];
    return l0 * l0 + z1 * z1 + J2 * J2;
  }
  Z.squaredDistance = i;
  function r(w0) {
    let P0 = w0[0], l0 = w0[1], z1 = w0[2];
    return Math.sqrt(P0 * P0 + l0 * l0 + z1 * z1);
  }
  Z.magnitude = r;
  function Y0(w0) {
    let P0 = w0[0], l0 = w0[1], z1 = w0[2];
    return P0 * P0 + l0 * l0 + z1 * z1;
  }
  Z.squaredMagnitude = Y0;
  function c(w0, P0, l0) {
    return B(w0, u(w0, P0), l0);
  }
  Z.setMagnitude = c;
  function n(w0, P0) {
    return w0[0] = -P0[0], w0[1] = -P0[1], w0[2] = -P0[2], w0;
  }
  Z.negate = n;
  function l(w0, P0) {
    return w0[0] = 1 / P0[0], w0[1] = 1 / P0[1], w0[2] = 1 / P0[2], w0;
  }
  Z.inverse = l;
  function u(w0, P0) {
    let l0 = P0[0], z1 = P0[1], J2 = P0[2], N2 = l0 * l0 + z1 * z1 + J2 * J2;
    if (N2 > 0)
      N2 = 1 / Math.sqrt(N2), w0[0] = P0[0] * N2, w0[1] = P0[1] * N2, w0[2] = P0[2] * N2;
    return w0;
  }
  Z.normalize = u;
  function G0(w0, P0) {
    return w0[0] * P0[0] + w0[1] * P0[1] + w0[2] * P0[2];
  }
  Z.dot = G0;
  function F0(w0, P0, l0) {
    let z1 = P0[0], J2 = P0[1], N2 = P0[2], X8 = l0[0], c0 = l0[1], M1 = l0[2];
    return w0[0] = J2 * M1 - N2 * c0, w0[1] = N2 * X8 - z1 * M1, w0[2] = z1 * c0 - J2 * X8, w0;
  }
  Z.cross = F0;
  function t(w0, P0, l0, z1) {
    let J2 = P0[0], N2 = P0[1], X8 = P0[2];
    return w0[0] = J2 + z1 * (l0[0] - J2), w0[1] = N2 + z1 * (l0[1] - N2), w0[2] = X8 + z1 * (l0[2] - X8), w0;
  }
  Z.lerp = t;
  let Z0 = J();
  function U0(w0, P0, l0, z1) {
    let J2 = x8(G0(P0, l0), -1, 1), N2 = Math.acos(J2) * z1;
    return T(Z0, l0, P0, -J2), u(Z0, Z0), R(w0, B(w0, P0, Math.cos(N2)), B(Z0, Z0, Math.sin(N2)));
  }
  Z.slerp = U0;
  function a(w0, P0, l0, z1, J2, N2) {
    let X8 = N2 * N2, c0 = X8 * (2 * N2 - 3) + 1, M1 = X8 * (N2 - 2) + N2, g1 = X8 * (N2 - 1), l2 = X8 * (3 - 2 * N2);
    return w0[0] = P0[0] * c0 + l0[0] * M1 + z1[0] * g1 + J2[0] * l2, w0[1] = P0[1] * c0 + l0[1] * M1 + z1[1] * g1 + J2[1] * l2, w0[2] = P0[2] * c0 + l0[2] * M1 + z1[2] * g1 + J2[2] * l2, w0;
  }
  Z.hermite = a;
  function Q0(w0, P0, l0, z1, J2, N2) {
    let X8 = 1 - N2, c0 = X8 * X8, M1 = N2 * N2, g1 = c0 * X8, l2 = 3 * N2 * c0, d8 = 3 * M1 * X8, I1 = M1 * N2;
    return w0[0] = P0[0] * g1 + l0[0] * l2 + z1[0] * d8 + J2[0] * I1, w0[1] = P0[1] * g1 + l0[1] * l2 + z1[1] * d8 + J2[1] * I1, w0[2] = P0[2] * g1 + l0[2] * l2 + z1[2] * d8 + J2[2] * I1, w0;
  }
  Z.bezier = Q0;
  function $0(w0, P0, l0, z1, J2) {
    return w0[0] = DS(P0[0], l0[0], z1[0], J2), w0[1] = DS(P0[1], l0[1], z1[1], J2), w0[2] = DS(P0[2], l0[2], z1[2], J2), w0;
  }
  Z.quadraticBezier = $0;
  function R0(w0, P0, l0, z1, J2, N2, X8) {
    return w0[0] = DM(P0[0], l0[0], z1[0], J2[0], N2, X8), w0[1] = DM(P0[1], l0[1], z1[1], J2[1], N2, X8), w0[2] = DM(P0[2], l0[2], z1[2], J2[2], N2, X8), w0;
  }
  Z.spline = R0;
  function X0(w0, P0) {
    let l0 = Math.random() * 2 * Math.PI, z1 = Math.random() * 2 - 1, J2 = Math.sqrt(1 - z1 * z1) * P0;
    return w0[0] = Math.cos(l0) * J2, w0[1] = Math.sin(l0) * J2, w0[2] = z1 * P0, w0;
  }
  Z.random = X0;
  function E0(w0, P0, l0) {
    let z1 = P0[0], J2 = P0[1], N2 = P0[2], X8 = 1 / (l0[3] * z1 + l0[7] * J2 + l0[11] * N2 + l0[15] || 1);
    return w0[0] = (l0[0] * z1 + l0[4] * J2 + l0[8] * N2 + l0[12]) * X8, w0[1] = (l0[1] * z1 + l0[5] * J2 + l0[9] * N2 + l0[13]) * X8, w0[2] = (l0[2] * z1 + l0[6] * J2 + l0[10] * N2 + l0[14]) * X8, w0;
  }
  Z.transformMat4 = E0;
  function V0(w0, P0, l0) {
    let z1 = P0[0], J2 = P0[1], N2 = P0[2];
    return w0[0] = l0[0] * z1 + l0[4] * J2 + l0[8] * N2, w0[1] = l0[1] * z1 + l0[5] * J2 + l0[9] * N2, w0[2] = l0[2] * z1 + l0[6] * J2 + l0[10] * N2, u(w0, w0);
  }
  Z.transformDirection = V0;
  function u0(w0, P0, l0, z1, J2, N2) {
    let X8 = P0[0 + J2], c0 = P0[1 + J2], M1 = P0[2 + J2], g1 = 1 / (l0[3 + N2] * X8 + l0[7 + N2] * c0 + l0[11 + N2] * M1 + l0[15 + N2] || 1);
    return w0[0 + z1] = (l0[0 + N2] * X8 + l0[4 + N2] * c0 + l0[8 + N2] * M1 + l0[12 + N2]) * g1, w0[1 + z1] = (l0[1 + N2] * X8 + l0[5 + N2] * c0 + l0[9 + N2] * M1 + l0[13 + N2]) * g1, w0[2 + z1] = (l0[2 + N2] * X8 + l0[6 + N2] * c0 + l0[10 + N2] * M1 + l0[14 + N2]) * g1, w0;
  }
  Z.transformMat4Offset = u0;
  function N0(w0, P0, l0, z1, J2, N2) {
    let X8 = P0[0 + J2], c0 = P0[1 + J2], M1 = P0[2 + J2];
    w0[0 + z1] = l0[0 + N2] * X8 + l0[4 + N2] * c0 + l0[8 + N2] * M1, w0[1 + z1] = l0[1 + N2] * X8 + l0[5 + N2] * c0 + l0[9 + N2] * M1, w0[2 + z1] = l0[2 + N2] * X8 + l0[6 + N2] * c0 + l0[10 + N2] * M1;
    let g1 = Math.hypot(w0[0 + z1], w0[1 + z1], w0[2 + z1]);
    if (g1 > 0)
      w0[0 + z1] /= g1, w0[1 + z1] /= g1, w0[2 + z1] /= g1;
    return w0;
  }
  Z.transformDirectionOffset = N0;
  function q0(w0, P0, l0) {
    let z1 = P0[0], J2 = P0[1], N2 = P0[2];
    return w0[0] = z1 * l0[0] + J2 * l0[3] + N2 * l0[6], w0[1] = z1 * l0[1] + J2 * l0[4] + N2 * l0[7], w0[2] = z1 * l0[2] + J2 * l0[5] + N2 * l0[8], w0;
  }
  Z.transformMat3 = q0;
  function A0(w0, P0, l0) {
    let z1 = P0[0], J2 = P0[1], N2 = P0[2], X8 = l0[0], c0 = l0[1], M1 = l0[2], g1 = l0[3], l2 = g1 * z1 + c0 * N2 - M1 * J2, d8 = g1 * J2 + M1 * z1 - X8 * N2, I1 = g1 * N2 + X8 * J2 - c0 * z1, W2 = -X8 * z1 - c0 * J2 - M1 * N2;
    return w0[0] = l2 * g1 + W2 * -X8 + d8 * -M1 - I1 * -c0, w0[1] = d8 * g1 + W2 * -c0 + I1 * -X8 - l2 * -M1, w0[2] = I1 * g1 + W2 * -M1 + l2 * -c0 - d8 * -X8, w0;
  }
  Z.transformQuat = A0;
  function S0(w0, P0) {
    let l0 = Math.sqrt(Y0(w0) * Y0(P0));
    if (l0 === 0)
      return Math.PI / 2;
    let z1 = G0(w0, P0) / l0;
    return Math.acos(x8(z1, -1, 1));
  }
  Z.angle = S0;
  let a0 = J(), D1 = J(), Y1 = J(), u1 = J(), b0 = J(), x0 = J(), m0 = J();
  function e0(w0, P0, l0, z1) {
    z(a0, w0, P0), z(D1, l0, P0), z(Y1, P0, l0), z(u1, z1, l0), F0(b0, a0, D1), F0(x0, Y1, u1);
    let J2 = S0(b0, x0);
    return F0(m0, b0, x0), G0(D1, m0) > 0 ? J2 : -J2;
  }
  Z.dihedralAngle = e0;
  function p(w0, P0, l0, z1) {
    return Z.set(w0, z1 * Math.cos(l0) * Math.sin(P0), z1 * Math.sin(l0) * Math.sin(P0), z1 * Math.cos(P0));
  }
  Z.directionFromSpherical = p;
  function J0(w0, P0) {
    return w0[0] === P0[0] && w0[1] === P0[1] && w0[2] === P0[2];
  }
  Z.exactEquals = J0;
  function T0(w0, P0) {
    let l0 = w0[0], z1 = w0[1], J2 = w0[2], N2 = P0[0], X8 = P0[1], c0 = P0[2];
    return Math.abs(l0 - N2) <= u8 * Math.max(1, Math.abs(l0), Math.abs(N2)) && Math.abs(z1 - X8) <= u8 * Math.max(1, Math.abs(z1), Math.abs(X8)) && Math.abs(J2 - c0) <= u8 * Math.max(1, Math.abs(J2), Math.abs(c0));
  }
  Z.equals = T0;
  let o0 = J();
  function y0(w0, P0, l0) {
    let z1 = S0(P0, l0);
    if (Math.abs(z1) < 0.0001)
      return e.setIdentity(w0);
    if (Math.abs(z1 - Math.PI) < u8)
      return e.fromRotation(w0, Math.PI, Math.abs(P0[0]) < 0.9 ? Z.unitX : Z.unitZ);
    let J2 = F0(o0, P0, l0);
    return e.fromRotation(w0, z1, J2);
  }
  Z.makeRotation = y0;
  function $1(w0) {
    return w0[0] === 0 && w0[1] === 0 && w0[2] === 0;
  }
  Z.isZero = $1;
  function F1(w0, P0, l0, z1) {
    z(w0, P0, z1);
    let J2 = G0(l0, w0) / Y0(l0);
    return R(w0, B(w0, l0, J2), z1);
  }
  Z.projectPointOnVector = F1;
  let A1 = J();
  function P1(w0, P0, l0, z1) {
    return u(A1, l0), z(w0, P0, z1), z(w0, P0, B(A1, A1, G0(w0, A1)));
  }
  Z.projectPointOnPlane = P1;
  function S1(w0, P0, l0) {
    let z1 = G0(l0, P0) / Y0(l0);
    return B(w0, l0, z1);
  }
  Z.projectOnVector = S1;
  let _1 = J();
  function a1(w0, P0, l0) {
    return S1(_1, P0, l0), z(w0, P0, _1);
  }
  Z.projectOnPlane = a1;
  function U2(w0, P0, l0) {
    if (u(w0, F0(w0, F0(w0, P0, l0), P0)), !Z.isZero(w0))
      return w0;
    if (w0[0] = 1, w0[1] = 0, w0[2] = 0, u(w0, F0(w0, F0(w0, P0, w0), P0)), !Z.isZero(w0))
      return w0;
    if (w0[0] = 0, w0[1] = 1, w0[2] = 0, u(w0, F0(w0, F0(w0, P0, w0), P0)), !Z.isZero(w0))
      return w0;
    if (u(w0, l0), !Z.isZero(w0))
      return w0;
    return w0[0] = 1, w0[1] = 0, w0[2] = 0, w0;
  }
  Z.orthogonalize = U2;
  function G2(w0, P0, l0) {
    if (G0(P0, l0) > 0)
      E(w0, P0);
    else
      n(w0, E(w0, P0));
    return w0;
  }
  Z.matchDirection = G2;
  function P2(w0, P0) {
    if ($1(P0))
      return E(w0, Z.unitX);
    else {
      let l0 = J();
      if (Math.abs(P0[0]) < Math.abs(P0[1]) && Math.abs(P0[0]) < Math.abs(P0[2]))
        l0[0] = 0, l0[1] = P0[2], l0[2] = -P0[1];
      else if (Math.abs(P0[1]) < Math.abs(P0[2]))
        l0[0] = -P0[2], l0[1] = 0, l0[2] = P0[0];
      else
        l0[0] = P0[1], l0[1] = -P0[0], l0[2] = 0;
      return u(w0, l0);
    }
  }
  Z.orthogonalDirection = P2;
  let v2 = J(), O8 = J();
  function n8(w0, P0, l0, z1) {
    return z(v2, l0, P0), z(O8, z1, P0), u(w0, F0(w0, v2, O8));
  }
  Z.triangleNormal = n8;
  let z6 = J();
  function L8(w0, P0, l0) {
    return Z.scaleAndAdd(w0, P0, Z.sub(z6, l0, P0), 0.5);
  }
  Z.center = L8;
  function R8(w0, P0) {
    return `[${w0[0].toPrecision(P0)} ${w0[1].toPrecision(P0)} ${w0[2].toPrecision(P0)}]`;
  }
  Z.toString = R8, Z.origin = q(0, 0, 0), Z.unit = q(1, 1, 1), Z.negUnit = q(-1, -1, -1), Z.unitX = q(1, 0, 0), Z.unitY = q(0, 1, 0), Z.unitZ = q(0, 0, 1), Z.negUnitX = q(-1, 0, 0), Z.negUnitY = q(0, -1, 0), Z.negUnitZ = q(0, 0, -1);
})(M || (M = {}));

// node_modules/molstar/lib/mol-util/object.js
var wS = Object.prototype.hasOwnProperty;
function p50(Z, J) {
  for (let $ of Object.keys(J)) {
    if (!wS.call(J, $))
      continue;
    if (typeof Z[$] === "undefined")
      Z[$] = J[$];
  }
  return Z;
}
function qa0(Z, J) {
  let $ = !1;
  for (let X of Object.keys(J)) {
    if (!wS.call(J, X))
      continue;
    if (J[X] !== Z[X]) {
      $ = !0;
      break;
    }
  }
  if (!$)
    return Z;
  return Object.assign({}, Z, J);
}
function iL(Z, J) {
  if (!Z) {
    if (!J)
      return !0;
    return !1;
  }
  if (!J)
    return !1;
  let $ = Object.keys(Z);
  if (Object.keys(J).length !== $.length)
    return !1;
  for (let X of $)
    if (!wS.call(Z, X) || Z[X] !== J[X])
      return !1;
  return !0;
}
function u50(Z, J) {
  let $ = Z;
  for (let X = 0;X < J.length; X++) {
    if (!J[X])
      continue;
    if ($ = qa0(Z, J[X]), $ !== Z) {
      for (let Y = X + 1;Y < J.length; Y++)
        $ = Object.assign($, J[Y]);
      break;
    }
  }
  return $;
}
function W$(Z) {
  if (Z === null || typeof Z !== "object")
    return Z;
  if (Z instanceof Array) {
    let J = [];
    for (let $ = 0, X = Z.length;$ < X; $++)
      J[$] = W$(Z[$]);
    return J;
  }
  if (typeof Z === "object" && !("prototype" in Z)) {
    let J = {};
    for (let $ in Z)
      if (wS.call(Z, $))
        J[$] = W$(Z[$]);
    return J;
  }
  throw new Error(`Can't clone, type "${typeof Z}" unsupported`);
}
function B7(Z, J) {
  if (!Z)
    return;
  for (let $ of Object.keys(Z))
    J(Z[$], $);
}

// node_modules/molstar/lib/mol-util/string.js
function c50(Z, J = " ") {
  return Z.replace(/([a-z\xE0-\xFF])([A-Z\xC0\xDF])/g, `$1${J}$2`);
}
function s$(Z) {
  return TN(c50(Z));
}
var Fa0 = (Z) => Z.toUpperCase();
function l50(Z) {
  if (!Z)
    return "";
  return typeof Z === "string" ? Z.toUpperCase() : `${Z}`.toUpperCase();
}
function TN(Z) {
  return Z.toLowerCase().replace(/^\w|\s\w/g, Fa0);
}
function Ua0(Z) {
  return Z.replace(/_/g, " ");
}
function La0(Z) {
  return Z.replace(/-/g, " ");
}
function v$(Z) {
  return TN(c50(Ua0(La0(Z))));
}
function n50(Z, J) {
  let $ = Object.keys(J), X = Object.values(J);
  return new Function(...$, `return \`${Z}\`;`)(...X);
}
function MK(Z) {
  return Z.replace(/<\/?[^>]+>/g, "");
}
function IF(Z) {
  return Z.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
}

// node_modules/molstar/lib/mol-util/color/spaces/lab.js
function TJ() {
  return TJ.zero();
}
(function(Z) {
  function J() {
    let h = [0.1, 0, 0];
    return h[0] = 0, h;
  }
  Z.zero = J;
  function $(h, x, b) {
    let g = J();
    return g[0] = h, g[1] = x, g[2] = b, g;
  }
  Z.create = $;
  function X(h, x, b, g) {
    return h[0] = x, h[1] = b, h[2] = g, h;
  }
  Z.set = X;
  function Y(h, x) {
    let b = x[0] - h[0], g = x[1] - h[1], m = x[2] - h[2];
    return Math.sqrt(b * b + g * g + m * m);
  }
  Z.distance = Y;
  function Q(h, x) {
    let [b, g, m] = i0.toRgb(x), [i, r, Y0] = v(b, g, m), c = 116 * r - 16;
    return h[0] = c < 0 ? 0 : c, h[1] = 500 * (i - r), h[2] = 200 * (r - Y0), h;
  }
  Z.fromColor = Q;
  function W(h, x) {
    return R5.toLab(h, x);
  }
  Z.fromHcl = W;
  function K(h) {
    let x = (h[0] + 16) / 116, b = isNaN(h[1]) ? x : x + h[1] / 500, g = isNaN(h[2]) ? x : x - h[2] / 200;
    x = D * I(x), b = z * I(b), g = A * I(g);
    let m = P(3.2404542 * b - 1.5371385 * x - 0.4985314 * g), i = P(-0.969266 * b + 1.8760108 * x + 0.041556 * g), r = P(0.0556434 * b - 0.2040259 * x + 1.0572252 * g);
    return i0.fromRgb(Math.round(x8(m, 0, 255)), Math.round(x8(i, 0, 255)), Math.round(x8(r, 0, 255)));
  }
  Z.toColor = K;
  function G(h, x) {
    let [b, g, m] = x, i = Math.sqrt(g * g + m * m), r = (k$(Math.atan2(m, g)) + 360) % 360;
    if (Math.round(i * 1e4) === 0)
      r = Number.NaN;
    return h[0] = r, h[1] = i, h[2] = b, h;
  }
  Z.toHcl = G;
  function H(h, x) {
    return h[0] = x[0], h[1] = x[1], h[2] = x[2], h;
  }
  Z.copy = H;
  function N(h, x, b) {
    return h[0] = x[0] - R * b, h[1] = x[1], h[2] = x[2], h;
  }
  Z.darken = N;
  function q(h, x, b) {
    return N(h, x, -b);
  }
  Z.lighten = q;
  let U = [0, 0, 0];
  function F(h, x, b) {
    return G(U, x), R5.toLab(h, R5.saturate(U, U, b));
  }
  Z.saturate = F;
  function E(h, x, b) {
    return F(h, x, -b);
  }
  Z.desaturate = E;
  let R = 18, z = 0.95047, D = 1, A = 1.08883, B = 0.137931034, T = 0.206896552, w = 0.12841855, V = 0.008856452;
  function P(h) {
    return 255 * (h <= 0.00304 ? 12.92 * h : 1.055 * Math.pow(h, 0.4166666666666667) - 0.055);
  }
  function I(h) {
    return h > T ? h * h * h : w * (h - B);
  }
  function S(h) {
    if ((h /= 255) <= 0.04045)
      return h / 12.92;
    return Math.pow((h + 0.055) / 1.055, 2.4);
  }
  function f(h) {
    if (h > V)
      return Math.pow(h, 0.3333333333333333);
    return h / w + B;
  }
  function v(h, x, b) {
    h = S(h), x = S(x), b = S(b);
    let g = f((0.4124564 * h + 0.3575761 * x + 0.1804375 * b) / z), m = f((0.2126729 * h + 0.7151522 * x + 0.072175 * b) / D), i = f((0.0193339 * h + 0.119192 * x + 0.9503041 * b) / A);
    return [g, m, i];
  }
})(TJ || (TJ = {}));

// node_modules/molstar/lib/mol-util/color/spaces/hcl.js
function R5() {
  return R5.zero();
}
(function(Z) {
  function J() {
    let A = [0.1, 0, 0];
    return A[0] = 0, A;
  }
  Z.zero = J;
  function $(A, B, T) {
    let w = J();
    return w[0] = A, w[1] = B, w[2] = T, w;
  }
  Z.create = $;
  function X(A, B, T, w) {
    return A[0] = B, A[1] = T, A[2] = w, A;
  }
  Z.set = X;
  function Y(A) {
    return !isNaN(A[0]);
  }
  Z.hasHue = Y;
  let Q = [0, 0, 0];
  function W(A, B) {
    return TJ.toHcl(A, TJ.fromColor(Q, B));
  }
  Z.fromColor = W;
  function K(A, B) {
    return TJ.toHcl(A, B);
  }
  Z.fromLab = K;
  let G = [0, 0, 0];
  function H(A) {
    return TJ.toColor(N(G, A));
  }
  Z.toColor = H;
  function N(A, B) {
    let [T, w, V] = B;
    if (isNaN(T))
      T = 0;
    return T = _8(T), A[0] = V, A[1] = Math.cos(T) * w, A[2] = Math.sin(T) * w, A;
  }
  Z.toLab = N;
  function q(A, B) {
    return A[0] = B[0], A[1] = B[1], A[2] = B[2], A;
  }
  Z.copy = q;
  function U(A, B, T) {
    return A[0] = B[0], A[1] = Math.max(0, B[1] + D * T), A[2] = B[2], A;
  }
  Z.saturate = U;
  function F(A, B, T) {
    return U(A, B, -T);
  }
  Z.desaturate = F;
  let E = [0, 0, 0];
  function R(A, B, T) {
    return N(E, B), TJ.toHcl(A, TJ.darken(E, E, T));
  }
  Z.darken = R;
  function z(A, B, T) {
    return R(A, B, -T);
  }
  Z.lighten = z;
  let D = 18;
})(R5 || (R5 = {}));

// node_modules/molstar/lib/mol-util/color/spaces/rgb.js
function lO() {
  return lO.zero();
}
(function(Z) {
  function J() {
    let Y = [0.1, 0, 0];
    return Y[0] = 0, Y;
  }
  Z.zero = J;
  function $(Y, Q) {
    return Y[0] = (Q >> 16 & 255) / 255, Y[1] = (Q >> 8 & 255) / 255, Y[2] = (Q & 255) / 255, Y;
  }
  Z.fromColor = $;
  function X(Y) {
    return Y[0] * 255 << 16 | Y[1] * 255 << 8 | Y[2] * 255;
  }
  Z.toColor = X;
})(lO || (lO = {}));

// node_modules/molstar/lib/mol-util/color/spaces/hsl.js
function _N() {
  return _N.zero();
}
(function(Z) {
  function J() {
    let N = [0.1, 0, 0];
    return N[0] = 0, N;
  }
  Z.zero = J;
  let $ = lO();
  function X(N, q) {
    return lO.fromColor($, q), Z.fromRgb(N, $);
  }
  Z.fromColor = X;
  function Y(N) {
    return G($, N), lO.toColor($);
  }
  Z.toColor = Y;
  function Q(N, q) {
    let [U, F, E] = q, R = Math.min(U, F, E), z = Math.max(U, F, E), D = (z + R) / 2, A = 0, B = 0;
    if (z === R)
      A = 0, B = Number.NaN;
    else
      A = D < 0.5 ? (z - R) / (z + R) : (z - R) / (2 - z - R);
    if (U === z)
      B = (F - E) / (z - R);
    else if (F === z)
      B = 2 + (E - U) / (z - R);
    else if (E === z)
      B = 4 + (U - F) / (z - R);
    if (B *= 60, B < 0)
      B += 360;
    return N[0] = B, N[1] = A, N[2] = D, N;
  }
  Z.fromRgb = Q;
  let W = [0, 0, 0], K = [0, 0, 0];
  function G(N, q) {
    let [U, F, E] = q, R, z, D;
    if (F === 0)
      R = z = D = E;
    else {
      let A = W, B = K, T = E < 0.5 ? E * (1 + F) : E + F - E * F, w = 2 * E - T, V = U / 360;
      A[0] = V + 0.3333333333333333, A[1] = V, A[2] = V - 0.3333333333333333;
      for (let P = 0;P < 3; P++) {
        if (A[P] < 0)
          A[P] += 1;
        if (A[P] > 1)
          A[P] -= 1;
        if (6 * A[P] < 1)
          B[P] = w + (T - w) * 6 * A[P];
        else if (2 * A[P] < 1)
          B[P] = T;
        else if (3 * A[P] < 2)
          B[P] = w + (T - w) * (0.6666666666666666 - A[P]) * 6;
        else
          B[P] = w;
      }
      R = B[0], z = B[1], D = B[2];
    }
    return N[0] = R, N[1] = z, N[2] = D, N;
  }
  Z.toRgb = G;
  function H(N, q, U, F) {
    let E = q, R = U, [z, D, A] = E, [B, T, w] = R, V, P, I;
    if (!isNaN(z) && !isNaN(B)) {
      if (B > z && B - z > 180)
        I = B - (z + 360);
      else if (B < z && z - B > 180)
        I = B + 360 - z;
      else
        I = B - z;
      P = z + F * I;
    } else if (!isNaN(z)) {
      if (P = z, w === 1 || w === 0)
        V = D;
    } else if (!isNaN(B)) {
      if (P = B, A === 1 || A === 0)
        V = T;
    } else
      P = Number.NaN;
    if (V === void 0)
      V = D + F * (T - D);
    let S = A + F * (w - A);
    return N[0] = P, N[1] = V, N[2] = S, N;
  }
  Z.interpolate = H;
})(_N || (_N = {}));

// node_modules/molstar/lib/mol-util/color/color.js
function i0(Z) {
  return Z;
}
(function(Z) {
  function J(c) {
    return `rgb(${c >> 16 & 255}, ${c >> 8 & 255}, ${c & 255})`;
  }
  Z.toStyle = J;
  function $(c) {
    return "#" + ("000000" + c.toString(16)).slice(-6);
  }
  Z.toHexStyle = $;
  function X(c) {
    return "0x" + ("000000" + c.toString(16)).slice(-6);
  }
  Z.toHexString = X;
  function Y(c) {
    return `RGB: ${Z.toRgb(c).join(", ")}`;
  }
  Z.toRgbString = Y;
  function Q(c) {
    return [c >> 16 & 255, c >> 8 & 255, c & 255];
  }
  Z.toRgb = Q;
  function W(c) {
    return [(c >> 16 & 255) / 255, (c >> 8 & 255) / 255, (c & 255) / 255];
  }
  Z.toRgbNormalized = W;
  function K(c) {
    return parseInt(c.replace("#", "0x"));
  }
  Z.fromHexStyle = K;
  function G(c) {
    return parseInt(c);
  }
  Z.fromHexString = G;
  function H(c, n, l) {
    return c << 16 | n << 8 | l;
  }
  Z.fromRgb = H;
  function N(c, n, l) {
    return c * 255 << 16 | n * 255 << 8 | l * 255;
  }
  Z.fromNormalizedRgb = N;
  function q(c, n) {
    return H(c[n], c[n + 1], c[n + 2]);
  }
  Z.fromArray = q;
  function U(c, n) {
    return N(c[n], c[n + 1], c[n + 2]);
  }
  Z.fromNormalizedArray = U;
  function F(c) {
    if (typeof c === "number")
      return c;
    else
      return c[0];
  }
  Z.fromColorListEntry = F;
  function E(c, n, l) {
    return n[l] = c >> 16 & 255, n[l + 1] = c >> 8 & 255, n[l + 2] = c & 255, n;
  }
  Z.toArray = E;
  function R(c, n, l) {
    return n[l] = (c >> 16 & 255) / 255, n[l + 1] = (c >> 8 & 255) / 255, n[l + 2] = (c & 255) / 255, n;
  }
  Z.toArrayNormalized = R;
  function z(c, n) {
    return c[0] = n >> 16 & 255, c[1] = n >> 8 & 255, c[2] = n & 255, c;
  }
  Z.toVec3 = z;
  function D(c, n) {
    return c[0] = (n >> 16 & 255) / 255, c[1] = (n >> 8 & 255) / 255, c[2] = (n & 255) / 255, c;
  }
  Z.toVec3Normalized = D;
  function A(c, n, l) {
    let u = c >> 16 & 255, G0 = c >> 8 & 255, F0 = c & 255, t = n >> 16 & 255, Z0 = n >> 8 & 255, U0 = n & 255, a = u + (t - u) * l, Q0 = G0 + (Z0 - G0) * l, $0 = F0 + (U0 - F0) * l;
    return a << 16 | Q0 << 8 | $0;
  }
  Z.interpolate = A;
  let B = _N.zero(), T = _N.zero();
  function w(c, n, l) {
    let u = _N.fromColor(B, c), G0 = _N.fromColor(T, n);
    return _N.interpolate(u, u, G0, l), _N.toColor(u);
  }
  Z.interpolateHsl = w;
  function V(c) {
    let n = c >> 16 & 255, l = c >> 8 & 255, u = c & 255;
    return n !== l || n !== u;
  }
  Z.hasHue = V;
  let P = [0, 0, 0];
  function I(c, n) {
    if (!V(c))
      return c;
    return R5.fromColor(P, c), R5.toColor(R5.saturate(P, P, n));
  }
  Z.saturate = I;
  function S(c, n) {
    return I(c, -n);
  }
  Z.desaturate = S;
  let f = [0, 0, 0];
  function v(c, n) {
    return TJ.fromColor(f, c), TJ.toColor(TJ.darken(f, f, n));
  }
  Z.darken = v;
  function h(c, n) {
    return v(c, -n);
  }
  Z.lighten = h;
  function x(c) {
    return c <= 0.03928 ? c / 12.92 : Math.pow((c + 0.055) / 1.055, 2.4);
  }
  function b(c) {
    let n = x((c >> 16 & 255) / 255), l = x((c >> 8 & 255) / 255), u = x((c & 255) / 255);
    return 0.2126 * n + 0.7152 * l + 0.0722 * u;
  }
  Z.luminance = b;
  function g(c, n) {
    let l = b(c), u = b(n);
    return l > u ? (l + 0.05) / (u + 0.05) : (u + 0.05) / (l + 0.05);
  }
  Z.contrast = g;
  function m(c) {
    return c < 0.04045 ? c * 0.0773993808 : Math.pow(c * 0.9478672986 + 0.0521327014, 2.4);
  }
  function i(c) {
    return N(m((c >> 16 & 255) / 255), m((c >> 8 & 255) / 255), m((c & 255) / 255));
  }
  Z.sRGBToLinear = i;
  function r(c) {
    return c < 0.0031308 ? c * 12.92 : 1.055 * Math.pow(c, 0.41666) - 0.055;
  }
  function Y0(c) {
    return N(r((c >> 16 & 255) / 255), r((c >> 8 & 255) / 255), r((c & 255) / 255));
  }
  Z.linearToSRGB = Y0;
})(i0 || (i0 = {}));
function r8(Z, J, $, X) {
  return { label: Z, description: $, list: X, type: J };
}
function QQ(Z) {
  return Z;
}
function VN(Z, J, $) {
  let X = {};
  for (let Y in Z) {
    let Q = Z[Y];
    Q = i0.saturate(Q, J), Q = i0.darken(Q, -$), X[Y] = Q;
  }
  return X;
}
function i50(Z) {
  return Z;
}

// node_modules/molstar/lib/mol-util/color/lists.js
var g7 = {
  reds: r8("Reds", "sequential", "Reds, sequential color scheme from ColorBrewer 2.0", [16774640, 16703698, 16563105, 16552562, 16476746, 15678252, 13309981, 10817301, 6750221]),
  oranges: r8("Oranges", "sequential", "Oranges, sequential color scheme from ColorBrewer 2.0", [16774635, 16705230, 16634018, 16625259, 16616764, 15821075, 14239745, 10892803, 8333060]),
  greens: r8("Greens", "sequential", "Greens, sequential color scheme from ColorBrewer 2.0", [16252149, 15070688, 13101504, 10607003, 7652470, 4303709, 2329413, 27948, 17435]),
  blues: r8("Blues", "sequential", "Blues, sequential color scheme from ColorBrewer 2.0", [16251903, 14609399, 13032431, 10406625, 7057110, 4362950, 2191797, 545180, 536683]),
  purples: r8("Purples", "sequential", "Purples, sequential color scheme from ColorBrewer 2.0", [16579581, 15724021, 14342891, 12369372, 10394312, 8420794, 6967715, 5515151, 4128893]),
  greys: r8("Greys", "sequential", "Greys, sequential color scheme from ColorBrewer 2.0", [16777215, 15790320, 14277081, 12434877, 9868950, 7566195, 5395026, 2434341, 0]),
  "orange-red": r8("Orange-Red", "sequential", "OrRd, sequential color scheme from ColorBrewer 2.0", [16775148, 16705736, 16635038, 16628612, 16551257, 15689032, 14102559, 11730944, 8323072]),
  "blue-green": r8("Blue-Green", "sequential", "BuGn, sequential color scheme from ColorBrewer 2.0", [16252157, 15070713, 13429990, 10082505, 6734500, 4304502, 2329413, 27948, 17435]),
  "purple-blue-green": r8("Purple-Blue-Green", "sequential", "PuBuGn, sequential color scheme from ColorBrewer 2.0", [16775163, 15524592, 13685222, 10927579, 6793679, 3576000, 164234, 93273, 83510]),
  "green-blue": r8("Green-Blue", "sequential", "GnBu, sequential color scheme from ColorBrewer 2.0", [16252144, 14742491, 13429701, 11066805, 8113348, 5157843, 2854078, 551084, 540801]),
  "purple-blue": r8("Purple-Blue", "sequential", "PuBu, sequential color scheme from ColorBrewer 2.0", [16775163, 15525874, 13685222, 10927579, 7645647, 3576000, 356528, 285325, 145496]),
  "blue-purple": r8("Blue-Purple", "sequential", "BuPu, sequential color scheme from ColorBrewer 2.0", [16252157, 14740724, 12571622, 10403034, 9213638, 9202609, 8929693, 8458108, 5046347]),
  "red-purple": r8("Red-Purple", "sequential", "RdPu, sequential color scheme from ColorBrewer 2.0", [16775155, 16638173, 16565696, 16424885, 16214177, 14496919, 11403646, 7995767, 4784234]),
  "purple-red": r8("Purple-Red", "sequential", "PuRd, sequential color scheme from ColorBrewer 2.0", [16250105, 15196655, 13941210, 13210823, 14640560, 15149450, 13505110, 9961539, 6750239]),
  "yellow-orange-red": r8("Yellow-Orange-Red", "sequential", "YlOrRd, sequential color scheme from ColorBrewer 2.0", [16777164, 16772512, 16701814, 16691788, 16616764, 16535082, 14883356, 12386342, 8388646]),
  "yellow-orange-brown": r8("Yellow-Orange-Brown", "sequential", "YlOrBr, sequential color scheme from ColorBrewer 2.0", [16777189, 16775100, 16704401, 16696399, 16685353, 15495188, 13388802, 10040324, 6694150]),
  "yellow-green": r8("Yellow-Green", "sequential", "YlGn, sequential color scheme from ColorBrewer 2.0", [16777189, 16252089, 14282915, 11394446, 7915129, 4303709, 2327619, 26679, 17705]),
  "yellow-green-blue": r8("Yellow-Green-Blue", "sequential", "YlGnBu, sequential color scheme from ColorBrewer 2.0", [16777177, 15595697, 13101492, 8375739, 4306628, 1937856, 2252456, 2438292, 531800]),
  "red-blue": r8("Red-Blue", "diverging", "RdBu, diverging color scheme from ColorBrewer 2.0", [6750239, 11671595, 14049357, 16033154, 16636871, 16250871, 13755888, 9618910, 4428739, 2188972, 340065]),
  "red-grey": r8("Red-Grey", "diverging", "RdGy, diverging color scheme from ColorBrewer 2.0", [6750239, 11671595, 14049357, 16033154, 16636871, 16777215, 14737632, 12237498, 8882055, 5066061, 1710618]),
  "pink-yellow-green": r8("Pink-Yellow-Green", "diverging", "PiYG, diverging color scheme from ColorBrewer 2.0", [9306450, 12917629, 14579630, 15840986, 16638191, 16250871, 15136208, 12116358, 8371265, 5083681, 2581529]),
  "brown-white-green": r8("Brown-White-Green", "diverging", "BrBG, diverging color scheme from ColorBrewer 2.0", [5517317, 9195786, 12550445, 14664317, 16181443, 16119285, 13101797, 8441281, 3512207, 91742, 15408]),
  "purple-green": r8("Purple-Green", "diverging", "PRGn, diverging color scheme from ColorBrewer 2.0", [4194379, 7744131, 10055851, 12756431, 15193320, 16250871, 14282963, 10935200, 5942881, 1800247, 17435]),
  "purple-orange": r8("Purple-Orange", "diverging", "PuOr, diverging color scheme from ColorBrewer 2.0", [2949195, 5515144, 8418220, 11709394, 14211819, 16250871, 16703670, 16627811, 14713364, 11753478, 8338184]),
  "orange-purple": r8("Orange-Purple", "diverging", "Reversed PuOr, diverging color scheme from ColorBrewer 2.0", [8338184, 11753478, 14713364, 16627811, 16703670, 16250871, 14211819, 11709394, 8418220, 5515144, 2949195]),
  "red-yellow-green": r8("Red-Yellow-Green", "diverging", "RdYlGn, diverging color scheme from ColorBrewer 2.0", [10813478, 14102567, 16018755, 16625249, 16703627, 16777151, 14282635, 10934634, 6733155, 1742928, 26679]),
  "red-yellow-blue": r8("Red-Yellow-Blue", "diverging", "RdYlBu, diverging color scheme from ColorBrewer 2.0", [10813478, 14102567, 16018755, 16625249, 16703632, 16777151, 14742520, 11262441, 7646673, 4552116, 3225237]),
  spectral: r8("Spectral", "diverging", "Spectral, diverging color scheme from ColorBrewer 2.0", [10355010, 13975119, 16018755, 16625249, 16703627, 16777151, 15136152, 11263396, 6734501, 3311805, 6180770]),
  magma: r8("Magma", "sequential", "Magma, sequential color scheme from Matplotlib, perceptually uniform shades of black-red-white", [4, 131595, 328726, 591648, 920363, 1314358, 1708098, 2167117, 2691418, 3346535, 3870576, 4460406, 4985210, 5510013, 5969279, 6560384, 7019905, 7676289, 8135554, 8660609, 9185665, 9710720, 10235519, 10826110, 11351164, 12007289, 12532343, 13057395, 13516656, 14042475, 14567784, 14962532, 15357537, 15687006, 16017244, 16216156, 16349533, 16483167, 16551011, 16619112, 16686957, 16689523, 16692347, 16694658, 16696970, 16699282, 16701594, 16638627, 16640940, 16577718, 16580031]),
  "magma-no-black": r8("Magma (no black)", "sequential", "Magma, sequential color scheme from Matplotlib, perceptually uniform shades of black-red-white (with the black region removed)", [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: r8("Inferno", "sequential", "Inferno, sequential color scheme from Matplotlib, perceptually uniform shades of black-red-yellow", [4, 131596, 328727, 657186, 1050925, 1444665, 1969221, 2427985, 3082843, 3737955, 4328040, 4852843, 5377645, 5902702, 6427502, 6952814, 7477870, 8133997, 8659051, 9184105, 9643623, 10168676, 10693729, 11218782, 11743834, 12334932, 12794703, 13254730, 13583429, 14109502, 14504250, 14833460, 15162926, 15427112, 15757088, 15955993, 16154643, 16288012, 16421383, 16489222, 16557322, 16559634, 16497183, 16434218, 16305463, 16176966, 16048470, 15919721, 15921789, 16120210, 16580516]),
  "inferno-no-black": r8("Inferno (no black)", "sequential", "Inferno, sequential color scheme from Matplotlib, perceptually uniform shades of black-red-yellow (with the black region removed)", [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: r8("Plasma", "sequential", "Plasma, sequential color scheme from Matplotlib, 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: r8("Viridis", "sequential", "Viridis, sequential color scheme from Matplotlib, 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: r8("Cividis", "sequential", "Cividis, sequential color scheme from Matplotlib, perceptually uniform shades of blue-grey-yellow, should look effectively identical to colorblind and non-colorblind users", [8273, 9305, 10079, 76644, 339560, 668266, 1062508, 1390957, 1916270, 2375790, 2835566, 3295342, 3754862, 4214638, 4543085, 5068397, 5462638, 5856878, 6185326, 6579567, 6908272, 7236721, 7499890, 7828595, 8091764, 8354933, 8617846, 8946551, 9209463, 9472888, 9736056, 10064760, 10327928, 10656632, 10985591, 11379830, 11708532, 12102770, 12497264, 12891501, 13285994, 13745766, 14140259, 14600287, 14994522, 15389014, 15717970, 16046926, 16310347, 16508232, 16640581]),
  twilight: r8("Twilight", "cyclical", "Twilight, cyclical color scheme from Matplotlib, perceptually uniform shades of white-blue-black-red-white", [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]),
  "set-2": r8("Set-2", "qualitative", "Set2, categorical color scheme from ColorBrewer 2.0", [6734501, 16551266, 9281739, 15174339, 10934356, 16767279, 15058068, 11776947]),
  accent: r8("Accent", "qualitative", "Accent, categorical color scheme from ColorBrewer 2.0", [8374655, 12496596, 16629894, 16777113, 3697840, 15729279, 12540695, 6710886]),
  "set-1": r8("Set-1", "qualitative", "Set1, categorical color scheme from ColorBrewer 2.0", [14948892, 3636920, 5091146, 9981603, 16744192, 16777011, 10901032, 16220607, 10066329]),
  "set-3": r8("Set-3", "qualitative", "Set3, categorical color scheme from ColorBrewer 2.0", [9294791, 16777139, 12499674, 16482418, 8434131, 16626786, 11787881, 16567781, 14277081, 12353725, 13429701, 16772463]),
  "dark-2": r8("Dark-2", "qualitative", "Dark2, categorical color scheme from ColorBrewer 2.0", [1810039, 14245634, 7696563, 15149450, 6727198, 15117058, 10909213, 6710886]),
  paired: r8("Paired", "qualitative", "Paired, categorical color scheme from ColorBrewer 2.0", [10931939, 2062516, 11722634, 3383340, 16489113, 14883356, 16629615, 16744192, 13284054, 6962586, 16777113, 11622696]),
  "pastel-2": r8("Pastel-2", "qualitative", "Pastel2, categorical color scheme from ColorBrewer 2.0", [11789005, 16633260, 13358568, 16042724, 15136201, 16773806, 15852236, 13421772]),
  "pastel-1": r8("Pastel-1", "qualitative", "Pastel1, categorical color scheme from ColorBrewer 2.0", [16495790, 11783651, 13429701, 14601188, 16701862, 16777164, 15063229, 16636652, 15921906]),
  turbo: r8("Turbo", "sequential", "Turbo color scheme from D3.js, improved (smooth) rainbow colormap for visualization", [2299675, 3547990, 4337541, 4799658, 4934343, 4872413, 4613867, 4289780, 3900152, 3510520, 3120629, 2796271, 2602726, 2474716, 2477264, 2611140, 2875575, 3270826, 3731101, 4387984, 5109892, 5897080, 6815085, 7798371, 8781145, 9829201, 10811209, 11858498, 12774460, 13755446, 14605618, 15389486, 16042283, 16563496, 16757029, 16753699, 16750369, 16746782, 16743196, 16608538, 16146200, 15487253, 14763026, 13973263, 13052940, 12198408, 11344133, 10621442, 9965056, 9571328, 9440256]),
  "turbo-no-black": r8("Turbo (no black)", "sequential", "Turbo color scheme from D3.js, improved (smooth) rainbow colormap for visualization, with black region removed", [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]),
  warm: r8("Warm", "sequential", "Warm, sequential color scheme from D3.js", [7225514, 7684013, 8208303, 8797873, 9322162, 9846195, 10370483, 10960051, 11484338, 12008625, 12532911, 13057452, 13581737, 14040742, 14434210, 14959005, 15352473, 15746196, 16074382, 16402824, 16665475, 16731772, 16732790, 16733808, 16734826, 16735843, 16737117, 16738135, 16739409, 16740939, 16742471, 16743746, 16745277, 16747065, 16748598, 16487987, 16162097, 15901743, 15575598, 15184174, 14858031, 14466608, 14140466, 13748788, 13422648, 13030972, 12704833, 12378438, 12052044, 11791187, 11530331]),
  cool: r8("Cool", "sequential", "Cool, sequential color scheme from D3.js", [7225514, 7095217, 6899639, 6769597, 6574275, 6313160, 6117837, 5856977, 5596117, 5335513, 5009115, 4748510, 4422368, 4161761, 3835361, 3575009, 3314401, 3053791, 2793438, 2598363, 2337752, 2208213, 2013137, 1883340, 1819335, 1755074, 1691068, 1692086, 1758640, 1825706, 1957795, 2155164, 2352790, 2615695, 2878601, 3207042, 3600764, 3994230, 4453489, 4912492, 5437031, 5961315, 6551391, 7140956, 7730778, 8386136, 8975703, 9630807, 10285911, 10940761, 11530331]),
  "cubehelix-default": r8("CubehelixDefault", "sequential", "CubehelixDefault, sequential color scheme from D3.js", [0, 525064, 984594, 1313308, 1576742, 1709360, 1776697, 1712705, 1649479, 1520715, 1457486, 1394254, 1396557, 1529674, 1662534, 2057794, 2518076, 3109175, 3765555, 4618288, 5536047, 6519343, 7568178, 8550967, 9599551, 10516809, 11368789, 12155235, 12745329, 13270146, 13663891, 13861539, 13928371, 13929921, 13800654, 13606106, 13411811, 13217514, 12957935, 12829170, 12700403, 12768243, 12835826, 13099761, 13428976, 13823727, 14349039, 14939888, 15530483, 16186616, 16777215]),
  rainbow: r8("Rainbow", "cyclical", "Rainbow, cyclical color scheme from D3.js", [7225514, 8208303, 9322162, 10370483, 11484338, 12532911, 13581737, 14434210, 15352473, 16074382, 16665475, 16732790, 16734826, 16737117, 16739409, 16742471, 16745277, 16748598, 16162097, 15575598, 14858031, 14140466, 13422648, 12704833, 12052044, 11530331, 10285911, 8975703, 7730777, 6485855, 5437031, 4453489, 3600764, 2878601, 2352790, 1957795, 1758896, 1691068, 1819335, 2013137, 2337752, 2793438, 3314401, 3835617, 4422368, 5009115, 5596117, 6117837, 6574275, 6899639, 7225514]),
  sinebow: r8("Sinebow", "cyclical", "Sinebow, cyclical color scheme from D3.js", [16728128, 16666162, 16473382, 16149788, 15695122, 15174923, 14458117, 13740802, 12892928, 11978752, 10999043, 9953287, 8972813, 7860757, 6879262, 5831722, 4849463, 3931972, 3079507, 2357858, 1635442, 1109378, 648082, 317858, 118193, 49087, 111053, 303833, 561890, 1081837, 1602292, 2319098, 3036157, 3884287, 4798463, 5778172, 6823928, 7804402, 8916458, 9897952, 10945493, 11927752, 12845243, 13697708, 14419357, 15141773, 15667837, 16129133, 16459357, 16659022, 16728128]),
  "category-10": r8("Category10", "qualitative", "Category10, categorical color scheme from D3.js / tab10 from Matplotlib (default in Matplotlib)", [2062260, 16744206, 2924588, 14034728, 9725885, 9197131, 14907330, 8355711, 12369186, 1556175]),
  "observable-10": r8("Observable10", "qualitative", "Observable10, categorical color scheme from D3.js", [4352464, 15708440, 16740956, 7128496, 3975505, 16747191, 10773490, 9944053, 10251086, 9738400]),
  "tableau-10": r8("Tableau10", "qualitative", "Tableau10, categorical color scheme from D3.js", [5142951, 15896108, 14767961, 7780274, 5873999, 15583561, 11500193, 16752039, 10253663, 12234923]),
  "simple-rainbow": r8("Simple rainbow", "sequential", "Simple 5-color rainbow (blue-green-yellow-orange-red)", [3367393, 3516485, 16383744, 15501073, 12526114]),
  "red-white-blue": r8("Red-White-Blue", "diverging", "Diverging color scheme with red-white-blue", [12526114, 16777215, 3367393]),
  "many-distinct": r8("Many-Distinct", "qualitative", "Customized color scheme combining colors from multiple standard schemes (Dark2, Set1, Set2)", [
    1810039,
    14245634,
    7696563,
    15149450,
    6727198,
    15117058,
    10909213,
    6710886,
    14948892,
    3636920,
    5091146,
    9981603,
    16744192,
    16777011,
    10901032,
    16220607,
    10066329,
    6734501,
    16551266,
    9281739,
    15174339,
    10934356,
    16767279,
    15058068,
    11776947
  ])
}, Ra0 = Object.keys(g7), jS = Ra0.map((Z) => [Z, g7[Z].label, TN(g7[Z].type), g7[Z].description]), o50 = jS.filter((Z) => g7[Z[0]].type === "sequential" || g7[Z[0]].type === "diverging" || g7[Z[0]].type === "cyclical"), s50 = jS.filter((Z) => g7[Z[0]].type === "qualitative");
function RJ(Z) {
  if (Z in g7)
    return g7[Z];
  return console.warn(`unknown color list named '${Z}'`), g7["red-yellow-blue"];
}

// node_modules/molstar/lib/mol-io/common/string-like.js
var oL = {
  is(Z) {
    return typeof Z.charCodeAt === "function";
  },
  toString(Z) {
    try {
      return Z.toString();
    } catch (J) {
      throw new Error(`Failed to convert StringLike object into string. This might be because the length ${Z.length} exceeds maximum allowed string length ${nO}. (${J})`);
    }
  }
}, nO = 536870888, TS = 28;

class MM {
  get length() {
    return this._length;
  }
  constructor(Z = TS) {
    this._chunks = [], this._length = 0, this._tmpArray = [], this.STRING_CHUNK_SIZE = 2 ** Z, this.STRING_CHUNK_SHIFT = Z, this.STRING_CHUNK_MASK = 2 ** Z - 1;
  }
  static fromString(Z, J = TS) {
    let $ = new MM(J);
    return $._append(Z), $;
  }
  static fromStrings(Z, J = TS) {
    let $ = new MM(J);
    for (let X of Z)
      $._append(X);
    return $;
  }
  static fromUtf8Data(Z, J = 0, $ = Z.length, X = TS) {
    let Y = 2 ** X, Q = [], W = J;
    while (W < $) {
      let K = Math.min(W + Y, $);
      if (K < $) {
        while ((Z[K] & 192) === 128)
          if (K--, K === W)
            throw new Error("Input is rubbish, no UTF-8 character start found in a chunk");
      }
      let G = IN(Z, W, K - W);
      Q.push(G), W = K;
    }
    return MM.fromStrings(Q, X);
  }
  _append(Z) {
    let J = this.STRING_CHUNK_SIZE, $ = this._chunks.length === 0 || this._chunks[this._chunks.length - 1].length === J ? "" : this._chunks.pop(), X = J - $.length;
    this._chunks.push($ + Z.substring(0, X));
    while (X < Z.length)
      this._chunks.push(Z.substring(X, X + J)), X += J;
    this._length += Z.length;
  }
  _getChunkIndex(Z) {
    return Z >>> this.STRING_CHUNK_SHIFT;
  }
  _getIndexInChunk(Z) {
    return Z & this.STRING_CHUNK_MASK;
  }
  _isOutOfRange(Z) {
    return Z < 0 || Z >= this.length;
  }
  at(Z) {
    if (-this.length <= Z && Z < 0)
      return this.at(Z + this.length);
    return this.charAt(Z) || void 0;
  }
  charAt(Z) {
    if (this._isOutOfRange(Z))
      return "";
    let J = this._getChunkIndex(Z), $ = this._getIndexInChunk(Z);
    return this._chunks[J][$];
  }
  charCodeAt(Z) {
    if (this._isOutOfRange(Z))
      return NaN;
    let J = this._getChunkIndex(Z), $ = this._getIndexInChunk(Z);
    return this._chunks[J].charCodeAt($);
  }
  substring(Z, J) {
    let $ = Math.min(Math.max(Z !== null && Z !== void 0 ? Z : 0, 0), this.length), X = Math.min(Math.max(J !== null && J !== void 0 ? J : this.length, 0), this.length);
    if ($ > X)
      return this.substring(X, $);
    if ($ === X)
      return "";
    if (X - $ > nO)
      throw new Error(`Trying to create get a substring longer (${X - $}) than maximum allowed string length (${nO}).`);
    let Y = this._getChunkIndex($), Q = this._getIndexInChunk($), W = this._getChunkIndex(X), K = this._getIndexInChunk(X);
    if (Y === W)
      return this._chunks[Y].substring(Q, K);
    else {
      let G = this._getTmpArray();
      G.push(this._chunks[Y].substring(Q, this.STRING_CHUNK_SIZE));
      for (let H = Y + 1;H < W; H++)
        G.push(this._chunks[H]);
      return G.push(this._chunks[W].substring(0, K)), G.join("");
    }
  }
  _getTmpArray() {
    while (this._tmpArray.length)
      this._tmpArray.pop();
    return this._tmpArray;
  }
  indexOf(Z, J = 0) {
    if (Z.length > this.STRING_CHUNK_SIZE)
      throw new Error("NotImplementedError: indexOf is only implemented for searchString shorter than STRING_CHUNK_SIZE");
    if (J < 0)
      J = 0;
    let $ = this._getChunkIndex(J);
    for (let X = $;X < this._chunks.length; X++) {
      let Y = this._chunks[X], Q = X === $ ? this._getIndexInChunk(J) : 0, W = Y.indexOf(Z, Q);
      if (W >= 0)
        return X * this.STRING_CHUNK_SIZE + W;
      if (X !== this._chunks.length - 1) {
        let K = Math.max(this.STRING_CHUNK_SIZE - Z.length + 1, Q), H = (Y.substring(K, void 0) + this._chunks[X + 1].substring(0, Z.length - 1)).indexOf(Z);
        if (H >= 0)
          return X * this.STRING_CHUNK_SIZE + K + H;
      }
    }
    return -1;
  }
  includes(Z, J = 0) {
    return this.indexOf(Z, J) >= 0;
  }
  startsWith(Z, J = 0) {
    if (Z.length > this.STRING_CHUNK_SIZE)
      throw new Error("NotImplementedError: startsWith is only implemented for searchString shorter than STRING_CHUNK_SIZE");
    return this.substring(J, J + Z.length) === Z;
  }
  toString() {
    try {
      return this._chunks.join("");
    } catch (Z) {
      throw new Error(`Failed to convert StringLike object into string. This might be because the length ${this.length} exceeds maximum allowed string length ${nO}. (${Z})`);
    }
  }
}

// node_modules/molstar/lib/mol-io/common/utf8.js
function sL(Z, J, $) {
  for (let X = 0, Y = $.length;X < Y; X++) {
    let Q = $.charCodeAt(X);
    if (Q < 128) {
      Z[J++] = Q >>> 0 & 127 | 0;
      continue;
    }
    if (Q < 2048) {
      Z[J++] = Q >>> 6 & 31 | 192, Z[J++] = Q >>> 0 & 63 | 128;
      continue;
    }
    if (Q < 65536) {
      Z[J++] = Q >>> 12 & 15 | 224, Z[J++] = Q >>> 6 & 63 | 128, Z[J++] = Q >>> 0 & 63 | 128;
      continue;
    }
    if (Q < 1114112) {
      Z[J++] = Q >>> 18 & 7 | 240, Z[J++] = Q >>> 12 & 63 | 128, Z[J++] = Q >>> 6 & 63 | 128, Z[J++] = Q >>> 0 & 63 | 128;
      continue;
    }
    throw new Error("bad codepoint " + Q);
  }
}
var Ea0 = function() {
  let Z = [];
  for (let J = 0;J < 1024; J++)
    Z[J] = String.fromCharCode(J);
  return Z;
}();
function r50(Z) {
  throw new Error(Z);
}
function Oa0(Z, J, $) {
  let X = Ea0, Y = void 0, Q = 0, W = [], K = 512;
  for (let G = J, H = J + $;G < H; G++) {
    let N = Z[G];
    if ((N & 128) === 0)
      W[Q++] = X[N];
    else if ((N & 224) === 192)
      W[Q++] = X[(N & 15) << 6 | Z[++G] & 63];
    else if ((N & 240) === 224)
      W[Q++] = String.fromCharCode((N & 15) << 12 | (Z[++G] & 63) << 6 | (Z[++G] & 63) << 0);
    else if ((N & 248) === 240)
      W[Q++] = String.fromCharCode((N & 7) << 18 | (Z[++G] & 63) << 12 | (Z[++G] & 63) << 6 | (Z[++G] & 63) << 0);
    else
      r50("Invalid byte " + N.toString(16));
    if (Q === K)
      Y = Y || [], Y[Y.length] = W.join(""), Q = 0;
  }
  if (!Y)
    return W.slice(0, Q).join("");
  if (Q > 0)
    Y[Y.length] = W.slice(0, Q).join("");
  return Y.join("");
}
var a50 = typeof TextDecoder !== "undefined" ? /* @__PURE__ */ new TextDecoder : void 0;
function IN(Z, J = 0, $ = Z.length) {
  if (a50) {
    let X = J || $ !== Z.length ? Z.subarray(J, J + $) : Z;
    return a50.decode(X);
  } else
    return Oa0(Z, J, $);
}
function _S(Z, J = 0, $ = Z.length) {
  if ($ <= nO)
    return IN(Z, J, $);
  let X = MM.fromUtf8Data(Z, J, J + $);
  return X.length <= nO ? X.toString() : X;
}
function AM(Z) {
  let J = 0;
  for (let $ = 0, X = Z.length;$ < X; $++) {
    let Y = Z.charCodeAt($);
    if (Y < 128) {
      J += 1;
      continue;
    }
    if (Y < 2048) {
      J += 2;
      continue;
    }
    if (Y < 65536) {
      J += 3;
      continue;
    }
    if (Y < 1114112) {
      J += 4;
      continue;
    }
    r50("bad codepoint " + Y);
  }
  return J;
}

// node_modules/molstar/lib/mol-task/util/scheduler.js
function za0() {
  let Z = function() {
    let R = typeof window !== "undefined" && window, z = typeof self !== "undefined" && typeof WorkerGlobalScope !== "undefined" && self instanceof WorkerGlobalScope && self;
    return R || typeof global !== "undefined" && global || z;
  }(), J = {}, $ = typeof document !== "undefined" ? document : void 0, X = 1, Y;
  function Q(R, ...z) {
    if (typeof R !== "function")
      R = new Function("" + R);
    let D = { callback: R, args: z };
    return J[X] = D, Y(X), X++;
  }
  function W(R) {
    delete J[R];
  }
  function K(R) {
    let { callback: z, args: D } = R;
    switch (D.length) {
      case 0:
        z();
        break;
      case 1:
        z(D[0]);
        break;
      case 2:
        z(D[0], D[1]);
        break;
      case 3:
        z(D[0], D[1], D[2]);
        break;
      default:
        z.apply(void 0, D);
        break;
    }
  }
  function G(R) {
    let z = J[R];
    W(R), K(z);
  }
  function H() {
    Y = function(R) {
      process.nextTick(function() {
        G(R);
      });
    };
  }
  function N() {
    if (Z && Z.postMessage && !Z.importScripts) {
      let R = !0, z = Z.onmessage;
      return Z.onmessage = function() {
        R = !1;
      }, Z.postMessage("", "*"), Z.onmessage = z, R;
    }
  }
  function q() {
    let R = "setImmediate$" + Math.random() + "$", z = function(D) {
      if (D.source === Z && typeof D.data === "string" && D.data.indexOf(R) === 0)
        G(+D.data.slice(R.length));
    };
    if (window.addEventListener)
      window.addEventListener("message", z, !1);
    else
      window.attachEvent("onmessage", z);
    Y = function(D) {
      window.postMessage(R + D, "*");
    };
  }
  function U() {
    let R = new MessageChannel;
    R.port1.onmessage = function(z) {
      let D = z.data;
      G(D);
    }, Y = function(z) {
      R.port2.postMessage(z);
    };
  }
  function F() {
    let R = $.documentElement;
    Y = function(z) {
      let D = $.createElement("script");
      D.onreadystatechange = function() {
        G(z), D.onreadystatechange = null, R.removeChild(D), D = null;
      }, R.appendChild(D);
    };
  }
  function E() {
    Y = function(R) {
      setTimeout(G, 0, R);
    };
  }
  if (typeof process !== "undefined" && {}.toString.call(process) === "[object process]")
    H();
  else if (N())
    q();
  else if (typeof MessageChannel !== "undefined")
    U();
  else if ($ && "onreadystatechange" in $.createElement("script"))
    F();
  else
    E();
  return {
    setImmediate: Q,
    clearImmediate: W
  };
}
var Yi = function() {
  if (typeof setImmediate !== "undefined")
    if (typeof window !== "undefined")
      return {
        setImmediate: (Z, ...J) => window.setImmediate(Z, ...J),
        clearImmediate: (Z) => window.clearImmediate(Z)
      };
    else
      return { setImmediate, clearImmediate };
  return za0();
}();
function Da0(Z) {
  Yi.setImmediate(Z);
}
var rG = {
  setImmediate: Yi.setImmediate,
  clearImmediate: Yi.clearImmediate,
  immediatePromise() {
    return new Promise(Da0);
  },
  delay(Z, J = void 0) {
    return new Promise(($) => setTimeout($, Z, J));
  }
};

// node_modules/molstar/lib/mol-util/debug.js
var aL = function() {
  try {
    return !1;
  } catch (Z) {
    return !1;
  }
}(), y2 = function Z() {
  try {
    let J = process.env.DEBUG;
    return J === "*" || J === "molstar";
  } catch (J) {
    return !1;
  }
}(), K1 = !1;
var VS = [];
function t50(Z) {
  if (!VS.includes(Z))
    VS.push(Z);
}
function e50(Z) {
  let J = VS.indexOf(Z);
  if (J !== -1)
    VS.splice(J, 1);
}

// node_modules/molstar/lib/mol-task/util/user-timing.js
var Ma0 = typeof performance !== "undefined" && !!performance.mark && performance.measure, Qi = Ma0 && K1, BM;
(function(Z) {
  function J(W) {
    return `startTask${W.id}`;
  }
  function $(W) {
    return `endTask${W.id}`;
  }
  function X(W) {
    if (Qi)
      performance.mark(J(W));
  }
  Z.markStart = X;
  function Y(W) {
    if (Qi)
      performance.mark($(W));
  }
  Z.markEnd = Y;
  function Q(W) {
    if (Qi)
      performance.measure(`✳️ ${W.name}`, J(W), $(W));
  }
  Z.measure = Q;
})(BM || (BM = {}));

// node_modules/molstar/lib/mol-task/execution/observable.js
function ZK0(Z, J, $ = 250) {
  let X = YK0(Z, J, $), Y = new PS(X, X.root);
  return Wi(Z, Y);
}
function JK0(Z, J, $ = 250) {
  let X = YK0(Z, J, $);
  return new PS(X, X.root);
}
function IS(Z, J) {
  return Wi(J, Z);
}
function $K0(Z, J, $) {
  return Z.runChild(J, $);
}
function XK0(Z) {
  return {
    taskId: Z.id,
    taskName: Z.name,
    message: "",
    startedTime: 0,
    canAbort: !0,
    isIndeterminate: !0,
    current: 0,
    max: 0
  };
}
function YK0(Z, J, $) {
  let X = { abortRequested: !1, treeAborted: !1, reason: "" };
  return {
    updateRateMs: $,
    lastNotified: m6(),
    observer: J,
    abortToken: X,
    taskId: Z.id,
    root: { progress: XK0(Z), children: [] },
    tryAbort: Aa0(X)
  };
}
function Aa0(Z) {
  return (J) => {
    Z.abortRequested = !0, Z.reason = J || Z.reason;
  };
}
function QK0(Z) {
  return { progress: { ...Z.progress }, children: Z.children.map(QK0) };
}
function WK0(Z) {
  return Z.progress.canAbort && Z.children.every(WK0);
}
function Ba0(Z) {
  return { root: QK0(Z.root), canAbort: WK0(Z.root), requestAbort: Z.tryAbort };
}
async function Wi(Z, J) {
  BM.markStart(Z), J.node.progress.startedTime = m6();
  try {
    let $ = await Z.f(J);
    if (BM.markEnd(Z), BM.measure(Z), J.info.abortToken.abortRequested)
      KK0(J.info);
    return $;
  } catch ($) {
    if (n0.isAbort($)) {
      if (J.isAborted = !0, J.node.children.length > 0)
        await new Promise((X) => {
          J.onChildrenFinished = X;
        });
      if (Z.onAbort)
        Z.onAbort();
    }
    throw $;
  }
}
function KK0(Z) {
  if (!Z.abortToken.treeAborted)
    Z.abortToken.treeAborted = !0, GK0(Z.root), HK0(Z, m6());
  throw n0.Aborted(Z.abortToken.reason);
}
function GK0(Z) {
  let J = Z.progress;
  J.isIndeterminate = !0, J.canAbort = !1, J.message = "Aborting...";
  for (let $ of Z.children)
    GK0($);
}
function HK0(Z, J) {
  Z.lastNotified = J;
  let $ = Ba0(Z);
  Z.observer($);
}

class PS {
  checkAborted() {
    if (this.info.abortToken.abortRequested)
      this.isAborted = !0, KK0(this.info);
  }
  get shouldUpdate() {
    return this.checkAborted(), m6() - this.lastUpdatedTime > this.info.updateRateMs;
  }
  updateProgress(Z) {
    if (this.checkAborted(), !Z)
      return;
    let J = this.node.progress;
    if (typeof Z === "string")
      J.message = Z, J.isIndeterminate = !0;
    else {
      if (typeof Z.canAbort !== "undefined")
        J.canAbort = Z.canAbort;
      if (typeof Z.message !== "undefined")
        J.message = Z.message;
      if (typeof Z.current !== "undefined")
        J.current = Z.current;
      if (typeof Z.max !== "undefined")
        J.max = Z.max;
      if (J.isIndeterminate = typeof J.current === "undefined" || typeof J.max === "undefined", typeof Z.isIndeterminate !== "undefined")
        J.isIndeterminate = Z.isIndeterminate;
    }
  }
  update(Z, J) {
    if (this.lastUpdatedTime = m6(), this.updateProgress(Z), J)
      return;
    return HK0(this.info, this.lastUpdatedTime), this.checkAborted(), rG.immediatePromise();
  }
  async runChild(Z, J) {
    this.updateProgress(J);
    let $ = { progress: XK0(Z), children: [] }, X = this.node.children;
    X.push($);
    let Y = new PS(this.info, $);
    try {
      return await Wi(Z, Y);
    } catch (Q) {
      if (n0.isAbort(Q)) {
        if (this.isAborted)
          return;
      }
      throw Q;
    } finally {
      let Q = X.indexOf($);
      if (Q >= 0) {
        for (let W = Q, K = X.length - 1;W < K; W++)
          X[W] = X[W + 1];
        X.pop();
      }
      if (X.length === 0 && this.onChildrenFinished)
        this.onChildrenFinished();
    }
  }
  constructor(Z, J) {
    this.isSynchronous = !1, this.isExecuting = !0, this.lastUpdatedTime = 0, this.onChildrenFinished = void 0, this.node = J, this.info = Z;
  }
}

// node_modules/molstar/lib/mol-task/execution/synchronous.js
class NK0 {
  constructor() {
    this.shouldUpdate = !1, this.isSynchronous = !0;
  }
  update(Z, J) {}
}
var wM = new NK0;

// node_modules/molstar/lib/mol-task/task.js
var n0;
(function(Z) {

  class J {
    run(q, U = 250) {
      if (q)
        return ZK0(this, q, U);
      return this.f(wM);
    }
    runAsChild(q, U) {
      if (q.isSynchronous)
        return this.f(wM);
      return $K0(q, this, U);
    }
    runInContext(q) {
      if (q.isSynchronous)
        return this.f(wM);
      return IS(q, this);
    }
    constructor(q, U, F) {
      this.name = q, this.f = U, this.onAbort = F, this.id = N();
    }
  }
  function $(q) {
    let U = q;
    return !!q && typeof U.id === "number" && typeof U.name === "string" && !!U.run;
  }
  Z.is = $;
  function X(q) {
    return !!q && !!q.isAborted;
  }
  Z.isAbort = X;
  function Y(q) {
    return { isAborted: !0, reason: q, toString() {
      return `Aborted${q ? ": " + q : ""}`;
    } };
  }
  Z.Aborted = Y;
  function Q(q, U, F) {
    return new J(q, U, F);
  }
  Z.create = Q;
  function W(q, U) {
    return Q(q, async (F) => U);
  }
  Z.constant = W;
  function K() {
    return Q("", async (q) => {});
  }
  Z.empty = K;
  function G(q, U) {
    return Q(q, async (F) => {
      throw new Error(U);
    });
  }
  Z.fail = G;
  function H(q, U) {
    if ($(q))
      return U ? q.runInContext(U) : q.run();
    return q;
  }
  Z.resolveInContext = H;
  let N = $7(0, 1073741823);
})(n0 || (n0 = {}));

// node_modules/molstar/lib/mol-task/execution/runtime-context.js
var Ki;
(function(Z) {
  Z.Synchronous = wM;
})(Ki || (Ki = {}));

// node_modules/molstar/lib/mol-task/execution/progress.js
var Gi;
(function(Z) {
  function J(X, Y = "") {
    let Q = X.progress;
    if (!X.children.length) {
      if (Q.isIndeterminate)
        return `${Y}${Q.taskName}: ${Q.message}`;
      return `${Y}${Q.taskName}: [${Q.current}/${Q.max}] ${Q.message}`;
    }
    let W = Y + "  |_ ", K = X.children.map((G) => J(G, W));
    if (Q.isIndeterminate)
      return `${Y}${Q.taskName}: ${Q.message}
${K.join(`
`)}`;
    return `${Y}${Q.taskName}: [${Q.current}/${Q.max}] ${Q.message}
${K.join(`
`)}`;
  }
  function $(X) {
    return J(X.root);
  }
  Z.format = $;
})(Gi || (Gi = {}));

// node_modules/molstar/lib/mol-task/util/chunked.js
async function K$(Z, J, $, X, Y) {
  let Q = Math.max(J, 0), W = 0, K = 0;
  if (Z.isSynchronous)
    return X(Number.MAX_SAFE_INTEGER, $), $;
  let G = m6(), H = 0, N = 0;
  while ((H = X(Q, $)) > 0) {
    W += H;
    let q = m6() - G;
    if (N += q, K += q, Z.shouldUpdate)
      await Y(Z, $, W), Q = Math.round(N * W / K) + 1, G = m6(), N = 0;
  }
  if (Z.shouldUpdate)
    await Y(Z, $, W);
  return $;
}

// node_modules/molstar/lib/mol-util/nodejs-shims.js
var tG = typeof process !== "undefined" && process.versions != null && process.versions.node != null, Hi = wa0();
function wa0() {
  if (typeof File === "undefined" || tG) {

    class Z {
      arrayBuffer() {
        return this.blob.arrayBuffer();
      }
      slice(J, $, X) {
        return this.blob.slice(J, $, X);
      }
      stream() {
        return this.blob.stream();
      }
      text() {
        return this.blob.text();
      }
      bytes() {
        return this.blob.bytes();
      }
      constructor(J, $, X) {
        var Y;
        this.blob = new Blob(J, X), this.size = this.blob.size, this.type = this.blob.type, this.name = $, this.lastModified = (Y = X === null || X === void 0 ? void 0 : X.lastModified) !== null && Y !== void 0 ? Y : 0, this.webkitRelativePath = "";
      }
    }
    return Z;
  } else
    return File;
}

// node_modules/molstar/lib/mol-util/zip/bin.js
function qK0(Z) {
  return Z >> 0;
}
function PN(Z, J) {
  return Z[J] | Z[J + 1] << 8;
}
function rL(Z, J, $) {
  Z[J] = $ & 255, Z[J + 1] = $ >> 8 & 255;
}
function tL(Z, J) {
  return Z[J + 3] * 16777216 + (Z[J + 2] << 16 | Z[J + 1] << 8 | Z[J]);
}
function CN(Z, J, $) {
  Z[J] = $ & 255, Z[J + 1] = $ >> 8 & 255, Z[J + 2] = $ >> 16 & 255, Z[J + 3] = $ >> 24 & 255;
}
function ja0(Z, J, $) {
  let X = "";
  for (let Y = 0;Y < $; Y++)
    X += String.fromCharCode(Z[J + Y]);
  return X;
}
function Ta0(Z) {
  return Z.length < 2 ? "0" + Z : Z;
}
function FK0(Z, J, $) {
  let X = "", Y;
  for (let Q = 0;Q < $; Q++)
    X += "%" + Ta0(Z[J + Q].toString(16));
  try {
    Y = decodeURIComponent(X);
  } catch (Q) {
    return ja0(Z, J, $);
  }
  return Y;
}
function UK0(Z, J, $) {
  let X = $.length, Y = 0;
  for (let Q = 0;Q < X; Q++) {
    let W = $.charCodeAt(Q);
    if ((W & 4294967168) === 0)
      Z[J + Y] = W, Y++;
    else if ((W & 4294965248) === 0)
      Z[J + Y] = 192 | W >> 6, Z[J + Y + 1] = 128 | W >> 0 & 63, Y += 2;
    else if ((W & 4294901760) === 0)
      Z[J + Y] = 224 | W >> 12, Z[J + Y + 1] = 128 | W >> 6 & 63, Z[J + Y + 2] = 128 | W >> 0 & 63, Y += 3;
    else if ((W & 4292870144) === 0)
      Z[J + Y] = 240 | W >> 18, Z[J + Y + 1] = 128 | W >> 12 & 63, Z[J + Y + 2] = 128 | W >> 6 & 63, Z[J + Y + 3] = 128 | W >> 0 & 63, Y += 4;
    else
      throw new Error("e");
  }
  return Y;
}
function Ni(Z) {
  let J = Z.length, $ = 0;
  for (let X = 0;X < J; X++) {
    let Y = Z.charCodeAt(X);
    if ((Y & 4294967168) === 0)
      $++;
    else if ((Y & 4294965248) === 0)
      $ += 2;
    else if ((Y & 4294901760) === 0)
      $ += 3;
    else if ((Y & 4292870144) === 0)
      $ += 4;
    else
      throw new Error("e");
  }
  return $;
}

// node_modules/molstar/lib/mol-util/zip/checksum.js
var _a0 = function() {
  let Z = new Uint32Array(256);
  for (let J = 0;J < 256; J++) {
    let $ = J;
    for (let X = 0;X < 8; X++)
      if ($ & 1)
        $ = 3988292384 ^ $ >>> 1;
      else
        $ = $ >>> 1;
    Z[J] = $;
  }
  return Z;
}();
function Va0(Z, J, $, X) {
  for (let Y = 0;Y < X; Y++)
    Z = _a0[(Z ^ J[$ + Y]) & 255] ^ Z >>> 8;
  return Z;
}
function qi(Z, J, $) {
  return Va0(4294967295, Z, J, $) ^ 4294967295;
}

// node_modules/molstar/lib/mol-util/zip/util.js
var CS = {
  deflate: void 0,
  "deflate-raw": void 0,
  gzip: void 0
};
function kS(Z) {
  if (CS[Z] === void 0)
    try {
      new CompressionStream(Z), CS[Z] = !0;
    } catch (J) {
      CS[Z] = !1;
    }
  return !!CS[Z];
}
var R2 = function() {
  let Z = Uint16Array, J = Uint32Array;
  return {
    next_code: new Z(16),
    bl_count: new Z(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 Z(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 J(32),
    flmap: new Z(512),
    fltree: [],
    fdmap: new Z(32),
    fdtree: [],
    lmap: new Z(32768),
    ltree: [],
    ttree: [],
    dmap: new Z(32768),
    dtree: [],
    imap: new Z(512),
    itree: [],
    rev15: new Z(32768),
    lhst: new J(286),
    dhst: new J(30),
    ihst: new J(19),
    lits: new J(15000),
    strt: new Z(65536),
    prev: new Z(32768)
  };
}();
(function() {
  for (let $ = 0;$ < 32768; $++) {
    let X = $;
    X = (X & 2863311530) >>> 1 | (X & 1431655765) << 1, X = (X & 3435973836) >>> 2 | (X & 858993459) << 2, X = (X & 4042322160) >>> 4 | (X & 252645135) << 4, X = (X & 4278255360) >>> 8 | (X & 16711935) << 8, R2.rev15[$] = (X >>> 16 | X << 16) >>> 17;
  }
  function J($, X, Y) {
    while (X-- !== 0)
      $.push(0, Y);
  }
  for (let $ = 0;$ < 32; $++)
    R2.ldef[$] = R2.of0[$] << 3 | R2.exb[$], R2.ddef[$] = R2.df0[$] << 4 | R2.dxb[$];
  J(R2.fltree, 144, 8), J(R2.fltree, 112, 9), J(R2.fltree, 24, 7), J(R2.fltree, 8, 8), kN(R2.fltree, 9), jM(R2.fltree, 9, R2.flmap), TM(R2.fltree, 9), J(R2.fdtree, 32, 5), kN(R2.fdtree, 5), jM(R2.fdtree, 5, R2.fdmap), TM(R2.fdtree, 5), J(R2.itree, 19, 0), J(R2.ltree, 286, 0), J(R2.dtree, 30, 0), J(R2.ttree, 320, 0);
})();
function jM(Z, J, $) {
  let X = Z.length, Y = R2.rev15;
  for (let Q = 0;Q < X; Q += 2)
    if (Z[Q + 1] !== 0) {
      let W = Q >> 1, K = Z[Q + 1], G = W << 4 | K, H = J - K, N = Z[Q] << H, q = N + (1 << H);
      while (N !== q) {
        let U = Y[N] >>> 15 - J;
        $[U] = G, N++;
      }
    }
}
function kN(Z, J) {
  let $ = Z.length, X = R2.bl_count;
  for (let W = 0;W <= J; W++)
    X[W] = 0;
  for (let W = 1;W < $; W += 2)
    X[Z[W]]++;
  let Y = R2.next_code, Q = 0;
  X[0] = 0;
  for (let W = 1;W <= J; W++)
    Q = Q + X[W - 1] << 1, Y[W] = Q;
  for (let W = 0;W < $; W += 2) {
    let K = Z[W + 1];
    if (K !== 0)
      Z[W] = Y[K], Y[K]++;
  }
}
function TM(Z, J) {
  let $ = R2.rev15, X = 15 - J;
  for (let Y = 0;Y < Z.length; Y += 2) {
    let Q = Z[Y] << J - Z[Y + 1];
    Z[Y] = $[Q] >>> X;
  }
}

// node_modules/molstar/lib/mol-util/zip/inflate.js
function Ia0(Z, J) {
  let $ = J === void 0;
  if (J === void 0)
    J = new Uint8Array(Z.length >>> 2 << 3);
  return {
    data: Z,
    buf: J,
    noBuf: $,
    BFINAL: 0,
    off: 0,
    pos: 0
  };
}
function Pa0(Z, J) {
  let { data: $, noBuf: X } = Z, { buf: Y, BFINAL: Q, off: W, pos: K } = Z, G = 0;
  while (Q === 0 && G < J) {
    let H, N, q = 0, U = 0;
    Q = Ui($, K, 1), G += 1;
    let F = Ui($, K + 1, 2);
    if (K += 3, F === 0) {
      if ((K & 7) !== 0)
        K += 8 - (K & 7);
      let E = (K >>> 3) + 4, R = $[E - 4] | $[E - 3] << 8;
      if (X)
        Y = Fi(Y, W + R);
      Y.set(new Uint8Array($.buffer, $.byteOffset + E, R), W), K = E + R << 3, W += R;
      continue;
    }
    if (X)
      Y = Fi(Y, W + 131072);
    if (F === 1)
      H = R2.flmap, N = R2.fdmap, q = 511, U = 31;
    else if (F === 2) {
      let E = eL($, K, 5) + 257, R = eL($, K + 5, 5) + 1, z = eL($, K + 10, 4) + 4;
      K += 14;
      for (let T = 0;T < 38; T += 2)
        R2.itree[T] = 0, R2.itree[T + 1] = 0;
      let D = 1;
      for (let T = 0;T < z; T++) {
        let w = eL($, K + T * 3, 3);
        if (R2.itree[(R2.ordr[T] << 1) + 1] = w, w > D)
          D = w;
      }
      K += 3 * z, kN(R2.itree, D), jM(R2.itree, D, R2.imap), H = R2.lmap, N = R2.dmap, K = Ca0(R2.imap, (1 << D) - 1, E + R, $, K, R2.ttree);
      let A = LK0(R2.ttree, 0, E, R2.ltree);
      q = (1 << A) - 1;
      let B = LK0(R2.ttree, E, R, R2.dtree);
      U = (1 << B) - 1, kN(R2.ltree, A), jM(R2.ltree, A, H), kN(R2.dtree, B), jM(R2.dtree, B, N);
    } else
      throw new Error(`unknown BTYPE ${F}`);
    while (!0) {
      let E = H[Li($, K) & q];
      K += E & 15;
      let R = E >>> 4;
      if (R >>> 8 === 0)
        Y[W++] = R;
      else if (R === 256)
        break;
      else {
        let z = W + R - 254;
        if (R > 264) {
          let w = R2.ldef[R - 257];
          z = W + (w >>> 3) + eL($, K, w & 7), K += w & 7;
        }
        let D = N[Li($, K) & U];
        K += D & 15;
        let A = D >>> 4, B = R2.ddef[A], T = (B >>> 4) + Ui($, K, B & 15);
        if (K += B & 15, X)
          Y = Fi(Y, W + 131072);
        while (W < z)
          Y[W] = Y[W++ - T], Y[W] = Y[W++ - T], Y[W] = Y[W++ - T], Y[W] = Y[W++ - T];
        W = z;
      }
    }
  }
  Z.buf = Y, Z.BFINAL = Q, Z.off = W, Z.pos = K;
}
async function RK0(Z, J, $) {
  if (J[0] === 3 && J[1] === 0)
    return $ ? $ : new Uint8Array(0);
  if (kS("deflate-raw")) {
    let Y = new DecompressionStream("deflate-raw"), W = new Blob([J]).stream().pipeThrough(Y), K = 0, G = [], H = W.getReader(), N = async () => {
      let { done: q, value: U } = await H.read();
      if (q)
        return;
      if (Z.shouldUpdate)
        await Z.update({ message: "Inflating blocks...", current: K, max: $ === null || $ === void 0 ? void 0 : $.length });
      if ($)
        $.set(U, K);
      else
        G.push(U);
      return K += U.length, N();
    };
    if (await N(), !$) {
      $ = new Uint8Array(K);
      for (let q = 0, U = 0;q < G.length; q++)
        $.set(G[q], U), U += G[q].length;
    }
    return $;
  }
  let X = Ia0(J, $);
  while (X.BFINAL === 0) {
    if (Z.shouldUpdate)
      await Z.update({ message: "Inflating blocks...", current: X.pos, max: J.length });
    Pa0(X, 100);
  }
  return X.buf.length === X.off ? X.buf : X.buf.slice(0, X.off);
}
function Fi(Z, J) {
  let $ = Z.length;
  if (J <= $)
    return Z;
  let X = new Uint8Array(Math.max($ << 1, J));
  return X.set(Z, 0), X;
}
function Ca0(Z, J, $, X, Y, Q) {
  let W = 0;
  while (W < $) {
    let K = Z[Li(X, Y) & J];
    Y += K & 15;
    let G = K >>> 4;
    if (G <= 15)
      Q[W] = G, W++;
    else {
      let H = 0, N = 0;
      if (G === 16)
        N = 3 + eL(X, Y, 2), Y += 2, H = Q[W - 1];
      else if (G === 17)
        N = 3 + eL(X, Y, 3), Y += 3;
      else if (G === 18)
        N = 11 + eL(X, Y, 7), Y += 7;
      let q = W + N;
      while (W < q)
        Q[W] = H, W++;
    }
  }
  return Y;
}
function LK0(Z, J, $, X) {
  let Y = 0, Q = 0, W = X.length >>> 1;
  while (Q < $) {
    let K = Z[Q + J];
    if (X[Q << 1] = 0, X[(Q << 1) + 1] = K, K > Y)
      Y = K;
    Q++;
  }
  while (Q < W)
    X[Q << 1] = 0, X[(Q << 1) + 1] = 0, Q++;
  return Y;
}
function eL(Z, J, $) {
  return (Z[J >>> 3] | Z[(J >>> 3) + 1] << 8) >>> (J & 7) & (1 << $) - 1;
}
function Ui(Z, J, $) {
  return (Z[J >>> 3] | Z[(J >>> 3) + 1] << 8 | Z[(J >>> 3) + 2] << 16) >>> (J & 7) & (1 << $) - 1;
}
function Li(Z, J) {
  return (Z[J >>> 3] | Z[(J >>> 3) + 1] << 8 | Z[(J >>> 3) + 2] << 16) >>> (J & 7);
}

// node_modules/molstar/lib/mol-util/zip/huffman.js
function vS(Z, J, $) {
  let X = [], Y = Z.length, Q = J.length;
  for (let E = 0;E < Q; E += 2)
    J[E] = 0, J[E + 1] = 0;
  for (let E = 0;E < Y; E++)
    if (Z[E] !== 0)
      X.push({ lit: E, f: Z[E], d: void 0 });
  let W = X.length, K = X.slice(0);
  if (W === 0)
    return 0;
  if (W === 1) {
    let E = X[0].lit, R = E === 0 ? 1 : 0;
    return J[(E << 1) + 1] = 1, J[(R << 1) + 1] = 1, 1;
  }
  X.sort(function(E, R) {
    return E.f - R.f;
  });
  let G = X[0], H = X[1], N = 0, q = 1, U = 2;
  X[0] = {
    lit: -1,
    f: G.f + H.f,
    l: G,
    r: H,
    d: 0
  };
  while (q !== W - 1) {
    if (N !== q && (U === W || X[N].f < X[U].f))
      G = X[N++];
    else
      G = X[U++];
    if (N !== q && (U === W || X[N].f < X[U].f))
      H = X[N++];
    else
      H = X[U++];
    X[q++] = {
      lit: -1,
      f: G.f + H.f,
      l: G,
      r: H,
      d: void 0
    };
  }
  let F = Ri(X[q - 1], 0);
  if (F > $)
    ka0(K, $, F), F = $;
  for (let E = 0;E < W; E++)
    J[(K[E].lit << 1) + 1] = K[E].d;
  return F;
}
function Ri(Z, J) {
  if (Z.lit !== -1)
    return Z.d = J, J;
  return Math.max(Ri(Z.l, J + 1), Ri(Z.r, J + 1));
}
function ka0(Z, J, $) {
  let X = 0, Y = 0, Q = 1 << $ - J;
  Z.sort(function(W, K) {
    return K.d === W.d ? W.f - K.f : K.d - W.d;
  });
  for (X = 0;X < Z.length; X++)
    if (Z[X].d > J) {
      let W = Z[X].d;
      Z[X].d = J, Y += Q - (1 << $ - W);
    } else
      break;
  Y = Y >>> $ - J;
  while (Y > 0) {
    let W = Z[X].d;
    if (W < J)
      Z[X].d++, Y -= 1 << J - W - 1;
    else
      X++;
  }
  for (;X >= 0; X--)
    if (Z[X].d === J && Y < 0)
      Z[X].d--, Y++;
  if (Y !== 0)
    console.log("debt left");
}

// node_modules/molstar/lib/mol-util/zip/deflate.js
function va0(Z, J, $, X) {
  let { lits: Y, strt: Q, prev: W } = R2;
  return {
    data: Z,
    out: J,
    opt: fa0[X],
    i: 0,
    pos: $ << 3,
    cvrd: 0,
    dlen: Z.length,
    li: 0,
    lc: 0,
    bs: 0,
    ebits: 0,
    c: 0,
    nc: 0,
    lits: Y,
    strt: Q,
    prev: W
  };
}
function Sa0(Z, J) {
  let { data: $, dlen: X, out: Y, opt: Q } = Z, { i: W, pos: K, cvrd: G, li: H, lc: N, bs: q, ebits: U, c: F, nc: E } = Z, { lits: R, strt: z, prev: D } = R2, A = Math.min(W + J, X);
  for (;W < A; W++) {
    if (F = E, W + 1 < X - 2) {
      E = Ei($, W + 1);
      let B = W + 1 & 32767;
      D[B] = z[E], z[E] = B;
    }
    if (G <= W) {
      if ((H > 14000 || N > 26697) && X - W > 100) {
        if (G < W)
          R[H] = W - G, H += 2, G = W;
        K = MK0(W === X - 1 || G === X ? 1 : 0, R, H, U, $, q, W - q, Y, K), H = N = U = 0, q = W;
      }
      let B = 0;
      if (W < X - 2)
        B = ha0($, W, D, F, Math.min(Q[2], X - W), Q[3]);
      if (B !== 0) {
        let T = B >>> 16, w = B & 65535, V = zK0(T, R2.of0);
        R2.lhst[257 + V]++;
        let P = zK0(w, R2.df0);
        R2.dhst[P]++, U += R2.exb[V] + R2.dxb[P], R[H] = T << 23 | W - G, R[H + 1] = w << 16 | V << 8 | P, H += 2, G = W + T;
      } else
        R2.lhst[$[W]]++;
      N++;
    }
  }
  Z.i = W, Z.pos = K, Z.cvrd = G, Z.li = H, Z.lc = N, Z.bs = q, Z.ebits = U, Z.c = F, Z.nc = E;
}
var fa0 = [
  [0, 0, 0, 0, 0],
  [4, 4, 8, 4, 0],
  [4, 5, 16, 8, 0],
  [4, 6, 16, 16, 0],
  [4, 10, 16, 32, 0],
  [8, 16, 32, 32, 0],
  [8, 16, 128, 128, 0],
  [8, 32, 128, 256, 0],
  [32, 128, 258, 1024, 1],
  [32, 258, 258, 4096, 1]
];
async function DK0(Z, J, $, X, Y) {
  if (kS("deflate-raw")) {
    let E = new CompressionStream("deflate-raw"), D = new Blob([J]).stream().pipeThrough(E).getReader(), A = X, B = async () => {
      let { done: T, value: w } = await D.read();
      if (T)
        return;
      if (Z.shouldUpdate)
        await Z.update({ message: "Deflating...", current: A, max: $.length });
      return $.set(w, A), A += w.length, B();
    };
    return await B(), A;
  }
  let Q = va0(J, $, X, Y), { dlen: W } = Q;
  if (Y === 0) {
    let { i: E, pos: R } = Q;
    while (E < W) {
      let z = Math.min(65535, W - E);
      iO($, R, E + z === W ? 1 : 0), R = AK0(J, E, z, $, R + 8), E += z;
    }
    return R >>> 3;
  }
  if (W > 2)
    Q.nc = Ei(J, 0), Q.strt[Q.nc] = 0;
  while (Q.i < W) {
    if (Z.shouldUpdate)
      await Z.update({ message: "Deflating...", current: Q.i, max: W });
    Sa0(Q, 1048576);
  }
  let { li: K, cvrd: G, pos: H } = Q, { i: N, lits: q, bs: U, ebits: F } = Q;
  if (U !== N || J.length === 0) {
    if (G < N)
      q[K] = N - G, K += 2, G = N;
    H = MK0(1, q, K, F, J, U, N - U, $, H);
  }
  while ((H & 7) !== 0)
    H++;
  return H >>> 3;
}
function ha0(Z, J, $, X, Y, Q) {
  let W = J & 32767, K = $[W], G = W - K + 32768 & 32767;
  if (K === W || X !== Ei(Z, J - G))
    return 0;
  let H = 0, N = 0, q = Math.min(32767, J);
  while (G <= q && --Q !== 0 && K !== W) {
    if (H === 0 || Z[J + H] === Z[J + H - G]) {
      let U = ba0(Z, J, G);
      if (U > H) {
        if (H = U, N = G, H >= Y)
          break;
        if (G + 2 < U)
          U = G + 2;
        let F = 0;
        for (let E = 0;E < U - 2; E++) {
          let R = J - G + E + 32768 & 32767, z = $[R], D = R - z + 32768 & 32767;
          if (D > F)
            F = D, K = R;
        }
      }
    }
    W = K, K = $[W], G += W - K + 32768 & 32767;
  }
  return H << 16 | N;
}
function ba0(Z, J, $) {
  if (Z[J] !== Z[J - $] || Z[J + 1] !== Z[J + 1 - $] || Z[J + 2] !== Z[J + 2 - $])
    return 0;
  let X = J, Y = Math.min(Z.length, J + 258);
  J += 3;
  while (J < Y && Z[J] === Z[J - $])
    J++;
  return J - X;
}
function Ei(Z, J) {
  return (Z[J] << 8 | Z[J + 1]) + (Z[J + 2] << 4) & 65535;
}
function MK0(Z, J, $, X, Y, Q, W, K, G) {
  R2.lhst[256]++;
  let [H, N, q, U, F, E, R, z] = xa0(), D = ((G + 3 & 7) === 0 ? 0 : 8 - (G + 3 & 7)) + 32 + (W << 3), A = X + U_(R2.fltree, R2.lhst) + U_(R2.fdtree, R2.dhst), B = X + U_(R2.ltree, R2.lhst) + U_(R2.dtree, R2.dhst);
  B += 14 + 3 * E + U_(R2.itree, R2.ihst) + (R2.ihst[16] * 2 + R2.ihst[17] * 3 + R2.ihst[18] * 7);
  for (let w = 0;w < 286; w++)
    R2.lhst[w] = 0;
  for (let w = 0;w < 30; w++)
    R2.dhst[w] = 0;
  for (let w = 0;w < 19; w++)
    R2.ihst[w] = 0;
  let T = D < A && D < B ? 0 : A < B ? 1 : 2;
  if (SS(K, G, Z), SS(K, G + 1, T), G += 3, T === 0) {
    while ((G & 7) !== 0)
      G++;
    G = AK0(Y, Q, W, K, G);
  } else {
    let w, V;
    if (T === 1)
      w = R2.fltree, V = R2.fdtree;
    else if (T === 2) {
      kN(R2.ltree, H), TM(R2.ltree, H), kN(R2.dtree, N), TM(R2.dtree, N), kN(R2.itree, q), TM(R2.itree, q), w = R2.ltree, V = R2.dtree, iO(K, G, U - 257), G += 5, iO(K, G, F - 1), G += 5, iO(K, G, E - 4), G += 4;
      for (let I = 0;I < E; I++)
        iO(K, G + I * 3, R2.itree[(R2.ordr[I] << 1) + 1]);
      G += 3 * E, G = EK0(R, R2.itree, K, G), G = EK0(z, R2.itree, K, G);
    } else
      T8(T);
    let P = Q;
    for (let I = 0;I < $; I += 2) {
      let S = J[I], f = S >>> 23, v = P + (S & 8388607);
      while (P < v)
        G = L_(Y[P++], w, K, G);
      if (f !== 0) {
        let h = J[I + 1], x = h >> 16, b = h >> 8 & 255, g = h & 255;
        G = L_(257 + b, w, K, G), iO(K, G, f - R2.of0[b]), G += R2.exb[b], G = L_(g, V, K, G), SS(K, G, x - R2.df0[g]), G += R2.dxb[g], P += f;
      }
    }
    G = L_(256, w, K, G);
  }
  return G;
}
function AK0(Z, J, $, X, Y) {
  let Q = Y >>> 3;
  return X[Q] = $, X[Q + 1] = $ >>> 8, X[Q + 2] = 255 - X[Q], X[Q + 3] = 255 - X[Q + 1], Q += 4, X.set(new Uint8Array(Z.buffer, J, $), Q), Y + ($ + 4 << 3);
}
function xa0() {
  let Z = vS(R2.lhst, R2.ltree, 15), J = vS(R2.dhst, R2.dtree, 15), $ = [], X = OK0(R2.ltree, $), Y = [], Q = OK0(R2.dtree, Y);
  for (let G = 0;G < $.length; G += 2)
    R2.ihst[$[G]]++;
  for (let G = 0;G < Y.length; G += 2)
    R2.ihst[Y[G]]++;
  let W = vS(R2.ihst, R2.itree, 7), K = 19;
  while (K > 4 && R2.itree[(R2.ordr[K - 1] << 1) + 1] === 0)
    K--;
  return [Z, J, W, X, Q, K, $, Y];
}
function U_(Z, J) {
  let $ = 0;
  for (let X = 0;X < J.length; X++)
    $ += J[X] * Z[(X << 1) + 1];
  return $;
}
function EK0(Z, J, $, X) {
  for (let Y = 0;Y < Z.length; Y += 2) {
    let Q = Z[Y], W = Z[Y + 1];
    X = L_(Q, J, $, X);
    let K = Q === 16 ? 2 : Q === 17 ? 3 : 7;
    if (Q > 15)
      iO($, X, W), X += K;
  }
  return X;
}
function OK0(Z, J) {
  let $ = Z.length;
  while ($ !== 2 && Z[$ - 1] === 0)
    $ -= 2;
  for (let X = 0;X < $; X += 2) {
    let Y = Z[X + 1], Q = X + 3 < $ ? Z[X + 3] : -1, W = X + 5 < $ ? Z[X + 5] : -1, K = X === 0 ? -1 : Z[X - 1];
    if (Y === 0 && Q === Y && W === Y) {
      let G = X + 5;
      while (G + 2 < $ && Z[G + 2] === Y)
        G += 2;
      let H = Math.min(G + 1 - X >>> 1, 138);
      if (H < 11)
        J.push(17, H - 3);
      else
        J.push(18, H - 11);
      X += H * 2 - 2;
    } else if (Y === K && Q === Y && W === Y) {
      let G = X + 5;
      while (G + 2 < $ && Z[G + 2] === Y)
        G += 2;
      let H = Math.min(G + 1 - X >>> 1, 6);
      J.push(16, H - 3), X += H * 2 - 2;
    } else
      J.push(Y, 0);
  }
  return $ >>> 1;
}
function zK0(Z, J) {
  let $ = 0;
  if (J[$ | 16] <= Z)
    $ |= 16;
  if (J[$ | 8] <= Z)
    $ |= 8;
  if (J[$ | 4] <= Z)
    $ |= 4;
  if (J[$ | 2] <= Z)
    $ |= 2;
  if (J[$ | 1] <= Z)
    $ |= 1;
  return $;
}
function L_(Z, J, $, X) {
  return SS($, X, J[Z << 1]), X + J[(Z << 1) + 1];
}
function iO(Z, J, $) {
  $ = $ << (J & 7);
  let X = J >>> 3;
  Z[X] |= $, Z[X + 1] |= $ >>> 8;
}
function SS(Z, J, $) {
  $ = $ << (J & 7);
  let X = J >>> 3;
  Z[X] |= $, Z[X + 1] |= $ >>> 8, Z[X + 2] |= $ >>> 16;
}

// node_modules/molstar/lib/mol-util/zip/zip.js
async function _M(Z, J, $ = !1) {
  let X = Object.create(null), Y = new Uint8Array(J);
  if (PN(Y, 0) !== 19280)
    throw new Error('Invalid ZIP file. A valid ZIP file must start with two magic bytes \\x50\\x4b ("PK" in ASCII).');
  let Q = Y.length - 4;
  while (tL(Y, Q) !== 101010256)
    Q--;
  let W = Q;
  W += 4, W += 4;
  let K = PN(Y, W);
  W += 2, W += 2, W += 4;
  let G = tL(Y, W);
  W += 4, W = G;
  for (let H = 0;H < K; H++) {
    W += 4, W += 4, W += 4, W += 4, W += 4, W += 4, W += 4;
    let N = PN(Y, W), q = PN(Y, W + 2), U = PN(Y, W + 4);
    W += 6, W += 8;
    let F = tL(Y, W);
    W += 4, W += N + q + U, await ya0(Z, Y, F, X, $);
  }
  return X;
}
async function ya0(Z, J, $, X, Y) {
  $ += 4, $ += 2, $ += 2;
  let Q = PN(J, $);
  $ += 2, $ += 4, $ += 4;
  let W = tL(J, $);
  $ += 4;
  let K = tL(J, $);
  $ += 4;
  let G = PN(J, $);
  $ += 2;
  let H = PN(J, $);
  $ += 2;
  let N = FK0(J, $, G);
  if ($ += G, $ += H, Y) {
    X[N] = { size: K, csize: W };
    return;
  }
  let q = new Uint8Array(J.buffer, $, W);
  if (Q === 0)
    X[N] = q;
  else if (Q === 8) {
    let U = new Uint8Array(K);
    await wK0(Z, q, U), X[N] = U;
  } else
    throw new Error(`unknown compression method: ${Q}`);
}
async function wK0(Z, J, $) {
  return RK0(Z, J, $);
}
async function fS(Z, J, $) {
  let X = J[3], Y = 10;
  if (X & 4) {
    let N = PN(J, Y);
    Y += N;
  }
  if (X & 8) {
    let N = Y;
    while (J[N] !== 0)
      ++N;
    Y = N + 1;
  }
  if (X & 16) {
    let N = Y;
    while (J[N] !== 0)
      ++N;
    Y = N + 1;
  }
  if (X & 1)
    Y += 2;
  let Q = qK0(tL(J, J.length - 8)), W = tL(J, J.length - 4);
  if ($ === void 0)
    $ = new Uint8Array(W);
  let K = new Uint8Array(J.buffer, J.byteOffset + Y, J.length - Y - 8), G = await wK0(Z, K, $), H = qi(G, 0, G.length);
  if (Q !== H)
    console.error("ungzip: checksums don't match");
  return G;
}
async function ga0(Z, J, $) {
  if ($ === void 0)
    $ = { level: 6 };
  let X = new Uint8Array(50 + Math.floor(J.length * 1.1)), Y = await DK0(Z, J, X, 0, $.level);
  return new Uint8Array(X.buffer, 0, Y);
}
function jK0(Z, J = !1) {
  return n0.create("Zip", ($) => ma0($, Z, J));
}
async function ma0(Z, J, $ = !1) {
  let X = 0, Y = {};
  for (let q in J) {
    let U = !da0(q) && !$, F = J[q], E = qi(F, 0, F.length);
    Y[q] = {
      cpr: U,
      usize: F.length,
      crc: E,
      file: U ? await ga0(Z, F) : F
    };
  }
  for (let q in Y)
    X += Y[q].file.length + 30 + 46 + 2 * Ni(q);
  X += 22;
  let Q = new Uint8Array(X), W = 0, K = [];
  for (let q in Y) {
    let U = Y[q];
    K.push(W), W = BK0(Q, W, q, U, 0);
  }
  let G = 0, H = W;
  for (let q in Y) {
    let U = Y[q];
    K.push(W), W = BK0(Q, W, q, U, 1, K[G++]);
  }
  let N = W - H;
  return CN(Q, W, 101010256), W += 4, W += 4, rL(Q, W, G), W += 2, rL(Q, W, G), W += 2, CN(Q, W, N), W += 4, CN(Q, W, H), W += 4, W += 2, Q.buffer;
}
function da0(Z) {
  let J = Z.split(".").pop().toLowerCase();
  return "png,jpg,jpeg,zip".indexOf(J) !== -1;
}
function BK0(Z, J, $, X, Y, Q = 0) {
  let W = X.file;
  if (CN(Z, J, Y === 0 ? 67324752 : 33639248), J += 4, Y === 1)
    J += 2;
  if (rL(Z, J, 20), J += 2, rL(Z, J, 0), J += 2, rL(Z, J, X.cpr ? 8 : 0), J += 2, CN(Z, J, 0), J += 4, CN(Z, J, X.crc), J += 4, CN(Z, J, W.length), J += 4, CN(Z, J, X.usize), J += 4, rL(Z, J, Ni($)), J += 2, rL(Z, J, 0), J += 2, Y === 1)
    J += 2, J += 2, J += 6, CN(Z, J, Q), J += 4;
  let K = UK0(Z, J, $);
  if (J += K, Y === 0)
    Z.set(W, J), J += W.length;
  return J;
}

// node_modules/molstar/lib/mol-util/data-source.js
var eG;
(function(Z) {
  Z[Z.None = 0] = "None", Z[Z.Gzip = 1] = "Gzip", Z[Z.Zip = 2] = "Zip";
})(eG || (eG = {}));
function SN(Z, J) {
  return la0(Z, J);
}
function R_(Z) {
  if (typeof Z === "string")
    return _K0(Z, Z, "string");
  return _K0(Z.title, Z.url, Z.type || "string", Z.body, Z.headers);
}
function pa0(Z) {
  if (tG)
    throw new Error("`isDone` should not be used when running in Node.js");
  if (Z instanceof FileReader)
    return Z.readyState === FileReader.DONE;
  else if (Z instanceof XMLHttpRequest)
    return Z.readyState === XMLHttpRequest.DONE;
  throw new Error("unknown data type");
}
function TK0(Z) {
  if (Z)
    return "Failed to download data. Possible reasons: Resource is not available, or CORS is not allowed on the server.";
  return "Failed to open file.";
}
function CK0(Z, J, $) {
  if (tG)
    throw new Error("`readData` should not be used when running in Node.js");
  return new Promise((X, Y) => {
    if (pa0($)) {
      let { error: W } = $;
      if (W !== null && W !== void 0)
        Y(W !== null && W !== void 0 ? W : TK0($ instanceof XMLHttpRequest));
      else
        X($);
      return;
    }
    let Q = !1;
    $.onerror = (W) => {
      if (Q)
        return;
      let { error: K } = W.target;
      Y(K !== null && K !== void 0 ? K : TK0($ instanceof XMLHttpRequest));
    }, $.onprogress = (W) => {
      if (!Z.shouldUpdate || Q)
        return;
      try {
        if (W.lengthComputable)
          Z.update({ message: J, isIndeterminate: !1, current: W.loaded, max: W.total });
        else
          Z.update({ message: `${J} ${(W.loaded / 1024 / 1024).toFixed(2)} MB`, isIndeterminate: !0 });
      } catch (K) {
        Q = !0, Y(K);
      }
    }, $.onload = (W) => {
      X($);
    };
  });
}
function kK0(Z) {
  return /\.gz$/i.test(Z) ? eG.Gzip : /\.zip$/i.test(Z) ? eG.Zip : eG.None;
}
var ua0 = /^(__MACOSX|.DS_Store)/;
async function ca0(Z, J, $) {
  switch ($) {
    case eG.None:
      return J;
    case eG.Gzip:
      return fS(Z, J);
    case eG.Zip:
      let X = await _M(Z, J.buffer), Y = Object.keys(X).filter((Q) => !ua0.test(Q));
      if (Y.length !== 1)
        throw new Error("can only decompress zip files with a single entry");
      return X[Y[0]];
  }
}
async function hS(Z, J, $, X) {
  if (J === null)
    throw new Error("no data given");
  let Y = new Uint8Array(J);
  if (X !== eG.None && $ !== "zip")
    Y = await ca0(Z, Y, X);
  if ($ === "binary")
    return Y;
  else if ($ === "zip")
    return await _M(Z, Y.buffer);
  else if ($ === "string")
    return _S(Y);
  else if ($ === "xml")
    return new DOMParser().parseFromString(IN(Y), "application/xml");
  else if ($ === "json")
    return JSON.parse(IN(Y));
  throw new Error(`could not get requested response data '${$}'`);
}
function la0(Z, J) {
  if (tG)
    return na0(Z, J);
  let $ = void 0;
  return n0.create("Read File", async (X) => {
    try {
      await X.update({ message: "Opening file...", canAbort: !0 }), $ = new FileReader, $.readAsArrayBuffer(Z);
      let Q = (await CK0(X, "Reading...", $)).result;
      return await X.update({ message: "Processing file...", canAbort: !1 }), await hS(X, Q, J, kK0(Z.name));
    } finally {
      $ = void 0;
    }
  }, () => {
    if ($)
      $.abort();
  });
}
function na0(Z, J) {
  return n0.create("Read File", async ($) => {
    await $.update({ message: "Opening file...", canAbort: !1 });
    let X = await Z.arrayBuffer();
    return await $.update({ message: "Processing file...", canAbort: !1 }), await hS($, X, J, kK0(Z.name));
  });
}

class vN {
  static get() {
    if (tG)
      throw new Error("`RequestPool.get` should not be used when running in Node.js");
    if (this.pool.length)
      return this.pool.pop();
    return new XMLHttpRequest;
  }
  static emptyFunc() {}
  static deposit(Z) {
    if (this.pool.length < this.poolSize)
      Z.onabort = vN.emptyFunc, Z.onerror = vN.emptyFunc, Z.onload = vN.emptyFunc, Z.onprogress = vN.emptyFunc, this.pool.push(Z);
  }
}
vN.pool = [];
vN.poolSize = 15;
function ia0(Z, J) {
  if (Z.status >= 200 && Z.status < 400) {
    let { response: $ } = Z;
    if (vN.deposit(Z), (J === "binary" || J === "zip") && $ instanceof ArrayBuffer)
      return new Uint8Array($);
    else if (J === "string" && typeof $ === "string")
      return $;
    else if (J === "xml" && $ instanceof XMLDocument)
      return $;
    else if (J === "json" && typeof $ === "object")
      return $;
    throw new Error(`could not get requested response data '${J}'`);
  } else
    throw vN.deposit(Z), new Error(`Download failed with status code ${Z.status}`);
}
function oa0(Z) {
  switch (Z) {
    case "json":
      return "json";
    case "xml":
      return "document";
    case "string":
      return "text";
    case "binary":
      return "arraybuffer";
    case "zip":
      return "arraybuffer";
  }
}
function _K0(Z, J, $, X, Y) {
  if (tG)
    if (J.startsWith("file://"))
      return ra0(Z, J, $, X, Y);
    else
      return ta0(Z, J, $, X, Y);
  let Q = void 0;
  return n0.create(Z ? Z : "Download", async (W) => {
    if (Q = vN.get(), Q.open(X ? "post" : "get", J, !0), Y)
      for (let [H, N] of Y)
        Q.setRequestHeader(H, N);
    Q.responseType = oa0($), Q.send(X), await W.update({ message: "Waiting for server...", canAbort: !0 });
    let K = await CK0(W, "Downloading...", Q);
    return Q = void 0, await W.update({ message: "Parsing response...", canAbort: !1 }), ia0(K, $);
  }, () => {
    if (Q)
      Q.abort(), Q = void 0;
  });
}
var VK0 = void 0;
function sa0() {
  if (!VK0)
    throw new Error("When running in Node.js and reading from files, call mol-util/data-source's setFSModule function first.");
  return VK0;
}
function aa0(Z) {
  return new Promise((J, $) => {
    sa0().readFile(Z, (X, Y) => {
      if (X)
        $(X);
      else
        J(Y);
    });
  });
}
function ra0(Z, J, $, X, Y) {
  if (!tG)
    throw new Error("This function should only be used when running in Node.js");
  if (!J.startsWith("file://"))
    throw new Error("This function is only for URLs with protocol file://");
  return n0.create(Z !== null && Z !== void 0 ? Z : "Download", async (Q) => {
    let W = J.substring(7);
    await Q.update({ message: "Loading file...", canAbort: !1 });
    let K = await aa0(W);
    return await Q.update({ message: "Parsing response...", canAbort: !1 }), await hS(Q, K.buffer, $, eG.None);
  });
}
function ta0(Z, J, $, X, Y) {
  if (!tG)
    throw new Error("This function should only be used when running in Node.js");
  let Q = new AbortController;
  return n0.create(Z !== null && Z !== void 0 ? Z : "Download", async (W) => {
    await W.update({ message: "Downloading...", canAbort: !0 });
    let K = await fetch(J, { signal: Q.signal });
    if (!(K.status >= 200 && K.status < 400))
      throw new Error(`Download failed with status code ${K.status}`);
    let G = await K.bytes();
    return await W.update({ message: "Parsing response...", canAbort: !1 }), await hS(W, G.buffer, $, eG.None);
  }, () => {
    Q.abort();
  });
}
async function vK0(Z, J, $, X) {
  let Y = $.length, Q = new Array($.length);
  await Z.update({ message: "Downloading...", current: 0, max: Y });
  let W = [], K = [], G = 0;
  for (let N = Math.min(Y, X);G < N; G++) {
    let q = $[G];
    W.push(PK0(G, q.id, J.resolve(E6.getUrlAsset(J, q.url), q.isBinary ? "binary" : "string").runAsChild(Z))), K.push(G);
  }
  let H = 0;
  while (W.length > 0) {
    let N = await Promise.race(W), q = $[N.index], U = K.indexOf(N.index);
    if (H++, N.kind === "error" && !q.canFail)
      throw new Error(`${q.url}: ${N.error}`);
    if (Z.shouldUpdate)
      await Z.update({ message: "Downloading...", current: H, max: Y });
    if (Q[N.index] = N, W = W.filter(IK0, U), K = K.filter(IK0, U), G < Y) {
      let F = $[G], E = J.resolve(E6.getUrlAsset(J, F.url), F.isBinary ? "binary" : "string").runAsChild(Z);
      W.push(PK0(G, F.id, E)), K.push(G), G++;
    }
  }
  return Q;
}
function IK0(Z, J) {
  return this !== J;
}
async function PK0(Z, J, $) {
  try {
    return { kind: "ok", result: await $, index: Z, id: J };
  } catch (X) {
    return { kind: "error", error: X, index: Z, id: J };
  }
}

// node_modules/molstar/lib/mol-data/util/array.js
function VM(Z, J) {
  for (let $ = 0, X = Z.length;$ < X; $++)
    if (J(Z[$]))
      return Z[$];
  return;
}
function IM(Z) {
  if (Array.from)
    return Array.from(Z);
  let J = [];
  while (!0) {
    let { done: $, value: X } = Z.next();
    if ($)
      break;
    J[J.length] = X;
  }
  return J;
}
function E_(Z, J, $) {
  let X = J - Z + 1, Y = $ ? new $(X) : new Int32Array(X);
  for (let Q = 0;Q < X; Q++)
    Y[Q] = Q + Z;
  return Y;
}
function SK0(Z, J) {
  let $ = new (ea0(Z))(J.length);
  for (let X = 0, Y = J.length;X < Y; X++)
    $[X] = Z[J[X]];
  return $;
}
function ea0(Z) {
  let J = Z.constructor;
  if (!J)
    throw new Error("data does not define a constructor and it should");
  return J;
}

// node_modules/molstar/lib/mol-util/assets.js
var E6;
(function(Z) {
  function J(G, H) {
    return { kind: "url", id: R6.create22(), url: G, ...H };
  }
  Z.Url = J;
  function $(G) {
    return { kind: "file", id: R6.create22(), name: G.name, file: G };
  }
  Z.File = $;
  function X(G) {
    return (G === null || G === void 0 ? void 0 : G.kind) === "url";
  }
  Z.isUrl = X;
  function Y(G) {
    return (G === null || G === void 0 ? void 0 : G.kind) === "file";
  }
  Z.isFile = Y;
  function Q(G, H, N) {
    return {
      data: G,
      dispose: () => {
        N.release(H);
      }
    };
  }
  Z.Wrapper = Q;
  function W(G) {
    return typeof G === "string" ? G : G.url;
  }
  Z.getUrl = W;
  function K(G, H, N) {
    if (typeof H === "string")
      return G.tryFindUrl(H, N) || J(H, { body: N });
    return H;
  }
  Z.getUrlAsset = K;
})(E6 || (E6 = {}));

class Oi {
  constructor() {
    this._assets = /* @__PURE__ */ new Map;
  }
  get assets() {
    return IM(this._assets.values());
  }
  tryFindUrl(Z, J) {
    let $ = this.assets.values();
    while (!0) {
      let X = $.next();
      if (X.done)
        return;
      let Y = X.value.asset;
      if (E6.isUrl(Y) && Y.url === Z && (Y.body || "") === (J || ""))
        return Y;
    }
  }
  tryFindFilename(Z) {
    let J = this._assets.values();
    while (!0) {
      let { done: $, value: X } = J.next();
      if ($)
        break;
      if (X.file.name === Z)
        return X.asset;
    }
  }
  set(Z, J, $) {
    this._assets.set(Z.id, { asset: Z, file: J, refCount: 0, tag: $ === null || $ === void 0 ? void 0 : $.tag, isStatic: $ === null || $ === void 0 ? void 0 : $.isStatic });
  }
  get(Z) {
    return this._assets.get(Z.id);
  }
  delete(Z) {
    return this._assets.delete(Z.id);
  }
  has(Z) {
    return this._assets.has(Z.id);
  }
  resolve(Z, J, $ = !0) {
    if (E6.isUrl(Z))
      return n0.create(`Download ${Z.title || Z.url}`, async (X) => {
        if (this._assets.has(Z.id)) {
          let W = this._assets.get(Z.id);
          return W.refCount++, E6.Wrapper(await SN(W.file, J).runInContext(X), Z, this);
        }
        if (!$)
          return E6.Wrapper(await R_({ ...Z, type: J }).runInContext(X), Z, this);
        let Y = await R_({ ...Z, type: "binary" }).runInContext(X), Q = new Hi([Y], "raw-data");
        return this._assets.set(Z.id, { asset: Z, file: Q, refCount: 1 }), E6.Wrapper(await SN(Q, J).runInContext(X), Z, this);
      });
    else
      return n0.create(`Read ${Z.name}`, async (X) => {
        if (this._assets.has(Z.id)) {
          let Y = this._assets.get(Z.id);
          return Y.refCount++, E6.Wrapper(await SN(Y.file, J).runInContext(X), Z, this);
        }
        if (!(Z.file instanceof Hi))
          throw new Error(`Cannot resolve file asset '${Z.name}' (${Z.id})`);
        if ($)
          this._assets.set(Z.id, { asset: Z, file: Z.file, refCount: 1 });
        return E6.Wrapper(await SN(Z.file, J).runInContext(X), Z, this);
      });
  }
  release(Z) {
    let J = this._assets.get(Z.id);
    if (!J)
      return;
    if (J.refCount--, J.refCount <= 0 && !J.isStatic)
      this._assets.delete(Z.id);
  }
  clearTag(Z) {
    let J = Array.from(this._assets.keys());
    for (let $ of J) {
      let X = this._assets.get($);
      if (X && X.tag === Z)
        this._assets.delete($);
    }
  }
  clear() {
    this._assets.clear();
  }
  dispose() {
    this.clear();
  }
}

// node_modules/molstar/lib/mol-util/param-definition.js
var j;
(function(Z) {
  Z.Essential = { isEssential: !0 };
  function J(N0, q0) {
    if (!q0)
      return N0;
    if (q0.label)
      N0.label = q0.label;
    if (q0.description)
      N0.description = q0.description;
    if (q0.legend)
      N0.legend = q0.legend;
    if (q0.fieldLabels)
      N0.fieldLabels = q0.fieldLabels;
    if (q0.isHidden)
      N0.isHidden = q0.isHidden;
    if (q0.shortLabel)
      N0.shortLabel = q0.shortLabel;
    if (q0.twoColumns)
      N0.twoColumns = q0.twoColumns;
    if (q0.isEssential)
      N0.isEssential = q0.isEssential;
    if (q0.category)
      N0.category = q0.category;
    if (q0.hideIf)
      N0.hideIf = q0.hideIf;
    if (q0.help)
      N0.help = q0.help;
    return N0;
  }
  function $(N0) {
    let q0 = { ...N0 };
    return q0.isOptional = !0, q0;
  }
  Z.Optional = $;
  function X(N0, q0) {
    return J({ type: "value", defaultValue: N0 }, q0);
  }
  Z.Value = X;
  function Y(N0, q0, A0) {
    return J({ type: "select", defaultValue: V0(N0, q0), options: q0, cycle: A0 === null || A0 === void 0 ? void 0 : A0.cycle }, A0);
  }
  Z.Select = Y;
  function Q(N0, q0, A0) {
    let S0 = J({ type: "multi-select", defaultValue: N0, options: q0 }, A0);
    if (A0 === null || A0 === void 0 ? void 0 : A0.emptyValue)
      S0.emptyValue = A0.emptyValue;
    return S0;
  }
  Z.MultiSelect = Q;
  function W(N0, q0) {
    return J({ type: "boolean", defaultValue: N0 }, q0);
  }
  Z.Boolean = W;
  function K(N0 = "", q0) {
    return J({ type: "text", defaultValue: N0, multiline: q0 === null || q0 === void 0 ? void 0 : q0.multiline, placeholder: q0 === null || q0 === void 0 ? void 0 : q0.placeholder, disableInteractiveUpdates: q0 === null || q0 === void 0 ? void 0 : q0.disableInteractiveUpdates }, q0);
  }
  Z.Text = K;
  function G(N0, q0) {
    let A0 = J({ type: "color", defaultValue: N0 }, q0);
    if (q0 === null || q0 === void 0 ? void 0 : q0.isExpanded)
      A0.isExpanded = q0.isExpanded;
    return A0;
  }
  Z.Color = G;
  function H(N0, q0) {
    let A0;
    if (typeof N0 === "string") {
      let S0 = RJ(N0);
      A0 = { kind: S0.type !== "qualitative" ? "interpolate" : "set", colors: S0.list };
    } else
      A0 = N0;
    return J({ type: "color-list", presetKind: (q0 === null || q0 === void 0 ? void 0 : q0.presetKind) || "all", defaultValue: A0, offsets: !!(q0 === null || q0 === void 0 ? void 0 : q0.offsets) }, q0);
  }
  Z.ColorList = H;
  function N(N0, q0, A0) {
    return J(R({ type: "vec3", defaultValue: N0 }, q0), A0);
  }
  Z.Vec3 = N;
  function q(N0, q0) {
    return J({ type: "mat4", defaultValue: N0 }, q0);
  }
  Z.Mat4 = q;
  function U(N0, q0) {
    let A0 = typeof N0 === "string" ? E6.Url(N0) : E6.Url(N0.url, { body: N0.body });
    return J({ type: "url", defaultValue: A0 }, q0);
  }
  Z.Url = U;
  function F(N0) {
    let q0 = J({ type: "file", defaultValue: null }, N0);
    if (N0 === null || N0 === void 0 ? void 0 : N0.accept)
      q0.accept = N0.accept;
    return q0;
  }
  Z.File = F;
  function E(N0) {
    let q0 = J({ type: "file-list", defaultValue: null }, N0);
    if (N0 === null || N0 === void 0 ? void 0 : N0.accept)
      q0.accept = N0.accept;
    return q0;
  }
  Z.FileList = E;
  function R(N0, q0) {
    if (!q0)
      return N0;
    if (typeof q0.min !== "undefined")
      N0.min = q0.min;
    if (typeof q0.max !== "undefined")
      N0.max = q0.max;
    if (typeof q0.step !== "undefined")
      N0.step = q0.step;
    return N0;
  }
  function z(N0, q0, A0) {
    let S0 = J(R({ type: "number", defaultValue: N0 }, q0), A0);
    if (A0 === null || A0 === void 0 ? void 0 : A0.immediateUpdate)
      S0.immediateUpdate = !0;
    return S0;
  }
  Z.Numeric = z;
  function D(N0, q0, A0) {
    return J(R({ type: "interval", defaultValue: N0 }, q0), A0);
  }
  Z.Interval = D;
  function A(N0, q0) {
    let A0 = J({ type: "line-graph", defaultValue: N0 }, q0);
    if (q0 === null || q0 === void 0 ? void 0 : q0.getVolume)
      A0.getVolume = q0.getVolume;
    return A0;
  }
  Z.LineGraph = A;
  function B(N0, q0) {
    let A0 = J({ type: "group", defaultValue: (q0 === null || q0 === void 0 ? void 0 : q0.customDefault) || m(N0), params: N0 }, q0);
    if (q0 === null || q0 === void 0 ? void 0 : q0.presets)
      A0.presets = q0.presets;
    if (q0 === null || q0 === void 0 ? void 0 : q0.isExpanded)
      A0.isExpanded = q0.isExpanded;
    if (q0 === null || q0 === void 0 ? void 0 : q0.isFlat)
      A0.isFlat = q0.isFlat;
    if (q0 === null || q0 === void 0 ? void 0 : q0.pivot)
      A0.pivot = q0.pivot;
    return A0;
  }
  Z.Group = B;
  function T(N0) {
    return B({}, N0);
  }
  Z.EmptyGroup = T;
  function w(N0, q0, A0, S0) {
    let a0 = V0(N0, q0);
    return J({
      type: "mapped",
      defaultValue: { name: a0, params: A0(a0).defaultValue },
      select: Y(a0, q0, S0),
      map: A0
    }, S0);
  }
  Z.Mapped = w;
  function V(N0, q0, A0) {
    let S0 = (A0 === null || A0 === void 0 ? void 0 : A0.options) ? A0.options : Object.keys(q0).map((D1) => [D1, q0[D1].label || v$(D1)]), a0 = V0(N0, S0);
    return J({
      type: "mapped",
      defaultValue: { name: a0, params: q0[a0].defaultValue },
      select: Y(a0, S0, A0),
      map: (D1) => q0[D1]
    }, A0);
  }
  Z.MappedStatic = V;
  function P(N0, q0, A0) {
    return J({ type: "object-list", element: N0, getLabel: q0, ctor: I, defaultValue: (A0 === null || A0 === void 0 ? void 0 : A0.defaultValue) || [] }, A0);
  }
  Z.ObjectList = P;
  function I() {
    return m(this.element);
  }
  function S() {
    throw new Error("getValue not set. Fix runtime.");
  }
  function f(N0, q0, A0) {
    var S0;
    return J({ type: "value-ref", defaultValue: { ref: (S0 = A0 === null || A0 === void 0 ? void 0 : A0.defaultRef) !== null && S0 !== void 0 ? S0 : "", getValue: S }, getOptions: N0, resolveRef: q0 }, A0);
  }
  Z.ValueRef = f;
  function v(N0) {
    var q0;
    return J({ type: "data-ref", defaultValue: { ref: (q0 = N0 === null || N0 === void 0 ? void 0 : N0.defaultRef) !== null && q0 !== void 0 ? q0 : "", getValue: S } }, N0);
  }
  Z.DataRef = v;
  function h(N0, q0, A0) {
    return J({ type: "converted", defaultValue: q0(A0.defaultValue), converted: A0, fromValue: N0, toValue: q0 }, A0);
  }
  Z.Converted = h;
  function x(N0, q0, A0, S0, a0) {
    let D1 = Object.keys(q0).map((Y1) => [Y1, Y1]);
    return J({ type: "conditioned", select: Y(A0(N0), D1, a0), defaultValue: N0, conditionParams: q0, conditionForValue: A0, conditionedValue: S0 }, a0);
  }
  Z.Conditioned = x;
  function b(N0, q0) {
    return J({ type: "script", defaultValue: N0 }, q0);
  }
  Z.Script = b;
  function g(N0) {
    return 0;
  }
  Z.For = g;
  function m(N0) {
    let q0 = {};
    for (let A0 of Object.keys(N0)) {
      if (N0[A0].isOptional)
        continue;
      q0[A0] = N0[A0].defaultValue;
    }
    return q0;
  }
  Z.getDefaultValues = m;
  function i(N0, q0, A0) {
    return () => N0(q0, A0);
  }
  function r(N0, q0, A0) {
    if (!q0)
      return;
    if (N0.type === "value-ref") {
      let S0 = q0;
      if (!S0.ref)
        S0.getValue = () => {
          throw new Error("Unset ref in ValueRef value.");
        };
      else
        S0.getValue = i(N0.resolveRef, S0.ref, A0);
    } else if (N0.type === "data-ref") {
      let S0 = q0;
      if (!S0.ref)
        S0.getValue = () => {
          throw new Error("Unset ref in ValueRef value.");
        };
      else
        S0.getValue = i(A0, S0.ref, A0);
    } else if (N0.type === "group")
      n(N0.params, q0, A0);
    else if (N0.type === "mapped") {
      let S0 = q0, a0 = N0.map(S0.name);
      r(a0, S0.params, A0);
    } else if (N0.type === "object-list") {
      if (!c(N0.element))
        return;
      for (let S0 of q0)
        n(N0.element, S0, A0);
    }
  }
  function Y0(N0) {
    if (N0.type === "value-ref" || N0.type === "data-ref")
      return !0;
    else if (N0.type === "group") {
      if (c(N0.params))
        return !0;
    } else if (N0.type === "mapped") {
      for (let [q0] of N0.select.options)
        if (Y0(N0.map(q0)))
          return !0;
    } else if (N0.type === "object-list")
      return c(N0.element);
    return !1;
  }
  function c(N0) {
    for (let q0 of Object.keys(N0))
      if (Y0(N0[q0]))
        return !0;
    return !1;
  }
  function n(N0, q0, A0) {
    for (let S0 of Object.keys(N0))
      r(N0[S0], q0 === null || q0 === void 0 ? void 0 : q0[S0], A0);
  }
  Z.resolveRefs = n;
  function l(N0, q0) {
    for (let A0 of Object.keys(N0)) {
      if (N0[A0].isOptional)
        continue;
      N0[A0].defaultValue = q0[A0];
    }
  }
  Z.setDefaultValues = l;
  function u(N0) {
    return W$(N0);
  }
  Z.clone = u;
  function G0(N0, q0) {
    return;
  }
  Z.validate = G0;
  function F0(N0, q0, A0) {
    if (q0 === A0)
      return !0;
    if (typeof q0 !== "object" || typeof A0 !== "object")
      return !1;
    for (let S0 of Object.keys(N0))
      if (!t(N0[S0], q0[S0], A0[S0]))
        return !1;
    return !0;
  }
  Z.areEqual = F0;
  function t(N0, q0, A0) {
    if (q0 === A0)
      return !0;
    if (N0.type === "group")
      return F0(N0.params, q0, A0);
    else if (N0.type === "mapped") {
      let S0 = q0, a0 = A0;
      if (S0.name !== a0.name)
        return !1;
      let D1 = N0.map(S0.name);
      return t(D1, S0.params, a0.params);
    } else if (N0.type === "multi-select") {
      let S0 = q0, a0 = A0;
      if (S0.length !== a0.length)
        return !1;
      if (S0.length < 10)
        for (let D1 = 0, Y1 = S0.length;D1 < Y1; D1++) {
          if (S0[D1] === a0[D1])
            continue;
          if (a0.indexOf(S0[D1]) < 0)
            return !1;
        }
      else {
        let D1 = new Set(a0);
        for (let Y1 = 0, u1 = S0.length;Y1 < u1; Y1++) {
          if (S0[Y1] === a0[Y1])
            continue;
          if (!D1.has(S0[Y1]))
            return !1;
        }
      }
      return !0;
    } else if (N0.type === "interval")
      return q0[0] === A0[0] && q0[1] === A0[1];
    else if (N0.type === "line-graph") {
      let S0 = q0, a0 = A0;
      if (S0.length !== a0.length)
        return !1;
      for (let D1 = 0, Y1 = S0.length;D1 < Y1; D1++)
        if (!h0.areEqual(S0[D1], a0[D1]))
          return !1;
      return !0;
    } else if (N0.type === "vec3")
      return M.equals(q0, A0);
    else if (N0.type === "mat4")
      return e.areEqual(q0, A0, u8);
    else if (N0.type === "script") {
      let S0 = q0, a0 = A0;
      return S0.language === a0.language && S0.expression === a0.expression;
    } else if (N0.type === "object-list") {
      let S0 = q0, a0 = A0, D1 = S0.length;
      if (D1 !== a0.length)
        return !1;
      for (let Y1 = 0;Y1 < D1; Y1++)
        if (!F0(N0.element, S0[Y1], a0[Y1]))
          return !1;
      return !0;
    } else if (typeof q0 === "object" && typeof A0 === "object")
      return zN(q0, A0);
    return !1;
  }
  Z.isParamEqual = t;
  function Z0(N0, q0, A0) {
    if (q0 === void 0)
      return { ...A0 };
    if (A0 === void 0)
      return { ...q0 };
    let S0 = {};
    for (let a0 of Object.keys(N0))
      S0[a0] = U0(N0[a0], q0[a0], A0[a0]);
    return S0;
  }
  Z.merge = Z0;
  function U0(N0, q0, A0) {
    if (q0 === void 0)
      return typeof A0 === "object" && !Array.isArray(A0) ? { ...A0 } : A0;
    if (A0 === void 0)
      return typeof q0 === "object" && !Array.isArray(q0) ? { ...q0 } : q0;
    if (N0.type === "group")
      return Z0(N0.params, q0, A0);
    else if (N0.type === "mapped") {
      let S0 = q0, a0 = A0;
      if (S0.name !== a0.name)
        return { ...a0 };
      let D1 = N0.map(a0.name);
      return {
        name: a0.name,
        params: U0(D1, S0.params, a0.params)
      };
    } else if (N0.type === "value")
      return A0;
    else if (typeof q0 === "object" && typeof A0 === "object") {
      if (Array.isArray(A0))
        return A0;
      return { ...q0, ...A0 };
    } else
      return A0;
  }
  Z.mergeParam = U0;
  function a(N0, q0) {
    for (let A0 of N0.options)
      if (A0[0] === q0)
        return !0;
    return !1;
  }
  function Q0(N0, q0, A0) {
    if (q0 === void 0 || q0 === null)
      return A0 ? N0.defaultValue : void 0;
    if (N0.type === "value")
      return q0;
    else if (N0.type === "group") {
      let S0 = {};
      for (let a0 of Object.keys(N0.params)) {
        let D1 = N0.params[a0];
        if (q0[a0] === void 0) {
          if (A0)
            S0[a0] = D1.defaultValue;
        } else
          S0[a0] = Q0(D1, q0[a0], A0);
      }
      return S0;
    } else if (N0.type === "mapped") {
      let S0 = q0;
      if (typeof S0.name !== "string")
        return N0.defaultValue;
      if (typeof S0.params === "undefined")
        return A0 ? N0.defaultValue : void 0;
      if (!a(N0.select, S0.name))
        return N0.defaultValue;
      let a0 = N0.map(S0.name);
      return {
        name: S0.name,
        params: Q0(a0, S0.params, A0)
      };
    } else if (N0.type === "select") {
      if (!a(N0, q0))
        return N0.defaultValue;
      return q0;
    } else if (N0.type === "multi-select") {
      if (!Array.isArray(q0))
        return N0.defaultValue;
      let S0 = q0.filter(function(a0) {
        return a(this, a0);
      }, N0);
      if (q0.length > 0 && S0.length === 0)
        return N0.defaultValue;
      return S0;
    } else if (N0.type === "object-list") {
      if (!Array.isArray(q0))
        return N0.defaultValue;
      return q0.map((S0) => $0(N0.element, S0, A0 ? "all" : "skip"));
    }
    return q0;
  }
  function $0(N0, q0, A0) {
    if (typeof q0 !== "object" || q0 === null)
      return A0 ? m(N0) : q0;
    let S0 = {};
    for (let a0 of Object.keys(N0)) {
      let D1 = N0[a0];
      if (q0[a0] === void 0) {
        if (A0 === "all")
          S0[a0] = D1.defaultValue;
      } else
        S0[a0] = Q0(D1, q0[a0], A0 !== "skip");
    }
    return S0;
  }
  Z.normalizeParams = $0;
  function R0(N0, q0) {
    let A0 = [];
    for (let S0 of Object.keys(N0))
      if (!q0)
        if (typeof N0[S0] === "string")
          A0.push([S0, N0[S0]]);
        else
          A0.push([S0, q0 === null ? S0 : v$(S0)]);
      else {
        let a0 = q0(S0, N0[S0]);
        A0.push(typeof a0 === "string" ? [S0, a0] : [S0, a0[0], a0[1]]);
      }
    return A0;
  }
  Z.objectToOptions = R0;
  function X0(N0, q0) {
    let A0 = [];
    for (let S0 of N0)
      if (!q0)
        A0.push([S0, q0 === null ? S0 : v$(S0)]);
      else
        A0.push([S0, q0(S0)]);
    return A0;
  }
  Z.arrayToOptions = X0;
  function E0(N0, q0) {
    for (let A0 of N0.options)
      if (A0[0] === q0)
        return A0[1];
    return "";
  }
  Z.optionLabel = E0;
  function V0(N0, q0) {
    for (let A0 of q0)
      if (A0[0] === N0)
        return N0;
    return q0.length > 0 ? q0[0][0] : void 0;
  }
  function u0(N0, q0) {
    let A0 = {};
    for (let S0 of Object.keys(q0)) {
      let a0 = q0[S0];
      if (!N0[S0] || a0 === null || a0 === void 0 || N0[S0].defaultValue === a0)
        continue;
      A0[S0] = { ...N0[S0], defaultValue: a0 };
    }
    return { ...N0, ...A0 };
  }
  Z.withDefaults = u0;
})(j || (j = {}));

// node_modules/molstar/lib/mol-state/action.js
var a$;
(function(Z) {
  function J(Y) {
    let Q = {
      create(W) {
        return { action: Q, params: W };
      },
      id: R6.create22(),
      definition: Y,
      createDefaultParams(W, K) {
        return Y.params ? j.getDefaultValues(Y.params(W, K)) : {};
      }
    };
    return Q;
  }
  Z.create = J;
  function $(Y) {
    let Q = Y.definition;
    return J({
      from: Q.from,
      display: Q.display,
      params: Q.params,
      isApplicable: Y.definition.isApplicable ? (W, K, G) => Y.definition.isApplicable(W, G) : void 0,
      run({ cell: W, state: K, params: G }) {
        let H = K.build().to(W.transform.ref).apply(Y, G);
        return K.updateTree(H);
      }
    });
  }
  Z.fromTransformer = $;
  let X;
  (function(Y) {
    function Q(W) {
      return (K) => J({
        from: W.from instanceof Array ? W.from : W.from ? [W.from] : [],
        display: typeof W.display === "string" ? { name: W.display } : W.display ? W.display : { name: "Unnamed State Action" },
        params: typeof W.params === "object" ? () => W.params : W.params ? W.params : void 0,
        isApplicable: W.isApplicable,
        ...typeof K === "function" ? { run: K } : K
      });
    }
    Y.build = (W) => Q(W);
  })(X = Z.Builder || (Z.Builder = {})), Z.build = X.build;
})(a$ || (a$ = {}));

// node_modules/molstar/lib/mol-state/transformer.js
var T1;
(function(Z) {
  function J(R, z, D) {
    return R.definition.params ? R.definition.params(z, D) : {};
  }
  Z.getParamDefinition = J;
  function $(R) {
    return !!R && typeof R.toAction === "function" && typeof R.apply === "function";
  }
  Z.is = $;
  let X;
  (function(R) {
    R[R.Unchanged = 0] = "Unchanged", R[R.Updated = 1] = "Updated", R[R.Recreate = 2] = "Recreate", R[R.Null = 3] = "Null";
  })(X = Z.UpdateResult || (Z.UpdateResult = {}));
  let Y = /* @__PURE__ */ new Map, Q = /* @__PURE__ */ new Map;
  function W(R) {
    for (let z of R.definition.from)
      if (Q.has(z.type))
        Q.get(z.type).push(R);
      else
        Q.set(z.type, [R]);
  }
  function K() {
    return Array.from(Y.values());
  }
  Z.getAll = K;
  function G(R) {
    let z = Y.get(R);
    if (!z)
      throw new Error(`A transformer with signature '${R}' is not registered.`);
    return z;
  }
  Z.get = G;
  function H(R) {
    return Q.get(R) || [];
  }
  Z.fromType = H;
  function N(R, z) {
    let { name: D } = z, A = `${R}.${D}`;
    if (Y.has(A))
      console.warn(`A transform with id '${D}' is already registered. Please pick a unique identifier for your transforms and/or register them only once. This is to ensure that transforms can be serialized and replayed.`);
    let B = {
      apply(T, w, V) {
        return D8.create(T, B, w, V);
      },
      toAction() {
        return a$.fromTransformer(B);
      },
      namespace: R,
      id: A,
      definition: z,
      createDefaultParams(T, w) {
        return z.params ? j.getDefaultValues(z.params(T, w)) : {};
      }
    };
    return Y.set(A, B), W(B), B;
  }
  Z.create = N;
  function q(R) {
    return (z) => N(R, z);
  }
  Z.factory = q;
  function U(R) {
    return F.build(R);
  }
  Z.builderFactory = U;
  let F;
  (function(R) {
    function z(A, B) {
      return (T) => N(A, {
        name: B.name,
        from: B.from instanceof Array ? B.from : [B.from],
        to: B.to instanceof Array ? B.to : [B.to],
        display: typeof B.display === "string" ? { name: B.display } : B.display ? B.display : { name: TN(B.name.replace(/[-]/g, " ")) },
        params: typeof B.params === "object" ? () => B.params : B.params ? B.params : void 0,
        isDecorator: B.isDecorator,
        ...T
      });
    }
    function D(A) {
      return (B) => z(A, B);
    }
    R.build = D;
  })(F = Z.Builder || (Z.Builder = {}));
  function E(R) {
    return F.build(R);
  }
  Z.build = E, Z.ROOT = N("build-in", {
    name: "root",
    from: [],
    to: [],
    display: { name: "Root", description: "For internal use." },
    apply() {
      throw new Error("should never be applied");
    },
    update() {
      return X.Unchanged;
    }
  });
})(T1 || (T1 = {}));

// node_modules/molstar/lib/mol-data/util/hash-functions.js
function bS(Z) {
  let J = Z ^ Z >> 4;
  return J = (J ^ 3735928559) + (J << 5), J = J ^ J >> 11, J;
}
function SQ(Z, J) {
  let $ = 23;
  return $ = 31 * $ + Z | 0, $ = 31 * $ + J | 0, $ = $ ^ $ >> 4, $ = ($ ^ 3735928559) + ($ << 5), $ = $ ^ $ >> 11, $;
}
function fK0(Z, J, $) {
  let X = 23;
  return X = 31 * X + Z | 0, X = 31 * X + J | 0, X = 31 * X + $ | 0, X = X ^ X >> 4, X = (X ^ 3735928559) + (X << 5), X = X ^ X >> 11, X;
}
function hK0(Z, J, $, X) {
  let Y = 23;
  return Y = 31 * Y + Z | 0, Y = 31 * Y + J | 0, Y = 31 * Y + $ | 0, Y = 31 * Y + X | 0, Y = Y ^ Y >> 4, Y = (Y ^ 3735928559) + (Y << 5), Y = Y ^ Y >> 11, Y;
}
function O_(Z) {
  let J = 0;
  for (let $ = 0, X = Z.length;$ < X; $++)
    J = (J << 5) - J + Z.charCodeAt($) | 0;
  return J;
}
function ZJ(Z, J) {
  return (Z + J) * (Z + J + 1) / 2 + J;
}
function wW(Z, J) {
  return Z < J ? ZJ(Z, J) : ZJ(J, Z);
}
function PM(Z, J) {
  let $ = Math.floor((Math.sqrt(8 * J + 1) - 1) / 2), X = ($ * $ + $) / 2, Y = J - X;
  return Z[0] = $ - Y, Z[1] = Y, Z;
}
function l9(Z) {
  let J = 2166136261;
  for (let $ = 0, X = Z.length;$ < X; ++$)
    J ^= Z[$], J += (J << 1) + (J << 4) + (J << 7) + (J << 8) + (J << 24);
  return J >>> 0;
}
class bK0 {
  constructor() {
    this.hashTarget = new Uint32Array(8), this.numberBytes = new Uint8Array(8), this.numberView = new DataView(this.numberBytes.buffer);
  }
  hash(Z) {
    return this.hashTarget.set(Zr0), this.hashValue(Z, 0), Yr0(this.hashTarget);
  }
  hashValue(Z, J) {
    if (J > 50)
      return;
    let $ = typeof Z;
    switch (this.addByte($.charCodeAt(0)), $) {
      case "string":
        this.addString(Z);
        break;
      case "number":
        this.addNumber(Z);
        break;
      case "boolean":
        this.addByte(Z ? 1 : 0);
        break;
      case "object":
        if (Z === null)
          this.addByte(0);
        else if (Array.isArray(Z))
          this.addArray(Z, J);
        else
          this.addObject(Z, J);
        break;
      case "undefined":
        this.addByte(255);
        break;
    }
  }
  addByte(Z) {
    this.hashTarget[0] ^= Z & 255, Jr0(this.hashTarget);
  }
  addString(Z) {
    for (let J = 0;J < Z.length; J++) {
      let $ = Z.charCodeAt(J);
      if ($ < 128)
        this.addByte($);
      else if ($ < 2048)
        this.addByte(192 | $ >> 6), this.addByte(128 | $ & 63);
      else
        this.addByte(224 | $ >> 12), this.addByte(128 | $ >> 6 & 63), this.addByte(128 | $ & 63);
    }
  }
  addNumber(Z) {
    if (Number.isNaN(Z))
      this.addByte(127), this.addByte(192), this.addByte(0), this.addByte(0), this.addByte(0), this.addByte(0), this.addByte(0), this.addByte(0);
    else if (!Number.isFinite(Z)) {
      if (Z > 0)
        this.addByte(127), this.addByte(128), this.addByte(0), this.addByte(0);
      else
        this.addByte(255), this.addByte(128), this.addByte(0), this.addByte(0);
      this.addByte(0), this.addByte(0), this.addByte(0), this.addByte(0);
    } else {
      this.numberView.setFloat64(0, Z, !1);
      for (let J = 0;J < 8; J++)
        this.addByte(this.numberBytes[J]);
    }
  }
  addArray(Z, J) {
    this.addNumber(Z.length);
    for (let $ = 0;$ < Z.length; $++)
      this.addNumber($), this.hashValue(Z[$], J + 1);
  }
  addObject(Z, J) {
    let $ = Object.keys(Z).sort();
    this.addNumber($.length);
    for (let X of $)
      this.addString(X), this.hashValue(Z[X], J + 1);
  }
}
var fp1 = new bK0, Zr0 = new Uint32Array([
  1818371886,
  129696066,
  1656234357,
  1653982605,
  383153456,
  3715178979,
  3004645376,
  256
]), PF = new Uint32Array(8), CF = new Uint32Array(8);
function Jr0(Z) {
  PF[0] = 0, PF[1] = 0, PF[2] = Z[0] << 24, PF[3] = Z[0] >>> 8 | Z[1] << 24, PF[4] = Z[1] >>> 8 | Z[2] << 24, PF[5] = Z[2] >>> 8 | Z[3] << 24, PF[6] = Z[3] >>> 8 | Z[4] << 24, PF[7] = Z[4] >>> 8 | Z[5] << 24, CF[0] = Z[0] << 8, CF[1] = Z[0] >>> 24 | Z[1] << 8, CF[2] = Z[1] >>> 24 | Z[2] << 8, CF[3] = Z[2] >>> 24 | Z[3] << 8, CF[4] = Z[3] >>> 24 | Z[4] << 8, CF[5] = Z[4] >>> 24 | Z[5] << 8, CF[6] = Z[5] >>> 24 | Z[6] << 8, CF[7] = Z[6] >>> 24 | Z[7] << 8;
  let J = 0;
  for (let $ = 0;$ < 8; $++) {
    let X = Z[$] * 59 + J;
    Z[$] = X >>> 0, J = Math.floor(X / 4294967296);
  }
  J = 0;
  for (let $ = 0;$ < 8; $++) {
    let X = Z[$] + PF[$] + CF[$] + J;
    Z[$] = X >>> 0, J = X >= 4294967296 ? 1 : 0;
  }
}
var $r0 = [
  "00000000",
  "0000000",
  "000000",
  "00000",
  "0000",
  "000",
  "00",
  "0"
];
function Xr0(Z) {
  let J = Z.toString(16);
  if (J.length >= 8)
    return J;
  return $r0[J.length] + J;
}
function Yr0(Z) {
  let J = "";
  for (let $ = 7;$ >= 0; $--)
    J += Xr0(Z[$]);
  return J;
}
function zi(Z, J = 42) {
  let $ = JSON.stringify(Z);
  return Qr0($, J);
}
function Qr0(Z, J) {
  let $ = J >>> 0, X = J >>> 0, Y = J >>> 0, Q = J >>> 0, W = Z.length % 16, K = Z.length - W;
  for (let U = 0;U < K; U += 16) {
    let F = Z.charCodeAt(U) & 255 | (Z.charCodeAt(U + 1) & 255) << 8 | (Z.charCodeAt(U + 2) & 255) << 16 | (Z.charCodeAt(U + 3) & 255) << 24, E = Z.charCodeAt(U + 4) & 255 | (Z.charCodeAt(U + 5) & 255) << 8 | (Z.charCodeAt(U + 6) & 255) << 16 | (Z.charCodeAt(U + 7) & 255) << 24, R = Z.charCodeAt(U + 8) & 255 | (Z.charCodeAt(U + 9) & 255) << 8 | (Z.charCodeAt(U + 10) & 255) << 16 | (Z.charCodeAt(U + 11) & 255) << 24, z = Z.charCodeAt(U + 12) & 255 | (Z.charCodeAt(U + 13) & 255) << 8 | (Z.charCodeAt(U + 14) & 255) << 16 | (Z.charCodeAt(U + 15) & 255) << 24;
    F = Math.imul(F, 597399067), F = F << 15 | F >>> 17, F = Math.imul(F, 2869860233), $ ^= F, $ = $ << 19 | $ >>> 13, $ += X, $ = Math.imul($, 5) + 1444728091, E = Math.imul(E, 2869860233), E = E << 16 | E >>> 16, E = Math.imul(E, 951274213), X ^= E, X = X << 17 | X >>> 15, X += Y, X = Math.imul(X, 5) + 197830471, R = Math.imul(R, 951274213), R = R << 17 | R >>> 15, R = Math.imul(R, 2716044179), Y ^= R, Y = Y << 15 | Y >>> 17, Y += Q, Y = Math.imul(Y, 5) + 2530024501, z = Math.imul(z, 2716044179), z = z << 13 | z >>> 19, z = Math.imul(z, 597399067), Q ^= z, Q = Q << 13 | Q >>> 19, Q += $, Q = Math.imul(Q, 5) + 850148119;
  }
  let G = 0, H = 0, N = 0, q = 0;
  switch (W) {
    case 15:
      q ^= Z.charCodeAt(K + 14) << 16;
    case 14:
      q ^= Z.charCodeAt(K + 13) << 8;
    case 13:
      q ^= Z.charCodeAt(K + 12), q = Math.imul(q, 2716044179), q = q << 13 | q >>> 19, q = Math.imul(q, 597399067), Q ^= q;
    case 12:
      N ^= Z.charCodeAt(K + 11) << 24;
    case 11:
      N ^= Z.charCodeAt(K + 10) << 16;
    case 10:
      N ^= Z.charCodeAt(K + 9) << 8;
    case 9:
      N ^= Z.charCodeAt(K + 8), N = Math.imul(N, 951274213), N = N << 17 | N >>> 15, N = Math.imul(N, 2716044179), Y ^= N;
    case 8:
      H ^= Z.charCodeAt(K + 7) << 24;
    case 7:
      H ^= Z.charCodeAt(K + 6) << 16;
    case 6:
      H ^= Z.charCodeAt(K + 5) << 8;
    case 5:
      H ^= Z.charCodeAt(K + 4), H = Math.imul(H, 2869860233), H = H << 16 | H >>> 16, H = Math.imul(H, 951274213), X ^= H;
    case 4:
      G ^= Z.charCodeAt(K + 3) << 24;
    case 3:
      G ^= Z.charCodeAt(K + 2) << 16;
    case 2:
      G ^= Z.charCodeAt(K + 1) << 8;
    case 1:
      G ^= Z.charCodeAt(K), G = Math.imul(G, 597399067), G = G << 15 | G >>> 17, G = Math.imul(G, 2869860233), $ ^= G;
  }
  return $ ^= Z.length, X ^= Z.length, Y ^= Z.length, Q ^= Z.length, $ += X, $ += Y, $ += Q, X += $, Y += $, Q += $, $ ^= $ >>> 16, $ = Math.imul($, 2246822507), $ ^= $ >>> 13, $ = Math.imul($, 3266489909), $ ^= $ >>> 16, X ^= X >>> 16, X = Math.imul(X, 2246822507), X ^= X >>> 13, X = Math.imul(X, 3266489909), X ^= X >>> 16, Y ^= Y >>> 16, Y = Math.imul(Y, 2246822507), Y ^= Y >>> 13, Y = Math.imul(Y, 3266489909), Y ^= Y >>> 16, Q ^= Q >>> 16, Q = Math.imul(Q, 2246822507), Q ^= Q >>> 13, Q = Math.imul(Q, 3266489909), Q ^= Q >>> 16, $ += X, $ += Y, $ += Q, X += $, Y += $, Q += $, ($ >>> 0).toString(16).padStart(8, "0") + (X >>> 0).toString(16).padStart(8, "0") + (Y >>> 0).toString(16).padStart(8, "0") + (Q >>> 0).toString(16).padStart(8, "0");
}

// node_modules/molstar/lib/mol-state/transform.js
var D8;
(function(Z) {
  Z.RootRef = "-=root=-";
  function J(A, B) {
    if (!B)
      return !1;
    if (typeof B.isCollapsed !== "undefined" && A.isCollapsed !== B.isCollapsed)
      return !0;
    if (typeof B.isHidden !== "undefined" && A.isHidden !== B.isHidden)
      return !0;
    if (typeof B.isGhost !== "undefined" && A.isGhost !== B.isGhost)
      return !0;
    if (typeof B.isLocked !== "undefined" && A.isLocked !== B.isLocked)
      return !0;
    return !1;
  }
  Z.isStateChange = J;
  function $(A, B) {
    if (!B)
      return !1;
    let T = !1;
    for (let w of Object.keys(B)) {
      let V = B[w], P = A[w];
      if (!!V === !!P)
        continue;
      T = !0, A[w] = V;
    }
    return T;
  }
  Z.assignState = $;
  function X(A, B) {
    if (!B)
      return !1;
    let T = !1;
    for (let w of Object.keys(B)) {
      let V = B[w], P = A[w];
      if (!!V === !!P)
        continue;
      if (T = !0, V !== void 0)
        A[w] = V;
      else
        delete A[w];
    }
    for (let w of Object.keys(A)) {
      let V = B[w], P = A[w];
      if (!!V === !!P)
        continue;
      if (T = !0, V !== void 0)
        A[w] = V;
      else
        delete A[w];
    }
    return T;
  }
  Z.syncState = X;
  function Y(A, B, T, w) {
    let V = w && w.ref ? w.ref : R6.create22(), P = void 0;
    if (w && w.tags)
      if (P = typeof w.tags === "string" ? [w.tags] : w.tags, P.length === 0)
        P = void 0;
      else
        P.sort();
    return {
      parent: A,
      transformer: B,
      state: (w === null || w === void 0 ? void 0 : w.state) || {},
      tags: P,
      ref: V,
      dependsOn: w && w.dependsOn,
      params: T,
      version: R6.create22()
    };
  }
  Z.create = Y;
  function Q(A, B) {
    return { ...A, params: B, version: R6.create22() };
  }
  Z.withParams = Q;
  function W(A, B) {
    if (!B)
      return A;
    return { ...A, state: { ...A.state, ...B } };
  }
  Z.withState = W;
  function K(A, B) {
    let T = void 0;
    if (B)
      if (T = typeof B === "string" ? [B] : B, T.length === 0)
        T = void 0;
      else
        T.sort();
    return { ...A, tags: T, version: R6.create22() };
  }
  Z.withTags = K;
  function G(A, B) {
    let T = void 0;
    if (B)
      if (T = typeof B === "string" ? [B] : B, T.length === 0)
        T = void 0;
      else
        T.sort();
    return { ...A, dependsOn: T, version: R6.create22() };
  }
  Z.withDependsOn = G;
  function H(A, B) {
    return { ...A, parent: B, version: R6.create22() };
  }
  Z.withParent = H;
  function N(A) {
    return Y(Z.RootRef, T1.ROOT, {}, { ref: Z.RootRef, state: A });
  }
  Z.createRoot = N;
  function q(A, B) {
    if (!A.tags)
      return !1;
    return A.tags.indexOf(B) >= 0;
  }
  Z.hasTag = q;
  function U(A, B) {
    if (!A.tags)
      return typeof B !== "string" && B.length === 0;
    if (typeof B === "string")
      return q(A, B);
    for (let T of B)
      if (A.tags.indexOf(T) < 0)
        return !1;
    return !0;
  }
  Z.hasTags = U;
  let F = {};
  function E(A) {
    var B, T;
    let w;
    try {
      w = zi((B = A.params) !== null && B !== void 0 ? B : F);
    } catch (V) {
      let P = A.transformer.definition.customSerialization ? A.transformer.definition.customSerialization.toJSON : R;
      w = zi(P((T = A.params) !== null && T !== void 0 ? T : F));
    }
    A.version = w;
  }
  Z.setParamsHashVersion = E;
  function R(A) {
    return A;
  }
  function z(A) {
    let B = A.transformer.definition.customSerialization ? A.transformer.definition.customSerialization.toJSON : R, T = void 0;
    for (let w of Object.keys(A.state)) {
      if (!A.state[w])
        continue;
      if (!T)
        T = {};
      T[w] = !0;
    }
    return {
      parent: A.parent,
      transformer: A.transformer.id,
      params: A.params ? B(A.params) : void 0,
      state: T,
      tags: A.tags,
      ref: A.ref,
      dependsOn: A.dependsOn,
      version: A.version
    };
  }
  Z.toJSON = z;
  function D(A) {
    let B = T1.get(A.transformer), T = B.definition.customSerialization ? B.definition.customSerialization.fromJSON : R;
    return {
      parent: A.parent,
      transformer: B,
      params: A.params ? T(A.params) : void 0,
      state: A.state || {},
      tags: A.tags,
      ref: A.ref,
      dependsOn: A.dependsOn,
      version: A.version
    };
  }
  Z.fromJSON = D;
})(D8 || (D8 = {}));

// node_modules/molstar/lib/mol-util/array.js
function yX(Z) {
  let J = -1 / 0;
  for (let $ = 0, X = Z.length;$ < X; ++$)
    if (Z[$] > J)
      J = Z[$];
  return J;
}
function ZR(Z) {
  let J = 1 / 0;
  for (let $ = 0, X = Z.length;$ < X; ++$)
    if (Z[$] < J)
      J = Z[$];
  return J;
}
function fQ(Z) {
  let J = 1 / 0, $ = -1 / 0;
  for (let X = 0, Y = Z.length;X < Y; ++X) {
    if (Z[X] < J)
      J = Z[X];
    if (Z[X] > $)
      $ = Z[X];
  }
  return [J, $];
}
function Di(Z, J = 1, $ = 0) {
  let X = Z.length, Y = 0;
  for (let Q = $;Q < X; Q += J)
    Y += Z[Q];
  return Y;
}
function JR(Z, J = 1, $ = 0) {
  return Di(Z, J, $) / (Z.length / J);
}
function $R(Z) {
  let J = Z.length, $ = 0;
  for (let X = 0;X < J; ++X) {
    let Y = Z[X];
    $ += Y * Y;
  }
  return Math.sqrt($ / J);
}
function uJ(Z, J) {
  for (let $ = 0, X = J ? Math.min(J, Z.length) : Z.length;$ < X; ++$)
    Z[$] = $;
  return Z;
}
function ZH(Z, J) {
  let $ = 0, X = !1;
  for (let Y = Z.length;$ < Y; $++)
    if (Z[$] === J) {
      X = !0;
      break;
    }
  if (!X)
    return !1;
  return XR(Z, $), !0;
}
function XR(Z, J) {
  for (let $ = J, X = Z.length - 1;$ < X; $++)
    Z[$] = Z[$ + 1];
  Z.pop();
}
function n9(Z, J) {
  if (Z.indexOf(J) >= 0)
    return !1;
  return Z.push(J), !0;
}
function L3(Z, J) {
  let $ = Z.indexOf(J);
  if ($ < 0)
    return !1;
  for (let X = $, Y = Z.length - 1;X < Y; X++)
    Z[X] = Z[X + 1];
  return Z.pop(), !0;
}
function CM(Z, J) {
  let $ = 0;
  for (let X = 0, Y = Z.length;X < Y; ++X)
    if (J.includes(Z[X]))
      $ += 1;
  return $;
}
function oO(Z, J) {
  if (!Z || Z.length === 0)
    return !J || J.length === 0;
  if (!J)
    return !1;
  let $ = Z.length;
  if ($ !== J.length)
    return !1;
  for (let X = 0;X < $; X++)
    if (Z[X] !== J[X])
      return !1;
  return !0;
}
function xK0(Z) {
  for (let J = 0, $ = Z.length;J < $; J++)
    if (Z[J] !== J)
      return !1;
  return !0;
}
function z_(Z, J, $) {
  for (let X = 0, Y = Z.length;X < Y; ++X)
    if (Z[X][0] === J) {
      Z[X][1] = $;
      return;
    }
  Z.push([J, $]);
}
function yK0(Z, J) {
  if (J === void 0)
    J = Z, Z = 0;
  let $ = Math.max(J - Z, 0), X = Array($);
  for (let Y = 0;Y < $; Y++)
    X[Y] = Z + Y;
  return X;
}

// node_modules/molstar/lib/mol-state/tree/transient.js
class xS {
  get childMutations() {
    if (this._childMutations)
      return this._childMutations;
    return this._childMutations = /* @__PURE__ */ new Map, this._childMutations;
  }
  get dependencyMutations() {
    if (this._dependencyMutations)
      return this._dependencyMutations;
    return this._dependencyMutations = /* @__PURE__ */ new Map, this._dependencyMutations;
  }
  changeNodes() {
    if (this.changedNodes)
      return;
    this.changedNodes = !0, this.transforms = this.transforms.asMutable();
  }
  changeChildren() {
    if (this.changedChildren)
      return;
    this.changedChildren = !0, this.children = this.children.asMutable();
  }
  changeDependencies() {
    if (this.changedDependencies)
      return;
    this.changedDependencies = !0, this.dependencies = this.dependencies.asMutable();
  }
  get root() {
    return this.transforms.get(D8.RootRef);
  }
  asTransient() {
    return this.asImmutable().asTransient();
  }
  addChild(Z, J) {
    if (this.changeChildren(), this.childMutations.has(Z))
      this.childMutations.get(Z).add(J);
    else {
      let $ = this.children.get(Z).asMutable();
      $.add(J), this.children.set(Z, $), this.childMutations.set(Z, $);
    }
  }
  removeChild(Z, J) {
    if (this.changeChildren(), this.childMutations.has(Z))
      this.childMutations.get(Z).remove(J);
    else {
      let $ = this.children.get(Z).asMutable();
      $.remove(J), this.children.set(Z, $), this.childMutations.set(Z, $);
    }
  }
  clearRoot() {
    let Z = D8.RootRef;
    if (this.children.get(Z).size === 0)
      return;
    this.changeChildren();
    let J = zK();
    this.children.set(Z, J), this.childMutations.set(Z, J);
  }
  mutateDependency(Z, J, $) {
    let X = this.dependencyMutations.get(Z);
    if (!X) {
      let Y = this.dependencies.get(Z);
      if (!Y && $ === "remove")
        return;
      this.changeDependencies(), X = Y ? Y.asMutable() : zK().asMutable(), this.dependencyMutations.set(Z, X), this.dependencies.set(Z, X);
    }
    if ($ === "add")
      X.add(J);
    else
      X.remove(J);
  }
  changeParent(Z, J) {
    D_(this.transforms, Z);
    let $ = this.transforms.get(Z);
    this.removeChild($.parent, Z), this.addChild(J, Z), this.changeNodes(), this.transforms.set(Z, D8.withParent($, J));
  }
  add(Z) {
    let J = Z.ref;
    if (this.transforms.has(Z.ref)) {
      if (this.transforms.get(Z.ref).parent !== Z.parent)
        Gr0(Z.ref);
    }
    let $ = this.children.get(Z.parent);
    if (!$)
      Hr0(Z.parent);
    if (!$.has(Z.ref))
      this.addChild(Z.parent, Z.ref);
    if (!this.children.has(Z.ref)) {
      if (!this.changedChildren)
        this.changedChildren = !0, this.children = this.children.asMutable();
      this.children.set(Z.ref, zK());
    }
    if (this.changeNodes(), this.transforms.set(J, Z), Z.dependsOn)
      for (let X of Z.dependsOn)
        this.mutateDependency(X, J, "add");
    return this;
  }
  setParams(Z, J) {
    D_(this.transforms, Z);
    let $ = this.transforms.get(Z);
    if (iL($.params, J))
      return !1;
    if (!this.changedNodes)
      this.changedNodes = !0, this.transforms = this.transforms.asMutable();
    return this.transforms.set($.ref, D8.withParams($, J)), !0;
  }
  setTags(Z, J) {
    D_(this.transforms, Z);
    let $ = this.transforms.get(Z), X = D8.withTags($, J);
    if (oO($.tags, X.tags))
      return !1;
    if (!this.changedNodes)
      this.changedNodes = !0, this.transforms = this.transforms.asMutable();
    return this.transforms.set($.ref, X), !0;
  }
  setDependsOn(Z, J) {
    D_(this.transforms, Z);
    let $ = this.transforms.get(Z), X = D8.withDependsOn($, J);
    if (oO($.dependsOn, X.dependsOn))
      return !1;
    if (!this.changedNodes)
      this.changedNodes = !0, this.transforms = this.transforms.asMutable();
    return this.transforms.set($.ref, X), !0;
  }
  assignState(Z, J) {
    D_(this.transforms, Z);
    let $ = this.transforms.get(Z);
    if (this._stateUpdates && this._stateUpdates.has(Z))
      return D8.assignState($.state, J), $;
    else {
      if (!this._stateUpdates)
        this._stateUpdates = /* @__PURE__ */ new Set;
      this._stateUpdates.add($.ref), this.changeNodes();
      let X = D8.withState($, J);
      return this.transforms.set(Z, X), X;
    }
  }
  remove(Z) {
    let J = this.transforms.get(Z);
    if (!J)
      return [];
    let $ = i9.subtreePostOrder(this, J);
    if (Z === D8.RootRef) {
      if ($.pop(), $.length === 0)
        return $;
      this.clearRoot();
    } else {
      if ($.length === 0)
        return $;
      this.removeChild(J.parent, J.ref);
    }
    this.changeNodes(), this.changeChildren();
    for (let Y of $)
      if (this.transforms.delete(Y.ref), this.children.delete(Y.ref), this._childMutations)
        this._childMutations.delete(Y.ref);
    let X = [];
    for (let Y of $) {
      if (Y.dependsOn)
        for (let Q of Y.dependsOn) {
          if (!this.transforms.has(Q))
            continue;
          this.mutateDependency(Q, Y.ref, "remove");
        }
      if (this.dependencies.has(Y.ref)) {
        let Q = this.dependencies.get(Y.ref).toArray();
        if (this.changeDependencies(), this.dependencies.delete(Y.ref), this._dependencyMutations)
          this._dependencyMutations.delete(Y.ref);
        for (let W of Q) {
          if (!this.transforms.has(W))
            continue;
          for (let K of this.remove(W))
            X[X.length] = K;
        }
      }
    }
    for (let Y of X)
      $[$.length] = Y;
    return $;
  }
  asImmutable() {
    if (!this.changedNodes && !this.changedChildren && !this._childMutations)
      return this.tree;
    if (this._childMutations)
      this._childMutations.forEach(Wr0, this.children);
    if (this._dependencyMutations)
      this._dependencyMutations.forEach(Kr0, this.dependencies);
    return i9.create(this.changedNodes ? this.transforms.asImmutable() : this.transforms, this.changedChildren ? this.children.asImmutable() : this.children, this.changedDependencies ? this.dependencies.asImmutable() : this.dependencies);
  }
  constructor(Z) {
    this.tree = Z, this.transforms = this.tree.transforms, this.children = this.tree.children, this.dependencies = this.tree.dependencies, this.changedNodes = !1, this.changedChildren = !1, this.changedDependencies = !1, this._childMutations = void 0, this._dependencyMutations = void 0, this._stateUpdates = void 0;
  }
}
function Wr0(Z, J) {
  this.set(J, Z.asImmutable());
}
function Kr0(Z, J) {
  if (Z.size === 0)
    this.delete(J);
  else
    this.set(J, Z.asImmutable());
}
function Gr0(Z) {
  throw new Error(`Transform '${Z}' is already present in the tree.`);
}
function Hr0(Z) {
  throw new Error(`Parent '${Z}' must be present in the tree.`);
}
function D_(Z, J) {
  if (!Z.has(J))
    throw new Error(`Node '${J}' is not present in the tree.`);
}

// node_modules/molstar/lib/mol-state/tree/immutable.js
var i9;
(function(Z) {

  class J {
    get root() {
      return this.transforms.get(D8.RootRef);
    }
    asTransient() {
      return new xS(this);
    }
    constructor(w, V, P) {
      this.transforms = w, this.children = V, this.dependencies = P;
    }
  }
  function $(w) {
    let V = w || D8.createRoot();
    return X(DK([[V.ref, V]]), DK([[V.ref, zK()]]), DK());
  }
  Z.createEmpty = $;
  function X(w, V, P) {
    return new J(w, V, P);
  }
  Z.create = X;
  function Y(w) {
    Q(this, this.tree.transforms.get(w));
  }
  function Q(w, V) {
    let P = w.tree.children.get(V.ref);
    if (P && P.size)
      P.forEach(Y, w);
    w.f(V, w.tree, w.state);
  }
  function W(w, V, P, I) {
    let S = { tree: w, state: P, f: I };
    return Q(S, V), S.state;
  }
  Z.doPostOrder = W;
  function K(w) {
    G(this, this.tree.transforms.get(w));
  }
  function G(w, V) {
    let P = w.f(V, w.tree, w.state);
    if (typeof P === "boolean" && !P)
      return;
    let I = w.tree.children.get(V.ref);
    if (I && I.size)
      I.forEach(K, w);
  }
  function H(w, V, P, I) {
    let S = { tree: w, state: P, f: I };
    return G(S, V), S.state;
  }
  Z.doPreOrder = H;
  function N(w, V, P) {
    P.push(w);
  }
  function q(w, V) {
    return W(w, V, [], N);
  }
  Z.subtreePostOrder = q;
  function U(w, V, P) {
    P.push(D8.toJSON(w));
  }
  function F(w) {
    let V = [];
    return H(w, w.root, V, U), { transforms: V };
  }
  Z.toJSON = F;
  function E(w) {
    let V = DK().asMutable(), P = DK().asMutable(), I = DK().asMutable();
    for (let f of w.transforms) {
      let v = D8.fromJSON(f);
      if (V.set(v.ref, v), !P.has(v.ref))
        P.set(v.ref, zK().asMutable());
      if (v.ref !== v.parent)
        P.get(v.parent).add(v.ref);
    }
    let S = /* @__PURE__ */ new Set;
    for (let f of w.transforms) {
      let v = f.ref;
      if (P.set(v, P.get(v).asImmutable()), !f.dependsOn)
        continue;
      for (let h of f.dependsOn)
        if (S.add(h), !I.has(h))
          I.set(h, zK([v]).asMutable());
        else
          I.get(h).add(v);
    }
    return S.forEach((f) => {
      I.set(f, I.get(f).asImmutable());
    }), X(V.asImmutable(), P.asImmutable(), I.asImmutable());
  }
  Z.fromJSON = E;
  function R(w) {
    console.log({
      tr: w.transforms.keySeq().toArray(),
      tr1: w.transforms.valueSeq().toArray().map((V) => V.ref),
      ch: w.children.keySeq().toArray()
    });
  }
  Z.dump = R;
  function z(w, V, P) {
    if (V === P)
      return !0;
    let S = w.children.get(V).values();
    while (!0) {
      let f = S.next();
      if (f.done)
        return !1;
      if (z(w, f.value, P))
        return !0;
    }
  }
  function D(w, V, P) {
    if (!w.transforms.has(V) || !w.transforms.has(P))
      return !1;
    return z(w, V, P);
  }
  Z.subtreeHasRef = D;
  function A(w, V) {
    let P = w.children.get(V);
    if (P.size !== 1)
      return V;
    let I = w.transforms.get(P.first());
    if (I === null || I === void 0 ? void 0 : I.transformer.definition.isDecorator)
      return A(w, I.ref);
    return V;
  }
  Z.getDecoratorRoot = A;
  function B(w, V) {
    for (let P of V) {
      let I = w.transforms.get(P);
      if (I)
        D8.setParamsHashVersion(I);
    }
  }
  Z.setParamHashVersion = B;
  function T(w, V) {
    let P = new Map(V.transforms.map((I) => [I.ref, I]));
    for (let I of w.transforms) {
      let S = P.get(I.ref);
      if (!S)
        continue;
      if (I.transformer !== S.transformer || I.version !== S.version)
        continue;
      I.params = S.params;
    }
  }
  Z.reuseTransformParams = T;
})(i9 || (i9 = {}));
// node_modules/molstar/lib/mol-state/state/selection.js
var f2;
(function(Z) {
  function J(t, Z0) {
    return $(t)(Z0);
  }
  Z.select = J;
  function $(t) {
    let Z0 = t ? t : H.root, U0;
    if (Y(Z0))
      U0 = Z0.compile();
    else if (X(Z0))
      U0 = H.byValue(Z0).compile();
    else if (Q(Z0))
      U0 = Z0;
    else
      U0 = H.byRef(Z0).compile();
    return U0;
  }
  Z.compile = $;
  function X(t) {
    return t.transform !== void 0 && t.status !== void 0;
  }
  function Y(t) {
    return t.compile !== void 0;
  }
  function Q(t) {
    return typeof t === "function";
  }
  let W = {
    select(t) {
      return J(this, t || this.state);
    }
  };
  function K(t, Z0) {
    W[t] = function(...U0) {
      return Z0.call(void 0, this, ...U0);
    };
  }
  function G(t) {
    return Object.create(W, { compile: { writable: !1, configurable: !1, value: t } });
  }
  let H;
  (function(t) {
    t.root = G(() => (N0) => [N0.cells.get(N0.tree.root.ref)]);
    function Z0(...N0) {
      return G(() => (q0) => {
        let A0 = [];
        for (let S0 of N0) {
          let a0 = q0.cells.get(S0);
          if (!a0)
            continue;
          A0.push(a0);
        }
        return A0;
      });
    }
    t.byRef = Z0;
    function U0(...N0) {
      return G(() => (q0) => N0);
    }
    t.byValue = U0;
    function a(N0, q0 = D8.RootRef) {
      return G(() => (A0) => {
        let S0 = { roots: [], cells: A0.cells, type: N0.type };
        return i9.doPreOrder(A0.tree, A0.tree.transforms.get(q0), S0, X0), S0.roots;
      });
    }
    t.rootsOfType = a;
    function Q0(N0, q0 = D8.RootRef) {
      return G(() => (A0) => {
        let S0 = { ret: [], cells: A0.cells, type: N0.type };
        return i9.doPreOrder(A0.tree, A0.tree.transforms.get(q0), S0, E0), S0.ret;
      });
    }
    t.ofType = Q0;
    function $0(N0, q0 = D8.RootRef) {
      return G(() => (A0) => {
        let S0 = { ret: [], cells: A0.cells, t: N0 };
        return i9.doPreOrder(A0.tree, A0.tree.transforms.get(q0), S0, V0), S0.ret;
      });
    }
    t.ofTransformer = $0;
    function R0(N0, q0 = D8.RootRef) {
      return G(() => (A0) => {
        let S0 = { ret: [], cells: A0.cells, t: N0 };
        return i9.doPreOrder(A0.tree, A0.tree.transforms.get(q0), S0, u0), S0.ret;
      });
    }
    t.ofTransformerWithError = R0;
    function X0(N0, q0, A0) {
      let S0 = A0.cells.get(N0.ref);
      if (S0 && S0.obj && S0.obj.type === A0.type)
        return A0.roots.push(S0), !1;
      return !0;
    }
    function E0(N0, q0, A0) {
      let S0 = A0.cells.get(N0.ref);
      if (S0 && S0.obj && S0.obj.type === A0.type)
        A0.ret.push(S0);
      return !0;
    }
    function V0(N0, q0, A0) {
      let S0 = A0.cells.get(N0.ref);
      if (S0 && S0.obj && S0.transform.transformer === A0.t)
        A0.ret.push(S0);
      return !0;
    }
    function u0(N0, q0, A0) {
      let S0 = A0.cells.get(N0.ref);
      if (S0 && S0.status === "error" && S0.transform.transformer === A0.t)
        A0.ret.push(S0);
      return !0;
    }
  })(H = Z.Generators || (Z.Generators = {})), K("flatMap", N);
  function N(t, Z0) {
    let U0 = $(t);
    return G(() => (a) => {
      let Q0 = [];
      for (let $0 of U0(a))
        for (let R0 of Z0($0, a))
          Q0.push(R0);
      return Q0;
    });
  }
  Z.flatMap = N, K("mapObject", q);
  function q(t, Z0) {
    let U0 = $(t);
    return G(() => (a) => {
      let Q0 = [];
      for (let $0 of U0(a)) {
        let R0 = Z0($0, a);
        if (R0)
          Q0.push(R0);
      }
      return Q0;
    });
  }
  Z.mapObject = q, K("unique", U);
  function U(t) {
    let Z0 = $(t);
    return G(() => (U0) => {
      let a = /* @__PURE__ */ new Set, Q0 = [];
      for (let $0 of Z0(U0)) {
        if (!$0)
          continue;
        if (!a.has($0.transform.ref))
          a.add($0.transform.ref), Q0.push($0);
      }
      return Q0;
    });
  }
  Z.unique = U, K("first", F);
  function F(t) {
    let Z0 = $(t);
    return G(() => (U0) => {
      let a = Z0(U0);
      return a.length ? [a[0]] : [];
    });
  }
  Z.first = F, K("filter", E);
  function E(t, Z0) {
    return N(t, (U0) => Z0(U0) ? [U0] : []);
  }
  Z.filter = E, K("withStatus", R);
  function R(t, Z0) {
    return E(t, (U0) => U0.status === Z0);
  }
  Z.withStatus = R, K("withTag", z);
  function z(t, Z0) {
    return E(t, (U0) => !!U0.transform.tags && U0.transform.tags.indexOf(Z0) >= 0);
  }
  Z.withTag = z, K("subtree", D);
  function D(t) {
    return N(t, (Z0, U0) => {
      let a = [];
      return i9.doPreOrder(U0.tree, U0.tree.transforms.get(Z0.transform.ref), a, (Q0, $0, R0) => {
        R0.push(Q0.ref);
      }), a.map((Q0) => U0.cells.get(Q0));
    });
  }
  Z.subtree = D, K("children", A);
  function A(t) {
    return N(t, (Z0, U0) => {
      let a = [];
      return U0.tree.children.get(Z0.transform.ref).forEach((Q0) => a.push(U0.cells.get(Q0))), a;
    });
  }
  Z.children = A, K("ofType", B);
  function B(t, Z0) {
    return E(t, (U0) => U0.obj ? U0.obj.type === Z0.type : !1);
  }
  Z.ofType = B, K("ancestor", T);
  function T(t, Z0) {
    return U(q(t, (U0, a) => h(a.tree, a.cells, U0.transform.ref, Z0)));
  }
  Z.ancestor = T, K("ancestorOfType", w);
  function w(t, Z0) {
    return U(q(t, (U0, a) => g(a.tree, a.cells, U0.transform.ref, Z0)));
  }
  Z.ancestorOfType = w, K("ancestorWithTransformer", V);
  function V(t, Z0) {
    return U(q(t, (U0, a) => b(a.tree, a.cells, U0.transform.ref, Z0)));
  }
  Z.ancestorWithTransformer = V, K("withTransformer", P);
  function P(t, Z0) {
    return E(t, (U0) => U0.transform.transformer === Z0);
  }
  Z.withTransformer = P, K("root", I);
  function I(t, Z0) {
    return U(q(t, (U0, a) => x(a.tree, a.cells, U0.transform.ref, Z0)));
  }
  Z.root = I, K("rootOfType", S);
  function S(t, Z0) {
    return U(q(t, (U0, a) => m(a.tree, a.cells, U0.transform.ref, Z0)));
  }
  Z.rootOfType = S, K("parent", f);
  function f(t) {
    return U(q(t, (Z0, U0) => U0.cells.get(U0.tree.transforms.get(Z0.transform.ref).parent)));
  }
  Z.parent = f;
  function v(t, Z0, U0, a, Q0) {
    let $0 = t.transforms.get(U0), R0 = void 0;
    while (!0) {
      $0 = t.transforms.get($0.parent);
      let X0 = Z0.get($0.ref);
      if (X0.obj && a(X0)) {
        if (R0 = X0, Q0)
          return R0;
      }
      if ($0.ref === D8.RootRef)
        return R0;
    }
  }
  function h(t, Z0, U0, a) {
    return v(t, Z0, U0, a, !0);
  }
  Z.findAncestor = h;
  function x(t, Z0, U0, a) {
    return v(t, Z0, U0, a, !1);
  }
  Z.findRoot = x;
  function b(t, Z0, U0, a) {
    return h(t, Z0, U0, Array.isArray(a) ? (Q0) => a.indexOf(Q0.transform.transformer) >= 0 : (Q0) => Q0.transform.transformer === a);
  }
  Z.findAncestorWithTransformer = b;
  function g(t, Z0, U0, a) {
    return h(t, Z0, U0, i(a));
  }
  Z.findAncestorOfType = g;
  function m(t, Z0, U0, a) {
    return x(t, Z0, U0, i(a));
  }
  Z.findRootOfType = m;
  function i(t) {
    return Array.isArray(t) ? (Z0) => {
      for (let U0 of t)
        if (U0.type === Z0.obj.type)
          return !0;
    } : (Z0) => Z0.obj.type === t.type;
  }
  function r(t, Z0, U0) {
    return i9.doPreOrder(t, t.transforms.get(Z0), { refs: {}, tags: U0 }, Y0).refs;
  }
  Z.findUniqueTagsInSubtree = r;
  function Y0(t, Z0, U0) {
    if (t.tags)
      for (let a of t.tags) {
        if (!U0.tags.has(a))
          continue;
        U0.refs[a] = t.ref;
        break;
      }
    return !0;
  }
  function c(t, Z0, U0) {
    return i9.doPreOrder(t, t.transforms.get(Z0), { ref: void 0, tag: U0 }, n).ref;
  }
  Z.findTagInSubtree = c;
  function n(t, Z0, U0) {
    if (t.tags && t.tags.indexOf(U0.tag) >= 0)
      return U0.ref = t.ref, !1;
    return !0;
  }
  function l(t, Z0, U0) {
    return i9.doPreOrder(t, t.transforms.get(Z0), { refs: [], tags: U0 }, u).refs;
  }
  Z.findWithAllTags = l;
  function u(t, Z0, U0) {
    if (t.tags) {
      let a = U0.tags.size, Q0 = 0;
      for (let $0 of t.tags) {
        if (!U0.tags.has($0))
          continue;
        if (Q0++, Q0 === a) {
          U0.refs.push(t);
          break;
        }
      }
    } else if (U0.tags.size === 0)
      U0.refs.push(t);
  }
  function G0(t, Z0, U0) {
    if (t.transforms.get(Z0).transformer === U0)
      return t.cells.get(Z0);
    let Q0 = t.tree.children.get(Z0);
    if (Q0.size !== 1)
      return;
    let $0 = Q0.first();
    if ($0 && t.transforms.get($0).transformer.definition.isDecorator)
      return G0(t, $0, U0);
  }
  Z.tryFindDecorator = G0;
  function F0(t, Z0) {
    let U0 = t.tree.children.get(Z0);
    if (U0.size !== 1)
      return t.cells.get(Z0);
    let a = U0.first();
    if (a && t.transforms.get(a).transformer.definition.isDecorator)
      return F0(t, a);
    return t.cells.get(Z0);
  }
  Z.getDecorated = F0;
})(f2 || (f2 = {}));

// node_modules/tslib/tslib.es6.mjs
var Mi = function(Z, J) {
  return Mi = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function($, X) {
    $.__proto__ = X;
  } || function($, X) {
    for (var Y in X)
      if (Object.prototype.hasOwnProperty.call(X, Y))
        $[Y] = X[Y];
  }, Mi(Z, J);
};
function hQ(Z, J) {
  if (typeof J !== "function" && J !== null)
    throw new TypeError("Class extends value " + String(J) + " is not a constructor or null");
  Mi(Z, J);
  function $() {
    this.constructor = Z;
  }
  Z.prototype = J === null ? Object.create(J) : ($.prototype = J.prototype, new $);
}
function gK0(Z, J, $, X) {
  function Y(Q) {
    return Q instanceof $ ? Q : new $(function(W) {
      W(Q);
    });
  }
  return new ($ || ($ = Promise))(function(Q, W) {
    function K(N) {
      try {
        H(X.next(N));
      } catch (q) {
        W(q);
      }
    }
    function G(N) {
      try {
        H(X.throw(N));
      } catch (q) {
        W(q);
      }
    }
    function H(N) {
      N.done ? Q(N.value) : Y(N.value).then(K, G);
    }
    H((X = X.apply(Z, J || [])).next());
  });
}
function yS(Z, J) {
  var $ = { label: 0, sent: function() {
    if (Q[0] & 1)
      throw Q[1];
    return Q[1];
  }, trys: [], ops: [] }, X, Y, Q, W = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
  return W.next = K(0), W.throw = K(1), W.return = K(2), typeof Symbol === "function" && (W[Symbol.iterator] = function() {
    return this;
  }), W;
  function K(H) {
    return function(N) {
      return G([H, N]);
    };
  }
  function G(H) {
    if (X)
      throw new TypeError("Generator is already executing.");
    while (W && (W = 0, H[0] && ($ = 0)), $)
      try {
        if (X = 1, Y && (Q = H[0] & 2 ? Y.return : H[0] ? Y.throw || ((Q = Y.return) && Q.call(Y), 0) : Y.next) && !(Q = Q.call(Y, H[1])).done)
          return Q;
        if (Y = 0, Q)
          H = [H[0] & 2, Q.value];
        switch (H[0]) {
          case 0:
          case 1:
            Q = H;
            break;
          case 4:
            return $.label++, { value: H[1], done: !1 };
          case 5:
            $.label++, Y = H[1], H = [0];
            continue;
          case 7:
            H = $.ops.pop(), $.trys.pop();
            continue;
          default:
            if ((Q = $.trys, !(Q = Q.length > 0 && Q[Q.length - 1])) && (H[0] === 6 || H[0] === 2)) {
              $ = 0;
              continue;
            }
            if (H[0] === 3 && (!Q || H[1] > Q[0] && H[1] < Q[3])) {
              $.label = H[1];
              break;
            }
            if (H[0] === 6 && $.label < Q[1]) {
              $.label = Q[1], Q = H;
              break;
            }
            if (Q && $.label < Q[2]) {
              $.label = Q[2], $.ops.push(H);
              break;
            }
            if (Q[2])
              $.ops.pop();
            $.trys.pop();
            continue;
        }
        H = J.call(Z, $);
      } catch (N) {
        H = [6, N], Y = 0;
      } finally {
        X = Q = 0;
      }
    if (H[0] & 5)
      throw H[1];
    return { value: H[0] ? H[1] : void 0, done: !0 };
  }
}
function kF(Z) {
  var J = typeof Symbol === "function" && Symbol.iterator, $ = J && Z[J], X = 0;
  if ($)
    return $.call(Z);
  if (Z && typeof Z.length === "number")
    return {
      next: function() {
        if (Z && X >= Z.length)
          Z = void 0;
        return { value: Z && Z[X++], done: !Z };
      }
    };
  throw new TypeError(J ? "Object is not iterable." : "Symbol.iterator is not defined.");
}
function vF(Z, J) {
  var $ = typeof Symbol === "function" && Z[Symbol.iterator];
  if (!$)
    return Z;
  var X = $.call(Z), Y, Q = [], W;
  try {
    while ((J === void 0 || J-- > 0) && !(Y = X.next()).done)
      Q.push(Y.value);
  } catch (K) {
    W = { error: K };
  } finally {
    try {
      if (Y && !Y.done && ($ = X.return))
        $.call(X);
    } finally {
      if (W)
        throw W.error;
    }
  }
  return Q;
}
function SF(Z, J, $) {
  if ($ || arguments.length === 2) {
    for (var X = 0, Y = J.length, Q;X < Y; X++)
      if (Q || !(X in J)) {
        if (!Q)
          Q = Array.prototype.slice.call(J, 0, X);
        Q[X] = J[X];
      }
  }
  return Z.concat(Q || Array.prototype.slice.call(J));
}
function sO(Z) {
  return this instanceof sO ? (this.v = Z, this) : new sO(Z);
}
function mK0(Z, J, $) {
  if (!Symbol.asyncIterator)
    throw new TypeError("Symbol.asyncIterator is not defined.");
  var X = $.apply(Z, J || []), Y, Q = [];
  return Y = Object.create((typeof AsyncIterator === "function" ? AsyncIterator : Object).prototype), K("next"), K("throw"), K("return", W), Y[Symbol.asyncIterator] = function() {
    return this;
  }, Y;
  function W(F) {
    return function(E) {
      return Promise.resolve(E).then(F, q);
    };
  }
  function K(F, E) {
    if (X[F]) {
      if (Y[F] = function(R) {
        return new Promise(function(z, D) {
          Q.push([F, R, z, D]) > 1 || G(F, R);
        });
      }, E)
        Y[F] = E(Y[F]);
    }
  }
  function G(F, E) {
    try {
      H(X[F](E));
    } catch (R) {
      U(Q[0][3], R);
    }
  }
  function H(F) {
    F.value instanceof sO ? Promise.resolve(F.value.v).then(N, q) : U(Q[0][2], F);
  }
  function N(F) {
    G("next", F);
  }
  function q(F) {
    G("throw", F);
  }
  function U(F, E) {
    if (F(E), Q.shift(), Q.length)
      G(Q[0][0], Q[0][1]);
  }
}
function dK0(Z) {
  if (!Symbol.asyncIterator)
    throw new TypeError("Symbol.asyncIterator is not defined.");
  var J = Z[Symbol.asyncIterator], $;
  return J ? J.call(Z) : (Z = typeof kF === "function" ? kF(Z) : Z[Symbol.iterator](), $ = {}, X("next"), X("throw"), X("return"), $[Symbol.asyncIterator] = function() {
    return this;
  }, $);
  function X(Q) {
    $[Q] = Z[Q] && function(W) {
      return new Promise(function(K, G) {
        W = Z[Q](W), Y(K, G, W.done, W.value);
      });
    };
  }
  function Y(Q, W, K, G) {
    Promise.resolve(G).then(function(H) {
      Q({ value: H, done: K });
    }, W);
  }
}

// node_modules/rxjs/dist/esm5/internal/util/isFunction.js
function o9(Z) {
  return typeof Z === "function";
}

// node_modules/rxjs/dist/esm5/internal/util/createErrorClass.js
function gS(Z) {
  var J = function(X) {
    Error.call(X), X.stack = new Error().stack;
  }, $ = Z(J);
  return $.prototype = Object.create(Error.prototype), $.prototype.constructor = $, $;
}

// node_modules/rxjs/dist/esm5/internal/util/UnsubscriptionError.js
var mS = gS(function(Z) {
  return function J($) {
    Z(this), this.message = $ ? $.length + ` errors occurred during unsubscription:
` + $.map(function(X, Y) {
      return Y + 1 + ") " + X.toString();
    }).join(`
  `) : "", this.name = "UnsubscriptionError", this.errors = $;
  };
});

// node_modules/rxjs/dist/esm5/internal/util/arrRemove.js
function aO(Z, J) {
  if (Z) {
    var $ = Z.indexOf(J);
    0 <= $ && Z.splice($, 1);
  }
}

// node_modules/rxjs/dist/esm5/internal/Subscription.js
var YR = function() {
  function Z(J) {
    this.initialTeardown = J, this.closed = !1, this._parentage = null, this._finalizers = null;
  }
  return Z.prototype.unsubscribe = function() {
    var J, $, X, Y, Q;
    if (!this.closed) {
      this.closed = !0;
      var W = this._parentage;
      if (W)
        if (this._parentage = null, Array.isArray(W))
          try {
            for (var K = kF(W), G = K.next();!G.done; G = K.next()) {
              var H = G.value;
              H.remove(this);
            }
          } catch (R) {
            J = { error: R };
          } finally {
            try {
              if (G && !G.done && ($ = K.return))
                $.call(K);
            } finally {
              if (J)
                throw J.error;
            }
          }
        else
          W.remove(this);
      var N = this.initialTeardown;
      if (o9(N))
        try {
          N();
        } catch (R) {
          Q = R instanceof mS ? R.errors : [R];
        }
      var q = this._finalizers;
      if (q) {
        this._finalizers = null;
        try {
          for (var U = kF(q), F = U.next();!F.done; F = U.next()) {
            var E = F.value;
            try {
              pK0(E);
            } catch (R) {
              if (Q = Q !== null && Q !== void 0 ? Q : [], R instanceof mS)
                Q = SF(SF([], vF(Q)), vF(R.errors));
              else
                Q.push(R);
            }
          }
        } catch (R) {
          X = { error: R };
        } finally {
          try {
            if (F && !F.done && (Y = U.return))
              Y.call(U);
          } finally {
            if (X)
              throw X.error;
          }
        }
      }
      if (Q)
        throw new mS(Q);
    }
  }, Z.prototype.add = function(J) {
    var $;
    if (J && J !== this)
      if (this.closed)
        pK0(J);
      else {
        if (J instanceof Z) {
          if (J.closed || J._hasParent(this))
            return;
          J._addParent(this);
        }
        (this._finalizers = ($ = this._finalizers) !== null && $ !== void 0 ? $ : []).push(J);
      }
  }, Z.prototype._hasParent = function(J) {
    var $ = this._parentage;
    return $ === J || Array.isArray($) && $.includes(J);
  }, Z.prototype._addParent = function(J) {
    var $ = this._parentage;
    this._parentage = Array.isArray($) ? ($.push(J), $) : $ ? [$, J] : J;
  }, Z.prototype._removeParent = function(J) {
    var $ = this._parentage;
    if ($ === J)
      this._parentage = null;
    else if (Array.isArray($))
      aO($, J);
  }, Z.prototype.remove = function(J) {
    var $ = this._finalizers;
    if ($ && aO($, J), J instanceof Z)
      J._removeParent(this);
  }, Z.EMPTY = function() {
    var J = new Z;
    return J.closed = !0, J;
  }(), Z;
}();
var Ai = YR.EMPTY;
function dS(Z) {
  return Z instanceof YR || Z && "closed" in Z && o9(Z.remove) && o9(Z.add) && o9(Z.unsubscribe);
}
function pK0(Z) {
  if (o9(Z))
    Z();
  else
    Z.unsubscribe();
}

// node_modules/rxjs/dist/esm5/internal/config.js
var JH = {
  onUnhandledError: null,
  onStoppedNotification: null,
  Promise: void 0,
  useDeprecatedSynchronousErrorHandling: !1,
  useDeprecatedNextContext: !1
};

// node_modules/rxjs/dist/esm5/internal/scheduler/timeoutProvider.js
var kM = {
  setTimeout: function(Z, J) {
    var $ = [];
    for (var X = 2;X < arguments.length; X++)
      $[X - 2] = arguments[X];
    var Y = kM.delegate;
    if (Y === null || Y === void 0 ? void 0 : Y.setTimeout)
      return Y.setTimeout.apply(Y, SF([Z, J], vF($)));
    return setTimeout.apply(void 0, SF([Z, J], vF($)));
  },
  clearTimeout: function(Z) {
    var J = kM.delegate;
    return ((J === null || J === void 0 ? void 0 : J.clearTimeout) || clearTimeout)(Z);
  },
  delegate: void 0
};

// node_modules/rxjs/dist/esm5/internal/util/reportUnhandledError.js
function pS(Z) {
  kM.setTimeout(function() {
    var J = JH.onUnhandledError;
    if (J)
      J(Z);
    else
      throw Z;
  });
}

// node_modules/rxjs/dist/esm5/internal/util/noop.js
function Bi() {}

// node_modules/rxjs/dist/esm5/internal/NotificationFactories.js
var uK0 = function() {
  return wi("C", void 0, void 0);
}();
function cK0(Z) {
  return wi("E", void 0, Z);
}
function lK0(Z) {
  return wi("N", Z, void 0);
}
function wi(Z, J, $) {
  return {
    kind: Z,
    value: J,
    error: $
  };
}

// node_modules/rxjs/dist/esm5/internal/util/errorContext.js
var rO = null;
function vM(Z) {
  if (JH.useDeprecatedSynchronousErrorHandling) {
    var J = !rO;
    if (J)
      rO = { errorThrown: !1, error: null };
    if (Z(), J) {
      var $ = rO, X = $.errorThrown, Y = $.error;
      if (rO = null, X)
        throw Y;
    }
  } else
    Z();
}
function nK0(Z) {
  if (JH.useDeprecatedSynchronousErrorHandling && rO)
    rO.errorThrown = !0, rO.error = Z;
}

// node_modules/rxjs/dist/esm5/internal/Subscriber.js
var M_ = function(Z) {
  hQ(J, Z);
  function J($) {
    var X = Z.call(this) || this;
    if (X.isStopped = !1, $) {
      if (X.destination = $, dS($))
        $.add(X);
    } else
      X.destination = Ur0;
    return X;
  }
  return J.create = function($, X, Y) {
    return new cS($, X, Y);
  }, J.prototype.next = function($) {
    if (this.isStopped)
      Ti(lK0($), this);
    else
      this._next($);
  }, J.prototype.error = function($) {
    if (this.isStopped)
      Ti(cK0($), this);
    else
      this.isStopped = !0, this._error($);
  }, J.prototype.complete = function() {
    if (this.isStopped)
      Ti(uK0, this);
    else
      this.isStopped = !0, this._complete();
  }, J.prototype.unsubscribe = function() {
    if (!this.closed)
      this.isStopped = !0, Z.prototype.unsubscribe.call(this), this.destination = null;
  }, J.prototype._next = function($) {
    this.destination.next($);
  }, J.prototype._error = function($) {
    try {
      this.destination.error($);
    } finally {
      this.unsubscribe();
    }
  }, J.prototype._complete = function() {
    try {
      this.destination.complete();
    } finally {
      this.unsubscribe();
    }
  }, J;
}(YR);
var Nr0 = Function.prototype.bind;
function ji(Z, J) {
  return Nr0.call(Z, J);
}
var qr0 = function() {
  function Z(J) {
    this.partialObserver = J;
  }
  return Z.prototype.next = function(J) {
    var $ = this.partialObserver;
    if ($.next)
      try {
        $.next(J);
      } catch (X) {
        uS(X);
      }
  }, Z.prototype.error = function(J) {
    var $ = this.partialObserver;
    if ($.error)
      try {
        $.error(J);
      } catch (X) {
        uS(X);
      }
    else
      uS(J);
  }, Z.prototype.complete = function() {
    var J = this.partialObserver;
    if (J.complete)
      try {
        J.complete();
      } catch ($) {
        uS($);
      }
  }, Z;
}(), cS = function(Z) {
  hQ(J, Z);
  function J($, X, Y) {
    var Q = Z.call(this) || this, W;
    if (o9($) || !$)
      W = {
        next: $ !== null && $ !== void 0 ? $ : void 0,
        error: X !== null && X !== void 0 ? X : void 0,
        complete: Y !== null && Y !== void 0 ? Y : void 0
      };
    else {
      var K;
      if (Q && JH.useDeprecatedNextContext)
        K = Object.create($), K.unsubscribe = function() {
          return Q.unsubscribe();
        }, W = {
          next: $.next && ji($.next, K),
          error: $.error && ji($.error, K),
          complete: $.complete && ji($.complete, K)
        };
      else
        W = $;
    }
    return Q.destination = new qr0(W), Q;
  }
  return J;
}(M_);
function uS(Z) {
  if (JH.useDeprecatedSynchronousErrorHandling)
    nK0(Z);
  else
    pS(Z);
}
function Fr0(Z) {
  throw Z;
}
function Ti(Z, J) {
  var $ = JH.onStoppedNotification;
  $ && kM.setTimeout(function() {
    return $(Z, J);
  });
}
var Ur0 = {
  closed: !0,
  next: Bi,
  error: Fr0,
  complete: Bi
};

// node_modules/rxjs/dist/esm5/internal/symbol/observable.js
var SM = function() {
  return typeof Symbol === "function" && Symbol.observable || "@@observable";
}();

// node_modules/rxjs/dist/esm5/internal/util/identity.js
function fM(Z) {
  return Z;
}

// node_modules/rxjs/dist/esm5/internal/util/pipe.js
function iK0(Z) {
  if (Z.length === 0)
    return fM;
  if (Z.length === 1)
    return Z[0];
  return function J($) {
    return Z.reduce(function(X, Y) {
      return Y(X);
    }, $);
  };
}

// node_modules/rxjs/dist/esm5/internal/Observable.js
var r$ = function() {
  function Z(J) {
    if (J)
      this._subscribe = J;
  }
  return Z.prototype.lift = function(J) {
    var $ = new Z;
    return $.source = this, $.operator = J, $;
  }, Z.prototype.subscribe = function(J, $, X) {
    var Y = this, Q = Rr0(J) ? J : new cS(J, $, X);
    return vM(function() {
      var W = Y, K = W.operator, G = W.source;
      Q.add(K ? K.call(Q, G) : G ? Y._subscribe(Q) : Y._trySubscribe(Q));
    }), Q;
  }, Z.prototype._trySubscribe = function(J) {
    try {
      return this._subscribe(J);
    } catch ($) {
      J.error($);
    }
  }, Z.prototype.forEach = function(J, $) {
    var X = this;
    return $ = oK0($), new $(function(Y, Q) {
      var W = new cS({
        next: function(K) {
          try {
            J(K);
          } catch (G) {
            Q(G), W.unsubscribe();
          }
        },
        error: Q,
        complete: Y
      });
      X.subscribe(W);
    });
  }, Z.prototype._subscribe = function(J) {
    var $;
    return ($ = this.source) === null || $ === void 0 ? void 0 : $.subscribe(J);
  }, Z.prototype[SM] = function() {
    return this;
  }, Z.prototype.pipe = function() {
    var J = [];
    for (var $ = 0;$ < arguments.length; $++)
      J[$] = arguments[$];
    return iK0(J)(this);
  }, Z.prototype.toPromise = function(J) {
    var $ = this;
    return J = oK0(J), new J(function(X, Y) {
      var Q;
      $.subscribe(function(W) {
        return Q = W;
      }, function(W) {
        return Y(W);
      }, function() {
        return X(Q);
      });
    });
  }, Z.create = function(J) {
    return new Z(J);
  }, Z;
}();
function oK0(Z) {
  var J;
  return (J = Z !== null && Z !== void 0 ? Z : JH.Promise) !== null && J !== void 0 ? J : Promise;
}
function Lr0(Z) {
  return Z && o9(Z.next) && o9(Z.error) && o9(Z.complete);
}
function Rr0(Z) {
  return Z && Z instanceof M_ || Lr0(Z) && dS(Z);
}

// node_modules/rxjs/dist/esm5/internal/util/lift.js
function Er0(Z) {
  return o9(Z === null || Z === void 0 ? void 0 : Z.lift);
}
function KY(Z) {
  return function(J) {
    if (Er0(J))
      return J.lift(function($) {
        try {
          return Z($, this);
        } catch (X) {
          this.error(X);
        }
      });
    throw new TypeError("Unable to lift unknown Observable type");
  };
}

// node_modules/rxjs/dist/esm5/internal/operators/OperatorSubscriber.js
function GY(Z, J, $, X, Y) {
  return new Or0(Z, J, $, X, Y);
}
var Or0 = function(Z) {
  hQ(J, Z);
  function J($, X, Y, Q, W, K) {
    var G = Z.call(this, $) || this;
    return G.onFinalize = W, G.shouldUnsubscribe = K, G._next = X ? function(H) {
      try {
        X(H);
      } catch (N) {
        $.error(N);
      }
    } : Z.prototype._next, G._error = Q ? function(H) {
      try {
        Q(H);
      } catch (N) {
        $.error(N);
      } finally {
        this.unsubscribe();
      }
    } : Z.prototype._error, G._complete = Y ? function() {
      try {
        Y();
      } catch (H) {
        $.error(H);
      } finally {
        this.unsubscribe();
      }
    } : Z.prototype._complete, G;
  }
  return J.prototype.unsubscribe = function() {
    var $;
    if (!this.shouldUnsubscribe || this.shouldUnsubscribe()) {
      var X = this.closed;
      Z.prototype.unsubscribe.call(this), !X && (($ = this.onFinalize) === null || $ === void 0 || $.call(this));
    }
  }, J;
}(M_);

// node_modules/rxjs/dist/esm5/internal/util/ObjectUnsubscribedError.js
var sK0 = gS(function(Z) {
  return function J() {
    Z(this), this.name = "ObjectUnsubscribedError", this.message = "object unsubscribed";
  };
});

// node_modules/rxjs/dist/esm5/internal/Subject.js
var P6 = function(Z) {
  hQ(J, Z);
  function J() {
    var $ = Z.call(this) || this;
    return $.closed = !1, $.currentObservers = null, $.observers = [], $.isStopped = !1, $.hasError = !1, $.thrownError = null, $;
  }
  return J.prototype.lift = function($) {
    var X = new aK0(this, this);
    return X.operator = $, X;
  }, J.prototype._throwIfClosed = function() {
    if (this.closed)
      throw new sK0;
  }, J.prototype.next = function($) {
    var X = this;
    vM(function() {
      var Y, Q;
      if (X._throwIfClosed(), !X.isStopped) {
        if (!X.currentObservers)
          X.currentObservers = Array.from(X.observers);
        try {
          for (var W = kF(X.currentObservers), K = W.next();!K.done; K = W.next()) {
            var G = K.value;
            G.next($);
          }
        } catch (H) {
          Y = { error: H };
        } finally {
          try {
            if (K && !K.done && (Q = W.return))
              Q.call(W);
          } finally {
            if (Y)
              throw Y.error;
          }
        }
      }
    });
  }, J.prototype.error = function($) {
    var X = this;
    vM(function() {
      if (X._throwIfClosed(), !X.isStopped) {
        X.hasError = X.isStopped = !0, X.thrownError = $;
        var Y = X.observers;
        while (Y.length)
          Y.shift().error($);
      }
    });
  }, J.prototype.complete = function() {
    var $ = this;
    vM(function() {
      if ($._throwIfClosed(), !$.isStopped) {
        $.isStopped = !0;
        var X = $.observers;
        while (X.length)
          X.shift().complete();
      }
    });
  }, J.prototype.unsubscribe = function() {
    this.isStopped = this.closed = !0, this.observers = this.currentObservers = null;
  }, Object.defineProperty(J.prototype, "observed", {
    get: function() {
      var $;
      return (($ = this.observers) === null || $ === void 0 ? void 0 : $.length) > 0;
    },
    enumerable: !1,
    configurable: !0
  }), J.prototype._trySubscribe = function($) {
    return this._throwIfClosed(), Z.prototype._trySubscribe.call(this, $);
  }, J.prototype._subscribe = function($) {
    return this._throwIfClosed(), this._checkFinalizedStatuses($), this._innerSubscribe($);
  }, J.prototype._innerSubscribe = function($) {
    var X = this, Y = this, Q = Y.hasError, W = Y.isStopped, K = Y.observers;
    if (Q || W)
      return Ai;
    return this.currentObservers = null, K.push($), new YR(function() {
      X.currentObservers = null, aO(K, $);
    });
  }, J.prototype._checkFinalizedStatuses = function($) {
    var X = this, Y = X.hasError, Q = X.thrownError, W = X.isStopped;
    if (Y)
      $.error(Q);
    else if (W)
      $.complete();
  }, J.prototype.asObservable = function() {
    var $ = new r$;
    return $.source = this, $;
  }, J.create = function($, X) {
    return new aK0($, X);
  }, J;
}(r$);
var aK0 = function(Z) {
  hQ(J, Z);
  function J($, X) {
    var Y = Z.call(this) || this;
    return Y.destination = $, Y.source = X, Y;
  }
  return J.prototype.next = function($) {
    var X, Y;
    (Y = (X = this.destination) === null || X === void 0 ? void 0 : X.next) === null || Y === void 0 || Y.call(X, $);
  }, J.prototype.error = function($) {
    var X, Y;
    (Y = (X = this.destination) === null || X === void 0 ? void 0 : X.error) === null || Y === void 0 || Y.call(X, $);
  }, J.prototype.complete = function() {
    var $, X;
    (X = ($ = this.destination) === null || $ === void 0 ? void 0 : $.complete) === null || X === void 0 || X.call($);
  }, J.prototype._subscribe = function($) {
    var X, Y;
    return (Y = (X = this.source) === null || X === void 0 ? void 0 : X.subscribe($)) !== null && Y !== void 0 ? Y : Ai;
  }, J;
}(P6);
// node_modules/rxjs/dist/esm5/internal/BehaviorSubject.js
var G$ = function(Z) {
  hQ(J, Z);
  function J($) {
    var X = Z.call(this) || this;
    return X._value = $, X;
  }
  return Object.defineProperty(J.prototype, "value", {
    get: function() {
      return this.getValue();
    },
    enumerable: !1,
    configurable: !0
  }), J.prototype._subscribe = function($) {
    var X = Z.prototype._subscribe.call(this, $);
    return !X.closed && $.next(this._value), X;
  }, J.prototype.getValue = function() {
    var $ = this, X = $.hasError, Y = $.thrownError, Q = $._value;
    if (X)
      throw Y;
    return this._throwIfClosed(), Q;
  }, J.prototype.next = function($) {
    Z.prototype.next.call(this, this._value = $);
  }, J;
}(P6);
// node_modules/rxjs/dist/esm5/internal/scheduler/dateTimestampProvider.js
var _i = {
  now: function() {
    return (_i.delegate || Date).now();
  },
  delegate: void 0
};

// node_modules/rxjs/dist/esm5/internal/scheduler/Action.js
var rK0 = function(Z) {
  hQ(J, Z);
  function J($, X) {
    return Z.call(this) || this;
  }
  return J.prototype.schedule = function($, X) {
    if (X === void 0)
      X = 0;
    return this;
  }, J;
}(YR);

// node_modules/rxjs/dist/esm5/internal/scheduler/intervalProvider.js
var A_ = {
  setInterval: function(Z, J) {
    var $ = [];
    for (var X = 2;X < arguments.length; X++)
      $[X - 2] = arguments[X];
    var Y = A_.delegate;
    if (Y === null || Y === void 0 ? void 0 : Y.setInterval)
      return Y.setInterval.apply(Y, SF([Z, J], vF($)));
    return setInterval.apply(void 0, SF([Z, J], vF($)));
  },
  clearInterval: function(Z) {
    var J = A_.delegate;
    return ((J === null || J === void 0 ? void 0 : J.clearInterval) || clearInterval)(Z);
  },
  delegate: void 0
};

// node_modules/rxjs/dist/esm5/internal/scheduler/AsyncAction.js
var tK0 = function(Z) {
  hQ(J, Z);
  function J($, X) {
    var Y = Z.call(this, $, X) || this;
    return Y.scheduler = $, Y.work = X, Y.pending = !1, Y;
  }
  return J.prototype.schedule = function($, X) {
    var Y;
    if (X === void 0)
      X = 0;
    if (this.closed)
      return this;
    this.state = $;
    var Q = this.id, W = this.scheduler;
    if (Q != null)
      this.id = this.recycleAsyncId(W, Q, X);
    return this.pending = !0, this.delay = X, this.id = (Y = this.id) !== null && Y !== void 0 ? Y : this.requestAsyncId(W, this.id, X), this;
  }, J.prototype.requestAsyncId = function($, X, Y) {
    if (Y === void 0)
      Y = 0;
    return A_.setInterval($.flush.bind($, this), Y);
  }, J.prototype.recycleAsyncId = function($, X, Y) {
    if (Y === void 0)
      Y = 0;
    if (Y != null && this.delay === Y && this.pending === !1)
      return X;
    if (X != null)
      A_.clearInterval(X);
    return;
  }, J.prototype.execute = function($, X) {
    if (this.closed)
      return new Error("executing a cancelled action");
    this.pending = !1;
    var Y = this._execute($, X);
    if (Y)
      return Y;
    else if (this.pending === !1 && this.id != null)
      this.id = this.recycleAsyncId(this.scheduler, this.id, null);
  }, J.prototype._execute = function($, X) {
    var Y = !1, Q;
    try {
      this.work($);
    } catch (W) {
      Y = !0, Q = W ? W : new Error("Scheduled action threw falsy error");
    }
    if (Y)
      return this.unsubscribe(), Q;
  }, J.prototype.unsubscribe = function() {
    if (!this.closed) {
      var $ = this, X = $.id, Y = $.scheduler, Q = Y.actions;
      if (this.work = this.state = this.scheduler = null, this.pending = !1, aO(Q, this), X != null)
        this.id = this.recycleAsyncId(Y, X, null);
      this.delay = null, Z.prototype.unsubscribe.call(this);
    }
  }, J;
}(rK0);

// node_modules/rxjs/dist/esm5/internal/Scheduler.js
var Vi = function() {
  function Z(J, $) {
    if ($ === void 0)
      $ = Z.now;
    this.schedulerActionCtor = J, this.now = $;
  }
  return Z.prototype.schedule = function(J, $, X) {
    if ($ === void 0)
      $ = 0;
    return new this.schedulerActionCtor(this, J).schedule(X, $);
  }, Z.now = _i.now, Z;
}();

// node_modules/rxjs/dist/esm5/internal/scheduler/AsyncScheduler.js
var eK0 = function(Z) {
  hQ(J, Z);
  function J($, X) {
    if (X === void 0)
      X = Vi.now;
    var Y = Z.call(this, $, X) || this;
    return Y.actions = [], Y._active = !1, Y;
  }
  return J.prototype.flush = function($) {
    var X = this.actions;
    if (this._active) {
      X.push($);
      return;
    }
    var Y;
    this._active = !0;
    do
      if (Y = $.execute($.state, $.delay))
        break;
    while ($ = X.shift());
    if (this._active = !1, Y) {
      while ($ = X.shift())
        $.unsubscribe();
      throw Y;
    }
  }, J;
}(Vi);

// node_modules/rxjs/dist/esm5/internal/scheduler/async.js
var B_ = new eK0(tK0), Z30 = B_;

// node_modules/rxjs/dist/esm5/internal/observable/empty.js
var lS = new r$(function(Z) {
  return Z.complete();
});

// node_modules/rxjs/dist/esm5/internal/util/isScheduler.js
function nS(Z) {
  return Z && o9(Z.schedule);
}

// node_modules/rxjs/dist/esm5/internal/util/args.js
function J30(Z) {
  return Z[Z.length - 1];
}
function $30(Z) {
  return nS(J30(Z)) ? Z.pop() : void 0;
}
function X30(Z, J) {
  return typeof J30(Z) === "number" ? Z.pop() : J;
}

// node_modules/rxjs/dist/esm5/internal/util/isArrayLike.js
var iS = function(Z) {
  return Z && typeof Z.length === "number" && typeof Z !== "function";
};

// node_modules/rxjs/dist/esm5/internal/util/isPromise.js
function oS(Z) {
  return o9(Z === null || Z === void 0 ? void 0 : Z.then);
}

// node_modules/rxjs/dist/esm5/internal/util/isInteropObservable.js
function sS(Z) {
  return o9(Z[SM]);
}

// node_modules/rxjs/dist/esm5/internal/util/isAsyncIterable.js
function aS(Z) {
  return Symbol.asyncIterator && o9(Z === null || Z === void 0 ? void 0 : Z[Symbol.asyncIterator]);
}

// node_modules/rxjs/dist/esm5/internal/util/throwUnobservableError.js
function rS(Z) {
  return new TypeError("You provided " + (Z !== null && typeof Z === "object" ? "an invalid object" : "'" + Z + "'") + " where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable.");
}

// node_modules/rxjs/dist/esm5/internal/symbol/iterator.js
function zr0() {
  if (typeof Symbol !== "function" || !Symbol.iterator)
    return "@@iterator";
  return Symbol.iterator;
}
var tS = zr0();

// node_modules/rxjs/dist/esm5/internal/util/isIterable.js
function eS(Z) {
  return o9(Z === null || Z === void 0 ? void 0 : Z[tS]);
}

// node_modules/rxjs/dist/esm5/internal/util/isReadableStreamLike.js
function Zf(Z) {
  return mK0(this, arguments, function J() {
    var $, X, Y, Q;
    return yS(this, function(W) {
      switch (W.label) {
        case 0:
          $ = Z.getReader(), W.label = 1;
        case 1:
          W.trys.push([1, , 9, 10]), W.label = 2;
        case 2:
          return [4, sO($.read())];
        case 3:
          if (X = W.sent(), Y = X.value, Q = X.done, !Q)
            return [3, 5];
          return [4, sO(void 0)];
        case 4:
          return [2, W.sent()];
        case 5:
          return [4, sO(Y)];
        case 6:
          return [4, W.sent()];
        case 7:
          return W.sent(), [3, 2];
        case 8:
          return [3, 10];
        case 9:
          return $.releaseLock(), [7];
        case 10:
          return [2];
      }
    });
  });
}
function Jf(Z) {
  return o9(Z === null || Z === void 0 ? void 0 : Z.getReader);
}

// node_modules/rxjs/dist/esm5/internal/observable/innerFrom.js
function E5(Z) {
  if (Z instanceof r$)
    return Z;
  if (Z != null) {
    if (sS(Z))
      return Dr0(Z);
    if (iS(Z))
      return Mr0(Z);
    if (oS(Z))
      return Ar0(Z);
    if (aS(Z))
      return Y30(Z);
    if (eS(Z))
      return Br0(Z);
    if (Jf(Z))
      return wr0(Z);
  }
  throw rS(Z);
}
function Dr0(Z) {
  return new r$(function(J) {
    var $ = Z[SM]();
    if (o9($.subscribe))
      return $.subscribe(J);
    throw new TypeError("Provided object does not correctly implement Symbol.observable");
  });
}
function Mr0(Z) {
  return new r$(function(J) {
    for (var $ = 0;$ < Z.length && !J.closed; $++)
      J.next(Z[$]);
    J.complete();
  });
}
function Ar0(Z) {
  return new r$(function(J) {
    Z.then(function($) {
      if (!J.closed)
        J.next($), J.complete();
    }, function($) {
      return J.error($);
    }).then(null, pS);
  });
}
function Br0(Z) {
  return new r$(function(J) {
    var $, X;
    try {
      for (var Y = kF(Z), Q = Y.next();!Q.done; Q = Y.next()) {
        var W = Q.value;
        if (J.next(W), J.closed)
          return;
      }
    } catch (K) {
      $ = { error: K };
    } finally {
      try {
        if (Q && !Q.done && (X = Y.return))
          X.call(Y);
      } finally {
        if ($)
          throw $.error;
      }
    }
    J.complete();
  });
}
function Y30(Z) {
  return new r$(function(J) {
    jr0(Z, J).catch(function($) {
      return J.error($);
    });
  });
}
function wr0(Z) {
  return Y30(Zf(Z));
}
function jr0(Z, J) {
  var $, X, Y, Q;
  return gK0(this, void 0, void 0, function() {
    var W, K;
    return yS(this, function(G) {
      switch (G.label) {
        case 0:
          G.trys.push([0, 5, 6, 11]), $ = dK0(Z), G.label = 1;
        case 1:
          return [4, $.next()];
        case 2:
          if (X = G.sent(), !!X.done)
            return [3, 4];
          if (W = X.value, J.next(W), J.closed)
            return [2];
          G.label = 3;
        case 3:
          return [3, 1];
        case 4:
          return [3, 11];
        case 5:
          return K = G.sent(), Y = { error: K }, [3, 11];
        case 6:
          if (G.trys.push([6, , 9, 10]), !(X && !X.done && (Q = $.return)))
            return [3, 8];
          return [4, Q.call($)];
        case 7:
          G.sent(), G.label = 8;
        case 8:
          return [3, 10];
        case 9:
          if (Y)
            throw Y.error;
          return [7];
        case 10:
          return [7];
        case 11:
          return J.complete(), [2];
      }
    });
  });
}

// node_modules/rxjs/dist/esm5/internal/util/executeSchedule.js
function R3(Z, J, $, X, Y) {
  if (X === void 0)
    X = 0;
  if (Y === void 0)
    Y = !1;
  var Q = J.schedule(function() {
    if ($(), Y)
      Z.add(this.schedule(null, X));
    else
      this.unsubscribe();
  }, X);
  if (Z.add(Q), !Y)
    return Q;
}

// node_modules/rxjs/dist/esm5/internal/operators/observeOn.js
function $f(Z, J) {
  if (J === void 0)
    J = 0;
  return KY(function($, X) {
    $.subscribe(GY(X, function(Y) {
      return R3(X, Z, function() {
        return X.next(Y);
      }, J);
    }, function() {
      return R3(X, Z, function() {
        return X.complete();
      }, J);
    }, function(Y) {
      return R3(X, Z, function() {
        return X.error(Y);
      }, J);
    }));
  });
}

// node_modules/rxjs/dist/esm5/internal/operators/subscribeOn.js
function Xf(Z, J) {
  if (J === void 0)
    J = 0;
  return KY(function($, X) {
    X.add(Z.schedule(function() {
      return $.subscribe(X);
    }, J));
  });
}

// node_modules/rxjs/dist/esm5/internal/scheduled/scheduleObservable.js
function Q30(Z, J) {
  return E5(Z).pipe(Xf(J), $f(J));
}

// node_modules/rxjs/dist/esm5/internal/scheduled/schedulePromise.js
function W30(Z, J) {
  return E5(Z).pipe(Xf(J), $f(J));
}

// node_modules/rxjs/dist/esm5/internal/scheduled/scheduleArray.js
function K30(Z, J) {
  return new r$(function($) {
    var X = 0;
    return J.schedule(function() {
      if (X === Z.length)
        $.complete();
      else if ($.next(Z[X++]), !$.closed)
        this.schedule();
    });
  });
}

// node_modules/rxjs/dist/esm5/internal/scheduled/scheduleIterable.js
function G30(Z, J) {
  return new r$(function($) {
    var X;
    return R3($, J, function() {
      X = Z[tS](), R3($, J, function() {
        var Y, Q, W;
        try {
          Y = X.next(), Q = Y.value, W = Y.done;
        } catch (K) {
          $.error(K);
          return;
        }
        if (W)
          $.complete();
        else
          $.next(Q);
      }, 0, !0);
    }), function() {
      return o9(X === null || X === void 0 ? void 0 : X.return) && X.return();
    };
  });
}

// node_modules/rxjs/dist/esm5/internal/scheduled/scheduleAsyncIterable.js
function Yf(Z, J) {
  if (!Z)
    throw new Error("Iterable cannot be null");
  return new r$(function($) {
    R3($, J, function() {
      var X = Z[Symbol.asyncIterator]();
      R3($, J, function() {
        X.next().then(function(Y) {
          if (Y.done)
            $.complete();
          else
            $.next(Y.value);
        });
      }, 0, !0);
    });
  });
}

// node_modules/rxjs/dist/esm5/internal/scheduled/scheduleReadableStreamLike.js
function H30(Z, J) {
  return Yf(Zf(Z), J);
}

// node_modules/rxjs/dist/esm5/internal/scheduled/scheduled.js
function N30(Z, J) {
  if (Z != null) {
    if (sS(Z))
      return Q30(Z, J);
    if (iS(Z))
      return K30(Z, J);
    if (oS(Z))
      return W30(Z, J);
    if (aS(Z))
      return Yf(Z, J);
    if (eS(Z))
      return G30(Z, J);
    if (Jf(Z))
      return H30(Z, J);
  }
  throw rS(Z);
}

// node_modules/rxjs/dist/esm5/internal/observable/from.js
function q30(Z, J) {
  return J ? N30(Z, J) : E5(Z);
}

// node_modules/rxjs/dist/esm5/internal/util/isDate.js
function F30(Z) {
  return Z instanceof Date && !isNaN(Z);
}

// node_modules/rxjs/dist/esm5/internal/operators/map.js
function w_(Z, J) {
  return KY(function($, X) {
    var Y = 0;
    $.subscribe(GY(X, function(Q) {
      X.next(Z.call(J, Q, Y++));
    }));
  });
}

// node_modules/rxjs/dist/esm5/internal/operators/mergeInternals.js
function U30(Z, J, $, X, Y, Q, W, K) {
  var G = [], H = 0, N = 0, q = !1, U = function() {
    if (q && !G.length && !H)
      J.complete();
  }, F = function(R) {
    return H < X ? E(R) : G.push(R);
  }, E = function(R) {
    Q && J.next(R), H++;
    var z = !1;
    E5($(R, N++)).subscribe(GY(J, function(D) {
      if (Y === null || Y === void 0 || Y(D), Q)
        F(D);
      else
        J.next(D);
    }, function() {
      z = !0;
    }, void 0, function() {
      if (z)
        try {
          H--;
          var D = function() {
            var A = G.shift();
            if (W)
              R3(J, W, function() {
                return E(A);
              });
            else
              E(A);
          };
          while (G.length && H < X)
            D();
          U();
        } catch (A) {
          J.error(A);
        }
    }));
  };
  return Z.subscribe(GY(J, F, function() {
    q = !0, U();
  })), function() {
    K === null || K === void 0 || K();
  };
}

// node_modules/rxjs/dist/esm5/internal/operators/mergeMap.js
function Ii(Z, J, $) {
  if ($ === void 0)
    $ = 1 / 0;
  if (o9(J))
    return Ii(function(X, Y) {
      return w_(function(Q, W) {
        return J(X, Q, Y, W);
      })(E5(Z(X, Y)));
    }, $);
  else if (typeof J === "number")
    $ = J;
  return KY(function(X, Y) {
    return U30(X, Y, Z, $);
  });
}

// node_modules/rxjs/dist/esm5/internal/operators/mergeAll.js
function L30(Z) {
  if (Z === void 0)
    Z = 1 / 0;
  return Ii(fM, Z);
}

// node_modules/rxjs/dist/esm5/internal/observable/timer.js
function R30(Z, J, $) {
  if (Z === void 0)
    Z = 0;
  if ($ === void 0)
    $ = Z30;
  var X = -1;
  if (J != null)
    if (nS(J))
      $ = J;
    else
      X = J;
  return new r$(function(Y) {
    var Q = F30(Z) ? +Z - $.now() : Z;
    if (Q < 0)
      Q = 0;
    var W = 0;
    return $.schedule(function() {
      if (!Y.closed)
        if (Y.next(W++), 0 <= X)
          this.schedule(void 0, X);
        else
          Y.complete();
    }, Q);
  });
}

// node_modules/rxjs/dist/esm5/internal/observable/merge.js
function O5() {
  var Z = [];
  for (var J = 0;J < arguments.length; J++)
    Z[J] = arguments[J];
  var $ = $30(Z), X = X30(Z, 1 / 0), Y = Z;
  return !Y.length ? lS : Y.length === 1 ? E5(Y[0]) : L30(X)(q30(Y, $));
}
// node_modules/rxjs/dist/esm5/internal/operators/filter.js
function fN(Z, J) {
  return KY(function($, X) {
    var Y = 0;
    $.subscribe(GY(X, function(Q) {
      return Z.call(J, Q, Y++) && X.next(Q);
    }));
  });
}
// node_modules/rxjs/dist/esm5/internal/operators/debounceTime.js
function QR(Z, J) {
  if (J === void 0)
    J = B_;
  return KY(function($, X) {
    var Y = null, Q = null, W = null, K = function() {
      if (Y) {
        Y.unsubscribe(), Y = null;
        var H = Q;
        Q = null, X.next(H);
      }
    };
    function G() {
      var H = W + Z, N = J.now();
      if (N < H) {
        Y = this.schedule(void 0, H - N), X.add(Y);
        return;
      }
      K();
    }
    $.subscribe(GY(X, function(H) {
      if (Q = H, W = J.now(), !Y)
        Y = J.schedule(G, Z), X.add(Y);
    }, function() {
      K(), X.complete();
    }, void 0, function() {
      Q = Y = null;
    }));
  });
}
// node_modules/rxjs/dist/esm5/internal/operators/take.js
function Pi(Z) {
  return Z <= 0 ? function() {
    return lS;
  } : KY(function(J, $) {
    var X = 0;
    J.subscribe(GY($, function(Y) {
      if (++X <= Z) {
        if ($.next(Y), Z <= X)
          $.complete();
      }
    }));
  });
}

// node_modules/rxjs/dist/esm5/internal/operators/distinctUntilChanged.js
function Ci(Z, J) {
  if (J === void 0)
    J = fM;
  return Z = Z !== null && Z !== void 0 ? Z : Tr0, KY(function($, X) {
    var Y, Q = !0;
    $.subscribe(GY(X, function(W) {
      var K = J(W);
      if (Q || !Z(Y, K))
        Q = !1, Y = K, X.next(W);
    }));
  });
}
function Tr0(Z, J) {
  return Z === J;
}
// node_modules/rxjs/dist/esm5/internal/operators/skip.js
function j_(Z) {
  return fN(function(J, $) {
    return Z <= $;
  });
}
// node_modules/rxjs/dist/esm5/internal/operators/throttle.js
function E30(Z, J) {
  return KY(function($, X) {
    var Y = J !== null && J !== void 0 ? J : {}, Q = Y.leading, W = Q === void 0 ? !0 : Q, K = Y.trailing, G = K === void 0 ? !1 : K, H = !1, N = null, q = null, U = !1, F = function() {
      if (q === null || q === void 0 || q.unsubscribe(), q = null, G)
        z(), U && X.complete();
    }, E = function() {
      q = null, U && X.complete();
    }, R = function(D) {
      return q = E5(Z(D)).subscribe(GY(X, F, E));
    }, z = function() {
      if (H) {
        H = !1;
        var D = N;
        N = null, X.next(D), !U && R(D);
      }
    };
    $.subscribe(GY(X, function(D) {
      H = !0, N = D, !(q && !q.closed) && (W ? z() : R(D));
    }, function() {
      U = !0, !(G && H && q && !q.closed) && X.complete();
    }));
  });
}

// node_modules/rxjs/dist/esm5/internal/operators/throttleTime.js
function bQ(Z, J, $) {
  if (J === void 0)
    J = B_;
  var X = R30(Z, J);
  return E30(function() {
    return X;
  }, $);
}
// node_modules/molstar/lib/mol-util/rx-event-helper.js
var xQ;
(function(Z) {
  function J() {
    let $ = new O30, X = () => $.create();
    return X.dispose = () => $.dispose(), X.behavior = (Y) => $.behavior(Y), X;
  }
  Z.create = J;
})(xQ || (xQ = {}));

class O30 {
  constructor() {
    this._eventList = [], this._disposed = !1;
  }
  create() {
    let Z = new P6;
    return this._eventList.push(Z), Z;
  }
  behavior(Z) {
    let J = new G$(Z);
    return this._eventList.push(J), J;
  }
  dispose() {
    if (this._disposed)
      return;
    for (let Z of this._eventList)
      Z.complete();
    this._disposed = !0;
  }
}

// node_modules/mutative/dist/mutative.cjs.development.js
var S$ = {
  Remove: "remove",
  Replace: "replace",
  Add: "add"
}, B30 = Symbol.for("__MUTATIVE_PROXY_DRAFT__"), _r0 = Symbol("__MUTATIVE_RAW_RETURN_SYMBOL__"), Qf = Symbol.iterator, BK = {
  mutable: "mutable",
  immutable: "immutable"
}, xi = {};
function __(Z, J) {
  return Z instanceof Map ? Z.has(J) : Object.prototype.hasOwnProperty.call(Z, J);
}
function z30(Z, J) {
  if (J in Z) {
    let $ = Reflect.getPrototypeOf(Z);
    while ($) {
      let X = Reflect.getOwnPropertyDescriptor($, J);
      if (X)
        return X;
      $ = Reflect.getPrototypeOf($);
    }
  }
  return;
}
function yi(Z) {
  return Object.getPrototypeOf(Z) === Set.prototype;
}
function gi(Z) {
  return Object.getPrototypeOf(Z) === Map.prototype;
}
function AK(Z) {
  var J;
  return (J = Z.copy) !== null && J !== void 0 ? J : Z.original;
}
function WR(Z) {
  return !!L9(Z);
}
function L9(Z) {
  if (typeof Z !== "object")
    return null;
  return Z === null || Z === void 0 ? void 0 : Z[B30];
}
function mi(Z) {
  var J;
  let $ = L9(Z);
  return $ ? (J = $.copy) !== null && J !== void 0 ? J : $.original : Z;
}
function $H(Z, J) {
  if (!Z || typeof Z !== "object")
    return !1;
  let $;
  return Object.getPrototypeOf(Z) === Object.prototype || Array.isArray(Z) || Z instanceof Map || Z instanceof Set || !!(J === null || J === void 0 ? void 0 : J.mark) && (($ = J.mark(Z, BK)) === BK.immutable || typeof $ === "function");
}
function w30(Z, J = []) {
  if (Object.hasOwnProperty.call(Z, "key")) {
    let $ = Z.parent.copy, X = L9(hF($, Z.key));
    if (X !== null && (X === null || X === void 0 ? void 0 : X.original) !== Z.original)
      return null;
    let Y = Z.parent.type === 3, Q = Y ? Array.from(Z.parent.setMap.keys()).indexOf(Z.key) : Z.key;
    if (!(Y && $.size > Q || __($, Q)))
      return null;
    J.push(Q);
  }
  if (Z.parent)
    return w30(Z.parent, J);
  J.reverse();
  try {
    Vr0(Z.copy, J);
  } catch ($) {
    return null;
  }
  return J;
}
function eO(Z) {
  if (Array.isArray(Z))
    return 1;
  if (Z instanceof Map)
    return 2;
  if (Z instanceof Set)
    return 3;
  return 0;
}
function hF(Z, J) {
  return eO(Z) === 2 ? Z.get(J) : Z[J];
}
function I_(Z, J, $) {
  if (eO(Z) === 2)
    Z.set(J, $);
  else
    Z[J] = $;
}
function ki(Z, J) {
  let $ = L9(Z);
  return ($ ? AK($) : Z)[J];
}
function fF(Z, J) {
  if (Z === J)
    return Z !== 0 || 1 / Z === 1 / J;
  else
    return Z !== Z && J !== J;
}
function vi(Z) {
  if (!Z)
    return;
  while (Z.finalities.revoke.length > 0)
    Z.finalities.revoke.pop()();
}
function tO(Z, J) {
  return J ? Z : [""].concat(Z).map(($) => {
    let X = `${$}`;
    if (X.indexOf("/") === -1 && X.indexOf("~") === -1)
      return X;
    return X.replace(/~/g, "~0").replace(/\//g, "~1");
  }).join("/");
}
function Vr0(Z, J) {
  for (let $ = 0;$ < J.length - 1; $ += 1) {
    let X = J[$];
    if (Z = hF(eO(Z) === 3 ? Array.from(Z) : Z, X), typeof Z !== "object")
      throw new Error(`Cannot resolve patch at '${J.join("/")}'.`);
  }
  return Z;
}
function Ir0(Z) {
  let J = Object.create(Object.getPrototypeOf(Z));
  return Reflect.ownKeys(Z).forEach(($) => {
    let X = Reflect.getOwnPropertyDescriptor(Z, $);
    if (X.enumerable && X.configurable && X.writable) {
      J[$] = Z[$];
      return;
    }
    if (!X.writable)
      X.writable = !0, X.configurable = !0;
    if (X.get || X.set)
      X = {
        configurable: !0,
        writable: !0,
        enumerable: X.enumerable,
        value: Z[$]
      };
    Reflect.defineProperty(J, $, X);
  }), J;
}
var Pr0 = Object.prototype.propertyIsEnumerable;
function j30(Z, J) {
  let $;
  if (Array.isArray(Z))
    return Array.prototype.concat.call(Z);
  else if (Z instanceof Set) {
    if (!yi(Z))
      return new (Object.getPrototypeOf(Z)).constructor(Z.values());
    return Set.prototype.difference ? Set.prototype.difference.call(Z, /* @__PURE__ */ new Set) : new Set(Z.values());
  } else if (Z instanceof Map) {
    if (!gi(Z))
      return new (Object.getPrototypeOf(Z)).constructor(Z);
    return new Map(Z);
  } else if ((J === null || J === void 0 ? void 0 : J.mark) && ($ = J.mark(Z, BK), $ !== void 0) && $ !== BK.mutable) {
    if ($ === BK.immutable)
      return Ir0(Z);
    else if (typeof $ === "function") {
      if (J.enablePatches || J.enableAutoFreeze)
        throw new Error("You can't use mark and patches or auto freeze together.");
      return $();
    }
    throw new Error(`Unsupported mark result: ${$}`);
  } else if (typeof Z === "object" && Object.getPrototypeOf(Z) === Object.prototype) {
    let X = {};
    return Object.keys(Z).forEach((Y) => {
      X[Y] = Z[Y];
    }), Object.getOwnPropertySymbols(Z).forEach((Y) => {
      if (Pr0.call(Z, Y))
        X[Y] = Z[Y];
    }), X;
  } else
    throw new Error("Please check mark() to ensure that it is a stable marker draftable function.");
}
function jW(Z) {
  if (Z.copy)
    return;
  Z.copy = j30(Z.original, Z.options);
}
function T_(Z) {
  if (!$H(Z))
    return mi(Z);
  if (Array.isArray(Z))
    return Z.map(T_);
  if (Z instanceof Map) {
    let $ = Array.from(Z.entries()).map(([X, Y]) => [
      X,
      T_(Y)
    ]);
    if (!gi(Z))
      return new (Object.getPrototypeOf(Z)).constructor($);
    return new Map($);
  }
  if (Z instanceof Set) {
    let $ = Array.from(Z).map(T_);
    if (!yi(Z))
      return new (Object.getPrototypeOf(Z)).constructor($);
    return new Set($);
  }
  let J = Object.create(Object.getPrototypeOf(Z));
  for (let $ in Z)
    J[$] = T_(Z[$]);
  return J;
}
function Wf(Z) {
  return WR(Z) ? T_(Z) : Z;
}
function hN(Z) {
  var J;
  if (Z.assignedMap = (J = Z.assignedMap) !== null && J !== void 0 ? J : /* @__PURE__ */ new Map, !Z.operated) {
    if (Z.operated = !0, Z.parent)
      hN(Z.parent);
  }
}
function D30() {
  throw new Error("Cannot modify frozen object");
}
function hM(Z, J, $, X, Y) {
  {
    $ = $ !== null && $ !== void 0 ? $ : /* @__PURE__ */ new WeakMap, X = X !== null && X !== void 0 ? X : [], Y = Y !== null && Y !== void 0 ? Y : [];
    let W = $.has(Z) ? $.get(Z) : Z;
    if (X.length > 0) {
      let K = X.indexOf(W);
      if (W && typeof W === "object" && K !== -1) {
        if (X[0] === W)
          throw new Error("Forbids circular reference");
        throw new Error(`Forbids circular reference: ~/${Y.slice(0, K).map((G, H) => {
          if (typeof G === "symbol")
            return `[${G.toString()}]`;
          let N = X[H];
          if (typeof G === "object" && (N instanceof Map || N instanceof Set))
            return Array.from(N.keys()).indexOf(G);
          return G;
        }).join("/")}`);
      }
      X.push(W), Y.push(J);
    } else
      X.push(W);
  }
  if (Object.isFrozen(Z) || WR(Z)) {
    X.pop(), Y.pop();
    return;
  }
  switch (eO(Z)) {
    case 2:
      for (let [K, G] of Z)
        hM(K, K, $, X, Y), hM(G, K, $, X, Y);
      Z.set = Z.clear = Z.delete = D30;
      break;
    case 3:
      for (let K of Z)
        hM(K, K, $, X, Y);
      Z.add = Z.clear = Z.delete = D30;
      break;
    case 1:
      Object.freeze(Z);
      let W = 0;
      for (let K of Z)
        hM(K, W, $, X, Y), W += 1;
      break;
    default:
      Object.freeze(Z), Object.keys(Z).forEach((K) => {
        let G = Z[K];
        hM(G, K, $, X, Y);
      });
  }
  X.pop(), Y.pop();
}
function di(Z, J) {
  let $ = eO(Z);
  if ($ === 0)
    Reflect.ownKeys(Z).forEach((X) => {
      J(X, Z[X], Z);
    });
  else if ($ === 1) {
    let X = 0;
    for (let Y of Z)
      J(X, Y, Z), X += 1;
  } else
    Z.forEach((X, Y) => J(Y, X, Z));
}
function T30(Z, J, $) {
  if (WR(Z) || !$H(Z, $) || J.has(Z) || Object.isFrozen(Z))
    return;
  let X = Z instanceof Set, Y = X ? /* @__PURE__ */ new Map : void 0;
  if (J.add(Z), di(Z, (Q, W) => {
    var K;
    if (WR(W)) {
      let G = L9(W);
      jW(G);
      let H = ((K = G.assignedMap) === null || K === void 0 ? void 0 : K.size) || G.operated ? G.copy : G.original;
      I_(X ? Y : Z, Q, H);
    } else
      T30(W, J, $);
  }), Y) {
    let Q = Z, W = Array.from(Q);
    Q.clear(), W.forEach((K) => {
      Q.add(Y.has(K) ? Y.get(K) : K);
    });
  }
}
function Cr0(Z, J) {
  let $ = Z.type === 3 ? Z.setMap : Z.copy;
  if (Z.finalities.revoke.length > 1 && Z.assignedMap.get(J) && $)
    T30(hF($, J), Z.finalities.handledSet, Z.options);
}
function Si(Z) {
  if (Z.type === 3 && Z.copy)
    Z.copy.clear(), Z.setMap.forEach((J) => {
      Z.copy.add(mi(J));
    });
}
function fi(Z, J, $, X) {
  if (Z.operated && Z.assignedMap && Z.assignedMap.size > 0 && !Z.finalized) {
    if ($ && X) {
      let Q = w30(Z);
      if (Q)
        J(Z, Q, $, X);
    }
    Z.finalized = !0;
  }
}
function pi(Z, J, $, X) {
  let Y = L9($);
  if (Y) {
    if (!Y.callbacks)
      Y.callbacks = [];
    if (Y.callbacks.push((Q, W) => {
      var K;
      let G = Z.type === 3 ? Z.setMap : Z.copy;
      if (fF(hF(G, J), $)) {
        let H = Y.original;
        if (Y.copy)
          H = Y.copy;
        if (Si(Z), fi(Z, X, Q, W), Z.options.enableAutoFreeze)
          Z.options.updatedValues = (K = Z.options.updatedValues) !== null && K !== void 0 ? K : /* @__PURE__ */ new WeakMap, Z.options.updatedValues.set(H, Y.original);
        I_(G, J, H);
      }
    }), Z.options.enableAutoFreeze) {
      if (Y.finalities !== Z.finalities)
        Z.options.enableAutoFreeze = !1;
    }
  }
  if ($H($, Z.options))
    Z.finalities.draft.push(() => {
      let Q = Z.type === 3 ? Z.setMap : Z.copy;
      if (fF(hF(Q, J), $))
        Cr0(Z, J);
    });
}
function kr0(Z, J, $, X, Y) {
  let { original: Q, assignedMap: W, options: K } = Z, G = Z.copy;
  if (G.length < Q.length)
    [Q, G] = [G, Q], [$, X] = [X, $];
  for (let H = 0;H < Q.length; H += 1)
    if (W.get(H.toString()) && G[H] !== Q[H]) {
      let N = J.concat([H]), q = tO(N, Y);
      $.push({
        op: S$.Replace,
        path: q,
        value: Wf(G[H])
      }), X.push({
        op: S$.Replace,
        path: q,
        value: Wf(Q[H])
      });
    }
  for (let H = Q.length;H < G.length; H += 1) {
    let N = J.concat([H]), q = tO(N, Y);
    $.push({
      op: S$.Add,
      path: q,
      value: Wf(G[H])
    });
  }
  if (Q.length < G.length) {
    let { arrayLengthAssignment: H = !0 } = K.enablePatches;
    if (H) {
      let N = J.concat(["length"]), q = tO(N, Y);
      X.push({
        op: S$.Replace,
        path: q,
        value: Q.length
      });
    } else
      for (let N = G.length;Q.length < N; N -= 1) {
        let q = J.concat([N - 1]), U = tO(q, Y);
        X.push({
          op: S$.Remove,
          path: U
        });
      }
  }
}
function vr0({ original: Z, copy: J, assignedMap: $ }, X, Y, Q, W) {
  $.forEach((K, G) => {
    let H = hF(Z, G), N = Wf(hF(J, G)), q = !K ? S$.Remove : __(Z, G) ? S$.Replace : S$.Add;
    if (fF(H, N) && q === S$.Replace)
      return;
    let U = X.concat(G), F = tO(U, W);
    Y.push(q === S$.Remove ? { op: q, path: F } : { op: q, path: F, value: N }), Q.push(q === S$.Add ? { op: S$.Remove, path: F } : q === S$.Remove ? { op: S$.Add, path: F, value: H } : { op: S$.Replace, path: F, value: H });
  });
}
function Sr0({ original: Z, copy: J }, $, X, Y, Q) {
  let W = 0;
  Z.forEach((K) => {
    if (!J.has(K)) {
      let G = $.concat([W]), H = tO(G, Q);
      X.push({
        op: S$.Remove,
        path: H,
        value: K
      }), Y.unshift({
        op: S$.Add,
        path: H,
        value: K
      });
    }
    W += 1;
  }), W = 0, J.forEach((K) => {
    if (!Z.has(K)) {
      let G = $.concat([W]), H = tO(G, Q);
      X.push({
        op: S$.Add,
        path: H,
        value: K
      }), Y.unshift({
        op: S$.Remove,
        path: H,
        value: K
      });
    }
    W += 1;
  });
}
function V_(Z, J, $, X) {
  let { pathAsArray: Y = !0 } = Z.options.enablePatches;
  switch (Z.type) {
    case 0:
    case 2:
      return vr0(Z, J, $, X, Y);
    case 1:
      return kr0(Z, J, $, X, Y);
    case 3:
      return Sr0(Z, J, $, X, Y);
  }
}
var fr0 = !1, Kf = (Z, J, $ = !1) => {
  if (typeof Z === "object" && Z !== null && (!$H(Z, J) || $) && !fr0)
    throw new Error("Strict mode: Mutable data cannot be accessed directly, please use 'unsafe(callback)' wrap.");
};
var hi = {
  get size() {
    return AK(L9(this)).size;
  },
  has(Z) {
    return AK(L9(this)).has(Z);
  },
  set(Z, J) {
    let $ = L9(this), X = AK($);
    if (!X.has(Z) || !fF(X.get(Z), J))
      jW($), hN($), $.assignedMap.set(Z, !0), $.copy.set(Z, J), pi($, Z, J, V_);
    return this;
  },
  delete(Z) {
    if (!this.has(Z))
      return !1;
    let J = L9(this);
    if (jW(J), hN(J), J.original.has(Z))
      J.assignedMap.set(Z, !1);
    else
      J.assignedMap.delete(Z);
    return J.copy.delete(Z), !0;
  },
  clear() {
    let Z = L9(this);
    if (!this.size)
      return;
    jW(Z), hN(Z), Z.assignedMap = /* @__PURE__ */ new Map;
    for (let [J] of Z.original)
      Z.assignedMap.set(J, !1);
    Z.copy.clear();
  },
  forEach(Z, J) {
    let $ = L9(this);
    AK($).forEach((X, Y) => {
      Z.call(J, this.get(Y), Y, this);
    });
  },
  get(Z) {
    var J, $;
    let X = L9(this), Y = AK(X).get(Z), Q = (($ = (J = X.options).mark) === null || $ === void 0 ? void 0 : $.call(J, Y, BK)) === BK.mutable;
    if (X.options.strict)
      Kf(Y, X.options, Q);
    if (Q)
      return Y;
    if (X.finalized || !$H(Y, X.options))
      return Y;
    if (Y !== X.original.get(Z))
      return Y;
    let W = xi.createDraft({
      original: Y,
      parentDraft: X,
      key: Z,
      finalities: X.finalities,
      options: X.options
    });
    return jW(X), X.copy.set(Z, W), W;
  },
  keys() {
    return AK(L9(this)).keys();
  },
  values() {
    let Z = this.keys();
    return {
      [Qf]: () => this.values(),
      next: () => {
        let J = Z.next();
        if (J.done)
          return J;
        return {
          done: !1,
          value: this.get(J.value)
        };
      }
    };
  },
  entries() {
    let Z = this.keys();
    return {
      [Qf]: () => this.entries(),
      next: () => {
        let J = Z.next();
        if (J.done)
          return J;
        let $ = this.get(J.value);
        return {
          done: !1,
          value: [J.value, $]
        };
      }
    };
  },
  [Qf]() {
    return this.entries();
  }
}, hr0 = Reflect.ownKeys(hi), M30 = (Z, J, { isValuesIterator: $ }) => () => {
  var X, Y;
  let Q = J.next();
  if (Q.done)
    return Q;
  let W = Q.value, K = Z.setMap.get(W), G = L9(K), H = ((Y = (X = Z.options).mark) === null || Y === void 0 ? void 0 : Y.call(X, K, BK)) === BK.mutable;
  if (Z.options.strict)
    Kf(W, Z.options, H);
  if (!H && !G && $H(W, Z.options) && !Z.finalized && Z.original.has(W)) {
    let N = xi.createDraft({
      original: W,
      parentDraft: Z,
      key: W,
      finalities: Z.finalities,
      options: Z.options
    });
    Z.setMap.set(W, N), K = N;
  } else if (G)
    K = G.proxy;
  return {
    done: !1,
    value: $ ? K : [K, K]
  };
}, Gf = {
  get size() {
    return L9(this).setMap.size;
  },
  has(Z) {
    let J = L9(this);
    if (J.setMap.has(Z))
      return !0;
    jW(J);
    let $ = L9(Z);
    if ($ && J.setMap.has($.original))
      return !0;
    return !1;
  },
  add(Z) {
    let J = L9(this);
    if (!this.has(Z))
      jW(J), hN(J), J.assignedMap.set(Z, !0), J.setMap.set(Z, Z), pi(J, Z, Z, V_);
    return this;
  },
  delete(Z) {
    if (!this.has(Z))
      return !1;
    let J = L9(this);
    jW(J), hN(J);
    let $ = L9(Z);
    if ($ && J.setMap.has($.original))
      return J.assignedMap.set($.original, !1), J.setMap.delete($.original);
    if (!$ && J.setMap.has(Z))
      J.assignedMap.set(Z, !1);
    else
      J.assignedMap.delete(Z);
    return J.setMap.delete(Z);
  },
  clear() {
    if (!this.size)
      return;
    let Z = L9(this);
    jW(Z), hN(Z);
    for (let J of Z.original)
      Z.assignedMap.set(J, !1);
    Z.setMap.clear();
  },
  values() {
    let Z = L9(this);
    jW(Z);
    let J = Z.setMap.keys();
    return {
      [Symbol.iterator]: () => this.values(),
      next: M30(Z, J, { isValuesIterator: !0 })
    };
  },
  entries() {
    let Z = L9(this);
    jW(Z);
    let J = Z.setMap.keys();
    return {
      [Symbol.iterator]: () => this.entries(),
      next: M30(Z, J, {
        isValuesIterator: !1
      })
    };
  },
  keys() {
    return this.values();
  },
  [Qf]() {
    return this.values();
  },
  forEach(Z, J) {
    let $ = this.values(), X = $.next();
    while (!X.done)
      Z.call(J, X.value, X.value, this), X = $.next();
  }
};
if (Set.prototype.difference)
  Object.assign(Gf, {
    intersection(Z) {
      return Set.prototype.intersection.call(new Set(this.values()), Z);
    },
    union(Z) {
      return Set.prototype.union.call(new Set(this.values()), Z);
    },
    difference(Z) {
      return Set.prototype.difference.call(new Set(this.values()), Z);
    },
    symmetricDifference(Z) {
      return Set.prototype.symmetricDifference.call(new Set(this.values()), Z);
    },
    isSubsetOf(Z) {
      return Set.prototype.isSubsetOf.call(new Set(this.values()), Z);
    },
    isSupersetOf(Z) {
      return Set.prototype.isSupersetOf.call(new Set(this.values()), Z);
    },
    isDisjointFrom(Z) {
      return Set.prototype.isDisjointFrom.call(new Set(this.values()), Z);
    }
  });
var br0 = Reflect.ownKeys(Gf), _30 = {
  get(Z, J, $) {
    var X, Y;
    let Q = (X = Z.copy) === null || X === void 0 ? void 0 : X[J];
    if (Q && Z.finalities.draftsCache.has(Q))
      return Q;
    if (J === B30)
      return Z;
    let W;
    if (Z.options.mark) {
      let H = J === "size" && (Z.original instanceof Map || Z.original instanceof Set) ? Reflect.get(Z.original, J) : Reflect.get(Z.original, J, $);
      if (W = Z.options.mark(H, BK), W === BK.mutable) {
        if (Z.options.strict)
          Kf(H, Z.options, !0);
        return H;
      }
    }
    let K = AK(Z);
    if (K instanceof Map && hr0.includes(J)) {
      if (J === "size")
        return Object.getOwnPropertyDescriptor(hi, "size").get.call(Z.proxy);
      return hi[J].bind(Z.proxy);
    }
    if (K instanceof Set && br0.includes(J)) {
      if (J === "size")
        return Object.getOwnPropertyDescriptor(Gf, "size").get.call(Z.proxy);
      return Gf[J].bind(Z.proxy);
    }
    if (!__(K, J)) {
      let H = z30(K, J);
      return H ? "value" in H ? H.value : (Y = H.get) === null || Y === void 0 ? void 0 : Y.call(Z.proxy) : void 0;
    }
    let G = K[J];
    if (Z.options.strict)
      Kf(G, Z.options);
    if (Z.finalized || !$H(G, Z.options))
      return G;
    if (G === ki(Z.original, J)) {
      if (jW(Z), Z.copy[J] = ui({
        original: Z.original[J],
        parentDraft: Z,
        key: Z.type === 1 ? Number(J) : J,
        finalities: Z.finalities,
        options: Z.options
      }), typeof W === "function") {
        let H = L9(Z.copy[J]);
        return jW(H), hN(H), H.copy;
      }
      return Z.copy[J];
    }
    if (WR(G))
      Z.finalities.draftsCache.add(G);
    return G;
  },
  set(Z, J, $) {
    var X;
    if (Z.type === 3 || Z.type === 2)
      throw new Error("Map/Set draft does not support any property assignment.");
    let Y;
    if (Z.type === 1 && J !== "length" && !(Number.isInteger(Y = Number(J)) && Y >= 0 && (J === 0 || Y === 0 || String(Y) === String(J))))
      throw new Error("Only supports setting array indices and the 'length' property.");
    let Q = z30(AK(Z), J);
    if (Q === null || Q === void 0 ? void 0 : Q.set)
      return Q.set.call(Z.proxy, $), !0;
    let W = ki(AK(Z), J), K = L9(W);
    if (K && fF(K.original, $))
      return Z.copy[J] = $, Z.assignedMap = (X = Z.assignedMap) !== null && X !== void 0 ? X : /* @__PURE__ */ new Map, Z.assignedMap.set(J, !1), !0;
    if (fF($, W) && ($ !== void 0 || __(Z.original, J)))
      return !0;
    if (jW(Z), hN(Z), __(Z.original, J) && fF($, Z.original[J]))
      Z.assignedMap.delete(J);
    else
      Z.assignedMap.set(J, !0);
    return Z.copy[J] = $, pi(Z, J, $, V_), !0;
  },
  has(Z, J) {
    return J in AK(Z);
  },
  ownKeys(Z) {
    return Reflect.ownKeys(AK(Z));
  },
  getOwnPropertyDescriptor(Z, J) {
    let $ = AK(Z), X = Reflect.getOwnPropertyDescriptor($, J);
    if (!X)
      return X;
    return {
      writable: !0,
      configurable: Z.type !== 1 || J !== "length",
      enumerable: X.enumerable,
      value: $[J]
    };
  },
  getPrototypeOf(Z) {
    return Reflect.getPrototypeOf(Z.original);
  },
  setPrototypeOf() {
    throw new Error("Cannot call 'setPrototypeOf()' on drafts");
  },
  defineProperty() {
    throw new Error("Cannot call 'defineProperty()' on drafts");
  },
  deleteProperty(Z, J) {
    var $;
    if (Z.type === 1)
      return _30.set.call(this, Z, J, void 0, Z.proxy);
    if (ki(Z.original, J) !== void 0 || J in Z.original)
      jW(Z), hN(Z), Z.assignedMap.set(J, !1);
    else
      Z.assignedMap = ($ = Z.assignedMap) !== null && $ !== void 0 ? $ : /* @__PURE__ */ new Map, Z.assignedMap.delete(J);
    if (Z.copy)
      delete Z.copy[J];
    return !0;
  }
};
function ui(Z) {
  let { original: J, parentDraft: $, key: X, finalities: Y, options: Q } = Z, W = eO(J), K = {
    type: W,
    finalized: !1,
    parent: $,
    original: J,
    copy: null,
    proxy: null,
    finalities: Y,
    options: Q,
    setMap: W === 3 ? new Map(J.entries()) : void 0
  };
  if (X || "key" in Z)
    K.key = X;
  let { proxy: G, revoke: H } = Proxy.revocable(W === 1 ? Object.assign([], K) : K, _30);
  if (Y.revoke.push(H), K.proxy = G, $) {
    let N = $;
    N.finalities.draft.push((q, U) => {
      var F, E;
      let R = L9(G), z = N.type === 3 ? N.setMap : N.copy, D = hF(z, X), A = L9(D);
      if (A) {
        let B = A.original;
        if (A.operated)
          B = mi(D);
        if (Si(A), fi(A, V_, q, U), N.options.enableAutoFreeze)
          N.options.updatedValues = (F = N.options.updatedValues) !== null && F !== void 0 ? F : /* @__PURE__ */ new WeakMap, N.options.updatedValues.set(B, A.original);
        I_(z, X, B);
      }
      (E = R.callbacks) === null || E === void 0 || E.forEach((B) => {
        B(q, U);
      });
    });
  } else {
    let N = L9(G);
    N.finalities.draft.push((q, U) => {
      Si(N), fi(N, V_, q, U);
    });
  }
  return G;
}
xi.createDraft = ui;
function xr0(Z, J, $, X, Y) {
  var Q;
  let W = L9(Z), K = (Q = W === null || W === void 0 ? void 0 : W.original) !== null && Q !== void 0 ? Q : Z, G = !!J.length;
  if (W === null || W === void 0 ? void 0 : W.operated)
    while (W.finalities.draft.length > 0)
      W.finalities.draft.pop()($, X);
  let H = G ? J[0] : W ? W.operated ? W.copy : W.original : Z;
  if (W)
    vi(W);
  if (Y)
    hM(H, H, W === null || W === void 0 ? void 0 : W.options.updatedValues);
  return [
    H,
    $ && G ? [{ op: S$.Replace, path: [], value: J[0] }] : $,
    X && G ? [{ op: S$.Replace, path: [], value: K }] : X
  ];
}
function yr0(Z, J) {
  var $;
  let X = {
    draft: [],
    revoke: [],
    handledSet: /* @__PURE__ */ new WeakSet,
    draftsCache: /* @__PURE__ */ new WeakSet
  }, Y, Q;
  if (J.enablePatches)
    Y = [], Q = [];
  let K = (($ = J.mark) === null || $ === void 0 ? void 0 : $.call(J, Z, BK)) === BK.mutable || !$H(Z, J) ? Z : ui({
    original: Z,
    parentDraft: null,
    finalities: X,
    options: J
  });
  return [
    K,
    (G = []) => {
      let [H, N, q] = xr0(K, G, Y, Q, J.enableAutoFreeze);
      return J.enablePatches ? [H, N, q] : H;
    }
  ];
}
function bi(Z) {
  let { rootDraft: J, value: $, useRawReturn: X = !1, isRoot: Y = !0 } = Z;
  if (di($, (Q, W, K) => {
    let G = L9(W);
    if (G && J && G.finalities === J.finalities) {
      Z.isContainDraft = !0;
      let H = G.original;
      if (K instanceof Set) {
        let N = Array.from(K);
        K.clear(), N.forEach((q) => K.add(Q === q ? H : q));
      } else
        I_(K, Q, H);
    } else if (typeof W === "object" && W !== null)
      Z.value = W, Z.isRoot = !1, bi(Z);
  }), Y) {
    if (!Z.isContainDraft)
      console.warn("The return value does not contain any draft, please use 'rawReturn()' to wrap the return value to improve performance.");
    if (X)
      console.warn("The return value contains drafts, please don't use 'rawReturn()' to wrap the return value.");
  }
}
function V30(Z) {
  var J;
  let $ = L9(Z);
  if (!$H(Z, $ === null || $ === void 0 ? void 0 : $.options))
    return Z;
  let X = eO(Z);
  if ($ && !$.operated)
    return $.original;
  let Y;
  function Q() {
    Y = X === 2 ? !gi(Z) ? new (Object.getPrototypeOf(Z)).constructor(Z) : new Map(Z) : X === 3 ? Array.from($.setMap.values()) : j30(Z, $ === null || $ === void 0 ? void 0 : $.options);
  }
  if ($) {
    $.finalized = !0;
    try {
      Q();
    } finally {
      $.finalized = !1;
    }
  } else
    Y = Z;
  if (di(Y, (W, K) => {
    if ($ && fF(hF($.original, W), K))
      return;
    let G = V30(K);
    if (G !== K) {
      if (Y === Z)
        Q();
      I_(Y, W, G);
    }
  }), X === 3) {
    let W = (J = $ === null || $ === void 0 ? void 0 : $.original) !== null && J !== void 0 ? J : Y;
    return !yi(W) ? new (Object.getPrototypeOf(W)).constructor(Y) : new Set(Y);
  }
  return Y;
}
function A30(Z) {
  if (!WR(Z))
    throw new Error(`current() is only used for Draft, parameter: ${Z}`);
  return V30(Z);
}
var gr0 = (Z) => {
  if (Z !== void 0 && Object.prototype.toString.call(Z) !== "[object Object]")
    throw new Error(`Invalid options: ${String(Z)}, 'options' should be an object.`);
  return function J($, X, Y) {
    var Q, W, K;
    if (typeof $ === "function" && typeof X !== "function")
      return function(w, ...V) {
        return J(w, (P) => $.call(this, P, ...V), X);
      };
    let G = $, H = X, N = Y;
    if (typeof X !== "function")
      N = X;
    if (N !== void 0 && Object.prototype.toString.call(N) !== "[object Object]")
      throw new Error(`Invalid options: ${N}, 'options' should be an object.`);
    N = Object.assign(Object.assign({}, Z), N);
    let q = WR(G) ? A30(G) : G, U = Array.isArray(N.mark) ? (w, V) => {
      for (let P of N.mark) {
        if (typeof P !== "function")
          throw new Error(`Invalid mark: ${P}, 'mark' should be a function.`);
        let I = P(w, V);
        if (I)
          return I;
      }
      return;
    } : N.mark, F = (Q = N.enablePatches) !== null && Q !== void 0 ? Q : !1, E = (W = N.strict) !== null && W !== void 0 ? W : !1, z = {
      enableAutoFreeze: (K = N.enableAutoFreeze) !== null && K !== void 0 ? K : !1,
      mark: U,
      strict: E,
      enablePatches: F
    };
    if (!$H(q, z) && typeof q === "object" && q !== null)
      throw new Error("Invalid base state: create() only supports plain objects, arrays, Set, Map or using mark() to mark the state as immutable.");
    let [D, A] = yr0(q, z);
    if (typeof X !== "function") {
      if (!$H(q, z))
        throw new Error("Invalid base state: create() only supports plain objects, arrays, Set, Map or using mark() to mark the state as immutable.");
      return [D, A];
    }
    let B;
    try {
      B = H(D);
    } catch (w) {
      throw vi(L9(D)), w;
    }
    let T = (w) => {
      let V = L9(D);
      if (!WR(w)) {
        if (w !== void 0 && !fF(w, D) && (V === null || V === void 0 ? void 0 : V.operated))
          throw new Error("Either the value is returned as a new non-draft value, or only the draft is modified without returning any value.");
        let I = w === null || w === void 0 ? void 0 : w[_r0];
        if (I) {
          let S = I[0];
          if (z.strict && typeof w === "object" && w !== null)
            bi({
              rootDraft: V,
              value: w,
              useRawReturn: !0
            });
          return A([S]);
        }
        if (w !== void 0) {
          if (typeof w === "object" && w !== null)
            bi({ rootDraft: V, value: w });
          return A([w]);
        }
      }
      if (w === D || w === void 0)
        return A([]);
      let P = L9(w);
      if (z === P.options) {
        if (P.operated)
          throw new Error("Cannot return a modified child draft.");
        return A([A30(w)]);
      }
      return A([w]);
    };
    if (B instanceof Promise)
      return B.then(T, (w) => {
        throw vi(L9(D)), w;
      });
    return T(B);
  };
}, mr0 = gr0();
var Oi1 = Object.prototype.constructor.toString();
var Hf = mr0;

// node_modules/molstar/lib/mol-util/produce.js
function WQ(Z, J) {
  if (typeof Z === "object" && !("prototype" in Z))
    return Hf({ ...Z }, J);
  return Hf(Z, J);
}

// node_modules/molstar/lib/mol-state/state/builder.js
var KR;
(function(Z) {
  function J(K) {
    let G = /* @__PURE__ */ new Set;
    for (let H of K.actions)
      switch (H.kind) {
        case "add":
          G.add(H.transform.ref);
          break;
        case "update":
          G.add(H.ref);
          break;
        case "delete":
          G.add(H.ref);
          break;
        case "insert": {
          G.add(H.ref), G.add(H.transform.ref);
          let N = K.tree.children.get(H.ref).toArray();
          for (let q of N)
            G.add(q);
          break;
        }
      }
    return Array.from(G);
  }
  function $(K, G) {
    if (!K.state || K.state.tree === K.editInfo.sourceTree) {
      let q = K.tree.asImmutable();
      if (G === null || G === void 0 ? void 0 : G.useHashVersion)
        i9.setParamHashVersion(q, J(K));
      return q;
    }
    let H = K.state.tree.asTransient();
    for (let q of K.actions)
      switch (q.kind) {
        case "add":
          H.add(q.transform);
          break;
        case "update":
          H.setParams(q.ref, q.params);
          break;
        case "delete":
          H.remove(q.ref);
          break;
        case "insert": {
          let U = H.children.get(q.ref).toArray();
          H.add(q.transform);
          for (let F of U)
            H.changeParent(F, q.transform.ref);
          break;
        }
      }
    K.editInfo.sourceTree = K.tree;
    let N = H.asImmutable();
    if (G === null || G === void 0 ? void 0 : G.useHashVersion)
      i9.setParamHashVersion(N, J(K));
    return N;
  }
  function X(K) {
    return !!K && typeof K.getTree === "function";
  }
  Z.is = X;
  function Y(K) {
    return !!K && typeof K.getTree === "function" && typeof K.ref === "string";
  }
  Z.isTo = Y;

  class Q {
    get editInfo() {
      return this.state.editInfo;
    }
    get currentTree() {
      return this.state.tree;
    }
    to(K) {
      let G = typeof K === "string" ? K : YM.is(K) ? K.transform.ref : K.ref;
      return new W(this.state, G, this);
    }
    toRoot() {
      return new W(this.state, this.state.tree.root.ref, this);
    }
    delete(K) {
      let G = X7.resolveRef(K);
      if (!G || !this.state.tree.transforms.has(G))
        return this;
      return this.editInfo.count++, this.state.tree.remove(G), this.state.actions.push({ kind: "delete", ref: G }), this;
    }
    getTree(K) {
      return $(this.state, K);
    }
    commit(K) {
      if (!this.state.state)
        throw new Error("Cannot commit template tree");
      return this.state.state.runTask(this.state.state.updateTree(this, K));
    }
    constructor(K, G) {
      this.state = { state: G, tree: K.asTransient(), actions: [], editInfo: { applied: !1, sourceTree: K, count: 0, lastUpdate: void 0 } };
    }
  }
  Z.Root = Q;

  class W {
    get editInfo() {
      return this.state.editInfo;
    }
    get selector() {
      return new sT(this.ref, this.state.state);
    }
    getApplyRoot() {
      return i9.getDecoratorRoot(this.state.tree, this.ref);
    }
    apply(K, G, H) {
      if (K.definition.isDecorator)
        return this.insert(K, G, H);
      let N = this.getApplyRoot(), q = K.apply(N, G, H);
      return this.state.tree.add(q), this.editInfo.count++, this.editInfo.lastUpdate = q.ref, this.state.actions.push({ kind: "add", transform: q }), new W(this.state, q.ref, this.root);
    }
    applyOrUpdate(K, G, H, N) {
      if (this.state.tree.transforms.has(K)) {
        let q = this.to(K);
        if (H)
          q.update(H);
        return q;
      } else
        return this.apply(G, H, { ...N, ref: K });
    }
    applyOrUpdateTagged(K, G, H, N) {
      if (G.definition.isDecorator)
        throw new Error("Can't use applyOrUpdateTagged on decorator transformers.");
      let q = this.getApplyRoot(), U = this.state.tree.children.get(q).values();
      while (!0) {
        let E = U.next();
        if (E.done)
          break;
        let R = this.state.tree.transforms.get(E.value);
        if (R && D8.hasTags(R, K)) {
          let z = this.to(E.value);
          return z.updateTagged(H, Nf(R.tags, K, N && N.tags)), z;
        }
      }
      let F = G.apply(q, H, { ...N, tags: Nf(K, N && N.tags) });
      return this.state.tree.add(F), this.editInfo.count++, this.editInfo.lastUpdate = F.ref, this.state.actions.push({ kind: "add", transform: F }), new W(this.state, F.ref, this.root);
    }
    group(K, G, H) {
      return this.apply(K, G, H);
    }
    insert(K, G, H) {
      let N = this.state.tree.children.get(this.ref).toArray(), q = K.apply(this.ref, G, H);
      this.state.tree.add(q);
      for (let U of N)
        this.state.tree.changeParent(U, q.ref);
      return this.editInfo.count++, this.editInfo.lastUpdate = q.ref, this.state.actions.push({ kind: "insert", ref: this.ref, transform: q }), new W(this.state, q.ref, this.root);
    }
    updateTagged(K, G) {
      if (this.state.tree.setParams(this.ref, K) || this.state.tree.setTags(this.ref, G))
        this.editInfo.count++, this.editInfo.lastUpdate = this.ref, this.state.actions.push({ kind: "update", ref: this.ref, params: K });
    }
    update(K, G) {
      let H;
      if (G) {
        let N = this.state.tree.transforms.get(this.ref);
        H = WQ(N.params, G);
      } else
        H = typeof K === "function" ? WQ(this.state.tree.transforms.get(this.ref).params, K) : K;
      if (this.state.tree.setParams(this.ref, H))
        this.editInfo.count++, this.editInfo.lastUpdate = this.ref, this.state.actions.push({ kind: "update", ref: this.ref, params: H });
      return this.root;
    }
    updateState(K) {
      let G = this.state.tree.transforms.get(this.ref);
      if (D8.isStateChange(G.state, K)) {
        if (this.state.tree.assignState(this.ref, K), this.editInfo.count++, this.editInfo.lastUpdate = this.ref, !this.state.actions.find((H) => H.kind === "update" && H.ref === this.ref))
          this.state.actions.push({ kind: "update", ref: this.ref, params: G.params });
      }
    }
    tag(K) {
      let G = this.state.tree.transforms.get(this.ref);
      return this.updateTagged(G.params, Nf(G.tags, K)), this;
    }
    dependsOn(K) {
      let G = this.state.tree.transforms.get(this.ref);
      if (this.state.tree.setDependsOn(this.ref, Nf(G.dependsOn, K)))
        this.editInfo.count++, this.editInfo.lastUpdate = this.ref, this.state.actions.push({ kind: "update", ref: this.ref, params: G.params });
    }
    to(K) {
      return this.root.to(K);
    }
    toRoot() {
      return this.root.toRoot();
    }
    delete(K) {
      return this.root.delete(K);
    }
    getTree(K) {
      return $(this.state, K);
    }
    commit(K) {
      if (!this.state.state)
        throw new Error("Cannot commit template tree");
      return this.state.state.runTask(this.state.state.updateTree(this, K));
    }
    constructor(K, G, H) {
      if (this.state = K, this.root = H, this.ref = G, !this.state.tree.transforms.has(G))
        throw new Error(`Could not find node '${G}'.`);
    }
  }
  Z.To = W;
})(KR || (KR = {}));
function Nf(...Z) {
  let J = void 0, $ = [];
  for (let X of Z) {
    if (!X)
      continue;
    if (!J)
      J = /* @__PURE__ */ new Set;
    if (typeof X === "string") {
      if (J.has(X))
        continue;
      J.add(X), $.push(X);
    } else
      for (let Y of X) {
        if (J.has(Y))
          continue;
        J.add(Y), $.push(Y);
      }
  }
  return $;
}

// node_modules/molstar/lib/mol-state/action/manager.js
class ci {
  constructor() {
    this.ev = xQ.create(), this.actions = /* @__PURE__ */ new Map, this.fromTypeIndex = /* @__PURE__ */ new Map, this.events = {
      added: this.ev(),
      removed: this.ev()
    };
  }
  add(Z) {
    let J = T1.is(Z) ? Z.toAction() : Z;
    if (this.actions.has(J.id))
      return this;
    this.actions.set(J.id, J);
    for (let $ of J.definition.from)
      if (this.fromTypeIndex.has($.type))
        this.fromTypeIndex.get($.type).push(J);
      else
        this.fromTypeIndex.set($.type, [J]);
    return this.events.added.next(void 0), this;
  }
  remove(Z) {
    let J = T1.is(Z) ? Z.toAction().id : R6.is(Z) ? Z : Z.id, $ = this.actions.get(J);
    if (!$)
      return this;
    this.actions.delete(J);
    for (let X of $.definition.from) {
      let Y = this.fromTypeIndex.get(X.type);
      if (!Y)
        continue;
      if (L3(Y, $), Y.length === 0)
        this.fromTypeIndex.delete(X.type);
    }
    return this.events.removed.next(void 0), this;
  }
  fromCell(Z, J) {
    let $ = Z.obj;
    if (!$)
      return [];
    let X = this.fromTypeIndex.get($.type);
    if (!X)
      return [];
    let Y = !1;
    for (let W of X)
      if (W.definition.isApplicable) {
        Y = !0;
        break;
      }
    if (!Y)
      return X;
    let Q = [];
    for (let W of X)
      if (W.definition.isApplicable) {
        if (W.definition.isApplicable($, Z.transform, J))
          Q.push(W);
      } else
        Q.push(W);
    return Q;
  }
  dispose() {
    this.ev.dispose();
  }
}

// node_modules/molstar/lib/mol-util/log-entry.js
var E3;
(function(Z) {
  function J(Q) {
    return { type: "message", timestamp: /* @__PURE__ */ new Date, message: Q };
  }
  Z.message = J;
  function $(Q) {
    return { type: "error", timestamp: /* @__PURE__ */ new Date, message: Q };
  }
  Z.error = $;
  function X(Q) {
    return { type: "warning", timestamp: /* @__PURE__ */ new Date, message: Q };
  }
  Z.warning = X;
  function Y(Q) {
    return { type: "info", timestamp: /* @__PURE__ */ new Date, message: Q };
  }
  Z.info = Y;
})(E3 || (E3 = {}));

// node_modules/molstar/lib/mol-state/tree/spine.js
var GR;
(function(Z) {

  class J {
    get current() {
      return this._current;
    }
    set current(Y) {
      this._current = Y;
    }
    getAncestorOfType(Y) {
      if (!this._current)
        return;
      let Q = this._current;
      while (!0) {
        if (Q = this.cells.get(Q.transform.parent), !Q.obj)
          return;
        if (Q.obj.type === Y.type)
          return Q.obj;
        if (Q.transform.ref === D8.RootRef)
          return;
      }
    }
    getRootOfType(Y) {
      if (!this._current)
        return;
      let Q = this._current, W = void 0;
      while (!0) {
        if (!Q.obj)
          return;
        if (Q.obj.type === Y.type)
          W = Q;
        if (Q.transform.ref === D8.RootRef)
          return W ? W.obj : void 0;
        Q = this.cells.get(Q.transform.parent);
      }
    }
    constructor(Y) {
      this.cells = Y, this._current = void 0;
    }
  }
  Z.Impl = J;
  function $(Y, Q) {
    let W = Y.cells, K = W.get(Q), G = [K];
    while (K === null || K === void 0 ? void 0 : K.transform.transformer.definition.isDecorator)
      K = W.get(K.transform.parent), G.push(K);
    return G;
  }
  Z.getDecoratorChain = $;
  function X(Y, Q, W) {
    let K = void 0, G = Y.cells.get(W);
    if (!G)
      return;
    while (!0) {
      if (!G.obj)
        return;
      if (G.obj.type === Q.type)
        K = G;
      if (G.transform.ref === D8.RootRef)
        return K ? K.obj : void 0;
      G = Y.cells.get(G.transform.parent);
    }
  }
  Z.getRootOfType = X;
})(GR || (GR = {}));

// node_modules/molstar/lib/mol-util/async-queue.js
class li {
  constructor() {
    this.queue = [], this.signal = new P6;
  }
  get length() {
    return this.queue.length;
  }
  enqueue(Z) {
    if (this.queue.push(Z), this.queue.length === 1)
      return !0;
    return this.waitFor(Z);
  }
  handled(Z) {
    if (ZH(this.queue, Z), this.queue.length > 0)
      this.signal.next({ v: this.queue[0], stillPresent: !0 });
  }
  remove(Z) {
    let J = ZH(this.queue, Z);
    if (J)
      this.signal.next({ v: Z, stillPresent: !1 });
    return J;
  }
  waitFor(Z) {
    return new Promise((J) => {
      let $ = this.signal.subscribe(({ v: X, stillPresent: Y }) => {
        if (X === Z)
          $.unsubscribe(), J(Y);
      });
    });
  }
}

// node_modules/molstar/lib/mol-data/generic/unique-array.js
var o6;
(function(Z) {
  function J() {
    return { keys: /* @__PURE__ */ new Set, array: [] };
  }
  Z.create = J;
  function $({ keys: Y, array: Q }, W, K) {
    if (Y.has(W))
      return !1;
    return Y.add(W), Q[Q.length] = K, !0;
  }
  Z.add = $;
  function X({ keys: Y }, Q) {
    return Y.has(Q);
  }
  Z.has = X;
})(o6 || (o6 = {}));

// node_modules/molstar/lib/mol-state/state.js
class wK {
  get tree() {
    return this._tree;
  }
  get transforms() {
    return this._tree.transforms;
  }
  get current() {
    return this.behaviors.currentObject.value.ref;
  }
  get root() {
    return this.cells.get(this._tree.root.ref);
  }
  build() {
    return new KR.Root(this.tree, this);
  }
  registerRefResolver(Z, J) {
    this.refResolvers.push([Z, J]);
  }
  removeRefResolver(Z) {
    this.refResolvers = this.refResolvers.filter((J) => J[0] !== Z);
  }
  addHistory(Z, J) {
    if (this.historyCapacity === 0)
      return;
    if (this.history.unshift([Z, J || "Update"]), this.history.length > this.historyCapacity)
      this.history.pop();
    this.events.historyUpdated.next({ state: this });
  }
  clearHistory() {
    if (this.history.length === 0)
      return;
    this.history = [], this.events.historyUpdated.next({ state: this });
  }
  get latestUndoLabel() {
    return this.history.length > 0 ? this.history[0][1] : void 0;
  }
  get canUndo() {
    return this.history.length > 0;
  }
  undo() {
    return n0.create("Undo", async (Z) => {
      let J = this.history.shift();
      if (!J)
        return;
      this.events.historyUpdated.next({ state: this }), this.undoingHistory = !0;
      try {
        await this.updateTree(J[0], { canUndo: !1 }).runInContext(Z);
      } finally {
        this.undoingHistory = !1;
      }
    });
  }
  getSnapshot() {
    return { tree: i9.toJSON(this._tree) };
  }
  setSnapshot(Z) {
    let J = i9.fromJSON(Z.tree);
    return this.updateTree(J);
  }
  setCurrent(Z) {
    this.behaviors.currentObject.next({ state: this, ref: Z });
  }
  updateCellState(Z, J) {
    let $ = this.cells.get(Z);
    if (!$)
      return;
    let X = typeof J === "function" ? J($.state) : J;
    if (D8.assignState($.state, X))
      $.transform = this._tree.assignState($.transform.ref, X), this.events.cell.stateUpdated.next({ state: this, ref: Z, cell: $ });
  }
  dispose() {
    this.ev.dispose(), this.actions.dispose();
  }
  select(Z) {
    return f2.select(Z, this);
  }
  selectQ(Z) {
    if (typeof Z === "string")
      return f2.select(Z, this);
    return f2.select(Z(f2.Generators), this);
  }
  applyAction(Z, J, $ = D8.RootRef) {
    return n0.create("Apply Action", (X) => {
      let Y = this.cells.get($);
      if (!Y)
        throw new Error(`'${$}' does not exist.`);
      if (Y.status !== "ok")
        throw new Error(`Action cannot be applied to a cell with status '${Y.status}'`);
      return oi(Z.definition.run({ ref: $, cell: Y, a: Y.obj, params: J, state: this }, this.globalContext), X);
    });
  }
  transaction(Z, J) {
    return n0.create("State Transaction", async ($) => {
      let X = this.inTransaction, Y = this._tree.asImmutable(), Q = !1;
      try {
        if (!X)
          this.behaviors.isUpdating.next(!0);
        if (this.inTransaction = !0, this.inTransactionError = !1, await Z($), this.inTransactionError)
          Q = !0, await this.updateTree(Y).runInContext($);
      } catch (W) {
        if (!Q)
          Q = !0, await this.updateTree(Y).runInContext($), this.events.log.next(E3.error("Error during state transaction, reverting"));
        if (X)
          throw this.inTransactionError = !0, W;
        if (J === null || J === void 0 ? void 0 : J.rethrowErrors)
          throw W;
        else
          console.error(W);
      } finally {
        if (!X) {
          if (this.inTransaction = !1, this.events.changed.next({ state: this, inTransaction: !1 }), this.behaviors.isUpdating.next(!1), !Q)
            if (J === null || J === void 0 ? void 0 : J.canUndo)
              this.addHistory(Y, typeof J.canUndo === "string" ? J.canUndo : void 0);
            else
              this.clearHistory();
        }
      }
    });
  }
  get inUpdate() {
    return this._inUpdate;
  }
  updateTree(Z, J) {
    let $ = { tree: Z, options: J };
    return n0.create("Update Tree", async (X) => {
      if (!await this.updateQueue.enqueue($))
        return;
      this._inUpdate = !0;
      let Q = (J === null || J === void 0 ? void 0 : J.canUndo) ? this._tree.asImmutable() : void 0, W = !1;
      if (!this.inTransaction)
        this.behaviors.isUpdating.next(!0);
      try {
        if (KR.is(Z)) {
          if (Z.editInfo.applied)
            throw new Error("This builder has already been applied. Create a new builder for further state updates");
          Z.editInfo.applied = !0;
        }
        this.reverted = !1;
        let K = J && (J.revertIfAborted || J.revertOnError) ? await this._revertibleTreeUpdate(X, $, J) : await this._updateTree(X, $);
        if (W = this.reverted, K.ctx.hadError)
          this.inTransactionError = !0;
        if (!K.cell)
          return;
        return new sT(K.cell.transform.ref, this);
      } finally {
        if (this._inUpdate = !1, this.updateQueue.handled($), !this.inTransaction) {
          if (this.behaviors.isUpdating.next(!1), !(J === null || J === void 0 ? void 0 : J.canUndo)) {
            if (!this.undoingHistory)
              this.clearHistory();
          } else if (!W)
            this.addHistory(Q, typeof J.canUndo === "string" ? J.canUndo : void 0);
        }
      }
    }, () => {
      this.updateQueue.remove($);
    });
  }
  async _revertibleTreeUpdate(Z, J, $) {
    let X = this.tree, Y = await this._updateTree(Z, J);
    if ((Y.ctx.hadError || Y.ctx.wasAborted) && $.revertOnError || Y.ctx.wasAborted && $.revertIfAborted)
      return this.reverted = !0, await this._updateTree(Z, { tree: X, options: J.options });
    return Y;
  }
  async _updateTree(Z, J) {
    let $ = !1, X = this.updateTreeAndCreateCtx(J.tree, Z, J.options);
    try {
      if ($ = await pr0(X), KR.isTo(J.tree)) {
        let Y = this.select(J.tree.ref)[0];
        return { ctx: X, cell: Y };
      }
      return { ctx: X };
    } finally {
      if (this.spine.current = void 0, $)
        this.events.changed.next({ state: this, inTransaction: this.inTransaction });
    }
  }
  updateTreeAndCreateCtx(Z, J, $) {
    let X = (KR.is(Z) ? Z.getTree() : Z).asTransient(), Y = this._tree;
    this._tree = X;
    let Q = {
      parent: this,
      editInfo: KR.is(Z) ? Z.editInfo : void 0,
      errorFree: this.errorFree,
      taskCtx: J,
      oldTree: Y,
      tree: X,
      cells: this.cells,
      spine: this.spine,
      results: [],
      options: { ...dr0, ...$ },
      changed: !1,
      hadError: !1,
      wasAborted: !1,
      newCurrent: void 0,
      getCellData: this.tryGetCellData
    };
    return this.errorFree = !0, Q;
  }
  constructor(Z, J) {
    this.errorFree = !0, this.ev = xQ.create(), this.globalContext = void 0, this.events = {
      cell: {
        stateUpdated: this.ev(),
        created: this.ev(),
        removed: this.ev()
      },
      object: {
        updated: this.ev(),
        created: this.ev(),
        removed: this.ev()
      },
      log: this.ev(),
      changed: this.ev(),
      historyUpdated: this.ev()
    }, this.behaviors = {
      currentObject: this.ev.behavior({ state: this, ref: D8.RootRef }),
      isUpdating: this.ev.behavior(!1)
    }, this.actions = new ci, this.cells = /* @__PURE__ */ new Map, this.spine = new GR.Impl(this.cells), this.refResolvers = [], this.tryGetCellData = (Y) => {
      var Q, W;
      let K = (W = (Q = this.cells.get(Y)) === null || Q === void 0 ? void 0 : Q.obj) === null || W === void 0 ? void 0 : W.data;
      if (K === void 0) {
        for (let [, G] of this.refResolvers)
          if (K = G(this, Y), K !== void 0)
            break;
        if (K === void 0)
          throw new Error(`Cell '${Y}' data undefined.`);
      }
      return K;
    }, this.historyCapacity = 5, this.history = [], this.undoingHistory = !1, this.inTransaction = !1, this.inTransactionError = !1, this._inUpdate = !1, this.reverted = !1, this.updateQueue = new li, this._tree = i9.createEmpty(D8.createRoot(J && J.rootState)).asTransient();
    let X = this._tree.root;
    if (this.runTask = J.runTask, (J === null || J === void 0 ? void 0 : J.historyCapacity) !== void 0)
      this.historyCapacity = J.historyCapacity;
    this.cells.set(X.ref, {
      parent: this,
      transform: X,
      sourceRef: void 0,
      obj: Z,
      status: "ok",
      state: { ...X.state },
      errorText: void 0,
      params: {
        definition: {},
        values: {}
      },
      dependencies: { dependentBy: [], dependsOn: [] },
      cache: {}
    }), this.globalContext = J && J.globalContext;
  }
}
(function(Z) {
  function J(X, Y) {
    return new Z(X, Y);
  }
  Z.create = J;
  let $;
  (function(X) {
    function Y(Q, W) {
      return !!W && Q.ref === W.transform.ref && Q.state === W.parent;
    }
    X.isCell = Y;
  })($ = Z.ObjectEvent || (Z.ObjectEvent = {}));
})(wK || (wK = {}));
var dr0 = {
  doNotLogTiming: !1,
  doNotUpdateCurrent: !0,
  revertIfAborted: !1,
  revertOnError: !1,
  canUndo: !1
};
async function pr0(Z) {
  let J = !!(Z.editInfo && Z.editInfo.count === 1 && Z.editInfo.lastUpdate && Z.editInfo.sourceTree === Z.oldTree), $, X = [], Y;
  if (J)
    $ = [], Y = [Z.editInfo.lastUpdate];
  else {
    $ = nr0(Z);
    let K = Z.parent.current, G = !1;
    for (let H of $)
      if (H === K) {
        G = !0;
        break;
      }
    if (G) {
      let H = I30(Z.oldTree, K, $, Z.cells);
      Z.parent.setCurrent(H);
    }
    for (let H = $.length - 1;H >= 0; H--) {
      let N = Z.cells.get($[H]);
      if (N)
        qf(N.transform, N.obj, N === null || N === void 0 ? void 0 : N.transform.params, N.cache, Z.parent.globalContext);
    }
    for (let H of $) {
      let N = Z.cells.get(H);
      if (N)
        N.parent = void 0, rr0(N);
      let q = N && N.obj;
      Z.cells.delete(H), X.push(q);
    }
    Y = ur0(Z.cells, Z.tree);
  }
  let Q = Zt0(Z, Y);
  for (let K of Q.added)
    Z.parent.events.cell.created.next({ state: Z.parent, ref: K.transform.ref, cell: K });
  for (let K = 0;K < $.length; K++) {
    let G = $[K], H = Z.oldTree.transforms.get(G).parent;
    Z.parent.events.object.removed.next({ state: Z.parent, ref: G, obj: X[K] }), Z.parent.events.cell.removed.next({ state: Z.parent, ref: G, parent: H });
  }
  if (X.length)
    X = [];
  if (Q.dependent)
    for (let K of Q.dependent)
      Y.push(K.transform.ref);
  ar0(Z, Y);
  for (let K of Y)
    await k30(Z, K);
  if (!Z.editInfo)
    or0(Z);
  let W = Z.newCurrent;
  for (let K of Z.results)
    if (K.action === "created") {
      if (Z.parent.events.object.created.next({ state: Z.parent, ref: K.ref, obj: K.obj }), !Z.newCurrent) {
        if (!Z.tree.transforms.get(K.ref).state.isGhost && K.obj !== LZ.Null)
          W = K.ref;
      }
    } else if (K.action === "updated")
      Z.parent.events.object.updated.next({ state: Z.parent, ref: K.ref, action: "in-place", obj: K.obj, oldData: K.oldData });
    else if (K.action === "replaced")
      Z.parent.events.object.updated.next({ state: Z.parent, ref: K.ref, action: "recreate", obj: K.obj, oldObj: K.oldObj });
  if (W) {
    if (!Z.options.doNotUpdateCurrent)
      Z.parent.setCurrent(W);
  } else {
    let K = Z.parent.current, G = Z.cells.get(K);
    if (G && (G.obj === LZ.Null || G.status === "error" && G.errorText === Jt0))
      W = I30(Z.oldTree, K, [], Z.cells), Z.parent.setCurrent(W);
  }
  return $.length > 0 || Y.length > 0 || Z.changed;
}
function ur0(Z, J) {
  let $ = { roots: [], cells: Z };
  return i9.doPreOrder(J, J.root, $, cr0), $.roots;
}
function cr0(Z, J, $) {
  let X = $.cells.get(Z.ref);
  if (!X || X.transform.version !== Z.version)
    return $.roots.push(Z.ref), !1;
  if (X.status === "error")
    return !1;
  if (X && X.obj === LZ.Null)
    return !1;
  return !0;
}
function lr0(Z, J, $) {
  if (!$.newTree.transforms.has(Z.ref) && $.cells.has(Z.ref))
    $.deletes.push(Z.ref);
}
function nr0(Z) {
  let J = { newTree: Z.tree, cells: Z.cells, deletes: [] };
  return i9.doPostOrder(Z.oldTree, Z.oldTree.root, J, lr0), J.deletes;
}
function ir0(Z, J, $) {
  let X = $.cells.get(Z.ref);
  if (!X || !D8.syncState(X.state, Z.state))
    return;
  $.parent.events.cell.stateUpdated.next({ state: $.parent, ref: Z.ref, cell: X });
}
function or0(Z) {
  i9.doPreOrder(Z.tree, Z.tree.root, Z, ir0);
}
function Ff(Z, J, $, X) {
  let Y = Z.cells.get(J), Q = Y.status !== $;
  if (Y.status = $, Y.errorText = X, Q)
    Z.parent.events.cell.stateUpdated.next({ state: Z.parent, ref: J, cell: Y });
}
function sr0(Z, J, $) {
  $.cells.get(Z.ref).transform = Z, Ff($, Z.ref, "pending");
}
function ar0(Z, J) {
  for (let $ of J)
    i9.doPreOrder(Z.tree, Z.tree.transforms.get($), Z, sr0);
}
function rr0(Z) {
  for (let J of Z.dependencies.dependsOn)
    L3(J.dependencies.dependentBy, Z);
}
function tr0(Z, J, { ctx: $, added: X, visited: Y }) {
  if (Y.add(Z.ref), $.cells.has(Z.ref))
    return;
  let Q = {
    parent: $.parent,
    transform: Z,
    sourceRef: void 0,
    status: "pending",
    state: { ...Z.state },
    errorText: void 0,
    params: void 0,
    dependencies: { dependentBy: [], dependsOn: [] },
    cache: void 0
  };
  $.cells.set(Z.ref, Q), X.push(Q);
}
function er0(Z, J) {
  if (!Z.transform.dependsOn)
    return;
  for (let $ of Z.transform.dependsOn) {
    if (!J.tree.transforms.get($))
      throw new Error("Cannot depend on a non-existent transform.");
    let Y = J.cells.get($);
    n9(Z.dependencies.dependsOn, Y), n9(Y.dependencies.dependentBy, Z);
  }
}
function Zt0(Z, J) {
  let $ = { ctx: Z, visited: /* @__PURE__ */ new Set, added: [] };
  for (let Y of J)
    i9.doPreOrder(Z.tree, Z.tree.transforms.get(Y), $, tr0);
  for (let Y of $.added)
    er0(Y, Z);
  let X;
  return $.visited.forEach((Y) => {
    let Q = Z.cells.get(Y);
    for (let W of Q.dependencies.dependentBy) {
      if ($.visited.has(W.transform.ref))
        continue;
      if (!X)
        X = o6.create();
      o6.add(X, W.transform.ref, W);
    }
  }), { added: $.added, dependent: X ? X.array : void 0 };
}
function I30(Z, J, $, X) {
  let Y = new Set($);
  return C30(Z, J, Y, X);
}
function C30(Z, J, $, X) {
  if (J === D8.RootRef)
    return J;
  let Y = Z.transforms.get(J), Q = Z.children.get(Y.parent).values(), W = void 0, K = !1;
  while (!0) {
    let G = Q.next();
    if (G.done)
      break;
    if ($.has(G.value))
      continue;
    let H = X.get(G.value);
    if (!H || H.status === "error" || H.obj === LZ.Null)
      continue;
    let N = Z.transforms.get(G.value);
    if (N.state.isGhost)
      continue;
    if (G.value === J) {
      if (K = !0, !$.has(J))
        W = J;
      continue;
    }
    if (K)
      return N.ref;
    W = N.ref;
  }
  if (W)
    return W;
  return C30(Z, Y.parent, $, X);
}
function ii(Z, J, $, X) {
  if (!X)
    Z.hadError = !0, Z.parent.errorFree = !1;
  let Y = Z.cells.get(J);
  if ($) {
    Z.wasAborted = Z.wasAborted || n0.isAbort($);
    let W = "" + $;
    if (Ff(Z, J, "error", W), !X)
      Z.parent.events.log.next({ type: "error", timestamp: /* @__PURE__ */ new Date, message: W });
  } else
    Y.params = void 0;
  if (Y.obj) {
    let W = Y.obj;
    Y.obj = void 0, Y.cache = void 0, Z.parent.events.object.removed.next({ state: Z.parent, ref: J, obj: W });
  }
  let Q = Z.tree.children.get(J).values();
  while (!0) {
    let W = Q.next();
    if (W.done)
      return;
    ii(Z, W.value, void 0, X);
  }
}
var Jt0 = "Parent is null";
async function k30(Z, J) {
  Ff(Z, J, "processing");
  let $ = !1;
  try {
    let Y = m6(), Q = await Xt0(Z, J), W = m6() - Y;
    if (Q.action !== "none")
      Z.changed = !0;
    if (Ff(Z, J, "ok"), Z.results.push(Q), Q.action === "created") {
      if ($ = Q.obj === LZ.Null, !$ && !Z.options.doNotLogTiming)
        Z.parent.events.log.next(E3.info(`Created ${Q.obj.label} in ${XM(W)}.`));
    } else if (Q.action === "updated") {
      if ($ = Q.obj === LZ.Null, !$ && !Z.options.doNotLogTiming)
        Z.parent.events.log.next(E3.info(`Updated ${Q.obj.label} in ${XM(W)}.`));
    } else if (Q.action === "replaced") {
      if ($ = Q.obj === LZ.Null, !$ && !Z.options.doNotLogTiming)
        Z.parent.events.log.next(E3.info(`Updated ${Q.obj.label} in ${XM(W)}.`));
    }
  } catch (Y) {
    if (Z.changed = !0, !Z.hadError)
      Z.newCurrent = J;
    ii(Z, J, Y, !1), console.error(Y);
    return;
  }
  let X = Z.tree.children.get(J).values();
  while (!0) {
    let Y = X.next();
    if (Y.done)
      return;
    if ($)
      ii(Z, Y.value, void 0, !0);
    else
      await k30(Z, Y.value);
  }
}
function $t0(Z, J, $, X) {
  let Y = J.transformer.definition.params, Q = Y ? Y($, Z.parent.globalContext) : {};
  if (J.version !== J._normalized_param_version)
    J.params = j.normalizeParams(Q, J.params, "all"), J._normalized_param_version = J.version;
  else {
    let W = j.getDefaultValues(Q);
    J.params = J.params ? p50(J.params, W) : W;
  }
  return j.resolveRefs(Q, J.params, Z.getCellData), { definition: Q, values: J.params };
}
async function Xt0(Z, J) {
  var $;
  let { oldTree: X, tree: Y } = Z, Q = Z.cells.get(J), W = Q.transform;
  if (Q.transform.ref === D8.RootRef)
    return { action: "none" };
  let K = Z.cells.get(Q.transform.parent);
  if ((K === null || K === void 0 ? void 0 : K.obj) === LZ.Null)
    if (Q.sourceRef = K.transform.ref, X.transforms.has(J) && Q.params) {
      let U = Q.params.values, F = Q.cache;
      return qf(W, Q.obj, U, F, Z.parent.globalContext), Q.params = void 0, Q.obj = LZ.Null, { ref: J, action: "updated", obj: Q.obj };
    } else
      return Q.params = void 0, { ref: J, action: "created", obj: LZ.Null };
  let H = W.transformer.definition.from.length === 0 ? K : f2.findAncestorOfType(Y, Z.cells, J, W.transformer.definition.from);
  if (!H)
    throw new Error(`No suitable parent found for '${J}'`);
  Z.spine.current = Q;
  let N = H.obj;
  Q.sourceRef = H.transform.ref;
  let q = $t0(Z, W, N, Q);
  if (!X.transforms.has(J) || !Q.params) {
    Q.params = q;
    let U = await P30(Z, Q, W.transformer, N, q.values);
    return ni(U, W), Q.obj = U, { ref: J, action: "created", obj: U };
  } else {
    let U = Q.params.values, F = Q.cache, E = ($ = Q.obj) === null || $ === void 0 ? void 0 : $.data, R = q.values;
    switch (Q.params = q, !!Q.obj && Q.obj !== LZ.Null ? await Yt0(Z, Q, W.transformer, N, Q.obj, U, R) : T1.UpdateResult.Recreate) {
      case T1.UpdateResult.Recreate: {
        let D = Q.obj;
        qf(W, D, U, F, Z.parent.globalContext);
        let A = await P30(Z, Q, W.transformer, N, R);
        return ni(A, W), Q.obj = A, { ref: J, action: "replaced", oldObj: D, obj: A };
      }
      case T1.UpdateResult.Updated:
        return ni(Q.obj, W), { ref: J, action: "updated", oldData: E, obj: Q.obj };
      case T1.UpdateResult.Null:
        return qf(W, Q.obj, U, F, Z.parent.globalContext), Q.obj = LZ.Null, { ref: J, action: "updated", obj: Q.obj };
      default:
        return { action: "none" };
    }
  }
}
function qf(Z, J, $, X, Y) {
  var Q, W;
  (W = (Q = Z.transformer.definition).dispose) === null || W === void 0 || W.call(Q, {
    b: J !== LZ.Null ? J : void 0,
    params: $,
    cache: X
  }, Y);
}
function ni(Z, J) {
  if (!Z || Z === LZ.Null)
    return;
  Z.tags = J.tags;
}
function oi(Z, J) {
  if (typeof Z.runInContext === "function")
    return Z.runInContext(J);
  return Z;
}
function v30(Z) {
  if (Z.dependencies.dependsOn.length === 0)
    return;
  let J = Object.create(null);
  for (let $ of Z.dependencies.dependsOn) {
    if (!$.obj)
      throw new Error("Unresolved dependency.");
    J[$.transform.ref] = $.obj;
  }
  return J;
}
function P30(Z, J, $, X, Y) {
  if (!J.cache)
    J.cache = Object.create(null);
  return oi($.definition.apply({ a: X, params: Y, cache: J.cache, spine: Z.spine, dependencies: v30(J) }, Z.parent.globalContext), Z.taskCtx);
}
async function Yt0(Z, J, $, X, Y, Q, W) {
  if (!$.definition.update)
    return T1.UpdateResult.Recreate;
  if (!J.cache)
    J.cache = Object.create(null);
  return oi($.definition.update({ a: X, oldParams: Q, b: Y, newParams: W, cache: J.cache, spine: Z.spine, dependencies: v30(J) }, Z.parent.globalContext), Z.taskCtx);
}
// node_modules/molstar/lib/mol-plugin-state/objects.js
var D0;
(function(Z) {
  Z.Create = LZ.factory();
  function J(U) {
    return !!U && U.type.typeClass === "Representation3D";
  }
  Z.isRepresentation3D = J;
  function $(U) {
    return !!U && U.type.typeClass === "Behavior";
  }
  Z.isBehavior = $;
  function X(U) {
    return Z.Create({ ...U, typeClass: "Representation3D" });
  }
  Z.CreateRepresentation3D = X;
  function Y(U) {
    return Z.Create({ ...U, typeClass: "Behavior" });
  }
  Z.CreateBehavior = Y;

  class Q extends Z.Create({ name: "Root", typeClass: "Root" }) {
  }
  Z.Root = Q;

  class W extends Z.Create({ name: "Group", typeClass: "Group" }) {
  }
  Z.Group = W;
  let K;
  (function(U) {

    class F extends Z.Create({ name: "String Data", typeClass: "Data" }) {
    }
    U.String = F;

    class E extends Z.Create({ name: "Binary Data", typeClass: "Data" }) {
    }
    U.Binary = E;

    class R extends Z.Create({ name: "Data Blob", typeClass: "Data" }) {
    }
    U.Blob = R;
  })(K = Z.Data || (Z.Data = {}));
  let G;
  (function(U) {

    class F extends Z.Create({ name: "JSON Data", typeClass: "Data" }) {
    }
    U.Json = F;

    class E extends Z.Create({ name: "CIF File", typeClass: "Data" }) {
    }
    U.Cif = E;

    class R extends Z.Create({ name: "Cube File", typeClass: "Data" }) {
    }
    U.Cube = R;

    class z extends Z.Create({ name: "PSF File", typeClass: "Data" }) {
    }
    U.Psf = z;

    class D extends Z.Create({ name: "PRMTOP File", typeClass: "Data" }) {
    }
    U.Prmtop = D;

    class A extends Z.Create({ name: "TOP File", typeClass: "Data" }) {
    }
    U.Top = A;

    class B extends Z.Create({ name: "PLY File", typeClass: "Data" }) {
    }
    U.Ply = B;

    class T extends Z.Create({ name: "CCP4/MRC/MAP File", typeClass: "Data" }) {
    }
    U.Ccp4 = T;

    class w extends Z.Create({ name: "DSN6/BRIX File", typeClass: "Data" }) {
    }
    U.Dsn6 = w;

    class V extends Z.Create({ name: "DX File", typeClass: "Data" }) {
    }
    U.Dx = V;

    class P extends Z.Create({ name: "Format Blob", typeClass: "Data" }) {
    }
    U.Blob = P;
  })(G = Z.Format || (Z.Format = {}));
  let H;
  (function(U) {

    class F extends Z.Create({ name: "Coordinates", typeClass: "Object" }) {
    }
    U.Coordinates = F;

    class E extends Z.Create({ name: "Topology", typeClass: "Object" }) {
    }
    U.Topology = E;

    class R extends Z.Create({ name: "Model", typeClass: "Object" }) {
    }
    U.Model = R;

    class z extends Z.Create({ name: "Trajectory", typeClass: "Object" }) {
    }
    U.Trajectory = z;

    class D extends Z.Create({ name: "Structure", typeClass: "Object" }) {
    }
    U.Structure = D, function(A) {

      class B extends X({ name: "Structure 3D" }) {
      }
      A.Representation3D = B;

      class T extends Z.Create({ name: "Structure 3D State", typeClass: "Object" }) {
      }
      A.Representation3DState = T;

      class w extends Z.Create({ name: "Selections", typeClass: "Object" }) {
      }
      A.Selections = w;
    }(D = U.Structure || (U.Structure = {}));
  })(H = Z.Molecule || (Z.Molecule = {}));
  let N;
  (function(U) {

    class F extends Z.Create({ name: "Volume", typeClass: "Object" }) {
    }
    U.Data = F;

    class E extends Z.Create({ name: "Lazy Volume", typeClass: "Object" }) {
    }
    U.Lazy = E;

    class R extends X({ name: "Volume 3D" }) {
    }
    U.Representation3D = R;
  })(N = Z.Volume || (Z.Volume = {}));
  let q;
  (function(U) {

    class F extends Z.Create({ name: "Shape Provider", typeClass: "Object" }) {
    }
    U.Provider = F;

    class E extends X({ name: "Shape 3D" }) {
    }
    U.Representation3D = E;
  })(q = Z.Shape || (Z.Shape = {}));
})(D0 || (D0 = {}));
var B2;
(function(Z) {
  Z.CreateBuiltIn = T1.factory("ms-plugin"), Z.BuiltIn = T1.builderFactory("ms-plugin");
})(B2 || (B2 = {}));

// node_modules/molstar/lib/mol-plugin/behavior/dynamic/volume-streaming/model.js
class P_ extends D0.Create({ name: "Volume Streaming", typeClass: "Object" }) {
}
var S30;
(function(Z) {
  let J;
  (function($) {
    $.Float32 = "float32", $.Int8 = "int8";
  })(J = Z.ValueType || (Z.ValueType = {}));
})(S30 || (S30 = {}));

// node_modules/molstar/lib/mol-util/url.js
function HR(Z, J) {
  return `${Z}${Z[Z.length - 1] === "/" || J[0] === "/" ? "" : "/"}${J}`;
}

// node_modules/molstar/lib/mol-data/util/sort.js
function Uf(Z, J, $) {
  return Z[J] - Z[$];
}
function bF(Z, J, $) {
  let X = Z[J];
  Z[J] = Z[$], Z[$] = X;
}
function f30(Z, J, $, X) {
  let Y = $ + X >> 1;
  if (J(Z, $, X) > 0)
    return J(Z, $, Y) > 0 ? J(Z, Y, X) > 0 ? Y : X : $;
  else
    return J(Z, X, Y) > 0 ? J(Z, Y, $) > 0 ? Y : $ : X;
}
function Qt0(Z, J, $) {
  let { cmp: X, swap: Y, data: Q, parts: W } = Z, K = J + 1, G = $;
  Y(Q, J, f30(Q, X, J, $));
  while (X(Q, G, J) > 0)
    --G;
  for (let H = J + 1;H <= G; H++) {
    let N = X(Q, H, J);
    if (N > 0) {
      Y(Q, H, G), --G;
      while (X(Q, G, J) > 0)
        --G;
      H--;
    } else if (N === 0)
      Y(Q, H, K), K++;
  }
  for (let H = J;H < K; H++)
    Y(Q, H, J + G - H);
  W[0] = G - K + J + 1, W[1] = G;
}
function Wt0({ data: Z, cmp: J, swap: $ }, X, Y) {
  for (let Q = X + 1;Q <= Y; Q++) {
    let W = Q - 1;
    while (W >= X && J(Z, W, W + 1) > 0)
      $(Z, W, W + 1), W = W - 1;
  }
}
function Lf(Z, J, $) {
  let { parts: X } = Z;
  while (J < $) {
    if ($ - J < 16) {
      Wt0(Z, J, $);
      return;
    }
    Qt0(Z, J, $);
    let Y = X[0], Q = X[1];
    if (Y - J < $ - Q)
      Lf(Z, J, Y - 1), J = Q + 1;
    else
      Lf(Z, Q + 1, $), $ = Y - 1;
  }
}
function Kt0(Z, J, $, X) {
  let Y = $ + 1, Q = X;
  bF(Z, $, f30(Z, Uf, $, X));
  let W = Z[$];
  while (Z[Q] > W)
    --Q;
  for (let K = $ + 1;K <= Q; K++) {
    let G = Z[K];
    if (G > W) {
      bF(Z, K, Q), --Q;
      while (Z[Q] > W)
        --Q;
      K--;
    } else if (G === W)
      bF(Z, K, Y), ++Y;
  }
  for (let K = $;K < Y; K++)
    bF(Z, K, $ + Q - K);
  J[0] = Q - Y + $ + 1, J[1] = Q;
}
function Gt0(Z, J, $) {
  for (let X = J + 1;X <= $; X++) {
    let Y = Z[X], Q = X - 1;
    while (Q >= J && Z[Q] > Y)
      Z[Q + 1] = Z[Q], Q = Q - 1;
    Z[Q + 1] = Y;
  }
}
function si(Z, J, $, X) {
  while ($ < X) {
    if (X - $ < 16) {
      Gt0(Z, $, X);
      return;
    }
    Kt0(Z, J, $, X);
    let Y = J[0], Q = J[1];
    if (Y - $ < X - Q)
      si(Z, J, $, Y - 1), $ = Q + 1;
    else
      si(Z, J, Q + 1, X), X = Y - 1;
  }
}
function t$(Z, J = Uf) {
  return Ht0(Z, 0, Z.length, J);
}
function Ht0(Z, J, $, X = Uf) {
  if (X === Uf)
    si(Z, [0, 0], J, $ - 1);
  else
    Lf({ data: Z, cmp: X, swap: bF, parts: [0, 0] }, J, $ - 1);
  return Z;
}
function Rf(Z, J, $, X, Y) {
  return Lf({ data: Z, cmp: X, swap: Y, parts: [0, 0] }, J, $ - 1), Z;
}

// node_modules/molstar/lib/mol-data/int/tuple.js
var JJ;
(function(Z) {
  Z.Zero = 0;
  let { _int32: J, _float64: $, _int32_1: X, _float64_1: Y } = function() {
    let R = new ArrayBuffer(8), z = new ArrayBuffer(8);
    return {
      _int32: new Int32Array(R),
      _float64: new Float64Array(R),
      _int32_1: new Int32Array(z),
      _float64_1: new Float64Array(z)
    };
  }();
  function Q(R) {
    return typeof R === "number";
  }
  Z.is = Q;
  function W(R, z) {
    return J[0] = R, J[1] = z, $[0];
  }
  Z.create = W;
  function K(R) {
    return $[0] = R, J[1] - J[0];
  }
  Z.diff = K;
  function G(R) {
    return $[0] = R, J[0];
  }
  Z.fst = G;
  function H(R) {
    return $[0] = R, J[1];
  }
  Z.snd = H;
  function N(R, z) {
    return $[0] = R, Y[0] = z, J[0] === X[0] && J[1] === X[1];
  }
  Z.areEqual = N;
  function q(R, z) {
    $[0] = R, Y[0] = z;
    let D = J[0] - X[0];
    if (D !== 0)
      return D;
    return J[1] - X[1];
  }
  Z.compare = q;
  function U(R, z, D) {
    $[0] = R[z], Y[0] = R[D];
    let A = J[0] - X[0];
    if (A !== 0)
      return A;
    return J[1] - X[1];
  }
  Z.compareInArray = U;
  function F(R) {
    return $[0] = R, SQ(J[0], J[1]);
  }
  Z.hashCode = F;
  function E(R) {
    return $[0] = R, `(${J[0]}, ${J[1]})`;
  }
  Z.toString = E;
})(JJ || (JJ = {}));

// node_modules/molstar/lib/mol-data/int/impl/interval.js
var ai = JJ.Zero;
function ri(Z, J) {
  return J < Z ? JJ.create(Z, Z) : JJ.create(Z, J + 1);
}
function Of(Z, J) {
  return J <= Z ? JJ.create(Z, Z) : JJ.create(Z, J);
}
function h30(Z) {
  return Z < 0 ? JJ.create(0, 0) : JJ.create(0, Z);
}
var b30 = JJ.is, XH = JJ.fst, bN = JJ.snd, C_ = JJ.fst;
function k_(Z) {
  return JJ.snd(Z) - 1;
}
var NR = JJ.diff, x30 = JJ.hashCode, y30 = JJ.toString;
function g30(Z, J) {
  return JJ.fst(Z) <= J && J < JJ.snd(Z);
}
function m30(Z, J) {
  let $ = XH(Z);
  return J >= $ && J < bN(Z) ? J - $ : -1;
}
function d30(Z, J) {
  return JJ.fst(Z) + J;
}
var p30 = JJ.areEqual;
function ti(Z, J) {
  let $ = NR(Z), X = NR(J);
  if ($ === 0 && X === 0)
    return !0;
  return $ > 0 && X > 0 && k_(Z) >= C_(J) && C_(Z) <= k_(J);
}
function u30(Z, J) {
  if (!NR(Z))
    return NR(J) === 0;
  if (!NR(J))
    return !0;
  return XH(Z) <= XH(J) && bN(Z) >= bN(J);
}
function Ef(Z, J) {
  let $ = XH(Z);
  if (J <= $)
    return 0;
  let X = bN(Z);
  if (J >= X)
    return X - $;
  return J - $;
}
function c30(Z, J, $) {
  let X = XH($), Y = XH(Z);
  if (J <= X + Y)
    return X;
  let Q = bN($);
  if (J >= Q + Y)
    return Q;
  return J - Y;
}
function ei(Z, J, $) {
  return Of(Ef(Z, J), Ef(Z, $ + 1));
}
function l30(Z, J) {
  if (!ti(Z, J))
    return ai;
  return Of(Math.max(XH(Z), XH(J)), Math.min(bN(Z), bN(J)));
}
function n30(Z, J) {
  return NR(ei(Z, C_(J), k_(J)));
}
function i30(Z, J) {
  return JJ.create(XH(Z) + J, bN(Z) + J);
}

// node_modules/molstar/lib/mol-data/int/interval.js
var k0;
(function(Z) {
  Z.Empty = ai, Z.ofSingleton = (J) => ri(J, J), Z.ofRange = ri, Z.ofBounds = Of, Z.ofLength = h30, Z.is = b30, Z.has = g30, Z.indexOf = m30, Z.getAt = d30, Z.start = XH, Z.end = bN, Z.min = C_, Z.max = k_, Z.size = NR, Z.hashCode = x30, Z.toString = y30, Z.areEqual = p30, Z.areIntersecting = ti, Z.isSubInterval = u30, Z.findPredecessorIndex = Ef, Z.findPredecessorIndexInInterval = c30, Z.findRange = ei, Z.intersectionSize = n30, Z.intersect = l30, Z.offset = i30;
})(k0 || (k0 = {}));

// node_modules/molstar/lib/mol-data/int/impl/sorted-array.js
var bM = [];
function o30(Z) {
  return [Z];
}
function FR(Z) {
  return Z;
}
function s30(Z) {
  return t$(Z), Z;
}
function Zo(Z, J) {
  if (J < Z)
    return [];
  let $ = new Int32Array(J - Z + 1);
  for (let X = Z;X <= J; X++)
    $[X - Z] = X;
  return $;
}
function a30(Z) {
  return Z && (Array.isArray(Z) || !!Z.buffer);
}
function Jo(Z) {
  return Z[Z.length - 1] - Z[0] + 1 === Z.length;
}
function zf(Z) {
  return Z[0];
}
function Df(Z) {
  return Z[Z.length - 1] + 1;
}
function r30(Z) {
  return Z[0];
}
function t30(Z) {
  return Z[Z.length - 1];
}
function $o(Z) {
  return Z.length;
}
function e30(Z) {
  let J = Z.length;
  if (!J)
    return 0;
  if (J > 2)
    return hK0(J, Z[0], Z[J - 1], Z[J >> 1]);
  return fK0(J, Z[0], Z[J - 1]);
}
function ZG0(Z) {
  let J = Z.length;
  if (J > 5)
    return `[${Z[0]}, ${Z[1]}, ..., ${Z[J - 1]}], length ${J}`;
  return `[${Z.join(", ")}]`;
}
function Xo(Z, J) {
  let $ = Z.length;
  return $ === 0 ? -1 : Z[0] <= J && J <= Z[$ - 1] ? QG0(Z, J, 0, $) : -1;
}
function JG0(Z, J, $) {
  return Yo(Z, J, k0.start($), k0.end($));
}
function Yo(Z, J, $, X) {
  return Z.length === 0 || X <= $ ? -1 : Z[$] <= J && J <= Z[X - 1] ? QG0(Z, J, $, X) : -1;
}
function $G0(Z, J) {
  return Xo(Z, J) >= 0;
}
function Qo(Z, J) {
  if (Z === J)
    return !0;
  let $ = Z.length;
  if ($ !== J.length || Z[0] !== J[0] || Z[$ - 1] !== J[$ - 1])
    return !1;
  if (Jo(Z))
    return !0;
  $--;
  for (let X = 1;X < $; X++)
    if (Z[X] !== J[X])
      return !1;
  return !0;
}
function qR(Z, J) {
  return WG0(Z, J, 0, Z.length);
}
function XG0(Z, J, $) {
  return WG0(Z, J, k0.start($), k0.end($));
}
function YG0(Z, J, $) {
  return k0.ofBounds(qR(Z, J), qR(Z, $ + 1));
}
function QG0(Z, J, $, X) {
  let Y = $, Q = X - 1;
  while (Y <= Q) {
    if (Y + 11 > Q) {
      for (let G = Y;G <= Q; G++)
        if (J === Z[G])
          return G;
      return -1;
    }
    let W = Y + Q >> 1, K = Z[W];
    if (J < K)
      Q = W - 1;
    else if (J > K)
      Y = W + 1;
    else
      return W;
  }
  return -1;
}
function WG0(Z, J, $, X) {
  if ($ === X)
    return $;
  if (Z[$] >= J)
    return $;
  if (Z[X - 1] < J)
    return X;
  let Y = $, Q = X;
  while (Q - Y > 4) {
    let W = Y + Q >> 1;
    if (Z[W] >= J)
      Q = W;
    else
      Y = W + 1;
  }
  for (let W = Y;W < Q; W++)
    if (Z[W] >= J)
      return W;
  return Q;
}
function KG0(Z, J) {
  if (Z === J)
    return !0;
  let { startI: $, startJ: X, endI: Y, endJ: Q } = Zz(Z, J);
  while ($ < Y && X < Q) {
    let W = Z[$], K = J[X];
    if (W < K)
      $++;
    else if (W > K)
      X++;
    else
      return !0;
  }
  return !1;
}
function GG0(Z, J) {
  if (Z === J)
    return !0;
  let $ = J.length, { startI: X, startJ: Y, endI: Q, endJ: W } = Zz(Z, J);
  if (W - Y < $ || Q - X < $)
    return !1;
  let K = 0;
  while (X < Q && Y < W) {
    let G = Z[X], H = J[Y];
    if (G < H)
      X++;
    else if (G > H)
      Y++;
    else
      X++, Y++, K++;
  }
  return K === $;
}
function Wo(Z, J) {
  if (Z === J)
    return Z;
  let $ = Z.length, X = J.length;
  if ($ === 0)
    return J;
  if (X === 0)
    return Z;
  if (Z[0] > J[0])
    return Wo(J, Z);
  let { startI: Y, startJ: Q, endI: W, endJ: K } = Zz(Z, J), G = Ko(Z, J, Y, Q, W, K);
  if (G === $ && G === X || G === X)
    return Z;
  if (G === $)
    return J;
  let H = new Int32Array($ + X - G), N = 0, q = 0, U = 0;
  for (N = 0;N < Y; N++)
    H[U++] = Z[N];
  while (q < K && Z[Y] > J[q])
    H[U++] = J[q++];
  while (N < W && q < K) {
    let F = Z[N], E = J[q];
    if (F < E)
      H[U++] = F, N++;
    else if (F > E)
      H[U++] = E, q++;
    else
      H[U++] = F, N++, q++;
  }
  for (;N < W; N++)
    H[U++] = Z[N];
  for (;q < K; q++)
    H[U++] = J[q];
  for (;N < $; N++)
    H[U++] = Z[N];
  for (;q < X; q++)
    H[U++] = J[q];
  return FR(H);
}
function HG0(Z, J) {
  if (Z === J)
    return $o(Z);
  let { startI: $, startJ: X, endI: Y, endJ: Q } = Zz(Z, J);
  return Ko(Z, J, $, X, Y, Q);
}
function Ko(Z, J, $, X, Y, Q) {
  let W = $, K = X, G = 0;
  while (W < Y && K < Q) {
    let H = Z[W], N = J[K];
    if (H < N)
      W++;
    else if (H > N)
      K++;
    else
      W++, K++, G++;
  }
  return G;
}
function NG0(Z, J) {
  if (Z === J)
    return Z;
  let { startI: $, startJ: X, endI: Y, endJ: Q } = Zz(Z, J), W = Ko(Z, J, $, X, Y, Q), K = Z.length, G = J.length;
  if (!W)
    return bM;
  if (W === K && W === G || W === G)
    return J;
  if (W === K)
    return Z;
  let H = new Int32Array(W), N = 0, q = $, U = X;
  while (q < Y && U < Q) {
    let F = Z[q], E = J[U];
    if (F < E)
      q++;
    else if (F > E)
      U++;
    else
      H[N++] = F, q++, U++;
  }
  return FR(H);
}
function qG0(Z, J) {
  if (Z === J)
    return bM;
  let $ = Z.length, { startI: X, startJ: Y, endI: Q, endJ: W } = Zz(Z, J), K = X, G = Y, H = 0;
  while (K < Q && G < W) {
    let U = Z[K], F = J[G];
    if (U < F)
      K++;
    else if (U > F)
      G++;
    else
      K++, G++, H++;
  }
  if (!H)
    return Z;
  if (H >= $)
    return bM;
  let N = new Int32Array($ - H), q = 0;
  for (let U = 0;U < X; U++)
    N[q++] = Z[U];
  K = X, G = Y;
  while (K < Q && G < W) {
    let U = Z[K], F = J[G];
    if (U < F)
      N[q++] = U, K++;
    else if (U > F)
      G++;
    else
      K++, G++;
  }
  for (;K < $; K++)
    N[q++] = Z[K];
  return FR(N);
}
function FG0(Z) {
  if (Z.length < 2)
    return Z;
  let J = 1;
  for (let Y = 0, Q = Z.length - 1;Y < Q; Y++)
    if (Z[Y] !== Z[Y + 1])
      J++;
  if (J === Z.length)
    return Z;
  let $ = new Int32Array(J), X = 0;
  for (let Y = 0, Q = Z.length - 1;Y < Q; Y++)
    if (Z[Y] !== Z[Y + 1])
      $[X++] = Z[Y];
  return $[X] = Z[Z.length - 1], $;
}
function UG0(Z, J) {
  if (Qo(Z, J))
    return FR(E_(0, Z.length - 1));
  let { startI: $, startJ: X, endI: Y, endJ: Q } = Zz(Z, J), W = $, K = X, G = 0;
  while (W < Y && K < Q) {
    let U = Z[W], F = J[K];
    if (U < F)
      W++;
    else if (U > F)
      K++;
    else
      W++, K++, G++;
  }
  let H = Z.length;
  if (!G)
    return bM;
  if (G === H)
    return FR(E_(0, Z.length - 1));
  let N = new Int32Array(G), q = 0;
  W = $, K = X;
  while (W < Y && K < Q) {
    let U = Z[W], F = J[K];
    if (U < F)
      W++;
    else if (U > F)
      K++;
    else
      N[q++] = W, W++, K++;
  }
  return FR(N);
}
var xF = { startI: 0, startJ: 0, endI: 0, endJ: 0 };
function Zz(Z, J) {
  let $ = Z.length, X = J.length, Y = $ / X;
  if ($ >= 128 || X >= 128 || Y <= 0.34 || Y >= 2.99)
    xF.startI = qR(Z, zf(J)), xF.startJ = qR(J, zf(Z)), xF.endI = qR(Z, Df(J)), xF.endJ = qR(J, Df(Z));
  else
    xF.startI = 0, xF.startJ = 0, xF.endI = $, xF.endJ = X;
  return xF;
}

// node_modules/molstar/lib/mol-data/int/sorted-array.js
var X1;
(function(Z) {
  Z.Empty = bM, Z.ofUnsortedArray = s30, Z.ofSingleton = o30, Z.ofSortedArray = FR, Z.ofRange = Zo, Z.ofBounds = (J, $) => Zo(J, $ - 1), Z.is = a30, Z.isRange = Jo, Z.has = $G0, Z.indexOf = Xo, Z.indexOfInInterval = JG0, Z.indexOfInRange = Yo, Z.start = zf, Z.end = Df, Z.min = r30, Z.max = t30, Z.size = $o, Z.hashCode = e30, Z.toString = ZG0, Z.areEqual = Qo, Z.areIntersecting = KG0, Z.isSubset = GG0, Z.union = Wo, Z.intersect = NG0, Z.subtract = qG0, Z.findPredecessorIndex = qR, Z.findPredecessorIndexInInterval = XG0, Z.findRange = YG0, Z.intersectionSize = HG0, Z.deduplicate = FG0, Z.indicesOf = UG0;
})(X1 || (X1 = {}));

// node_modules/molstar/lib/mol-data/int/impl/ordered-set.js
var YH = k0.Empty, DG0 = k0.ofSingleton, MG0 = k0.ofRange, AG0 = k0.ofBounds;
function O3(Z) {
  if (!Z.length)
    return YH;
  if (X1.isRange(Z))
    return k0.ofRange(Z[0], Z[Z.length - 1]);
  return Z;
}
function yF(Z) {
  return k0.is(Z) ? k0.size(Z) : X1.size(Z);
}
function BG0(Z, J) {
  return k0.is(Z) ? k0.has(Z, J) : X1.has(Z, J);
}
function wG0(Z, J) {
  return k0.is(Z) ? k0.indexOf(Z, J) : X1.indexOf(Z, J);
}
function Mf(Z, J) {
  return k0.is(Z) ? k0.getAt(Z, J) : Z[J];
}
function Jz(Z) {
  return k0.is(Z) ? k0.min(Z) : X1.min(Z);
}
function $z(Z) {
  return k0.is(Z) ? k0.max(Z) : X1.max(Z);
}
function jG0(Z) {
  return k0.is(Z) ? k0.start(Z) : X1.start(Z);
}
function TG0(Z) {
  return k0.is(Z) ? k0.end(Z) : X1.end(Z);
}
function _G0(Z) {
  return yF(Z) === 0;
}
function VG0(Z) {
  return k0.is(Z) ? k0.hashCode(Z) : X1.hashCode(Z);
}
function IG0(Z) {
  return k0.is(Z) ? k0.toString(Z) : X1.toString(Z);
}
function PG0(Z, J) {
  if (k0.is(Z)) {
    if (k0.is(J))
      return k0.areEqual(Z, J);
    return LG0(Z, J);
  } else if (k0.is(J))
    return LG0(J, Z);
  return X1.areEqual(Z, J);
}
function CG0(Z, J) {
  if (k0.is(Z)) {
    if (k0.is(J))
      return k0.areIntersecting(Z, J);
    return RG0(J, Z);
  } else if (k0.is(J))
    return RG0(Z, J);
  return X1.areIntersecting(Z, J);
}
function kG0(Z, J) {
  if (k0.is(Z)) {
    if (k0.is(J))
      return k0.isSubInterval(Z, J);
    return Ut0(Z, J);
  } else if (k0.is(J))
    return Ft0(Z, J);
  return X1.isSubset(Z, J);
}
function vG0(Z, J) {
  return k0.is(Z) ? k0.findPredecessorIndex(Z, J) : X1.findPredecessorIndex(Z, J);
}
function SG0(Z, J, $) {
  return k0.is(Z) ? k0.findPredecessorIndexInInterval(Z, J, $) : X1.findPredecessorIndexInInterval(Z, J, $);
}
function fG0(Z, J, $) {
  return k0.is(Z) ? k0.findRange(Z, J, $) : X1.findRange(Z, J, $);
}
function hG0(Z, J) {
  if (k0.is(Z)) {
    if (k0.is(J))
      return k0.intersectionSize(Z, J);
    return OG0(J, Z);
  } else if (k0.is(J))
    return OG0(Z, J);
  return X1.intersectionSize(Z, J);
}
function bG0(Z, J) {
  if (k0.is(Z)) {
    if (k0.is(J))
      return Et0(Z, J);
    return EG0(J, Z);
  } else if (k0.is(J))
    return EG0(Z, J);
  return O3(X1.union(Z, J));
}
function xG0(Z, J) {
  if (k0.is(Z)) {
    if (k0.is(J))
      return k0.intersect(Z, J);
    return zG0(J, Z);
  } else if (k0.is(J))
    return zG0(Z, J);
  return O3(X1.intersect(Z, J));
}
function yG0(Z, J) {
  if (k0.is(Z)) {
    if (k0.is(J))
      return Ot0(Z, J);
    return Dt0(Z, J);
  } else if (k0.is(J))
    return zt0(Z, J);
  return O3(X1.subtract(Z, J));
}
function LG0(Z, J) {
  return k0.size(Z) === X1.size(J) && k0.start(Z) === X1.start(J) && k0.end(Z) === X1.end(J);
}
function RG0(Z, J) {
  return Z.length !== 0 && k0.size(X1.findRange(Z, k0.min(J), k0.max(J))) !== 0;
}
function Ft0(Z, J) {
  let $ = k0.min(J), X = k0.max(J);
  if (X - $ + 1 === 0)
    return !0;
  let Y = X1.min(Z), Q = X1.max(Z);
  if ($ < Y || X > Q)
    return !1;
  let W = X1.findRange(Z, $, X);
  return k0.size(W) === k0.size(J);
}
function Ut0(Z, J) {
  let $ = k0.min(Z), X = k0.max(Z);
  if (X - $ + 1 === 0)
    return !1;
  let Y = X1.min(J), Q = X1.max(J);
  return Y >= $ && Q <= X;
}
function Lt0(Z, J) {
  let $ = yF(Z), X = yF(J);
  if ($ === 0 && X === 0)
    return !0;
  return $ > 0 && X > 0 && $z(Z) >= Jz(J) && Jz(Z) <= $z(J);
}
function Rt0(Z, J) {
  if (!yF(Z))
    return yF(J) === 0;
  if (!yF(J))
    return !0;
  return Jz(Z) <= Jz(J) && $z(Z) >= $z(J);
}
function Et0(Z, J) {
  if (k0.areEqual(Z, J))
    return Z;
  let $ = k0.size(Z), X = k0.size(J);
  if (!X)
    return Z;
  if (!$)
    return J;
  let Y = k0.min(Z), Q = k0.min(J);
  if (Lt0(Z, J))
    return k0.ofRange(Math.min(Y, Q), Math.max(k0.max(Z), k0.max(J)));
  let W, K, G, H;
  if (Y < Q)
    W = $, K = Y, G = X, H = Q;
  else
    W = X, K = Q, G = $, H = Y;
  let N = new Int32Array($ + X);
  for (let q = 0;q < W; q++)
    N[q] = q + K;
  for (let q = 0;q < G; q++)
    N[q + W] = q + H;
  return O3(N);
}
function EG0(Z, J) {
  let $ = k0.size(J);
  if (!$)
    return Z;
  if (Rt0(J, Z))
    return J;
  let X = k0.min(J), Y = k0.max(J), Q = X1.findRange(Z, X, Y), W = k0.start(Q), K = k0.end(Q), G = new Int32Array(W + (Z.length - K) + $), H = 0;
  for (let N = 0;N < W; N++)
    G[H++] = Z[N];
  for (let N = X;N <= Y; N++)
    G[H++] = N;
  for (let N = K, q = Z.length;N < q; N++)
    G[H++] = Z[N];
  return O3(G);
}
function OG0(Z, J) {
  if (!k0.size(J))
    return 0;
  let $ = X1.findRange(Z, k0.min(J), k0.max(J));
  return k0.end($) - k0.start($);
}
function zG0(Z, J) {
  if (!k0.size(J))
    return YH;
  let $ = X1.findRange(Z, k0.min(J), k0.max(J)), X = k0.start($), Y = k0.end($), Q = Y - X;
  if (!Q)
    return YH;
  if (Q === Z.length)
    return Z;
  let W = new Int32Array(Q), K = 0;
  for (let G = X;G < Y; G++)
    W[K++] = Z[G];
  return O3(W);
}
function Ot0(Z, J) {
  if (k0.areEqual(Z, J))
    return YH;
  if (!k0.areIntersecting(Z, J))
    return Z;
  let $ = k0.min(Z), X = k0.max(Z), Y = k0.min(J), Q = k0.max(J);
  if (X < $ || Q < Y)
    return Z;
  if (k0.isSubInterval(J, Z))
    return YH;
  if (k0.isSubInterval(Z, J)) {
    let W = Y - $, K = X - Q;
    if (W <= 0)
      return k0.ofRange(Q + 1, Q + K);
    if (K <= 0)
      return k0.ofRange($, $ + W - 1);
    let G = new Int32Array(W + K), H = 0;
    for (let N = 0;N < W; N++)
      G[H++] = $ + N;
    for (let N = 1;N <= K; N++)
      G[H++] = Q + N;
    return O3(G);
  }
  if ($ < Y)
    return k0.ofRange($, Y - 1);
  return k0.ofRange(Q + 1, X);
}
function zt0(Z, J) {
  let $ = k0.min(J), X = k0.max(J);
  if (X < $)
    return Z;
  let Y = X1.findRange(Z, $, X), Q = k0.start(Y), W = k0.end(Y), K = Z.length - (W - Q);
  if (K <= 0)
    return YH;
  if (K === Z.length)
    return Z;
  let G = new Int32Array(K), H = 0;
  for (let N = 0;N < Q; N++)
    G[H++] = Z[N];
  for (let N = W, q = Z.length;N < q; N++)
    G[H++] = Z[N];
  return O3(G);
}
function Dt0(Z, J) {
  let $ = k0.min(Z), X = k0.max(Z);
  if (X < $)
    return Z;
  let Y = X - $ + 1, Q = X1.findRange(J, $, X), W = k0.start(Q), K = k0.end(Q), G = K - W;
  if (G === 0)
    return Z;
  let H = Y - G;
  if (H <= 0)
    return YH;
  let N = new Int32Array(H), q = J.length - 1, U = J[Math.min(W, q)], F = J[Math.min(K, q)], E = 0;
  for (let R = $;R < U; R++)
    N[E++] = R;
  for (let R = U;R <= F; R++)
    if (X1.indexOfInInterval(J, R, Q) < 0)
      N[E++] = R;
  for (let R = F + 1;R <= X; R++)
    N[E++] = R;
  return O3(N);
}
function gG0(Z, J, $) {
  if (k0.is(Z)) {
    let X = k0.min(Z);
    for (let Y = X, Q = k0.max(Z);Y <= Q; Y++)
      J(Y, Y - X, $);
  } else
    for (let X = 0, Y = Z.length;X < Y; X++)
      J(Z[X], X, $);
  return $;
}
function mG0(Z, J, $, X) {
  if (k0.is(Z)) {
    let Y = 0;
    for (let Q = k0.min(Z), W = k0.max(Z);Q <= W; Q++) {
      let K = J(Q), G = Q + 1;
      while (G < W && J(G) === K)
        G++;
      Q = G - 1, $(K, Y, X), Y++;
    }
  } else {
    let Y = 0;
    for (let Q = 0, W = Z.length;Q < W; Q++) {
      let K = J(Z[Q]), G = Q + 1;
      while (G < W && J(Z[G]) === K)
        G++;
      Q = G - 1, $(K, Y, X), Y++;
    }
  }
  return X;
}
function dG0(Z, J, $) {
  if (J === $)
    return Z;
  let X = yF(Z), Y = J.length, Q = $.length;
  if (X === 0 || Y === 0 || Q === 0)
    return YH;
  let W = X1.findPredecessorIndex($, J[Jz(Z)]), K = X1.findPredecessorIndex($, J[$z(Z)] + 1), G = 0, H = 0, N = 0, q = W;
  while (N < X && q < K) {
    let F = J[Mf(Z, N)], E = $[q];
    if (F < E)
      N++;
    else if (F > E)
      q++;
    else
      G++, N++, q++;
  }
  if (G === 0)
    return YH;
  if (G === Y && G === Q)
    return Z;
  let U = new Int32Array(G);
  H = 0, N = 0, q = W;
  while (N < X && q < K) {
    let F = J[Mf(Z, N)], E = $[q];
    if (F < E)
      N++;
    else if (F > E)
      q++;
    else
      U[H++] = q, N++, q++;
  }
  return O3(U);
}

// node_modules/molstar/lib/mol-data/int/ordered-set.js
var f0;
(function(Z) {
  Z.Empty = YH, Z.ofSingleton = DG0, Z.ofRange = MG0, Z.ofBounds = AG0, Z.ofSortedArray = O3, Z.has = BG0, Z.indexOf = wG0, Z.getAt = Mf, Z.isEmpty = _G0, Z.min = Jz, Z.max = $z, Z.start = jG0, Z.end = TG0, Z.size = yF, Z.hashCode = VG0, Z.areEqual = PG0, Z.areIntersecting = CG0, Z.isSubset = kG0, Z.union = bG0, Z.intersect = xG0, Z.indexedIntersect = dG0, Z.subtract = yG0, Z.findPredecessorIndex = vG0, Z.findPredecessorIndexInInterval = SG0, Z.findRange = fG0, Z.intersectionSize = hG0;
  function J(K, G, H) {
    return gG0(K, G, H);
  }
  Z.forEach = J;
  function $(K, G, H, N) {
    return mG0(K, G, H, N);
  }
  Z.forEachSegment = $;
  function X(K) {
    return k0.is(K);
  }
  Z.isInterval = X;
  function Y(K) {
    return !k0.is(K);
  }
  Z.isSortedArray = Y;
  function Q(K) {
    let G = [];
    return Z.forEach(K, (H) => G.push(H)), G;
  }
  Z.toArray = Q;
  function W(K) {
    return IG0(K);
  }
  Z.toString = W;
})(f0 || (f0 = {}));

// node_modules/molstar/lib/mol-math/linear-algebra/3d/vec4.js
function E2() {
  return E2.zero();
}
(function(Z) {
  function J() {
    let h = [0.1, 0, 0, 0];
    return h[0] = 0, h;
  }
  Z.zero = J;
  function $(h) {
    let x = J();
    return x[0] = h[0], x[1] = h[1], x[2] = h[2], x[3] = h[3], x;
  }
  Z.clone = $;
  function X(h, x, b, g) {
    let m = J();
    return m[0] = h, m[1] = x, m[2] = b, m[3] = g, m;
  }
  Z.create = X;
  function Y(h, x) {
    return h[0] = x.center[0], h[1] = x.center[1], h[2] = x.center[2], h[3] = x.radius, h;
  }
  Z.fromSphere = Y;
  function Q(h) {
    return Y(J(), h);
  }
  Z.ofSphere = Q;
  function W(h) {
    return Number.isNaN(h[0]) || Number.isNaN(h[1]) || Number.isNaN(h[2]) || Number.isNaN(h[3]);
  }
  Z.hasNaN = W;
  function K(h, x, b) {
    return x[b + 0] = h[0], x[b + 1] = h[1], x[b + 2] = h[2], x[b + 3] = h[3], x;
  }
  Z.toArray = K;
  function G(h, x, b) {
    return h[0] = x[b + 0], h[1] = x[b + 1], h[2] = x[b + 2], h[3] = x[b + 3], h;
  }
  Z.fromArray = G;
  function H(h, x, b) {
    x[b + 0] = h[0], x[b + 1] = h[1], x[b + 2] = h[2];
  }
  Z.toVec3Array = H;
  function N(h, x, b) {
    return h[0] = x[b + 0], h[1] = x[b + 1], h[2] = x[b + 2], h[3] = 0, h;
  }
  Z.fromVec3Array = N;
  function q(h, x) {
    return h[0] = x[0], h[1] = x[1], h[2] = x[2], h[3] = x[3], h;
  }
  Z.copy = q;
  function U(h, x, b, g, m) {
    return h[0] = x, h[1] = b, h[2] = g, h[3] = m, h;
  }
  Z.set = U;
  function F(h, x, b) {
    return h[0] = x[0] + b[0], h[1] = x[1] + b[1], h[2] = x[2] + b[2], h[3] = x[3] + b[3], h;
  }
  Z.add = F;
  function E(h, x) {
    let b = x[0] - h[0], g = x[1] - h[1], m = x[2] - h[2], i = x[3] - h[3];
    return Math.sqrt(b * b + g * g + m * m + i * i);
  }
  Z.distance = E;
  function R(h, x, b) {
    return h[0] = x[0] * b, h[1] = x[1] * b, h[2] = x[2] * b, h[4] = x[4] * b, h;
  }
  Z.scale = R;
  function z(h, x) {
    return h[0] = Math.round(x[0]), h[1] = Math.round(x[1]), h[2] = Math.round(x[2]), h[3] = Math.round(x[3]), h;
  }
  Z.round = z;
  function D(h, x) {
    return h[0] = Math.ceil(x[0]), h[1] = Math.ceil(x[1]), h[2] = Math.ceil(x[2]), h[3] = Math.ceil(x[3]), h;
  }
  Z.ceil = D;
  function A(h, x) {
    return h[0] = Math.floor(x[0]), h[1] = Math.floor(x[1]), h[2] = Math.floor(x[2]), h[3] = Math.floor(x[3]), h;
  }
  Z.floor = A;
  function B(h, x) {
    let b = x[0] - h[0], g = x[1] - h[1], m = x[2] - h[2], i = x[3] - h[3];
    return b * b + g * g + m * m + i * i;
  }
  Z.squaredDistance = B;
  function T(h) {
    let x = h[0], b = h[1], g = h[2], m = h[3];
    return Math.sqrt(x * x + b * b + g * g + m * m);
  }
  Z.norm = T;
  function w(h) {
    let x = h[0], b = h[1], g = h[2], m = h[3];
    return x * x + b * b + g * g + m * m;
  }
  Z.squaredNorm = w;
  function V(h, x, b) {
    let g = x[0], m = x[1], i = x[2], r = x[3];
    return h[0] = b[0] * g + b[4] * m + b[8] * i + b[12] * r, h[1] = b[1] * g + b[5] * m + b[9] * i + b[13] * r, h[2] = b[2] * g + b[6] * m + b[10] * i + b[14] * r, h[3] = b[3] * g + b[7] * m + b[11] * i + b[15] * r, h;
  }
  Z.transformMat4 = V;
  function P(h, x) {
    return h[0] * x[0] + h[1] * x[1] + h[2] * x[2] + h[3] * x[3];
  }
  Z.dot = P;
  function I(h, x) {
    return h[0] = 1 / x[0], h[1] = 1 / x[1], h[2] = 1 / x[2], h[3] = 1 / x[3], h;
  }
  Z.inverse = I;
  function S(h, x) {
    return h[0] === x[0] && h[1] === x[1] && h[2] === x[2] && h[3] === x[3];
  }
  Z.exactEquals = S;
  function f(h, x) {
    let b = h[0], g = h[1], m = h[2], i = h[3], r = x[0], Y0 = x[1], c = x[2], n = x[3];
    return Math.abs(b - r) <= u8 * Math.max(1, Math.abs(b), Math.abs(r)) && Math.abs(g - Y0) <= u8 * Math.max(1, Math.abs(g), Math.abs(Y0)) && Math.abs(m - c) <= u8 * Math.max(1, Math.abs(m), Math.abs(c)) && Math.abs(i - n) <= u8 * Math.max(1, Math.abs(i), Math.abs(n));
  }
  Z.equals = f;
  function v(h, x) {
    return `[${h[0].toPrecision(x)} ${h[1].toPrecision(x)} ${h[2].toPrecision(x)}  ${h[3].toPrecision(x)}]`;
  }
  Z.toString = v;
})(E2 || (E2 = {}));
// node_modules/molstar/lib/mol-math/linear-algebra/tensor.js
var M8;
(function(Z) {
  function J(w, V, P) {
    let I = [];
    for (let f = 0;f < V.length; f++)
      I[f] = V[V.length - f - 1];
    let S = [1];
    for (let f = 1;f < w.length; f++)
      S[f] = w[I[f - 1]];
    return { dimensions: w, axisOrderFastToSlow: I, axisOrderSlowToFast: V, accessDimensions: S, defaultCtor: P || Float64Array };
  }
  function $(w, V) {
    return { space: w, data: V };
  }
  Z.create = $;
  function X(w, V, P) {
    let I = J(w, V, P), { get: S, set: f, add: v, dataOffset: h, getCoords: x } = F(I);
    return { rank: w.length, dimensions: w, axisOrderSlowToFast: V, create: E(I), get: S, set: f, add: v, dataOffset: h, getCoords: x };
  }
  Z.Space = X;
  function Y(w) {
    return w;
  }
  Z.Data1 = Y;
  function Q(w, V) {
    return X([w], [0], V);
  }
  Z.Vector = Q;
  function W(w, V, P) {
    return X([w, V], [1, 0], P);
  }
  Z.ColumnMajorMatrix = W;
  function K(w, V, P) {
    return X([w, V], [0, 1], P);
  }
  Z.RowMajorMatrix = K;
  function G(w, V, P) {
    if (V.rank !== 2)
      throw new Error("Invalid tensor rank");
    let I = Math.min(4, V.dimensions[0]), S = Math.min(4, V.dimensions[1]);
    for (let f = 0;f < I; f++)
      for (let v = 0;v < S; v++)
        e.setValue(w, f, v, V.get(P, f, v));
    return w;
  }
  Z.toMat4 = G;
  function H(w, V, P) {
    if (V.rank !== 2)
      throw new Error("Invalid tensor rank");
    let I = Math.min(3, V.dimensions[0]), S = Math.min(3, V.dimensions[1]);
    for (let f = 0;f < I; f++)
      for (let v = 0;v < S; v++)
        h2.setValue(w, f, v, V.get(P, f, v));
    return w;
  }
  Z.toMat3 = H;
  function N(w, V, P) {
    if (V.rank !== 1)
      throw new Error("Invalid tensor rank");
    let I = Math.min(3, V.dimensions[0]);
    for (let S = 0;S < I; S++)
      w[S] = P[S];
    return w;
  }
  Z.toVec3 = N;
  function q(w, V, P) {
    if (V.rank !== 1)
      throw new Error("Invalid tensor rank");
    let I = Math.min(4, V.dimensions[0]);
    for (let S = 0;S < I; S++)
      w[S] = P[S];
    return w;
  }
  Z.toVec4 = q;
  function U(w, V) {
    let P = w.length;
    if (P !== V.length)
      return !1;
    for (let I = 0;I < P; I++)
      if (w[I] !== V[I])
        return !1;
    return !0;
  }
  Z.areEqualExact = U;
  function F(w) {
    let { dimensions: V, axisOrderFastToSlow: P } = w;
    switch (V.length) {
      case 1:
        return {
          get: (I, S) => I[S],
          set: (I, S, f) => I[S] = f,
          add: (I, S, f) => I[S] += f,
          dataOffset: (I) => I,
          getCoords: (I, S) => {
            return S[0] = I, S;
          }
        };
      case 2: {
        if (P[0] === 0 && P[1] === 1) {
          let I = V[0];
          return {
            get: (S, f, v) => S[v * I + f],
            set: (S, f, v, h) => S[v * I + f] = h,
            add: (S, f, v, h) => S[v * I + f] += h,
            dataOffset: (S, f) => f * I + S,
            getCoords: (S, f) => {
              return f[0] = S % I, f[1] = Math.floor(S / I), f;
            }
          };
        }
        if (P[0] === 1 && P[1] === 0) {
          let I = V[1];
          return {
            get: (S, f, v) => S[f * I + v],
            set: (S, f, v, h) => S[f * I + v] = h,
            add: (S, f, v, h) => S[f * I + v] += h,
            dataOffset: (S, f) => S * I + f,
            getCoords: (S, f) => {
              return f[0] = Math.floor(S / I), f[1] = S % I, f;
            }
          };
        }
        throw new Error("bad axis order");
      }
      case 3: {
        if (P[0] === 0 && P[1] === 1 && P[2] === 2) {
          let I = V[0], S = V[1], f = I * S;
          return {
            get: (v, h, x, b) => v[h + x * I + b * f],
            set: (v, h, x, b, g) => v[h + x * I + b * f] = g,
            add: (v, h, x, b, g) => v[h + x * I + b * f] += g,
            dataOffset: (v, h, x) => v + h * I + x * f,
            getCoords: (v, h) => {
              let x = Math.floor(v / I);
              return h[0] = v % I, h[1] = x % S, h[2] = Math.floor(x / S), h;
            }
          };
        }
        if (P[0] === 0 && P[1] === 2 && P[2] === 1) {
          let I = V[0], S = V[2], f = I * S;
          return {
            get: (v, h, x, b) => v[h + b * I + x * f],
            set: (v, h, x, b, g) => v[h + b * I + x * f] = g,
            add: (v, h, x, b, g) => v[h + b * I + x * f] += g,
            dataOffset: (v, h, x) => v + x * I + h * f,
            getCoords: (v, h) => {
              let x = Math.floor(v / I);
              return h[0] = v % I, h[1] = Math.floor(x / S), h[2] = x % S, h;
            }
          };
        }
        if (P[0] === 1 && P[1] === 0 && P[2] === 2) {
          let I = V[1], S = V[0], f = I * S;
          return {
            get: (v, h, x, b) => v[x + h * I + b * f],
            set: (v, h, x, b, g) => v[x + h * I + b * f] = g,
            add: (v, h, x, b, g) => v[x + h * I + b * f] += g,
            dataOffset: (v, h, x) => h + v * I + x * f,
            getCoords: (v, h) => {
              let x = Math.floor(v / I);
              return h[0] = x % S, h[1] = v % I, h[2] = Math.floor(x / S), h;
            }
          };
        }
        if (P[0] === 1 && P[1] === 2 && P[2] === 0) {
          let I = V[1], S = V[2], f = I * S;
          return {
            get: (v, h, x, b) => v[x + b * I + h * f],
            set: (v, h, x, b, g) => v[x + b * I + h * f] = g,
            add: (v, h, x, b, g) => v[x + b * I + h * f] += g,
            dataOffset: (v, h, x) => h + x * I + v * f,
            getCoords: (v, h) => {
              let x = Math.floor(v / I);
              return h[0] = Math.floor(x / S), h[1] = v % I, h[2] = x % S, h;
            }
          };
        }
        if (P[0] === 2 && P[1] === 0 && P[2] === 1) {
          let I = V[2], S = V[0], f = I * S;
          return {
            get: (v, h, x, b) => v[b + h * I + x * f],
            set: (v, h, x, b, g) => v[b + h * I + x * f] = g,
            add: (v, h, x, b, g) => v[b + h * I + x * f] += g,
            dataOffset: (v, h, x) => x + v * I + h * f,
            getCoords: (v, h) => {
              let x = Math.floor(v / I);
              return h[0] = x % S, h[1] = Math.floor(x / S), h[2] = v % I, h;
            }
          };
        }
        if (P[0] === 2 && P[1] === 1 && P[2] === 0) {
          let I = V[2], S = V[1], f = I * S;
          return {
            get: (v, h, x, b) => v[b + x * I + h * f],
            set: (v, h, x, b, g) => v[b + x * I + h * f] = g,
            add: (v, h, x, b, g) => v[b + x * I + h * f] += g,
            dataOffset: (v, h, x) => x + h * I + v * f,
            getCoords: (v, h) => {
              let x = Math.floor(v / I);
              return h[0] = Math.floor(x / S), h[1] = x % S, h[2] = v % I, h;
            }
          };
        }
        throw new Error("bad axis order");
      }
      default:
        return {
          get: (I, ...S) => I[R(w, S)],
          set: (I, ...S) => I[R(w, S)] = S[S.length - 1],
          add: (I, ...S) => I[R(w, S)] += S[S.length - 1],
          dataOffset: (...I) => R(w, I),
          getCoords: (I, S) => z(w, I, S)
        };
    }
  }
  function E(w) {
    let { dimensions: V } = w, P = 1;
    for (let I = 0, S = V.length;I < S; I++)
      P *= V[I];
    return (I) => new (I || w.defaultCtor)(P);
  }
  function R(w, V) {
    let { accessDimensions: P, axisOrderFastToSlow: I } = w, S = P.length - 1, f = P[S] * V[I[S]];
    for (let v = S - 1;v >= 0; v--)
      f = (f + V[I[v]]) * P[v];
    return f;
  }
  function z(w, V, P) {
    let { dimensions: I, axisOrderFastToSlow: S } = w, f = I.length, v = V;
    for (let h = 0;h < f; h++) {
      let x = I[S[h]];
      P[S[h]] = v % x, v = Math.floor(v / x);
    }
    return P[S[f + 1]] = v, P;
  }
  function D(w) {
    let V = [];
    for (let P = 0;P < w.length; P++)
      V[P] = w[w.length - P - 1];
    return V;
  }
  Z.invertAxisOrder = D;
  function A(w, V) {
    let P = [];
    for (let I = 0;I < w.length; I++)
      P[I] = w[V[I]];
    return P;
  }
  function B(w) {
    let V = new Int32Array(w.length);
    for (let P = 0;P < w.length; P++)
      V[w[P]] = P;
    return (P) => A(P, V);
  }
  Z.convertToCanonicalAxisIndicesFastToSlow = B;
  function T(w) {
    let V = new Int32Array(w.length);
    for (let P = 0;P < w.length; P++)
      V[w[w.length - P - 1]] = P;
    return (P) => A(P, V);
  }
  Z.convertToCanonicalAxisIndicesSlowToFast = T;
})(M8 || (M8 = {}));
// node_modules/molstar/lib/mol-math/geometry/primitives/axes3d.js
function m7() {
  return m7.empty();
}
(function(Z) {
  function J(U, F, E, R) {
    return { origin: U, dirA: F, dirB: E, dirC: R };
  }
  Z.create = J;
  function $() {
    return { origin: M(), dirA: M(), dirB: M(), dirC: M() };
  }
  Z.empty = $;
  function X(U, F) {
    return M.copy(U.origin, F.origin), M.copy(U.dirA, F.dirA), M.copy(U.dirB, F.dirB), M.copy(U.dirC, F.dirC), U;
  }
  Z.copy = X;
  function Y(U) {
    return X($(), U);
  }
  Z.clone = Y;
  function Q(U, F) {
    return M.set(U, M.magnitude(F.dirA) * 2, M.magnitude(F.dirB) * 2, M.magnitude(F.dirC) * 2);
  }
  Z.size = Q;
  let W = M();
  function K(U) {
    return Q(W, U), W[0] * W[1] * W[2];
  }
  Z.volume = K;
  function G(U, F) {
    return M.copy(U.origin, F.origin), M.normalize(U.dirA, F.dirA), M.normalize(U.dirB, F.dirB), M.normalize(U.dirC, F.dirC), U;
  }
  Z.normalize = G;
  let H = h2();
  function N(U, F, E) {
    M.transformMat4(U.origin, F.origin, E);
    let R = h2.directionTransform(H, E);
    return M.transformMat3(U.dirA, F.dirA, R), M.transformMat3(U.dirB, F.dirB, R), M.transformMat3(U.dirC, F.dirC, R), U;
  }
  Z.transform = N;
  function q(U, F, E) {
    return M.scale(U.dirA, F.dirA, E), M.scale(U.dirB, F.dirB, E), M.scale(U.dirC, F.dirC, E), U;
  }
  Z.scale = q;
})(m7 || (m7 = {}));

// node_modules/molstar/lib/mol-math/linear-algebra/matrix/matrix.js
var ZZ;
(function(Z) {
  function J(U, F, E = Float32Array) {
    let R = U * F;
    return { data: new E(R), size: R, cols: U, rows: F };
  }
  Z.create = J;
  function $(U, F, E) {
    return U.data[U.rows * E + F];
  }
  Z.get = $;
  function X(U, F, E, R) {
    return U.data[U.rows * E + F] = R, U;
  }
  Z.set = X;
  function Y(U, F, E, R) {
    return U.data[U.rows * E + F] += R, U;
  }
  Z.add = Y;
  function Q(U) {
    return U.data.fill(0), U;
  }
  Z.makeZero = Q;
  function W(U) {
    return { data: U.data.slice(), size: U.size, cols: U.cols, rows: U.rows };
  }
  Z.clone = W;
  function K(U, F, E) {
    return { data: U, size: F * E, cols: F, rows: E };
  }
  Z.fromArray = K;
  function G(U, F) {
    if (U.cols !== F.rows || U.rows !== F.cols)
      throw new Error("transpose: matrix dimensions incompatible");
    if (U.data === F.data)
      throw new Error("transpose: matrices share memory");
    let { rows: E, cols: R, data: z } = F, D = U.data;
    for (let A = 0, B = 0, T = 0;A < E; T += 1, B += R, ++A) {
      let w = T;
      for (let V = 0;V < R; w += E, V++)
        D[w] = z[B + V];
    }
    return U;
  }
  Z.transpose = G;
  function H(U, F, E) {
    let { cols: R, rows: z } = F, D = E.rows, A = F.data, B = E.data, T = U.data;
    for (let w = 0, V = 0, P = 0;w < z; V += R, w++)
      for (let I = 0, S = 0;S < D; P++, S++) {
        let f = 0, v = V;
        for (let h = 0;h < R; v++, I++, h++)
          f += A[v] * B[I];
        T[P] = f;
      }
    return U;
  }
  Z.multiplyABt = H;
  function N(U) {
    let { rows: F, cols: E, data: R } = U, z = new Array(E);
    for (let D = 0;D < E; ++D)
      z[D] = 0;
    for (let D = 0, A = 0;D < F; ++D)
      for (let B = 0;B < E; ++B, ++A)
        z[B] += R[A];
    for (let D = 0;D < E; ++D)
      z[D] /= F;
    return z;
  }
  Z.meanRows = N;
  function q(U, F) {
    let { rows: E, cols: R, data: z } = U;
    for (let D = 0, A = 0;D < E; ++D)
      for (let B = 0;B < R; ++B, ++A)
        z[A] -= F[B];
    return U;
  }
  Z.subRows = q;
})(ZZ || (ZZ = {}));

// node_modules/molstar/lib/mol-math/linear-algebra/matrix/svd.js
function Go(Z, J, $, X) {
  X = Z[J], Z[J] = Z[$], Z[$] = X;
}
function At0(Z, J) {
  if (Z = Math.abs(Z), J = Math.abs(J), Z > J)
    return J /= Z, Z * Math.sqrt(1 + J * J);
  if (J > 0)
    return Z /= J, J * Math.sqrt(1 + Z * Z);
  return 0;
}
var Bt0 = 0.0000001192092896, wt0 = 0.0000000000000000000000000000000000001;
function jt0(Z, J, $, X, Y, Q, W, K) {
  let G = Bt0 * 2, H = wt0, N = 0, q = 0, U = 0, F = 0, E = Math.max(Q, 30), R = 0, z = 0, D = 0, A = 0, B = 0, T = 0, w = 0, V = 0, P = 0, I = 0, S = 0, f = 0, v = 0, h = 0, x = 0, b = 0, g = 0, m = 4660, i = 0, r = 0, Y0 = 0, c = new Float64Array(W << 3);
  for (;N < W; N++) {
    for (U = 0, S = 0;U < Q; U++)
      V = Z[N * J + U], S += V * V;
    if (c[N] = S, X) {
      for (U = 0;U < W; U++)
        X[N * Y + U] = 0;
      X[N * Y + N] = 1;
    }
  }
  for (;F < E; F++) {
    B = 0;
    for (N = 0;N < W - 1; N++)
      for (q = N + 1;q < W; q++) {
        R = N * J | 0, z = q * J | 0, x = c[N], b = 0, g = c[q], U = 2, b += Z[R] * Z[z], b += Z[R + 1] * Z[z + 1];
        for (;U < Q; U++)
          b += Z[R + U] * Z[z + U];
        if (Math.abs(b) <= G * Math.sqrt(x * g))
          continue;
        if (b *= 2, f = x - g, v = At0(b, f), f < 0)
          h = (v - f) * 0.5, w = Math.sqrt(h / v), T = b / (v * w * 2);
        else
          T = Math.sqrt((v + f) / (v * 2)), w = b / (v * T * 2);
        x = 0, g = 0, U = 2, P = T * Z[R] + w * Z[z], I = -w * Z[R] + T * Z[z], Z[R] = P, Z[z] = I, x += P * P, g += I * I, P = T * Z[R + 1] + w * Z[z + 1], I = -w * Z[R + 1] + T * Z[z + 1], Z[R + 1] = P, Z[z + 1] = I, x += P * P, g += I * I;
        for (;U < Q; U++)
          P = T * Z[R + U] + w * Z[z + U], I = -w * Z[R + U] + T * Z[z + U], Z[R + U] = P, Z[z + U] = I, x += P * P, g += I * I;
        if (c[N] = x, c[q] = g, B = 1, X) {
          D = N * Y | 0, A = q * Y | 0, U = 2, P = T * X[D] + w * X[A], I = -w * X[D] + T * X[A], X[D] = P, X[A] = I, P = T * X[D + 1] + w * X[A + 1], I = -w * X[D + 1] + T * X[A + 1], X[D + 1] = P, X[A + 1] = I;
          for (;U < W; U++)
            P = T * X[D + U] + w * X[A + U], I = -w * X[D + U] + T * X[A + U], X[D + U] = P, X[A + U] = I;
        }
      }
    if (B === 0)
      break;
  }
  for (N = 0;N < W; N++) {
    for (U = 0, S = 0;U < Q; U++)
      V = Z[N * J + U], S += V * V;
    c[N] = Math.sqrt(S);
  }
  for (N = 0;N < W - 1; N++) {
    q = N;
    for (U = N + 1;U < W; U++)
      if (c[q] < c[U])
        q = U;
    if (N !== q) {
      if (Go(c, N, q, S), X) {
        for (U = 0;U < Q; U++)
          Go(Z, N * J + U, q * J + U, V);
        for (U = 0;U < W; U++)
          Go(X, N * Y + U, q * Y + U, V);
      }
    }
  }
  for (N = 0;N < W; N++)
    $[N] = c[N];
  if (!X)
    return;
  for (N = 0;N < K; N++) {
    S = N < W ? c[N] : 0;
    while (S <= H) {
      r = 1 / Q;
      for (U = 0;U < Q; U++)
        m = m * 214013 + 2531011, i = (m >> 16 & 32767 & 256) !== 0 ? r : -r, Z[N * J + U] = i;
      for (F = 0;F < 2; F++)
        for (q = 0;q < N; q++) {
          S = 0;
          for (U = 0;U < Q; U++)
            S += Z[N * J + U] * Z[q * J + U];
          Y0 = 0;
          for (U = 0;U < Q; U++)
            V = Z[N * J + U] - S * Z[q * J + U], Z[N * J + U] = V, Y0 += Math.abs(V);
          Y0 = Y0 ? 1 / Y0 : 0;
          for (U = 0;U < Q; U++)
            Z[N * J + U] *= Y0;
        }
      S = 0;
      for (U = 0;U < Q; U++)
        V = Z[N * J + U], S += V * V;
      S = Math.sqrt(S);
    }
    w = 1 / S;
    for (U = 0;U < Q; U++)
      Z[N * J + U] *= w;
  }
}
function pG0(Z, J, $, X) {
  let Y = 0, Q = 0, W = Z.rows, K = Z.cols, G = W, H = K;
  if (G < H)
    Y = 1, Q = G, G = H, H = Q;
  let N = ZZ.create(G, G), q = ZZ.create(1, H), U = ZZ.create(H, H);
  if (Y === 0)
    ZZ.transpose(N, Z);
  else {
    for (Q = 0;Q < K * W; Q++)
      N.data[Q] = Z.data[Q];
    for (;Q < H * G; Q++)
      N.data[Q] = 0;
  }
  if (jt0(N.data, G, q.data, U.data, H, G, H, G), J) {
    for (Q = 0;Q < H; Q++)
      J.data[Q] = q.data[Q];
    for (;Q < K; Q++)
      J.data[Q] = 0;
  }
  if (Y === 0) {
    if ($)
      ZZ.transpose($, N);
    if (X)
      ZZ.transpose(X, U);
  } else {
    if ($)
      ZZ.transpose($, U);
    if (X)
      ZZ.transpose(X, N);
  }
}

// node_modules/molstar/lib/mol-math/linear-algebra/matrix/principal-axes.js
var HY;
(function(Z) {
  function J(W) {
    let K = $(W), G = Q(W, K);
    return { momentsAxes: K, boxAxes: G };
  }
  Z.ofPositions = J;
  function $(W) {
    if (W.length === 3)
      return m7.create(M.fromArray(M(), W, 0), M.create(1, 0, 0), M.create(0, 1, 0), M.create(0, 0, 1));
    let K = ZZ.fromArray(W, 3, W.length / 3), G = K.rows, H = G / 3, N = ZZ.create(3, 3), q = ZZ.create(1, 3), U = ZZ.create(3, 3), F = ZZ.create(3, 3), E = ZZ.meanRows(K), R = ZZ.subRows(ZZ.clone(K), E), z = ZZ.transpose(ZZ.create(G, 3), R);
    ZZ.multiplyABt(N, z, z), pG0(N, q, U, F);
    let D = M.create(E[0], E[1], E[2]), A = M.create(U.data[0], U.data[3], U.data[6]), B = M.create(U.data[1], U.data[4], U.data[7]), T = M.create(U.data[2], U.data[5], U.data[8]);
    return M.scale(A, A, Math.sqrt(q.data[0] / H)), M.scale(B, B, Math.sqrt(q.data[1] / H)), M.scale(T, T, Math.sqrt(q.data[2] / H)), m7.create(D, A, B, T);
  }
  Z.calculateMomentsAxes = $;
  function X(W) {
    let K = m7.clone(W);
    if (M.magnitude(K.dirC) < u8)
      M.cross(K.dirC, K.dirA, K.dirB);
    return m7.normalize(K, K);
  }
  Z.calculateNormalizedAxes = X;
  let Y = M();
  function Q(W, K) {
    if (W.length === 3)
      return m7.clone(K);
    let G = -1 / 0, H = -1 / 0, N = -1 / 0, q = -1 / 0, U = -1 / 0, F = -1 / 0, E = M(), R = M(), z = K.origin, D = X(K);
    for (let f = 0, v = W.length;f < v; f += 3) {
      M.projectPointOnVector(E, M.fromArray(E, W, f), D.dirA, z);
      let h = M.dot(D.dirA, M.normalize(R, M.sub(R, E, z))), x = M.distance(E, z);
      if (h > 0) {
        if (x > G)
          G = x;
      } else if (x > H)
        H = x;
      M.projectPointOnVector(E, M.fromArray(E, W, f), D.dirB, z);
      let b = M.dot(D.dirB, M.normalize(R, M.sub(R, E, z))), g = M.distance(E, z);
      if (b > 0) {
        if (g > N)
          N = g;
      } else if (g > q)
        q = g;
      M.projectPointOnVector(E, M.fromArray(E, W, f), D.dirC, z);
      let m = M.dot(D.dirC, M.normalize(R, M.sub(R, E, z))), i = M.distance(E, z);
      if (m > 0) {
        if (i > U)
          U = i;
      } else if (i > F)
        F = i;
    }
    let A = M.setMagnitude(M(), D.dirA, (G + H) / 2), B = M.setMagnitude(M(), D.dirB, (N + q) / 2), T = M.setMagnitude(M(), D.dirC, (U + F) / 2), w = M.isFinite(A), V = M.isFinite(B), P = M.isFinite(T), I = M(), S = function(f, v, h) {
      if (M.copy(Y, z), w)
        M.scaleAndAdd(Y, Y, D.dirA, f);
      if (V)
        M.scaleAndAdd(Y, Y, D.dirB, v);
      if (P)
        M.scaleAndAdd(Y, Y, D.dirC, h);
      M.add(I, I, Y);
    };
    return S(G, N, U), S(G, N, -F), S(G, -q, -F), S(G, -q, U), S(-H, -q, -F), S(-H, -q, U), S(-H, N, U), S(-H, N, -F), M.scale(I, I, 0.125), m7.create(I, A, B, T);
  }
  Z.calculateBoxAxes = Q;
})(HY || (HY = {}));

// node_modules/molstar/lib/mol-math/geometry/primitives/sphere3d.js
function C0() {
  return C0.zero();
}
(function(Z) {
  function J(b) {
    return b.extrema !== void 0;
  }
  Z.hasExtrema = J;
  function $(b, g) {
    return { center: b, radius: g };
  }
  Z.create = $;
  function X() {
    return { center: M(), radius: 0 };
  }
  Z.zero = X;
  function Y(b) {
    let g = $(M.clone(b.center), b.radius);
    if (J(b))
      g.extrema = b.extrema.map((m) => M.clone(m));
    return g;
  }
  Z.clone = Y;
  function Q(b, g, m) {
    return M.copy(b.center, g), b.radius = m, b;
  }
  Z.set = Q;
  function W(b, g) {
    if (M.copy(b.center, g.center), b.radius = g.radius, J(g))
      K(b, g.extrema.map((m) => M.clone(m)));
    return b;
  }
  Z.copy = W;
  function K(b, g) {
    if (b.extrema !== void 0)
      b.extrema.length = 0, b.extrema.push(...g);
    else
      b.extrema = g;
    return b;
  }
  Z.setExtrema = K;
  function G(b) {
    let { x: g, y: m, z: i, indices: r } = b, Y0 = 0, c = 0, n = 0, l = 0, u = f0.size(r);
    for (let G0 = 0;G0 < u; G0++) {
      let F0 = f0.getAt(r, G0);
      Y0 += g[F0], c += m[F0], n += i[F0];
    }
    if (u > 0)
      Y0 /= u, c /= u, n /= u;
    for (let G0 = 0;G0 < u; G0++) {
      let F0 = f0.getAt(r, G0), t = g[F0] - Y0, Z0 = m[F0] - c, U0 = i[F0] - n, a = t * t + Z0 * Z0 + U0 * U0;
      if (a > l)
        l = a;
    }
    return { center: M.create(Y0, c, n), radius: Math.sqrt(l) };
  }
  Z.computeBounding = G;
  function H(b, g, m) {
    if (M.transformMat4(b.center, g.center, m), b.radius = g.radius * e.getMaxScaleOnAxis(m), J(g))
      K(b, g.extrema.map((i) => M.transformMat4(M(), i, m)));
    return b;
  }
  Z.transform = H;
  function N(b, g, m) {
    if (M.add(b.center, g.center, m), J(g))
      K(b, g.extrema.map((i) => M.add(M(), i, m)));
    return b;
  }
  Z.translate = N;
  function q(b, g, m) {
    if (M.scale(b.center, g.center, m), b.radius = g.radius * m, J(g))
      K(b, g.extrema.map((i) => M.scale(M(), i, m)));
    return b;
  }
  Z.scale = q;
  function U(b, g, m) {
    return M.scale(b.center, g.center, m), b.radius = g.radius * m, b;
  }
  Z.scaleNX = U;
  function F(b, g, m) {
    return M.toArray(b.center, g, m), g[m + 3] = b.radius, g;
  }
  Z.toArray = F;
  function E(b, g, m) {
    return M.fromArray(b.center, g, m), b.radius = g[m + 3], b;
  }
  Z.fromArray = E;
  function R(b, g) {
    return M.scale(b.center, M.add(b.center, g.max, g.min), 0.5), b.radius = M.distance(b.center, g.max), Z.setExtrema(b, [
      M.create(g.min[0], g.min[1], g.min[2]),
      M.create(g.max[0], g.max[1], g.max[2]),
      M.create(g.max[0], g.min[1], g.min[2]),
      M.create(g.min[0], g.max[1], g.max[2]),
      M.create(g.min[0], g.min[1], g.max[2]),
      M.create(g.max[0], g.min[1], g.max[2]),
      M.create(g.max[0], g.max[1], g.min[2]),
      M.create(g.min[0], g.max[1], g.min[2])
    ]), b;
  }
  Z.fromBox3D = R;
  function z(b, g) {
    return M.copy(b.center, g.origin), b.radius = Math.max(M.magnitude(g.dirA), M.magnitude(g.dirB), M.magnitude(g.dirC)), b;
  }
  Z.fromAxes3D = z;
  let D = M();
  function A(b, g, m) {
    let [i, r, Y0] = g, c = M.create(0, 0, 0);
    M.transformMat4(c, c, m);
    let n = M.create(i, r, Y0);
    M.transformMat4(n, n, m);
    let l = M.create(i, 0, 0);
    M.transformMat4(l, l, m);
    let u = M.create(0, r, Y0);
    M.transformMat4(u, u, m);
    let G0 = M.create(0, 0, Y0);
    M.transformMat4(G0, G0, m);
    let F0 = M.create(i, 0, Y0);
    M.transformMat4(F0, F0, m);
    let t = M.create(i, r, 0);
    M.transformMat4(t, t, m);
    let Z0 = M.create(0, r, 0);
    M.transformMat4(Z0, Z0, m), M.add(D, c, n), M.scale(D, D, 0.5);
    let U0 = Math.max(M.distance(c, n), M.distance(l, u));
    return Z.set(b, D, U0 / 2), Z.setExtrema(b, [c, n, l, u, G0, F0, t, Z0]), b;
  }
  Z.fromDimensionsAndTransform = A;
  let B = M();
  function T(b, g, m) {
    if (M.distance(g.center, m) < g.radius)
      return Z.copy(b, g);
    return M.sub(B, g.center, m), M.sub(B, g.center, B), M.setMagnitude(B, B, g.radius), M.scale(b.center, M.add(B, B, m), 0.5), b.radius = M.distance(b.center, m), b;
  }
  Z.addVec3 = T;
  function w(b, g, m) {
    if (M.copy(b.center, g.center), b.radius = Math.max(g.radius, M.distance(g.center, m.center) + m.radius), J(g) && J(m))
      K(b, [
        ...g.extrema.map((i) => M.clone(i)),
        ...m.extrema.map((i) => M.clone(i))
      ]);
    return b;
  }
  Z.expandBySphere = w;
  let V = M();
  function P(b, g, m) {
    var i, r;
    if (M.copy(b.center, g.center), b.radius = g.radius + m, g.radius < 0.000000000001 || ((r = (i = g.extrema) === null || i === void 0 ? void 0 : i.length) !== null && r !== void 0 ? r : 0) <= 1)
      return b.extrema = void 0, b;
    if (J(g)) {
      let Y0 = new Float32Array(g.extrema.length * 3);
      for (let n = 0;n < g.extrema.length; n++)
        M.toArray(g.extrema[n], Y0, n * 3);
      let c = HY.calculateMomentsAxes(Y0);
      m7.scale(c, m7.normalize(c, c), m), K(b, g.extrema.map((n) => {
        M.normalize(V, M.sub(V, n, g.center));
        let l = M.clone(n), u = M.dot(V, c.dirA) < 0 ? -1 : 1;
        M.scaleAndAdd(l, l, c.dirA, u);
        let G0 = M.dot(V, c.dirB) < 0 ? -1 : 1;
        M.scaleAndAdd(l, l, c.dirB, G0);
        let F0 = M.dot(V, c.dirC) < 0 ? -1 : 1;
        if (M.scaleAndAdd(l, l, c.dirC, F0), M.distance(b.center, l) > b.radius) {
          if (g.extrema.length >= 14)
            M.normalize(V, M.sub(V, l, g.center));
          M.scaleAndAdd(l, b.center, V, b.radius);
        }
        return l;
      }));
    }
    return b;
  }
  Z.expand = P;
  function I(b, g) {
    return b.radius === g.radius && M.exactEquals(b.center, g.center);
  }
  Z.exactEquals = I;
  function S(b, g) {
    let m = b.radius, i = g.radius;
    return Math.abs(m - i) <= u8 * Math.max(1, Math.abs(m), Math.abs(i)) && M.equals(b.center, g.center);
  }
  Z.equals = S;
  function f(b, g) {
    if (J(g)) {
      for (let m of g.extrema)
        if (M.distance(b.center, m) > b.radius)
          return !1;
      return !0;
    } else
      return M.distance(b.center, g.center) + g.radius <= b.radius;
  }
  Z.includes = f;
  function v(b, g) {
    return M.distance(b.center, g.center) <= b.radius + g.radius;
  }
  Z.overlaps = v;
  function h(b, g) {
    return M.distance(b.center, g.center) - b.radius + g.radius;
  }
  Z.distance = h;
  function x(b, g) {
    let { center: m, radius: i } = b;
    return M.distance(g, m) - i;
  }
  Z.distanceToVec = x;
})(C0 || (C0 = {}));

// node_modules/molstar/lib/mol-math/geometry/primitives/box3d.js
function t1() {
  return t1.zero();
}
(function(Z) {
  function J(b, g) {
    return { min: b, max: g };
  }
  Z.create = J;
  function $() {
    return { min: M(), max: M() };
  }
  Z.zero = $;
  function X(b, g) {
    return M.copy(b.min, g.min), M.copy(b.max, g.max), b;
  }
  Z.copy = X;
  function Y(b, g, m) {
    return M.copy(b.min, g), M.copy(b.max, m), b;
  }
  Z.set = Y;
  function Q(b) {
    return X($(), b);
  }
  Z.clone = Q;
  let W = M();
  function K(b, g) {
    if (C0.hasExtrema(g) && g.extrema.length >= 14)
      return H(b, g.extrema);
    return M.set(W, g.radius, g.radius, g.radius), M.sub(b.min, g.center, W), M.add(b.max, g.center, W), b;
  }
  Z.fromSphere3D = K;
  function G(b, g) {
    for (let m = 0, i = g.length;m < i; m++)
      A(b, g[m]);
    return b;
  }
  Z.addVec3Array = G;
  function H(b, g) {
    return D(b), G(b, g), b;
  }
  Z.fromVec3Array = H;
  function N(b, g) {
    if (C0.hasExtrema(g) && g.extrema.length >= 14)
      return G(b, g.extrema);
    return A(b, M.subScalar(W, g.center, g.radius)), A(b, M.addScalar(W, g.center, g.radius)), b;
  }
  Z.addSphere3D = N;
  function q(b, g) {
    return A(b, g.min), A(b, g.max), b;
  }
  Z.addBox3D = q;
  function U(b, g) {
    return M.clamp(W, g.center, b.min, b.max), M.squaredDistance(W, g.center) <= g.radius * g.radius;
  }
  Z.intersectsSphere3D = U;
  function F(b) {
    let g = M.create(Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE), m = M.create(-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE), { x: i, y: r, z: Y0, indices: c } = b;
    for (let n = 0, l = f0.size(c);n < l; n++) {
      let u = f0.getAt(c, n);
      g[0] = Math.min(i[u], g[0]), g[1] = Math.min(r[u], g[1]), g[2] = Math.min(Y0[u], g[2]), m[0] = Math.max(i[u], m[0]), m[1] = Math.max(r[u], m[1]), m[2] = Math.max(Y0[u], m[2]);
    }
    return { min: g, max: m };
  }
  Z.computeBounding = F;
  function E(b, g) {
    return M.sub(b, g.max, g.min);
  }
  Z.size = E;
  let R = M();
  function z(b) {
    return E(R, b), R[0] * R[1] * R[2];
  }
  Z.volume = z;
  function D(b) {
    return M.set(b.min, Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE), M.set(b.max, -Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE), b;
  }
  Z.setEmpty = D;
  function A(b, g) {
    return M.min(b.min, b.min, g), M.max(b.max, b.max, g), b;
  }
  Z.add = A;
  function B(b, g, m) {
    return M.sub(b.min, g.min, m), M.add(b.max, g.max, m), b;
  }
  Z.expand = B;
  function T(b, g, m) {
    return M.subScalar(b.min, g.min, m), M.addScalar(b.max, g.max, m), b;
  }
  Z.expandUniformly = T;
  function w(b, g, m) {
    return M.scale(b.min, g.min, m), M.scale(b.max, g.max, m), b;
  }
  Z.scale = w;
  let V = M();
  function P(b, g, m) {
    let [i, r, Y0] = g.min, [c, n, l] = g.max;
    return D(b), A(b, M.transformMat4(V, M.set(V, i, r, Y0), m)), A(b, M.transformMat4(V, M.set(V, i, r, l), m)), A(b, M.transformMat4(V, M.set(V, i, n, Y0), m)), A(b, M.transformMat4(V, M.set(V, i, n, l), m)), A(b, M.transformMat4(V, M.set(V, c, r, Y0), m)), A(b, M.transformMat4(V, M.set(V, c, r, l), m)), A(b, M.transformMat4(V, M.set(V, c, n, Y0), m)), A(b, M.transformMat4(V, M.set(V, c, n, l), m)), b;
  }
  Z.transform = P;
  function I(b, g) {
    return !(g[0] < b.min[0] || g[0] > b.max[0] || g[1] < b.min[1] || g[1] > b.max[1] || g[2] < b.min[2] || g[2] > b.max[2]);
  }
  Z.containsVec3 = I;
  function S(b, g) {
    return !(b.max[0] < g.min[0] || b.min[0] > g.max[0] || b.max[1] < g.min[1] || b.min[1] > g.max[1] || b.max[2] < g.min[2] || b.min[2] > g.max[2]);
  }
  Z.overlaps = S;
  function f(b, g) {
    let { center: m, radius: i } = g;
    return m[0] - i < b.min[0] || m[0] + i > b.max[0] || m[1] - i < b.min[1] || m[1] + i > b.max[1] || m[2] - i < b.min[2] || m[2] + i > b.max[2] ? !1 : !0;
  }
  Z.containsSphere3D = f;
  function v(b, g) {
    return M.center(b, g.max, g.min);
  }
  Z.center = v;
  function h(b, g) {
    return M.exactEquals(b.min, g.min) && M.exactEquals(b.max, g.max);
  }
  Z.exactEquals = h;
  function x(b, g) {
    return M.equals(b.min, g.min) && M.equals(b.max, g.max);
  }
  Z.equals = x;
})(t1 || (t1 = {}));

// node_modules/molstar/lib/mol-math/geometry/common.js
function UR(Z, J, $) {
  let X = new Float32Array(Z);
  for (let Y = 0;Y < X.length; Y++)
    X[Y] = J + $ * Y;
  return X;
}
// node_modules/molstar/lib/mol-math/geometry/symmetry-operator.js
var RZ;
(function(Z) {
  Z.DefaultName = "1_555", Z.Default = J(Z.DefaultName, e.identity()), Z.RotationTranslationEpsilon = 0.005;
  function J(T, w, V) {
    var P;
    let { assembly: I, ncsId: S, hkl: f, spgrOp: v, key: h } = V || {}, x = f ? M.clone(f) : M();
    v = v !== null && v !== void 0 ? v : -1, h = h !== null && h !== void 0 ? h : -1, S = S || -1;
    let b = e.isIdentity(w), g = Q(V, b), m = (P = V === null || V === void 0 ? void 0 : V.instanceId) !== null && P !== void 0 ? P : T;
    if (b)
      return { name: T, instanceId: m, assembly: I, matrix: w, inverse: e.identity(), isIdentity: !0, hkl: x, spgrOp: v, ncsId: S, suffix: g, key: h };
    if (!e.isRotationAndTranslation(w, Z.RotationTranslationEpsilon))
      console.warn(`Symmetry operator (${T}) should be a composition of rotation and translation.`);
    return { name: T, instanceId: m, assembly: I, matrix: w, inverse: e.invert(e(), w), isIdentity: !1, hkl: x, spgrOp: v, key: h, ncsId: S, suffix: g };
  }
  Z.create = J;
  function $(T) {
    return !!T && !!T.matrix && !!T.inverse && typeof T.name === "string";
  }
  function X(T, w, V, P) {
    let I = (S) => S >= 0 && S <= 9 ? `${S}` : `(${S})`;
    return `${T + 1}_${I(w + 5)}${I(V + 5)}${I(P + 5)}`;
  }
  Z.getSymmetryOperatorName = X;
  function Y(T) {
    return "ASM-" + T.join("-");
  }
  Z.getAssemblyOperatorName = Y;
  function Q(T, w) {
    if (!T)
      return "";
    if (T.assembly) {
      if ($(T))
        return T.suffix;
      return w ? "" : `_${T.assembly.operId}`;
    }
    if (typeof T.spgrOp !== "undefined" && typeof T.hkl !== "undefined" && T.spgrOp !== -1) {
      let [V, P, I] = T.hkl;
      return `-${X(T.spgrOp, V, P, I)}`;
    }
    if (T.ncsId !== -1)
      return `_${T.ncsId}`;
    return "";
  }
  let W = e();
  function K(T, w) {
    e.setIdentity(W);
    for (let V = 0;V < 3; V++)
      for (let P = 0;P < 3; P++)
        e.setValue(W, V, P, h2.getValue(T, V, P));
    return e.setTranslation(W, w), e.isRotationAndTranslation(W, Z.RotationTranslationEpsilon);
  }
  Z.checkIfRotationAndTranslation = K;
  function G(T, w, V, P) {
    let I = e.identity();
    for (let S = 0;S < 3; S++)
      for (let f = 0;f < 3; f++)
        e.setValue(I, S, f, h2.getValue(w, S, f));
    return e.setTranslation(I, V), J(T, I, { ncsId: P });
  }
  Z.ofRotationAndOffset = G;
  let H = k8.identity(), N = k8(), q = k8(), U = M();
  function F(T, w, V) {
    let P = w.inverse;
    if (w.isIdentity)
      return e.copy(T, P);
    let I = 1 - V;
    e.getRotation(N, P), k8.slerp(N, H, N, I);
    let S = k8.getAxisAngle(U, N);
    return e.fromRotation(T, S, U), e.setValue(T, 0, 3, I * e.getValue(P, 0, 3)), e.setValue(T, 1, 3, I * e.getValue(P, 1, 3)), e.setValue(T, 2, 3, I * e.getValue(P, 2, 3)), T;
  }
  Z.lerpFromIdentity = F;
  function E(T, w, V, P) {
    if (Math.abs(P) <= 0.00001)
      return e.copy(T, w);
    if (Math.abs(P - 1) <= 0.00001)
      return e.copy(T, V);
    e.getRotation(N, w), e.getRotation(q, V), k8.slerp(q, N, q, P);
    let I = k8.getAxisAngle(U, q);
    return e.fromRotation(T, I, U), e.setValue(T, 0, 3, pZ(e.getValue(w, 0, 3), e.getValue(V, 0, 3), P)), e.setValue(T, 1, 3, pZ(e.getValue(w, 1, 3), e.getValue(V, 1, 3), P)), e.setValue(T, 2, 3, pZ(e.getValue(w, 2, 3), e.getValue(V, 2, 3), P)), T;
  }
  Z.slerp = E;
  function R(T, w) {
    let V = e.mul(e(), w.matrix, T.matrix);
    return J(w.name, V, w);
  }
  Z.compose = R;

  class z {
    constructor(T, w, V = Af) {
      this.operator = T, this.coordinates = w, this.r = V, this._x = w.x, this._y = w.y, this._z = w.z, this._m = T.matrix;
    }
    invariantPosition(T, w) {
      return w[0] = this._x[T], w[1] = this._y[T], w[2] = this._z[T], w;
    }
    position(T, w) {
      return w[0] = this._x[T], w[1] = this._y[T], w[2] = this._z[T], M.transformMat4(w, w, this._m), w;
    }
    x(T) {
      let w = this._m, V = w[0], P = w[4], I = w[8], S = w[12], f = this._x[T], v = this._y[T], h = this._z[T], x = w[3] * f + w[7] * v + w[11] * h + w[15] || 1;
      return (V * f + P * v + I * h + S) / x;
    }
    y(T) {
      let w = this._m, V = w[1], P = w[5], I = w[9], S = w[13], f = this._x[T], v = this._y[T], h = this._z[T], x = w[3] * f + w[7] * v + w[11] * h + w[15] || 1;
      return (V * f + P * v + I * h + S) / x;
    }
    z(T) {
      let w = this._m, V = w[2], P = w[6], I = w[10], S = w[14], f = this._x[T], v = this._y[T], h = this._z[T], x = w[3] * f + w[7] * v + w[11] * h + w[15] || 1;
      return (V * f + P * v + I * h + S) / x;
    }
  }

  class D {
    constructor(T, w, V = Af) {
      this.operator = T, this.coordinates = w, this.r = V, this._x = w.x, this._y = w.y, this._z = w.z, this._m = T.matrix;
    }
    invariantPosition(T, w) {
      return w[0] = this._x[T], w[1] = this._y[T], w[2] = this._z[T], w;
    }
    position(T, w) {
      return w[0] = this.x(T), w[1] = this.y(T), w[2] = this.z(T), w;
    }
    x(T) {
      let w = this._m;
      return w[0] * this._x[T] + w[4] * this._y[T] + w[8] * this._z[T] + w[12];
    }
    y(T) {
      let w = this._m;
      return w[1] * this._x[T] + w[5] * this._y[T] + w[9] * this._z[T] + w[13];
    }
    z(T) {
      let w = this._m;
      return w[2] * this._x[T] + w[6] * this._y[T] + w[10] * this._z[T] + w[14];
    }
  }

  class A {
    constructor(T, w, V = Af) {
      this.operator = T, this.coordinates = w, this.r = V, this._x = w.x, this._y = w.y, this._z = w.z;
    }
    invariantPosition(T, w) {
      return w[0] = this._x[T], w[1] = this._y[T], w[2] = this._z[T], w;
    }
    position(T, w) {
      return w[0] = this._x[T], w[1] = this._y[T], w[2] = this._z[T], w;
    }
    x(T) {
      return this._x[T];
    }
    y(T) {
      return this._y[T];
    }
    z(T) {
      return this._z[T];
    }
  }
  function B(T, w, V = Af) {
    return e.isIdentity(T.matrix) ? new A(T, w, V) : Tt0(T.matrix) ? new D(T, w, V) : new z(T, w, V);
  }
  Z.createMapping = B;
})(RZ || (RZ = {}));
function Af(Z) {
  return 0;
}
function Tt0(Z) {
  return Z[3] === 0 && Z[7] === 0 && Z[11] === 0 && Z[15] === 1;
}
// node_modules/molstar/lib/mol-math/geometry/spacegroup/tables.js
var Bf = [
  [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, 0.3333333333333333],
  [0, 0, 1, 0.6666666666666666],
  [1, 0, 0, 0.6666666666666666],
  [0, 1, 0, 0.3333333333333333],
  [0, -1, 0, 0.6666666666666666],
  [1, -1, 0, 0.3333333333333333],
  [-1, 1, 0, 0.6666666666666666],
  [-1, 0, 0, 0.3333333333333333],
  [1, 0, 0, 0.3333333333333333],
  [0, 1, 0, 0.6666666666666666],
  [0, -1, 0, 0.3333333333333333],
  [1, -1, 0, 0.6666666666666666],
  [-1, 1, 0, 0.3333333333333333],
  [-1, 0, 0, 0.6666666666666666],
  [0, 0, -1, 0.3333333333333333],
  [0, 0, -1, 0.6666666666666666],
  [0, 0, 1, 0.8333333333333334],
  [0, 0, 1, 0.16666666666666666],
  [0, 0, -1, 0.8333333333333334],
  [0, 0, -1, 0.16666666666666666]
], uG0 = [
  [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]
], cG0 = [
  [0],
  [0, 1],
  [0, 2],
  [0, 3],
  [0, 2, 4, 5],
  [0, 6],
  [0, 7],
  [0, 6, 4, 8],
  [0, 7, 4, 9],
  [0, 6, 2, 1],
  [0, 3, 1, 10],
  [0, 6, 2, 1, 4, 8, 5, 11],
  [0, 12, 1, 7],
  [0, 1, 13, 14],
  [0, 12, 1, 7, 4, 15, 11, 9],
  [0, 16, 2, 17],
  [0, 18, 12, 17],
  [0, 16, 5, 19],
  [0, 20, 13, 19],
  [0, 18, 12, 17, 4, 21, 15, 19],
  [0, 16, 2, 17, 4, 22, 5, 19],
  [0, 16, 2, 17, 23, 24, 13, 25, 26, 20, 27, 28, 4, 22, 5, 19],
  [0, 16, 17, 2, 29, 21, 30, 15],
  [0, 20, 13, 19, 29, 31, 32, 33],
  [0, 16, 6, 34],
  [0, 18, 7, 34],
  [0, 16, 7, 35],
  [0, 16, 36, 37],
  [0, 18, 36, 38],
  [0, 16, 14, 39],
  [0, 20, 40, 34],
  [0, 16, 8, 41],
  [0, 18, 8, 42],
  [0, 16, 9, 42],
  [0, 16, 6, 34, 4, 22, 8, 41],
  [0, 18, 7, 34, 4, 21, 9, 41],
  [0, 16, 7, 35, 4, 22, 9, 42],
  [0, 16, 6, 34, 23, 24, 14, 39],
  [0, 16, 10, 43, 23, 24, 7, 35],
  [0, 16, 36, 37, 23, 24, 9, 42],
  [0, 16, 8, 41, 23, 24, 40, 38],
  [0, 16, 6, 34, 23, 24, 14, 39, 26, 20, 40, 38, 4, 22, 8, 41],
  [0, 16, 44, 45, 23, 24, 46, 47, 26, 20, 48, 49, 4, 22, 50, 51],
  [0, 16, 6, 34, 29, 21, 9, 42],
  [0, 16, 8, 41, 29, 21, 7, 35],
  [0, 16, 36, 37, 29, 21, 14, 39],
  [0, 16, 2, 17, 1, 52, 6, 34],
  [0, 16, 2, 17, 53, 54, 9, 42],
  [0, 16, 12, 33, 1, 52, 7, 35],
  [0, 16, 2, 17, 11, 55, 8, 41],
  [0, 56, 2, 57, 1, 58, 6, 37],
  [0, 56, 15, 25, 1, 58, 9, 39],
  [0, 20, 27, 17, 1, 59, 40, 34],
  [0, 56, 12, 28, 1, 58, 7, 38],
  [0, 16, 5, 19, 1, 52, 8, 41],
  [0, 22, 13, 28, 1, 55, 14, 38],
  [0, 18, 13, 60, 1, 61, 14, 43],
  [0, 16, 15, 30, 1, 52, 9, 42],
  [0, 16, 5, 19, 11, 55, 6, 34],
  [0, 21, 12, 19, 1, 54, 7, 41],
  [0, 20, 13, 19, 1, 59, 14, 41],
  [0, 20, 3, 30, 1, 59, 10, 42],
  [0, 18, 12, 17, 1, 61, 7, 34, 4, 21, 15, 19, 11, 54, 9, 41],
  [0, 24, 13, 17, 1, 62, 14, 34, 4, 20, 27, 19, 11, 59, 40, 41],
  [0, 16, 2, 17, 1, 52, 6, 34, 4, 22, 5, 19, 11, 55, 8, 41],
  [0, 16, 12, 33, 1, 52, 7, 35, 4, 22, 15, 30, 11, 55, 9, 42],
  [0, 31, 3, 17, 1, 63, 10, 34, 4, 56, 32, 19, 11, 58, 36, 41],
  [0, 22, 2, 19, 64, 59, 14, 38, 4, 16, 5, 17, 65, 62, 40, 39],
  [0, 16, 2, 17, 1, 52, 6, 34, 23, 24, 13, 25, 64, 62, 14, 39, 26, 20, 27, 28, 65, 59, 40, 38, 4, 22, 5, 19, 11, 55, 8, 41],
  [0, 16, 2, 17, 66, 67, 44, 45, 23, 24, 13, 25, 68, 69, 46, 47, 26, 20, 27, 28, 70, 71, 48, 49, 4, 22, 5, 19, 72, 73, 50, 51],
  [0, 16, 2, 17, 1, 52, 6, 34, 29, 21, 15, 30, 53, 54, 9, 42],
  [0, 16, 5, 19, 1, 52, 8, 41, 29, 21, 12, 33, 53, 54, 7, 35],
  [0, 20, 13, 19, 1, 59, 14, 41, 29, 31, 32, 33, 53, 63, 36, 35],
  [0, 31, 3, 17, 1, 63, 10, 34, 29, 20, 27, 30, 53, 59, 40, 42],
  [0, 16, 74, 75],
  [0, 18, 76, 77],
  [0, 16, 78, 79],
  [0, 18, 80, 81],
  [0, 16, 74, 75, 29, 21, 82, 83],
  [0, 21, 84, 85, 29, 16, 86, 87],
  [0, 16, 88, 89],
  [0, 16, 88, 89, 29, 21, 90, 91],
  [0, 16, 74, 75, 1, 52, 88, 89],
  [0, 16, 78, 79, 1, 52, 92, 93],
  [0, 16, 94, 95, 11, 55, 88, 89],
  [0, 16, 82, 83, 53, 54, 88, 89],
  [0, 16, 74, 75, 1, 52, 88, 89, 29, 21, 82, 83, 53, 54, 90, 91],
  [0, 21, 84, 85, 96, 97, 88, 91, 29, 16, 86, 87, 98, 99, 90, 89],
  [0, 16, 74, 75, 2, 17, 100, 101],
  [0, 16, 94, 95, 5, 19, 100, 101],
  [0, 18, 76, 77, 2, 33, 102, 103],
  [0, 18, 104, 105, 106, 107, 100, 108],
  [0, 16, 78, 79, 2, 17, 109, 108],
  [0, 16, 82, 83, 15, 30, 100, 101],
  [0, 18, 80, 81, 2, 33, 110, 111],
  [0, 18, 112, 113, 114, 115, 100, 108],
  [0, 16, 74, 75, 2, 17, 100, 101, 29, 21, 82, 83, 15, 30, 116, 117],
  [0, 21, 84, 85, 118, 119, 116, 101, 29, 16, 86, 87, 120, 121, 100, 117],
  [0, 16, 74, 75, 6, 34, 122, 123],
  [0, 16, 74, 75, 8, 41, 124, 125],
  [0, 16, 78, 79, 7, 35, 122, 123],
  [0, 16, 82, 83, 9, 42, 122, 123],
  [0, 16, 74, 75, 7, 35, 126, 127],
  [0, 16, 74, 75, 9, 42, 128, 129],
  [0, 16, 78, 79, 6, 34, 126, 127],
  [0, 16, 78, 79, 8, 41, 128, 129],
  [0, 16, 74, 75, 6, 34, 122, 123, 29, 21, 82, 83, 9, 42, 128, 129],
  [0, 16, 74, 75, 7, 35, 126, 127, 29, 21, 82, 83, 8, 41, 124, 125],
  [0, 21, 84, 85, 6, 42, 130, 131, 29, 16, 86, 87, 9, 34, 132, 133],
  [0, 21, 84, 85, 7, 41, 134, 135, 29, 16, 86, 87, 8, 35, 136, 137],
  [0, 16, 89, 88, 2, 17, 122, 123],
  [0, 16, 89, 88, 12, 33, 126, 127],
  [0, 16, 89, 88, 5, 19, 124, 125],
  [0, 16, 89, 88, 15, 30, 128, 129],
  [0, 16, 88, 89, 6, 34, 100, 101],
  [0, 16, 89, 88, 7, 35, 109, 108],
  [0, 16, 89, 88, 8, 41, 138, 139],
  [0, 16, 89, 88, 9, 42, 116, 117],
  [0, 16, 89, 88, 6, 34, 100, 101, 29, 21, 91, 90, 9, 42, 116, 117],
  [0, 16, 89, 88, 7, 35, 109, 108, 29, 21, 91, 90, 8, 41, 138, 139],
  [0, 16, 89, 88, 2, 17, 122, 123, 29, 21, 91, 90, 15, 30, 128, 129],
  [0, 16, 89, 88, 118, 121, 132, 131, 29, 21, 91, 90, 120, 119, 130, 133],
  [0, 16, 74, 75, 2, 17, 100, 101, 1, 52, 88, 89, 6, 34, 122, 123],
  [0, 16, 74, 75, 12, 33, 109, 108, 1, 52, 88, 89, 7, 35, 126, 127],
  [0, 16, 74, 75, 2, 17, 100, 101, 11, 55, 140, 141, 8, 41, 124, 125],
  [0, 16, 74, 75, 2, 17, 100, 101, 53, 54, 90, 91, 9, 42, 128, 129],
  [0, 16, 74, 75, 5, 19, 138, 139, 1, 52, 88, 89, 8, 41, 124, 125],
  [0, 16, 74, 75, 15, 30, 116, 117, 1, 52, 88, 89, 9, 42, 128, 129],
  [0, 16, 94, 95, 5, 19, 100, 101, 11, 55, 88, 89, 6, 34, 124, 125],
  [0, 16, 94, 95, 15, 30, 109, 108, 11, 55, 88, 89, 7, 35, 128, 129],
  [0, 16, 78, 79, 2, 17, 109, 108, 1, 52, 92, 93, 6, 34, 126, 127],
  [0, 16, 78, 79, 12, 33, 100, 101, 1, 52, 92, 93, 7, 35, 122, 123],
  [0, 16, 82, 83, 12, 33, 138, 139, 53, 54, 88, 89, 8, 41, 126, 127],
  [0, 16, 82, 83, 2, 17, 116, 117, 53, 54, 88, 89, 9, 42, 122, 123],
  [0, 16, 78, 79, 5, 19, 116, 117, 1, 52, 92, 93, 8, 41, 128, 129],
  [0, 16, 82, 83, 15, 30, 100, 101, 1, 52, 90, 91, 9, 42, 122, 123],
  [0, 16, 82, 83, 15, 30, 100, 101, 53, 54, 88, 89, 6, 34, 128, 129],
  [0, 16, 82, 83, 5, 19, 109, 108, 53, 54, 88, 89, 7, 35, 124, 125],
  [0, 16, 74, 75, 2, 17, 100, 101, 1, 52, 88, 89, 6, 34, 122, 123, 29, 21, 82, 83, 15, 30, 116, 117, 53, 54, 90, 91, 9, 42, 128, 129],
  [0, 16, 74, 75, 12, 33, 109, 108, 1, 52, 88, 89, 7, 35, 126, 127, 29, 21, 82, 83, 5, 19, 138, 139, 53, 54, 90, 91, 8, 41, 124, 125],
  [0, 21, 84, 85, 118, 119, 116, 101, 96, 97, 88, 91, 9, 34, 132, 133, 29, 16, 86, 87, 120, 121, 100, 117, 98, 99, 90, 89, 6, 42, 130, 131],
  [0, 21, 84, 85, 142, 143, 138, 108, 96, 97, 88, 91, 8, 35, 136, 137, 29, 16, 86, 87, 144, 145, 109, 139, 98, 99, 90, 89, 7, 41, 134, 135],
  [0, 146, 147],
  [0, 148, 149],
  [0, 150, 151],
  [0, 146, 147, 152, 153, 154, 155, 156, 157],
  [0, 158, 159],
  [0, 146, 147, 1, 160, 161],
  [0, 146, 147, 1, 160, 161, 152, 153, 154, 162, 163, 164, 155, 156, 157, 165, 166, 167],
  [0, 158, 159, 1, 168, 169],
  [0, 146, 147, 101, 170, 171],
  [0, 146, 147, 100, 172, 173],
  [0, 148, 149, 174, 175, 171],
  [0, 148, 149, 100, 176, 177],
  [0, 150, 151, 178, 179, 171],
  [0, 150, 151, 100, 180, 181],
  [0, 146, 147, 100, 172, 173, 152, 153, 154, 182, 183, 184, 155, 156, 157, 185, 186, 187],
  [0, 158, 159, 101, 188, 189],
  [0, 146, 147, 122, 190, 191],
  [0, 146, 147, 123, 192, 193],
  [0, 146, 147, 126, 194, 195],
  [0, 146, 147, 127, 196, 197],
  [0, 146, 147, 122, 190, 191, 152, 153, 154, 198, 199, 200, 155, 156, 157, 201, 202, 203],
  [0, 158, 159, 123, 204, 205],
  [0, 146, 147, 126, 194, 195, 152, 153, 154, 206, 207, 208, 155, 156, 157, 209, 210, 211],
  [0, 158, 159, 129, 212, 213],
  [0, 146, 147, 101, 170, 171, 1, 160, 161, 123, 192, 193],
  [0, 146, 147, 108, 214, 215, 1, 160, 161, 127, 196, 197],
  [0, 146, 147, 100, 172, 173, 1, 160, 161, 122, 190, 191],
  [0, 146, 147, 109, 216, 217, 1, 160, 161, 126, 194, 195],
  [0, 146, 147, 100, 172, 173, 1, 160, 161, 122, 190, 191, 152, 153, 154, 182, 183, 184, 162, 163, 164, 198, 199, 200, 155, 156, 157, 185, 186, 187, 165, 166, 167, 201, 202, 203],
  [0, 158, 159, 101, 188, 189, 1, 168, 169, 123, 204, 205],
  [0, 146, 147, 109, 216, 217, 1, 160, 161, 126, 194, 195, 152, 153, 154, 218, 219, 220, 162, 163, 164, 206, 207, 208, 155, 156, 157, 221, 222, 223, 165, 166, 167, 209, 210, 211],
  [0, 158, 159, 117, 224, 225, 1, 168, 169, 129, 212, 213],
  [0, 146, 147, 16, 226, 227],
  [0, 148, 149, 18, 228, 229],
  [0, 150, 151, 18, 230, 231],
  [0, 150, 151, 16, 232, 233],
  [0, 148, 149, 16, 234, 235],
  [0, 146, 147, 18, 236, 237],
  [0, 146, 147, 52, 238, 239],
  [0, 146, 147, 16, 226, 227, 1, 160, 161, 52, 238, 239],
  [0, 146, 147, 18, 236, 237, 1, 160, 161, 61, 240, 241],
  [0, 146, 147, 16, 226, 227, 100, 172, 173, 101, 170, 171],
  [0, 148, 149, 18, 228, 229, 242, 172, 181, 243, 214, 244],
  [0, 150, 151, 18, 230, 231, 245, 172, 177, 246, 214, 247],
  [0, 150, 151, 16, 232, 233, 245, 172, 177, 174, 170, 248],
  [0, 148, 149, 16, 234, 235, 242, 172, 181, 178, 170, 249],
  [0, 146, 147, 18, 236, 237, 100, 172, 173, 108, 214, 215],
  [0, 146, 147, 16, 226, 227, 122, 190, 191, 123, 192, 193],
  [0, 146, 147, 16, 226, 227, 126, 194, 195, 127, 196, 197],
  [0, 146, 147, 18, 236, 237, 126, 194, 195, 123, 192, 193],
  [0, 146, 147, 18, 236, 237, 122, 190, 191, 127, 196, 197],
  [0, 146, 147, 52, 238, 239, 122, 190, 191, 101, 170, 171],
  [0, 146, 147, 61, 240, 241, 126, 194, 195, 101, 170, 171],
  [0, 146, 147, 52, 238, 239, 100, 172, 173, 123, 192, 193],
  [0, 146, 147, 61, 240, 241, 100, 172, 173, 127, 196, 197],
  [0, 146, 147, 16, 226, 227, 100, 172, 173, 101, 170, 171, 1, 160, 161, 52, 239, 238, 122, 190, 191, 123, 192, 193],
  [0, 146, 147, 16, 226, 227, 109, 216, 217, 108, 214, 215, 1, 160, 161, 52, 239, 238, 126, 194, 195, 127, 196, 197],
  [0, 146, 147, 18, 236, 237, 109, 216, 217, 101, 170, 171, 1, 160, 161, 61, 241, 240, 126, 194, 195, 123, 192, 193],
  [0, 146, 147, 18, 236, 237, 100, 172, 173, 108, 214, 215, 1, 160, 161, 61, 241, 240, 122, 190, 191, 127, 196, 197],
  [0, 16, 2, 17, 158, 250, 251, 252, 159, 253, 254, 255],
  [0, 16, 2, 17, 158, 250, 251, 252, 159, 253, 254, 255, 23, 24, 13, 25, 256, 257, 258, 259, 260, 261, 262, 263, 26, 20, 27, 28, 264, 265, 266, 267, 268, 269, 270, 271, 4, 22, 5, 19, 272, 273, 274, 275, 276, 277, 278, 279],
  [0, 16, 2, 17, 158, 250, 251, 252, 159, 253, 254, 255, 29, 21, 15, 30, 280, 281, 282, 283, 284, 285, 286, 287],
  [0, 20, 13, 19, 158, 273, 266, 259, 159, 261, 278, 271],
  [0, 20, 13, 19, 158, 273, 266, 259, 159, 261, 278, 271, 29, 31, 32, 33, 280, 288, 289, 290, 284, 291, 292, 293],
  [0, 16, 2, 17, 158, 250, 251, 252, 159, 253, 254, 255, 1, 52, 6, 34, 168, 294, 295, 296, 169, 297, 298, 299],
  [0, 16, 2, 17, 158, 250, 251, 252, 159, 253, 254, 255, 53, 54, 9, 42, 300, 301, 302, 303, 304, 305, 306, 307],
  [0, 16, 2, 17, 158, 250, 251, 252, 159, 253, 254, 255, 1, 52, 6, 34, 168, 294, 295, 296, 169, 297, 298, 299, 23, 24, 13, 25, 256, 257, 258, 259, 260, 261, 262, 263, 64, 62, 14, 39, 308, 309, 310, 311, 312, 313, 314, 315, 26, 20, 27, 28, 264, 265, 266, 267, 268, 269, 270, 271, 65, 59, 40, 38, 316, 317, 318, 319, 320, 321, 322, 323, 4, 22, 5, 19, 272, 273, 274, 275, 276, 277, 278, 279, 11, 55, 8, 41, 324, 325, 326, 327, 328, 329, 330, 331],
  [0, 16, 2, 17, 158, 250, 251, 252, 159, 253, 254, 255, 66, 67, 44, 45, 332, 333, 334, 335, 336, 337, 338, 339, 23, 24, 13, 25, 256, 257, 258, 259, 260, 261, 262, 263, 68, 69, 46, 47, 340, 341, 342, 343, 344, 345, 346, 347, 26, 20, 27, 28, 264, 265, 266, 267, 268, 269, 270, 271, 70, 71, 48, 49, 348, 349, 350, 351, 352, 353, 354, 355, 4, 22, 5, 19, 272, 273, 274, 275, 276, 277, 278, 279, 72, 73, 50, 51, 356, 357, 358, 359, 360, 361, 362, 363],
  [0, 16, 2, 17, 158, 250, 251, 252, 159, 253, 254, 255, 1, 52, 6, 34, 168, 294, 295, 296, 169, 297, 298, 299, 29, 21, 15, 30, 280, 281, 282, 283, 284, 285, 286, 287, 53, 54, 9, 42, 300, 301, 302, 303, 304, 305, 306, 307],
  [0, 20, 13, 19, 158, 273, 266, 259, 159, 261, 278, 271, 1, 59, 14, 41, 168, 325, 318, 311, 169, 313, 330, 323],
  [0, 20, 13, 19, 158, 273, 266, 259, 159, 261, 278, 271, 1, 59, 14, 41, 168, 325, 318, 311, 169, 313, 330, 323, 29, 31, 32, 33, 280, 288, 289, 290, 284, 291, 292, 293, 53, 63, 36, 35, 300, 364, 365, 366, 304, 367, 368, 369],
  [0, 16, 2, 17, 158, 250, 251, 252, 159, 253, 254, 255, 100, 101, 75, 74, 370, 371, 188, 372, 373, 374, 375, 189],
  [0, 16, 2, 17, 158, 250, 251, 252, 159, 253, 254, 255, 116, 117, 83, 82, 376, 377, 224, 378, 379, 380, 381, 225],
  [0, 16, 2, 17, 158, 250, 251, 252, 159, 253, 254, 255, 100, 101, 75, 74, 370, 371, 188, 372, 373, 374, 375, 189, 23, 24, 13, 25, 256, 257, 258, 259, 260, 261, 262, 263, 382, 383, 384, 385, 386, 387, 388, 389, 390, 391, 392, 393, 26, 20, 27, 28, 264, 265, 266, 267, 268, 269, 270, 271, 394, 395, 396, 397, 398, 399, 400, 401, 402, 403, 404, 405, 4, 22, 5, 19, 272, 273, 274, 275, 276, 277, 278, 279, 138, 139, 95, 94, 406, 407, 408, 409, 410, 411, 412, 413],
  [0, 24, 5, 28, 158, 265, 258, 275, 159, 277, 270, 263, 414, 415, 416, 417, 418, 419, 420, 421, 422, 423, 424, 425, 23, 16, 27, 19, 256, 273, 251, 267, 260, 269, 278, 255, 426, 427, 428, 429, 430, 431, 432, 433, 434, 435, 436, 437, 26, 22, 13, 17, 264, 250, 274, 259, 268, 261, 254, 279, 438, 439, 440, 441, 442, 443, 444, 445, 446, 447, 448, 449, 4, 20, 2, 25, 272, 257, 266, 252, 276, 253, 262, 271, 450, 451, 452, 453, 454, 455, 456, 457, 458, 459, 460, 461],
  [0, 16, 2, 17, 158, 250, 251, 252, 159, 253, 254, 255, 100, 101, 75, 74, 370, 371, 188, 372, 373, 374, 375, 189, 29, 21, 15, 30, 280, 281, 282, 283, 284, 285, 286, 287, 116, 117, 83, 82, 376, 377, 224, 378, 379, 380, 381, 225],
  [0, 20, 13, 19, 158, 273, 266, 259, 159, 261, 278, 271, 450, 415, 440, 429, 454, 431, 420, 445, 458, 447, 436, 425],
  [0, 20, 13, 19, 158, 273, 266, 259, 159, 261, 278, 271, 462, 463, 464, 465, 466, 467, 468, 469, 470, 471, 472, 473],
  [0, 20, 13, 19, 158, 273, 266, 259, 159, 261, 278, 271, 462, 463, 464, 465, 466, 467, 468, 469, 470, 471, 472, 473, 29, 31, 32, 33, 280, 288, 289, 290, 284, 291, 292, 293, 450, 415, 440, 429, 454, 431, 420, 445, 458, 447, 436, 425],
  [0, 16, 2, 17, 158, 250, 251, 252, 159, 253, 254, 255, 123, 122, 88, 89, 204, 474, 475, 476, 205, 477, 478, 479],
  [0, 16, 2, 17, 158, 250, 251, 252, 159, 253, 254, 255, 123, 122, 88, 89, 204, 474, 475, 476, 205, 477, 478, 479, 23, 24, 13, 25, 256, 257, 258, 259, 260, 261, 262, 263, 480, 481, 482, 483, 484, 485, 486, 487, 488, 489, 490, 491, 26, 20, 27, 28, 264, 265, 266, 267, 268, 269, 270, 271, 492, 493, 494, 495, 496, 497, 498, 499, 500, 501, 502, 503, 4, 22, 5, 19, 272, 273, 274, 275, 276, 277, 278, 279, 125, 124, 140, 141, 504, 505, 506, 507, 508, 509, 510, 511],
  [0, 16, 2, 17, 158, 250, 251, 252, 159, 253, 254, 255, 123, 122, 88, 89, 204, 474, 475, 476, 205, 477, 478, 479, 29, 21, 15, 30, 280, 281, 282, 283, 284, 285, 286, 287, 129, 128, 90, 91, 212, 512, 513, 514, 213, 515, 516, 517],
  [0, 16, 2, 17, 158, 250, 251, 252, 159, 253, 254, 255, 129, 128, 90, 91, 212, 512, 513, 514, 213, 515, 516, 517],
  [0, 16, 2, 17, 158, 250, 251, 252, 159, 253, 254, 255, 129, 128, 90, 91, 212, 512, 513, 514, 213, 515, 516, 517, 23, 24, 13, 25, 256, 257, 258, 259, 260, 261, 262, 263, 518, 519, 520, 521, 522, 523, 524, 525, 526, 527, 528, 529, 26, 20, 27, 28, 264, 265, 266, 267, 268, 269, 270, 271, 530, 531, 532, 533, 534, 535, 536, 537, 538, 539, 540, 541, 4, 22, 5, 19, 272, 273, 274, 275, 276, 277, 278, 279, 127, 126, 92, 93, 542, 543, 544, 545, 546, 547, 548, 549],
  [0, 20, 13, 19, 158, 273, 266, 259, 159, 261, 278, 271, 550, 551, 552, 553, 554, 555, 556, 557, 558, 559, 560, 561, 29, 31, 32, 33, 280, 288, 289, 290, 284, 291, 292, 293, 562, 563, 564, 565, 566, 567, 568, 569, 570, 571, 572, 573],
  [0, 16, 2, 17, 158, 250, 251, 252, 159, 253, 254, 255, 100, 101, 75, 74, 370, 371, 188, 372, 373, 374, 375, 189, 1, 52, 6, 34, 168, 294, 295, 296, 169, 297, 298, 299, 122, 123, 89, 88, 475, 476, 204, 474, 479, 478, 477, 205],
  [0, 16, 2, 17, 158, 250, 251, 252, 159, 253, 254, 255, 100, 101, 75, 74, 370, 371, 188, 372, 373, 374, 375, 189, 53, 54, 9, 42, 300, 301, 302, 303, 304, 305, 306, 307, 128, 129, 91, 90, 513, 514, 212, 512, 517, 516, 515, 213],
  [0, 16, 2, 17, 158, 250, 251, 252, 159, 253, 254, 255, 116, 117, 83, 82, 376, 377, 224, 378, 379, 380, 381, 225, 1, 52, 6, 34, 168, 294, 295, 296, 169, 297, 298, 299, 128, 129, 91, 90, 513, 514, 212, 512, 517, 516, 515, 213],
  [0, 16, 2, 17, 158, 250, 251, 252, 159, 253, 254, 255, 116, 117, 83, 82, 376, 377, 224, 378, 379, 380, 381, 225, 53, 54, 9, 42, 300, 301, 302, 303, 304, 305, 306, 307, 122, 123, 89, 88, 475, 476, 204, 474, 479, 478, 477, 205],
  [0, 16, 2, 17, 158, 250, 251, 252, 159, 253, 254, 255, 100, 101, 75, 74, 370, 371, 188, 372, 373, 374, 375, 189, 1, 52, 6, 34, 168, 294, 295, 296, 169, 297, 298, 299, 122, 123, 89, 88, 475, 476, 204, 474, 479, 478, 477, 205, 23, 24, 13, 25, 256, 257, 258, 259, 260, 261, 262, 263, 382, 383, 384, 385, 386, 387, 388, 389, 390, 391, 392, 393, 64, 62, 14, 39, 308, 309, 310, 311, 312, 313, 314, 315, 481, 480, 483, 482, 486, 487, 484, 485, 491, 490, 489, 488, 26, 20, 27, 28, 264, 265, 266, 267, 268, 269, 270, 271, 394, 395, 396, 397, 398, 399, 400, 401, 402, 403, 404, 405, 65, 59, 40, 38, 316, 317, 318, 319, 320, 321, 322, 323, 493, 492, 495, 494, 498, 499, 496, 497, 503, 502, 501, 500, 4, 22, 5, 19, 272, 273, 274, 275, 276, 277, 278, 279, 138, 139, 95, 94, 406, 407, 408, 409, 410, 411, 412, 413, 11, 55, 8, 41, 324, 325, 326, 327, 328, 329, 330, 331, 124, 125, 141, 140, 506, 507, 504, 505, 511, 510, 509, 508],
  [0, 16, 2, 17, 158, 250, 251, 252, 159, 253, 254, 255, 116, 117, 83, 82, 376, 377, 224, 378, 379, 380, 381, 225, 1, 52, 6, 34, 168, 294, 295, 296, 169, 297, 298, 299, 128, 129, 91, 90, 513, 514, 212, 512, 517, 516, 515, 213, 23, 24, 13, 25, 256, 257, 258, 259, 260, 261, 262, 263, 574, 575, 576, 577, 578, 579, 580, 581, 582, 583, 584, 585, 64, 62, 14, 39, 308, 309, 310, 311, 312, 313, 314, 315, 519, 518, 521, 520, 524, 525, 522, 523, 529, 528, 527, 526, 26, 20, 27, 28, 264, 265, 266, 267, 268, 269, 270, 271, 586, 587, 588, 589, 590, 591, 592, 593, 594, 595, 596, 597, 65, 59, 40, 38, 316, 317, 318, 319, 320, 321, 322, 323, 531, 530, 533, 532, 536, 537, 534, 535, 541, 540, 539, 538, 4, 22, 5, 19, 272, 273, 274, 275, 276, 277, 278, 279, 109, 108, 79, 78, 598, 599, 600, 601, 602, 603, 604, 605, 11, 55, 8, 41, 324, 325, 326, 327, 328, 329, 330, 331, 126, 127, 93, 92, 544, 545, 542, 543, 549, 548, 547, 546],
  [0, 24, 5, 28, 158, 265, 258, 275, 159, 277, 270, 263, 414, 415, 416, 417, 418, 419, 420, 421, 422, 423, 424, 425, 66, 69, 50, 49, 332, 349, 342, 359, 336, 361, 354, 347, 493, 123, 483, 140, 498, 507, 204, 485, 503, 490, 509, 205, 23, 16, 27, 19, 256, 273, 251, 267, 260, 269, 278, 255, 426, 427, 428, 429, 430, 431, 432, 433, 434, 435, 436, 437, 68, 67, 48, 51, 340, 357, 334, 351, 344, 353, 362, 339, 124, 480, 89, 494, 506, 499, 484, 474, 511, 478, 501, 488, 26, 22, 13, 17, 264, 250, 274, 259, 268, 261, 254, 279, 438, 439, 440, 441, 442, 443, 444, 445, 446, 447, 448, 449, 70, 73, 46, 45, 348, 333, 358, 343, 352, 345, 338, 363, 122, 492, 141, 482, 475, 487, 496, 505, 479, 510, 489, 500, 4, 20, 2, 25, 272, 257, 266, 252, 276, 253, 262, 271, 450, 451, 452, 453, 454, 455, 456, 457, 458, 459, 460, 461, 72, 71, 44, 47, 356, 341, 350, 335, 360, 337, 346, 355, 481, 125, 495, 88, 486, 476, 504, 497, 491, 502, 477, 508],
  [0, 24, 5, 28, 158, 265, 258, 275, 159, 277, 270, 263, 414, 415, 416, 417, 418, 419, 420, 421, 422, 423, 424, 425, 606, 607, 608, 609, 610, 611, 612, 613, 614, 615, 616, 617, 531, 129, 521, 92, 536, 545, 212, 523, 541, 528, 547, 213, 23, 16, 27, 19, 256, 273, 251, 267, 260, 269, 278, 255, 426, 427, 428, 429, 430, 431, 432, 433, 434, 435, 436, 437, 618, 619, 620, 621, 622, 623, 624, 625, 626, 627, 628, 629, 126, 518, 91, 532, 544, 537, 522, 512, 549, 516, 539, 526, 26, 22, 13, 17, 264, 250, 274, 259, 268, 261, 254, 279, 438, 439, 440, 441, 442, 443, 444, 445, 446, 447, 448, 449, 630, 631, 632, 633, 634, 635, 636, 637, 638, 639, 640, 641, 128, 530, 93, 520, 513, 525, 534, 543, 517, 548, 527, 538, 4, 20, 2, 25, 272, 257, 266, 252, 276, 253, 262, 271, 450, 451, 452, 453, 454, 455, 456, 457, 458, 459, 460, 461, 642, 643, 644, 645, 646, 647, 648, 649, 650, 651, 652, 653, 519, 127, 533, 90, 524, 514, 542, 535, 529, 540, 515, 546],
  [0, 16, 2, 17, 158, 250, 251, 252, 159, 253, 254, 255, 100, 101, 75, 74, 370, 371, 188, 372, 373, 374, 375, 189, 1, 52, 6, 34, 168, 294, 295, 296, 169, 297, 298, 299, 122, 123, 89, 88, 475, 476, 204, 474, 479, 478, 477, 205, 29, 21, 15, 30, 280, 281, 282, 283, 284, 285, 286, 287, 116, 117, 83, 82, 376, 377, 224, 378, 379, 380, 381, 225, 53, 54, 9, 42, 300, 301, 302, 303, 304, 305, 306, 307, 128, 129, 91, 90, 513, 514, 212, 512, 517, 516, 515, 213],
  [0, 20, 13, 19, 158, 273, 266, 259, 159, 261, 278, 271, 462, 463, 464, 465, 466, 467, 468, 469, 470, 471, 472, 473, 1, 59, 14, 41, 168, 325, 318, 311, 169, 313, 330, 323, 551, 550, 553, 552, 556, 557, 554, 555, 561, 560, 559, 558, 29, 31, 32, 33, 280, 288, 289, 290, 284, 291, 292, 293, 450, 415, 440, 429, 454, 431, 420, 445, 458, 447, 436, 425, 53, 63, 36, 35, 300, 364, 365, 366, 304, 367, 368, 369, 563, 562, 565, 564, 568, 569, 566, 567, 573, 572, 571, 570],
  [0, 16],
  [0, 18],
  [0, 16, 26, 20],
  [0, 2, 23, 13],
  [0, 3, 4, 32],
  [0, 2, 29, 15],
  [0, 3, 29, 27],
  [0, 52],
  [0, 63],
  [0, 52, 26, 59],
  [0, 63, 26, 54],
  [0, 52, 16, 1],
  [0, 18, 1, 61],
  [0, 52, 16, 1, 26, 59, 20, 65],
  [0, 31, 1, 63],
  [0, 1, 24, 62],
  [0, 15, 1, 9],
  [0, 5, 1, 8],
  [0, 31, 1, 63, 26, 21, 65, 54],
  [0, 2, 57, 56],
  [0, 60, 3, 16],
  [0, 22, 57, 3],
  [0, 2, 28, 20],
  [0, 17, 13, 24],
  [0, 20, 19, 13, 4, 24, 17, 27],
  [0, 22, 57, 3, 4, 16, 60, 32],
  [0, 22, 57, 3, 23, 20, 30, 12, 26, 24, 33, 15, 4, 16, 60, 32],
  [0, 22, 57, 3, 29, 18, 27, 25],
  [0, 22, 3, 57, 1, 55, 10, 37],
  [0, 22, 385, 396, 3, 57, 109, 117],
  [0, 22, 57, 3, 159, 279, 654, 655, 158, 274, 656, 657, 29, 18, 25, 27, 284, 658, 262, 269, 280, 659, 257, 267]
], v_ = {
  "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 _t0(Z) {
  switch (Z) {
    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;
  }
  let J = 0;
  if (Z > 146)
    ++J;
  if (Z > 148)
    ++J;
  if (Z > 155)
    ++J;
  if (Z > 160)
    ++J;
  if (Z > 161)
    ++J;
  if (Z > 166)
    ++J;
  if (Z > 167)
    ++J;
  return Z - 1 + J;
}
function Vt0(Z) {
  if (Z < 146)
    return Z + 1;
  if (Z === 146)
    return 1146;
  if (Z < 149)
    return Z + 1 - 1;
  if (Z === 149)
    return 1148;
  if (Z < 157)
    return Z + 1 - 2;
  if (Z === 157)
    return 1155;
  if (Z < 163)
    return Z + 1 - 3;
  if (Z === 163)
    return 1160;
  if (Z < 165)
    return Z + 1 - 4;
  if (Z === 165)
    return 1161;
  if (Z < 171)
    return Z + 1 - 5;
  if (Z === 171)
    return 1166;
  if (Z < 173)
    return Z + 1 - 6;
  if (Z === 173)
    return 1167;
  if (Z < 237)
    return Z + 1 - 7;
  if (Z === 237)
    return 1003;
  if (Z === 238)
    return 1004;
  if (Z === 239)
    return 1005;
  if (Z === 240)
    return 2005;
  if (Z === 241)
    return 3005;
  if (Z === 242)
    return 4005;
  if (Z === 243)
    return 5005;
  if (Z === 244)
    return 1006;
  if (Z === 245)
    return 1007;
  if (Z === 246)
    return 1008;
  if (Z === 247)
    return 1009;
  if (Z === 248)
    return 1010;
  if (Z === 249)
    return 1011;
  if (Z === 250)
    return 1012;
  if (Z === 251)
    return 1013;
  if (Z === 252)
    return 1014;
  if (Z === 253)
    return 2014;
  if (Z === 254)
    return 3014;
  if (Z === 255)
    return 1015;
  if (Z === 256)
    return 1017;
  if (Z === 257)
    return 2017;
  if (Z === 258)
    return 1018;
  if (Z === 259)
    return 2018;
  if (Z === 260)
    return 3018;
  if (Z === 261)
    return 1020;
  if (Z === 262)
    return 1021;
  if (Z === 263)
    return 1022;
  if (Z === 264)
    return 1023;
  if (Z === 265)
    return 1059;
  if (Z === 266)
    return 1094;
  if (Z === 267)
    return 1197;
  throw new Error(`unknown spacegroup index '${Z}'`);
}
var Ho = function() {
  let Z = Object.create(null);
  for (let J of Object.keys(v_))
    Z[v_[J]] = J;
  return Z;
}(), lG0 = function() {
  let Z = Object.create(null);
  for (let J of Object.keys(v_)) {
    let $ = v_[J];
    Z[$] = Vt0($);
  }
  return Z;
}();
function nG0(Z) {
  let J = typeof Z === "number" ? _t0(Z) : v_[Z];
  if (typeof J === "undefined" || typeof Ho[J] === "undefined")
    return -1;
  return J;
}

// node_modules/molstar/lib/mol-math/geometry/spacegroup/construction.js
var d7;
(function(Z) {
  Z.Zero = $("P 1", M.create(1, 1, 1), M.create(Math.PI / 2, Math.PI / 2, Math.PI / 2));
  function J(X) {
    if (!X)
      return !0;
    return X.index === 0 && X.size[0] === 1 && X.size[1] === 1 && X.size[1] === 1;
  }
  Z.isZero = J;
  function $(X, Y, Q) {
    let W = nG0(X);
    if (W < 0)
      return console.warn(`Unknown spacegroup '${X}', returning a 'P 1' with cellsize [1, 1, 1]`), Z.Zero;
    let K = Y[0] * Y[1] * Y[2], G = Q[0], H = Q[1], N = Q[2], q = Y[0], U = Y[1], F = Y[2], E = Math.cos(H), R = (Math.cos(G) - Math.cos(H) * Math.cos(N)) / Math.sin(N), z = Math.sqrt(1 - E * E - R * R), D = [q, 0, 0], A = [Math.cos(N) * U, Math.sin(N) * U, 0], B = [E * F, R * F, z * F], T = e.ofRows([
      [D[0], A[0], B[0], 0],
      [0, A[1], B[1], 0],
      [0, 0, B[2], 0],
      [0, 0, 0, 1]
    ]), w = e.invert(e.zero(), T);
    return { index: W, size: Y, volume: K, anglesInRadians: Q, toFractional: w, fromFractional: T };
  }
  Z.create = $;
})(d7 || (d7 = {}));
var f$;
(function(Z) {
  Z.ZeroP1 = J(d7.Zero);
  function J(z) {
    let D = cG0[z.index].map((T) => q(uG0[T])), A = Ho[z.index], B = lG0[z.index];
    return { name: A, num: B, cell: z, operators: D };
  }
  Z.create = J;
  let $ = M(), X = e();
  function Y(z, D, A, B, T, w) {
    return M.set($, A, B, T), e.fromTranslation(X, $), e.mul(w, e.mul(w, e.mul(w, z.cell.fromFractional, X), z.operators[D]), z.cell.toFractional);
  }
  Z.setOperatorMatrix = Y;
  function Q(z, D, A, B, T) {
    let w = Y(z, D, A, B, T, e.zero());
    return RZ.create(RZ.getSymmetryOperatorName(D, A, B, T), w, { hkl: M.create(A, B, T), spgrOp: D });
  }
  Z.getSymmetryOperator = Q;
  let W = M(), K = M(), G = M(), H = M();
  function N(z, D, A, B, T, w) {
    let V = e.zero();
    M.set($, A, B, T), M.floor(W, w), e.copy(V, z.operators[D]), M.floor(K, M.transformMat4(K, w, V)), e.getTranslation(H, V), M.sub(H, H, K), M.add(H, H, W), M.add(H, H, $), e.setTranslation(V, H), e.mul(V, z.cell.fromFractional, V), e.mul(V, V, z.cell.toFractional), M.sub(G, K, W);
    let P = A - G[0], I = B - G[1], S = T - G[2];
    return RZ.create(RZ.getSymmetryOperatorName(D, P, I, S), V, { hkl: M.create(P, I, S), spgrOp: D });
  }
  Z.getSymmetryOperatorRef = N;
  function q(z) {
    let D = Bf[z[0]], A = Bf[z[1]], B = Bf[z[2]];
    return e.ofRows([D, A, B, [0, 0, 0, 1]]);
  }
  function U(z) {
    return [
      R(F(z[0], z[4], z[8]), E(z[12])),
      R(F(z[1], z[5], z[9]), E(z[13])),
      R(F(z[2], z[6], z[10]), E(z[14]))
    ].join(",");
  }
  Z.getOperatorXyz = U;
  function F(z, D, A) {
    let B = [];
    if (z > 0)
      B.push("+X");
    else if (z < 0)
      B.push("-X");
    if (D > 0)
      B.push("+Y");
    else if (D < 0)
      B.push("-Y");
    if (A > 0)
      B.push("+Z");
    else if (A < 0)
      B.push("-Z");
    if (B.length === 1)
      return B[0].charAt(0) === "+" ? B[0].substr(1) : B[0];
    if (B.length === 2) {
      let T = B[0].charAt(0), w = B[1].charAt(0);
      if (T === "+")
        return `${B[0].substr(1)}${B[1]}`;
      if (w === "+")
        return `${B[1].substr(1)}${B[0]}`;
    }
    throw new Error(`unknown rotation '${B}', ${z} ${D} ${A}`);
  }
  function E(z) {
    switch (z) {
      case 0.5:
        return "1/2";
      case 0.25:
        return "1/4";
      case 0.75:
        return "3/4";
      case 0.3333333333333333:
        return "1/3";
      case 0.6666666666666666:
        return "2/3";
      case 0.16666666666666666:
        return "1/6";
      case 0.8333333333333334:
        return "5/6";
    }
    return "";
  }
  function R(z, D) {
    if (D === "")
      return z;
    if (z.length > 2)
      return `${z}+${D}`;
    return z.charAt(0) === "-" ? `${D}${z}` : `${D}+${z}`;
  }
})(f$ || (f$ = {}));
// node_modules/molstar/lib/mol-math/geometry/lookup3d/common.js
var KQ;
(function(Z) {
  function J(Q, W, K) {
    Q.squaredDistances[Q.count] = K, Q.indices[Q.count++] = W;
  }
  Z.add = J;
  function $(Q) {
    Q.count = 0;
  }
  Z.reset = $;
  function X() {
    return { count: 0, indices: [], squaredDistances: [] };
  }
  Z.create = X;
  function Y(Q, W) {
    for (let K = 0;K < W.count; ++K)
      Q.indices[K] = W.indices[K], Q.squaredDistances[K] = W.squaredDistances[K];
    return Q.count = W.count, Q;
  }
  Z.copy = Y;
})(KQ || (KQ = {}));
// node_modules/molstar/lib/mol-data/int/impl/segmentation.js
function No(Z) {
  let J = X1.ofSortedArray(Z), $ = X1.max(J), X = new Int32Array($);
  for (let Y = 0, Q = Z.length - 1;Y < Q; Y++)
    for (let W = Z[Y], K = Z[Y + 1];W < K; W++)
      X[W] = Y;
  return { offsets: J, index: X, count: Z.length - 1 };
}
function iG0(Z, J) {
  let $ = k0.start(J), X = new Int32Array(Z.length + 1);
  for (let Y = 0, Q = Z.length;Y < Q; Y++)
    X[Y] = Z[Y] - $;
  return X[Z.length] = k0.end(J) - $, No(X);
}
function oG0({ count: Z }) {
  return Z;
}
function sG0({ index: Z }, J) {
  return Z[J];
}
function aG0({ offsets: Z }, J, $) {
  let X = f0.max(Z), Y = $ >= X ? -1 : f0.findPredecessorIndex(Z, $ - 1);
  return f0.findRange(J, f0.getAt(Z, Y), f0.getAt(Z, Y + 1) - 1);
}

class rG0 {
  move() {
    while (this.hasNext)
      if (this.updateValue()) {
        this.value.index = this.segmentMin++, this.hasNext = this.segmentMax >= this.segmentMin && k0.size(this.setRange) > 0;
        break;
      } else
        this.updateSegmentRange();
    return this.value;
  }
  updateValue() {
    let Z = this.segments[this.segmentMin + 1], J = f0.findPredecessorIndexInInterval(this.set, Z, this.setRange);
    return this.value.start = k0.start(this.setRange), this.value.end = J, this.setRange = k0.ofBounds(J, k0.end(this.setRange)), J > this.value.start;
  }
  updateSegmentRange() {
    let Z = k0.min(this.setRange), J = k0.max(this.setRange);
    if (J < Z) {
      this.hasNext = !1;
      return;
    }
    this.segmentMin = this.segmentMap[f0.getAt(this.set, Z)], this.segmentMax = this.segmentMap[f0.getAt(this.set, J)], this.hasNext = this.segmentMax >= this.segmentMin;
  }
  setSegment(Z) {
    this.setRange = k0.ofBounds(Z.start, Z.end), this.updateSegmentRange();
  }
  constructor(Z, J, $, X) {
    this.segments = Z, this.segmentMap = J, this.set = $, this.segmentMin = 0, this.segmentMax = 0, this.setRange = k0.Empty, this.value = { index: 0, start: 0, end: 0 }, this.hasNext = !1, this.setRange = X, this.updateSegmentRange();
  }
}
function tG0(Z, J, $) {
  let X = typeof $ !== "undefined" ? k0.ofBounds($.start, $.end) : k0.ofBounds(0, f0.size(J));
  return new rG0(Z.offsets, Z.index, J, X);
}

// node_modules/molstar/lib/mol-data/int/segmentation.js
var b2;
(function(Z) {
  Z.create = No, Z.ofOffsets = iG0, Z.count = oG0, Z.getSegment = sG0, Z.projectValue = aG0, Z.transientSegments = tG0;
})(b2 || (b2 = {}));

// node_modules/molstar/lib/mol-data/int/linked-index.js
function qo(Z) {
  return new eG0(Z);
}

class eG0 {
  remove(Z) {
    let { prev: J, next: $ } = this, X = J[Z], Y = $[Z];
    if (X >= 0)
      $[X] = Y, J[Z] = -1;
    if (Y >= 0)
      J[Y] = X, $[Z] = -1;
    if (Z === this.head)
      if (X < 0)
        this.head = Y;
      else
        this.head = X;
  }
  has(Z) {
    return this.prev[Z] >= 0 || this.next[Z] >= 0 || this.head === Z;
  }
  constructor(Z) {
    this.head = Z > 0 ? 0 : -1, this.prev = new Int32Array(Z), this.next = new Int32Array(Z);
    for (let J = 0;J < Z; J++)
      this.next[J] = J + 1, this.prev[J] = J - 1;
    this.prev[0] = -1, this.next[Z - 1] = -1;
  }
}

// node_modules/molstar/lib/mol-data/int/map.js
var NY;
(function(Z) {
  Z.Empty = /* @__PURE__ */ new Map;
  function J(W) {
    return IM(W.keys());
  }
  Z.keyArray = J;
  function $() {
    return /* @__PURE__ */ new Map;
  }
  Z.Mutable = $;
  function X(W) {
    return W;
  }
  Z.asImmutable = X;
  function Y(W) {
    let K = $(), G = W.keys();
    while (!0) {
      let { done: H, value: N } = G.next();
      if (H)
        break;
      K.set(N, W.get(N));
    }
    return K;
  }
  Z.copy = Y;
  function Q(W, K) {
    let G = K.keys();
    while (!0) {
      let { done: H, value: N } = G.next();
      if (H)
        break;
      W.set(N, K.get(N));
    }
    return W;
  }
  Z.addFrom = Q;
})(NY || (NY = {}));

// node_modules/molstar/lib/mol-data/iterator.js
class ZH0 {
  move() {
    return ++this.index, this.lastValue = this.xs[this.index], this.hasNext = this.index < this.length - 1, this.lastValue;
  }
  constructor(Z) {
    this.xs = [], this.index = -1, this.length = 0, this.hasNext = !1, this.length = Z.length, this.hasNext = Z.length > 0, this.xs = Z, this.index = -1, this.lastValue = Z.length > 0 ? Z[0] : void 0;
  }
}

class Fo {
  move() {
    return ++this.value, this.hasNext = this.value < this.max, this.value;
  }
  constructor(Z, J) {
    this.max = J, this.value = 0, this.hasNext = !1, this.value = Z - 1, this.hasNext = J >= Z;
  }
}

class JH0 {
  move() {
    return this.hasNext = !1, this.value;
  }
  constructor(Z) {
    this.value = Z, this.hasNext = !0;
  }
}

class $H0 {
  move() {
    let Z = this.f(this.base.move());
    return this.hasNext = this.base.hasNext, Z;
  }
  constructor(Z, J) {
    this.base = Z, this.f = J, this.hasNext = !1, this.hasNext = Z.hasNext;
  }
}

class XH0 {
  move() {
    let Z = this.next;
    return this.hasNext = this.findNext(), Z;
  }
  findNext() {
    while (this.base.hasNext)
      if (this.next = this.base.move(), this.p(this.next))
        return !0;
    return !1;
  }
  constructor(Z, J) {
    this.base = Z, this.p = J, this.hasNext = this.findNext();
  }
}
var LR;
(function(Z) {
  Z.Empty = new Fo(0, -1);
  function J(K) {
    return new ZH0(K);
  }
  Z.Array = J;
  function $(K) {
    return new JH0(K);
  }
  Z.Value = $;
  function X(K, G) {
    return new Fo(K, G);
  }
  Z.Range = X;
  function Y(K, G) {
    return new $H0(K, G);
  }
  Z.map = Y;
  function Q(K, G) {
    return new XH0(K, G);
  }
  Z.filter = Q;
  function W(K, G, H) {
    while (K.hasNext)
      if (G(K.move(), H))
        return H;
    return H;
  }
  Z.forEach = W;
})(LR || (LR = {}));

// node_modules/molstar/lib/mol-util/fibonacci-heap.js
class YH0 {
  constructor(Z, J) {
    this.parent = null, this.child = null, this.degree = 0, this.isMarked = !1, this.key = Z, this.value = J, this.prev = this, this.next = this;
  }
}

class QH0 {
  constructor(Z) {
    if (this._index = -1, this._items = [], this._len = 0, Z) {
      let J = Z, $ = 0;
      do
        this._items[$++] = J, J = J.next;
      while (Z !== J);
      this._len = $;
    }
  }
  hasNext() {
    return this._index < this._len - 1;
  }
  next() {
    return this._items[++this._index];
  }
  reset(Z) {
    this._index = -1, this._len = 0;
    let J = Z, $ = 0;
    do
      this._items[$++] = J, J = J.next;
    while (Z !== J);
    this._len = $;
  }
}
var Uo = new QH0;

class S_ {
  constructor(Z) {
    this._minNode = null, this._nodeCount = 0, this._compare = Z ? Z : this._defaultCompare;
  }
  clear() {
    this._minNode = null, this._nodeCount = 0;
  }
  decreaseKey(Z, J) {
    if (!Z)
      throw new Error("Cannot decrease key of non-existent node");
    if (this._compare({ key: J }, { key: Z.key }) > 0)
      throw new Error("New key is larger than old key");
    Z.key = J;
    let $ = Z.parent;
    if ($ && this._compare(Z, $) < 0)
      this._cut(Z, $, this._minNode), this._cascadingCut($, this._minNode);
    if (this._compare(Z, this._minNode) < 0)
      this._minNode = Z;
  }
  delete(Z) {
    let J = Z.parent;
    if (J)
      this._cut(Z, J, this._minNode), this._cascadingCut(J, this._minNode);
    this._minNode = Z, this.extractMinimum();
  }
  extractMinimum() {
    let Z = this._minNode;
    if (Z) {
      if (Z.child) {
        let $ = Z.child;
        do
          $.parent = null, $ = $.next;
        while ($ !== Z.child);
      }
      let J = null;
      if (Z.next !== Z)
        J = Z.next;
      if (this._removeNodeFromList(Z), this._nodeCount--, this._minNode = this._mergeLists(J, Z.child), this._minNode)
        this._minNode = this._consolidate(this._minNode);
    }
    return Z;
  }
  findMinimum() {
    return this._minNode;
  }
  insert(Z, J) {
    let $ = new YH0(Z, J);
    return this._minNode = this._mergeLists(this._minNode, $), this._nodeCount++, $;
  }
  isEmpty() {
    return this._minNode === null;
  }
  size() {
    if (this._minNode === null)
      return 0;
    return this._getNodeListSize(this._minNode);
  }
  union(Z) {
    this._minNode = this._mergeLists(this._minNode, Z._minNode), this._nodeCount += Z._nodeCount;
  }
  _defaultCompare(Z, J) {
    if (Z.key > J.key)
      return 1;
    if (Z.key < J.key)
      return -1;
    return 0;
  }
  _cut(Z, J, $) {
    if (Z.parent = null, J.degree--, Z.next === Z)
      J.child = null;
    else
      J.child = Z.next;
    this._removeNodeFromList(Z);
    let X = this._mergeLists($, Z);
    return Z.isMarked = !1, X;
  }
  _cascadingCut(Z, J) {
    let $ = Z.parent;
    if ($)
      if (Z.isMarked)
        J = this._cut(Z, $, J), J = this._cascadingCut($, J);
      else
        Z.isMarked = !0;
    return J;
  }
  _consolidate(Z) {
    let J = [];
    Uo.reset(Z);
    while (Uo.hasNext()) {
      let X = Uo.next(), Y = J[X.degree];
      while (Y) {
        if (this._compare(X, Y) > 0) {
          let Q = X;
          X = Y, Y = Q;
        }
        this._linkHeaps(Y, X), J[X.degree] = null, X.degree++, Y = J[X.degree];
      }
      J[X.degree] = X;
    }
    let $ = null;
    for (let X = 0;X < J.length; X++) {
      let Y = J[X];
      if (Y)
        Y.next = Y, Y.prev = Y, $ = this._mergeLists($, Y);
    }
    return $;
  }
  _removeNodeFromList(Z) {
    let { prev: J, next: $ } = Z;
    J.next = $, $.prev = J, Z.next = Z, Z.prev = Z;
  }
  _linkHeaps(Z, J) {
    this._removeNodeFromList(Z), J.child = this._mergeLists(Z, J.child), Z.parent = J, Z.isMarked = !1;
  }
  _mergeLists(Z, J) {
    if (!Z) {
      if (!J)
        return null;
      return J;
    }
    if (!J)
      return Z;
    let $ = Z.next;
    return Z.next = J.next, Z.next.prev = Z, J.next = $, J.next.prev = J, this._compare(Z, J) < 0 ? Z : J;
  }
  _getNodeListSize(Z) {
    let J = 0, $ = Z;
    do {
      if (J++, $.child)
        J += this._getNodeListSize($.child);
      $ = $.next;
    } while ($ !== Z);
    return J;
  }
}

// node_modules/molstar/lib/mol-util/memoize.js
function cJ(Z) {
  let J = void 0, $ = void 0;
  return (...X) => {
    if (!J || J.length !== X.length)
      return J = X, $ = Z.apply(void 0, X), $;
    for (let Y = 0, Q = X.length;Y < Q; Y++)
      if (X[Y] !== J[Y])
        return J = X, $ = Z.apply(void 0, X), $;
    return $;
  };
}
function QH(Z) {
  let J = /* @__PURE__ */ new Map;
  return ($) => {
    if (J.has($))
      return J.get($);
    let X = Z($);
    return J.set($, X), X;
  };
}

// node_modules/molstar/lib/mol-math/geometry/primitives/ray3d.js
function GQ() {
  return GQ.create(M.create(0, 0, 0), M.create(1, 0, 0));
}
(function(Z) {
  function J(E, R) {
    return { origin: E, direction: R };
  }
  Z.create = J;
  function $(E, R) {
    return M.copy(E.origin, R.origin), M.copy(E.direction, R.direction), E;
  }
  Z.copy = $;
  function X(E) {
    return $(Z(), E);
  }
  Z.clone = X;
  function Y(E, R, z) {
    return M.copy(E.origin, R.origin), M.normalize(E.direction, M.sub(E.direction, z, R.origin)), E;
  }
  Z.targetTo = Y;
  function Q(E, R, z) {
    return M.transformMat4(E.origin, R.origin, z), M.transformDirection(E.direction, R.direction, z), E;
  }
  Z.transform = Q;
  let W = M();
  function K(E, R) {
    let { center: z, radius: D } = R, { origin: A, direction: B } = E, T = M.sub(W, A, z), w = M.dot(B, B), V = 2 * M.dot(T, B), P = M.dot(T, T) - D * D, I = V * V - 4 * w * P;
    if (I < 0)
      return -1;
    let S = (-V - Math.sqrt(I)) / (2 * w);
    if (S < 0)
      return -1;
    return S;
  }
  function G(E, R, z) {
    let D = K(R, z);
    if (D < 0)
      return !1;
    return M.scaleAndAdd(E, R.origin, R.direction, D), !0;
  }
  Z.intersectSphere3D = G;
  function H(E, R) {
    return K(E, R) >= 0;
  }
  Z.isIntersectingSphere3D = H;
  function N(E, R) {
    return M.distance(E.origin, R.center) < R.radius;
  }
  Z.isInsideSphere3D = N;
  function q(E, R) {
    let { origin: z, direction: D } = E, [A, B, T] = R.min, [w, V, P] = R.max, [I, S, f] = z, v = 1 / D[0], h = 1 / D[1], x = 1 / D[2], b, g, m, i, r, Y0;
    if (v >= 0)
      b = (A - I) * v, g = (w - I) * v;
    else
      b = (w - I) * v, g = (A - I) * v;
    if (h >= 0)
      m = (B - S) * h, i = (V - S) * h;
    else
      m = (V - S) * h, i = (B - S) * h;
    if (b > i || m > g)
      return -1;
    if (m > b)
      b = m;
    if (i < g)
      g = i;
    if (x >= 0)
      r = (T - f) * x, Y0 = (P - f) * x;
    else
      r = (P - f) * x, Y0 = (T - f) * x;
    if (b > Y0 || r > g)
      return -1;
    if (r > b)
      b = r;
    if (Y0 < g)
      g = Y0;
    return b >= 0 ? b : -1;
  }
  function U(E, R, z) {
    let D = q(R, z);
    if (D < 0)
      return !1;
    return M.scaleAndAdd(E, R.origin, R.direction, D), !0;
  }
  Z.intersectBox3D = U;
  function F(E, R) {
    return q(E, R) >= 0;
  }
  Z.isIntersectingBox3D = F;
})(GQ || (GQ = {}));

// node_modules/molstar/lib/mol-math/geometry/lookup3d/grid.js
function TW(Z, J, $) {
  return new GH0(Z, J, $);
}
class GH0 {
  find(Z, J, $, X, Y) {
    this.ctx.x = Z, this.ctx.y = J, this.ctx.z = $, this.ctx.radius = X, this.ctx.isCheck = !1;
    let Q = Y !== null && Y !== void 0 ? Y : this.result;
    return KH0(this.ctx, Q), Q;
  }
  nearest(Z, J, $, X = 1, Y, Q) {
    this.ctx.x = Z, this.ctx.y = J, this.ctx.z = $, this.ctx.k = X, this.ctx.stopIf = Y;
    let W = Q !== null && Q !== void 0 ? Q : this.result;
    return gt0(this.ctx, W), W;
  }
  check(Z, J, $, X) {
    return this.ctx.x = Z, this.ctx.y = J, this.ctx.z = $, this.ctx.radius = X, this.ctx.isCheck = !0, KH0(this.ctx, this.result);
  }
  approxNearest(Z, J, $, X, Y) {
    this.ctx.x = Z, this.ctx.y = J, this.ctx.z = $, this.ctx.radius = X, this.ctx.isCheck = !1;
    let Q = Y !== null && Y !== void 0 ? Y : this.result;
    return ht0(this.ctx, Q), Q;
  }
  constructor(Z, J, $) {
    let X = kt0(Z, J, $);
    this.ctx = vt0(X), this.boundary = { box: X.boundingBox, sphere: X.boundingSphere }, this.buckets = { offset: X.bucketOffset, count: X.bucketCounts, array: X.bucketArray }, this.result = KQ.create();
  }
}
function Ct0(Z) {
  let { expandedBox: J, size: [$, X, Y], data: { x: Q, y: W, z: K, radius: G, indices: H }, elementCount: N, delta: q } = Z, U = $ * X * Y, { min: [F, E, R] } = J, z = 0, D = 0, A = new Uint32Array(U), B = new Int32Array(N);
  for (let I = 0;I < N; I++) {
    let S = f0.getAt(H, I), f = Math.floor((Q[S] - F) / q[0]), v = Math.floor((W[S] - E) / q[1]), h = Math.floor((K[S] - R) / q[2]), x = (f * X + v) * Y + h;
    if ((A[x] += 1) === 1)
      D += 1;
    B[I] = x;
  }
  if (G)
    for (let I = 0;I < N; I++) {
      let S = f0.getAt(H, I);
      if (G[S] > z)
        z = G[S];
    }
  let T = new Int32Array(D);
  for (let I = 0, S = 0;I < U; I++) {
    let f = A[I];
    if (f > 0)
      A[I] = S + 1, T[S] = f, S += 1;
  }
  let w = new Uint32Array(D);
  for (let I = 1;I < D; ++I)
    w[I] += w[I - 1] + T[I - 1];
  let V = new Int32Array(D), P = new Int32Array(N);
  for (let I = 0;I < N; I++) {
    let S = A[B[I]];
    if (S > 0) {
      let f = S - 1;
      P[w[f] + V[f]] = I, V[f] += 1;
    }
  }
  return {
    size: Z.size,
    bucketArray: P,
    bucketCounts: T,
    bucketOffset: w,
    grid: A,
    delta: q,
    min: Z.expandedBox.min,
    data: Z.data,
    maxRadius: z,
    expandedBox: Z.expandedBox,
    boundingBox: Z.boundingBox,
    boundingSphere: Z.boundingSphere
  };
}
var WH0 = 16777216;
function kt0(Z, J, $) {
  let X = t1.expand(t1(), J.box, M.create(0.5, 0.5, 0.5)), { indices: Y } = Z, Q = t1.size(M(), X), W, K, G = f0.size(Y), H = typeof $ === "number" ? $ : 32, N = Array.isArray($) && $;
  if (N && !M.isZero(N))
    K = [Math.ceil(Q[0] / N[0]), Math.ceil(Q[1] / N[1]), Math.ceil(Q[2] / N[2])], W = N;
  else if (G > 0) {
    let E = Math.ceil(G / H), R = Math.pow(E / (Q[0] * Q[1] * Q[2]), 0.3333333333333333);
    K = [Math.ceil(Q[0] * R), Math.ceil(Q[1] * R), Math.ceil(Q[2] * R)], W = [Q[0] / K[0], Q[1] / K[1], Q[2] / K[2]];
  } else
    W = Q, K = [1, 1, 1];
  let q = K[0] * K[1] * K[2];
  if (q > WH0) {
    let E = Math.cbrt(q / WH0);
    K = [Math.ceil(K[0] / E), Math.ceil(K[1] / E), Math.ceil(K[2] / E)], W = [Q[0] / K[0], Q[1] / K[1], Q[2] / K[2]];
  }
  let U = {
    x: Z.x,
    y: Z.y,
    z: Z.z,
    indices: Y,
    radius: Z.radius
  }, F = {
    size: K,
    data: U,
    expandedBox: X,
    boundingBox: J.box,
    boundingSphere: J.sphere,
    elementCount: G,
    delta: W
  };
  return Ct0(F);
}
function vt0(Z) {
  return { grid: Z, x: 0.1, y: 0.1, z: 0.1, k: 1, stopIf: void 0, radius: 0.1, isCheck: !1 };
}
function KH0(Z, J) {
  let { min: $, size: [X, Y, Q], bucketOffset: W, bucketCounts: K, bucketArray: G, grid: H, data: { x: N, y: q, z: U, indices: F, radius: E }, delta: R, maxRadius: z } = Z.grid, { radius: D, isCheck: A, x: B, y: T, z: w } = Z, V = D + z, P = V * V;
  KQ.reset(J);
  let I = Math.max(0, Math.floor((B - V - $[0]) / R[0])), S = Math.max(0, Math.floor((T - V - $[1]) / R[1])), f = Math.max(0, Math.floor((w - V - $[2]) / R[2])), v = Math.min(X - 1, Math.floor((B + V - $[0]) / R[0])), h = Math.min(Y - 1, Math.floor((T + V - $[1]) / R[1])), x = Math.min(Q - 1, Math.floor((w + V - $[2]) / R[2]));
  if (I > v || S > h || f > x)
    return !1;
  for (let b = I;b <= v; b++)
    for (let g = S;g <= h; g++)
      for (let m = f;m <= x; m++) {
        let i = H[(b * Y + g) * Q + m];
        if (i === 0)
          continue;
        let r = i - 1, Y0 = W[r], c = K[r], n = Y0 + c;
        for (let l = Y0;l < n; l++) {
          let u = f0.getAt(F, G[l]), G0 = N[u] - B, F0 = q[u] - T, t = U[u] - w, Z0 = G0 * G0 + F0 * F0 + t * t;
          if (Z0 <= P) {
            if (z > 0 && Math.sqrt(Z0) - E[u] > D)
              continue;
            if (A)
              return !0;
            KQ.add(J, G[l], Z0);
          }
        }
      }
  return J.count > 0;
}
function St0(Z) {
  let J = [], $ = Z * 2 + 1;
  for (let X = 0;X < $; ++X)
    for (let Y = 0;Y < $; ++Y)
      for (let Q = 0;Q < $; ++Q)
        J.push(M.create(X - Z, Y - Z, Q - Z));
  return J.sort((X, Y) => M.squaredMagnitude(X) - M.squaredMagnitude(Y)), J.flat();
}
var ft0 = QH(St0);
function ht0(Z, J) {
  let { min: $, size: [X, Y, Q], bucketOffset: W, bucketCounts: K, bucketArray: G, grid: H, data: { x: N, y: q, z: U, indices: F }, delta: E } = Z.grid, { radius: R, x: z, y: D, z: A } = Z, B = R * R;
  KQ.reset(J);
  let T = Math.max(0, Math.floor((z - R - $[0]) / E[0])), w = Math.max(0, Math.floor((D - R - $[1]) / E[1])), V = Math.max(0, Math.floor((A - R - $[2]) / E[2])), P = Math.min(X - 1, Math.floor((z + R - $[0]) / E[0])), I = Math.min(Y - 1, Math.floor((D + R - $[1]) / E[1])), S = Math.min(Q - 1, Math.floor((A + R - $[2]) / E[2]));
  if (T > P || w > I || V > S)
    return !1;
  let f = Math.floor((z - $[0]) / E[0]), v = Math.floor((D - $[1]) / E[1]), h = Math.floor((A - $[2]) / E[2]), x = ft0(Math.max(P - T, I - w, S - V) + 1);
  for (let b = 0, g = x.length;b < g; b += 3) {
    let m = f + x[b], i = v + x[b + 1], r = h + x[b + 2];
    if (m < T || m > P || i < w || i > I || r < V || r > S)
      continue;
    let Y0 = H[(m * Y + i) * Q + r];
    if (Y0 === 0)
      continue;
    let c = Y0 - 1, n = W[c], l = K[c], u = n + l, G0 = Number.MAX_VALUE;
    for (let F0 = n;F0 < u; F0++) {
      let t = f0.getAt(F, G[F0]), Z0 = N[t] - z, U0 = q[t] - D, a = U[t] - A, Q0 = Z0 * Z0 + U0 * U0 + a * a;
      if (Q0 <= B && Q0 < G0)
        KQ.add(J, G[F0], Q0), G0 = Q0;
    }
    if (G0 !== Number.MAX_VALUE)
      return !0;
  }
  return J.count > 0;
}
var gF = GQ(), f_ = /* @__PURE__ */ new Set, Lo = /* @__PURE__ */ new Set, bt0 = [0.1], xt0 = [0.1], yt0 = [0.1], xM = new S_;
function gt0(Z, J) {
  let { min: $, expandedBox: X, boundingSphere: { center: Y }, size: [Q, W, K], bucketOffset: G, bucketCounts: H, bucketArray: N, grid: q, data: { x: U, y: F, z: E, indices: R, radius: z }, delta: D, maxRadius: A } = Z.grid, { x: B, y: T, z: w, k: V, stopIf: P } = Z, I = f0.size(R);
  if (KQ.reset(J), I === 0 || V <= 0)
    return !1;
  let S, f, v, h = !1, x = 1, b = !0, g = 0, m = bt0, i = xt0, r = 0, Y0 = !0, c, n = !1, l = yt0, u = A * A;
  if (m.length = 0, l.length = 0, f_.clear(), xM.clear(), M.set(gF.origin, B, T, w), !t1.containsVec3(X, gF.origin))
    GQ.targetTo(gF, gF, Y), GQ.intersectBox3D(gF.origin, gF, X), S = Math.max(0, Math.min(Q - 1, Math.floor((gF.origin[0] - $[0]) / D[0]))), f = Math.max(0, Math.min(W - 1, Math.floor((gF.origin[1] - $[1]) / D[1]))), v = Math.max(0, Math.min(K - 1, Math.floor((gF.origin[2] - $[2]) / D[2])));
  else
    S = Math.floor((B - $[0]) / D[0]), f = Math.floor((T - $[1]) / D[1]), v = Math.floor((w - $[2]) / D[2]);
  let G0 = A !== 0 ? Math.max(1, Math.min(Q - 1, Math.ceil(A / D[0]))) : 1, F0 = A !== 0 ? Math.max(1, Math.min(W - 1, Math.ceil(A / D[1]))) : 1, t = A !== 0 ? Math.max(1, Math.min(K - 1, Math.ceil(A / D[2]))) : 1;
  m.push(S, f, v, (S * W + f) * K + v);
  while (J.count < I) {
    let Z0 = x * 4;
    for (let U0 = 0;U0 < Z0; U0 += 4)
      if (c = m[U0 + 3], !f_.has(c)) {
        f_.add(c), n = f_.size >= q.length;
        let a = q[c];
        if (a !== 0) {
          let Q0 = r, $0 = a - 1, R0 = G[$0], X0 = H[$0], E0 = R0 + X0;
          for (let V0 = R0;V0 < E0; V0++) {
            let u0 = N[V0], N0 = f0.getAt(R, u0), q0 = U[N0] - B, A0 = F[N0] - T, S0 = E[N0] - w, a0 = q0 * q0 + A0 * A0 + S0 * S0;
            if (A !== 0) {
              let D1 = z[N0];
              a0 -= D1 * D1;
            }
            if (Y0 && a0 > r)
              r = a0;
            xM.insert(a0, u0);
          }
          if (Q0 < r)
            Y0 = !1;
        }
      }
    i.length = 0, g = 0, Lo.clear();
    for (let U0 = 0;U0 < Z0; U0 += 4) {
      S = m[U0], f = m[U0 + 1], v = m[U0 + 2];
      for (let a = -G0;a <= G0; a++) {
        let Q0 = S + a;
        if (Q0 < 0 || Q0 >= Q)
          continue;
        for (let $0 = -F0;$0 <= F0; $0++) {
          let R0 = f + $0;
          if (R0 < 0 || R0 >= W)
            continue;
          for (let X0 = -t;X0 <= t; X0++) {
            let E0 = v + X0;
            if (E0 < 0 || E0 >= K)
              continue;
            if (c = (Q0 * W + R0) * K + E0, Lo.has(c))
              continue;
            if (Lo.add(c), f_.has(c))
              continue;
            if (!b) {
              let V0 = $[0] + Q0 * D[0] - B, u0 = $[1] + R0 * D[1] - T, N0 = $[2] + E0 * D[2] - w;
              if (V0 * V0 + u0 * u0 + N0 * N0 - u > r) {
                l.push(Q0, R0, E0, c);
                continue;
              }
            }
            i.push(Q0, R0, E0, c), g++;
          }
        }
      }
    }
    if (b = !1, g === 0) {
      if (V === 1) {
        let U0 = xM.findMinimum();
        if (U0) {
          let { key: a, value: Q0 } = U0;
          return KQ.add(J, Q0, a), !0;
        }
      } else
        while (!xM.isEmpty() && (n || xM.findMinimum().key <= r) && J.count < V) {
          let U0 = xM.extractMinimum(), a = U0.key, Q0 = U0.value;
          if (KQ.add(J, Q0, a), P && !h)
            h = P(Q0, a);
        }
      if (J.count >= V || h || J.count >= I)
        return J.count > 0;
      if (b = !0, Y0 = !0, l.length > 0) {
        for (let U0 = 0, a = l.length;U0 < a; U0++)
          m.push(l[U0]);
        l.length = 0, x = m.length;
      }
    } else {
      let U0 = m;
      m = i, i = U0, x = g;
    }
  }
  return J.count > 0;
}
// node_modules/molstar/lib/mol-math/histogram.js
function NH0(Z, J, $) {
  if (!$) {
    let [X, Y] = fQ(Z);
    return HH0(Z, J, X, Y);
  } else
    return HH0(Z, J, $.min, $.max);
}
function HH0(Z, J, $, X) {
  let Y = (X - $) / J;
  if (Y === 0)
    Y = 1;
  let Q = new Int32Array(J);
  for (let W = 0, K = Z.length;W < K; W++) {
    let G = Math.floor((Z[W] - $) / Y);
    if (G >= J)
      G = J - 1;
    else if (G < 0)
      G = 0;
    Q[G]++;
  }
  return { min: $, max: X, binWidth: Y, counts: Q };
}

// node_modules/molstar/lib/mol-model/volume/grid.js
var s6;
(function(Z) {
  Z.One = {
    transform: { kind: "matrix", matrix: e.identity() },
    cells: M8.create(M8.Space([1, 1, 1], [0, 1, 2]), M8.Data1([0])),
    stats: { min: 0, max: 0, mean: 0, sigma: 0 }
  };
  let J = e(), $ = e();
  function X(H) {
    if (H.transform.kind === "matrix")
      return e.copy(e(), H.transform.matrix);
    if (H.transform.kind === "spacegroup") {
      let { cells: { space: N } } = H, q = e.fromScaling(J, M.div(M(), t1.size(M(), H.transform.fractionalBox), M.ofArray(N.dimensions))), U = e.fromTranslation($, H.transform.fractionalBox.min);
      return e.mul3(e(), H.transform.cell.fromFractional, U, q);
    }
    return e.identity();
  }
  Z.getGridToCartesianTransform = X;
  function Y(H, N) {
    return H === N;
  }
  Z.areEquivalent = Y;
  function Q(H) {
    return H.cells.data.length === 0;
  }
  Z.isEmpty = Q;
  function W(H, N) {
    if (!N)
      N = C0();
    let q = H.cells.space.dimensions, U = Z.getGridToCartesianTransform(H);
    return C0.fromDimensionsAndTransform(N, q, U);
  }
  Z.getBoundingSphere = W;
  function K(H, N) {
    let q = H._historams;
    if (!q)
      q = H._historams = {};
    if (!q[N])
      q[N] = NH0(H.cells.data, N, { min: H.stats.min, max: H.stats.max });
    return q[N];
  }
  Z.getHistogram = K;
  function G(H, N) {
    let q = Z.getGridToCartesianTransform(H);
    e.invert(q, q);
    let U = M(), { stats: F } = H, { dimensions: E, get: R } = H.cells.space, z = H.cells.data, [D, A, B] = E;
    return function T(w) {
      M.copy(U, w), M.transformMat4(U, U, q);
      let V = Math.trunc(U[0]), P = Math.trunc(U[1]), I = Math.trunc(U[2]);
      if (V < 0 || V >= D || P < 0 || P >= A || I < 0 || I >= B)
        return Number.NaN;
      let S = U[0] - V, f = U[1] - P, v = U[2] - I, h = Math.min(V + 1, D - 1), x = Math.min(P + 1, A - 1), b = Math.min(I + 1, B - 1), g = R(z, V, P, I), m = R(z, h, P, I), i = R(z, V, x, I), r = R(z, h, x, I), Y0 = pZ(pZ(g, m, S), pZ(i, r, S), f);
      g = R(z, V, P, b), m = R(z, h, P, b), i = R(z, V, x, b), r = R(z, h, x, b);
      let c = pZ(pZ(g, m, S), pZ(i, r, S), f), n = pZ(Y0, c, v);
      if (N === "relative")
        return (n - F.mean) / F.sigma;
      else
        return n;
    };
  }
  Z.makeGetTrilinearlyInterpolated = G;
})(s6 || (s6 = {}));

// node_modules/molstar/lib/mol-math/geometry/centroid-helper.js
var mt0 = M.add, dt0 = M.squaredDistance, pt0 = M.distance;
class yQ {
  reset() {
    M.set(this.center, 0, 0, 0), this.radiusSq = 0, this.count = 0;
  }
  includeStep(Z) {
    mt0(this.center, this.center, Z), this.count++;
  }
  finishedIncludeStep() {
    if (this.count === 0)
      return;
    M.scale(this.center, this.center, 1 / this.count);
  }
  radiusStep(Z) {
    let J = dt0(Z, this.center);
    if (J > this.radiusSq)
      this.radiusSq = J;
  }
  radiusSphereStep(Z, J) {
    let $ = pt0(Z, this.center) + J, X = $ * $;
    if (X > this.radiusSq)
      this.radiusSq = X;
  }
  getSphere(Z) {
    if (!Z)
      Z = C0();
    return M.copy(Z.center, this.center), Z.radius = Math.sqrt(this.radiusSq), Z;
  }
  getCount() {
    return this.count;
  }
  constructor() {
    this.count = 0, this.center = M(), this.radiusSq = 0;
  }
}
(function(Z) {
  let J = new Z, $ = M(), X = M();
  function Y({ x: K, y: G, z: H }, N) {
    J.reset();
    let q = K.length;
    for (let U = 0;U < q; U++)
      M.set($, K[U], G[U], H[U]), J.includeStep($);
    J.finishedIncludeStep();
    for (let U = 0;U < q; U++)
      M.set($, K[U], G[U], H[U]), J.radiusStep($);
    return M.copy(N.center, J.center), N.radius = Math.sqrt(J.radiusSq), N;
  }
  Z.fromArrays = Y;
  function Q(K, G, H) {
    J.reset();
    for (let N = 0;N < K; N++)
      G(N, $), J.includeStep($);
    J.finishedIncludeStep();
    for (let N = 0;N < K; N++)
      G(N, $), J.radiusStep($);
    return M.copy(H.center, J.center), H.radius = Math.sqrt(J.radiusSq), H;
  }
  Z.fromProvider = Q;
  function W(K, G, H) {
    J.reset();
    for (let N = 0;N < K; N++)
      G(N, $, X), J.includeStep($), J.includeStep(X);
    J.finishedIncludeStep();
    for (let N = 0;N < K; N++)
      G(N, $, X), J.radiusStep($), J.radiusStep(X);
    return M.copy(H.center, J.center), H.radius = Math.sqrt(J.radiusSq), H;
  }
  Z.fromPairProvider = W;
})(yQ || (yQ = {}));

// node_modules/molstar/lib/mol-math/geometry/boundary-helper.js
var qH0 = M.dot, FH0 = M.copy, ut0 = M.scaleAndSub, ct0 = M.scaleAndAdd;

class $J {
  computeExtrema(Z, J) {
    let $ = qH0(this.dir[Z], J);
    if ($ < this.minDist[Z])
      this.minDist[Z] = $, FH0(this.extrema[Z * 2], J);
    if ($ > this.maxDist[Z])
      this.maxDist[Z] = $, FH0(this.extrema[Z * 2 + 1], J);
  }
  computeSphereExtrema(Z, J, $) {
    let X = this.dir[Z], Y = qH0(X, J);
    if (Y - $ < this.minDist[Z])
      this.minDist[Z] = Y - $, ut0(this.extrema[Z * 2], J, X, $);
    if (Y + $ > this.maxDist[Z])
      this.maxDist[Z] = Y + $, ct0(this.extrema[Z * 2 + 1], J, X, $);
  }
  includeSphere(Z) {
    if (C0.hasExtrema(Z) && Z.extrema.length > 1)
      for (let J of Z.extrema)
        this.includePosition(J);
    else
      this.includePositionRadius(Z.center, Z.radius);
  }
  includePosition(Z) {
    for (let J = 0;J < this.dirLength; ++J)
      this.computeExtrema(J, Z);
  }
  includePositionRadius(Z, J) {
    for (let $ = 0;$ < this.dirLength; ++$)
      this.computeSphereExtrema($, Z, J);
  }
  finishedIncludeStep() {
    for (let Z = 0;Z < this.extrema.length; Z++)
      this.centroidHelper.includeStep(this.extrema[Z]);
    this.centroidHelper.finishedIncludeStep();
  }
  radiusSphere(Z) {
    if (C0.hasExtrema(Z) && Z.extrema.length > 1)
      for (let J of Z.extrema)
        this.radiusPosition(J);
    else
      this.radiusPositionRadius(Z.center, Z.radius);
  }
  radiusPosition(Z) {
    this.centroidHelper.radiusStep(Z);
  }
  radiusPositionRadius(Z, J) {
    this.centroidHelper.radiusSphereStep(Z, J);
  }
  getSphere(Z) {
    return C0.setExtrema(this.centroidHelper.getSphere(Z), this.extrema.slice());
  }
  getBox(Z) {
    return t1.fromVec3Array(Z || t1(), this.extrema);
  }
  reset() {
    for (let Z = 0;Z < this.dirLength; ++Z)
      this.minDist[Z] = 1 / 0, this.maxDist[Z] = -1 / 0, this.extrema[Z * 2] = M(), this.extrema[Z * 2 + 1] = M();
    this.centroidHelper.reset();
  }
  constructor(Z) {
    this.minDist = [], this.maxDist = [], this.extrema = [], this.centroidHelper = new yQ, this.dir = lt0(Z), this.dirLength = this.dir.length, this.reset();
  }
}
function lt0(Z) {
  let J;
  switch (Z) {
    case "6":
      J = [...wf];
      break;
    case "14":
      J = [...wf, ...Ro];
      break;
    case "26":
      J = [...wf, ...Ro, ...UH0];
      break;
    case "98":
      J = [...wf, ...Ro, ...UH0, ...nt0, ...it0, ...ot0];
      break;
  }
  return J.map(($) => {
    let X = M.create($[0], $[1], $[2]);
    return M.normalize(X, X);
  });
}
var wf = [
  [1, 0, 0],
  [0, 1, 0],
  [0, 0, 1]
], Ro = [
  [1, 1, 1],
  [-1, 1, 1],
  [-1, -1, 1],
  [1, -1, 1]
], UH0 = [
  [1, 1, 0],
  [1, -1, 0],
  [1, 0, 1],
  [1, 0, -1],
  [0, 1, 1],
  [0, 1, -1]
], nt0 = [
  [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]
], it0 = [
  [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]
], ot0 = [
  [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]
];

// node_modules/molstar/lib/mol-model/custom-property.js
function p7(Z) {
  return Z;
}
(function(Z) {
  function J($) {
    if (!$.__key)
      $.__key = R6.create22();
    return $.__key;
  }
  Z.getUUID = J;
})(p7 || (p7 = {}));

class H$ {
  constructor() {
    this._list = [], this._set = /* @__PURE__ */ new Set, this._refs = /* @__PURE__ */ new Map, this._assets = /* @__PURE__ */ new Map;
  }
  get all() {
    return this._list;
  }
  add(Z) {
    if (this._set.has(Z))
      return;
    this._list.push(Z), this._set.add(Z);
  }
  reference(Z, J) {
    let $ = this._refs.get(Z) || 0;
    $ += J ? 1 : -1, this._refs.set(Z, Math.max($, 0));
  }
  hasReference(Z) {
    return (this._refs.get(Z) || 0) > 0;
  }
  has(Z) {
    return this._set.has(Z);
  }
  assets(Z, J) {
    let $ = this._assets.get(Z);
    if ($)
      for (let X of $)
        X.dispose();
    if (J)
      this._assets.set(Z, J);
    else
      this._assets.delete(Z);
  }
  dispose() {
    this._assets.forEach((Z) => {
      for (let J of Z)
        J.dispose();
    });
  }
}

// node_modules/molstar/lib/mol-model-formats/volume/cube.js
function LH0(Z, J) {
  return n0.create("Create Volume", async () => {
    let { header: $, values: X } = Z, Y = M8.Space($.dim, [0, 1, 2], Float64Array), Q;
    if ($.dataSetIds.length === 0)
      Q = X;
    else {
      let [H, N, q] = $.dim, U = ((J === null || J === void 0 ? void 0 : J.dataIndex) || 0) + 1, F = 0, E = 0;
      Q = new Float64Array(H * N * q);
      for (let R = 0;R < H; R++)
        for (let z = 0;z < N; z++)
          for (let D = 0;D < q; D++)
            Q[F++] = X[E], E += U;
    }
    let W = M8.create(Y, M8.Data1(Q)), K = e.fromTranslation(e(), $.origin), G = e.fromBasis(e(), $.basisX, $.basisY, $.basisZ);
    return e.mul(K, K, G), {
      label: J === null || J === void 0 ? void 0 : J.label,
      entryId: J === null || J === void 0 ? void 0 : J.entryId,
      grid: {
        transform: { kind: "matrix", matrix: K },
        cells: W,
        stats: {
          min: ZR(Q),
          max: yX(Q),
          mean: JR(Q),
          sigma: $R(Q)
        }
      },
      instances: [{ transform: e.identity() }],
      sourceData: h_.create(Z),
      customProperties: new H$,
      _propertyData: Object.create(null)
    };
  });
}
var h_;
(function(Z) {
  function J(X) {
    return (X === null || X === void 0 ? void 0 : X.kind) === "cube";
  }
  Z.is = J;
  function $(X) {
    return { kind: "cube", name: X.name, data: X };
  }
  Z.create = $;
})(h_ || (h_ = {}));

// node_modules/molstar/lib/mol-util/number.js
function st0(Z, J, $) {
  let X = 1, Y;
  for (Y = 0;Y < J; Y++) {
    let Q = X * Z;
    if (Math.abs(Math.round(Q) - Q) <= $)
      return Y;
    X *= 10;
  }
  return -1;
}
function RH0(Z, J) {
  if (Math.abs(Z) < J)
    return 0;
  return Math.floor(Math.log10(Math.abs(Z))) + 1;
}
function EH0(Z, J, $) {
  let X = 1, Y = 0;
  for (let Q = 0, W = Z.length;Q < W; Q++) {
    if (X >= 0) {
      let G = st0(Z[Q], J, $);
      if (G < 0)
        X = -1;
      else if (G > X)
        X = G;
    }
    let K = Math.abs(Z[Q]);
    if (K > $) {
      let G = Math.floor(Math.log10(Math.abs(K))) + 1;
      if (G > Y)
        Y = G;
    }
  }
  return { mantissaDigits: X, integerDigits: Y };
}
function OH0(Z) {
  Z = Z.trim();
  let J = parseInt(Z, 10);
  return Number.isNaN(J) ? !1 : J.toString() === Z;
}
function Xz(Z) {
  if (!isFinite(Z))
    return 0;
  let J = 1, $ = 0;
  while (Math.round(Z * J) / J !== Z)
    J *= 10, ++$;
  return $;
}
function b_(Z, J) {
  return parseFloat(Z.toPrecision(J));
}
function zH0(Z, J) {
  return parseFloat(Z.toFixed(J));
}

// node_modules/molstar/lib/mol-model-formats/volume/density-server.js
function jf(Z, J) {
  return n0.create("Create Volume", async ($) => {
    let { volume_data_3d_info: X, volume_data_3d: Y } = Z, Q = d7.create(X.spacegroup_number.value(0) || "P 1", M.ofArray(X.spacegroup_cell_size.value(0)), M.scale(M.zero(), M.ofArray(X.spacegroup_cell_angles.value(0)), Math.PI / 180)), W = X.axis_order.value(0), K = M8.convertToCanonicalAxisIndicesFastToSlow(W), G = K(X.sample_count.value(0)), H = M8.Space(G, M8.invertAxisOrder(W), Float32Array), N = M8.create(H, M8.Data1(Y.values.toArray({ array: Float32Array }))), q = M.ofArray(K(X.origin.value(0))), U = M.ofArray(K(X.dimensions.value(0)));
    return {
      label: J === null || J === void 0 ? void 0 : J.label,
      entryId: J === null || J === void 0 ? void 0 : J.entryId,
      periodicity: M.isInteger(U) ? "xyz" : "none",
      grid: {
        transform: { kind: "spacegroup", cell: Q, fractionalBox: t1.create(q, M.add(M.zero(), q, U)) },
        cells: N,
        stats: {
          min: X.min_sampled.value(0),
          max: X.max_sampled.value(0),
          mean: X.mean_sampled.value(0),
          sigma: X.sigma_sampled.value(0)
        }
      },
      instances: [{ transform: e.identity() }],
      sourceData: x_.create(Z),
      customProperties: new H$,
      _propertyData: Object.create(null)
    };
  });
}
var x_;
(function(Z) {
  function J(X) {
    return (X === null || X === void 0 ? void 0 : X.kind) === "dscif";
  }
  Z.is = J;
  function $(X) {
    return { kind: "dscif", name: X._name, data: X };
  }
  Z.create = $;
})(x_ || (x_ = {}));

// node_modules/molstar/lib/mol-model/volume/volume.js
var Q1;
(function(Z) {
  function J(A) {
    var B, T, w, V;
    return ((V = (w = (T = (B = A === null || A === void 0 ? void 0 : A.grid) === null || B === void 0 ? void 0 : B.cells) === null || T === void 0 ? void 0 : T.space) === null || w === void 0 ? void 0 : w.dimensions) === null || V === void 0 ? void 0 : V.length) && (A === null || A === void 0 ? void 0 : A.sourceData) && (A === null || A === void 0 ? void 0 : A.customProperties) && (A === null || A === void 0 ? void 0 : A._propertyData);
  }
  Z.is = J;
  let $;
  (function(A) {
    function B(v, h, x) {
      return dZ(I(v, x).absoluteValue, I(h, x).absoluteValue, x.sigma / 100);
    }
    A.areSame = B;
    function T(v) {
      return { kind: "absolute", absoluteValue: v };
    }
    A.absolute = T;
    function w(v) {
      return { kind: "relative", relativeValue: v };
    }
    A.relative = w;
    function V(v, h) {
      return h * v.sigma + v.mean;
    }
    A.calcAbsolute = V;
    function P(v, h) {
      return v.sigma === 0 ? 0 : (h - v.mean) / v.sigma;
    }
    A.calcRelative = P;
    function I(v, h) {
      return v.kind === "absolute" ? v : { kind: "absolute", absoluteValue: A.calcAbsolute(h, v.relativeValue) };
    }
    A.toAbsolute = I;
    function S(v, h) {
      return v.kind === "relative" ? v : { kind: "relative", relativeValue: A.calcRelative(h, v.absoluteValue) };
    }
    A.toRelative = S;
    function f(v) {
      return v.kind === "relative" ? `${v.relativeValue.toFixed(2)} σ` : `${v.absoluteValue.toPrecision(4)}`;
    }
    A.toString = f;
  })($ = Z.IsoValue || (Z.IsoValue = {}));
  function X(A, B, T) {
    if (T === "relative")
      return $.relative(B);
    let w = $.absolute(B);
    if (x_.is(A.sourceData)) {
      let V = {
        min: A.sourceData.data.volume_data_3d_info.min_source.value(0),
        max: A.sourceData.data.volume_data_3d_info.max_source.value(0),
        mean: A.sourceData.data.volume_data_3d_info.mean_source.value(0),
        sigma: A.sourceData.data.volume_data_3d_info.sigma_source.value(0)
      };
      return Z.IsoValue.toRelative(w, V);
    }
    return w;
  }
  Z.adjustedIsoValue = X;
  let Y = { min: -1, max: 1, mean: 0, sigma: 0.1 };
  function Q(A, B) {
    let T = B || Y, { min: w, max: V, mean: P, sigma: I } = T, S = (w - P) / I, f = (V - P) / I, v = A;
    if (A.kind === "absolute") {
      if (A.absoluteValue < w)
        v = Z.IsoValue.absolute(w);
      else if (A.absoluteValue > V)
        v = Z.IsoValue.absolute(V);
    } else if (A.relativeValue < S)
      v = Z.IsoValue.relative(S);
    else if (A.relativeValue > f)
      v = Z.IsoValue.relative(f);
    return j.Conditioned(v, {
      absolute: j.Converted((h) => Z.IsoValue.toAbsolute(h, s6.One.stats).absoluteValue, (h) => Z.IsoValue.absolute(h), j.Numeric(P, { min: w, max: V, step: b_(I / 100, 2) }, { immediateUpdate: !0 })),
      relative: j.Converted((h) => Z.IsoValue.toRelative(h, s6.One.stats).relativeValue, (h) => Z.IsoValue.relative(h), j.Numeric(Math.min(1, f), { min: S, max: f, step: b_(Math.round((V - w) / I) / 100, 2) }, { immediateUpdate: !0 }))
    }, (h) => h.kind === "absolute" ? "absolute" : "relative", (h, x) => x === "absolute" ? Z.IsoValue.toAbsolute(h, T) : Z.IsoValue.toRelative(h, T), { isEssential: !0 });
  }
  Z.createIsoValueParam = Q, Z.IsoValueParam = Q(Z.IsoValue.relative(2)), Z.One = {
    label: "",
    grid: s6.One,
    instances: [],
    sourceData: { kind: "", name: "", data: {} },
    customProperties: new H$,
    _propertyData: Object.create(null)
  };
  function W(A, B) {
    return s6.areEquivalent(A.grid, B.grid) && K(A, B);
  }
  Z.areEquivalent = W;
  function K(A, B) {
    if (A.instances.length !== B.instances.length)
      return !1;
    for (let T = 0, w = A.instances.length;T < w; ++T)
      if (!e.areEqual(A.instances[T].transform, B.instances[T].transform, u8))
        return !1;
    return !0;
  }
  Z.areInstanceTransformsEqual = K;
  function G(A) {
    return s6.isEmpty(A.grid) || A.instances.length === 0;
  }
  Z.isEmpty = G;
  function H(A) {
    if (!h_.is(A.sourceData))
      return !1;
    return A.sourceData.data.header.orbitals;
  }
  Z.isOrbitals = H;
  function N(A, B) {
    return { kind: "volume-loci", volume: A, instances: B };
  }
  Z.Loci = N;
  function q(A) {
    return !!A && A.kind === "volume-loci";
  }
  Z.isLoci = q;
  function U(A, B) {
    return A.volume === B.volume && f0.areEqual(A.instances, B.instances);
  }
  Z.areLociEqual = U;
  function F(A) {
    return G(A.volume) || f0.isEmpty(A.instances);
  }
  Z.isLociEmpty = F;
  function E(A, B) {
    return s6.getBoundingSphere(A.grid, B);
  }
  Z.getBoundingSphere = E;
  let R;
  (function(A) {
    function B(S, f, v) {
      return { kind: "isosurface-loci", volume: S, isoValue: f, instances: v };
    }
    A.Loci = B;
    function T(S) {
      return !!S && S.kind === "isosurface-loci";
    }
    A.isLoci = T;
    function w(S, f) {
      return S.volume === f.volume && Z.IsoValue.areSame(S.isoValue, f.isoValue, S.volume.grid.stats) && f0.areEqual(S.instances, f.instances);
    }
    A.areLociEqual = w;
    function V(S) {
      return G(S.volume) || f0.isEmpty(S.instances);
    }
    A.isLociEmpty = V;
    let P = t1();
    function I(S, f, v) {
      let h = Z.IsoValue.toAbsolute(f, S.grid.stats).absoluteValue, x = h < 0, b = [0, 0, 0], g = S.grid.cells.space.getCoords, m = S.grid.cells.data, [i, r, Y0] = S.grid.cells.space.dimensions, c = i - 1, n = r - 1, l = Y0 - 1, u = 0, G0 = 0, F0 = 0;
      for (let Z0 = 0, U0 = m.length;Z0 < U0; ++Z0)
        if (x && m[Z0] <= h || !x && m[Z0] >= h) {
          if (g(Z0, b), b[0] < c)
            c = b[0];
          if (b[1] < n)
            n = b[1];
          if (b[2] < l)
            l = b[2];
          if (b[0] > u)
            u = b[0];
          if (b[1] > G0)
            G0 = b[1];
          if (b[2] > F0)
            F0 = b[2];
        }
      M.set(P.min, c - 1, n - 1, l - 1), M.set(P.max, u + 1, G0 + 1, F0 + 1);
      let t = s6.getGridToCartesianTransform(S.grid);
      return t1.transform(P, P, t), C0.fromBox3D(v || C0(), P);
    }
    A.getBoundingSphere = I;
  })(R = Z.Isosurface || (Z.Isosurface = {}));
  let z;
  (function(A) {
    function B(b, g) {
      return { kind: "cell-loci", volume: b, elements: g };
    }
    A.Loci = B;
    function T(b) {
      return !!b && b.kind === "cell-loci";
    }
    A.isLoci = T;
    function w(b, g) {
      if (b.volume !== g.volume || b.elements.length !== g.elements.length)
        return !1;
      for (let m = 0, i = b.elements.length;m < i; ++m) {
        let r = b.elements[m], Y0 = g.elements[m];
        if (!f0.areEqual(r.instances, Y0.instances) || !f0.areEqual(r.indices, Y0.indices))
          return !1;
      }
      return !0;
    }
    A.areLociEqual = w;
    function V(b) {
      for (let { indices: g, instances: m } of b.elements)
        if (!f0.isEmpty(m) || !f0.isEmpty(g))
          return !1;
      return !0;
    }
    A.isLociEmpty = V;
    function P(b) {
      let g = 0;
      for (let { indices: m, instances: i } of b.elements)
        g += f0.size(m) * f0.size(i);
      return g;
    }
    A.getLociSize = P;
    function I(b, g, m) {
      return {
        kind: "cell-location",
        volume: b,
        cell: g,
        instance: m
      };
    }
    A.Location = I;
    function S(b) {
      return !!b && b.kind === "cell-location";
    }
    A.isLocation = S;
    let f = new $J("98"), v = M(), h = M();
    function x(b, g, m) {
      f.reset();
      let i = s6.getGridToCartesianTransform(b.grid), { getCoords: r } = b.grid.cells.space;
      for (let { indices: c, instances: n } of g)
        for (let l = 0, u = f0.size(c);l < u; l++) {
          let G0 = f0.getAt(c, l);
          r(G0, v), M.transformMat4(v, v, i);
          for (let F0 = 0, t = f0.size(n);F0 < t; F0++) {
            let Z0 = b.instances[f0.getAt(n, F0)];
            M.transformMat4(h, v, Z0.transform), f.includePosition(h);
          }
        }
      f.finishedIncludeStep();
      for (let { indices: c, instances: n } of g)
        for (let l = 0, u = f0.size(c);l < u; l++) {
          let G0 = f0.getAt(c, l);
          r(G0, v), M.transformMat4(v, v, i);
          for (let F0 = 0, t = f0.size(n);F0 < t; F0++) {
            let Z0 = b.instances[f0.getAt(n, F0)];
            M.transformMat4(h, v, Z0.transform), f.radiusPosition(h);
          }
        }
      let Y0 = f.getSphere(m);
      return C0.expand(Y0, Y0, e.getMaxScaleOnAxis(i) * 10);
    }
    A.getBoundingSphere = x;
  })(z = Z.Cell || (Z.Cell = {}));
  let D;
  (function(A) {
    function B(b, g) {
      return { kind: "segment-loci", volume: b, elements: g };
    }
    A.Loci = B;
    function T(b) {
      return !!b && b.kind === "segment-loci";
    }
    A.isLoci = T;
    function w(b, g) {
      if (b.volume !== g.volume || b.elements.length !== g.elements.length)
        return !1;
      for (let m = 0, i = b.elements.length;m < i; ++m) {
        let r = b.elements[m], Y0 = g.elements[m];
        if (!f0.areEqual(r.instances, Y0.instances) || !f0.areEqual(r.segments, Y0.segments))
          return !1;
      }
      return !0;
    }
    A.areLociEqual = w;
    function V(b) {
      for (let { segments: g, instances: m } of b.elements)
        if (!f0.isEmpty(m) || !f0.isEmpty(g))
          return !1;
      return !0;
    }
    A.isLociEmpty = V;
    function P(b) {
      let g = 0;
      for (let { segments: m, instances: i } of b.elements)
        g += f0.size(m) * f0.size(i);
      return g;
    }
    A.getLociSize = P;
    let I = t1(), S = t1(), f = t1();
    function v(b, g, m) {
      let i = Z.Segmentation.get(b);
      if (i) {
        t1.setEmpty(I);
        let r = s6.getGridToCartesianTransform(b.grid);
        for (let { segments: Y0, instances: c } of g) {
          t1.setEmpty(S);
          for (let n = 0, l = f0.size(Y0);n < l; n++) {
            let u = f0.getAt(Y0, n), G0 = i.bounds[u];
            t1.add(S, G0.min), t1.add(S, G0.max);
          }
          t1.transform(S, S, r);
          for (let n = 0, l = f0.size(c);n < l; n++) {
            let u = b.instances[f0.getAt(c, n)];
            t1.transform(f, S, u.transform), t1.addBox3D(I, f);
          }
        }
        return C0.fromBox3D(m || C0(), I);
      } else
        return Z.getBoundingSphere(b, m);
    }
    A.getBoundingSphere = v;
    function h(b, g, m) {
      return {
        kind: "segment-location",
        volume: b,
        segment: g,
        instance: m
      };
    }
    A.Location = h;
    function x(b) {
      return !!b && b.kind === "segment-location";
    }
    A.isLocation = x;
  })(D = Z.Segment || (Z.Segment = {})), Z.PickingGranularity = {
    set(A, B) {
      A._propertyData.__picking_granularity__ = B;
    },
    get(A) {
      var B;
      return (B = A._propertyData.__picking_granularity__) !== null && B !== void 0 ? B : "voxel";
    }
  }, Z.Segmentation = {
    set(A, B) {
      A._propertyData.__segmentation__ = B;
    },
    get(A) {
      return A._propertyData.__segmentation__;
    }
  };
})(Q1 || (Q1 = {}));
// node_modules/molstar/lib/mol-data/db/column-helpers.js
var w7 = {};
y9(w7, {
  typedArrayWindow: () => _f,
  isTypedArray: () => Tf,
  getArrayBounds: () => RR,
  fillArrayValues: () => DH0,
  createArray: () => Yz,
  createAndFillArray: () => at0
});
function RR(Z, J) {
  let $ = J && typeof J.start !== "undefined" ? Math.max(Math.min(J.start, Z - 1), 0) : 0, X = J && typeof J.end !== "undefined" ? Math.min(J.end, Z) : Z;
  return { start: $, end: X };
}
function Yz(Z, J) {
  let $ = J && typeof J.array !== "undefined" ? J.array : Array, { start: X, end: Y } = RR(Z, J);
  return { array: new $(Y - X), start: X, end: Y };
}
function DH0(Z, J, $) {
  for (let X = 0, Y = J.length;X < Y; X++)
    J[X] = Z($ + X);
  return J;
}
function at0(Z, J, $) {
  let { array: X, start: Y } = Yz(Z, $);
  return DH0(J, X, Y);
}
function Tf(Z) {
  return !!Z.buffer && typeof Z.byteLength === "number" && typeof Z.BYTES_PER_ELEMENT === "number";
}
function _f(Z, J) {
  let { constructor: $, buffer: X, length: Y, byteOffset: Q, BYTES_PER_ELEMENT: W } = Z, { start: K, end: G } = RR(Y, J);
  if (K === 0 && G === Y)
    return Z;
  return new $(X, Q + W * K, Math.min(Y, G - K));
}

// node_modules/molstar/lib/mol-io/reader/common/text/number-parser.js
function mF(Z, J, $) {
  while (J < $ && Z.charCodeAt(J) === 32)
    J++;
  return z3(Z, J, $);
}
function z3(Z, J, $) {
  let X = J, Y = 0, Q = 1;
  if (Z.charCodeAt(X) === 45)
    Q = -1, ++X;
  else if (Z.charCodeAt(X) === 43)
    ++X;
  for (;X < $; X++) {
    let W = Z.charCodeAt(X) - 48;
    if (W > 9 || W < 0)
      return Q * Y | 0;
    else
      Y = 10 * Y + W | 0;
  }
  return Q * Y;
}
function MH0(Z, J, $, X) {
  if (J.charCodeAt($) === 43)
    $++;
  return Z * Math.pow(10, z3(J, $, X));
}
function AH0(Z, J, $) {
  while (J < $ && Z.charCodeAt(J) === 32)
    J++;
  return _W(Z, J, $);
}
function _W(Z, J, $) {
  let X = J, Y = 1, Q = 0, W = 0, K = 1;
  if (Z.charCodeAt(X) === 45)
    Y = -1, ++X;
  else if (Z.charCodeAt(X) === 43)
    ++X;
  while (X < $) {
    let G = Z.charCodeAt(X) - 48;
    if (G >= 0 && G < 10)
      Q = Q * 10 + G, ++X;
    else if (G === -2) {
      ++X;
      while (X < $)
        if (G = Z.charCodeAt(X) - 48, G >= 0 && G < 10)
          W = 10 * W + G, K = 10 * K, ++X;
        else if (G === 53 || G === 21)
          return MH0(Y * (Q + W / K), Z, X + 1, $);
        else
          return Y * (Q + W / K);
      return Y * (Q + W / K);
    } else if (G === 53 || G === 21)
      return MH0(Y * Q, Z, X + 1, $);
    else
      break;
  }
  return Y * Q;
}
var Qz;
(function(Z) {
  Z[Z.Int = 0] = "Int", Z[Z.Float = 1] = "Float", Z[Z.Scientific = 2] = "Scientific", Z[Z.NaN = 3] = "NaN";
})(Qz || (Qz = {}));
var Jr1 = {
  Int: Qz.Int,
  Float: Qz.Float,
  Scientific: Qz.Scientific,
  NaN: Qz.NaN
};

// node_modules/molstar/lib/mol-data/db/column.js
var s;
(function(Z) {
  let J;
  (function(v) {
    v.str = { "@type": "str", T: "", valueType: "str" }, v.ustr = { "@type": "str", T: "", valueType: "str", transform: "uppercase" }, v.lstr = { "@type": "str", T: "", valueType: "str", transform: "lowercase" }, v.int = { "@type": "int", T: 0, valueType: "int" }, v.coord = { "@type": "coord", T: 0, valueType: "float" }, v.float = { "@type": "float", T: 0, valueType: "float" };
    function h(c) {
      var n;
      return { "@type": "str", T: (n = c === null || c === void 0 ? void 0 : c.defaultValue) !== null && n !== void 0 ? n : "", transform: c === null || c === void 0 ? void 0 : c.transform, valueType: "str" };
    }
    v.Str = h;
    function x(c = 0) {
      return { "@type": "int", T: c, valueType: "int" };
    }
    v.Int = x;
    function b(c = 0) {
      return { "@type": "float", T: c, valueType: "float" };
    }
    v.Float = b;
    function g(c, n = v.float) {
      return { "@type": "tensor", T: c.create(), space: c, valueType: "tensor", baseType: n };
    }
    v.Tensor = g;
    function m(c, n = v.float) {
      return g(M8.Vector(c, n["@type"] === "int" ? Int32Array : Float64Array), n);
    }
    v.Vector = m;
    function i(c, n, l = v.float) {
      return g(M8.ColumnMajorMatrix(c, n, l["@type"] === "int" ? Int32Array : Float64Array), l);
    }
    v.Matrix = i;
    function r(c) {
      return c;
    }
    v.Aliased = r;
    function Y0(c, n, l = []) {
      return { "@type": "list", T: l, separator: c, itemParse: n, valueType: "list" };
    }
    v.List = Y0;
  })(J = Z.Schema || (Z.Schema = {}));
  function $(v) {
    return !!v && !!v.schema && !!v.value;
  }
  Z.is = $;
  let X;
  (function(v) {
    v[v.Present = 0] = "Present", v[v.NotPresent = 1] = "NotPresent", v[v.Unknown = 2] = "Unknown";
  })(X = Z.ValueKinds || (Z.ValueKinds = {})), Z.ValueKind = {
    Present: X.Present,
    NotPresent: X.NotPresent,
    Unknown: X.Unknown
  };
  function Y(v, h) {
    return BH0(h.T, v, h, X.NotPresent);
  }
  Z.Undefined = Y;
  function Q(v, h, x) {
    return BH0(v, h, x, X.Present);
  }
  Z.ofConst = Q;
  function W(v) {
    return Vf(v);
  }
  Z.ofLambda = W;
  function K(v, h) {
    return W({
      value: (x) => x + v,
      rowCount: Math.max(h - v + 1, 0),
      schema: J.int
    });
  }
  Z.range = K;
  function G(v) {
    return dF(v);
  }
  Z.ofArray = G;
  function H(v) {
    return dF({ array: v, schema: J.int });
  }
  Z.ofIntArray = H;
  function N(v) {
    return dF({ array: v, schema: J.float });
  }
  Z.ofFloatArray = N;
  function q(v) {
    return dF({ array: v, schema: J.str });
  }
  Z.ofStringArray = q;
  function U(v) {
    return dF({ array: v, schema: J.Aliased(J.str) });
  }
  Z.ofStringAliasArray = U;
  function F(v, h = ",") {
    return dF({ array: v, schema: J.List(h, (x) => x) });
  }
  Z.ofStringListArray = F;
  function E(v) {
    let { count: h, data: x, indices: b } = v;
    return Vf({
      value: (g) => z3(x, b[2 * g], b[2 * g + 1]) || 0,
      rowCount: h,
      schema: J.int
    });
  }
  Z.ofIntTokens = E;
  function R(v) {
    let { count: h, data: x, indices: b } = v;
    return Vf({
      value: (g) => _W(x, b[2 * g], b[2 * g + 1]) || 0,
      rowCount: h,
      schema: J.float
    });
  }
  Z.ofFloatTokens = R;
  function z(v) {
    let { count: h, data: x, indices: b } = v;
    return Vf({
      value: (g) => {
        let m = x.substring(b[2 * g], b[2 * g + 1]);
        if (m === "." || m === "?")
          return "";
        return m;
      },
      rowCount: h,
      schema: J.str
    });
  }
  Z.ofStringTokens = z;
  function D(v, h, x) {
    return et0(v, h, x);
  }
  Z.window = D;
  function A(v, h, x = !0) {
    return Xe0(v, h, x);
  }
  Z.view = A;
  function B(v) {
    return rt0(v);
  }
  Z.createFirstIndexMap = B;
  function T(v) {
    return tt0(v);
  }
  Z.createIndexer = T;
  function w(v, h, x) {
    return We0(v, h, x || Array);
  }
  Z.mapToArray = w;
  function V(v, h) {
    return Ke0(v, h);
  }
  Z.areEqual = V;
  function P(v, h) {
    return Ne0(v, h);
  }
  Z.indicesOf = P;
  function I(v, h) {
    if (v.__array)
      return v;
    if (!v.isDefined)
      return Y(v.rowCount, v.schema);
    return dF({ array: v.toArray({ array: h }), schema: v.schema, valueKind: v.valueKind });
  }
  Z.asArrayColumn = I;
  function S(v, h, x = 0) {
    if (!v.isDefined)
      return;
    let b = v.__array;
    if (b)
      for (let g = 0, m = b.length;g < m; g++)
        h[x + g] = b[g];
    else
      for (let g = 0, m = v.rowCount;g < m; g++)
        h[x + g] = v.value(g);
  }
  Z.copyToArray = S;
  function f(v) {
    for (let h = 0, x = v.rowCount;h < x; h++)
      if (h !== v.value(h))
        return !1;
    return !0;
  }
  Z.isIdentity = f;
})(s || (s = {}));
function rt0(Z) {
  let J = /* @__PURE__ */ new Map;
  for (let $ = 0, X = Z.rowCount;$ < X; $++) {
    let Y = Z.value($);
    if (!J.has(Y))
      J.set(Z.value($), $);
  }
  return J;
}
function tt0(Z) {
  let J = /* @__PURE__ */ new Map;
  for (let $ = 0, X = Z.rowCount;$ < X; $++) {
    let Y = Z.value($);
    if (!J.has(Y))
      J.set(Z.value($), $);
  }
  return ($) => J.has($) ? J.get($) : -1;
}
function BH0(Z, J, $, X) {
  let Y = (Q) => Z;
  return {
    schema: $,
    __array: void 0,
    isDefined: X === s.ValueKinds.Present,
    rowCount: J,
    value: Y,
    valueKind: (Q) => X,
    toArray: (Q) => {
      let { array: W } = Yz(J, Q);
      for (let K = 0, G = W.length;K < G; K++)
        W[K] = Z;
      return W;
    },
    areValuesEqual: (Q, W) => !0
  };
}
function Vf({ value: Z, valueKind: J, areValuesEqual: $, rowCount: X, schema: Y }) {
  return {
    schema: Y,
    __array: void 0,
    isDefined: !0,
    rowCount: X,
    value: Z,
    valueKind: J ? J : (Q) => s.ValueKinds.Present,
    toArray: (Q) => {
      let { array: W, start: K } = Yz(X, Q);
      for (let G = 0, H = W.length;G < H; G++)
        W[G] = Z(G + K);
      return W;
    },
    areValuesEqual: $ ? $ : (Q, W) => Z(Q) === Z(W)
  };
}
function dF({ array: Z, schema: J, valueKind: $ }) {
  let X = Z.length, Y = J.T, Q = J.valueType === "str" ? J.transform === "lowercase" ? (K) => {
    let G = Z[K];
    return typeof G === "string" ? G.toLowerCase() : `${G !== null && G !== void 0 ? G : Y}`.toLowerCase();
  } : J.transform === "uppercase" ? (K) => {
    let G = Z[K];
    return typeof G === "string" ? G.toUpperCase() : `${G !== null && G !== void 0 ? G : Y}`.toUpperCase();
  } : (K) => {
    let G = Z[K];
    return typeof G === "string" ? G : `${G !== null && G !== void 0 ? G : Y}`;
  } : (K) => Z[K], W = Tf(Z);
  return {
    schema: J,
    __array: Z,
    isDefined: !0,
    rowCount: X,
    value: Q,
    valueKind: $ ? $ : (K) => s.ValueKinds.Present,
    toArray: J.valueType === "str" ? J.transform === "lowercase" ? (K) => {
      let { start: G, end: H } = RR(X, K), N = new (K && typeof K.array !== "undefined" ? K.array : Z.constructor)(H - G);
      for (let q = 0, U = H - G;q < U; q++) {
        let F = Z[G + q];
        N[q] = typeof F === "string" ? F.toLowerCase() : `${F !== null && F !== void 0 ? F : Y}`.toLowerCase();
      }
      return N;
    } : J.transform === "uppercase" ? (K) => {
      let { start: G, end: H } = RR(X, K), N = new (K && typeof K.array !== "undefined" ? K.array : Z.constructor)(H - G);
      for (let q = 0, U = H - G;q < U; q++) {
        let F = Z[G + q];
        N[q] = typeof F === "string" ? F.toUpperCase() : `${F !== null && F !== void 0 ? F : Y}`.toUpperCase();
      }
      return N;
    } : (K) => {
      let { start: G, end: H } = RR(X, K), N = new (K && typeof K.array !== "undefined" ? K.array : Z.constructor)(H - G);
      for (let q = 0, U = H - G;q < U; q++) {
        let F = Z[G + q];
        N[q] = typeof F === "string" ? F : `${F !== null && F !== void 0 ? F : Y}`;
      }
      return N;
    } : W ? (K) => _f(Z, K) : (K) => {
      let { start: G, end: H } = RR(X, K);
      if (G === 0 && H === Z.length)
        return Z;
      let N = new (K && typeof K.array !== "undefined" ? K.array : Z.constructor)(H - G);
      for (let q = 0, U = H - G;q < U; q++)
        N[q] = Z[G + q];
      return N;
    },
    areValuesEqual: (K, G) => Z[K] === Z[G]
  };
}
function et0(Z, J, $) {
  if (!Z.isDefined)
    return s.Undefined($ - J, Z.schema);
  if (J === 0 && $ === Z.rowCount)
    return Z;
  if (!!Z.__array && Tf(Z.__array))
    return Ze0(Z, J, $);
  return Je0(Z, J, $);
}
function Ze0(Z, J, $) {
  let X = _f(Z.__array, { start: J, end: $ }), Y = Z.valueKind;
  return dF({ array: X, schema: Z.schema, valueKind: (Q) => Y(J + Q) });
}
function Je0(Z, J, $) {
  let { value: X, valueKind: Y, areValuesEqual: Q } = Z, W = J === 0 ? X : (G) => X(G + J), K = $ - J;
  return {
    schema: Z.schema,
    __array: void 0,
    isDefined: Z.isDefined,
    rowCount: K,
    value: W,
    valueKind: J === 0 ? Y : (G) => Y(G + J),
    toArray: (G) => {
      let { array: H } = Yz(K, G);
      for (let N = 0, q = H.length;N < q; N++)
        H[N] = X(N + J);
      return H;
    },
    areValuesEqual: J === 0 ? Q : (G, H) => Q(G + J, H + J)
  };
}
function $e0(Z, J) {
  if (Z.length !== J)
    return !1;
  for (let $ = 0, X = Z.length;$ < X; $++)
    if (Z[$] !== $)
      return !1;
  return !0;
}
function Xe0(Z, J, $) {
  if (Z.rowCount === 0)
    return Z;
  if ($ && $e0(J, Z.rowCount))
    return Z;
  if (!!Z.__array && typeof Z.value(0) === typeof Z.__array[0])
    return Ye0(Z, J);
  return Qe0(Z, J);
}
function Ye0(Z, J) {
  let $ = Z.__array, X = new $.constructor(J.length);
  for (let Q = 0, W = J.length;Q < W; Q++)
    X[Q] = $[J[Q]];
  let Y = Z.valueKind;
  return dF({ array: X, schema: Z.schema, valueKind: (Q) => Y(J[Q]) });
}
function Qe0(Z, J) {
  let { value: $, valueKind: X, areValuesEqual: Y } = Z, Q = (K) => $(J[K]), W = J.length;
  return {
    schema: Z.schema,
    __array: void 0,
    isDefined: Z.isDefined,
    rowCount: W,
    value: Q,
    valueKind: (K) => X(J[K]),
    toArray: (K) => {
      let { array: G } = Yz(W, K);
      for (let H = 0, N = G.length;H < N; H++)
        G[H] = $(J[H]);
      return G;
    },
    areValuesEqual: (K, G) => Y(J[K], J[G])
  };
}
function We0(Z, J, $) {
  let X = new $(Z.rowCount);
  for (let Y = 0, Q = Z.rowCount;Y < Q; Y++)
    X[Y] = J(Z.value(Y));
  return X;
}
function Ke0(Z, J) {
  if (Z === J)
    return !0;
  if (Z.rowCount !== J.rowCount || Z.isDefined !== J.isDefined || Z.schema.valueType !== J.schema.valueType)
    return !1;
  if (!!Z.__array && !!J.__array)
    return Ge0(Z, J);
  return He0(Z, J);
}
function Ge0(Z, J) {
  let $ = Z.__array, X = J.__array;
  for (let Y = 0, Q = Z.rowCount;Y < Q; Y++)
    if ($[Y] !== X[Y])
      return !1;
  return !0;
}
function He0(Z, J) {
  let $ = Z.value, X = J.value;
  for (let Y = 0, Q = Z.rowCount;Y < Q; Y++)
    if ($(Y) !== X(Y))
      return !1;
  return !0;
}
function Ne0(Z, J) {
  let $ = [], X = Z.value;
  for (let Y = 0, Q = Z.rowCount;Y < Q; Y++)
    if (J(X(Y)))
      $[$.length] = Y;
  return $;
}

// node_modules/molstar/lib/mol-data/db/table.js
var A8;
(function(Z) {
  function J(T) {
    return T && typeof T._rowCount === "number" && !!T._columns && !!T._schema;
  }
  Z.is = J;
  function $(T, w, V = {}) {
    let P = Object.create(null), I = Object.keys(T);
    P._rowCount = w._rowCount, P._columns = I, P._schema = T;
    for (let S of I)
      if (w[S])
        P[S] = w[S];
      else if (V[S])
        P[S] = V[S];
      else
        throw Error(`Cannot find column '${S}'.`);
    return P;
  }
  Z.pickColumns = $;
  function X(T, w) {
    let V = Object.keys(w);
    return { _rowCount: w[V[0]].rowCount, _columns: V, _schema: T, ...w };
  }
  Z.ofColumns = X;
  function Y(T, w, V) {
    let P = Object.create(null), I = Object.keys(T);
    P._rowCount = V, P._columns = I, P._schema = T;
    for (let S of I)
      if (S in w)
        P[S] = w[S];
      else
        P[S] = s.Undefined(V, T[S]);
    return P;
  }
  Z.ofPartialColumns = Y;
  function Q(T, w) {
    let V = Object.create(null), P = Object.keys(T);
    V._rowCount = w, V._columns = P, V._schema = T;
    for (let I of P)
      V[I] = s.Undefined(w, T[I]);
    return V;
  }
  Z.ofUndefinedColumns = Q;
  function W(T, w) {
    let V = Object.create(null), P = w.length, I = Object.keys(T);
    V._rowCount = P, V._columns = I, V._schema = T;
    for (let S of I)
      V[S] = s.ofLambda({
        rowCount: P,
        schema: T[S],
        value: (f) => w[f][S],
        valueKind: (f) => typeof w[f][S] === "undefined" ? s.ValueKinds.NotPresent : s.ValueKinds.Present
      });
    return V;
  }
  Z.ofRows = W;
  function K(T, w) {
    var V;
    let P = Object.create(null), I = Object.keys(T);
    P._rowCount = 0, P._columns = I, P._schema = T;
    for (let S of I)
      if (typeof w[S] !== "undefined")
        P[S] = s.ofArray({ array: w[S], schema: T[S] }), P._rowCount = (V = w[S]) === null || V === void 0 ? void 0 : V.length;
      else
        P[S] = s.Undefined(P._rowCount, T[S]);
    return P;
  }
  Z.ofArrays = K;
  function G(T, w, V) {
    let P = Object.create(null), I = Object.keys(w);
    P._rowCount = V.length, P._columns = I, P._schema = w;
    for (let S of I)
      P[S] = s.view(T[S], V);
    return P;
  }
  Z.view = G;
  function H(T, w, V) {
    let P = [];
    for (let I = 0, S = T._rowCount;I < S; ++I)
      if (V(I))
        P.push(I);
    return G(T, w, P);
  }
  Z.pick = H;
  function N(T, w, V, P) {
    if (V === 0 && P === T._rowCount)
      return T;
    let I = Object.create(null), S = Object.keys(w);
    I._rowCount = P - V, I._columns = S, I._schema = w;
    for (let f of S)
      I[f] = s.window(T[f], V, P);
    return I;
  }
  Z.window = N;
  function q(T, w) {
    let V = Object.create(null), P = Object.keys(w);
    V._rowCount = 0;
    for (let f of T)
      V._rowCount += f._rowCount;
    let I = {};
    for (let f of P)
      I[f] = new Array(V._rowCount);
    V._columns = P, V._schema = w;
    let S = 0;
    for (let f of T) {
      for (let v of P)
        s.copyToArray(f[v], I[v], S);
      S += f._rowCount;
    }
    for (let f of P)
      V[f] = s.ofArray({ array: I[f], schema: w[f] });
    return V;
  }
  Z.concat = q;
  function U(T, w, V) {
    T[w] = s.asArrayColumn(T[w], V);
  }
  Z.columnToArray = U;
  function F(T, w) {
    let V = new Int32Array(T._rowCount);
    for (let S = 0, f = V.length;S < f; S++)
      V[S] = S;
    t$(V, (S, f, v) => w(f, v));
    let P = !0;
    for (let S = 0, f = V.length;S < f; S++)
      if (V[S] !== S) {
        P = !1;
        break;
      }
    if (P)
      return T;
    let I = Object.create(null);
    I._rowCount = T._rowCount, I._columns = T._columns, I._schema = T._schema;
    for (let S of T._columns)
      I[S] = s.view(T[S], V, !1);
    return I;
  }
  Z.sort = F;
  function E(T, w) {
    if (T._rowCount !== w._rowCount)
      return !1;
    if (T._columns.length !== w._columns.length)
      return !1;
    for (let V of T._columns)
      if (!w[V])
        return !1;
    for (let V of T._columns)
      if (!s.areEqual(T[V], w[V]))
        return !1;
    return !0;
  }
  Z.areEqual = E;
  function R(T, w) {
    let V = Object.create(null), { _columns: P } = T;
    for (let I = 0;I < P.length; I++) {
      let S = P[I];
      V[S] = T[S].value(w);
    }
    return V;
  }
  Z.getRow = R;
  function z(T, w) {
    for (let V = 0, P = T._rowCount;V < P; ++V)
      if (w(V))
        return R(T, V);
  }
  Z.pickRow = z;
  function D(T) {
    let w = [], { _rowCount: V } = T;
    for (let P = 0;P < V; P++)
      w[P] = R(T, P);
    return w;
  }
  Z.getRows = D;
  function A(T) {
    let w = {}, { _columns: V } = T;
    for (let P = 0;P < V.length; P++) {
      let I = V[P];
      w[I] = T[I].toArray();
    }
    return w;
  }
  Z.toArrays = A;
  function B(T) {
    let w = UZ.create(), { _columns: V, _rowCount: P } = T, I = 1;
    UZ.write(w, "|");
    for (let S = 0;S < V.length; S++)
      UZ.write(w, V[S]), UZ.write(w, "|"), I += V[S].length + 1;
    UZ.newline(w), UZ.write(w, new Array(I + 1).join("-")), UZ.newline(w);
    for (let S = 0;S < P; S++) {
      UZ.write(w, "|");
      for (let f = 0;f < V.length; f++) {
        let v = T[V[f]];
        if (v.valueKind(S) === s.ValueKinds.Present)
          UZ.write(w, v.value(S)), UZ.write(w, "|");
        else
          UZ.write(w, ".|");
      }
      UZ.newline(w);
    }
    return UZ.getString(w);
  }
  Z.formatToString = B;
})(A8 || (A8 = {}));

// node_modules/molstar/lib/mol-data/db/database.js
var y_;
(function(Z) {
  function J(X, Y, Q) {
    let W = Object.keys(Q), K = Object.create(null), G = [];
    K._name = X, K._tableNames = G, K._schema = Y;
    for (let H of W) {
      if (!A8.is(Q[H]))
        continue;
      K[H] = Q[H], G[G.length] = H;
    }
    return K;
  }
  Z.ofTables = J;
  function $(X) {
    let Y = {};
    for (let Q of X._tableNames)
      Y[Q] = A8.getRows(X[Q]);
    return Y;
  }
  Z.getTablesAsRows = $;
})(y_ || (y_ = {}));

// node_modules/molstar/lib/mol-model/structure/coordinates/coordinates.js
function N$(Z, J) {
  return { value: Z, unit: J };
}
var z5;
(function(Z) {
  function J(G, H, N) {
    let q = !!G[0].cell, U = !!G[0].velocities, F = !!G[0].forces;
    return {
      id: R6.create22(),
      frames: G,
      hasCell: q,
      hasVelocities: U,
      hasForces: F,
      deltaTime: H,
      timeOffset: N
    };
  }
  Z.create = J;
  function $(G, H, N) {
    var q, U;
    let { x: F, y: E, z: R } = G;
    if (G.xyzOrdering.frozen) {
      if (N) {
        if (G.xyzOrdering.isIdentity)
          F = W(F, N), E = W(E, N), R = W(R, N);
        else if (!b7(G.xyzOrdering.index, N))
          F = Q(F, G.xyzOrdering.index, N), E = Q(E, G.xyzOrdering.index, N), R = Q(R, G.xyzOrdering.index, N);
      } else if (!G.xyzOrdering.isIdentity)
        F = K(F, G.xyzOrdering.index), E = K(E, G.xyzOrdering.index), R = K(R, G.xyzOrdering.index);
    } else if (N) {
      if (G.xyzOrdering.isIdentity)
        G.xyzOrdering.isIdentity = !1, G.xyzOrdering.index = N, Y(F, N), Y(E, N), Y(R, N);
      else if (!b7(G.xyzOrdering.index, N))
        F = Q(F, G.xyzOrdering.index, N), E = Q(E, G.xyzOrdering.index, N), R = Q(R, G.xyzOrdering.index, N);
    }
    return G.xyzOrdering.frozen = !0, {
      id: R6.create22(),
      atomId: H.atomId,
      occupancy: (q = H.occupancy) !== null && q !== void 0 ? q : s.ofConst(1, G.elementCount, s.Schema.int),
      B_iso_or_equiv: (U = H.B_iso_or_equiv) !== null && U !== void 0 ? U : s.ofConst(0, G.elementCount, s.Schema.float),
      xyzDefined: !0,
      x: F,
      y: E,
      z: R
    };
  }
  Z.getAtomicConformation = $;
  let X = [0.123];
  function Y(G, H) {
    let N = X;
    for (let q = 0, U = G.length;q < U; q++)
      N[q] = G[H[q]];
    for (let q = 0, U = G.length;q < U; q++)
      G[q] = N[q];
  }
  function Q(G, H, N) {
    let q = new Float32Array(G.length);
    for (let U = 0, F = G.length;U < F; U++)
      q[U] = G[H[N[U]]];
    return q;
  }
  function W(G, H) {
    let N = new Float32Array(G.length);
    for (let q = 0, U = G.length;q < U; q++)
      N[q] = G[H[q]];
    return N;
  }
  function K(G, H) {
    let N = new Float32Array(G.length);
    for (let q = 0, U = G.length;q < U; q++)
      N[H[q]] = G[q];
    return N;
  }
})(z5 || (z5 = {}));
// node_modules/molstar/lib/mol-model/structure/topology/topology.js
var ER;
(function(Z) {
  function J($, X, Y, Q) {
    return {
      id: R6.create22(),
      label: $,
      basic: X,
      sourceData: Q,
      bonds: Y
    };
  }
  Z.create = J;
})(ER || (ER = {}));
// node_modules/molstar/lib/mol-io/reader/cif/schema/mmcif.js
var pF = s.Schema, z0 = pF.str, Z1 = pF.int, G6 = pF.float, Eo = pF.coord, S2 = pF.Aliased, OR = pF.Matrix, If = pF.Vector, G9 = pF.lstr, Wz = pF.List, Q6 = {
  atom_site: {
    auth_asym_id: z0,
    auth_atom_id: z0,
    auth_comp_id: z0,
    auth_seq_id: Z1,
    B_iso_or_equiv: G6,
    Cartn_x: Eo,
    Cartn_y: Eo,
    Cartn_z: Eo,
    group_PDB: S2(z0),
    id: Z1,
    label_alt_id: z0,
    label_asym_id: z0,
    label_atom_id: z0,
    label_comp_id: z0,
    label_entity_id: z0,
    label_seq_id: Z1,
    occupancy: G6,
    type_symbol: z0,
    pdbx_PDB_ins_code: z0,
    pdbx_PDB_model_num: Z1,
    pdbx_formal_charge: Z1,
    pdbx_label_index: Z1,
    pdbx_sifts_xref_db_name: z0,
    pdbx_sifts_xref_db_acc: z0,
    pdbx_sifts_xref_db_num: z0,
    pdbx_sifts_xref_db_res: z0,
    ihm_model_id: Z1
  },
  atom_site_anisotrop: {
    id: Z1,
    type_symbol: z0,
    U: OR(3, 3),
    U_esd: OR(3, 3),
    pdbx_auth_seq_id: Z1,
    pdbx_auth_asym_id: z0,
    pdbx_auth_atom_id: z0,
    pdbx_auth_comp_id: z0,
    pdbx_label_seq_id: Z1,
    pdbx_label_alt_id: z0,
    pdbx_label_asym_id: z0,
    pdbx_label_atom_id: z0,
    pdbx_label_comp_id: z0,
    pdbx_PDB_ins_code: z0
  },
  atom_sites: {
    entry_id: z0,
    fract_transf_matrix: OR(3, 3),
    fract_transf_vector: If(3)
  },
  audit_author: {
    name: z0,
    pdbx_ordinal: Z1,
    identifier_ORCID: z0
  },
  audit_conform: {
    dict_location: z0,
    dict_name: z0,
    dict_version: z0
  },
  cell: {
    angle_alpha: G6,
    angle_beta: G6,
    angle_gamma: G6,
    entry_id: z0,
    length_a: G6,
    length_b: G6,
    length_c: G6,
    Z_PDB: Z1,
    pdbx_unique_axis: z0
  },
  chem_comp: {
    formula: z0,
    formula_weight: G6,
    id: z0,
    mon_nstd_flag: S2(G9),
    name: z0,
    type: S2(G9),
    pdbx_synonyms: Wz(";", (Z) => Z)
  },
  chem_comp_bond: {
    atom_id_1: z0,
    atom_id_2: z0,
    comp_id: z0,
    value_order: S2(G9),
    pdbx_ordinal: Z1,
    pdbx_stereo_config: S2(G9),
    pdbx_aromatic_flag: S2(G9)
  },
  citation: {
    book_publisher: z0,
    country: z0,
    id: z0,
    journal_abbrev: z0,
    journal_id_ASTM: z0,
    journal_id_CSD: z0,
    journal_id_ISSN: z0,
    journal_volume: z0,
    page_first: z0,
    page_last: z0,
    title: z0,
    year: Z1,
    pdbx_database_id_DOI: z0,
    pdbx_database_id_PubMed: Z1
  },
  citation_author: {
    citation_id: z0,
    name: z0,
    ordinal: Z1
  },
  database_2: {
    database_id: S2(G9),
    database_code: z0
  },
  entity: {
    details: z0,
    formula_weight: G6,
    id: z0,
    src_method: S2(G9),
    type: S2(G9),
    pdbx_description: Wz(",", (Z) => Z),
    pdbx_number_of_molecules: Z1,
    pdbx_parent_entity_id: z0,
    pdbx_mutation: z0,
    pdbx_fragment: z0,
    pdbx_ec: Wz(",", (Z) => Z)
  },
  entity_poly: {
    entity_id: z0,
    nstd_linkage: S2(G9),
    nstd_monomer: S2(G9),
    type: S2(z0),
    pdbx_strand_id: Wz(",", (Z) => Z),
    pdbx_seq_one_letter_code: z0,
    pdbx_seq_one_letter_code_can: z0,
    pdbx_target_identifier: z0
  },
  entity_poly_seq: {
    entity_id: z0,
    hetero: S2(G9),
    mon_id: z0,
    num: Z1
  },
  entry: {
    id: z0
  },
  exptl: {
    entry_id: z0,
    method: S2(z0)
  },
  software: {
    classification: z0,
    date: z0,
    description: z0,
    name: z0,
    type: S2(G9),
    version: z0,
    pdbx_ordinal: Z1
  },
  struct: {
    entry_id: z0,
    title: z0,
    pdbx_structure_determination_methodology: S2(z0),
    pdbx_descriptor: z0
  },
  struct_asym: {
    details: z0,
    entity_id: z0,
    id: z0,
    pdbx_modified: z0,
    pdbx_blank_PDB_chainid_flag: S2(z0)
  },
  struct_conf: {
    beg_label_asym_id: z0,
    beg_label_comp_id: z0,
    beg_label_seq_id: Z1,
    beg_auth_asym_id: z0,
    beg_auth_comp_id: z0,
    beg_auth_seq_id: Z1,
    conf_type_id: S2(G9),
    details: z0,
    end_label_asym_id: z0,
    end_label_comp_id: z0,
    end_label_seq_id: Z1,
    end_auth_asym_id: z0,
    end_auth_comp_id: z0,
    end_auth_seq_id: Z1,
    id: z0,
    pdbx_beg_PDB_ins_code: z0,
    pdbx_end_PDB_ins_code: z0,
    pdbx_PDB_helix_class: z0,
    pdbx_PDB_helix_length: Z1,
    pdbx_PDB_helix_id: z0
  },
  struct_conn: {
    conn_type_id: S2(G9),
    details: z0,
    id: z0,
    ptnr1_label_asym_id: z0,
    ptnr1_label_atom_id: z0,
    ptnr1_label_comp_id: z0,
    ptnr1_label_seq_id: Z1,
    ptnr1_auth_asym_id: z0,
    ptnr1_auth_comp_id: z0,
    ptnr1_auth_seq_id: Z1,
    ptnr1_symmetry: z0,
    ptnr2_label_asym_id: z0,
    ptnr2_label_atom_id: z0,
    ptnr2_label_comp_id: z0,
    ptnr2_label_seq_id: Z1,
    ptnr2_auth_asym_id: z0,
    ptnr2_auth_comp_id: z0,
    ptnr2_auth_seq_id: Z1,
    ptnr2_symmetry: z0,
    pdbx_ptnr1_PDB_ins_code: z0,
    pdbx_ptnr1_label_alt_id: z0,
    pdbx_ptnr1_standard_comp_id: z0,
    pdbx_ptnr2_PDB_ins_code: z0,
    pdbx_ptnr2_label_alt_id: z0,
    pdbx_ptnr3_PDB_ins_code: z0,
    pdbx_ptnr3_label_alt_id: z0,
    pdbx_ptnr3_label_asym_id: z0,
    pdbx_ptnr3_label_atom_id: z0,
    pdbx_ptnr3_label_comp_id: z0,
    pdbx_ptnr3_label_seq_id: Z1,
    pdbx_PDB_id: z0,
    pdbx_dist_value: G6,
    pdbx_value_order: S2(G9)
  },
  struct_conn_type: {
    criteria: z0,
    id: S2(G9),
    reference: z0
  },
  struct_keywords: {
    entry_id: z0,
    text: Wz(",", (Z) => Z),
    pdbx_keywords: z0
  },
  struct_mon_prot_cis: {
    label_alt_id: z0,
    label_asym_id: z0,
    label_comp_id: z0,
    label_seq_id: Z1,
    auth_asym_id: z0,
    auth_comp_id: z0,
    auth_seq_id: Z1,
    pdbx_auth_asym_id_2: z0,
    pdbx_auth_comp_id_2: z0,
    pdbx_auth_seq_id_2: Z1,
    pdbx_label_asym_id_2: z0,
    pdbx_label_comp_id_2: z0,
    pdbx_label_seq_id_2: Z1,
    pdbx_PDB_ins_code: z0,
    pdbx_PDB_ins_code_2: z0,
    pdbx_PDB_model_num: Z1,
    pdbx_omega_angle: z0,
    pdbx_id: z0,
    pdbx_auth_ins_code: z0,
    pdbx_auth_ins_code_2: z0
  },
  struct_ncs_oper: {
    code: S2(z0),
    details: z0,
    id: Z1,
    matrix: OR(3, 3),
    vector: If(3)
  },
  struct_sheet_range: {
    beg_label_asym_id: z0,
    beg_label_comp_id: z0,
    beg_label_seq_id: Z1,
    end_label_asym_id: z0,
    end_label_comp_id: z0,
    end_label_seq_id: Z1,
    beg_auth_asym_id: z0,
    beg_auth_comp_id: z0,
    beg_auth_seq_id: Z1,
    end_auth_asym_id: z0,
    end_auth_comp_id: z0,
    end_auth_seq_id: Z1,
    id: z0,
    sheet_id: z0,
    pdbx_beg_PDB_ins_code: z0,
    pdbx_end_PDB_ins_code: z0
  },
  struct_site: {
    details: z0,
    id: z0,
    pdbx_num_residues: Z1,
    pdbx_evidence_code: z0,
    pdbx_auth_asym_id: z0,
    pdbx_auth_comp_id: z0,
    pdbx_auth_seq_id: Z1,
    pdbx_auth_ins_code: z0
  },
  struct_site_gen: {
    details: z0,
    id: z0,
    label_alt_id: z0,
    label_asym_id: z0,
    label_atom_id: z0,
    label_comp_id: z0,
    label_seq_id: Z1,
    auth_asym_id: z0,
    auth_atom_id: z0,
    auth_comp_id: z0,
    auth_seq_id: Z1,
    site_id: z0,
    symmetry: z0,
    pdbx_auth_ins_code: z0,
    pdbx_num_res: Z1
  },
  struct_site_keywords: {
    site_id: z0,
    text: z0
  },
  symmetry: {
    entry_id: z0,
    cell_setting: S2(G9),
    Int_Tables_number: Z1,
    space_group_name_Hall: z0,
    "space_group_name_H-M": z0
  },
  pdbx_database_status: {
    status_code: S2(z0),
    status_code_sf: S2(z0),
    status_code_mr: S2(z0),
    entry_id: z0,
    recvd_initial_deposition_date: z0,
    SG_entry: S2(G9),
    deposit_site: S2(z0),
    process_site: S2(z0),
    status_code_cs: S2(z0),
    methods_development_category: S2(z0),
    pdb_format_compatible: S2(G9)
  },
  pdbx_nonpoly_scheme: {
    asym_id: z0,
    entity_id: z0,
    mon_id: z0,
    pdb_strand_id: z0,
    ndb_seq_num: z0,
    pdb_seq_num: z0,
    auth_seq_num: z0,
    pdb_mon_id: z0,
    auth_mon_id: z0,
    pdb_ins_code: z0
  },
  pdbx_database_related: {
    db_name: S2(z0),
    details: z0,
    db_id: z0,
    content_type: S2(z0)
  },
  pdbx_entity_nonpoly: {
    entity_id: z0,
    comp_id: z0,
    name: z0
  },
  pdbx_chem_comp_synonyms: {
    name: z0,
    comp_id: z0,
    provenance: S2(z0)
  },
  pdbx_chem_comp_identifier: {
    comp_id: z0,
    identifier: z0,
    type: S2(z0),
    program: z0,
    program_version: z0
  },
  pdbx_unobs_or_zero_occ_residues: {
    id: Z1,
    polymer_flag: S2(G9),
    occupancy_flag: S2(Z1),
    PDB_model_num: Z1,
    auth_asym_id: z0,
    auth_comp_id: z0,
    auth_seq_id: Z1,
    PDB_ins_code: z0,
    label_asym_id: z0,
    label_comp_id: z0,
    label_seq_id: Z1
  },
  pdbx_struct_mod_residue: {
    id: Z1,
    auth_asym_id: z0,
    auth_comp_id: z0,
    auth_seq_id: Z1,
    PDB_ins_code: z0,
    label_asym_id: z0,
    label_comp_id: z0,
    label_seq_id: Z1,
    parent_comp_id: z0,
    details: z0
  },
  pdbx_struct_oper_list: {
    id: z0,
    type: S2(z0),
    name: z0,
    symmetry_operation: z0,
    matrix: OR(3, 3),
    vector: If(3)
  },
  pdbx_struct_assembly: {
    method_details: z0,
    oligomeric_details: z0,
    oligomeric_count: Z1,
    details: z0,
    id: z0
  },
  pdbx_struct_assembly_gen: {
    asym_id_list: Wz(",", (Z) => Z),
    assembly_id: z0,
    oper_expression: z0
  },
  pdbx_reference_entity_list: {
    prd_id: z0,
    ref_entity_id: z0,
    type: S2(G9),
    details: z0,
    component_id: Z1
  },
  pdbx_reference_entity_link: {
    link_id: Z1,
    prd_id: z0,
    details: z0,
    ref_entity_id_1: z0,
    ref_entity_id_2: z0,
    entity_seq_num_1: Z1,
    entity_seq_num_2: Z1,
    comp_id_1: z0,
    comp_id_2: z0,
    atom_id_1: z0,
    atom_id_2: z0,
    value_order: S2(G9),
    component_1: Z1,
    component_2: Z1,
    link_class: S2(z0)
  },
  pdbx_reference_entity_poly_link: {
    link_id: Z1,
    prd_id: z0,
    ref_entity_id: z0,
    component_id: Z1,
    entity_seq_num_1: Z1,
    entity_seq_num_2: Z1,
    comp_id_1: z0,
    comp_id_2: z0,
    atom_id_1: z0,
    atom_id_2: z0,
    value_order: S2(G9)
  },
  pdbx_molecule: {
    prd_id: z0,
    instance_id: Z1,
    asym_id: z0
  },
  pdbx_molecule_features: {
    prd_id: z0,
    class: S2(G9),
    type: S2(G9),
    name: z0,
    details: z0
  },
  entity_src_nat: {
    entity_id: z0,
    pdbx_organism_scientific: z0,
    pdbx_plasmid_name: z0,
    pdbx_src_id: Z1,
    pdbx_beg_seq_num: Z1,
    pdbx_end_seq_num: Z1
  },
  entity_src_gen: {
    entity_id: z0,
    pdbx_gene_src_gene: Wz(",", (Z) => Z),
    pdbx_gene_src_scientific_name: z0,
    plasmid_name: z0,
    pdbx_src_id: Z1,
    pdbx_beg_seq_num: Z1,
    pdbx_end_seq_num: Z1
  },
  pdbx_entity_src_syn: {
    organism_scientific: z0,
    entity_id: z0,
    pdbx_src_id: Z1,
    pdbx_beg_seq_num: Z1,
    pdbx_end_seq_num: Z1
  },
  pdbx_entity_branch_descriptor: {
    entity_id: z0,
    descriptor: z0,
    type: S2(G9),
    program: z0,
    program_version: z0,
    ordinal: Z1
  },
  pdbx_entity_instance_feature: {
    details: z0,
    feature_type: S2(z0),
    auth_asym_id: z0,
    asym_id: z0,
    auth_seq_num: z0,
    seq_num: Z1,
    comp_id: z0,
    auth_comp_id: z0,
    ordinal: Z1
  },
  pdbx_entity_branch_list: {
    entity_id: z0,
    hetero: S2(G9),
    comp_id: z0,
    num: Z1
  },
  pdbx_entity_branch_link: {
    link_id: Z1,
    details: z0,
    entity_id: z0,
    entity_branch_list_num_1: Z1,
    entity_branch_list_num_2: Z1,
    comp_id_1: z0,
    comp_id_2: z0,
    atom_id_1: z0,
    leaving_atom_id_1: z0,
    atom_stereo_config_1: S2(G9),
    atom_id_2: z0,
    leaving_atom_id_2: z0,
    atom_stereo_config_2: S2(G9),
    value_order: S2(G9)
  },
  pdbx_entity_branch: {
    entity_id: z0,
    type: S2(z0)
  },
  pdbx_branch_scheme: {
    entity_id: z0,
    hetero: S2(G9),
    asym_id: z0,
    mon_id: z0,
    num: Z1,
    pdb_asym_id: z0,
    pdb_seq_num: z0,
    pdb_mon_id: z0,
    auth_asym_id: z0,
    auth_seq_num: z0,
    auth_mon_id: z0
  },
  pdbx_chem_comp_related: {
    comp_id: z0,
    related_comp_id: z0,
    relationship_type: S2(z0),
    details: z0
  },
  ihm_starting_model_details: {
    starting_model_id: z0,
    entity_id: z0,
    entity_description: z0,
    asym_id: z0,
    entity_poly_segment_id: Z1,
    starting_model_source: S2(z0),
    starting_model_auth_asym_id: z0,
    starting_model_sequence_offset: Z1,
    dataset_list_id: Z1
  },
  ihm_starting_comparative_models: {
    id: Z1,
    starting_model_id: z0,
    starting_model_auth_asym_id: z0,
    starting_model_seq_id_begin: Z1,
    starting_model_seq_id_end: Z1,
    template_auth_asym_id: z0,
    template_seq_id_begin: Z1,
    template_seq_id_end: Z1,
    template_sequence_identity: G6,
    template_sequence_identity_denominator: S2(Z1),
    template_dataset_list_id: Z1,
    alignment_file_id: Z1
  },
  ihm_starting_model_seq_dif: {
    id: Z1,
    entity_id: z0,
    asym_id: z0,
    seq_id: Z1,
    comp_id: z0,
    starting_model_id: z0,
    db_asym_id: z0,
    db_seq_id: Z1,
    db_comp_id: z0,
    details: z0
  },
  ihm_model_representation: {
    id: Z1,
    name: z0,
    details: z0
  },
  ihm_model_representation_details: {
    id: Z1,
    representation_id: Z1,
    entity_poly_segment_id: Z1,
    entity_id: z0,
    entity_description: z0,
    entity_asym_id: z0,
    model_object_primitive: S2(z0),
    starting_model_id: z0,
    model_mode: S2(z0),
    model_granularity: S2(z0),
    model_object_count: Z1
  },
  ihm_struct_assembly_details: {
    id: Z1,
    assembly_id: Z1,
    parent_assembly_id: Z1,
    entity_description: z0,
    entity_id: z0,
    asym_id: z0,
    entity_poly_segment_id: Z1
  },
  ihm_struct_assembly: {
    id: Z1,
    name: z0,
    description: z0
  },
  ihm_modeling_protocol: {
    id: Z1,
    num_steps: Z1,
    protocol_name: z0
  },
  ihm_modeling_protocol_details: {
    id: Z1,
    protocol_id: Z1,
    step_id: Z1,
    struct_assembly_id: Z1,
    dataset_group_id: Z1,
    struct_assembly_description: z0,
    step_name: z0,
    step_method: z0,
    num_models_begin: Z1,
    num_models_end: Z1,
    multi_scale_flag: S2(G9),
    multi_state_flag: S2(G9),
    ordered_flag: S2(G9),
    script_file_id: Z1,
    software_id: Z1
  },
  ihm_multi_state_modeling: {
    state_id: Z1,
    state_group_id: Z1,
    population_fraction: G6,
    population_fraction_sd: G6,
    state_type: z0,
    state_name: z0,
    experiment_type: S2(z0),
    details: z0
  },
  ihm_modeling_post_process: {
    id: Z1,
    protocol_id: Z1,
    analysis_id: Z1,
    step_id: Z1,
    type: S2(z0),
    feature: S2(z0),
    num_models_begin: Z1,
    num_models_end: Z1
  },
  ihm_ensemble_info: {
    ensemble_id: Z1,
    ensemble_name: z0,
    post_process_id: Z1,
    model_group_id: Z1,
    ensemble_clustering_method: S2(z0),
    ensemble_clustering_feature: S2(z0),
    num_ensemble_models: Z1,
    num_ensemble_models_deposited: Z1,
    ensemble_precision_value: G6,
    ensemble_file_id: Z1
  },
  ihm_model_list: {
    model_id: Z1,
    model_name: z0,
    assembly_id: Z1,
    protocol_id: Z1,
    representation_id: Z1
  },
  ihm_model_group: {
    id: Z1,
    name: z0,
    details: z0
  },
  ihm_model_group_link: {
    model_id: Z1,
    group_id: Z1
  },
  ihm_model_representative: {
    id: Z1,
    model_group_id: Z1,
    model_id: Z1,
    selection_criteria: S2(z0)
  },
  ihm_dataset_list: {
    id: Z1,
    data_type: S2(z0),
    database_hosted: S2(G9)
  },
  ihm_dataset_group: {
    id: Z1,
    name: z0,
    application: S2(z0),
    details: z0
  },
  ihm_dataset_group_link: {
    dataset_list_id: Z1,
    group_id: Z1
  },
  ihm_related_datasets: {
    dataset_list_id_derived: Z1,
    dataset_list_id_primary: Z1
  },
  ihm_dataset_related_db_reference: {
    id: Z1,
    dataset_list_id: Z1,
    db_name: S2(z0),
    accession_code: z0,
    version: z0,
    details: z0
  },
  ihm_external_reference_info: {
    reference_id: Z1,
    reference_provider: z0,
    reference_type: S2(z0),
    reference: z0,
    refers_to: S2(z0),
    associated_url: z0
  },
  ihm_external_files: {
    id: Z1,
    reference_id: Z1,
    file_path: z0,
    content_type: S2(z0),
    file_size_bytes: G6,
    details: z0
  },
  ihm_dataset_external_reference: {
    id: Z1,
    dataset_list_id: Z1,
    file_id: Z1
  },
  ihm_localization_density_files: {
    id: Z1,
    file_id: Z1,
    ensemble_id: Z1,
    entity_id: z0,
    entity_poly_segment_id: Z1,
    asym_id: z0
  },
  ihm_predicted_contact_restraint: {
    id: Z1,
    group_id: Z1,
    entity_id_1: z0,
    entity_id_2: z0,
    asym_id_1: z0,
    asym_id_2: z0,
    comp_id_1: z0,
    comp_id_2: z0,
    seq_id_1: Z1,
    seq_id_2: Z1,
    rep_atom_1: S2(z0),
    rep_atom_2: S2(z0),
    distance_lower_limit: G6,
    distance_upper_limit: G6,
    probability: G6,
    restraint_type: S2(z0),
    model_granularity: S2(z0),
    dataset_list_id: Z1,
    software_id: Z1
  },
  ihm_cross_link_list: {
    id: Z1,
    group_id: Z1,
    entity_description_1: z0,
    entity_description_2: z0,
    entity_id_1: z0,
    entity_id_2: z0,
    comp_id_1: z0,
    comp_id_2: z0,
    seq_id_1: Z1,
    seq_id_2: Z1,
    linker_type: S2(z0),
    dataset_list_id: Z1
  },
  ihm_cross_link_restraint: {
    id: Z1,
    group_id: Z1,
    entity_id_1: z0,
    entity_id_2: z0,
    asym_id_1: z0,
    asym_id_2: z0,
    comp_id_1: z0,
    comp_id_2: z0,
    seq_id_1: Z1,
    seq_id_2: Z1,
    atom_id_1: z0,
    atom_id_2: z0,
    restraint_type: S2(z0),
    conditional_crosslink_flag: S2(z0),
    model_granularity: S2(z0),
    distance_threshold: G6,
    psi: G6,
    sigma_1: G6,
    sigma_2: G6
  },
  ihm_cross_link_result_parameters: {
    id: Z1,
    restraint_id: Z1,
    model_id: Z1,
    psi: G6,
    sigma_1: G6,
    sigma_2: G6
  },
  ihm_2dem_class_average_restraint: {
    id: Z1,
    dataset_list_id: Z1,
    number_raw_micrographs: Z1,
    pixel_size_width: G6,
    pixel_size_height: G6,
    image_resolution: G6,
    image_segment_flag: S2(G9),
    number_of_projections: Z1,
    struct_assembly_id: Z1,
    details: z0
  },
  ihm_2dem_class_average_fitting: {
    id: Z1,
    restraint_id: Z1,
    model_id: Z1,
    cross_correlation_coefficient: G6,
    rot_matrix: OR(3, 3),
    tr_vector: If(3)
  },
  ihm_3dem_restraint: {
    id: Z1,
    dataset_list_id: Z1,
    model_id: Z1,
    struct_assembly_id: Z1,
    fitting_method: z0,
    number_of_gaussians: Z1,
    cross_correlation_coefficient: G6
  },
  ihm_sas_restraint: {
    id: Z1,
    dataset_list_id: Z1,
    model_id: Z1,
    struct_assembly_id: Z1,
    profile_segment_flag: S2(G9),
    fitting_atom_type: z0,
    fitting_method: z0,
    fitting_state: S2(z0),
    radius_of_gyration: G6,
    chi_value: G6,
    details: z0
  },
  ihm_starting_model_coord: {
    ordinal_id: Z1,
    starting_model_id: z0,
    group_PDB: S2(z0),
    id: Z1,
    type_symbol: z0,
    entity_id: z0,
    atom_id: z0,
    comp_id: z0,
    seq_id: Z1,
    asym_id: z0,
    Cartn_x: G6,
    Cartn_y: G6,
    Cartn_z: G6,
    B_iso_or_equiv: G6
  },
  ihm_sphere_obj_site: {
    id: Z1,
    entity_id: z0,
    seq_id_begin: Z1,
    seq_id_end: Z1,
    asym_id: z0,
    Cartn_x: G6,
    Cartn_y: G6,
    Cartn_z: G6,
    object_radius: G6,
    rmsf: G6,
    model_id: Z1
  },
  ihm_gaussian_obj_site: {
    id: Z1,
    entity_id: z0,
    seq_id_begin: Z1,
    seq_id_end: Z1,
    asym_id: z0,
    mean_Cartn_x: G6,
    mean_Cartn_y: G6,
    mean_Cartn_z: G6,
    weight: G6,
    covariance_matrix: OR(3, 3),
    model_id: Z1
  },
  ihm_gaussian_obj_ensemble: {
    id: Z1,
    entity_id: z0,
    seq_id_begin: Z1,
    seq_id_end: Z1,
    asym_id: z0,
    mean_Cartn_x: G6,
    mean_Cartn_y: G6,
    mean_Cartn_z: G6,
    weight: G6,
    covariance_matrix: OR(3, 3),
    ensemble_id: Z1
  },
  ihm_feature_list: {
    feature_id: Z1,
    feature_type: S2(z0),
    entity_type: S2(z0)
  },
  ihm_poly_residue_feature: {
    ordinal_id: Z1,
    feature_id: Z1,
    entity_id: z0,
    asym_id: z0,
    comp_id_begin: z0,
    comp_id_end: z0,
    seq_id_begin: Z1,
    seq_id_end: Z1
  },
  ihm_derived_distance_restraint: {
    id: Z1,
    group_id: Z1,
    feature_id_1: Z1,
    feature_id_2: Z1,
    group_conditionality: S2(z0),
    random_exclusion_fraction: G6,
    distance_upper_limit: G6,
    restraint_type: S2(z0),
    dataset_list_id: Z1
  },
  ma_model_list: {
    ordinal_id: Z1,
    model_id: Z1,
    model_group_id: Z1,
    model_name: z0,
    model_group_name: z0,
    model_type: S2(z0),
    data_id: Z1
  },
  ma_target_entity: {
    entity_id: z0,
    data_id: Z1,
    origin: S2(z0)
  },
  ma_target_entity_instance: {
    asym_id: z0,
    entity_id: z0,
    details: z0
  },
  ma_target_ref_db_details: {
    target_entity_id: z0,
    db_name: S2(z0),
    db_code: z0,
    db_accession: z0,
    seq_db_isoform: z0,
    seq_db_align_begin: z0,
    seq_db_align_end: z0,
    ncbi_taxonomy_id: z0,
    organism_scientific: z0
  },
  ma_data: {
    id: Z1,
    content_type: S2(z0),
    content_type_other_details: z0,
    name: z0
  },
  ma_software_group: {
    ordinal_id: Z1,
    group_id: Z1,
    software_id: Z1
  },
  ma_qa_metric: {
    id: Z1,
    name: z0,
    type: S2(z0),
    mode: S2(z0),
    software_group_id: Z1
  },
  ma_qa_metric_global: {
    ordinal_id: Z1,
    model_id: Z1,
    metric_id: Z1,
    metric_value: G6
  },
  ma_qa_metric_local: {
    ordinal_id: Z1,
    model_id: Z1,
    label_asym_id: z0,
    label_seq_id: Z1,
    label_comp_id: z0,
    metric_id: Z1,
    metric_value: G6
  },
  ma_qa_metric_local_pairwise: {
    ordinal_id: Z1,
    model_id: Z1,
    label_asym_id_1: z0,
    label_seq_id_1: Z1,
    label_comp_id_1: z0,
    label_asym_id_2: z0,
    label_seq_id_2: Z1,
    label_comp_id_2: z0,
    metric_id: Z1,
    metric_value: G6
  }
};

// node_modules/molstar/lib/mol-model/structure/model/properties/atomic/hierarchy.js
var wH0 = {
  type_symbol: s.Schema.Aliased(Q6.atom_site.type_symbol),
  label_atom_id: Q6.atom_site.label_atom_id,
  auth_atom_id: Q6.atom_site.auth_atom_id,
  label_alt_id: Q6.atom_site.label_alt_id,
  label_comp_id: Q6.atom_site.label_comp_id,
  auth_comp_id: Q6.atom_site.auth_comp_id,
  pdbx_formal_charge: Q6.atom_site.pdbx_formal_charge
}, jH0 = {
  group_PDB: Q6.atom_site.group_PDB,
  label_seq_id: Q6.atom_site.label_seq_id,
  auth_seq_id: Q6.atom_site.auth_seq_id,
  pdbx_PDB_ins_code: Q6.atom_site.pdbx_PDB_ins_code
}, TH0 = {
  label_asym_id: Q6.atom_site.label_asym_id,
  auth_asym_id: Q6.atom_site.auth_asym_id,
  label_entity_id: Q6.atom_site.label_entity_id
}, Pf;
(function(Z) {
  function J() {
    return { label_entity_id: "", label_asym_id: "", auth_seq_id: 0, pdbx_PDB_ins_code: void 0 };
  }
  Z.EmptyResidueKey = J;
})(Pf || (Pf = {}));
var zR;
(function(Z) {
  function J(K, G) {
    return K.residueAtomSegments.index[K.chainAtomSegments.offsets[G]];
  }
  Z.chainStartResidueIndex = J;
  function $(K, G) {
    return K.residueAtomSegments.index[K.chainAtomSegments.offsets[G + 1] - 1] + 1;
  }
  Z.chainEndResidueIndexExcl = $;
  function X(K, G) {
    return $(K, G) - J(K, G);
  }
  Z.chainResidueCount = X;
  function Y(K, G) {
    return K.residueAtomSegments.offsets[G];
  }
  Z.residueFirstAtomIndex = Y;
  function Q(K, G) {
    return K.chainAtomSegments.index[G];
  }
  Z.atomChainIndex = Q;
  function W(K, G) {
    return K.chainAtomSegments.index[K.residueAtomSegments.offsets[G]];
  }
  Z.residueChainIndex = W;
})(zR || (zR = {}));
// node_modules/molstar/lib/mol-model/structure/model/properties/atomic/measures.js
var g_ = {
  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
}, Fe0 = {
  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
}, Ue0 = {
  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
};
function D5(Z) {
  let J = g_[Z];
  return J === void 0 ? 1.7 : Fe0[J];
}
function _H0(Z) {
  let J = g_[Z];
  return J === void 0 ? 10.81 : Ue0[J];
}
function DR(Z) {
  let J = g_[Z];
  return J === void 0 ? 0 : J;
}
// node_modules/molstar/lib/mol-model/structure/model/util.js
function VH0(Z, J) {
  let $ = [], X = [], Y = [];
  if (Z.x.length)
    $.push(...fQ(Z.x)), X.push(...fQ(Z.y)), Y.push(...fQ(Z.z));
  if (J) {
    if (J.spheres.x.length)
      $.push(...fQ(J.spheres.x)), X.push(...fQ(J.spheres.y)), Y.push(...fQ(J.spheres.z));
    if (J.gaussians.x.length)
      $.push(...fQ(J.gaussians.x)), X.push(...fQ(J.gaussians.y)), Y.push(...fQ(J.gaussians.z));
  }
  let [Q, W] = fQ($), [K, G] = fQ(X), [H, N] = fQ(Y), q = Q + (W - Q) / 2, U = K + (G - K) / 2, F = H + (N - H) / 2;
  return M.create(q, U, F);
}
function IH0(Z) {
  let J = /* @__PURE__ */ new Set, $ = /* @__PURE__ */ new Set;
  return Z.properties.structAsymMap.forEach(({ auth_id: X }, Y) => {
    J.add(X), $.add(Y);
  }), { auth: J.size, label: $.size };
}

// node_modules/molstar/lib/mol-data/util/chunked-array.js
var B1;
(function(Z) {
  function J(U) {
    return U.creator && U.chunkSize;
  }
  Z.is = J;
  function $(U) {
    let F = U.growBy * U.elementSize;
    U.currentSize = F, U.currentIndex = 0, U.currentChunk = new U.ctor(F), U.allocatedSize += F, U.chunks[U.chunks.length] = U.currentChunk;
  }
  function X(U, F, E, R, z) {
    if (U.currentIndex >= U.currentSize)
      $(U);
    let { currentChunk: D, currentIndex: A } = U;
    return D[A] = F, D[A + 1] = E, D[A + 2] = R, D[A + 3] = z, U.currentIndex += 4, U.elementCount++;
  }
  Z.add4 = X;
  function Y(U, F, E, R) {
    if (U.currentIndex >= U.currentSize)
      $(U);
    let { currentChunk: z, currentIndex: D } = U;
    return z[D] = F, z[D + 1] = E, z[D + 2] = R, U.currentIndex += 3, U.elementCount++;
  }
  Z.add3 = Y;
  function Q(U, F, E) {
    if (U.currentIndex >= U.currentSize)
      $(U);
    let { currentChunk: R, currentIndex: z } = U;
    return R[z] = F, R[z + 1] = E, U.currentIndex += 2, U.elementCount++;
  }
  Z.add2 = Q;
  function W(U, F) {
    if (U.currentIndex >= U.currentSize)
      $(U);
    return U.currentChunk[U.currentIndex] = F, U.currentIndex += 1, U.elementCount++;
  }
  Z.add = W;
  function K(U, F, E) {
    for (let R = 0;R < F; R++) {
      if (U.currentIndex >= U.currentSize)
        $(U);
      U.currentChunk[U.currentIndex++] = E, U.elementCount++;
    }
    return U.elementCount;
  }
  Z.addRepeat = K;
  function G(U, F) {
    let { elementSize: E } = U;
    for (let R = 0, z = F.length;R < z; R += E) {
      if (U.currentIndex >= U.currentSize)
        $(U);
      let { currentChunk: D } = U;
      for (let A = 0;A < E; A++)
        D[U.currentIndex++] = F[R + A];
      U.elementCount++;
    }
    return U.elementCount;
  }
  Z.addMany = G;
  function H(U, F = !1) {
    return N(U, F);
  }
  Z.compact = H;
  function N(U, F) {
    let { ctor: E, chunks: R, currentIndex: z } = U;
    if (!R.length)
      return new E(0);
    if (R.length === 1) {
      if (F || z === U.allocatedSize)
        return R[0];
    }
    let D = 0;
    for (let w = 0, V = R.length - 1;w < V; w++)
      D += R[w].length;
    D += U.currentIndex;
    let A = new E(D), B = 0;
    if (A.buffer)
      for (let w = 0, V = R.length - 1;w < V; w++)
        A.set(R[w], B), B += R[w].length;
    else
      for (let w = 0, V = R.length - 1;w < V; w++) {
        let P = R[w];
        for (let I = 0, S = P.length;I < S; I++)
          A[B + I] = P[I];
        B += P.length;
      }
    let T = R[R.length - 1];
    if (A.buffer && z >= U.currentSize)
      A.set(T, B);
    else
      for (let w = 0, V = T.length;w < V; w++)
        A[B + w] = T[w];
    return A;
  }
  Z._compact = N;
  function q(U, F, E, R) {
    let z = {
      ctor: U,
      elementSize: F,
      growBy: Math.max(1, Math.ceil(E)),
      allocatedSize: 0,
      elementCount: 0,
      currentSize: 0,
      currentChunk: void 0,
      currentIndex: 0,
      chunks: []
    };
    if (typeof R === "undefined")
      return z;
    if (typeof R === "number")
      return z.currentChunk = new U(R * F), z.allocatedSize = R * F, z.currentSize = z.currentChunk.length, z.chunks[0] = z.currentChunk, z;
    let D = R;
    if (D.length % F !== 0)
      throw new Error("initialChunk length must be a multiple of the element size.");
    return z.currentChunk = D, z.allocatedSize = D.length, z.currentSize = D.length, z.chunks[0] = D, z;
  }
  Z.create = q;
})(B1 || (B1 = {}));
// node_modules/molstar/lib/mol-data/util/buckets.js
function Le0(Z, J, $) {
  return Z[J].key < Z[$].key ? -1 : 1;
}
function Re0(Z, J, $, X, Y) {
  let Q = /* @__PURE__ */ new Map, W = [], K = J(Z[0]), G = !0;
  for (let F = X;F < Y; F++) {
    let E = J(Z[F]);
    if (Q.has(E)) {
      if (Q.get(E).count++, K !== E)
        G = !1;
    } else {
      let R = { key: E, count: 1, offset: F };
      Q.set(E, R), W[W.length] = R;
    }
    K = E;
  }
  let H = new Int32Array(W.length + 1);
  H[W.length] = Y;
  let N = !0;
  if ($) {
    for (let F = 1, E = W.length;F < E; F++)
      if (W[F - 1].key > W[F].key) {
        N = !1;
        break;
      }
  }
  if (G && N) {
    for (let F = 0;F < W.length; F++)
      H[F] = W[F].offset;
    return H;
  }
  if ($ && !N)
    Rf(W, 0, W.length, Le0, bF);
  let q = 0;
  for (let F = 0;F < W.length; F++) {
    let E = W[F];
    E.offset = q, q += E.count;
  }
  let U = new Int32Array(Y - X);
  for (let F = X;F < Y; F++) {
    let E = J(Z[F]), R = Q.get(E);
    U[R.offset++] = Z[F];
  }
  for (let F = 0, E = U.length;F < E; F++)
    Z[F + X] = U[F];
  H[0] = X;
  for (let F = 1;F < W.length; F++)
    H[F] = W[F - 1].offset + X;
  return H;
}
function Cf(Z, J, $) {
  let X = $ && $.start || 0, Y = $ && $.end || Z.length;
  if (Y - X <= 0)
    throw new Error("Can only bucket non-empty collections.");
  return Re0(Z, J, !!($ && $.sort), X, Y);
}
// node_modules/molstar/lib/mol-data/util/equivalence-classes.js
class PH0 {
  createGroup(Z, J) {
    let $ = this.id++, X = [Z];
    return this.groups[$] = X, { id: $, keys: X, value: J };
  }
  add(Z, J) {
    let $ = this.getHash(J);
    if (this.byHash.has($)) {
      let X = this.byHash.get($);
      for (let Q = 0, W = X.length;Q < W; Q++) {
        let K = X[Q];
        if (this.areEqual(J, K.value))
          return K.keys[K.keys.length] = Z, K.value;
      }
      let Y = this.createGroup(Z, J);
      return X[X.length] = Y, Y.value;
    } else {
      let X = this.createGroup(Z, J);
      return this.byHash.set($, [X]), X.value;
    }
  }
  constructor(Z, J) {
    this.getHash = Z, this.areEqual = J, this.id = 0, this.byHash = /* @__PURE__ */ new Map, this.groups = [];
  }
}
function CH0(Z, J) {
  return new PH0(Z, J);
}
// node_modules/molstar/lib/mol-math/graph/int-adjacency-graph.js
var lJ;
(function(Z) {
  function J(q, U) {
    if (q === U)
      return !0;
    if (q.vertexCount !== U.vertexCount || q.edgeCount !== U.edgeCount)
      return !1;
    let { a: F, b: E, offset: R } = q, { a: z, b: D, offset: A } = U;
    for (let B = 0, T = q.a.length;B < T; B++)
      if (F[B] !== z[B])
        return !1;
    for (let B = 0, T = q.b.length;B < T; B++)
      if (E[B] !== D[B])
        return !1;
    for (let B = 0, T = q.offset.length;B < T; B++)
      if (R[B] !== A[B])
        return !1;
    for (let B of Object.keys(q.edgeProps)) {
      let T = q.edgeProps[B], w = U.edgeProps[B];
      if (!w)
        return !1;
      for (let V = 0, P = T.length;V < P; V++)
        if (T[V] !== w[V])
          return !1;
    }
    return !0;
  }
  Z.areEqual = J;

  class $ {
    getEdgeIndex(q, U) {
      let F, E;
      if (q < U)
        F = q, E = U;
      else
        F = U, E = q;
      for (let R = this.offset[F], z = this.offset[F + 1];R < z; R++)
        if (this.b[R] === E)
          return R;
      return -1;
    }
    getDirectedEdgeIndex(q, U) {
      for (let F = this.offset[q], E = this.offset[q + 1];F < E; F++)
        if (this.b[F] === U)
          return F;
      return -1;
    }
    getVertexEdgeCount(q) {
      return this.offset[q + 1] - this.offset[q];
    }
    constructor(q, U, F, E, R, z) {
      this.offset = q, this.a = U, this.b = F, this.edgeCount = E, this.props = z, this.vertexCount = q.length - 1, this.edgeProps = R || {};
    }
  }
  function X(q, U, F, E, R, z) {
    return new $(q, U, F, E, R, z);
  }
  Z.create = X;

  class Y {
    createGraph(q, U) {
      return X(this.offsets, this.a, this.b, this.edgeCount, q, U);
    }
    addNextEdge() {
      let q = this.xs[this.current], U = this.ys[this.current], F = this.offsets[q] + this.bucketFill[q];
      this.a[F] = q, this.b[F] = U, this.bucketFill[q]++;
      let E = this.offsets[U] + this.bucketFill[U];
      this.a[E] = U, this.b[E] = q, this.bucketFill[U]++, this.current++, this.curA = F, this.curB = E;
    }
    addAllEdges() {
      for (let q = 0;q < this.edgeCount; q++)
        this.addNextEdge();
    }
    assignProperty(q, U) {
      q[this.curA] = U, q[this.curB] = U;
    }
    assignDirectedProperty(q, U, F, E) {
      q[this.curA] = U, q[this.curB] = E, F[this.curB] = U, F[this.curA] = E;
    }
    constructor(q, U, F) {
      this.vertexCount = q, this.xs = U, this.ys = F, this.current = 0, this.curA = 0, this.curB = 0, this.edgeCount = U.length, this.offsets = new Int32Array(this.vertexCount + 1), this.bucketFill = new Int32Array(this.vertexCount);
      let E = new Int32Array(this.vertexCount);
      for (let z = 0, D = this.xs.length;z < D; z++)
        E[this.xs[z]]++;
      for (let z = 0, D = this.ys.length;z < D; z++)
        E[this.ys[z]]++;
      let R = 0;
      for (let z = 0;z < this.vertexCount; z++)
        this.offsets[z] = R, R += E[z];
      this.offsets[this.vertexCount] = R, this.slotCount = R, this.a = new Int32Array(R), this.b = new Int32Array(R);
    }
  }
  Z.EdgeBuilder = Y;

  class Q {
    createGraph(q, U) {
      return X(this.offsets, this.a, this.b, this.edgeCount, q, U);
    }
    addNextEdge() {
      let q = this.xs[this.current], U = this.ys[this.current], F = this.offsets[q] + this.bucketFill[q];
      this.a[F] = q, this.b[F] = U, this.bucketFill[q]++, this.current++, this.curA = F;
    }
    addAllEdges() {
      for (let q = 0;q < this.edgeCount; q++)
        this.addNextEdge();
    }
    assignProperty(q, U) {
      q[this.curA] = U;
    }
    constructor(q, U, F) {
      this.vertexCount = q, this.xs = U, this.ys = F, this.current = 0, this.curA = 0, this.edgeCount = U.length, this.offsets = new Int32Array(this.vertexCount + 1), this.bucketFill = new Int32Array(this.vertexCount);
      let E = new Int32Array(this.vertexCount);
      for (let z = 0, D = this.xs.length;z < D; z++)
        E[this.xs[z]]++;
      let R = 0;
      for (let z = 0;z < this.vertexCount; z++)
        this.offsets[z] = R, R += E[z];
      this.offsets[this.vertexCount] = R, this.slotCount = R, this.a = new Int32Array(R), this.b = new Int32Array(R);
    }
  }
  Z.DirectedEdgeBuilder = Q;

  class W {
    addEdge(q, U) {
      let F = q, E = U;
      if (q > U)
        F = U, E = q;
      let R = ZJ(F, E);
      if (this.included.has(R))
        return !1;
      return this.included.add(R), this.xs[this.xs.length] = F, this.ys[this.ys.length] = E, !0;
    }
    getGraph() {
      return K(this.vertexCount, this.xs, this.ys);
    }
    getEdgeBuiler() {
      return new Y(this.vertexCount, this.xs, this.ys);
    }
    constructor(q) {
      this.vertexCount = q, this.xs = [], this.ys = [], this.included = /* @__PURE__ */ new Set;
    }
  }
  Z.UniqueEdgeBuilder = W;
  function K(q, U, F) {
    let E = new Z.EdgeBuilder(q, U, F);
    return E.addAllEdges(), E.createGraph({});
  }
  Z.fromVertexPairs = K;
  function G(q, U, F) {
    let { b: E, offset: R, vertexCount: z, edgeProps: D } = q, A = new Int32Array(z);
    for (let v = 0, h = U.length;v < h; v++)
      A[U[v]] = v + 1;
    let B = 0;
    for (let v = 0;v < z; v++) {
      if (A[v] === 0)
        continue;
      for (let h = R[v], x = R[v + 1];h < x; h++)
        if (E[h] > v && A[E[h]] !== 0)
          B++;
    }
    let T = new Int32Array(U.length + 1), w = new Int32Array(2 * B), V = new Int32Array(2 * B), P = new Int32Array(2 * B), I = 0, S = 0;
    for (let v = 0;v < z; v++) {
      if (A[v] === 0)
        continue;
      let h = A[v] - 1;
      for (let x = R[v], b = R[v + 1];x < b; x++) {
        let g = A[E[x]];
        if (g === 0)
          continue;
        V[I] = h, P[I] = g - 1, w[I] = x, I++;
      }
      T[++S] = I;
    }
    let f = {};
    for (let v of Object.keys(D))
      f[v] = SK0(D[v], w);
    return X(T, V, P, B, f, F);
  }
  Z.induceByVertices = G;
  function H(q) {
    let U = q.vertexCount;
    if (U === 0)
      return { componentCount: 0, componentIndex: new Int32Array(0) };
    if (q.edgeCount === 0) {
      let B = new Int32Array(U);
      for (let T = 0, w = U;T < w; T++)
        B[T] = T;
      return { componentCount: U, componentIndex: B };
    }
    let F = new Int32Array(U);
    for (let B = 0, T = U;B < T; B++)
      F[B] = -1;
    let E = 0;
    F[0] = E;
    let { offset: R, b: z } = q, D = [0], A = qo(U);
    A.remove(0);
    while (D.length > 0) {
      let B = D.pop(), T = F[B];
      for (let w = R[B], V = R[B + 1];w < V; w++) {
        let P = z[w];
        if (!A.has(P))
          continue;
        A.remove(P), D.push(P), F[P] = T;
      }
      if (D.length === 0 && A.head >= 0)
        D.push(A.head), F[A.head] = ++E, A.remove(A.head);
    }
    return { componentCount: U, componentIndex: F };
  }
  Z.connectedComponents = H;
  function N(q, U, F, E) {
    if (X1.areIntersecting(U, F))
      return !0;
    if (E < 1)
      return !1;
    let R = /* @__PURE__ */ new Set;
    for (let z = 0, D = U.length;z < D; ++z)
      R.add(U[z]);
    return kH0(q, U, F, E, R);
  }
  Z.areVertexSetsConnected = N;
})(lJ || (lJ = {}));
function kH0(Z, J, $, X, Y) {
  let { b: Q, offset: W } = Z, K = [];
  for (let G = 0, H = J.length;G < H; ++G) {
    let N = J[G];
    for (let q = W[N], U = W[N + 1];q < U; ++q) {
      let F = Q[q];
      if (Y.has(F))
        continue;
      if (X1.has($, F))
        return !0;
      Y.add(F), K[K.length] = F;
    }
  }
  return X > 1 ? kH0(Z, K, $, X - 1, Y) : !1;
}
// node_modules/molstar/lib/mol-model-formats/structure/common/property.js
class vH0 {
  constructor() {
    this.map = /* @__PURE__ */ new Map, this.applicable = /* @__PURE__ */ new Map;
  }
  add(Z, J, $) {
    if (this.map.set(Z, J), $)
      this.applicable.set(Z, $);
  }
  remove(Z) {
    this.map.delete(Z), this.applicable.delete(Z);
  }
  get(Z) {
    return this.map.get(Z);
  }
  isApplicable(Z) {
    if (!this.map.has(Z.sourceData.kind))
      return !1;
    let J = this.applicable.get(Z.sourceData.kind);
    return J ? J(Z) : !0;
  }
}
var e$;
(function(Z) {
  function J($, X) {
    let { name: Y } = $, Q = new vH0;
    return {
      descriptor: $,
      formatRegistry: Q,
      isApplicable(W) {
        return Q.isApplicable(W);
      },
      get(W) {
        let K = (X === null || X === void 0 ? void 0 : X.asDynamic) ? W._dynamicPropertyData : W._staticPropertyData;
        if (K[Y])
          return K[Y];
        if (W.customProperties.has($))
          return;
        let G = Q.get(W.sourceData.kind);
        if (!G)
          return;
        return K[Y] = G(W), W.customProperties.add($), K[Y];
      },
      set(W, K) {
        if (X === null || X === void 0 ? void 0 : X.asDynamic)
          W._dynamicPropertyData[Y] = K;
        else
          W._staticPropertyData[Y] = K;
      },
      delete(W) {
        if (X === null || X === void 0 ? void 0 : X.asDynamic)
          delete W._dynamicPropertyData[Y];
        else
          delete W._staticPropertyData[Y];
      }
    };
  }
  Z.create = J;
})(e$ || (e$ = {}));
// node_modules/molstar/lib/mol-util/legend.js
function ZX(Z) {
  return { kind: "table-legend", table: Z };
}
function SH0(Z, J, $) {
  return { kind: "scale-legend", minLabel: Z, maxLabel: J, colors: $ };
}

// node_modules/molstar/lib/mol-util/color/scale.js
var Oe0 = {
  domain: [0, 1],
  reverse: !1,
  listOrName: "red-yellow-blue",
  minLabel: "",
  maxLabel: ""
}, _J;
(function(Z) {
  function J(G) {
    return X(G, "continuous");
  }
  Z.create = J;
  function $(G) {
    return X(G, "discrete");
  }
  Z.createDiscrete = $;
  function X(G, H) {
    let { domain: N, reverse: q, listOrName: U } = { ...Oe0, ...G }, F = typeof U === "string" ? RJ(U).list : U, E = q ? F.slice().reverse() : F, R = 0, z = 0, D = 0;
    function A(P, I) {
      z = P, D = I, R = D - z || 1;
    }
    A(N[0], N[1]);
    let B = t7(G.minLabel, z.toString()), T = t7(G.maxLabel, D.toString()), w;
    if (E.every((P) => Array.isArray(P))) {
      let P = [...E];
      P.sort((v, h) => v[1] - h[1]);
      let I = P.map((v) => v[0]), S = X1.ofSortedArray(P.map((v) => v[1])), f = I.length - 1;
      switch (H) {
        case "continuous":
          w = (v) => Y(v, I, S, z, f, R);
          break;
        case "discrete":
          w = (v) => W(v, I, S, z, f, R);
          break;
      }
    } else
      switch (H) {
        case "continuous":
          w = (P) => Q(P, E, z, R);
          break;
        case "discrete":
          w = (P) => K(P, E, z, D, R);
          break;
      }
    return {
      color: w,
      colorToArray: (P, I, S) => {
        i0.toArray(w(P), I, S);
      },
      normalizedColorToArray: (P, I, S) => {
        i0.toArrayNormalized(w(P), I, S);
      },
      setDomain: A,
      get legend() {
        return SH0(B, T, E);
      }
    };
  }
  function Y(G, H, N, q, U, F) {
    let E = x8((G - q) / F, 0, 1), R = X1.findPredecessorIndex(N, E);
    if (R === 0)
      return H[0];
    else if (R > U)
      return H[U];
    let z = N[R - 1], D = N[R], A = x8((E - z) / (D - z), 0, 1);
    return i0.interpolate(H[R - 1], H[R], A);
  }
  function Q(G, H, N, q) {
    let U = Math.min(H.length - 1, Math.max(0, (G - N) / q * (H.length - 1))), F = Math.floor(U), E = H[F], R = H[Math.ceil(U)];
    return i0.interpolate(E, R, U - F);
  }
  function W(G, H, N, q, U, F) {
    if (H.length === 0)
      return i0.fromRgb(0, 0, 0);
    let E = x8((G - q) / F, 0, 1), R = X1.findPredecessorIndex(N, E);
    if (R === 0)
      return H[0];
    else if (R > U)
      return H[U];
    return H[R];
  }
  function K(G, H, N, q, U) {
    if (H.length === 0)
      return i0.fromRgb(0, 0, 0);
    let F = U / H.length;
    if (G <= N)
      return H[0];
    else if (G >= q)
      return H[H.length - 1];
    let E = Math.min(H.length - 1, Math.floor((G - N) / F));
    return H[E];
  }
})(_J || (_J = {}));
// node_modules/molstar/lib/mol-model/structure/model/types/saccharides.js
var Oo = /* @__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", "2SI", "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", "8I4", "8LM", "8LR", "8OQ", "8PK", "8S0", "8YV", "95Z", "96O", "98U", "9AM", "9C1", "9CD", "9GP", "9KJ", "9MR", "9OK", "9PG", "9QG", "9QZ", "9RN", "9S7", "9SG", "9SJ", "9SM", "9SP", "9T1", "9T7", "9VP", "9WJ", "9WN", "9WZ", "9YW", "A0K", "A1AIO", "A1APB", "A1APC", "A1APD", "A1CCV", "A1CCW", "A1EAX", "A1EFW", "A1EGT", "A1EGV", "A1EGW", "A1EGX", "A1EGY", "A1EJ0", "A1EJ2", "A1EKO", "A1EN6", "A1H03", "A1H0P", "A1H0Z", "A1H10", "A1H1B", "A1H1F", "A1H1V", "A1I9U", "A1ID6", "A1IH4", "A1IVP", "A1IZL", "A1JAQ", "A1L1P", "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", "BW3", "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", "ED6", "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", "HLA", "HMS", "HNV", "HNW", "HSG", "HSH", "HSJ", "HSQ", "HSR", "HSU", "HSX", "HSY", "HSZ", "HTG", "HTM", "HVC", "I57", "IAB", "IDC", "IDF", "IDG", "IDR", "IDS", "IDT", "IDU", "IDX", "IDY", "IEM", "IN1", "IPT", "ISD", "ISL", "ISX", "IVG", "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", "KQC", "KTU", "L1L", "L6N", "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", "N3U", "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", "NOJ", "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", "TY6", "TYV", "U1Y", "U2A", "U2D", "U63", "U8V", "U97", "U9A", "U9D", "U9G", "U9J", "U9M", "UAP", "UBH", "UBO", "UCD", "UDC", "UEA", "V3M", "V3P", "V71", "VDF", "VG1", "VJ1", "VJ4", "VKN", "VTB", "W9T", "WIA", "WKO", "WKT", "WOO", "WT8", "WUN", "WZ1", "WZ2", "WZ4", "X0X", "X1P", "X1X", "X2F", "X2Y", "X34", "X4S", "X5S", "X6N", "X6X", "X6Y", "X6Z", "XBP", "XDP", "XDX", "XGP", "XIL", "XIQ", "XKJ", "XLF", "XLS", "XMM", "XS2", "XUL", "XXM", "XXR", "XXX", "XY6", "XY9", "XYB", "XYF", "XYL", "XYP", "XYS", "XYT", "XYZ", "YDR", "YIO", "YJM", "YKR", "YO5", "YX0", "YX1", "YYB", "YYD", "YYH", "YYJ", "YYK", "YYM", "YYQ", "YYR", "YZ0", "YZT", "Z0F", "Z15", "Z16", "Z2D", "Z2T", "Z3K", "Z3L", "Z3Q", "Z3U", "Z4K", "Z4R", "Z4S", "Z4U", "Z4V", "Z4W", "Z4Y", "Z57", "Z5J", "Z5L", "Z61", "Z6G", "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"]);

// node_modules/molstar/lib/mol-model/structure/structure/carbohydrates/constants.js
var R9;
(function(Z) {
  Z[Z.FilledSphere = 0] = "FilledSphere", Z[Z.FilledCube = 1] = "FilledCube", Z[Z.CrossedCube = 2] = "CrossedCube", Z[Z.DividedDiamond = 3] = "DividedDiamond", Z[Z.FilledCone = 4] = "FilledCone", Z[Z.DevidedCone = 5] = "DevidedCone", Z[Z.FlatBox = 6] = "FlatBox", Z[Z.FilledStar = 7] = "FilledStar", Z[Z.FilledDiamond = 8] = "FilledDiamond", Z[Z.FlatDiamond = 9] = "FlatDiamond", Z[Z.FlatHexagon = 10] = "FlatHexagon", Z[Z.Pentagon = 11] = "Pentagon", Z[Z.DiamondPrism = 12] = "DiamondPrism", Z[Z.PentagonalPrism = 13] = "PentagonalPrism", Z[Z.HexagonalPrism = 14] = "HexagonalPrism", Z[Z.HeptagonalPrism = 15] = "HeptagonalPrism";
})(R9 || (R9 = {}));
var u2 = QQ({
  Blue: 37052,
  Green: 42577,
  Yellow: 16765952,
  Orange: 16021792,
  Pink: 16162465,
  Purple: 10830745,
  LightBlue: 9424105,
  Brown: 10582605,
  Red: 15539236,
  Secondary: 15854817
}), w2;
(function(Z) {
  Z[Z.Hexose = 0] = "Hexose", Z[Z.HexNAc = 1] = "HexNAc", Z[Z.Hexosamine = 2] = "Hexosamine", Z[Z.Hexuronate = 3] = "Hexuronate", Z[Z.Deoxyhexose = 4] = "Deoxyhexose", Z[Z.DeoxyhexNAc = 5] = "DeoxyhexNAc", Z[Z.DiDeoxyhexose = 6] = "DiDeoxyhexose", Z[Z.Pentose = 7] = "Pentose", Z[Z.Deoxynonulosonate = 8] = "Deoxynonulosonate", Z[Z.DiDeoxynonulosonate = 9] = "DiDeoxynonulosonate", Z[Z.Unknown = 10] = "Unknown", Z[Z.Assigned = 11] = "Assigned";
})(w2 || (w2 = {}));
var Ot1 = {
  [w2.Hexose]: "Hexose",
  [w2.HexNAc]: "HexNAc",
  [w2.Hexosamine]: "Hexosamine",
  [w2.Hexuronate]: "Hexuronate",
  [w2.Deoxyhexose]: "Deoxyhexose",
  [w2.DeoxyhexNAc]: "DeoxyhexNAc",
  [w2.DiDeoxyhexose]: "Di-deoxyhexose",
  [w2.Pentose]: "Pentose",
  [w2.Deoxynonulosonate]: "Deoxynonulosonate",
  [w2.DiDeoxynonulosonate]: "Di-deoxynonulosonate",
  [w2.Unknown]: "Unknown",
  [w2.Assigned]: "Assigned"
};
var ze0 = {
  [w2.Hexose]: R9.FilledSphere,
  [w2.HexNAc]: R9.FilledCube,
  [w2.Hexosamine]: R9.CrossedCube,
  [w2.Hexuronate]: R9.DividedDiamond,
  [w2.Deoxyhexose]: R9.FilledCone,
  [w2.DeoxyhexNAc]: R9.DevidedCone,
  [w2.DiDeoxyhexose]: R9.FlatBox,
  [w2.Pentose]: R9.FilledStar,
  [w2.Deoxynonulosonate]: R9.FilledDiamond,
  [w2.DiDeoxynonulosonate]: R9.FlatDiamond,
  [w2.Unknown]: R9.FlatHexagon,
  [w2.Assigned]: R9.Pentagon
};
function fH0(Z, J) {
  if (Z === w2.Unknown)
    if (J === 4)
      return R9.DiamondPrism;
    else if (J === 5)
      return R9.PentagonalPrism;
    else if (J === 6)
      return R9.HexagonalPrism;
    else if (J === 7)
      return R9.HeptagonalPrism;
    else
      return R9.FlatHexagon;
  else
    return ze0[Z];
}
var kf = {
  abbr: "Unk",
  name: "Unknown",
  color: u2.Secondary,
  type: w2.Unknown
}, yM = [
  { abbr: "Glc", name: "Glucose", color: u2.Blue, type: w2.Hexose },
  { abbr: "Man", name: "Mannose", color: u2.Green, type: w2.Hexose },
  { abbr: "Gal", name: "Galactose", color: u2.Yellow, type: w2.Hexose },
  { abbr: "Gul", name: "Gulose", color: u2.Orange, type: w2.Hexose },
  { abbr: "Alt", name: "Altrose", color: u2.Pink, type: w2.Hexose },
  { abbr: "All", name: "Allose", color: u2.Purple, type: w2.Hexose },
  { abbr: "Tal", name: "Talose", color: u2.LightBlue, type: w2.Hexose },
  { abbr: "Ido", name: "Idose", color: u2.Brown, type: w2.Hexose },
  { abbr: "GlcNAc", name: "N-Acetyl Glucosamine", color: u2.Blue, type: w2.HexNAc },
  { abbr: "ManNAc", name: "N-Acetyl Mannosamine", color: u2.Green, type: w2.HexNAc },
  { abbr: "GalNAc", name: "N-Acetyl Galactosamine", color: u2.Yellow, type: w2.HexNAc },
  { abbr: "GulNAc", name: "N-Acetyl Gulosamine", color: u2.Orange, type: w2.HexNAc },
  { abbr: "AltNAc", name: "N-Acetyl Altrosamine", color: u2.Pink, type: w2.HexNAc },
  { abbr: "AllNAc", name: "N-Acetyl Allosamine", color: u2.Purple, type: w2.HexNAc },
  { abbr: "TalNAc", name: "N-Acetyl Talosamine", color: u2.LightBlue, type: w2.HexNAc },
  { abbr: "IdoNAc", name: "N-Acetyl Idosamine", color: u2.Brown, type: w2.HexNAc },
  { abbr: "GlcN", name: "Glucosamine", color: u2.Blue, type: w2.Hexosamine },
  { abbr: "ManN", name: "Mannosamine", color: u2.Green, type: w2.Hexosamine },
  { abbr: "GalN", name: "Galactosamine", color: u2.Yellow, type: w2.Hexosamine },
  { abbr: "GulN", name: "Gulosamine", color: u2.Orange, type: w2.Hexosamine },
  { abbr: "AltN", name: "Altrosamine", color: u2.Pink, type: w2.Hexosamine },
  { abbr: "AllN", name: "Allosamine", color: u2.Purple, type: w2.Hexosamine },
  { abbr: "TalN", name: "Talosamine", color: u2.LightBlue, type: w2.Hexosamine },
  { abbr: "IdoN", name: "Idosamine", color: u2.Brown, type: w2.Hexosamine },
  { abbr: "GlcNS", name: "N-sulfo Glucosamine", color: u2.Blue, type: w2.Hexosamine },
  { abbr: "GlcA", name: "Glucuronic Acid", color: u2.Blue, type: w2.Hexuronate },
  { abbr: "ManA", name: "Mannuronic Acid", color: u2.Green, type: w2.Hexuronate },
  { abbr: "GalA", name: "Galacturonic Acid", color: u2.Yellow, type: w2.Hexuronate },
  { abbr: "GulA", name: "Guluronic Acid", color: u2.Orange, type: w2.Hexuronate },
  { abbr: "AltA", name: "Altruronic Acid", color: u2.Pink, type: w2.Hexuronate },
  { abbr: "AllA", name: "Alluronic Acid", color: u2.Purple, type: w2.Hexuronate },
  { abbr: "TalA", name: "Taluronic Acid", color: u2.LightBlue, type: w2.Hexuronate },
  { abbr: "IdoA", name: "Iduronic Acid", color: u2.Brown, type: w2.Hexuronate },
  { abbr: "Qui", name: "Quinovose", color: u2.Blue, type: w2.Deoxyhexose },
  { abbr: "Rha", name: "Rhamnose", color: u2.Green, type: w2.Deoxyhexose },
  { abbr: "6dGul", name: "6-Deoxy Gulose", color: u2.Orange, type: w2.Deoxyhexose },
  { abbr: "6dAlt", name: "6-Deoxy Altrose", color: u2.Pink, type: w2.Deoxyhexose },
  { abbr: "6dTal", name: "6-Deoxy Talose", color: u2.LightBlue, type: w2.Deoxyhexose },
  { abbr: "Fuc", name: "Fucose", color: u2.Red, type: w2.Deoxyhexose },
  { abbr: "QuiNAc", name: "N-Acetyl Quinovosamine", color: u2.Blue, type: w2.DeoxyhexNAc },
  { abbr: "RhaNAc", name: "N-Acetyl Rhamnosamine", color: u2.Green, type: w2.DeoxyhexNAc },
  { abbr: "6dAltNAc", name: "N-Acetyl 6-Deoxy Altrosamine", color: u2.Pink, type: w2.DeoxyhexNAc },
  { abbr: "6dTalNAc", name: "N-Acetyl 6-Deoxy Talosamine", color: u2.LightBlue, type: w2.DeoxyhexNAc },
  { abbr: "FucNAc", name: "N-Acetyl Fucosamine", color: u2.Red, type: w2.DeoxyhexNAc },
  { abbr: "AAT", name: "AAT", color: u2.Red, type: w2.DeoxyhexNAc },
  { abbr: "Oli", name: "Olivose", color: u2.Blue, type: w2.DiDeoxyhexose },
  { abbr: "Tyv", name: "Tyvelose", color: u2.Green, type: w2.DiDeoxyhexose },
  { abbr: "Abe", name: "Abequose", color: u2.Orange, type: w2.DiDeoxyhexose },
  { abbr: "Par", name: "Paratose", color: u2.Pink, type: w2.DiDeoxyhexose },
  { abbr: "Dig", name: "Digitoxose", color: u2.Purple, type: w2.DiDeoxyhexose },
  { abbr: "Col", name: "Colitose", color: u2.LightBlue, type: w2.DiDeoxyhexose },
  { abbr: "Ara", name: "Arabinose", color: u2.Green, type: w2.Pentose },
  { abbr: "Lyx", name: "Lyxose", color: u2.Yellow, type: w2.Pentose },
  { abbr: "Xyl", name: "Xylose", color: u2.Orange, type: w2.Pentose },
  { abbr: "Rib", name: "Ribose", color: u2.Pink, type: w2.Pentose },
  { abbr: "Kdn", name: "Keto-Deoxy Nonulonic Acid", color: u2.Green, type: w2.Deoxynonulosonate },
  { abbr: "Neu5Ac", name: "N-Acetyl Neuraminic Acid", color: u2.Purple, type: w2.Deoxynonulosonate },
  { abbr: "Neu5Gc", name: "N-Glycolyl Neuraminic Acid", color: u2.LightBlue, type: w2.Deoxynonulosonate },
  { abbr: "Neu", name: "Neuraminic Acid", color: u2.Brown, type: w2.Deoxynonulosonate },
  { abbr: "Sia", name: "Sialic acid", color: u2.Red, type: w2.Deoxynonulosonate },
  { abbr: "Pse", name: "Pseudaminic Acid", color: u2.Green, type: w2.DiDeoxynonulosonate },
  { abbr: "Leg", name: "Legionaminic Acid", color: u2.Yellow, type: w2.DiDeoxynonulosonate },
  { abbr: "Aci", name: "Acinetaminic Acid", color: u2.Pink, type: w2.DiDeoxynonulosonate },
  { abbr: "4eLeg", name: "4-Epilegionaminic Acid", color: u2.LightBlue, type: w2.DiDeoxynonulosonate },
  { abbr: "Bac", name: "Bacillosamine", color: u2.Blue, type: w2.Unknown },
  { abbr: "LDmanHep", name: "L-Glycero-D-Manno Heptose", color: u2.Green, type: w2.Unknown },
  { abbr: "Kdo", name: "Keto-Deoxy Octulonic Acid", color: u2.Yellow, type: w2.Unknown },
  { abbr: "Dha", name: "3-Deoxy Lyxo-Heptulosaric Acid", color: u2.Orange, type: w2.Unknown },
  { abbr: "DDmanHep", name: "D-Glycero-D-Manno-Heptose", color: u2.Pink, type: w2.Unknown },
  { abbr: "MurNAc", name: "N-Acetyl Muramic Acid", color: u2.Purple, type: w2.Unknown },
  { abbr: "MurNGc", name: "N-Glycolyl Muramic Acid", color: u2.LightBlue, type: w2.Unknown },
  { abbr: "Mur", name: "Muramic Acid", color: u2.Brown, type: w2.Unknown },
  { abbr: "K3O", name: "D-glycero-a-D-talo-oct-2-Ulosonic Acid", color: u2.Red, type: w2.Unknown },
  { abbr: "dUA", name: "4-deoxy-4,5-didehydro iduronic acid", color: u2.Secondary, type: w2.Unknown },
  { abbr: "Api", name: "Apicose", color: u2.Green, type: w2.Assigned },
  { abbr: "Fru", name: "Fructose", color: u2.Green, type: w2.Assigned },
  { abbr: "Tag", name: "Tagatose", color: u2.Yellow, type: w2.Assigned },
  { abbr: "Sor", name: "Sorbose", color: u2.Orange, type: w2.Assigned },
  { abbr: "Psi", name: "Psicose", color: u2.Pink, type: w2.Assigned }
], hH0 = function() {
  let Z = /* @__PURE__ */ new Map;
  for (let J = 0, $ = yM.length;J < $; ++J) {
    let X = yM[J];
    Z.set(X.abbr, X);
  }
  return Z;
}(), bH0 = [
  ["Glc-family", u2.Blue],
  ["Man-family", u2.Green],
  ["Gal-family", u2.Yellow],
  ["Gul-family", u2.Orange],
  ["Alt-family", u2.Pink],
  ["All-family", u2.Purple],
  ["Tal-family", u2.LightBlue],
  ["Ido-family", u2.Brown],
  ["Fuc-family", u2.Red],
  ["Generic/Unknown/Secondary", u2.Secondary]
], xH0 = {
  Glc: [
    "GLC",
    "BGC",
    "Z8T",
    "TRE",
    "MLR"
  ],
  Man: ["MAN", "BMA"],
  Gal: ["GLA", "GAL", "GZL", "GXL", "GIV"],
  Gul: ["4GL", "GL0", "GUP", "Z8H"],
  Alt: ["Z6H", "3MK", "SHD"],
  All: ["AFD", "ALL", "WOO", "Z2D"],
  Tal: ["ZEE", "A5C", "SDY"],
  Ido: ["ZCD", "Z0F", "4N2"],
  GlcNAc: ["NDG", "NAG", "NGZ"],
  ManNAc: ["BM3", "BM7"],
  GalNAc: ["A2G", "NGA", "YYQ"],
  GulNAc: ["LXB"],
  AltNAc: [],
  AllNAc: ["NAA"],
  TalNAc: [],
  IdoNAc: ["LXZ", "HSQ"],
  GlcN: ["PA1", "GCS"],
  ManN: ["95Z"],
  GalN: ["X6X", "1GN"],
  GulN: [],
  AltN: [],
  AllN: [],
  TalN: [],
  IdoN: [],
  GlcA: ["GCU", "BDP"],
  ManA: ["MAV", "BEM"],
  GalA: ["ADA", "GTR", "GTK"],
  GulA: ["LGU"],
  AltA: [],
  AllA: [],
  TalA: ["X1X", "X0X"],
  IdoA: ["IDR"],
  Qui: ["G6D", "YYK"],
  Rha: ["RAM", "RM4", "XXR"],
  "6dGul": ["66O"],
  "6dAlt": [],
  "6dTal": [],
  Fuc: ["FUC", "FUL", "FCA", "FCB", "GYE"],
  QuiNAc: ["Z9W"],
  RhaNAc: [],
  "6dAltNAc": [],
  "6dTalNAc": [],
  FucNAc: ["49T"],
  Oli: ["DDA", "RAE", "Z5J"],
  Tyv: ["TYV"],
  Abe: ["ABE"],
  Par: ["PZU"],
  Dig: ["Z3U"],
  Col: [],
  Ara: ["64K", "ARA", "ARB", "AHR", "FUB", "BXY", "BXX", "SEJ"],
  Lyx: ["LDY", "Z4W"],
  Xyl: ["XYS", "XYP", "XYZ", "HSY", "LXC"],
  Rib: ["YYM", "RIP", "RIB", "BDR", "0MK", "Z6J", "32O"],
  Kdn: ["KDM", "KDN"],
  Neu5Ac: ["SIA", "SLB"],
  Neu5Gc: ["NGC", "NGE"],
  Neu: [],
  Sia: [],
  Pse: [],
  Leg: [],
  Aci: [],
  "4eLeg": [],
  Bac: [],
  LDmanHep: ["GMH"],
  Kdo: ["KDO"],
  Dha: [],
  DDmanHep: ["289"],
  MurNAc: ["MUB", "AMU"],
  MurNGc: [],
  Mur: ["1S4", "MUR"],
  Api: ["XXM"],
  Fru: ["BDF", "Z9N", "FRU", "LFR"],
  Tag: ["T6T"],
  Sor: ["SOE", "UEA"],
  Psi: ["PSV", "SF6", "SF9", "TTV"]
}, yH0 = {
  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"]
}, De0 = {
  Glc: ["0GA", "0GB", "1GA", "1GB", "2GA", "2GB", "3GA", "3GB", "4GA", "4GB", "6GA", "6GB", "ZGA", "ZGB", "YGA", "YGB", "XGA", "XGB", "WGA", "WGB", "VGA", "VGB", "UGA", "UGB", "TGA", "TGB", "SGA", "SGB", "RGA", "RGB", "QGA", "QGB", "PGA", "PGB", "0gA", "0gB", "1gA", "1gB", "2gA", "2gB", "3gA", "3gB", "4gA", "4gB", "6gA", "6gB", "ZgA", "ZgB", "YgA", "YgB", "XgA", "XgB", "WgA", "WgB", "VgA", "VgB", "UgA", "UgB", "TgA", "TgB", "SgA", "SgB", "RgA", "RgB", "QgA", "QgB", "PgA", "PgB"],
  GlcNAc: ["0YA", "0YB", "1YA", "1YB", "3YA", "3YB", "4YA", "4YB", "6YA", "6YB", "WYA", "WYB", "VYA", "VYB", "UYA", "UYB", "QYA", "QYB", "0yA", "0yB", "1yA", "1yB", "3yA", "3yB", "4yA", "4yB", "6yA", "6yB", "WyA", "WyB", "VyA", "VyB", "UyA", "UyB", "QyA", "QyB", "0YS", "0Ys", "3YS", "3Ys", "4YS", "4Ys", "6YS", "6Ys", "QYS", "QYs", "UYS", "UYs", "VYS", "VYs", "WYS", "WYs", "0yS", "0ys", "3yS", "3ys", "4yS", "4ys"],
  GlcA: ["0ZA", "0ZB", "1ZA", "1ZB", "2ZA", "2ZB", "3ZA", "3ZB", "4ZA", "4ZB", "ZZA", "ZZB", "YZA", "YZB", "WZA", "WZB", "TZA", "TZB", "0zA", "0zB", "1zA", "1zB", "2zA", "2zB", "3zA", "3zB", "4zA", "4zB", "ZzA", "ZzB", "YzA", "YzB", "WzA", "WzB", "TzA", "TzB", "TZBP", "WZBP", "YZBP", "4ZBP", "ZZBP", "3ZBP", "2ZBP", "1ZBP", "0ZBP", "0ZF", "1ZF", "4ZF", "0Zf", "1Zf", "4Zf"],
  GlcN: ["0YN", "3YN", "4YN", "6YN", "WYN", "VYN", "UYN", "QYN", "3Yn", "4Yn", "WYn", "0Yn", "0YP", "3YP", "4YP", "6YP", "WYP", "VYP", "UYP", "QYP", "0Yp", "3Yp", "4Yp", "WYp", "QYN", "WYN", "VYN", "3YN", "UYN", "4YN", "6YN", "1YN", "0YN", "QYn", "VYn", "WYn", "3Yn", "UYn", "6Yn", "4Yn", "1Yn", "0Yn", "QYNP", "WYNP", "VYNP", "3YNP", "UYNP", "4YNP", "6YNP", "1YNP", "0YNP", "QYnP", "UYnP", "VYnP", "6YnP", "WYnP", "4YnP", "3YnP", "1YnP", "0YnP"],
  Man: ["0MA", "0MB", "1MA", "1MB", "2MA", "2MB", "3MA", "3MB", "4MA", "4MB", "6MA", "6MB", "ZMA", "ZMB", "YMA", "YMB", "XMA", "XMB", "WMA", "WMB", "VMA", "VMB", "UMA", "UMB", "TMA", "TMB", "SMA", "SMB", "RMA", "RMB", "QMA", "QMB", "PMA", "PMB", "0mA", "0mB", "1mA", "1mB", "2mA", "2mB", "3mA", "3mB", "4mA", "4mB", "6mA", "6mB", "ZmA", "ZmB", "YmA", "YmB", "XmA", "XmB", "WmA", "WmB", "VmA", "VmB", "UmA", "UmB", "TmA", "TmB", "SmA", "SmB", "RmA", "RmB", "QmA", "QmB", "PmA", "PmB"],
  ManNAc: ["0WA", "0WB", "1WA", "1WB", "3WA", "3WB", "4WA", "4WB", "6WA", "6WB", "WWA", "WWB", "VWA", "VWB", "UWA", "UWB", "QWA", "QWB", "0wA", "0wB", "1wA", "1wB", "3wA", "3wB", "4wA", "4wB", "6wA", "6wB", "WwA", "WwB", "VwA", "VwB", "UwA", "UwB", "QwA", "QwB"],
  Ara: ["0AA", "0AB", "1AA", "1AB", "2AA", "2AB", "3AA", "3AB", "4AA", "4AB", "ZAA", "ZAB", "YAA", "YAB", "WAA", "WAB", "TAA", "TAB", "0AD", "0AU", "1AD", "1AU", "2AD", "2AU", "3AD", "3AU", "5AD", "5AU", "ZAD", "ZAU", "0aA", "0aB", "1aA", "1aB", "2aA", "2aB", "3aA", "3aB", "4aA", "4aB", "ZaA", "ZaB", "YaA", "YaB", "WaA", "WaB", "TaA", "TaB", "0aD", "0aU", "1aD", "1aU", "2aD", "2aU", "3aD", "3aU", "5aD", "5aU", "ZaD", "ZaU"],
  Gal: ["0LA", "0LB", "1LA", "1LB", "2LA", "2LB", "3LA", "3LB", "4LA", "4LB", "6LA", "6LB", "ZLA", "ZLB", "YLA", "YLB", "XLA", "XLB", "WLA", "WLB", "VLA", "VLB", "ULA", "ULB", "TLA", "TLB", "SLA", "SLB", "RLA", "RLB", "QLA", "QLB", "PLA", "PLB", "0lA", "0lB", "1lA", "1lB", "2lA", "2lB", "3lA", "3lB", "4lA", "4lB", "6lA", "6lB", "ZlA", "ZlB", "YlA", "YlB", "XlA", "XlB", "WlA", "WlB", "VlA", "VlB", "UlA", "UlB", "TlA", "TlB", "SlA", "SlB", "RlA", "RlB", "QlA", "QlB", "PlA", "PlB"],
  GalNAc: ["0VA", "0VB", "1VA", "1VB", "3VA", "3VB", "4VA", "4VB", "6VA", "6VB", "WVA", "WVB", "VVA", "VVB", "UVA", "UVB", "QVA", "QVB", "0vA", "0vB", "1vA", "1vB", "3vA", "3vB", "4vA", "4vB", "6vA", "6vB", "WvA", "WvB", "VvA", "VvB", "UvA", "UvB", "QvA", "QvB"],
  GalA: ["0OA", "0OB", "1OA", "1OB", "2OA", "2OB", "3OA", "3OB", "4OA", "4OB", "ZOA", "ZOB", "YOA", "YOB", "WOA", "WOB", "TOA", "TOB", "0oA", "0oB", "1oA", "1oB", "2oA", "2oB", "3oA", "3oB", "4oA", "4oB", "ZoA", "ZoB", "YoA", "YoB", "WoA", "WoB", "ToA", "ToB"],
  Gul: ["0KA", "0KB", "1KA", "1KB", "2KA", "2KB", "3KA", "3KB", "4KA", "4KB", "6KA", "6KB", "ZKA", "ZKB", "YKA", "YKB", "XKA", "XKB", "WKA", "WKB", "VKA", "VKB", "UKA", "UKB", "TKA", "TKB", "SKA", "SKB", "RKA", "RKB", "QKA", "QKB", "PKA", "PKB", "0kA", "0kB", "1kA", "1kB", "2kA", "2kB", "3kA", "3kB", "4kA", "4kB", "6kA", "6kB", "ZkA", "ZkB", "YkA", "YkB", "XkA", "XkB", "WkA", "WkB", "VkA", "VkB", "UkA", "UkB", "TkA", "TkB", "SkA", "SkB", "RkA", "RkB", "QkA", "QkB", "PkA", "PkB"],
  Alt: ["0EA", "0EB", "1EA", "1EB", "2EA", "2EB", "3EA", "3EB", "4EA", "4EB", "6EA", "6EB", "ZEA", "ZEB", "YEA", "YEB", "XEA", "XEB", "WEA", "WEB", "VEA", "VEB", "UEA", "UEB", "TEA", "TEB", "SEA", "SEB", "REA", "REB", "QEA", "QEB", "PEA", "PEB", "0eA", "0eB", "1eA", "1eB", "2eA", "2eB", "3eA", "3eB", "4eA", "4eB", "6eA", "6eB", "ZeA", "ZeB", "YeA", "YeB", "XeA", "XeB", "WeA", "WeB", "VeA", "VeB", "UeA", "UeB", "TeA", "TeB", "SeA", "SeB", "ReA", "ReB", "QeA", "QeB", "PeA", "PeB"],
  All: ["0NA", "0NB", "1NA", "1NB", "2NA", "2NB", "3NA", "3NB", "4NA", "4NB", "6NA", "6NB", "ZNA", "ZNB", "YNA", "YNB", "XNA", "XNB", "WNA", "WNB", "VNA", "VNB", "UNA", "UNB", "TNA", "TNB", "SNA", "SNB", "RNA", "RNB", "QNA", "QNB", "PNA", "PNB", "0nA", "0nB", "1nA", "1nB", "2nA", "2nB", "3nA", "3nB", "4nA", "4nB", "6nA", "6nB", "ZnA", "ZnB", "YnA", "YnB", "XnA", "XnB", "WnA", "WnB", "VnA", "VnB", "UnA", "UnB", "TnA", "TnB", "SnA", "SnB", "RnA", "RnB", "QnA", "QnB", "PnA", "PnB"],
  Tal: ["0TA", "0TB", "1TA", "1TB", "2TA", "2TB", "3TA", "3TB", "4TA", "4TB", "6TA", "6TB", "ZTA", "ZTB", "YTA", "YTB", "XTA", "XTB", "WTA", "WTB", "VTA", "VTB", "UTA", "UTB", "TTA", "TTB", "STA", "STB", "RTA", "RTB", "QTA", "QTB", "PTA", "PTB", "0tA", "0tB", "1tA", "1tB", "2tA", "2tB", "3tA", "3tB", "4tA", "4tB", "6tA", "6tB", "ZtA", "ZtB", "YtA", "YtB", "XtA", "XtB", "WtA", "WtB", "VtA", "VtB", "UtA", "UtB", "TtA", "TtB", "StA", "StB", "RtA", "RtB", "QtA", "QtB", "PtA", "PtB"],
  Ido: ["0IA", "0IB", "1IA", "1IB", "2IA", "2IB", "3IA", "3IB", "4IA", "4IB", "6IA", "6IB", "ZIA", "ZIB", "YIA", "YIB", "XIA", "XIB", "WIA", "WIB", "VIA", "VIB", "UIA", "UIB", "TIA", "TIB", "SIA", "SIB", "RIA", "RIB", "QIA", "QIB", "PIA", "PIB", "0iA", "0iB", "1iA", "1iB", "2iA", "2iB", "3iA", "3iB", "4iA", "4iB", "6iA", "6iB", "ZiA", "ZiB", "YiA", "YiB", "XiA", "XiB", "WiA", "WiB", "ViA", "ViB", "UiA", "UiB", "TiA", "TiB", "SiA", "SiB", "RiA", "RiB", "QiA", "QiB", "PiA", "PiB"],
  IdoA: ["0UA", "0UB", "1UA", "1UB", "2UA", "2UB", "3UA", "3UB", "4UA", "4UB", "ZUA", "ZUB", "YUA", "YUB", "WUA", "WUB", "TUA", "TUB", "0uA", "0uB", "1uA", "1uB", "2uA", "2uB", "3uA", "3uB", "4uA", "4uB", "ZuA", "ZuB", "YuA", "YuB", "WuA", "WuB", "TuA", "TuB", "YuAP"],
  Fuc: ["0FA", "0FB", "1FA", "1FB", "2FA", "2FB", "3FA", "3FB", "4FA", "4FB", "ZFA", "ZFB", "YFA", "YFB", "WFA", "WFB", "TFA", "TFB", "0fA", "0fB", "1fA", "1fB", "2fA", "2fB", "3fA", "3fB", "4fA", "4fB", "ZfA", "ZfB", "YfA", "YfB", "WfA", "WfB", "TfA", "TfB"],
  Rha: ["0HA", "0HB", "1HA", "1HB", "2HA", "2HB", "3HA", "3HB", "4HA", "4HB", "ZHA", "ZHB", "YHA", "YHB", "WHA", "WHB", "THA", "THB", "0hA", "0hB", "1hA", "1hB", "2hA", "2hB", "3hA", "3hB", "4hA", "4hB", "ZhA", "ZhB", "YhA", "YhB", "WhA", "WhB", "ThA", "ThB"],
  Qui: ["0QA", "0QB", "1QA", "1QB", "2QA", "2QB", "3QA", "3QB", "4QA", "4QB", "ZQA", "ZQB", "YQA", "YQB", "WQA", "WQB", "TQA", "TQB", "0qA", "0qB", "1qA", "1qB", "2qA", "2qB", "3qA", "3qB", "4qA", "4qB", "ZqA", "ZqB", "YqA", "YqB", "WqA", "WqB", "TqA", "TqB"],
  Lyx: ["0DA", "0DB", "1DA", "1DB", "2DA", "2DB", "3DA", "3DB", "4DA", "4DB", "ZDA", "ZDB", "YDA", "YDB", "WDA", "WDB", "TDA", "TDB", "0DD", "0DU", "1DD", "1DU", "2DD", "2DU", "3DD", "3DU", "5DD", "5DU", "ZDD", "ZDU", "0dA", "0dB", "1dA", "1dB", "2dA", "2dB", "3dA", "3dB", "4dA", "4dB", "ZdA", "ZdB", "YdA", "YdB", "WdA", "WdB", "TdA", "TdB", "0dD", "0dU", "1dD", "1dU", "2dD", "2dU", "3dD", "3dU", "5dD", "5dU", "ZdD", "ZdU"],
  Xyl: ["0XA", "0XB", "1XA", "1XB", "2XA", "2XB", "3XA", "3XB", "4XA", "4XB", "ZXA", "ZXB", "YXA", "YXB", "WXA", "WXB", "TXA", "TXB", "0XD", "0XU", "1XD", "1XU", "2XD", "2XU", "3XD", "3XU", "5XD", "5XU", "ZXD", "ZXU", "0xA", "0xB", "1xA", "1xB", "2xA", "2xB", "3xA", "3xB", "4xA", "4xB", "ZxA", "ZxB", "YxA", "YxB", "WxA", "WxB", "TxA", "TxB", "0xD", "0xU", "1xD", "1xU", "2xD", "2xU", "3xD", "3xU", "5xD", "5xU", "ZxD", "ZxU"],
  Rib: ["0RA", "0RB", "1RA", "1RB", "2RA", "2RB", "3RA", "3RB", "4RA", "4RB", "ZRA", "ZRB", "YRA", "YRB", "WRA", "WRB", "TRA", "TRB", "0RD", "0RU", "1RD", "1RU", "2RD", "2RU", "3RD", "3RU", "5RD", "5RU", "ZRD", "ZRU", "0rA", "0rB", "1rA", "1rB", "2rA", "2rB", "3rA", "3rB", "4rA", "4rB", "ZrA", "ZrB", "YrA", "YrB", "WrA", "WrB", "TrA", "TrB", "0rD", "0rU", "1rD", "1rU", "2rD", "2rU", "3rD", "3rU", "5rD", "5rU", "ZrD", "ZrU"],
  Fru: ["0CA", "0CB", "1CA", "1CB", "2CA", "2CB", "3CA", "3CB", "4CA", "4CB", "5CA", "5CB", "WCA", "WCB", "0CD", "0CU", "1CD", "1CU", "2CD", "2CU", "3CD", "3CU", "4CD", "4CU", "6CD", "6CU", "WCD", "WCU", "VCD", "VCU", "UCD", "UCU", "QCD", "QCU", "0cA", "0cB", "1cA", "1cB", "2cA", "2cB", "3cA", "3cB", "4cA", "4cB", "5cA", "5cB", "WcA", "WcB", "0cD", "0cU", "1cD", "1cU", "2cD", "2cU", "3cD", "3cU", "4cD", "4cU", "6cD", "6cU", "WcD", "WcU", "VcD", "VcU", "UcD", "UcU", "QcD", "QcU"],
  Tag: ["0JA", "0JB", "1JA", "1JB", "2JA", "2JB", "3JA", "3JB", "4JA", "4JB", "5JA", "5JB", "WJA", "WJB", "0JD", "0JU", "1JD", "1JU", "2JD", "2JU", "3JD", "3JU", "4JD", "4JU", "6JD", "6JU", "WJD", "WJU", "VJD", "VJU", "UJD", "UJU", "QJD", "QJU", "0jA", "0jB", "1jA", "1jB", "2jA", "2jB", "3jA", "3jB", "4jA", "4jB", "5jA", "5jB", "WjA", "WjB", "0jD", "0jU", "1jD", "1jU", "2jD", "2jU", "3jD", "3jU", "4jD", "4jU", "6jD", "6jU", "WjD", "WjU", "VjD", "VjU", "UjD", "UjU", "QjD", "QjU"],
  Sor: ["0BA", "0BB", "1BA", "1BB", "2BA", "2BB", "3BA", "3BB", "4BA", "4BB", "5BA", "5BB", "WBA", "WBB", "0BD", "0BU", "1BD", "1BU", "2BD", "2BU", "3BD", "3BU", "4BD", "4BU", "6BD", "6BU", "WBD", "WBU", "VBD", "VBU", "UBD", "UBU", "QBD", "QBU", "0bA", "0bB", "1bA", "1bB", "2bA", "2bB", "3bA", "3bB", "4bA", "4bB", "5bA", "5bB", "WbA", "WbB", "0bD", "0bU", "1bD", "1bU", "2bD", "2bU", "3bD", "3bU", "4bD", "4bU", "6bD", "6bU", "WbD", "WbU", "VbD", "VbU", "UbD", "UbU", "QbD", "QbU"],
  Psi: ["0PA", "0PB", "1PA", "1PB", "2PA", "2PB", "3PA", "3PB", "4PA", "4PB", "5PA", "5PB", "WPA", "WPB", "0PD", "0PU", "1PD", "1PU", "2PD", "2PU", "3PD", "3PU", "4PD", "4PU", "6PD", "6PU", "WPD", "WPU", "VPD", "VPU", "UPD", "UPU", "QPD", "QPU", "0pA", "0pB", "1pA", "1pB", "2pA", "2pB", "3pA", "3pB", "4pA", "4pB", "5pA", "5pB", "WpA", "WpB", "0pD", "0pU", "1pD", "1pU", "2pD", "2pU", "3pD", "3pU", "4pD", "4pU", "6pD", "6pU", "WpD", "WpU", "VpD", "VpU", "UpD", "UpU", "QpD", "QpU"],
  Neu5Ac: ["0SA", "0SB", "4SA", "4SB", "7SA", "7SB", "8SA", "8SB", "9SA", "9SB", "ASA", "ASB", "BSA", "BSB", "CSA", "CSB", "DSA", "DSB", "ESA", "ESB", "FSA", "FSB", "GSA", "GSB", "HSA", "HSB", "ISA", "ISB", "JSA", "JSB", "KSA", "KSB", "0sA", "0sB", "4sA", "4sB", "7sA", "7sB", "8sA", "8sB", "9sA", "9sB", "AsA", "AsB", "BsA", "BsB", "CsA", "CsB", "DsA", "DsB", "EsA", "EsB", "FsA", "FsB", "GsA", "GsB", "HsA", "HsB", "IsA", "IsB", "JsA", "JsB", "KsA", "KsB"],
  Neu5Gc: ["0GL", "4GL", "7GL", "8GL", "9GL", "CGL", "DGL", "EGL", "FGL", "GGL", "HGL", "IGL", "JGL", "KGL", "0gL", "4gL", "7gL", "8gL", "9gL", "AgL", "BgL", "CgL", "DgL", "EgL", "FgL", "GgL", "HgL", "IgL", "JgL", "KgL"],
  Tyv: ["YTV", "4TV", "2TV", "1TV", "0TV", "YTv", "4Tv", "2Tv", "1Tv", "0Tv"],
  Abe: ["YAE", "2AE", "4AE", "1AE", "0AE", "YAe", "4Ae", "2Ae", "1Ae", "0Ae"],
  Bac: ["0BC", "1BC", "3BC", "0bC", "1bC", "3bC"],
  Kdn: ["0KN", "4KN", "5KN", "7KN", "8KN", "9KN", "AKN", "BKN", "CKN", "DKN", "EKN", "FKN", "GKN", "HKN", "IKN", "JKN", "KKN", "LKN", "MKN", "NKN", "OKN", "PKN", "QKN", "RKN", "SKN", "TKN", "UKN", "VKN", "WKN", "XKN", "YKN", "0Kn", "4Kn", "5Kn", "7Kn", "8Kn", "9Kn", "AKn", "BKn", "CKn", "DKn", "EKn", "FKn", "GKn", "HKn", "IKn", "JKn", "KKn", "LKn", "MKn", "NKn", "OKn", "PKn", "QKn", "RKn", "SKn", "TKn", "UKn", "VKn", "WKn", "XKn", "YKn"],
  Kdo: ["0KO", "4KO", "5KO", "7KO", "8KO", "AKO", "BKO", "CKO", "DKO", "EKO", "FKO", "GKO", "HKO", "IKO", "JKO", "KKO", "0Ko", "4Ko", "5Ko", "7Ko", "8Ko", "AKo", "BKo", "CKo", "DKo", "EKo", "FKo", "GKo", "HKo", "IKo", "JKo", "KKo"],
  QuiNAc: ["0QF", "1QF", "3QF", "0Qf", "1Qf", "3Qf"],
  AAT: ["0FC", "1FC", "3FC", "0Fc", "1Fc", "3Fc"],
  Ara4N: ["ZaN", "3aN", "2aN", "1aN", "0aN", "Zan", "3an", "2an", "1an", "0an"],
  Aci: ["JeC", "8eC", "4eC", "2eC", "0eC", "Jec", "8ec", "4ec", "2ec", "0ec"],
  Leg: ["JLG", "8LG", "4LG", "2LG", "0LG", "JLg", "8Lg", "4Lg", "2Lg", "0Lg"],
  Pse: ["JmP", "8mP", "4mP", "2mP", "0mP", "Jmp", "8mp", "4mp", "2mp", "0mp"],
  Fus: ["EgF", "HgF", "JgF", "8gF", "KgF", "7gF", "4gF", "2gF", "0gF", "Egf", "Hgf", "Jgf", "8gf", "Kgf", "7gf", "4gf", "2gf", "0gf"],
  DDmanpHep: ["ODH", "NDH", "LDH", "MDH", "KDH", "7DH", "PDH", "SDH", "RDH", "XDH", "QDH", "VDH", "UDH", "6DH", "TDH", "ZDH", "YDH", "2DH", "WDH", "3DH", "4DH", "1DH", "ODh", "NDh", "LDh", "MDh", "KDh", "7Dh", "PDh", "SDh", "RDh", "XDh", "QDh", "VDh", "UDh", "6Dh", "TDh", "ZDh", "YDh", "2Dh", "WDh", "3Dh", "4Dh", "1Dh"],
  LDmanpHep: ["OLH", "NLH", "LLH", "MLH", "KLH", "7LH", "PLH", "SLH", "RLH", "XLH", "QLH", "VLH", "ULH", "6LH", "TLH", "ZLH", "YLH", "2LH", "WLH", "3LH", "4LH", "1LH", "OLh", "NLh", "LLh", "MLh", "KLh", "7Lh", "PLh", "SLh", "RLh", "XLh", "QLh", "VLh", "ULh", "6Lh", "TLh", "ZLh", "YLh", "2Lh", "WLh", "3Lh", "4Lh", "1Lh"],
  K3O: ["dKX", "EKX", "hKX", "HKX", "jKX", "JKX", "pKX", "8KX", "MKX", "kKX", "KKX", "qKX", "7KX", "xKX", "WKX", "tKX", "3KX", "sKX", "4KX", "5KX", "2KX", "0KX", "dKx", "EKx", "hKx", "HKx", "jKx", "JKx", "pKx", "8Kx", "MKx", "kKx", "KKx", "qKx", "7Kx", "xKx", "WKx", "tKx", "3Kx", "sKx", "4Kx", "5Kx", "2Kx", "0Kx"],
  MurNAc: ["UMR", "4MR", "6MR", "1MR", "0MR", "UMr", "4Mr", "6Mr", "1Mr", "0Mr"],
  Oli: ["WdR", "4dR", "3dR", "1dR", "0dR"],
  dUA: ["Z45", "345", "245", "145", "045"],
  GlcNS: ["QYS", "UYS", "VYS", "6YS", "WYS", "4YS", "3YS", "1YS", "0YS", "QYs", "UYs", "VYs", "6Ys", "WYs", "4Ys", "3Ys", "1Ys", "0Ys", "QyS", "UyS", "VyS", "6yS", "WyS", "4yS", "3yS", "1yS", "0yS", "Qys", "Uys", "Vys", "6ys", "Wys", "4ys", "3ys", "1ys", "0ys"]
}, gH0 = function() {
  let Z = /* @__PURE__ */ new Map;
  for (let J = 0, $ = yM.length;J < $; ++J) {
    let X = yM[J], Y = xH0[X.abbr];
    if (Y)
      for (let W = 0, K = Y.length;W < K; ++W)
        Z.set(Y[W], X);
    let Q = yH0[X.abbr];
    if (Q)
      for (let W = 0, K = Q.length;W < K; ++W)
        Z.set(Q[W], X);
  }
  return Oo.forEach((J) => {
    if (!Z.has(J))
      Z.set(J, kf);
  }), Z;
}(), Me0 = function() {
  let Z = /* @__PURE__ */ new Map;
  for (let J = 0, $ = yM.length;J < $; ++J) {
    let X = yM[J], Y = xH0[X.abbr];
    if (Y)
      for (let K = 0, G = Y.length;K < G; ++K)
        Z.set(Y[K], X);
    let Q = yH0[X.abbr];
    if (Q)
      for (let K = 0, G = Q.length;K < G; ++K)
        Z.set(Q[K], X);
    let W = De0[X.abbr];
    if (W) {
      for (let K = 0, G = W.length;K < G; ++K)
        if (!Z.has(W[K]))
          Z.set(W[K], X);
    }
  }
  return Oo.forEach((J) => {
    if (!Z.has(J))
      Z.set(J, kf);
  }), Z;
}();
function mH0(Z) {
  D3 = Z === "default" ? gH0 : Me0;
}
var D3 = gH0;

// node_modules/molstar/lib/mol-util/set.js
var uZ;
(function(Z) {
  function J(F) {
    return Array.from(F.values());
  }
  Z.toArray = J;
  function $(F, E) {
    if (F === E)
      return !0;
    if (F.size < E.size)
      return !1;
    for (let R of E)
      if (!F.has(R))
        return !1;
    return !0;
  }
  Z.isSuperset = $;
  function X(F, ...E) {
    for (let R = 0;R < E.length; R++)
      for (let z of E[R])
        F.add(z);
    return F;
  }
  Z.add = X;
  function Y(F, E) {
    let R = new Set(F);
    if (F === E)
      return R;
    for (let z of E)
      R.add(z);
    return R;
  }
  Z.union = Y;
  function Q(...F) {
    if (F.length === 0)
      return /* @__PURE__ */ new Set;
    let E = new Set(F[0]);
    for (let R = 1, z = F.length;R < z; R++)
      for (let D of F[R])
        E.add(D);
    return E;
  }
  Z.unionMany = Q;
  function W(F) {
    if (F.length === 0)
      return /* @__PURE__ */ new Set;
    let E = new Set(F[0]);
    for (let R = 1;R < F.length; R++)
      for (let z of F[R])
        E.add(z);
    return E;
  }
  Z.unionManyArrays = W;
  function K(F, E) {
    if (F === E)
      return new Set(F);
    let R = /* @__PURE__ */ new Set;
    for (let z of E)
      if (F.has(z))
        R.add(z);
    return R;
  }
  Z.intersection = K;
  function G(F, E) {
    if (F === E)
      return F.size > 0;
    if (F.size < E.size)
      [F, E] = [E, F];
    for (let R of E)
      if (F.has(R))
        return !0;
    return !1;
  }
  Z.areIntersecting = G;
  function H(F, E) {
    if (F === E)
      return F.size;
    if (F.size < E.size)
      [F, E] = [E, F];
    let R = 0;
    for (let z of E)
      if (F.has(z))
        R += 1;
    return R;
  }
  Z.intersectionSize = H;
  function N(F, E) {
    if (F === E)
      return /* @__PURE__ */ new Set;
    let R = new Set(F);
    for (let z of E)
      R.delete(z);
    return R;
  }
  Z.difference = N;
  function q(F, E) {
    if (F === E)
      return 0;
    let R = F.size;
    for (let z of F)
      if (E.has(z))
        R -= 1;
    return R;
  }
  Z.differenceSize = q;
  function U(F, E) {
    if (F === E)
      return !0;
    if (F.size !== E.size)
      return !1;
    for (let R of E)
      if (!F.has(R))
        return !1;
    return !0;
  }
  Z.areEqual = U;
})(uZ || (uZ = {}));

// node_modules/molstar/lib/mol-model/structure/model/types/lipids.js
var zo = /* @__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", "DAPA", "DBPA", "DFPA", "DGPA", "DIPA", "DLPA", "DNPA", "DOPA", "DPPA", "DRPA", "DTPA", "DVPA", "DXPA", "DYPA", "LPPA", "PAPA", "PGPA", "PIPA", "POPA", "PRPA", "PUPA", "DAPG", "DBPG", "DFPG", "DGPG", "DIPG", "DLPG", "DNPG", "DOPG", "DPPG", "DRPG", "DTPG", "DVPG", "DXPG", "DYPG", "LPPG", "PAPG", "PGPG", "PIPG", "POPG", "PRPG", "DMPC", "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"]);

// node_modules/molstar/lib/mol-model/structure/model/types/ions.js
var Do = /* @__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", "NT3", "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", "RHF", "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", "ZTM", "NCO", "OHX"]);

// node_modules/molstar/lib/mol-model/structure/model/types.js
var Ae0 = function() {
  let Z = Object.create(null), J = [];
  for (let $ = 65;$ <= 90; $++)
    J[J.length] = String.fromCharCode($);
  for (let $ = 97;$ <= 122; $++)
    J[J.length] = String.fromCharCode($);
  for (let $ = 48;$ <= 57; $++)
    J[J.length] = String.fromCharCode($);
  for (let $ of J) {
    Z[$] = $.toUpperCase();
    for (let X of J) {
      Z[$ + X] = ($ + X).toUpperCase();
      for (let Y of J)
        Z[$ + X + Y] = ($ + X + Y).toUpperCase();
    }
  }
  return Z;
}();
function WH(Z) {
  return Ae0[Z] || Z.toUpperCase();
}
var dH0 = 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((Z) => [Z[0], WH(Z[1])]));
function uH0(Z) {
  if (dH0.has(Z))
    return dH0.get(Z);
  return WH("H");
}
var pH0;
(function(Z) {
  Z[Z.unknown = 0] = "unknown", Z[Z.polymer = 1] = "polymer", Z[Z["non-polymer"] = 2] = "non-polymer", Z[Z.macrolide = 3] = "macrolide", Z[Z.water = 4] = "water", Z[Z.branched = 5] = "branched";
})(pH0 || (pH0 = {}));
var e2;
(function(Z) {
  Z[Z.Unknown = 0] = "Unknown", Z[Z.Other = 1] = "Other", Z[Z.Water = 2] = "Water", Z[Z.Ion = 3] = "Ion", Z[Z.Lipid = 4] = "Lipid", Z[Z.Protein = 5] = "Protein", Z[Z.RNA = 6] = "RNA", Z[Z.DNA = 7] = "DNA", Z[Z.PNA = 8] = "PNA", Z[Z.Saccharide = 9] = "Saccharide";
})(e2 || (e2 = {}));
var q$;
(function(Z) {
  Z[Z.NA = 0] = "NA", Z[Z.Protein = 1] = "Protein", Z[Z.GammaProtein = 2] = "GammaProtein", Z[Z.BetaProtein = 3] = "BetaProtein", Z[Z.RNA = 4] = "RNA", Z[Z.DNA = 5] = "DNA", Z[Z.PNA = 6] = "PNA";
})(q$ || (q$ = {}));
var cH0 = {
  [q$.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
  },
  [q$.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"]),
    coarseBackbone: /* @__PURE__ */ new Set(["CA", "CA1", "BB", "BAS"])
  },
  [q$.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"])
  },
  [q$.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"])
  },
  [q$.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"])
  },
  [q$.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"])
  },
  [q$.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"])
  }
}, jK = /* @__PURE__ */ new Set([
  "CA",
  "C",
  "N",
  "O",
  "O1",
  "O2",
  "OC1",
  "OC2",
  "OT1",
  "OT2",
  "OX1",
  "OXT",
  "H",
  "H1",
  "H2",
  "H3",
  "HA",
  "HN",
  "HXT",
  "BB"
]), gM = /* @__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*"
]), lH0 = /* @__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"
]), nH0 = /* @__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"
]), Be0 = /* @__PURE__ */ new Set([
  "d-gamma-peptide, c-delta linking",
  "l-gamma-peptide, c-delta linking"
]), we0 = /* @__PURE__ */ new Set([
  "d-beta-peptide, c-gamma linking",
  "l-beta-peptide, c-gamma linking"
]), je0 = /* @__PURE__ */ new Set([
  "d-peptide nh3 amino terminus",
  "d-peptide cooh carboxy terminus",
  "l-peptide nh3 amino terminus",
  "l-peptide cooh carboxy terminus"
]), iH0 = /* @__PURE__ */ new Set([
  "peptide linking",
  "peptide-like"
]), Te0 = uZ.unionMany(lH0, nH0, iH0), oH0 = /* @__PURE__ */ new Set([
  "dna linking",
  "l-dna linking",
  "dna oh 5 prime terminus",
  "dna oh 3 prime terminus"
]), sH0 = /* @__PURE__ */ new Set([
  "rna linking",
  "l-rna linking",
  "rna oh 5 prime terminus",
  "rna oh 3 prime terminus"
]), aH0 = uZ.unionMany(/* @__PURE__ */ new Set([
  "d-saccharide, beta linking",
  "l-saccharide, beta linking",
  "d-saccharide, alpha linking",
  "l-saccharide, alpha linking",
  "l-saccharide",
  "d-saccharide",
  "saccharide"
]), /* @__PURE__ */ new Set([
  "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"
])), _e0 = /* @__PURE__ */ new Set([
  "non-polymer",
  "other"
]), Ve0 = /* @__PURE__ */ new Set([
  "ion"
]), Ie0 = /* @__PURE__ */ new Set([
  "lipid"
]), mM = /* @__PURE__ */ new Set([
  "SOL",
  "WAT",
  "HOH",
  "H2O",
  "W",
  "DOD",
  "D3O",
  "TIP",
  "TIP3",
  "TIP4",
  "SPC"
]), vf = /* @__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",
  "HYP",
  "HSD",
  "HSE",
  "HSP",
  "LSN",
  "ASPP",
  "GLUP",
  "HID",
  "HIE",
  "HIP",
  "LYN",
  "ASH",
  "GLH"
]), rH0 = /* @__PURE__ */ new Set([
  "DAL",
  "DAR",
  "DSG",
  "DAS",
  "DCY",
  "DGL",
  "DGN",
  "DHI",
  "DIL",
  "DLE",
  "DLY",
  "MED",
  "DPN",
  "DPR",
  "DSN",
  "DTH",
  "DTR",
  "DTY",
  "DVA",
  "DNE"
]), Kz = uZ.unionMany(vf, rH0), tH0 = /* @__PURE__ */ new Set([
  "NME",
  "ACE",
  "NH2",
  "FOR",
  "FMT"
]), dM = /* @__PURE__ */ new Set([
  "A",
  "C",
  "T",
  "G",
  "I",
  "U",
  "N"
]), pM = /* @__PURE__ */ new Set([
  "DA",
  "DC",
  "DT",
  "DG",
  "DI",
  "DU",
  "DN"
]), Mo = /* @__PURE__ */ new Set(["APN", "CPN", "TPN", "GPN"]), Pe0 = /* @__PURE__ */ new Set(["A", "G", "I", "DA", "DG", "DI", "APN", "GPN"]), Ce0 = /* @__PURE__ */ new Set(["C", "T", "U", "DC", "DT", "DU", "CPN", "TPN"]), Gz = uZ.unionMany(dM, pM, Mo), eH0 = (Z) => Pe0.has(Z.toUpperCase()), ZN0 = (Z) => Ce0.has(Z.toUpperCase()), uF = uZ.unionMany(Kz, Gz);
function qY(Z, J) {
  if (J = J.toUpperCase(), Mo.has(J))
    return e2.PNA;
  else if (Te0.has(Z))
    return e2.Protein;
  else if (sH0.has(Z))
    return e2.RNA;
  else if (oH0.has(Z))
    return e2.DNA;
  else if (aH0.has(Z))
    return e2.Saccharide;
  else if (mM.has(J))
    return e2.Water;
  else if (Do.has(J))
    return e2.Ion;
  else if (zo.has(J))
    return e2.Lipid;
  else if (_e0.has(Z))
    if (D3.has(J))
      return e2.Saccharide;
    else if (Kz.has(J))
      return e2.Protein;
    else if (dM.has(J))
      return e2.RNA;
    else if (pM.has(J))
      return e2.DNA;
    else
      return e2.Other;
  else
    return e2.Unknown;
}
function JN0(Z, J) {
  if (J === e2.Protein)
    if (Be0.has(Z))
      return q$.GammaProtein;
    else if (we0.has(Z))
      return q$.BetaProtein;
    else if (je0.has(Z))
      return q$.NA;
    else
      return q$.Protein;
  else if (J === e2.RNA)
    return q$.RNA;
  else if (J === e2.DNA)
    return q$.DNA;
  else if (J === e2.PNA)
    return q$.PNA;
  else
    return q$.NA;
}
function Ao(Z) {
  if (Z = Z.toUpperCase(), Kz.has(Z))
    return "peptide linking";
  else if (dM.has(Z))
    return "rna linking";
  else if (pM.has(Z))
    return "dna linking";
  else if (D3.has(Z))
    return "saccharide";
  else
    return "other";
}
function $N0(Z) {
  return {
    formula: "",
    formula_weight: 0,
    id: Z,
    name: Z,
    mon_nstd_flag: uF.has(Z) ? "y" : "n",
    pdbx_synonyms: [],
    type: Ao(Z)
  };
}
function XN0(Z) {
  if (Z = Z.toUpperCase(), mM.has(Z))
    return "water";
  else if (uF.has(Z))
    return "polymer";
  else if (D3.has(Z))
    return "branched";
  else
    return "non-polymer";
}
function YN0(Z, J) {
  if (Z = Z.toUpperCase(), nH0.has(J))
    return "polypeptide(L)";
  else if (lH0.has(J))
    return "polypeptide(D)";
  else if (sH0.has(J))
    return "polyribonucleotide";
  else if (oH0.has(J))
    return "polydeoxyribonucleotide";
  else if (aH0.has(J))
    return "oligosaccharide";
  else if (D3.has(Z))
    return "oligosaccharide";
  else if (Mo.has(Z))
    return "peptide nucleic acid";
  else if (vf.has(Z))
    return "polypeptide(L)";
  else if (rH0.has(Z))
    return "polypeptide(D)";
  else if (dM.has(Z))
    return "polyribonucleotide";
  else if (pM.has(Z))
    return "polydeoxyribonucleotide";
  else if (Ve0.has(J) || Do.has(Z))
    return "ion";
  else if (Ie0.has(J) || zo.has(Z))
    return "lipid";
  else if (iH0.has(J))
    return "peptide-like";
  else
    return "other";
}
function MR(Z) {
  return XJ(Z) || Bo(Z);
}
function XJ(Z) {
  return Z === e2.DNA || Z === e2.RNA || Z === e2.PNA;
}
function Bo(Z) {
  return Z === e2.Protein;
}
var m2;
(function(Z) {
  Z.is = r7.has, Z.create = r7.create;
  let J;
  (function($) {
    $[$.None = 0] = "None", $[$.DoubleHelix = 1] = "DoubleHelix", $[$.Helix = 2] = "Helix", $[$.Beta = 4] = "Beta", $[$.Bend = 8] = "Bend", $[$.Turn = 16] = "Turn", $[$.LeftHanded = 32] = "LeftHanded", $[$.RightHanded = 64] = "RightHanded", $[$.ClassicTurn = 128] = "ClassicTurn", $[$.InverseTurn = 256] = "InverseTurn", $[$.HelixOther = 512] = "HelixOther", $[$.Helix27 = 1024] = "Helix27", $[$.Helix3Ten = 2048] = "Helix3Ten", $[$.HelixAlpha = 4096] = "HelixAlpha", $[$.HelixGamma = 8192] = "HelixGamma", $[$.HelixOmega = 16384] = "HelixOmega", $[$.HelixPi = 32768] = "HelixPi", $[$.HelixPolyproline = 65536] = "HelixPolyproline", $[$.DoubleHelixOther = 131072] = "DoubleHelixOther", $[$.DoubleHelixZ = 262144] = "DoubleHelixZ", $[$.DoubleHelixA = 524288] = "DoubleHelixA", $[$.DoubleHelixB = 1048576] = "DoubleHelixB", $[$.BetaOther = 2097152] = "BetaOther", $[$.BetaStrand = 4194304] = "BetaStrand", $[$.BetaSheet = 8388608] = "BetaSheet", $[$.BetaBarell = 16777216] = "BetaBarell", $[$.TurnOther = 33554432] = "TurnOther", $[$.Turn1 = 67108864] = "Turn1", $[$.Turn2 = 134217728] = "Turn2", $[$.Turn3 = 268435456] = "Turn3", $[$.NA = 536870912] = "NA";
  })(J = Z.Flag || (Z.Flag = {})), Z.SecondaryStructureMmcif = {
    helx_lh_27_p: J.Helix | J.LeftHanded | J.Helix27,
    helx_lh_3t_p: J.Helix | J.LeftHanded | J.Helix3Ten,
    helx_lh_al_p: J.Helix | J.LeftHanded | J.HelixAlpha,
    helx_lh_a_n: J.DoubleHelix | J.LeftHanded | J.DoubleHelixA,
    helx_lh_b_n: J.DoubleHelix | J.LeftHanded | J.DoubleHelixB,
    helx_lh_ga_p: J.Helix | J.LeftHanded | J.HelixGamma,
    helx_lh_n: J.DoubleHelix | J.LeftHanded,
    helx_lh_om_p: J.Helix | J.LeftHanded | J.HelixOmega,
    helx_lh_ot_n: J.DoubleHelix | J.LeftHanded | J.DoubleHelixOther,
    helx_lh_ot_p: J.Helix | J.LeftHanded | J.HelixOther,
    helx_lh_p: J.Helix | J.LeftHanded,
    helx_lh_pi_p: J.Helix | J.LeftHanded | J.HelixPi,
    helx_lh_pp_p: J.Helix | J.LeftHanded | J.HelixPolyproline,
    helx_lh_z_n: J.DoubleHelix | J.LeftHanded | J.DoubleHelixZ,
    helx_n: J.DoubleHelix,
    helx_ot_n: J.DoubleHelix,
    helx_ot_p: J.Helix,
    helx_p: J.Helix,
    helx_rh_27_p: J.Helix | J.RightHanded | J.Helix27,
    helx_rh_3t_p: J.Helix | J.RightHanded | J.Helix3Ten,
    helx_rh_al_p: J.Helix | J.RightHanded | J.HelixAlpha,
    helx_rh_a_n: J.DoubleHelix | J.RightHanded | J.DoubleHelixA,
    helx_rh_b_n: J.DoubleHelix | J.RightHanded | J.DoubleHelixB,
    helx_rh_ga_p: J.Helix | J.RightHanded | J.HelixGamma,
    helx_rh_n: J.DoubleHelix | J.RightHanded,
    helx_rh_om_p: J.Helix | J.RightHanded | J.HelixOmega,
    helx_rh_ot_n: J.DoubleHelix | J.RightHanded | J.DoubleHelixOther,
    helx_rh_ot_p: J.Helix | J.RightHanded | J.HelixOther,
    helx_rh_p: J.Helix | J.RightHanded,
    helx_rh_pi_p: J.Helix | J.RightHanded | J.HelixPi,
    helx_rh_pp_p: J.Helix | J.RightHanded | J.HelixPolyproline,
    helx_rh_z_n: J.DoubleHelix | J.RightHanded | J.DoubleHelixZ,
    strn: J.Beta | J.BetaStrand,
    turn_ot_p: J.Turn | J.TurnOther,
    turn_p: J.Turn,
    turn_ty1p_p: J.Turn | J.InverseTurn | J.Turn1,
    turn_ty1_p: J.Turn | J.ClassicTurn | J.Turn1,
    turn_ty2p_p: J.Turn | J.InverseTurn | J.Turn2,
    turn_ty2_p: J.Turn | J.ClassicTurn | J.Turn2,
    turn_ty3p_p: J.Turn | J.InverseTurn | J.Turn3,
    turn_ty3_p: J.Turn | J.ClassicTurn | J.Turn3,
    bend: J.Bend,
    other: J.None
  }, Z.SecondaryStructurePdb = {
    1: J.Helix | J.RightHanded | J.HelixAlpha,
    2: J.Helix | J.RightHanded | J.HelixOmega,
    3: J.Helix | J.RightHanded | J.HelixPi,
    4: J.Helix | J.RightHanded | J.HelixGamma,
    5: J.Helix | J.RightHanded | J.Helix3Ten,
    6: J.Helix | J.LeftHanded | J.HelixAlpha,
    7: J.Helix | J.LeftHanded | J.HelixOmega,
    8: J.Helix | J.LeftHanded | J.HelixGamma,
    9: J.Helix | J.Helix27,
    10: J.Helix | J.HelixPolyproline
  }, Z.SecondaryStructureStride = {
    H: J.Helix | J.HelixAlpha,
    G: J.Helix | J.Helix3Ten,
    I: J.Helix | J.HelixPi,
    E: J.Beta | J.BetaSheet,
    B: J.Beta | J.BetaStrand,
    T: J.Turn,
    C: J.NA
  }, Z.SecondaryStructureDssp = {
    H: J.Helix | J.HelixAlpha,
    B: J.Beta | J.BetaStrand,
    E: J.Beta | J.BetaSheet,
    G: J.Helix | J.Helix3Ten,
    I: J.Helix | J.HelixPi,
    T: J.Turn,
    S: J.Bend
  };
})(m2 || (m2 = {}));
var s1;
(function(Z) {
  Z.is = r7.has;
  let J;
  (function(G) {
    G[G.None = 0] = "None", G[G.Covalent = 1] = "Covalent", G[G.MetallicCoordination = 2] = "MetallicCoordination", G[G.HydrogenBond = 4] = "HydrogenBond", G[G.Disulfide = 8] = "Disulfide", G[G.Aromatic = 16] = "Aromatic", G[G.Computed = 32] = "Computed";
  })(J = Z.Flag || (Z.Flag = {}));
  function $(G) {
    return r7.create(G);
  }
  Z.create = $;
  function X(G) {
    return (G & Z.Flag.Covalent) !== 0;
  }
  Z.isCovalent = X;
  function Y(G) {
    return G === Math.pow(2, 6) - 1;
  }
  Z.isAll = Y, Z.Names = {
    covalent: J.Covalent,
    "metal-coordination": J.MetallicCoordination,
    "hydrogen-bond": J.HydrogenBond,
    disulfide: J.Disulfide,
    aromatic: J.Aromatic,
    computed: J.Computed
  };
  function Q(G) {
    return G in Z.Names;
  }
  Z.isName = Q;
  function W(G) {
    switch (G) {
      case "covalent":
        return J.Covalent;
      case "metal-coordination":
        return J.MetallicCoordination;
      case "hydrogen-bond":
        return J.HydrogenBond;
      case "disulfide":
        return J.Disulfide;
      case "aromatic":
        return J.Aromatic;
      case "computed":
        return J.Computed;
    }
  }
  Z.fromName = W;
  function K(G) {
    let H = J.None;
    for (let N = 0, q = G.length;N < q; ++N)
      H |= W(G[N]);
    return H;
  }
  Z.fromNames = K;
})(s1 || (s1 = {}));
var Sf = {
  ALA: [0.17, 0.5, 0.33],
  ARG: [0.81, 1.81, 1],
  ASN: [0.42, 0.85, 0.43],
  ASP: [1.23, 3.64, 2.41],
  ASH: [-0.07, 0.43, 0.5],
  CYS: [-0.24, -0.02, 0.22],
  GLN: [0.58, 0.77, 0.19],
  GLU: [2.02, 3.63, 1.61],
  GLH: [-0.01, 0.11, 0.12],
  GLY: [0.01, 1.15, 1.14],
  HIS: [0.17, 0.11, -0.06],
  ILE: [-0.31, -1.12, -0.81],
  LEU: [-0.56, -1.25, -0.69],
  LYS: [0.99, 2.8, 1.81],
  MET: [-0.23, -0.67, -0.44],
  PHE: [-1.13, -1.71, -0.58],
  PRO: [0.45, 0.14, -0.31],
  SER: [0.13, 0.46, 0.33],
  THR: [0.14, 0.25, 0.11],
  TRP: [-1.85, -2.09, -0.24],
  TYR: [-0.94, -0.71, 0.23],
  VAL: [0.07, -0.46, -0.53],
  HSD: [0.17, 0.11, -0.06],
  HSE: [0.17, 0.11, -0.06],
  HSP: [0.96, 2.33, 1.37],
  HID: [0.17, 0.11, -0.06],
  HIE: [0.17, 0.11, -0.06],
  HIP: [0.96, 2.33, 1.37]
};

// node_modules/molstar/lib/mol-model-formats/structure/property/bonds/index-pair.js
function ve0(Z, J, $, X) {
  let Y = new lJ.EdgeBuilder(X, Z, J), Q = new Int32Array(Y.slotCount), W = new Array(Y.slotCount), K = new Array(Y.slotCount), G = new Int8Array(Y.slotCount), H = new Array(Y.slotCount), N = new Array(Y.slotCount);
  for (let q = 0, U = Y.edgeCount;q < U; q++)
    Y.addNextEdge(), Y.assignProperty(Q, $.key ? $.key[q] : -1), Y.assignDirectedProperty(W, $.operatorA ? $.operatorA[q] : -1, K, $.operatorB ? $.operatorB[q] : -1), Y.assignProperty(G, $.order ? $.order[q] : 1), Y.assignProperty(H, $.distance ? $.distance[q] : -1), Y.assignProperty(N, $.flag ? $.flag[q] : s1.Flag.Covalent);
  return Y.createGraph({ key: Q, operatorA: W, operatorB: K, order: G, distance: H, flag: N });
}
var j9;
(function(Z) {
  Z.Descriptor = {
    name: "index_pair_bonds"
  }, Z.Provider = e$.create(Z.Descriptor, { asDynamic: !0 }), Z.DefaultProps = {
    maxDistance: -1,
    cacheable: !0
  };
  function J(X, Y = {}) {
    let Q = { ...Z.DefaultProps, ...Y }, { pairs: W, count: K } = X, G = W.indexA.toArray(), H = W.indexB.toArray(), N = W.key && W.key.toArray(), q = W.operatorA && W.operatorA.toArray(), U = W.operatorB && W.operatorB.toArray(), F = W.order && W.order.toArray(), E = W.distance && W.distance.toArray(), R = W.flag && W.flag.toArray(), z = !1;
    if (q && U) {
      z = !0;
      for (let B = 0, T = q.length;B < T; ++B)
        if (q[B] === -1 || U[B] === -1) {
          z = !1;
          break;
        }
    }
    let D = ve0(G, H, { key: N, operatorA: q, operatorB: U, order: F, distance: E, flag: R }, K), A = /* @__PURE__ */ new Map;
    if (z) {
      let { operatorA: B, operatorB: T } = D.edgeProps;
      for (let w = 0, V = B.length;w < V; ++w)
        if (B[w] === T[w]) {
          let P = B[w];
          if (A.has(P))
            A.get(P).push(w);
          else
            A.set(P, [w]);
        }
    }
    return {
      bonds: D,
      maxDistance: Q.maxDistance,
      cacheable: Q.cacheable,
      hasOperators: z,
      bySameOperator: A
    };
  }
  Z.fromData = J;
  function $(X, Y, Q, W, K) {
    let G, H, N, q;
    if (Y < Q)
      G = Y, H = Q, N = W, q = K;
    else
      G = Q, H = Y, N = K, q = W;
    for (let U = X.offset[G], F = X.offset[G + 1];U < F; U++)
      if (X.b[U] === H && X.edgeProps.operatorA[U] === N && X.edgeProps.operatorB[U] === q)
        return U;
    return -1;
  }
  Z.getEdgeIndexForOperators = $;
})(j9 || (j9 = {}));

// node_modules/molstar/lib/mol-io/reader/common/text/column/token.js
function I2(Z) {
  return function(J) {
    return ff(Z, J);
  };
}
function ff(Z, J) {
  let { data: $, indices: X, count: Y } = Z, { valueType: Q } = J, W = Q === "str" ? (K) => $.substring(X[2 * K], X[2 * K + 1]) : Q === "int" ? (K) => z3($, X[2 * K], X[2 * K + 1]) || 0 : (K) => _W($, X[2 * K], X[2 * K + 1]) || 0;
  return {
    schema: J,
    __array: void 0,
    isDefined: !0,
    rowCount: Y,
    value: W,
    valueKind: (K) => s.ValueKinds.Present,
    toArray: (K) => w7.createAndFillArray(Y, W, K),
    areValuesEqual: wo(Z)
  };
}
function wo(Z) {
  let { data: J, indices: $ } = Z;
  return function(X, Y) {
    let Q = $[2 * X], W = $[2 * Y], K = $[2 * X + 1] - Q;
    if (K !== $[2 * Y + 1] - W)
      return !1;
    for (let G = 0;G < K; G++)
      if (J.charCodeAt(G + Q) !== J.charCodeAt(G + W))
        return !1;
    return !0;
  };
}
function QN0(Z) {
  let { count: J, indices: $ } = Z;
  for (let X = 0;X < J; ++X)
    if ($[2 * X] !== $[2 * X + 1])
      return !1;
  return !0;
}

// node_modules/molstar/lib/mol-io/reader/cif/data-model.js
function hf(Z, J) {
  return { name: J, blocks: Z };
}
function m_(Z, J, $, X = []) {
  return {
    categoryNames: Z,
    header: $,
    categories: J,
    saveFrames: X,
    getField(Y) {
      let [Q, W] = Y.split(".");
      return J[Q].getField(W || "");
    }
  };
}
function WN0(Z, J, $) {
  return { categoryNames: Z, header: $, categories: J };
}
function YJ(Z, J, $, X) {
  return { rowCount: J, name: Z, fieldNames: [...$], getField(Y) {
    return X[Y];
  } };
}
(function(Z) {
  function J(Y) {
    return { rowCount: 0, name: Y, fieldNames: [], getField(Q) {
      return;
    } };
  }
  Z.empty = J;
  function $(Y, Q) {
    let W = Object.keys(Q);
    return {
      rowCount: W.length > 0 ? Q[W[0]].rowCount : 0,
      name: Y,
      fieldNames: W,
      getField(K) {
        return Q[K];
      }
    };
  }
  Z.ofFields = $;
  function X(Y, Q) {
    let W = {};
    for (let K of Q._columns)
      W[K] = K2.ofColumn(Q[K]);
    return $(Y, W);
  }
  Z.ofTable = X;
})(YJ || (YJ = {}));
var K2;
(function(Z) {
  function J(K) {
    return $([K]);
  }
  Z.ofString = J;
  function $(K) {
    let G = K.length, H = (F) => {
      let E = K[F];
      if (!E || E === "." || E === "?")
        return "";
      return E;
    }, N = (F) => {
      let E = K[F];
      return z3(E, 0, E.length) || 0;
    }, q = (F) => {
      let E = K[F];
      return _W(E, 0, E.length) || 0;
    };
    return {
      __array: void 0,
      binaryEncoding: void 0,
      isDefined: !0,
      rowCount: G,
      str: H,
      int: N,
      float: q,
      valueKind: (F) => {
        let E = K[F], R = E.length;
        if (R > 1)
          return s.ValueKinds.Present;
        if (R === 0)
          return s.ValueKinds.NotPresent;
        let z = E.charCodeAt(0);
        if (z === 46)
          return s.ValueKinds.NotPresent;
        if (z === 63)
          return s.ValueKinds.Unknown;
        return s.ValueKinds.Present;
      },
      areValuesEqual: (F, E) => K[F] === K[E],
      toStringArray: (F) => F ? w7.createAndFillArray(G, H, F) : K,
      toIntArray: (F) => w7.createAndFillArray(G, N, F),
      toFloatArray: (F) => w7.createAndFillArray(G, q, F)
    };
  }
  Z.ofStrings = $;
  function X(K) {
    let G = K.length, H = (F) => {
      return "" + K[F];
    }, N = (F) => K[F], q = (F) => s.ValueKinds.Present, U = (F) => {
      if (!F || F.array && K instanceof F.array)
        return K;
      else
        return w7.createAndFillArray(G, N, F);
    };
    return {
      __array: void 0,
      binaryEncoding: void 0,
      isDefined: !0,
      rowCount: G,
      str: H,
      int: N,
      float: N,
      valueKind: q,
      areValuesEqual: (F, E) => K[F] === K[E],
      toStringArray: (F) => w7.createAndFillArray(G, H, F),
      toIntArray: U,
      toFloatArray: U
    };
  }
  Z.ofNumbers = X;
  function Y(K) {
    let { data: G, indices: H, count: N } = K, q = (R) => {
      let z = G.substring(H[2 * R], H[2 * R + 1]);
      if (z === "." || z === "?")
        return "";
      return z;
    }, U = (R) => {
      return z3(G, H[2 * R], H[2 * R + 1]) || 0;
    }, F = (R) => {
      return _W(G, H[2 * R], H[2 * R + 1]) || 0;
    };
    return {
      __array: void 0,
      binaryEncoding: void 0,
      isDefined: !0,
      rowCount: N,
      str: q,
      int: U,
      float: F,
      valueKind: (R) => {
        let z = H[2 * R], D = H[2 * R + 1] - z;
        if (D > 1)
          return s.ValueKinds.Present;
        if (D === 0)
          return s.ValueKinds.NotPresent;
        let A = G.charCodeAt(z);
        if (A === 46)
          return s.ValueKinds.NotPresent;
        if (A === 63)
          return s.ValueKinds.Unknown;
        return s.ValueKinds.Present;
      },
      areValuesEqual: wo(K),
      toStringArray: (R) => w7.createAndFillArray(N, q, R),
      toIntArray: (R) => w7.createAndFillArray(N, U, R),
      toFloatArray: (R) => w7.createAndFillArray(N, F, R)
    };
  }
  Z.ofTokens = Y;
  function Q(K) {
    let { rowCount: G, valueKind: H, areValuesEqual: N, isDefined: q } = K, U, F, E;
    switch (K.schema.valueType) {
      case "float":
      case "int":
        U = (z) => {
          return "" + K.value(z);
        }, F = K.value, E = K.value;
        break;
      case "str":
        U = K.value, F = (z) => {
          let D = K.value(z);
          return z3(D, 0, D.length) || 0;
        }, E = (z) => {
          let D = K.value(z);
          return _W(D, 0, D.length) || 0;
        };
        break;
      case "list":
        let { separator: R } = K.schema;
        U = (z) => K.value(z).join(R), F = (z) => NaN, E = (z) => NaN;
        break;
      default:
        throw new Error(`unsupported valueType '${K.schema.valueType}'`);
    }
    return {
      __array: void 0,
      binaryEncoding: void 0,
      isDefined: q,
      rowCount: G,
      str: U,
      int: F,
      float: E,
      valueKind: H,
      areValuesEqual: N,
      toStringArray: (R) => w7.createAndFillArray(G, U, R),
      toIntArray: (R) => w7.createAndFillArray(G, F, R),
      toFloatArray: (R) => w7.createAndFillArray(G, E, R)
    };
  }
  Z.ofColumn = Q;
  function W(K, G) {
    return Q(s.Undefined(K, G));
  }
  Z.ofUndefined = W;
})(K2 || (K2 = {}));
function KN0(Z, J, $, X) {
  let Y = $ ? 0 : 1;
  switch (J) {
    case 1:
      return X === "brackets" ? (Q) => `${Z}[${Q + Y}]` : (Q) => `${Z}_${Q + Y}`;
    case 2:
      return X === "brackets" ? (Q, W) => `${Z}[${Q + Y}][${W + Y}]` : (Q, W) => `${Z}_${Q + Y}${W + Y}`;
    case 3:
      return X === "brackets" ? (Q, W, K) => `${Z}[${Q + Y}][${W + Y}][${K + Y}]` : (Q, W, K) => `${Z}_${Q + Y}${W + Y}${K + Y}`;
    default:
      throw new Error("Tensors with rank > 3 or rank 0 are currently not supported.");
  }
}
function GN0(Z, J, $, X) {
  let Y = J.create();
  if (J.rank === 1) {
    let Q = J.dimensions[0];
    for (let W = 0;W < Q; W++) {
      let K = Z.getField(X(W));
      J.set(Y, W, K ? K.float($) : 0);
    }
  } else if (J.rank === 2) {
    let Q = J.dimensions[0], W = J.dimensions[1];
    for (let K = 0;K < Q; K++)
      for (let G = 0;G < W; G++) {
        let H = Z.getField(X(K, G));
        J.set(Y, K, G, H ? H.float($) : 0);
      }
  } else if (J.rank === 3) {
    let Q = J.dimensions[0], W = J.dimensions[1], K = J.dimensions[2];
    for (let G = 0;G < Q; G++)
      for (let H = 0;H < W; H++)
        for (let N = 0;N < K; N++) {
          let q = Z.getField(X(G, H, N));
          J.set(Y, G, H, N, q ? q.float($) : 0);
        }
  } else
    throw new Error("Tensors with rank > 3 or rank 0 are currently not supported.");
  return Y;
}

// node_modules/molstar/lib/mol-io/reader/cif/schema.js
var uM;
(function(Z) {
  function J(Y) {
    return Y.replace(".", "_").replace(/\[/, "_").replace(/(\[|\])/g, "");
  }
  Z.canonical = J;
  function $(Y, Q) {
    return J(Y) === J(Q);
  }
  Z.equal = $;
  function X(Y, Q, W = !1) {
    let K = `${Y}${Q ? `.${Q}` : ""}`;
    return W ? J(K) : K;
  }
  Z.create = X;
})(uM || (uM = {}));
function NN0(Z, J, $) {
  let X = {};
  for (let Y of J.blocks)
    X[Y.header] = HQ(Z, Y, $);
  return X;
}
function HQ(Z, J, $) {
  return xe0(Z, J, $);
}
function qN0(Z, J) {
  return new To(J, Z, !0);
}
function Se0(Z) {
  switch (Z.valueType) {
    case "str":
      return (J, $, X) => fe0(Z, J, J.str, J.toStringArray);
    case "int":
      return (J, $, X) => HN0(Z, J, J.int, J.toIntArray);
    case "float":
      return (J, $, X) => HN0(Z, J, J.float, J.toFloatArray);
    case "list":
      throw new Error("Use createListColumn instead.");
    case "tensor":
      throw new Error("Use createTensorColumn instead.");
  }
}
function fe0(Z, J, $, X) {
  return {
    schema: Z,
    __array: J.__array,
    isDefined: J.isDefined,
    rowCount: J.rowCount,
    value: Z.transform === "lowercase" ? (Y) => $(Y).toLowerCase() : Z.transform === "uppercase" ? (Y) => $(Y).toUpperCase() : $,
    valueKind: J.valueKind,
    areValuesEqual: J.areValuesEqual,
    toArray: Z.transform === "lowercase" ? (Y) => Array.from(X(Y)).map((Q) => Q.toLowerCase()) : Z.transform === "uppercase" ? (Y) => Array.from(X(Y)).map((Q) => Q.toUpperCase()) : X
  };
}
function HN0(Z, J, $, X) {
  return {
    schema: Z,
    __array: J.__array,
    isDefined: J.isDefined,
    rowCount: J.rowCount,
    value: $,
    valueKind: J.valueKind,
    areValuesEqual: J.areValuesEqual,
    toArray: X
  };
}
function he0(Z, J, $) {
  let { separator: X, itemParse: Y } = Z, Q = J.getField($), W = Q ? (G) => Q.str(G).split(X).map((H) => Y(H.trim())).filter((H) => !!H) : (G) => [], K = (G) => w7.createAndFillArray(J.rowCount, W, G);
  return {
    schema: Z,
    __array: void 0,
    isDefined: !!Q,
    rowCount: J.rowCount,
    value: W,
    valueKind: Q ? Q.valueKind : () => s.ValueKinds.NotPresent,
    areValuesEqual: (G, H) => b7(W(G), W(H)),
    toArray: K
  };
}
function be0(Z, J, $) {
  let X = Z.space, Y = J.fieldNames.includes(`${$}[0]`) || J.fieldNames.includes(`${$}[0][0]`) || J.fieldNames.includes(`${$}[0][0][0]`), Q = Y ? 0 : 1, W = J.fieldNames.includes(`${$}_1`) || J.fieldNames.includes(`${$}_11`) || J.fieldNames.includes(`${$}_111`) ? "underscore" : "brackets", K = KN0($, X.rank, Y, W), G = J.getField(K(Q, Q, Q)) || s.Undefined(J.rowCount, Z), H = (q) => GN0(J, X, q, K), N = (q) => w7.createAndFillArray(J.rowCount, H, q);
  return {
    schema: Z,
    __array: void 0,
    isDefined: G.isDefined,
    rowCount: J.rowCount,
    value: H,
    valueKind: G.valueKind,
    areValuesEqual: (q, U) => M8.areEqualExact(H(q), H(U)),
    toArray: N
  };
}

class To {
  constructor(Z, J, $) {
    this._isDefined = $;
    let X = Object.keys(J);
    this._rowCount = Z.rowCount, this._columns = X, this._schema = J;
    let Y = Object.create(null);
    for (let Q of X)
      Object.defineProperty(this, Q, {
        get: function() {
          if (Y[Q])
            return Y[Q];
          let W = J[Q];
          if (W.valueType === "list")
            Y[Q] = he0(W, Z, Q);
          else if (W.valueType === "tensor")
            Y[Q] = be0(W, Z, Q);
          else {
            let K = Se0(W), G = Z.getField(Q);
            Y[Q] = G ? K(G, Z, Q) : s.Undefined(Z.rowCount, W);
          }
          return Y[Q];
        },
        enumerable: !0,
        configurable: !1
      });
  }
}
function xe0(Z, J, $) {
  let X = Object.create(null);
  for (let Y of Object.keys(Z))
    X[Y] = me0(Y, Z[Y], J, $);
  return y_.ofTables(J.header, Z, X);
}
function ye0(Z) {
  let J = Object.create(null);
  for (let $ of Object.keys(Z.categories))
    for (let X of Z.categories[$].fieldNames) {
      let Y = uM.create($, X, !0);
      J[Y] = Z.categories[$].getField(X);
    }
  return J;
}
function ge0(Z, J, $, X) {
  let Y = uM.create(J, Z), Q = uM.canonical(Y);
  if (Q in $)
    return $[Q];
  if (X && Y in X)
    for (let W of X[Y]) {
      let K = uM.canonical(W);
      if (K in $)
        return $[K];
    }
}
function me0(Z, J, $, X) {
  let Y = $.categories[Z];
  if (X) {
    let Q = ye0($), W = Object.create(null), K = [], G = 0;
    for (let H of Object.keys(J)) {
      let N = ge0(H, Z, Q, X);
      if (N)
        W[H] = N, K.push(H), G = N.rowCount;
    }
    Y = {
      rowCount: G,
      name: Z,
      fieldNames: [...K],
      getField(H) {
        return W[H];
      }
    };
  }
  return new To(Y || YJ.empty(Z), J, !!Y);
}

// node_modules/molstar/lib/mol-model/structure/structure/element/element.js
var W0 = {};
y9(W0, {
  residueIndex: () => K61,
  property: () => Ks,
  entityIndex: () => H61,
  coarseProperty: () => W61,
  chainIndex: () => G61,
  atomicProperty: () => Q61,
  Stats: () => Ws,
  Schema: () => o_,
  Loci: () => B3,
  Location: () => H9,
  Bundle: () => oF
});

// node_modules/molstar/lib/mol-model/structure/structure/element/location.js
var H9;
(function(Z) {
  function J(F, E, R) {
    return {
      kind: "element-location",
      structure: F,
      unit: E,
      element: R || 0
    };
  }
  Z.create = J;
  function $(F) {
    return J(F.structure, F.unit, F.element);
  }
  Z.clone = $;
  function X(F, E, R, z) {
    if (E)
      F.structure = E;
    if (R)
      F.unit = R;
    if (z !== void 0)
      F.element = z;
    return F;
  }
  Z.set = X;
  function Y(F, E) {
    return F.unit = E.unit, F.element = E.element, F;
  }
  Z.copy = Y;
  function Q(F) {
    return !!F && F.kind === "element-location";
  }
  Z.is = Q;
  function W(F, E) {
    return F.unit === E.unit && F.element === E.element;
  }
  Z.areEqual = W;
  let K = M(), G = M();
  function H(F, E) {
    return F.unit.conformation.position(F.element, K), E.unit.conformation.position(E.element, G), M.distance(K, G);
  }
  Z.distance = H;
  function N(F, E) {
    return E.unit.conformation.position(E.element, F);
  }
  Z.position = N;
  function q(F) {
    return F.unit.model.atomicHierarchy.residueAtomSegments.index[F.element];
  }
  Z.residueIndex = q;
  function U(F) {
    return F.unit.model.atomicHierarchy.chainAtomSegments.index[F.element];
  }
  Z.chainIndex = U;
})(H9 || (H9 = {}));
// node_modules/molstar/lib/mol-data/generic/hash-set.js
class FN0 {
  add(Z) {
    let J = this.getHash(Z);
    if (this.byHash.has(J)) {
      let $ = this.byHash.get(J);
      for (let X = 0, Y = $.length;X < Y; X++)
        if (this.areEqual(Z, $[X]))
          return !1;
      return $[$.length] = Z, this.size++, !0;
    } else
      return this.byHash.set(J, [Z]), this.size++, !0;
  }
  has(Z) {
    let J = this.getHash(Z);
    if (!this.byHash.has(J))
      return !1;
    let $ = this.byHash.get(J);
    for (let X = 0, Y = $.length;X < Y; X++)
      if (this.areEqual(Z, $[X]))
        return !0;
    return !1;
  }
  constructor(Z, J) {
    this.getHash = Z, this.areEqual = J, this.size = 0, this.byHash = /* @__PURE__ */ new Map;
  }
}
function cM(Z, J) {
  return new FN0(Z, J);
}
// node_modules/molstar/lib/mol-data/generic/linked-list.js
function d_() {
  return new LN0;
}
function UN0(Z) {
  return { previous: null, next: null, inList: !0, value: Z };
}

class LN0 {
  constructor() {
    this.count = 0, this.first = null, this.last = null;
  }
  addFirst(Z) {
    let J = UN0(Z);
    if (J.inList = !0, this.first)
      this.first.previous = J;
    if (J.next = this.first, this.first = J, this.count++, !this.last)
      this.last = J;
    return J;
  }
  addLast(Z) {
    let J = UN0(Z);
    if (this.last !== null)
      this.last.next = J;
    if (J.previous = this.last, this.last = J, this.first === null)
      this.first = J;
    return J.inList = !0, this.count++, J;
  }
  removeFirst() {
    let Z = this.first;
    if (Z)
      return this.remove(Z), Z.value;
    return;
  }
  removeLast() {
    let Z = this.last;
    if (Z)
      return this.remove(Z), Z.value;
    return;
  }
  remove(Z) {
    if (!Z.inList)
      return;
    if (Z.inList = !1, Z.previous !== null)
      Z.previous.next = Z.next;
    else if (Z.previous === null)
      this.first = Z.next;
    if (Z.next !== null)
      Z.next.previous = Z.previous;
    else if (Z.next === null)
      this.last = Z.previous;
    Z.next = null, Z.previous = null, this.count--;
  }
  find(Z) {
    let J = this.first;
    while (J !== null) {
      if (J.value === Z)
        return J;
      J = J.next;
    }
    return;
  }
}
// node_modules/molstar/lib/mol-script/language/type.js
var r0;
(function(Z) {
  function J(K, G, H) {
    return { kind: "variable", name: K, type: G, isConstraint: H };
  }
  Z.Variable = J;
  function $(K, G, H) {
    return { kind: "value", namespace: K, name: G, parent: H };
  }
  Z.Value = $;
  function X(K, G, H, N) {
    return { kind: "container", namespace: K, name: G, child: H, alias: N };
  }
  Z.Container = X;
  function Y(K) {
    return { kind: "union", types: K };
  }
  Z.Union = Y;
  function Q(K, G, H, N) {
    let q = Object.create(null);
    for (let U of N)
      q[U] = !0;
    return { kind: "oneof", namespace: K, name: G, type: H, values: q };
  }
  Z.OneOf = Q, Z.Any = { kind: "any" }, Z.AnyValue = { kind: "any-value" }, Z.Num = $("", "Number"), Z.Str = $("", "String"), Z.Bool = Q("", "Bool", Z.Str, ["true", "false"]);
  function W({ values: K }) {
    return Object.keys(K).sort();
  }
  Z.oneOfValues = W;
})(r0 || (r0 = {}));

// node_modules/molstar/lib/mol-script/language/expression.js
var VJ;
(function(Z) {
  function J(G) {
    return { name: G };
  }
  Z.Symbol = J;
  function $(G, H) {
    return H ? { head: G, args: H } : { head: G };
  }
  Z.Apply = $;
  function X(G) {
    return !!G && Array.isArray(G);
  }
  Z.isArgumentsArray = X;
  function Y(G) {
    return !!G && !Array.isArray(G);
  }
  Z.isArgumentsMap = Y;
  function Q(G) {
    return !W(G) && !K(G);
  }
  Z.isLiteral = Q;
  function W(G) {
    return !!G && !!G.head && typeof G === "object";
  }
  Z.isApply = W;
  function K(G) {
    return !!G && typeof G.name === "string";
  }
  Z.isSymbol = K;
})(VJ || (VJ = {}));

// node_modules/molstar/lib/mol-script/language/symbol.js
function Q2(Z, J) {
  let { description: $ = void 0, isOptional: X = !1, isRest: Y = !1, defaultValue: Q = void 0 } = J || {};
  return { type: Z, isOptional: X, isRest: Y, defaultValue: Q, description: $ };
}
var r2;
(function(Z) {
  Z.None = J({});
  function J(X) {
    return { kind: "dictionary", map: X, "@type": 0 };
  }
  Z.Dictionary = J;
  function $(X, Y) {
    let { nonEmpty: Q = !1 } = Y || {};
    return { kind: "list", type: X, nonEmpty: Q, "@type": 0 };
  }
  Z.List = $;
})(r2 || (r2 = {}));
function Hz(Z, J, $, X) {
  let Y = function(Q) {
    return VJ.Apply(VJ.Symbol(Y.id), Q);
  };
  return Y.info = { namespace: "", name: Z, description: X }, Y.id = "", Y.args = J, Y.type = $, Y;
}
function lM(Z, J, $, X) {
  let Y = function(Q) {
    return VJ.Apply(VJ.Symbol(Y.id), Q);
  };
  return Y.info = { namespace: Z, name: J, description: X }, Y.id = `${Z}.${J}`, Y.args = r2.None, Y.type = $, Y;
}
function p_(Z) {
  let J = Z;
  return typeof J === "function" && !!J.info && !!J.args && typeof J.info.namespace === "string" && !!J.type;
}

// node_modules/molstar/lib/mol-script/language/helpers.js
function H8(Z, J, $) {
  return Hz("", Z, J, $);
}
function bf(Z) {
  EN0("", "", Z);
}
function xf(Z) {
  let J = [];
  return ON0(Z, J), J;
}
function RN0(Z) {
  let J = /([a-z])([A-Z])([a-z]|$)/g;
  return Z.replace(J, ($, X, Y, Q) => `${X}-${Y.toLocaleLowerCase()}${Q}`).replace(J, ($, X, Y, Q) => `${X}-${Y.toLocaleLowerCase()}${Q}`);
}
function EN0(Z, J, $) {
  if (p_($)) {
    $.info.namespace = Z, $.info.name = $.info.name || RN0(J), $.id = `${$.info.namespace}.${$.info.name}`;
    return;
  }
  let X = `${$["@namespace"] || RN0(J)}`, Y = Z ? `${Z}.${X}` : X;
  for (let Q of Object.keys($)) {
    if (typeof $[Q] !== "object" && !p_($[Q]))
      continue;
    EN0(Y, Q, $[Q]);
  }
}
function ON0(Z, J) {
  if (p_(Z)) {
    J.push(Z);
    return;
  }
  for (let $ of Object.keys(Z)) {
    if (typeof Z[$] !== "object" && !p_(Z[$]))
      continue;
    ON0(Z[$], J);
  }
}

// node_modules/molstar/lib/mol-script/language/symbol-table/core.js
var $Z;
(function(Z) {
  Z.AnyVar = r0.Variable("a", r0.Any), Z.AnyValueVar = r0.Variable("a", r0.Any), Z.ConstrainedVar = r0.Variable("a", r0.Any, !0), Z.Regex = r0.Value("Core", "Regex"), Z.Set = (J) => r0.Container("Core", "Set", J || Z.AnyValueVar), Z.List = (J) => r0.Container("Core", "List", J || Z.AnyVar), Z.Fn = (J, $) => r0.Container("Core", "Fn", J || Z.AnyVar, $), Z.Flags = (J, $) => r0.Container("Core", "Flags", J, $), Z.BitFlags = Z.Flags(r0.Num, "BitFlags");
})($Z || ($Z = {}));
function h$(Z, J) {
  return H8(r2.Dictionary({ 0: Q2(Z) }), Z, J);
}
function AR(Z, J) {
  return H8(r2.List(Z, { nonEmpty: !0 }), Z, J);
}
function M3(Z, J, $) {
  return H8(r2.Dictionary({
    0: Q2(Z),
    1: Q2(Z)
  }), J, $);
}
var Ye1 = r2.Dictionary({
  0: Q2(r0.Num),
  1: Q2(r0.Num)
}), pe0 = {
  "@header": "Types",
  bool: H8(r2.Dictionary({ 0: Q2(r0.AnyValue) }), r0.Bool, "Convert a value to boolean."),
  num: H8(r2.Dictionary({ 0: Q2(r0.AnyValue) }), r0.Num, "Convert a value to number."),
  str: H8(r2.Dictionary({ 0: Q2(r0.AnyValue) }), r0.Str, "Convert a value to string."),
  regex: H8(r2.Dictionary({
    0: Q2(r0.Str, { description: "Expression" }),
    1: Q2(r0.Str, { isOptional: !0, description: "Flags, e.g. 'i' for ignore case" })
  }), $Z.Regex, "Creates a regular expression from a string using the ECMAscript syntax."),
  list: H8(r2.List($Z.AnyVar), $Z.List()),
  set: H8(r2.List($Z.AnyValueVar), $Z.Set()),
  bitflags: H8(r2.Dictionary({ 0: Q2(r0.Num) }), $Z.BitFlags, "Interpret a number as bitflags."),
  compositeKey: H8(r2.List(r0.AnyValue), r0.AnyValue)
}, ue0 = {
  "@header": "Logic",
  not: h$(r0.Bool),
  and: AR(r0.Bool),
  or: AR(r0.Bool)
}, ce0 = {
  "@header": "Control",
  eval: H8(r2.Dictionary({ 0: Q2($Z.Fn($Z.AnyVar)) }), $Z.AnyVar, "Evaluate a function."),
  fn: H8(r2.Dictionary({ 0: Q2($Z.AnyVar) }), $Z.Fn($Z.AnyVar), 'Wrap an expression to a "lazy" function.'),
  if: H8(r2.Dictionary({
    0: Q2(r0.Bool, { description: "Condition" }),
    1: Q2(r0.Variable("a", r0.Any), { description: "If true" }),
    2: Q2(r0.Variable("b", r0.Any), { description: "If false" })
  }), r0.Union([r0.Variable("a", r0.Any), r0.Variable("b", r0.Any)])),
  assoc: H8(r2.Dictionary({
    0: Q2(r0.Str, { description: "Name" }),
    1: Q2(r0.Variable("a", r0.Any), { description: "Value to assign" })
  }), r0.Variable("a", r0.Any))
}, le0 = {
  "@header": "Relational",
  eq: M3(r0.Variable("a", r0.AnyValue, !0), r0.Bool),
  neq: M3(r0.Variable("a", r0.AnyValue, !0), r0.Bool),
  lt: M3(r0.Num, r0.Bool),
  lte: M3(r0.Num, r0.Bool),
  gr: M3(r0.Num, r0.Bool),
  gre: M3(r0.Num, r0.Bool),
  inRange: H8(r2.Dictionary({
    0: Q2(r0.Num, { description: "Value to test" }),
    1: Q2(r0.Num, { description: "Minimum value" }),
    2: Q2(r0.Num, { description: "Maximum value" })
  }), r0.Bool, "Check if the value of the 1st argument is >= 2nd and <= 3rd.")
}, ne0 = {
  "@header": "Math",
  add: AR(r0.Num),
  sub: AR(r0.Num),
  mult: AR(r0.Num),
  div: M3(r0.Num, r0.Num),
  pow: M3(r0.Num, r0.Num),
  mod: M3(r0.Num, r0.Num),
  min: AR(r0.Num),
  max: AR(r0.Num),
  cantorPairing: M3(r0.Num, r0.Num),
  sortedCantorPairing: M3(r0.Num, r0.Num),
  invertCantorPairing: H8(r2.Dictionary({ 0: Q2(r0.Num) }), $Z.List(r0.Num)),
  floor: h$(r0.Num),
  ceil: h$(r0.Num),
  roundInt: h$(r0.Num),
  trunc: h$(r0.Num),
  abs: h$(r0.Num),
  sign: h$(r0.Num),
  sqrt: h$(r0.Num),
  cbrt: h$(r0.Num),
  sin: h$(r0.Num),
  cos: h$(r0.Num),
  tan: h$(r0.Num),
  asin: h$(r0.Num),
  acos: h$(r0.Num),
  atan: h$(r0.Num),
  sinh: h$(r0.Num),
  cosh: h$(r0.Num),
  tanh: h$(r0.Num),
  exp: h$(r0.Num),
  log: h$(r0.Num),
  log10: h$(r0.Num),
  atan2: M3(r0.Num, r0.Num)
}, ie0 = {
  "@header": "Strings",
  concat: AR(r0.Str),
  match: H8(r2.Dictionary({ 0: Q2($Z.Regex), 1: Q2(r0.Str) }), r0.Bool)
}, oe0 = {
  "@header": "Lists",
  getAt: H8(r2.Dictionary({ 0: Q2($Z.List()), 1: Q2(r0.Num) }), $Z.AnyVar),
  equal: H8(r2.Dictionary({ 0: Q2($Z.List()), 1: Q2($Z.List()) }), r0.Bool)
}, se0 = {
  "@header": "Sets",
  has: H8(r2.Dictionary({ 0: Q2($Z.Set($Z.ConstrainedVar)), 1: Q2($Z.ConstrainedVar) }), r0.Bool, "Check if the the 1st argument includes the value of the 2nd."),
  isSubset: H8(r2.Dictionary({ 0: Q2($Z.Set($Z.ConstrainedVar)), 1: Q2($Z.Set($Z.ConstrainedVar)) }), r0.Bool, "Check if the the 1st argument is a subset of the 2nd.")
}, ae0 = {
  "@header": "Flags",
  hasAny: H8(r2.Dictionary({
    0: Q2($Z.Flags($Z.ConstrainedVar)),
    1: Q2($Z.Flags($Z.ConstrainedVar))
  }), r0.Bool, "Check if the the 1st argument has at least one of the 2nd one's flags."),
  hasAll: H8(r2.Dictionary({
    0: Q2($Z.Flags($Z.ConstrainedVar)),
    1: Q2($Z.Flags($Z.ConstrainedVar))
  }), r0.Bool, "Check if the the 1st argument has all 2nd one's flags.")
}, yf = {
  "@header": "Language Primitives",
  type: pe0,
  logic: ue0,
  ctrl: ce0,
  rel: le0,
  math: ne0,
  str: ie0,
  list: oe0,
  set: se0,
  flags: ae0
};
bf(yf);
var re0 = xf(yf), Qe1 = function() {
  let Z = Object.create(null);
  for (let J of re0)
    Z[J.id] = J;
  return Z;
}();

// node_modules/molstar/lib/mol-script/language/symbol-table/structure-query.js
var C2;
(function(Z) {
  Z.ElementSymbol = r0.Value("Structure", "ElementSymbol"), Z.AtomName = r0.Value("Structure", "AtomName"), Z.BondFlag = r0.OneOf("Structure", "BondFlag", r0.Str, ["covalent", "metallic", "ion", "hydrogen", "sulfide", "computed", "aromatic"]), Z.BondFlags = $Z.Flags(Z.BondFlag, "BondFlags"), Z.SecondaryStructureFlag = r0.OneOf("Structure", "SecondaryStructureFlag", r0.Str, ["alpha", "beta", "3-10", "pi", "sheet", "strand", "helix", "turn", "none"]), Z.SecondaryStructureFlags = $Z.Flags(Z.SecondaryStructureFlag, "SecondaryStructureFlag"), Z.RingFingerprint = r0.Value("Structure", "RingFingerprint"), Z.EntityType = r0.OneOf("Structure", "EntityType", r0.Str, ["polymer", "non-polymer", "water", "branched"]), Z.EntitySubtype = r0.OneOf("Structure", "EntitySubtype", r0.Str, ["other", "polypeptide(D)", "polypeptide(L)", "polydeoxyribonucleotide", "polyribonucleotide", "polydeoxyribonucleotide/polyribonucleotide hybrid", "cyclic-pseudo-peptide", "peptide nucleic acid", "oligosaccharide"]), Z.ObjectPrimitive = r0.OneOf("Structure", "ObjectPrimitive", r0.Str, ["atomistic", "sphere", "gaussian", "other"]), Z.ResidueId = r0.Value("Structure", "ResidueId"), Z.ElementSet = r0.Value("Structure", "ElementSet"), Z.ElementSelection = r0.Value("Structure", "ElementSelection"), Z.ElementReference = r0.Value("Structure", "ElementReference"), Z.ElementSelectionQuery = $Z.Fn(Z.ElementSelection, "ElementSelectionQuery");
})(C2 || (C2 = {}));
var ee0 = {
  "@header": "Types",
  elementSymbol: H8(r2.Dictionary({ 0: Q2(r0.Str) }), C2.ElementSymbol, "Create element symbol representation from a string value."),
  atomName: H8(r2.Dictionary({ 0: Q2(r0.AnyValue) }), C2.AtomName, "Convert a value to an atom name."),
  entityType: H8(r2.Dictionary({ 0: Q2(C2.EntityType) }), C2.EntityType, `Create normalized representation of entity type: ${r0.oneOfValues(C2.EntityType).join(", ")}.`),
  bondFlags: H8(r2.List(C2.BondFlag), C2.BondFlags, `Create bond flags representation from a list of strings. Allowed flags: ${r0.oneOfValues(C2.BondFlag).join(", ")}.`),
  ringFingerprint: H8(r2.List(C2.ElementSymbol, { nonEmpty: !0 }), C2.RingFingerprint, "Create ring fingerprint from the supplied atom element list."),
  secondaryStructureFlags: H8(r2.List(C2.SecondaryStructureFlag), C2.SecondaryStructureFlags, `Create secondary structure flags representation from a list of strings. Allowed flags: ${r0.oneOfValues(C2.SecondaryStructureFlag).join(", ")}.`),
  authResidueId: H8(r2.Dictionary({
    0: Q2(r0.Str, { description: "auth_asym_id" }),
    1: Q2(r0.Num, { description: "auth_seq_id" }),
    2: Q2(r0.Str, { description: "pdbx_PDB_ins_code", isOptional: !0 })
  }), C2.ResidueId, 'Residue identifier based on "auth_" annotation.'),
  labelResidueId: H8(r2.Dictionary({
    0: Q2(r0.Str, { description: "label_entity_id" }),
    1: Q2(r0.Str, { description: "label_asym_id" }),
    2: Q2(r0.Num, { description: "label_seq_id" }),
    3: Q2(r0.Str, { description: "pdbx_PDB_ins_code", isOptional: !0 })
  }), C2.ResidueId, `Residue identifier based on mmCIF's "label_" annotation.`)
}, Z01 = {
  "@header": "Iteration Slots",
  element: H8(r2.None, C2.ElementReference, "A reference to the current element."),
  elementSetReduce: H8(r2.None, r0.Variable("a", r0.AnyValue, !0), "Current value of the element set reducer.")
}, J01 = {
  "@header": "Generators",
  all: H8(r2.None, C2.ElementSelectionQuery, "The entire structure."),
  atomGroups: H8(r2.Dictionary({
    "entity-test": Q2(r0.Bool, { isOptional: !0, defaultValue: !0, description: "Test for the 1st atom of every entity" }),
    "chain-test": Q2(r0.Bool, { isOptional: !0, defaultValue: !0, description: "Test for the 1st atom of every chain" }),
    "residue-test": Q2(r0.Bool, { isOptional: !0, defaultValue: !0, description: "Test for the 1st atom every residue" }),
    "atom-test": Q2(r0.Bool, { isOptional: !0, defaultValue: !0 }),
    "group-by": Q2(r0.Any, { isOptional: !0, defaultValue: "atom-key", description: "Group atoms to sets based on this property. Default: each atom has its own set" })
  }), C2.ElementSelectionQuery, "Return all atoms for which the tests are satisfied, grouped into sets."),
  bondedAtomicPairs: H8(r2.Dictionary({
    0: Q2(r0.Bool, { isOptional: !0, defaultValue: "true for covalent bonds", description: "Test each bond with this predicate. Each bond is visited twice with swapped atom order." })
  }), C2.ElementSelectionQuery, "Return all pairs of atoms for which the test is satisfied."),
  rings: H8(r2.Dictionary({
    fingerprint: Q2(C2.RingFingerprint, { isOptional: !0 }),
    "only-aromatic": Q2(r0.Bool, { isOptional: !0, defaultValue: !1 })
  }), C2.ElementSelectionQuery, "Return all rings or those with the specified fingerprint and/or only aromatic rings."),
  queryInSelection: H8(r2.Dictionary({
    0: Q2(C2.ElementSelectionQuery),
    query: Q2(C2.ElementSelectionQuery),
    "in-complement": Q2(r0.Bool, { isOptional: !0, defaultValue: !1 })
  }), C2.ElementSelectionQuery, "Executes query only on atoms that are in the source selection."),
  empty: H8(r2.None, C2.ElementSelectionQuery, "Nada.")
}, $01 = {
  "@header": "Selection Modifications",
  queryEach: H8(r2.Dictionary({
    0: Q2(C2.ElementSelectionQuery),
    query: Q2(C2.ElementSelectionQuery)
  }), C2.ElementSelectionQuery, "Query every atom set in the input selection separately."),
  intersectBy: H8(r2.Dictionary({
    0: Q2(C2.ElementSelectionQuery),
    by: Q2(C2.ElementSelectionQuery)
  }), C2.ElementSelectionQuery, "Intersect each atom set from the first sequence from atoms in the second one."),
  exceptBy: H8(r2.Dictionary({
    0: Q2(C2.ElementSelectionQuery),
    by: Q2(C2.ElementSelectionQuery)
  }), C2.ElementSelectionQuery, "Remove all atoms from 'selection' that occur in 'by'."),
  unionBy: H8(r2.Dictionary({
    0: Q2(C2.ElementSelectionQuery),
    by: Q2(C2.ElementSelectionQuery)
  }), C2.ElementSelectionQuery, "For each atom set A in the orginal sequence, combine all atoms sets in the target selection that intersect with A."),
  union: H8(r2.Dictionary({
    0: Q2(C2.ElementSelectionQuery)
  }), C2.ElementSelectionQuery, "Collects all atom sets in the sequence into a single atom set."),
  cluster: H8(r2.Dictionary({
    0: Q2(C2.ElementSelectionQuery),
    "min-distance": Q2(r0.Num, { isOptional: !0, defaultValue: 0 }),
    "max-distance": Q2(r0.Num),
    "min-size": Q2(r0.Num, { description: "Minimal number of sets to merge, must be at least 2", isOptional: !0, defaultValue: 2 }),
    "max-size": Q2(r0.Num, { description: "Maximal number of sets to merge, if not set, no limit", isOptional: !0 })
  }), C2.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: H8(r2.Dictionary({
    0: Q2(C2.ElementSelectionQuery),
    radius: Q2(r0.Num),
    "atom-radius": Q2(r0.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": Q2(r0.Bool, { isOptional: !0 })
  }), C2.ElementSelectionQuery, "For each atom set in the selection, include all surrouding atoms/residues that are within the specified radius."),
  surroundingLigands: H8(r2.Dictionary({
    0: Q2(C2.ElementSelectionQuery),
    radius: Q2(r0.Num),
    "include-water": Q2(r0.Bool, { isOptional: !0, defaultValue: !0 })
  }), C2.ElementSelectionQuery, "Find all ligands components around the source query."),
  includeConnected: H8(r2.Dictionary({
    0: Q2(C2.ElementSelectionQuery),
    "bond-test": Q2(r0.Bool, { isOptional: !0, defaultValue: "true for covalent bonds" }),
    "layer-count": Q2(r0.Num, { isOptional: !0, defaultValue: 1, description: "Number of bonded layers to include." }),
    "fixed-point": Q2(r0.Bool, { isOptional: !0, defaultValue: !1, description: "Continue adding layers as long as new connections exist." }),
    "as-whole-residues": Q2(r0.Bool, { isOptional: !0 })
  }), C2.ElementSelectionQuery, "Pick all atom sets that are connected to the target."),
  wholeResidues: H8(r2.Dictionary({
    0: Q2(C2.ElementSelectionQuery)
  }), C2.ElementSelectionQuery, "Expand the selection to whole residues."),
  expandProperty: H8(r2.Dictionary({
    0: Q2(C2.ElementSelectionQuery),
    property: Q2(r0.AnyValue)
  }), C2.ElementSelectionQuery, "To each atom set in the selection, add all atoms that have the same property value that was already present in the set.")
}, X01 = {
  "@header": "Selection Filters",
  pick: H8(r2.Dictionary({
    0: Q2(C2.ElementSelectionQuery),
    test: Q2(r0.Bool)
  }), C2.ElementSelectionQuery, "Pick all atom sets that satisfy the test."),
  first: H8(r2.Dictionary({
    0: Q2(C2.ElementSelectionQuery)
  }), C2.ElementSelectionQuery, "Take the 1st atom set in the sequence."),
  withSameAtomProperties: H8(r2.Dictionary({
    0: Q2(C2.ElementSelectionQuery),
    source: Q2(C2.ElementSelectionQuery),
    property: Q2(r0.Any)
  }), C2.ElementSelectionQuery, "Pick all atom sets for which the set of given atom properties is a subset of the source properties."),
  intersectedBy: H8(r2.Dictionary({
    0: Q2(C2.ElementSelectionQuery),
    by: Q2(C2.ElementSelectionQuery)
  }), C2.ElementSelectionQuery, "Pick all atom sets that have non-zero intersection with the target."),
  within: H8(r2.Dictionary({
    0: Q2(C2.ElementSelectionQuery),
    target: Q2(C2.ElementSelectionQuery),
    "min-radius": Q2(r0.Num, { isOptional: !0, defaultValue: 0 }),
    "max-radius": Q2(r0.Num),
    "atom-radius": Q2(r0.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: Q2(r0.Bool, { isOptional: !0, defaultValue: !1, description: "If true, pick only atom sets that are further than the specified radius." })
  }), C2.ElementSelectionQuery, "Pick all atom sets from selection that have any atom within the radius of any atom from target."),
  isConnectedTo: H8(r2.Dictionary({
    0: Q2(C2.ElementSelectionQuery),
    target: Q2(C2.ElementSelectionQuery),
    "bond-test": Q2(r0.Bool, { isOptional: !0, defaultValue: "true for covalent bonds" }),
    disjunct: Q2(r0.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: Q2(r0.Bool, { isOptional: !0, defaultValue: !1, description: "If true, return atom sets that are not connected." })
  }), C2.ElementSelectionQuery, "Pick all atom sets that are connected to the target.")
}, Y01 = {
  "@header": "Selection Combinators",
  intersect: H8(r2.List(C2.ElementSelectionQuery), C2.ElementSelectionQuery, "Return all unique atom sets that appear in all of the source selections."),
  merge: H8(r2.List(C2.ElementSelectionQuery), C2.ElementSelectionQuery, "Merges multiple selections into a single one. Only unique atom sets are kept."),
  distanceCluster: H8(r2.Dictionary({
    matrix: Q2($Z.List($Z.List(r0.Num)), { description: "Distance matrix, represented as list of rows (num[][])). Lower triangle is min distance, upper triangle is max distance." }),
    selections: Q2($Z.List(C2.ElementSelectionQuery), { description: "A list of held selections." })
  }), C2.ElementSelectionQuery, "Pick combinations of atom sets from the source sequences that are mutually within distances specified by a matrix.")
}, Q01 = {
  "@header": "Atom Sets",
  atomCount: H8(r2.None, r0.Num),
  countQuery: H8(r2.Dictionary({
    0: Q2(C2.ElementSelectionQuery)
  }), r0.Num, "Counts the number of occurences of a specific query inside the current atom set."),
  reduce: H8(r2.Dictionary({
    initial: Q2(r0.Variable("a", r0.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: Q2(r0.Variable("a", r0.AnyValue, !0), { description: "Expression executed for each atom in the set" })
  }), r0.Variable("a", r0.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: H8(r2.Dictionary({
    0: Q2($Z.ConstrainedVar)
  }), $Z.Set($Z.ConstrainedVar), "Returns a set with all values of the given property in the current atom set.")
}, W01 = {
  "@header": "Atom Properties",
  core: {
    "@header": "Core Properties",
    elementSymbol: d6(C2.ElementSymbol),
    vdw: d6(r0.Num, "Van der Waals radius"),
    mass: d6(r0.Num, "Atomic weight"),
    atomicNumber: d6(r0.Num, "Atomic number"),
    x: d6(r0.Num, "Cartesian X coordinate"),
    y: d6(r0.Num, "Cartesian Y coordinate"),
    z: d6(r0.Num, "Cartesian Z coordinate"),
    atomKey: d6(r0.AnyValue, "Unique value for each atom. Main use case is grouping of atoms."),
    bondCount: H8(r2.Dictionary({
      0: Q2(C2.ElementReference, { isOptional: !0, defaultValue: "slot.current-atom" }),
      flags: Q2(C2.BondFlags, { isOptional: !0, defaultValue: "covalent" })
    }), r0.Num, "Number of bonds (by default only covalent bonds are counted)."),
    sourceIndex: d6(r0.Num, "Index of the atom/element in the input file."),
    operatorName: d6(r0.Str, "Name of the symmetry operator applied to this element."),
    instanceId: d6(r0.Str, "Canonical name of the symmetry operator applied to this element."),
    operatorKey: d6(r0.Num, "Key of the symmetry operator applied to this element."),
    modelIndex: d6(r0.Num, "Index of the model in the input file."),
    modelLabel: d6(r0.Str, "Label/header of the model in the input file."),
    modelEntryId: d6(r0.Str, "Entry ID of the model (e.g., PDB ID).")
  },
  topology: {
    connectedComponentKey: d6(r0.AnyValue, "Unique value for each connected component.")
  },
  macromolecular: {
    "@header": "Macromolecular Properties (derived from the mmCIF format)",
    authResidueId: d6(C2.ResidueId, "type.auth-residue-id symbol executed on current atom's residue"),
    labelResidueId: d6(C2.ResidueId, "type.label-residue-id symbol executed on current atom's residue"),
    residueKey: d6(r0.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: d6(r0.AnyValue, "Unique value for each tuple ``(label_entity_id, auth_asym_id)``, main use case is grouping of atoms"),
    entityKey: d6(r0.AnyValue, "Unique value for each tuple ``label_entity_id``, main use case is grouping of atoms"),
    isHet: d6(r0.Bool, "Equivalent to atom_site.group_PDB !== ATOM"),
    id: d6(r0.Num, "_atom_site.id"),
    label_atom_id: d6(C2.AtomName),
    label_alt_id: d6(r0.Str),
    label_comp_id: d6(r0.Str),
    label_asym_id: d6(r0.Str),
    label_entity_id: d6(r0.Str),
    label_seq_id: d6(r0.Num),
    auth_atom_id: d6(C2.AtomName),
    auth_comp_id: d6(r0.Str),
    auth_asym_id: d6(r0.Str),
    auth_seq_id: d6(r0.Num),
    residueSourceIndex: d6(r0.Num),
    pdbx_PDB_ins_code: d6(r0.Str),
    pdbx_formal_charge: d6(r0.Num),
    occupancy: d6(r0.Num),
    B_iso_or_equiv: d6(r0.Num),
    entityType: d6(C2.EntityType, "Type of the entity as defined in mmCIF (polymer, non-polymer, branched, water)"),
    entitySubtype: d6(C2.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: d6(r0.Str, "The PRD ID of the entity."),
    entityDescription: d6($Z.List(r0.Str)),
    objectPrimitive: d6(C2.ObjectPrimitive, "Type of the primitive object used to model this segment as defined in mmCIF/IHM (atomistic, sphere, gaussian, other)"),
    secondaryStructureKey: d6(r0.AnyValue, "Unique value for each secondary structure element."),
    secondaryStructureFlags: d6(C2.SecondaryStructureFlags),
    isModified: d6(r0.Bool, "True if the atom belongs to modification of a standard residue."),
    modifiedParentName: d6(r0.Str, "'3-letter' code of the modifed parent residue."),
    isNonStandard: d6(r0.Bool, "True if this is a non-standard residue."),
    chemCompType: d6(r0.Str, "Type of the chemical component as defined in mmCIF.")
  },
  ihm: {
    hasSeqId: H8(r2.Dictionary({ 0: Q2(r0.Num) }), r0.Bool, "Checks if the current element represents a given sequence id"),
    overlapsSeqIdRange: H8(r2.Dictionary({ beg: Q2(r0.Num), end: Q2(r0.Num) }), r0.Bool, "Checks if the current element overlaps with the specified residue range")
  }
}, K01 = {
  "@header": "Bond Properties",
  flags: nM(C2.BondFlags),
  order: nM(r0.Num),
  key: nM(r0.Num),
  length: nM(r0.Num),
  atomA: nM(C2.ElementReference),
  atomB: nM(C2.ElementReference)
};
function d6(Z, J) {
  return H8(r2.Dictionary({ 0: Q2(C2.ElementReference, { isOptional: !0, defaultValue: "slot.current-atom" }) }), Z, J);
}
function nM(Z, J) {
  return H8(r2.None, Z, J);
}
var zN0 = {
  "@header": "Structure Queries",
  type: ee0,
  slot: Z01,
  generator: J01,
  modifier: $01,
  filter: X01,
  combinator: Y01,
  atomSet: Q01,
  atomProperty: W01,
  bondProperty: K01
};

// node_modules/molstar/lib/mol-script/language/symbol-table/internal.js
var H01 = {
  "@header": "Generators",
  bundleElement: H8(r2.Dictionary({
    groupedUnits: Q2(r0.Any),
    set: Q2(r0.Any),
    ranges: Q2(r0.Any)
  }), r0.Any),
  bundle: H8(r2.Dictionary({
    elements: Q2(r0.Any)
  }), C2.ElementSelectionQuery, "A selection with single structure containing represented by the bundle."),
  current: H8(r2.None, C2.ElementSelectionQuery, "Current selection provided by the query context. Avoid using this in State Transforms.")
}, DN0 = {
  "@header": "Internal Queries",
  generator: H01
};

// node_modules/molstar/lib/mol-script/language/symbol-table.js
var p0 = { core: yf, structureQuery: zN0, internal: DN0 };
bf(p0);
var N01 = xf(p0), Oe1 = function() {
  let Z = Object.create(null);
  for (let J of N01)
    Z[J.id] = J;
  return Z;
}();

// node_modules/molstar/lib/mol-script/language/builder.js
var L0;
(function(Z) {
  Z.core = p0.core, Z.struct = p0.structureQuery, Z.internal = p0.internal;
  function J(A) {
    return Z.struct.type.atomName([A]);
  }
  Z.atomName = J;
  function $(A) {
    return Z.struct.type.elementSymbol([A]);
  }
  Z.es = $;
  function X(...A) {
    return Z.core.type.list(A);
  }
  Z.list = X;
  function Y(...A) {
    return Z.core.type.set(A);
  }
  Z.set = Y;
  function Q(A, B) {
    return Z.core.type.regex([A, B]);
  }
  Z.re = Q;
  function W(A) {
    return Z.core.ctrl.fn([A]);
  }
  Z.fn = W;
  function K(A) {
    return Z.core.ctrl.eval([A]);
  }
  Z.evaluate = K;
  let G = Z.struct.atomProperty.core, H = Z.struct.atomProperty.macromolecular, N = Z.struct.atomProperty.topology;
  function q(A) {
    return G[A]();
  }
  Z.acp = q;
  function U(A) {
    return N[A]();
  }
  Z.atp = U;
  function F(A) {
    return H[A]();
  }
  Z.ammp = F;
  let E = Z.struct.atomSet.propertySet;
  function R(A) {
    return E([q(A)]);
  }
  Z.acpSet = R;
  function z(A) {
    return E([U(A)]);
  }
  Z.atpSet = z;
  function D(A) {
    return E([F(A)]);
  }
  Z.ammpSet = D;
})(L0 || (L0 = {}));

// node_modules/molstar/lib/mol-math/graph/inter-unit-graph.js
class FY {
  getConnectedUnits(Z) {
    if (!this.map.has(Z))
      return MN0;
    return this.map.get(Z);
  }
  getEdgeIndex(Z, J, $, X) {
    let Y = this.edgeKeyIndex.get(FY.getEdgeUnitKey(J, X));
    if (Y === void 0)
      return -1;
    let Q = Y.get(FY.getEdgeIndexKey(Z, $));
    return Q !== void 0 ? Q : -1;
  }
  hasEdge(Z, J, $, X) {
    return this.getEdgeIndex(Z, J, $, X) !== -1;
  }
  getEdge(Z, J, $, X) {
    let Y = this.getEdgeIndex(Z, J, $, X);
    return Y !== -1 ? this.edges[Y] : void 0;
  }
  getEdgeIndices(Z, J) {
    return this.vertexKeyIndex.get(FY.getVertexKey(Z, J)) || [];
  }
  constructor(Z) {
    this.map = Z;
    let J = 0, $ = [], X = /* @__PURE__ */ new Map, Y = /* @__PURE__ */ new Map;
    this.map.forEach((Q) => {
      Q.forEach((W) => {
        J += W.edgeCount, W.connectedIndices.forEach((K) => {
          W.getEdges(K).forEach((G) => {
            let { unitA: H, unitB: N } = W, q = FY.getEdgeIndexKey(H, N), U = FY.getEdgeIndexKey(K, G.indexB), F = X.get(q);
            if (F === void 0)
              X.set(q, /* @__PURE__ */ new Map([[U, $.length]]));
            else
              F.set(U, $.length);
            let E = FY.getVertexKey(K, H), R = Y.get(E);
            if (R === void 0)
              Y.set(E, [$.length]);
            else
              R.push($.length);
            $.push({ ...G, indexA: K, unitA: H, unitB: N });
          });
        });
      });
    }), this.edgeCount = J, this.edges = $, this.edgeKeyIndex = X, this.vertexKeyIndex = Y;
  }
}
(function(Z) {

  class J {
    hasEdges(K) {
      return this.edgeMap.has(K);
    }
    getEdges(K) {
      if (!this.edgeMap.has(K))
        return MN0;
      return this.edgeMap.get(K);
    }
    get areUnitsOrdered() {
      return this.unitA < this.unitB;
    }
    constructor(K, G, H, N, q) {
      this.unitA = K, this.unitB = G, this.edgeCount = H, this.connectedIndices = N, this.edgeMap = q;
    }
  }
  Z.UnitPairEdges = J;
  function $(K, G) {
    return ZJ(K, G);
  }
  Z.getEdgeUnitKey = $;
  function X(K, G) {
    return ZJ(K, G);
  }
  Z.getEdgeIndexKey = X;
  function Y(K, G) {
    return ZJ(K, G);
  }
  Z.getVertexKey = Y;
  function Q(K, G, H) {
    if (K.has(G))
      K.get(G).push(H);
    else
      K.set(G, [H]);
  }

  class W {
    constructor() {
      this.map = /* @__PURE__ */ new Map;
    }
    startUnitPair(K, G) {
      this.uA = K, this.uB = G, this.mapAB = /* @__PURE__ */ new Map, this.mapBA = /* @__PURE__ */ new Map, this.linkedA = o6.create(), this.linkedB = o6.create(), this.linkCount = 0;
    }
    finishUnitPair() {
      if (this.linkCount === 0)
        return;
      Q(this.map, this.uA, new J(this.uA, this.uB, this.linkCount, this.linkedA.array, this.mapAB)), Q(this.map, this.uB, new J(this.uB, this.uA, this.linkCount, this.linkedB.array, this.mapBA));
    }
    add(K, G, H) {
      Q(this.mapAB, K, { indexB: G, props: H }), Q(this.mapBA, G, { indexB: K, props: H }), o6.add(this.linkedA, K, K), o6.add(this.linkedB, G, G), this.linkCount += 1;
    }
    getMap() {
      return this.map;
    }
  }
  Z.Builder = W;
})(FY || (FY = {}));
var MN0 = [];

// node_modules/molstar/lib/mol-model/structure/structure/unit/bonds/data.js
var iM;
(function(Z) {
  Z.Empty = lJ.create([], [], [], 0, { flags: [], order: [], key: [] });
})(iM || (iM = {}));

class cF extends FY {
  getBondFromLocation(Z) {
    return j0.isAtomic(Z.aUnit) && j0.isAtomic(Z.bUnit) ? this.getEdge(Z.aIndex, Z.aUnit.id, Z.bIndex, Z.bUnit.id) : void 0;
  }
  getBondIndexFromLocation(Z) {
    return j0.isAtomic(Z.aUnit) && j0.isAtomic(Z.bUnit) ? this.getEdgeIndex(Z.aIndex, Z.aUnit.id, Z.bIndex, Z.bUnit.id) : -1;
  }
}
(function(Z) {

  class J extends FY.UnitPairEdges {
  }
  Z.UnitPairBonds = J;
})(cF || (cF = {}));
// node_modules/molstar/lib/mol-model/structure/structure/unit/bonds/common.js
var gf = {
  forceCompute: !1,
  noCompute: !1,
  maxRadius: 4
}, _o = { 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 }, q01 = { 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 }, F01 = { 0: 0.8, 20: 1.31, 27: 1.2, 35: 1.15, 44: 1.1, 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 };
var BR = function() {
  let Z = ["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"], J = /* @__PURE__ */ new Set;
  for (let $ of Z)
    J.add(_o[$]);
  return J;
}();
function U01(Z, J) {
  if (Z < J)
    return (Z + J) * (Z + J + 1) / 2 + J;
  else
    return (Z + J) * (Z + J + 1) / 2 + Z;
}
function M5(Z) {
  let J = _o[Z];
  if (J === void 0)
    return -1;
  return J;
}
function L01(Z, J) {
  if (Z < 0 || J < 0)
    return -1;
  let $ = F01[U01(Z, J)];
  if ($ === void 0)
    return -1;
  return $;
}
function xN(Z) {
  if (Z < 0)
    return 2.001;
  let J = q01[Z];
  if (J === void 0)
    return 2.001;
  return J;
}
function oM(Z, J, $, X) {
  let Y = L01(Z, J);
  return Y > 0 ? Y : J < 0 ? $ : ($ + X) / 1.95;
}
var R01 = _o.H;
function A3(Z) {
  return Z === R01;
}

// node_modules/molstar/lib/mol-model/structure/model/properties/atomic/bonds.js
var E01 = /* @__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 AN0(Z, J, $) {
  if ([J, $] = J < $ ? [J, $] : [$, J], Kz.has(Z) && J === "C" && $ === "O")
    return 2;
  if (Gz.has(Z) && J === "OP1" && $ === "P")
    return 2;
  return E01.get(`${Z}|${J}|${$}`) || 1;
}
var O01 = /* @__PURE__ */ new Map([
  ["LYS|NZ|RET|C15", 2]
]);
function mf(Z, J, $, X) {
  if (Z > $)
    [Z, $] = [$, Z], [J, X] = [X, J];
  return O01.get(`${Z}|${J}|${$}|${X}`) || 1;
}

// node_modules/molstar/lib/mol-io/common/binary-cif/encoding.js
var BN0 = "0.3.0", EZ;
(function(Z) {
  let J;
  (function(Q) {
    Q[Q.Int8 = 1] = "Int8", Q[Q.Int16 = 2] = "Int16", Q[Q.Int32 = 3] = "Int32", Q[Q.Uint8 = 4] = "Uint8", Q[Q.Uint16 = 5] = "Uint16", Q[Q.Uint32 = 6] = "Uint32";
  })(J = Z.IntDataType || (Z.IntDataType = {}));
  let $;
  (function(Q) {
    Q[Q.Float32 = 32] = "Float32", Q[Q.Float64 = 33] = "Float64";
  })($ = Z.FloatDataType || (Z.FloatDataType = {}));
  function X(Q) {
    let W;
    if (Q instanceof Int8Array)
      W = Z.IntDataType.Int8;
    else if (Q instanceof Int16Array)
      W = Z.IntDataType.Int16;
    else if (Q instanceof Int32Array)
      W = Z.IntDataType.Int32;
    else if (Q instanceof Uint8Array)
      W = Z.IntDataType.Uint8;
    else if (Q instanceof Uint16Array)
      W = Z.IntDataType.Uint16;
    else if (Q instanceof Uint32Array)
      W = Z.IntDataType.Uint32;
    else if (Q instanceof Float32Array)
      W = Z.FloatDataType.Float32;
    else if (Q instanceof Float64Array)
      W = Z.FloatDataType.Float64;
    else
      W = Z.IntDataType.Int32;
    return W;
  }
  Z.getDataType = X;
  function Y(Q) {
    if (Q instanceof Int8Array || Q instanceof Int16Array || Q instanceof Int32Array)
      return !0;
    for (let W = 0, K = Q.length;W < K; W++)
      if (W < 0)
        return !1;
    return !0;
  }
  Z.isSignedIntegerDataType = Y;
})(EZ || (EZ = {}));

// node_modules/molstar/lib/mol-io/common/binary.js
var wN0 = new Uint16Array(new Uint8Array([18, 52]).buffer)[0] === 13330;
function jN0(Z, J) {
  let $ = new ArrayBuffer(Z.length), X = new Uint8Array($);
  for (let Y = 0, Q = Z.length;Y < Q; Y += J)
    for (let W = 0;W < J; W++)
      X[Y + J - W - 1] = Z[Y + W];
  return $;
}
var Vo = 28672;
function TN0(Z) {
  if (Z.length > Vo) {
    let J = [];
    for (let $ = 0;$ < Z.length; $ += Vo)
      J.push(String.fromCharCode.apply(null, Z.subarray($, $ + Vo)));
    return J.join("");
  } else
    return String.fromCharCode.apply(null, Z);
}

// node_modules/molstar/lib/mol-io/common/binary-cif/decoder.js
function sM(Z) {
  let J = Z.data;
  for (let $ = Z.encoding.length - 1;$ >= 0; $--)
    J = z01(J, Z.encoding[$]);
  return J;
}
function z01(Z, J) {
  switch (J.kind) {
    case "ByteArray":
      switch (J.type) {
        case EZ.IntDataType.Uint8:
          return Z;
        case EZ.IntDataType.Int8:
          return D01(Z);
        case EZ.IntDataType.Int16:
          return M01(Z);
        case EZ.IntDataType.Uint16:
          return A01(Z);
        case EZ.IntDataType.Int32:
          return B01(Z);
        case EZ.IntDataType.Uint32:
          return w01(Z);
        case EZ.FloatDataType.Float32:
          return j01(Z);
        case EZ.FloatDataType.Float64:
          return T01(Z);
        default:
          T8(J.type);
      }
    case "FixedPoint":
      return _01(Z, J);
    case "IntervalQuantization":
      return V01(Z, J);
    case "RunLength":
      return I01(Z, J);
    case "Delta":
      return P01(Z, J);
    case "IntegerPacking":
      return v01(Z, J);
    case "StringArray":
      return S01(Z, J);
  }
}
function _N0(Z, J) {
  switch (Z) {
    case EZ.IntDataType.Int8:
      return new Int8Array(J);
    case EZ.IntDataType.Int16:
      return new Int16Array(J);
    case EZ.IntDataType.Int32:
      return new Int32Array(J);
    case EZ.IntDataType.Uint8:
      return new Uint8Array(J);
    case EZ.IntDataType.Uint16:
      return new Uint16Array(J);
    case EZ.IntDataType.Uint32:
      return new Uint32Array(J);
    default:
      return new Int32Array(J);
  }
}
function VN0(Z, J) {
  switch (Z) {
    case EZ.FloatDataType.Float32:
      return new Float32Array(J);
    case EZ.FloatDataType.Float64:
      return new Float64Array(J);
    default:
      return new Float64Array(J);
  }
}
function D01(Z) {
  return new Int8Array(Z.buffer, Z.byteOffset);
}
function aM(Z, J, $) {
  if (wN0)
    return new $(Z.buffer);
  return new $(jN0(Z, J));
}
function M01(Z) {
  return aM(Z, 2, Int16Array);
}
function A01(Z) {
  return aM(Z, 2, Uint16Array);
}
function B01(Z) {
  return aM(Z, 4, Int32Array);
}
function w01(Z) {
  return aM(Z, 4, Uint32Array);
}
function j01(Z) {
  return aM(Z, 4, Float32Array);
}
function T01(Z) {
  return aM(Z, 8, Float64Array);
}
function _01(Z, J) {
  let $ = Z.length, X = VN0(J.srcType, $), Y = 1 / J.factor;
  for (let Q = 0;Q < $; Q++)
    X[Q] = Y * Z[Q];
  return X;
}
function V01(Z, J) {
  let $ = Z.length, X = VN0(J.srcType, $), Y = (J.max - J.min) / (J.numSteps - 1), Q = J.min;
  for (let W = 0;W < $; W++)
    X[W] = Q + Y * Z[W];
  return X;
}
function I01(Z, J) {
  let $ = _N0(J.srcType, J.srcSize), X = 0;
  for (let Y = 0, Q = Z.length;Y < Q; Y += 2) {
    let W = Z[Y], K = Z[Y + 1];
    for (let G = 0;G < K; ++G)
      $[X++] = W;
  }
  return $;
}
function P01(Z, J) {
  let $ = Z.length, X = _N0(J.srcType, $);
  if (!$)
    return Z;
  X[0] = Z[0] + (J.origin | 0);
  for (let Y = 1;Y < $; ++Y)
    X[Y] = Z[Y] + X[Y - 1];
  return X;
}
function C01(Z, J) {
  let $ = J.byteCount === 1 ? 127 : 32767, X = -$ - 1, Y = Z.length, Q = new Int32Array(J.srcSize), W = 0, K = 0;
  while (W < Y) {
    let G = 0, H = Z[W];
    while (H === $ || H === X)
      G += H, W++, H = Z[W];
    G += H, Q[K] = G, W++, K++;
  }
  return Q;
}
function k01(Z, J) {
  let $ = J.byteCount === 1 ? 255 : 65535, X = Z.length, Y = new Int32Array(J.srcSize), Q = 0, W = 0;
  while (Q < X) {
    let K = 0, G = Z[Q];
    while (G === $)
      K += G, Q++, G = Z[Q];
    K += G, Y[W] = K, Q++, W++;
  }
  return Y;
}
function v01(Z, J) {
  if (Z.length === J.srcSize)
    return Z;
  return J.isUnsigned ? k01(Z, J) : C01(Z, J);
}
function S01(Z, J) {
  let $ = sM({ encoding: J.offsetEncoding, data: J.offsets }), X = sM({ encoding: J.dataEncoding, data: Z }), Y = J.stringData, Q = new Array($.length);
  Q[0] = "";
  for (let G = 1, H = $.length;G < H; G++)
    Q[G] = Y.substring($[G - 1], $[G]);
  let W = 0, K = new Array(X.length);
  for (let G = 0, H = X.length;G < H; G++)
    K[W++] = Q[X[G] + 1];
  return K;
}
// node_modules/molstar/lib/mol-io/common/binary-cif/classifier.js
function c_(Z) {
  return u_.classify(Z);
}
function IN0(Z) {
  return Io.classify(Z);
}
var u_;
(function(Z) {
  function J(F, E) {
    return F >= 0 ? Math.ceil((F + 1) / E) : Math.ceil((F + 1) / (-E - 1));
  }
  function $(F) {
    let E = !1;
    for (let R = 0, z = F.length;R < z; R++)
      if (F[R] < 0) {
        E = !0;
        break;
      }
    return E ? { signed: E, limit8: 127, limit16: 32767 } : { signed: E, limit8: 255, limit16: 65535 };
  }
  function X() {
    return { pack8: 0, pack16: 0, count: 0 };
  }
  function Y({ limit8: F, limit16: E }, R, z) {
    R.pack8 += J(z, F), R.pack16 += J(z, E), R.count += 1;
  }
  function Q(F, E) {
    F.pack8 += J(E, 127), F.pack16 += J(E, 32767), F.count += 1;
  }
  function W(F) {
    if (F.count * 4 < F.pack16 * 2)
      return { length: F.count * 4, elem: 4 };
    if (F.pack16 * 2 < F.pack8)
      return { length: F.pack16 * 2, elem: 2 };
    return { length: F.pack8, elem: 1 };
  }
  function K(F, E) {
    let R = X();
    for (let z = 0, D = F.length;z < D; z++)
      Y(E, R, F[z]);
    return { ...W(R), kind: "pack" };
  }
  function G(F, E) {
    let R = X(), z = F[0];
    for (let D = 1, A = F.length;D < A; D++)
      Q(R, F[D] - z), z = F[D];
    return { ...W(R), kind: "delta" };
  }
  function H(F, E) {
    let R = X(), z = 1;
    for (let D = 1, A = F.length;D < A; D++)
      if (F[D - 1] !== F[D])
        Y(E, R, F[D - 1]), Y(E, R, z), z = 1;
      else
        z++;
    return Y(E, R, F[F.length - 1]), Y(E, R, z), { ...W(R), kind: "rle" };
  }
  function N(F, E) {
    let R = X(), z = 1, D = 0, A = 0;
    for (let B = 1, T = F.length;B < T; B++) {
      let w = F[B] - D;
      if (A !== w)
        Q(R, A), Q(R, z), z = 1;
      else
        z++;
      A = w, D = F[B];
    }
    return Q(R, A), Q(R, z), { ...W(R), kind: "delta-rle" };
  }
  function q(F) {
    let E = $(F), R = [K(F, E), H(F, E), G(F, E), N(F, E)];
    return R.sort((z, D) => z.length - D.length), R;
  }
  Z.getSize = q;
  function U(F) {
    if (F.length < 2)
      return C6.by(C6.byteArray);
    let R = q(F)[0];
    switch (R.kind) {
      case "pack":
        return C6.by(C6.integerPacking);
      case "rle":
        return C6.by(C6.runLength).and(C6.integerPacking);
      case "delta":
        return C6.by(C6.delta).and(C6.integerPacking);
      case "delta-rle":
        return C6.by(C6.delta).and(C6.runLength).and(C6.integerPacking);
      default:
        T8(R);
    }
  }
  Z.classify = U;
})(u_ || (u_ = {}));
var Io;
(function(Z) {
  function $(Y) {
    let { mantissaDigits: W, integerDigits: K } = EH0(Y, 4, 0.000001);
    if (W < 0 || W + K > 10)
      return C6.by(C6.byteArray);
    if (W === 0)
      return u_.classify(Y);
    let G = X(W), H = new Int32Array(Y.length);
    for (let F = 0, E = Y.length;F < E; F++)
      H[F] = Math.round(G * Y[F]);
    let q = u_.getSize(H)[0], U = C6.by(C6.fixedPoint(G));
    switch (q.kind) {
      case "pack":
        return U.and(C6.integerPacking);
      case "rle":
        return U.and(C6.runLength).and(C6.integerPacking);
      case "delta":
        return U.and(C6.delta).and(C6.integerPacking);
      case "delta-rle":
        return U.and(C6.delta).and(C6.runLength).and(C6.integerPacking);
      default:
        T8(q);
    }
  }
  Z.classify = $;
  function X(Y) {
    let Q = 1;
    for (let W = 0;W < Y; W++)
      Q *= 10;
    return Q;
  }
})(Io || (Io = {}));

// node_modules/molstar/lib/mol-io/common/binary-cif/array-encoder.js
class df {
  and(Z) {
    return new df(this.providers.concat([Z]));
  }
  encode(Z) {
    let J = [];
    for (let $ of this.providers) {
      let X = $(Z);
      if (!X.encodings.length)
        throw new Error("Encodings must be non-empty.");
      Z = X.data;
      for (let Y of X.encodings)
        J.push(Y);
    }
    if (!(Z instanceof Uint8Array))
      throw new Error("The encoding must result in a Uint8Array. Fix your encoding chain.");
    return {
      encoding: J,
      data: Z
    };
  }
  constructor(Z) {
    this.providers = Z;
  }
}
var KH;
(function(Z) {
  function J(Y) {
    return new df([Y]);
  }
  Z.by = J;
  function $(Y) {
    let Q = J(X(Y[0]));
    for (let W = 1;W < Y.length; W++) {
      if (Y[W - 1].kind === "IntegerPacking")
        break;
      Q = Q.and(X(Y[W]));
    }
    return Q;
  }
  Z.fromEncoding = $;
  function X(Y) {
    switch (Y.kind) {
      case "ByteArray":
        return C6.byteArray;
      case "FixedPoint":
        return C6.fixedPoint(Y.factor);
      case "IntervalQuantization":
        return C6.intervalQuantizaiton(Y.min, Y.max, Y.numSteps);
      case "RunLength":
        return C6.runLength;
      case "Delta":
        return C6.delta;
      case "IntegerPacking":
        return C6.integerPacking;
      case "StringArray":
        return C6.stringArray;
    }
  }
})(KH || (KH = {}));
var C6;
(function(Z) {
  function J(T) {
    return new df([T]);
  }
  Z.by = J;
  function $(T) {
    return {
      encodings: [{ kind: "ByteArray", type: EZ.IntDataType.Uint8 }],
      data: T
    };
  }
  function X(T) {
    return {
      encodings: [{ kind: "ByteArray", type: EZ.IntDataType.Int8 }],
      data: new Uint8Array(T.buffer, T.byteOffset)
    };
  }
  let Y = {
    [EZ.IntDataType.Int16]: function(T, w, V) {
      T.setInt16(2 * w, V, !0);
    },
    [EZ.IntDataType.Uint16]: function(T, w, V) {
      T.setUint16(2 * w, V, !0);
    },
    [EZ.IntDataType.Int32]: function(T, w, V) {
      T.setInt32(4 * w, V, !0);
    },
    [EZ.IntDataType.Uint32]: function(T, w, V) {
      T.setUint32(4 * w, V, !0);
    },
    [EZ.FloatDataType.Float32]: function(T, w, V) {
      T.setFloat32(4 * w, V, !0);
    },
    [EZ.FloatDataType.Float64]: function(T, w, V) {
      T.setFloat64(8 * w, V, !0);
    }
  }, Q = {
    [EZ.IntDataType.Int16]: 2,
    [EZ.IntDataType.Uint16]: 2,
    [EZ.IntDataType.Int32]: 4,
    [EZ.IntDataType.Uint32]: 4,
    [EZ.FloatDataType.Float32]: 4,
    [EZ.FloatDataType.Float64]: 8
  };
  function W(T) {
    let w = EZ.getDataType(T);
    if (w === EZ.IntDataType.Int8)
      return X(T);
    else if (w === EZ.IntDataType.Uint8)
      return $(T);
    let V = new Uint8Array(T.length * Q[w]), P = Y[w], I = new DataView(V.buffer);
    for (let S = 0, f = T.length;S < f; S++)
      P(I, S, T[S]);
    return {
      encodings: [{ kind: "ByteArray", type: w }],
      data: V
    };
  }
  Z.byteArray = W;
  function K(T, w) {
    let V = EZ.getDataType(T), P = new Int32Array(T.length);
    for (let I = 0, S = T.length;I < S; I++)
      P[I] = Math.round(T[I] * w);
    return {
      encodings: [{ kind: "FixedPoint", factor: w, srcType: V }],
      data: P
    };
  }
  function G(T) {
    return (w) => K(w, T);
  }
  Z.fixedPoint = G;
  function H(T, w, V, P, I) {
    let S = EZ.getDataType(T);
    if (!T.length)
      return {
        encodings: [{ kind: "IntervalQuantization", min: w, max: V, numSteps: P, srcType: S }],
        data: new Int32Array(0)
      };
    if (V < w) {
      let h = w;
      w = V, V = h;
    }
    let f = (V - w) / (P - 1), v = new I(T.length);
    for (let h = 0, x = T.length;h < x; h++) {
      let b = T[h];
      if (b <= w)
        v[h] = 0;
      else if (b >= V)
        v[h] = P - 1;
      else
        v[h] = Math.round((b - w) / f) | 0;
    }
    return {
      encodings: [{ kind: "IntervalQuantization", min: w, max: V, numSteps: P, srcType: S }],
      data: v
    };
  }
  function N(T, w, V, P = Int32Array) {
    return (I) => H(I, T, w, V, P);
  }
  Z.intervalQuantizaiton = N;
  function q(T) {
    let w = EZ.getDataType(T);
    if (w === void 0)
      T = new Int32Array(T), w = EZ.IntDataType.Int32;
    if (!T.length)
      return {
        encodings: [{ kind: "RunLength", srcType: w, srcSize: 0 }],
        data: new Int32Array(0)
      };
    let V = 2;
    for (let f = 1, v = T.length;f < v; f++)
      if (T[f - 1] !== T[f])
        V += 2;
    let P = new Int32Array(V), I = 0, S = 1;
    for (let f = 1, v = T.length;f < v; f++)
      if (T[f - 1] !== T[f])
        P[I] = T[f - 1], P[I + 1] = S, S = 1, I += 2;
      else
        ++S;
    return P[I] = T[T.length - 1], P[I + 1] = S, {
      encodings: [{ kind: "RunLength", srcType: w, srcSize: T.length }],
      data: P
    };
  }
  Z.runLength = q;
  function U(T) {
    if (!EZ.isSignedIntegerDataType(T))
      throw new Error("Only signed integer types can be encoded using delta encoding.");
    let w = EZ.getDataType(T);
    if (w === void 0)
      T = new Int32Array(T), w = EZ.IntDataType.Int32;
    if (!T.length)
      return {
        encodings: [{ kind: "Delta", origin: 0, srcType: w }],
        data: new T.constructor(0)
      };
    let V = new T.constructor(T.length), P = T[0];
    V[0] = T[0];
    for (let I = 1, S = T.length;I < S; I++)
      V[I] = T[I] - T[I - 1];
    return V[0] = 0, {
      encodings: [{ kind: "Delta", origin: P, srcType: w }],
      data: V
    };
  }
  Z.delta = U;
  function F(T) {
    for (let w = 0, V = T.length;w < V; w++)
      if (T[w] < 0)
        return !0;
    return !1;
  }
  function E(T, w) {
    let V = 0;
    for (let P = 0, I = T.length;P < I; P++)
      V += T[P] / w | 0;
    return V += T.length, V;
  }
  function R(T, w) {
    let V = -w - 1, P = 0;
    for (let I = 0, S = T.length;I < S; I++) {
      let f = T[I];
      if (f >= 0)
        P += f / w | 0;
      else
        P += f / V | 0;
    }
    return P += T.length, P;
  }
  function z(T) {
    let w = F(T), V = w ? R(T, 127) : E(T, 255), P = w ? R(T, 32767) : E(T, 65535);
    if (T.length * 4 < P * 2)
      return {
        isSigned: w,
        size: T.length,
        bytesPerElement: 4
      };
    else if (P * 2 < V)
      return {
        isSigned: w,
        size: P,
        bytesPerElement: 2
      };
    else
      return {
        isSigned: w,
        size: V,
        bytesPerElement: 1
      };
  }
  function D(T, w) {
    let V = w.isSigned ? w.bytesPerElement === 1 ? 127 : 32767 : w.bytesPerElement === 1 ? 255 : 65535, P = -V - 1, I = T.length, S = w.isSigned ? w.bytesPerElement === 1 ? new Int8Array(w.size) : new Int16Array(w.size) : w.bytesPerElement === 1 ? new Uint8Array(w.size) : new Uint16Array(w.size), f = 0;
    for (let h = 0;h < I; h++) {
      let x = T[h];
      if (x >= 0)
        while (x >= V)
          S[f] = V, ++f, x -= V;
      else
        while (x <= P)
          S[f] = P, ++f, x -= P;
      S[f] = x, ++f;
    }
    let v = W(S);
    return {
      encodings: [
        {
          kind: "IntegerPacking",
          byteCount: w.bytesPerElement,
          isUnsigned: !w.isSigned,
          srcSize: I
        },
        v.encodings[0]
      ],
      data: v.data
    };
  }
  function A(T) {
    let w = z(T);
    if (w.bytesPerElement === 4)
      return W(T);
    return D(T, w);
  }
  Z.integerPacking = A;
  function B(T) {
    let w = Object.create(null), V = [], P = new Int32Array(T.length), I = B1.create(Int32Array, 1, Math.min(1024, T.length < 32 ? T.length + 1 : Math.round(T.length / 8) + 1));
    B1.add(I, 0);
    let S = 0, f = 0;
    for (let m of T) {
      if (m === null || m === void 0) {
        P[f++] = -1;
        continue;
      }
      let i = w[m];
      if (i === void 0)
        S += m.length, i = V.length, V[i] = m, w[m] = i, B1.add(I, S);
      P[f++] = i;
    }
    let v = B1.compact(I), x = c_(v).encode(v), g = c_(P).encode(P);
    return {
      encodings: [{ kind: "StringArray", dataEncoding: g.encoding, stringData: V.join(""), offsetEncoding: x.encoding, offsets: x.data }],
      data: g.data
    };
  }
  Z.stringArray = B;
})(C6 || (C6 = {}));
// node_modules/molstar/lib/mol-io/writer/cif/encoder.js
var F$;
(function(Z) {
  let J;
  (function(G) {
    G[G.Str = 0] = "Str", G[G.Int = 1] = "Int", G[G.Float = 2] = "Float";
  })(J = Z.Type || (Z.Type = {}));
  function $(G, H, N) {
    return { name: G, type: J.Str, value: H, valueKind: N && N.valueKind, defaultFormat: N && N.encoder ? { encoder: N.encoder } : void 0, shouldInclude: N && N.shouldInclude };
  }
  Z.str = $;
  function X(G, H, N) {
    return {
      name: G,
      type: J.Int,
      value: H,
      valueKind: N && N.valueKind,
      defaultFormat: N ? { encoder: N.encoder, typedArray: N.typedArray } : void 0,
      shouldInclude: N && N.shouldInclude
    };
  }
  Z.int = X;
  function Y(G, H, N) {
    return {
      name: G,
      type: J.Float,
      value: H,
      valueKind: N && N.valueKind,
      defaultFormat: N ? { encoder: N.encoder, typedArray: N.typedArray, digitCount: typeof N.digitCount !== "undefined" ? N.digitCount : void 0 } : void 0,
      shouldInclude: N && N.shouldInclude
    };
  }
  Z.float = Y;
  function Q(G) {
    return X(G, (H, N, q) => q + 1, { typedArray: Int32Array, encoder: C6.by(C6.delta).and(C6.runLength).and(C6.integerPacking) });
  }
  Z.index = Q;

  class W {
    constructor() {
      this.fields = [];
    }
    index(G) {
      return this.fields.push(Z.index(G)), this;
    }
    str(G, H, N) {
      return this.fields.push(Z.str(G, H, N)), this;
    }
    int(G, H, N) {
      return this.fields.push(Z.int(G, H, N)), this;
    }
    vec(G, H, N) {
      for (let q = 0;q < H.length; q++)
        this.fields.push(Z.int(`${G}[${q + 1}]`, H[q], N));
      return this;
    }
    float(G, H, N) {
      return this.fields.push(Z.float(G, H, N)), this;
    }
    many(G) {
      for (let H = 0;H < G.length; H++)
        this.fields.push(G[H]);
      return this;
    }
    add(G) {
      return this.fields.push(G), this;
    }
    getFields() {
      return this.fields;
    }
  }
  Z.Builder = W;
  function K() {
    return new W;
  }
  Z.build = K;
})(F$ || (F$ = {}));
var gQ;
(function(Z) {
  Z.Empty = { fields: [], source: [] };
  function J(X) {
    let Y = [], Q = [], W = [], K = [];
    for (let H of X.split(/[\r\n]+/)) {
      if (H = H.trim(), H.length === 0)
        continue;
      let N = /^!/.test(H);
      if (N)
        H = H.substr(1);
      let q = H.split(/\./), U = q[1], F = N ? U ? K : Q : U ? W : Y;
      if (F[F.length] = H, U && !Y.includes(q[0]))
        Y[Y.length] = q[0];
    }
    let G = W.map((H) => H.split(".")[0]);
    return {
      includeCategory(H) {
        if (Q.includes(H))
          return !1;
        else
          return Y.length <= 0 || Y.indexOf(H) !== -1;
      },
      includeField(H, N) {
        let q = H + "." + N;
        if (K.includes(q))
          return !1;
        else
          return !G.includes(H) || W.includes(q);
      }
    };
  }
  Z.filterOf = J, Z.DefaultFilter = {
    includeCategory(X) {
      return !0;
    },
    includeField(X, Y) {
      return !0;
    }
  }, Z.DefaultFormatter = {
    getFormat(X, Y) {
      return;
    }
  };
  function $(X, Y) {
    if (Y)
      return {
        fields: PN0(X._schema),
        source: [{ data: X, rowCount: Y.length, keys: () => LR.Array(Y) }]
      };
    return {
      fields: PN0(X._schema),
      source: [{ data: X, rowCount: X._rowCount }]
    };
  }
  Z.ofTable = $;
})(gQ || (gQ = {}));
var pf;
(function(Z) {
  function J(X, Y, Q) {
    X.startDataBlock(Y);
    for (let W of Q._tableNames)
      X.writeCategory({ name: W, instance: () => gQ.ofTable(Q[W]) });
  }
  Z.writeDatabase = J;
  function $(X, Y) {
    for (let Q of Object.keys(Y))
      J(X, Q, Y[Q]);
  }
  Z.writeDatabaseCollection = $;
})(pf || (pf = {}));
function Po(Z) {
  return (J, $) => $[Z].value(J);
}
function f01(Z) {
  return (J, $) => $[Z].value(J).join($[Z].schema.separator);
}
function Co(Z, ...J) {
  return ($, X) => X[Z].schema.space.get(X[Z].value($), ...J);
}
function l_(Z) {
  return (J, $) => $[Z].valueKind(J);
}
function h01(Z, J) {
  let $ = [], X = F$.Type.Float, Y = l_(Z);
  if (J.rank === 1) {
    let Q = J.dimensions[0];
    for (let W = 0;W < Q; W++) {
      let K = `${Z}[${W + 1}]`;
      $.push({ name: K, type: X, value: Co(Z, W), valueKind: Y });
    }
  } else if (J.rank === 2) {
    let Q = J.dimensions[0], W = J.dimensions[1];
    for (let K = 0;K < Q; K++)
      for (let G = 0;G < W; G++) {
        let H = `${Z}[${K + 1}][${G + 1}]`;
        $.push({ name: H, type: X, value: Co(Z, K, G), valueKind: Y });
      }
  } else if (J.rank === 3) {
    let Q = J.dimensions[0], W = J.dimensions[1], K = J.dimensions[2];
    for (let G = 0;G < Q; G++)
      for (let H = 0;H < W; H++)
        for (let N = 0;N < K; N++) {
          let q = `${Z}[${G + 1}][${H + 1}][${N + 1}]`;
          $.push({ name: q, type: X, value: Co(Z, G, H, N), valueKind: Y });
        }
  } else
    throw new Error("Tensors with rank > 3 or rank 0 are currently not supported.");
  return $;
}
function PN0(Z) {
  let J = [];
  for (let $ of Object.keys(Z)) {
    let X = Z[$];
    if (X.valueType === "int")
      J.push({ name: $, type: F$.Type.Int, value: Po($), valueKind: l_($) });
    else if (X.valueType === "float")
      J.push({ name: $, type: F$.Type.Float, value: Po($), valueKind: l_($) });
    else if (X.valueType === "str")
      J.push({ name: $, type: F$.Type.Str, value: Po($), valueKind: l_($) });
    else if (X.valueType === "list")
      J.push({ name: $, type: F$.Type.Str, value: f01($), valueKind: l_($) });
    else if (X.valueType === "tensor")
      J.push(...h01($, X.space));
    else
      T8(X.valueType);
  }
  return J;
}

// node_modules/molstar/lib/mol-io/writer/cif/encoder/util.js
function CN0(Z) {
  if (Z.defaultFormat && typeof Z.defaultFormat.digitCount !== "undefined")
    return Math.max(0, Math.min(Z.defaultFormat.digitCount, 16));
  return 6;
}
function n_(Z) {
  return Z.fields.some((J) => !!J.shouldInclude) ? Z.fields.filter((J) => !J.shouldInclude || Z.source.some(($) => J.shouldInclude($.data))) : Z.fields;
}
function uf(Z, J) {
  let $ = Z.instance(J), X = $.source.filter((W) => W.rowCount > 0);
  if (!X.length)
    return { instance: $, rowCount: 0, source: [] };
  let Y = X.reduce((W, K) => W + K.rowCount, 0), Q = X.map((W) => ({
    data: W.data,
    keys: () => W.keys ? W.keys() : LR.Range(0, W.rowCount - 1),
    rowCount: W.rowCount
  }));
  return { instance: $, rowCount: Y, source: Q };
}

// node_modules/molstar/lib/mol-io/writer/cif/encoder/text.js
class ko {
  constructor() {
    this.builder = UZ.create(), this.encoded = !1, this.dataBlockCreated = !1, this.filter = gQ.DefaultFilter, this.formatter = gQ.DefaultFormatter, this.isBinary = !1, this.binaryEncodingProvider = void 0;
  }
  setFilter(Z) {
    this.filter = Z || gQ.DefaultFilter;
  }
  isCategoryIncluded(Z) {
    return this.filter.includeCategory(Z);
  }
  setFormatter(Z) {
    this.formatter = Z || gQ.DefaultFormatter;
  }
  startDataBlock(Z) {
    this.dataBlockCreated = !0, UZ.write(this.builder, `data_${(Z || "").replace(/[ \n\t]/g, "").toUpperCase()}
#
`);
  }
  writeCategory(Z, J, $) {
    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 (!($ === null || $ === void 0 ? void 0 : $.ignoreFilter) && !this.filter.includeCategory(Z.name))
      return;
    let { instance: X, rowCount: Y, source: Q } = uf(Z, J);
    if (!Y)
      return;
    if (Y === 1)
      x01(Z, X, Q, this.builder, this.filter, this.formatter);
    else
      y01(Z, X, Q, this.builder, this.filter, this.formatter);
  }
  encode() {
    this.encoded = !0;
  }
  writeTo(Z) {
    let J = UZ.getChunks(this.builder);
    for (let $ = 0, X = J.length;$ < X; $++)
      Z.writeString(J[$]);
  }
  getSize() {
    return UZ.getSize(this.builder);
  }
  getData() {
    return UZ.getString(this.builder);
  }
}
function vN0(Z, J, $, X, Y, Q) {
  let W = X.valueKind, K = W ? W($, J) : s.ValueKinds.Present;
  if (K !== s.ValueKinds.Present)
    if (K === s.ValueKinds.NotPresent)
      p01(Z);
    else
      u01(Z);
  else {
    let G = X.value($, J, Q), H = X.type;
    if (H === F$.Type.Str)
      if (g01(G))
        return cf(Z, G), !0;
      else
        return c01(Z, G);
    else if (H === F$.Type.Int)
      m01(Z, G);
    else
      d01(Z, G, Y);
  }
  return !1;
}
function SN0(Z, J, $) {
  let X = [];
  for (let Y of J) {
    let Q = $.getFormat(Z, Y.name);
    if (Q && typeof Q.digitCount !== "undefined")
      X[X.length] = Y.type === F$.Type.Float ? Math.pow(10, Math.max(0, Math.min(Q.digitCount, 15))) : 0;
    else
      X[X.length] = Y.type === F$.Type.Float ? Math.pow(10, CN0(Y)) : 0;
  }
  return X;
}
function x01(Z, J, $, X, Y, Q) {
  let W = n_(J), K = $[0], G = K.data, H = W.reduce((F, E) => Y.includeField(Z.name, E.name) ? Math.max(F, E.name.length) : 0, 0);
  if (H === 0)
    return;
  H += Z.name.length + 6;
  let q = K.keys().move(), U = SN0(Z.name, J.fields, Q);
  for (let F = 0;F < W.length; F++) {
    let E = W[F];
    if (!Y.includeField(Z.name, E.name))
      continue;
    if (UZ.writePadRight(X, `_${Z.name}.${E.name}`, H), !vN0(X, G, q, E, U[F], 0))
      UZ.newline(X);
  }
  UZ.write(X, `#
`);
}
function y01(Z, J, $, X, Y, Q) {
  let W = n_(J), K = Y === gQ.DefaultFilter ? W : W.filter((q) => Y.includeField(Z.name, q.name)), G = K.length;
  if (G === 0)
    return;
  let H = SN0(Z.name, K, Q);
  kN0(X, "loop_");
  for (let q = 0;q < G; q++)
    kN0(X, `_${Z.name}.${K[q].name}`);
  let N = 0;
  for (let q = 0;q < $.length; q++) {
    let U = $[q], F = U.data;
    if (U.rowCount === 0)
      continue;
    let E = U.keys();
    while (E.hasNext) {
      let R = E.move(), z = !1;
      for (let D = 0;D < G; D++)
        z = vN0(X, F, R, K[D], H[D], N);
      if (!z)
        UZ.newline(X);
      N++;
    }
  }
  UZ.write(X, `#
`);
}
function g01(Z) {
  return typeof Z === "string" && Z.indexOf(`
`) >= 0;
}
function kN0(Z, J) {
  UZ.write(Z, J), UZ.newline(Z);
}
function m01(Z, J) {
  UZ.writeInteger(Z, J), UZ.whitespace1(Z);
}
function d01(Z, J, $) {
  UZ.writeFloat(Z, J, $), UZ.whitespace1(Z);
}
function p01(Z) {
  UZ.writeSafe(Z, ". ");
}
function u01(Z) {
  UZ.writeSafe(Z, "? ");
}
function c01(Z, J) {
  if (!J)
    return UZ.writeSafe(Z, ". "), !1;
  let $ = J.charCodeAt(0), X = !1, Y = 0, Q = !1, W = !1;
  for (let K = 0, G = J.length - 1;K <= G; K++)
    switch (J.charCodeAt(K)) {
      case 9:
        X = !0;
        break;
      case 10:
        return cf(Z, J), !0;
      case 32:
        X = !0;
        break;
      case 34:
        if (K && K === G)
          break;
        if (Q)
          return cf(Z, J), !0;
        W = !0, X = !0, Y = 0;
        break;
      case 39:
        if (K && K === G)
          break;
        if (W)
          return cf(Z, J), !0;
        Q = !0, X = !0, Y = 1;
        break;
    }
  if (!X && ($ === 35 || $ === 36 || $ === 59 || $ === 91 || $ === 93 || $ === 95))
    X = !0;
  if (X)
    UZ.writeSafe(Z, Y ? '"' : "'"), UZ.writeSafe(Z, J), UZ.writeSafe(Z, Y ? '" ' : "' ");
  else
    UZ.writeSafe(Z, J), UZ.writeSafe(Z, " ");
  return !1;
}
function cf(Z, J) {
  UZ.writeSafe(Z, `
;` + J), UZ.writeSafe(Z, `
;
`);
}

// node_modules/molstar/lib/mol-io/common/msgpack/encode.js
function fN0(Z) {
  let J = new ArrayBuffer(lf(Z)), $ = new DataView(J), X = new Uint8Array(J);
  return nf(Z, $, X, 0), X;
}
function lf(Z) {
  let J = typeof Z;
  if (J === "string") {
    let $ = AM(Z);
    if ($ < 32)
      return 1 + $;
    if ($ < 256)
      return 2 + $;
    if ($ < 65536)
      return 3 + $;
    if ($ < 4294967296)
      return 5 + $;
  }
  if (Z instanceof Uint8Array) {
    let $ = Z.byteLength;
    if ($ < 256)
      return 2 + $;
    if ($ < 65536)
      return 3 + $;
    if ($ < 4294967296)
      return 5 + $;
  }
  if (J === "number") {
    if (Math.floor(Z) !== Z)
      return 9;
    if (Z >= 0) {
      if (Z < 128)
        return 1;
      if (Z < 256)
        return 2;
      if (Z < 65536)
        return 3;
      if (Z < 4294967296)
        return 5;
      throw new Error("Number too big 0x" + Z.toString(16));
    }
    if (Z >= -32)
      return 1;
    if (Z >= -128)
      return 2;
    if (Z >= -32768)
      return 3;
    if (Z >= -2147483648)
      return 5;
    throw new Error("Number too small -0x" + Z.toString(16).substr(1));
  }
  if (J === "boolean" || Z === null || Z === void 0)
    return 1;
  if (J === "object") {
    let $, X = 0;
    if (Array.isArray(Z)) {
      $ = Z.length;
      for (let Y = 0;Y < $; Y++)
        X += lf(Z[Y]);
    } else {
      let Y = Object.keys(Z);
      $ = Y.length;
      for (let Q = 0;Q < $; Q++) {
        let W = Y[Q];
        X += lf(W) + lf(Z[W]);
      }
    }
    if ($ < 16)
      return 1 + X;
    if ($ < 65536)
      return 3 + X;
    if ($ < 4294967296)
      return 5 + X;
    throw new Error("Array or object too long 0x" + $.toString(16));
  }
  throw new Error("Unknown type " + J);
}
function nf(Z, J, $, X) {
  let Y = typeof Z;
  if (Y === "string") {
    let Q = AM(Z);
    if (Q < 32)
      return J.setUint8(X, Q | 160), sL($, X + 1, Z), 1 + Q;
    if (Q < 256)
      return J.setUint8(X, 217), J.setUint8(X + 1, Q), sL($, X + 2, Z), 2 + Q;
    if (Q < 65536)
      return J.setUint8(X, 218), J.setUint16(X + 1, Q), sL($, X + 3, Z), 3 + Q;
    if (Q < 4294967296)
      return J.setUint8(X, 219), J.setUint32(X + 1, Q), sL($, X + 5, Z), 5 + Q;
  }
  if (Z instanceof Uint8Array) {
    let Q = Z.byteLength, W = new Uint8Array(J.buffer);
    if (Q < 256)
      return J.setUint8(X, 196), J.setUint8(X + 1, Q), W.set(Z, X + 2), 2 + Q;
    if (Q < 65536)
      return J.setUint8(X, 197), J.setUint16(X + 1, Q), W.set(Z, X + 3), 3 + Q;
    if (Q < 4294967296)
      return J.setUint8(X, 198), J.setUint32(X + 1, Q), W.set(Z, X + 5), 5 + Q;
  }
  if (Y === "number") {
    if (!isFinite(Z))
      throw new Error("Number not finite: " + Z);
    if (Math.floor(Z) !== Z)
      return J.setUint8(X, 203), J.setFloat64(X + 1, Z), 9;
    if (Z >= 0) {
      if (Z < 128)
        return J.setUint8(X, Z), 1;
      if (Z < 256)
        return J.setUint8(X, 204), J.setUint8(X + 1, Z), 2;
      if (Z < 65536)
        return J.setUint8(X, 205), J.setUint16(X + 1, Z), 3;
      if (Z < 4294967296)
        return J.setUint8(X, 206), J.setUint32(X + 1, Z), 5;
      throw new Error("Number too big 0x" + Z.toString(16));
    }
    if (Z >= -32)
      return J.setInt8(X, Z), 1;
    if (Z >= -128)
      return J.setUint8(X, 208), J.setInt8(X + 1, Z), 2;
    if (Z >= -32768)
      return J.setUint8(X, 209), J.setInt16(X + 1, Z), 3;
    if (Z >= -2147483648)
      return J.setUint8(X, 210), J.setInt32(X + 1, Z), 5;
    throw new Error("Number too small -0x" + (-Z).toString(16).substr(1));
  }
  if (Z === null || Z === void 0)
    return J.setUint8(X, 192), 1;
  if (Y === "boolean")
    return J.setUint8(X, Z ? 195 : 194), 1;
  if (Y === "object") {
    let Q, W = 0, K = Array.isArray(Z), G;
    if (K)
      Q = Z.length;
    else
      G = Object.keys(Z), Q = G.length;
    if (Q < 16)
      J.setUint8(X, Q | (K ? 144 : 128)), W = 1;
    else if (Q < 65536)
      J.setUint8(X, K ? 220 : 222), J.setUint16(X + 1, Q), W = 3;
    else if (Q < 4294967296)
      J.setUint8(X, K ? 221 : 223), J.setUint32(X + 1, Q), W = 5;
    if (K)
      for (let H = 0;H < Q; H++)
        W += nf(Z[H], J, $, X + W);
    else
      for (let H = 0, N = G.length;H < N; H++) {
        let q = G[H];
        W += nf(q, J, $, X + W), W += nf(Z[q], J, $, X + W);
      }
    return W;
  }
  throw new Error("Unknown type " + Y);
}

// node_modules/molstar/lib/mol-io/writer/cif/encoder/binary.js
class vo {
  setFilter(Z) {
    this.filter = Z || gQ.DefaultFilter;
  }
  isCategoryIncluded(Z) {
    return this.filter.includeCategory(Z);
  }
  setFormatter(Z) {
    this.formatter = Z || gQ.DefaultFormatter;
  }
  startDataBlock(Z) {
    this.dataBlocks.push({
      header: (Z || "").replace(/[ \n\t]/g, "").toUpperCase(),
      categories: []
    });
  }
  writeCategory(Z, J, $) {
    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 (!($ === null || $ === void 0 ? void 0 : $.ignoreFilter) && !this.filter.includeCategory(Z.name))
      return;
    let { instance: X, rowCount: Y, source: Q } = uf(Z, J);
    if (!Y)
      return;
    let W = { name: "_" + Z.name, columns: [], rowCount: Y }, K = n_(X);
    for (let G of K) {
      if (!this.filter.includeField(Z.name, G.name))
        continue;
      let H = this.formatter.getFormat(Z.name, G.name);
      W.columns.push(s01(Z.name, G, Q, Y, H, this.binaryEncodingProvider, this.autoClassify));
    }
    if (!W.columns.length)
      return;
    this.dataBlocks[this.dataBlocks.length - 1].categories.push(W);
  }
  encode() {
    if (this.encodedData)
      return;
    this.encodedData = fN0(this.data), this.data = null, this.dataBlocks = null;
  }
  writeTo(Z) {
    Z.writeBinary(this.encodedData);
  }
  getData() {
    return this.encode(), this.encodedData;
  }
  getSize() {
    return this.encodedData.length;
  }
  constructor(Z, J, $) {
    this.autoClassify = $, this.dataBlocks = [], this.filter = gQ.DefaultFilter, this.formatter = gQ.DefaultFormatter, this.isBinary = !0, this.binaryEncodingProvider = void 0, this.binaryEncodingProvider = J, this.data = {
      encoder: Z,
      version: BN0,
      dataBlocks: this.dataBlocks
    };
  }
}
function l01(Z, J) {
  if (J && J.typedArray)
    return J.typedArray;
  if (Z.defaultFormat && Z.defaultFormat.typedArray)
    return Z.defaultFormat.typedArray;
  if (Z.type === F$.Type.Str)
    return Array;
  if (Z.type === F$.Type.Int)
    return Int32Array;
  return Float64Array;
}
function n01(Z) {
  if (Z === F$.Type.Str)
    return KH.by(C6.stringArray);
  return KH.by(C6.byteArray);
}
function i01(Z, J, $, X) {
  if ($ && $.encoder)
    return $.encoder;
  else if (J.defaultFormat && J.defaultFormat.encoder)
    return J.defaultFormat.encoder;
  else if (X)
    return X.get(Z, J.name);
  else
    return;
}
function o01(Z, J) {
  if (Z === F$.Type.Str)
    return KH.by(C6.stringArray);
  if (Z === F$.Type.Int)
    return c_(J);
  return IN0(J);
}
function s01(Z, J, $, X, Y, Q, W) {
  let { array: K, allPresent: G, mask: H } = a01(J, l01(J, Y), X, $), N;
  if (J.type === F$.Type.Str)
    N = KH.by(C6.stringArray);
  else
    N = i01(Z, J, Y, Q);
  if (!N)
    if (W)
      N = o01(J.type, K);
    else
      N = n01(J.type);
  let q = N.encode(K), U = void 0;
  if (!G) {
    let F = KH.by(C6.runLength).and(C6.byteArray).encode(H);
    if (F.data.length < H.length)
      U = F;
    else
      U = KH.by(C6.byteArray).encode(H);
  }
  return {
    name: J.name,
    data: q,
    mask: U
  };
}
function a01(Z, J, $, X) {
  let Y = Z.type === F$.Type.Str, Q = new J($), W = new Uint8Array($), K = Z.valueKind, G = Z.value, H = !0, N = 0;
  for (let q = 0;q < X.length; q++) {
    let U = X[q].data, F = X[q].keys();
    while (F.hasNext) {
      let E = F.move(), R = K ? K(E, U) : s.ValueKinds.Present;
      if (R !== s.ValueKinds.Present) {
        if (W[N] = R, Y)
          Q[N] = "";
        H = !1;
      } else {
        let z = G(E, U, N);
        if (typeof z === "string" && !z)
          W[N] = s.ValueKinds.NotPresent, H = !1;
        else
          W[N] = s.ValueKinds.Present;
        Q[N] = z;
      }
      N++;
    }
  }
  return { array: Q, allPresent: H, mask: W };
}

// node_modules/molstar/lib/mol-io/writer/cif.js
var m9;
(function(Z) {
  Z.Encoder = pf, Z.Category = gQ, Z.Field = F$, Z.Encoding = C6;
  function J(G) {
    let { binary: H = !1, encoderName: N = "mol*" } = G || {};
    return H ? new vo(N, G ? G.binaryEncodingPovider : void 0, G ? !!G.binaryAutoClassifyEncoding : !1) : new ko;
  }
  Z.createEncoder = J;
  function $() {
    return Z.Field.build();
  }
  Z.fields = $;
  var X = Z.Encoding;
  Z.Encodings = {
    deltaRLE: X.by(X.delta).and(X.runLength).and(X.integerPacking),
    fixedPoint2: X.by(X.fixedPoint(100)).and(X.delta).and(X.integerPacking),
    fixedPoint3: X.by(X.fixedPoint(1000)).and(X.delta).and(X.integerPacking)
  };
  function Y(G, H) {
    return { fields: G, source: [H] };
  }
  Z.categoryInstance = Y;
  function Q(G) {
    return {
      get(H, N) {
        let q = G.categories[H];
        if (!q)
          return;
        let U = q.getField(N);
        return U && U.binaryEncoding ? KH.fromEncoding(U.binaryEncoding) : void 0;
      }
    };
  }
  Z.createEncodingProviderFromCifFrame = Q;
  function W(G) {
    return {
      get(H, N) {
        for (let q = 0;q < G.length; q++) {
          let U = G[q];
          if (U.categoryName === H && U.columnName === N)
            return K(U);
        }
      }
    };
  }
  Z.createEncodingProviderFromJsonConfig = W;
  function K(G) {
    let H = G.precision;
    if (H !== void 0) {
      let N = Math.pow(10, H), q = X.by(X.fixedPoint(N));
      switch (G.encoding) {
        case "pack":
          return q.and(X.integerPacking);
        case "rle":
          return q.and(X.runLength).and(X.integerPacking);
        case "delta":
          return q.and(X.delta).and(X.integerPacking);
        case "delta-rle":
          return q.and(X.delta).and(X.runLength).and(X.integerPacking);
      }
    } else
      switch (G.encoding) {
        case "pack":
          return X.by(X.integerPacking);
        case "rle":
          return X.by(X.runLength).and(X.integerPacking);
        case "delta":
          return X.by(X.delta).and(X.integerPacking);
        case "delta-rle":
          return X.by(X.delta).and(X.runLength).and(X.integerPacking);
      }
    throw new Error("cannot be reached");
  }
})(m9 || (m9 = {}));

// node_modules/molstar/lib/mol-model-formats/structure/property/bonds/chem_comp.js
var lF;
(function(Z) {
  Z.Descriptor = {
    name: "chem_comp_bond",
    cifExport: {
      prefix: "",
      categories: [{
        name: "chem_comp_bond",
        instance(Y) {
          let Q = Z.Provider.get(Y.firstModel);
          if (!Q)
            return m9.Category.Empty;
          let W = Q.data;
          if (!W)
            return m9.Category.Empty;
          let K = Y.structures[0].uniqueResidueNames, { comp_id: G, _rowCount: H } = W, N = [];
          for (let q = 0;q < H; q++)
            if (K.has(G.value(q)))
              N[N.length] = q;
          return m9.Category.ofTable(W, N);
        }
      }]
    }
  }, Z.Provider = e$.create(Z.Descriptor);
  function J(Y, Q) {
    return A8.pick(Q, Q6.chem_comp_bond, (W) => {
      return Y.properties.chemicalComponentMap.has(Q.comp_id.value(W));
    });
  }
  Z.chemCompBondFromTable = J;
  function $(Y) {
    let Q = /* @__PURE__ */ new Map;
    function W(R) {
      if (Q.has(R))
        return Q.get(R);
      let z = new X(R);
      return Q.set(R, z), z;
    }
    let { comp_id: K, atom_id_1: G, atom_id_2: H, value_order: N, pdbx_aromatic_flag: q, _rowCount: U, pdbx_ordinal: F } = Y, E = W(K.value(0));
    for (let R = 0;R < U; R++) {
      let z = K.value(R), D = G.value(R), A = H.value(R), B = N.value(R), T = q.value(R) === "y", w = F.value(R);
      if (E.id !== z)
        E = W(z);
      let V = s1.Flag.Covalent, P = 1;
      if (T)
        V |= s1.Flag.Aromatic;
      switch (B.toLowerCase()) {
        case "delo":
          V |= s1.Flag.Aromatic;
          break;
        case "doub":
          P = 2;
          break;
        case "trip":
          P = 3;
          break;
        case "quad":
          P = 4;
          break;
      }
      E.add(D, A, P, V, w);
    }
    return Q;
  }
  Z.getEntriesFromChemCompBond = $;

  class X {
    add(Y, Q, W, K, G, H = !0) {
      let N = this.map.get(Y);
      if (N !== void 0) {
        if (N.get(Q) === void 0)
          N.set(Q, { order: W, flags: K, key: G });
      } else {
        let q = /* @__PURE__ */ new Map;
        q.set(Q, { order: W, flags: K, key: G }), this.map.set(Y, q);
      }
      if (H)
        this.add(Q, Y, W, K, G, !1);
    }
    constructor(Y) {
      this.id = Y, this.map = /* @__PURE__ */ new Map;
    }
  }
  Z.Entry = X;
})(lF || (lF = {}));

// node_modules/molstar/lib/mol-model-formats/structure/property/bonds/struct_conn.js
var mQ;
(function(Z) {
  Z.Descriptor = {
    name: "struct_conn",
    cifExport: {
      prefix: "",
      categories: [{
        name: "struct_conn",
        instance(Q) {
          let W = Z.Provider.get(Q.firstModel);
          if (!W || W.entries.length === 0)
            return m9.Category.Empty;
          let K = Q.structures[0], G = [];
          for (let H of W.entries)
            if ($(K, H.partnerA.atomIndex) && $(K, H.partnerB.atomIndex))
              G[G.length] = H.rowIndex;
          return m9.Category.ofTable(W.data, G);
        }
      }]
    }
  }, Z.Provider = e$.create(Z.Descriptor);
  function J(Q) {
    let W = Z.Provider.get(Q);
    return !!W && W.entries.length / Q.atomicConformation.atomId.rowCount > 0.95;
  }
  Z.isExhaustive = J;
  function $({ units: Q }, W) {
    for (let K = 0, G = Q.length;K < G; K++)
      if (X1.indexOf(Q[K].elements, W) >= 0)
        return !0;
    return !1;
  }
  function X(Q) {
    let W = /* @__PURE__ */ new Map;
    for (let K of Q) {
      let { partnerA: { atomIndex: G }, partnerB: { atomIndex: H } } = K;
      if (W.has(G))
        W.get(G).push(K);
      else
        W.set(G, [K]);
      if (W.has(H))
        W.get(H).push(K);
      else
        W.set(H, [K]);
    }
    return W;
  }
  Z.getAtomIndexFromEntries = X;
  function Y(Q, W) {
    let { conn_type_id: K, pdbx_dist_value: G, pdbx_value_order: H } = Q, N = {
      label_asym_id: Q.ptnr1_label_asym_id,
      label_seq_id: Q.ptnr1_label_seq_id,
      auth_seq_id: Q.ptnr1_auth_seq_id,
      label_atom_id: Q.ptnr1_label_atom_id,
      label_alt_id: Q.pdbx_ptnr1_label_alt_id,
      ins_code: Q.pdbx_ptnr1_PDB_ins_code,
      symmetry: Q.ptnr1_symmetry
    }, q = {
      label_asym_id: Q.ptnr2_label_asym_id,
      label_seq_id: Q.ptnr2_label_seq_id,
      auth_seq_id: Q.ptnr2_auth_seq_id,
      label_atom_id: Q.ptnr2_label_atom_id,
      label_alt_id: Q.pdbx_ptnr2_label_alt_id,
      ins_code: Q.pdbx_ptnr2_PDB_ins_code,
      symmetry: Q.ptnr2_symmetry
    }, U = Array.from(W.entities.data.id.toArray()), F = (R, z) => {
      if (z.label_asym_id.valueKind(R) !== s.ValueKinds.Present)
        return;
      let D = z.label_asym_id.value(R), A = z.label_atom_id.value(R);
      if (!A)
        return;
      let B = z.auth_seq_id.valueKind(R) === s.ValueKind.Present ? z.auth_seq_id.value(R) : z.label_seq_id.value(R), T = z.ins_code.value(R), w = z.label_alt_id.value(R);
      for (let V of U) {
        let P = W.atomicHierarchy.index.findResidue(V, D, B, T);
        if (P < 0)
          continue;
        let I = W.atomicHierarchy.index.findAtomOnResidue(P, A, w);
        if (I < 0)
          continue;
        return { residueIndex: P, atomIndex: I, symmetry: z.symmetry.value(R) };
      }
      return;
    }, E = [];
    for (let R = 0;R < Q._rowCount; R++) {
      let z = F(R, N), D = F(R, q);
      if (z === void 0 || D === void 0)
        continue;
      let A = K.value(R), B = H.value(R) || "", T = s1.Flag.None, w = 1;
      switch (B) {
        case "sing":
          w = 1;
          break;
        case "doub":
          w = 2;
          break;
        case "trip":
          w = 3;
          break;
        case "quad":
          w = 4;
          break;
        default:
          w = mf(Q.ptnr1_label_comp_id.value(R), Q.ptnr1_label_atom_id.value(R), Q.ptnr2_label_comp_id.value(R), Q.ptnr2_label_atom_id.value(R));
      }
      switch (A) {
        case "covale":
          T = s1.Flag.Covalent;
          break;
        case "disulf":
          T = s1.Flag.Covalent | s1.Flag.Disulfide;
          break;
        case "hydrog":
          T = s1.Flag.HydrogenBond;
          break;
        case "metalc":
          T = s1.Flag.MetallicCoordination;
          break;
      }
      E.push({
        rowIndex: R,
        flags: T,
        order: w,
        distance: G.value(R),
        partnerA: z,
        partnerB: D
      });
    }
    return E;
  }
  Z.getEntriesFromStructConn = Y;
})(mQ || (mQ = {}));

// node_modules/molstar/lib/mol-model/structure/structure/unit/bonds/intra-compute.js
var r01 = M.distance, t01 = 6, e01 = 5.5, Z11 = 3.9;
function So(Z, J, $, X, Y, Q, W) {
  let K = new lJ.EdgeBuilder(Q, Z, J), G = new Uint16Array(K.slotCount), H = new Int8Array(K.slotCount), N = new Uint32Array(K.slotCount);
  for (let q = 0, U = K.edgeCount;q < U; q++)
    K.addNextEdge(), K.assignProperty(G, X[q]), K.assignProperty(H, $[q]), K.assignProperty(N, Y[q]);
  return K.createGraph({ flags: G, order: H, key: N }, W);
}
var hN0 = M(), bN0 = M();
function J11(Z, J, $) {
  return Z.conformation.position(J, hN0), Z.conformation.position($, bN0), r01(hN0, bN0);
}
var $11 = /* @__PURE__ */ new Set;
function X11(Z) {
  let J = j9.Provider.get(Z.model), { elements: $ } = Z, { type_symbol: X } = Z.model.atomicHierarchy.atoms, Y = Z.elements.length, { maxDistance: Q } = J, { offset: W, b: K, edgeProps: { order: G, distance: H, flag: N, key: q, operatorA: U, operatorB: F } } = J.bonds, { atomSourceIndex: E } = Z.model.atomicHierarchy, { invertedIndex: R } = O2.getInvertedAtomSourceIndex(Z.model), z = [], D = [], A = [], B = [], T = [], w = Z.conformation.operator.key;
  for (let V = 0;V < Y; V++) {
    let P = $[V], I = M5(X.value(P)), S = A3(I), f = E.value(P);
    for (let v = W[f], h = W[f + 1];v < h; ++v) {
      let x = R[K[v]];
      if (P >= x)
        continue;
      let b = X1.indexOf(Z.elements, x);
      if (b < 0)
        continue;
      let g = U[v], m = F[v];
      if (g >= 0 && g !== w || m >= 0 && m !== w)
        continue;
      let i = M5(X.value(x)), r = H[v], Y0 = J11(Z, P, x), c = !1;
      if (r >= 0)
        c = dZ(Y0, r, 0.3);
      else if (Q >= 0)
        c = Y0 < Q;
      else {
        let n = oM(I, i, xN(I), xN(i));
        if (c = Y0 < n, S && A3(i))
          c = !1;
      }
      if (c)
        z[z.length] = V, D[D.length] = b, B[B.length] = G[v], A[A.length] = N[v], T[T.length] = q[v];
    }
  }
  return So(z, D, B, A, T, Y, {
    canRemap: !1,
    cacheable: J.cacheable
  });
}
function Y11(Z, J) {
  let $ = O2.isCoarseGrained(Z.model), X = $ ? t01 : J.maxRadius, { x: Y, y: Q, z: W } = Z.model.atomicConformation, K = Z.elements.length, { elements: G, residueIndex: H, chainIndex: N } = Z, { type_symbol: q, label_atom_id: U, label_alt_id: F, label_comp_id: E } = Z.model.atomicHierarchy.atoms, { label_seq_id: R } = Z.model.atomicHierarchy.residues, { traceElementIndex: z } = Z.model.atomicHierarchy.derived.residue, { index: D } = Z.model.atomicHierarchy, { byEntityKey: A } = Z.model.sequence, B = Z.lookup3d, T = mQ.Provider.get(Z.model), w = lF.Provider.get(Z.model), V = mQ.isExhaustive(Z.model), P = [], I = [], S = [], f = [], v = [], h = -1, x = void 0, b = !0, g = !0, m = !0, i = $11, r = !!(T === null || T === void 0 ? void 0 : T.residueCantorPairs.size);
  for (let Y0 = 0;Y0 < K; Y0++) {
    let c = G[Y0], n = q.value(c);
    if (b && (n !== "H" && n !== "O"))
      b = !1;
    let l = J.forceCompute ? void 0 : T && T.byAtomIndex.get(c), u = !1;
    if (l)
      for (let N0 of l) {
        let { partnerA: q0, partnerB: A0 } = N0;
        if (q0.symmetry !== A0.symmetry)
          continue;
        let S0 = q0.atomIndex === c ? A0 : q0, a0 = X1.indexOf(Z.elements, S0.atomIndex);
        if (a0 < 0 || G[a0] < c)
          continue;
        if (P[P.length] = Y0, I[I.length] = a0, S[S.length] = N0.flags, f[f.length] = N0.order, v[v.length] = N0.rowIndex, !u)
          i.clear();
        u = !0, i.add(a0);
      }
    if (V)
      continue;
    let G0 = H[c], F0 = R.value(G0), t = E.value(c);
    if (!J.forceCompute && G0 !== h)
      if (!!w && w.entries.has(t)) {
        let N0 = A[D.getEntityFromChain(N[c])];
        if (N0 && N0.sequence.microHet.has(F0))
          x = void 0;
        else
          x = w.entries.get(t).map;
      } else
        x = void 0;
    h = G0;
    let Z0 = M5(n), U0 = U.value(c), a = x ? x.get(U0) : void 0, { indices: Q0, count: $0, squaredDistances: R0 } = B.find(Y[c], Q[c], W[c], X), X0 = A3(Z0), E0 = xN(Z0), V0 = F.value(c), u0 = BR.has(Z0);
    for (let N0 = 0;N0 < $0; N0++) {
      let q0 = Q0[N0];
      if (u && i.has(q0))
        continue;
      let A0 = G[q0];
      if (A0 <= c)
        continue;
      let S0 = F.value(A0);
      if (V0 && S0 && V0 !== S0)
        continue;
      if (r) {
        let m0 = wW(H[c], H[A0]);
        if (T.residueCantorPairs.has(m0))
          continue;
      }
      let a0 = M5(q.value(A0)), D1 = A3(a0);
      if (X0 && D1)
        continue;
      let Y1 = (u0 || BR.has(a0)) && !(X0 || D1), u1 = H[A0];
      if (G0 === u1 && a) {
        let m0 = a.get(U.value(A0));
        if (m0) {
          P[P.length] = Y0, I[I.length] = q0, f[f.length] = m0.order;
          let e0 = m0.flags;
          if (Y1) {
            if (e0 | s1.Flag.Covalent)
              e0 ^= s1.Flag.Covalent;
            e0 |= s1.Flag.MetallicCoordination;
          }
          S[S.length] = e0, v[v.length] = m0.key;
        }
        continue;
      }
      let b0 = Math.sqrt(R0[N0]);
      if (b0 === 0)
        continue;
      let x0 = !1;
      if ($)
        if (G0 === u1)
          x0 = b0 <= e01;
        else
          x0 = b0 <= Z11 && z[G0] === c && z[u1] === A0;
      else {
        let m0 = oM(Z0, a0, E0, xN(a0));
        x0 = b0 <= m0;
      }
      if (x0) {
        P[P.length] = Y0, I[I.length] = q0, f[f.length] = AN0(t, U0, U.value(A0)), S[S.length] = (Y1 ? s1.Flag.MetallicCoordination : s1.Flag.Covalent) | s1.Flag.Computed, v[v.length] = -1;
        let m0 = R.value(u1);
        if (F0 === m0)
          g = !1;
        if (Math.abs(F0 - m0) > 1)
          m = !1;
      }
    }
  }
  return So(P, I, f, S, v, K, {
    canRemap: b || g && m
  });
}
function Q11(Z) {
  if (Z.conformation.operator.key === -1)
    return !1;
  let J = j9.Provider.get(Z.model);
  return !!(J === null || J === void 0 ? void 0 : J.hasOperators);
}
function W11(Z) {
  let J = j9.Provider.get(Z.model), $ = J.bySameOperator.get(Z.conformation.operator.key);
  if (!$)
    return iM.Empty;
  let { a: X, b: Y, edgeProps: { key: Q, flag: W, order: K } } = J.bonds, { invertedIndex: G } = O2.getInvertedAtomSourceIndex(Z.model), { elements: H } = Z, N = [], q = [], U = [], F = [], E = [];
  for (let R = 0, z = $.length;R < z; ++R) {
    let D = $[R];
    if (X[D] >= Y[D])
      continue;
    let A = G[X[D]], B = X1.indexOf(H, A);
    if (B < 0)
      continue;
    let T = G[Y[D]], w = X1.indexOf(H, T);
    if (w < 0)
      continue;
    N[N.length] = B, q[q.length] = w, U[U.length] = W[D], F[F.length] = K[D], E[E.length] = Q[D];
  }
  return So(N, q, F, U, E, H.length, {
    canRemap: !1,
    cacheable: J.cacheable
  });
}
function xN0(Z, J) {
  let $ = { ...gf, ...J };
  if ($.noCompute)
    return iM.Empty;
  if (Z.elements.length <= 1)
    return iM.Empty;
  if (!$.forceCompute && j9.Provider.get(Z.model))
    return Q11(Z) ? W11(Z) : X11(Z);
  else
    return Y11(Z, $);
}
// node_modules/molstar/lib/mol-model/structure/structure/unit/bonds/inter-compute.js
var K11 = M.distance, G11 = M.set, H11 = M.squaredDistance, N11 = M.transformMat4, yN0 = M(), gN0 = M();
function mN0(Z, J, $, X) {
  return Z.conformation.position(J, yN0), $.conformation.position(X, gN0), K11(yN0, gN0);
}
var q11 = e(), Nz = M();
function F11(Z, J, $, X) {
  let { maxRadius: Y } = $, { elements: Q, residueIndex: W } = Z, { x: K, y: G, z: H } = Z.model.atomicConformation, { elements: N, residueIndex: q } = J, U = Z.elements.length, { type_symbol: F, label_alt_id: E, label_atom_id: R, label_comp_id: z } = Z.model.atomicHierarchy.atoms, { type_symbol: D, label_alt_id: A, label_atom_id: B, label_comp_id: T } = J.model.atomicHierarchy.atoms, { auth_seq_id: w } = Z.model.atomicHierarchy.residues, { auth_seq_id: V } = J.model.atomicHierarchy.residues, { occupancy: P } = Z.model.atomicConformation, { occupancy: I } = J.model.atomicConformation, S = P.isDefined && I.isDefined, f = Z.model === J.model && mQ.Provider.get(Z.model), v = !$.forceCompute && Z.model === J.model && j9.Provider.get(Z.model), { atomSourceIndex: h } = Z.model.atomicHierarchy, { invertedIndex: x } = v ? O2.getInvertedAtomSourceIndex(J.model) : { invertedIndex: void 0 }, b = Z.model === J.model && mQ.isExhaustive(Z.model), g = e.mul(q11, J.conformation.operator.inverse, Z.conformation.operator.matrix), m = !e.isIdentity(g), { center: i, radius: r } = J.boundary.sphere, Y0 = (r + Y) * (r + Y);
  X.startUnitPair(Z.id, J.id);
  let c = Z.conformation.operator.key, n = J.conformation.operator.key;
  for (let l = 0;l < U; l++) {
    let u = Q[l];
    if (G11(Nz, K[u], G[u], H[u]), m)
      N11(Nz, Nz, g);
    if (H11(Nz, i) > Y0)
      continue;
    if (!$.forceCompute && v) {
      let { maxDistance: N0 } = v, { offset: q0, b: A0, edgeProps: { order: S0, distance: a0, flag: D1, key: Y1, operatorA: u1, operatorB: b0 } } = v.bonds, x0 = h.value(u), m0 = M5(F.value(u));
      for (let e0 = q0[x0], p = q0[x0 + 1];e0 < p; ++e0) {
        let J0 = x[A0[e0]], T0 = X1.indexOf(J.elements, J0);
        if (T0 < 0)
          continue;
        let o0 = u1[e0], y0 = b0[e0];
        if (o0 >= 0 && y0 >= 0) {
          if (o0 === y0)
            continue;
          if (o0 !== c || y0 !== n)
            continue;
        }
        let $1 = M5(F.value(J0)), F1 = a0[e0], A1 = mN0(Z, u, J, J0), P1 = !1;
        if (F1 >= 0)
          P1 = dZ(A1, F1, 0.3);
        else if (N0 >= 0)
          P1 = A1 < N0;
        else {
          let S1 = oM(m0, $1, xN(m0), xN($1));
          if (P1 = A1 < S1, A3(m0) && A3($1))
            P1 = !1;
        }
        if (P1)
          X.add(l, T0, { order: S0[e0], flag: D1[e0], key: Y1[e0] });
      }
      continue;
    }
    let G0 = $.forceCompute ? void 0 : f && f.byAtomIndex.get(u);
    if (G0 && G0.length) {
      let N0 = !1;
      for (let q0 of G0) {
        let { partnerA: A0, partnerB: S0 } = q0, a0 = A0.atomIndex === u ? S0 : A0, D1 = X1.indexOf(J.elements, a0.atomIndex);
        if (D1 < 0)
          continue;
        if (mN0(Z, u, J, a0.atomIndex) > Y)
          continue;
        X.add(l, D1, { order: q0.order, flag: q0.flags, key: q0.rowIndex }), N0 = !0;
      }
      if (N0)
        continue;
    }
    if (b)
      continue;
    let F0 = P.value(u), { lookup3d: t } = J, { indices: Z0, count: U0, squaredDistances: a } = t.find(Nz[0], Nz[1], Nz[2], Y);
    if (U0 === 0)
      continue;
    let Q0 = M5(F.value(u)), $0 = A3(Q0), R0 = xN(Q0), X0 = E.value(u), E0 = BR.has(Q0), V0 = R.value(u), u0 = z.value(W[u]);
    for (let N0 = 0;N0 < U0; N0++) {
      let q0 = Z0[N0], A0 = N[q0], S0 = A.value(A0);
      if (X0 && S0 && X0 !== S0)
        continue;
      if (S && I.value(A0) < 1 && F0 < 1) {
        if (w.value(W[u]) === V.value(q[A0]))
          continue;
      }
      if (f && Z.model === J.model) {
        let x0 = wW(W[u], q[A0]);
        if (f.residueCantorPairs.has(x0))
          continue;
      }
      let a0 = M5(D.value(A0)), D1 = A3(a0);
      if ($0 && D1)
        continue;
      let Y1 = (E0 || BR.has(a0)) && !($0 || D1), u1 = Math.sqrt(a[N0]);
      if (u1 === 0)
        continue;
      let b0 = oM(Q0, a0, R0, xN(a0));
      if (u1 <= b0) {
        let x0 = B.value(A0), m0 = T.value(q[A0]);
        X.add(l, q0, {
          order: mf(u0, m0, V0, x0),
          flag: (Y1 ? s1.Flag.MetallicCoordination : s1.Flag.Covalent) | s1.Flag.Computed,
          key: -1
        });
      }
    }
  }
  X.finishUnitPair();
}
function U11(Z) {
  for (let J of Z.models) {
    let $ = j9.Provider.get(J);
    if (!($ === null || $ === void 0 ? void 0 : $.hasOperators))
      return !1;
  }
  for (let J of Z.units)
    if (J.conformation.operator.key === -1)
      return !1;
  return !0;
}
function L11(Z, J) {
  let $ = /* @__PURE__ */ new Map;
  for (let X of Z.units) {
    let { key: Y } = X.conformation.operator;
    if ($.has(Y))
      $.get(Y).add(X);
    else
      $.set(Y, /* @__PURE__ */ new Set([X]));
  }
  for (let X of Z.models) {
    let Y = j9.Provider.get(X), { a: Q, b: W } = Y.bonds, { order: K, flag: G, key: H, operatorA: N, operatorB: q } = Y.bonds.edgeProps, { invertedIndex: U } = O2.getInvertedAtomSourceIndex(X), F = /* @__PURE__ */ new Map;
    for (let z of Z.units) {
      if (z.model !== X)
        continue;
      for (let D = 0, A = z.elements.length;D < A; ++D) {
        let B = z.elements[D];
        if (F.has(B))
          F.get(B).add(z);
        else
          F.set(B, /* @__PURE__ */ new Set([z]));
      }
    }
    let E = /* @__PURE__ */ new Map;
    for (let z = 0, D = N.length;z < D; ++z) {
      let A, B;
      if (N[z] === q[z])
        A = F.get(U[Q[z]]), B = F.get(U[W[z]]);
      else
        A = $.get(N[z]), B = $.get(q[z]);
      if (!A || !B)
        continue;
      for (let T of A) {
        if (N[z] !== T.conformation.operator.key)
          continue;
        for (let w of B) {
          if (q[z] !== w.conformation.operator.key)
            continue;
          if (T === w || !j0.isAtomic(T) || !j0.isAtomic(w))
            continue;
          if (T.id > w.id)
            continue;
          let V = ZJ(T.id, w.id);
          if (E.has(V))
            E.get(V).add(z);
          else
            E.set(V, /* @__PURE__ */ new Set([z]));
        }
      }
    }
    let R = [-1, -1];
    E.forEach((z, D) => {
      let [A, B] = PM(R, D), T = Z.unitMap.get(A), w = Z.unitMap.get(B);
      J.startUnitPair(A, B), z.forEach((V) => {
        let P = U[Q[V]], I = X1.indexOf(T.elements, P);
        if (I < 0)
          return;
        let S = U[W[V]], f = X1.indexOf(w.elements, S);
        if (f < 0)
          return;
        J.add(I, f, { order: K[V], flag: G[V], key: H[V] });
      }), J.finishUnitPair();
    });
  }
}
var R11 = {
  ...gf,
  ignoreWater: !0,
  ignoreIon: !0
};
function E11(Z, J) {
  let $ = new FY.Builder, X = Z.models.some((Q) => j9.Provider.get(Q)), Y = Z.models.some((Q) => mQ.isExhaustive(Q));
  if (J.noCompute || Z.isCoarseGrained && !X && !Y)
    return new cF($.getMap());
  if (!J.forceCompute && U11(Z))
    return L11(Z, $), new cF($.getMap());
  return s0.eachUnitPair(Z, (Q, W) => {
    F11(Q, W, J, $);
  }, {
    maxRadius: J.maxRadius,
    validUnit: (Q) => J.validUnit(Q),
    validUnitPair: (Q, W) => J.validUnitPair(Z, Q, W)
  }), new cF($.getMap());
}
function dN0(Z, J) {
  let $ = { ...R11, ...J };
  return E11(Z, {
    ...$,
    validUnit: J && J.validUnit || ((X) => j0.isAtomic(X)),
    validUnitPair: J && J.validUnitPair || ((X, Y, Q) => {
      if (!s0.validUnitPair(X, Y, Q))
        return !1;
      let K = Y.model.atomicHierarchy.derived.residue.moleculeType, G = Q.model.atomicHierarchy.derived.residue.moleculeType, H = (!j0.isAtomic(Y) || K[Y.residueIndex[Y.elements[0]]] !== e2.Water) && (!j0.isAtomic(Q) || G[Q.residueIndex[Q.elements[0]]] !== e2.Water), N = !j0.isAtomic(Y) || K[Y.residueIndex[Y.elements[0]]] !== e2.Ion, q = !j0.isAtomic(Q) || G[Q.residueIndex[Q.elements[0]]] !== e2.Ion, U = N && q;
      if (!((H || !$.ignoreWater) && (U || !$.ignoreIon)))
        return O11(Y, Q);
      return !0;
    })
  });
}
function O11(Z, J) {
  if (Z.model !== J.model || !j0.isAtomic(Z) || !j0.isAtomic(J))
    return !1;
  let $ = mQ.Provider.get(Z.model);
  if (!$)
    return !1;
  let X = Z.elements.length < J.elements.length ? Z : J, Y = Z.elements.length >= J.elements.length ? Z : J, { elements: Q } = X, { elements: W } = Y, { indexOf: K } = X1;
  for (let G = 0, H = Q.length;G < H; G++) {
    let N = Q[G], q = $.byAtomIndex.get(N);
    if (!(q === null || q === void 0 ? void 0 : q.length))
      continue;
    for (let U of q) {
      let F = U.partnerA.atomIndex === N ? U.partnerB.atomIndex : U.partnerA.atomIndex;
      if (K(W, F) >= 0)
        return !0;
    }
  }
  return !1;
}

// node_modules/molstar/lib/mol-model/structure/structure/unit/bonds.js
var $2;
(function(Z) {
  function J(z, D, A, B, T, w) {
    return {
      kind: "bond-location",
      aStructure: z,
      aUnit: D,
      aIndex: A,
      bStructure: B,
      bUnit: T,
      bIndex: w
    };
  }
  Z.Location = J;
  function $(z) {
    return !!z && z.kind === "bond-location";
  }
  Z.isLocation = $;
  function X(z, D) {
    return z.aStructure.label === D.aStructure.label && z.bStructure.label === D.bStructure.label && z.aIndex === D.aIndex && z.bIndex === D.bIndex && z.aUnit.id === D.aUnit.id && z.bUnit.id === D.bUnit.id;
  }
  Z.areLocationsEqual = X;
  function Y(z, D) {
    return { kind: "bond-loci", structure: z, bonds: D };
  }
  Z.Loci = Y;
  function Q(z) {
    return !!z && z.kind === "bond-loci";
  }
  Z.isLoci = Q;
  function W(z, D) {
    if (z.structure !== D.structure)
      return !1;
    if (z.bonds.length !== D.bonds.length)
      return !1;
    for (let A = 0, B = z.bonds.length;A < B; ++A)
      if (!X(z.bonds[A], D.bonds[A]))
        return !1;
    return !0;
  }
  Z.areLociEqual = W;
  function K(z) {
    return z.bonds.length === 0 ? !0 : !1;
  }
  Z.isLociEmpty = K;
  function G(z, D) {
    if (D === z.structure)
      return z;
    let A = [];
    return z.bonds.forEach((B) => {
      let T = D.unitMap.get(B.aUnit.id);
      if (!T)
        return;
      let w = D.unitMap.get(B.bUnit.id);
      if (!w)
        return;
      let V = B.aUnit.elements[B.aIndex], P = X1.indexOf(T.elements, V);
      if (P === -1)
        return;
      let I = B.bUnit.elements[B.bIndex], S = X1.indexOf(w.elements, I);
      if (S === -1)
        return;
      A.push(J(z.structure, T, P, z.structure, w, S));
    }), Y(D, A);
  }
  Z.remapLoci = G;
  function H(z) {
    let D = [], A = /* @__PURE__ */ new Map;
    for (let B of z.bonds) {
      let { aIndex: T, aUnit: w, bIndex: V, bUnit: P } = B;
      if (w === P)
        if (A.has(w.id))
          A.get(w.id).push(T, V);
        else
          A.set(w.id, [T, V]);
      else {
        if (A.has(w.id))
          A.get(w.id).push(T);
        else
          A.set(w.id, [T]);
        if (A.has(P.id))
          A.get(P.id).push(V);
        else
          A.set(P.id, [V]);
      }
    }
    return A.forEach((B, T) => {
      D.push({
        unit: z.structure.unitMap.get(T),
        indices: X1.deduplicate(X1.ofUnsortedArray(B))
      });
    }), W0.Loci(z.structure, D);
  }
  Z.toStructureElementLoci = H;
  function N(z) {
    let { aUnit: D, aIndex: A } = z.bonds[0];
    return W0.Loci(z.structure, [{ unit: D, indices: f0.ofSingleton(A) }]);
  }
  Z.toFirstStructureElementLoci = N;
  function q(z, D) {
    if (D.aUnit === D.bUnit) {
      let A = D.aUnit.bonds, B = A.getEdgeIndex(D.aIndex, D.bIndex);
      if (B < 0)
        return s1.create(s1.Flag.None);
      return s1.create(A.edgeProps.flags[B]);
    } else {
      let A = z.interUnitBonds.getBondFromLocation(D);
      if (A)
        return s1.create(A.props.flag);
      return s1.create(s1.Flag.None);
    }
  }
  Z.getType = q;
  function U(z, D) {
    if (D.aUnit === D.bUnit) {
      let A = D.aUnit.bonds, B = A.getEdgeIndex(D.aIndex, D.bIndex);
      if (B < 0)
        return 0;
      return A.edgeProps.order[B];
    } else {
      let A = z.interUnitBonds.getBondFromLocation(D);
      if (A)
        return A.props.order;
      return 0;
    }
  }
  Z.getOrder = U;
  function F(z) {
    let D = 0;
    for (let A of z.unitSymmetryGroups) {
      let B = A.units[0];
      if (j0.isAtomic(B))
        D += B.bonds.edgeCount * A.units.length;
    }
    return D;
  }
  Z.getIntraUnitBondCount = F;

  class E {
    move() {
      return this.advance(), this.current;
    }
    setElement(z, D, A) {
      this.structure = z, this.unit = D, this.index = A, this.interBondIndices = z.interUnitBonds.getEdgeIndices(A, D.id), this.interBondCount = this.interBondIndices.length, this.interBondIndex = 0, this.intraBondEnd = D.bonds.offset[A + 1], this.intraBondIndex = D.bonds.offset[A], this.hasNext = this.interBondIndex < this.interBondCount || this.intraBondIndex < this.intraBondEnd;
    }
    advance() {
      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) {
        let z = this.structure.interUnitBonds.edges[this.interBondIndices[this.interBondIndex]];
        this.current.otherUnit = this.structure.unitMap.get(z.unitA !== this.unit.id ? z.unitA : z.unitB), this.current.otherIndex = z.indexA !== this.index ? z.indexA : z.indexB, this.current.type = z.props.flag, this.current.order = z.props.order, this.interBondIndex += 1;
      } else {
        this.hasNext = !1;
        return;
      }
      this.hasNext = this.interBondIndex < this.interBondCount || this.intraBondIndex < this.intraBondEnd;
    }
    constructor() {
      this.current = {}, this.hasNext = !1;
    }
  }
  Z.ElementBondIterator = E;
  function R(z, D) {
    return yQ.fromPairProvider(z.bonds.length, (A, B, T) => {
      let { aUnit: w, aIndex: V, bUnit: P, bIndex: I } = z.bonds[A];
      w.conformation.position(w.elements[V], B), P.conformation.position(P.elements[I], T);
    }, D);
  }
  Z.getBoundingSphere = R;
})($2 || ($2 = {}));

// node_modules/molstar/lib/mol-model/structure/structure/unit/rings/compute.js
function oN0(Z) {
  let J = D11(Z), $ = z11(Z, J), X = b2.transientSegments(Z.model.atomicHierarchy.residueAtomSegments, Z.elements);
  while (X.hasNext) {
    let Y = X.move();
    M11($, Y.start, Y.end);
  }
  return $.rings;
}
var wR;
(function(Z) {
  Z[Z.MaxDepth = 5] = "MaxDepth";
})(wR || (wR = {}));
function z11(Z, J) {
  return {
    startVertex: 0,
    endVertex: 0,
    count: 0,
    isRingAtom: new Int32Array(J),
    marked: new Int32Array(J),
    queue: new Int32Array(J),
    pred: new Int32Array(J),
    depth: new Int32Array(J),
    left: new Int32Array(wR.MaxDepth),
    right: new Int32Array(wR.MaxDepth),
    color: new Int32Array(J),
    currentColor: 0,
    currentAltLoc: "",
    hasAltLoc: !1,
    rings: [],
    currentRings: [],
    unit: Z,
    bonds: Z.bonds,
    altLoc: Z.model.atomicHierarchy.atoms.label_alt_id
  };
}
function pN0(Z) {
  Z.count = Z.endVertex - Z.startVertex;
  let { isRingAtom: J, pred: $, color: X, depth: Y, marked: Q } = Z;
  for (let W = 0;W < Z.count; W++)
    J[W] = 0, $[W] = -1, Q[W] = -1, X[W] = 0, Y[W] = 0;
  Z.currentColor = 0, Z.currentAltLoc = "", Z.hasAltLoc = !1;
}
function uN0(Z) {
  let { depth: J } = Z;
  for (let $ = 0;$ < Z.count; $++)
    J[$] = Z.count + 1;
}
function D11(Z) {
  let J = b2.transientSegments(Z.model.atomicHierarchy.residueAtomSegments, Z.elements), $ = 0;
  while (J.hasNext) {
    let X = J.move();
    $ = Math.max($, X.end - X.start);
  }
  return $;
}
function cN0(Z, J) {
  let $ = Z.bonds.offset, X = Z.startVertex + J, Y = $[X], W = $[X + 1] - Y;
  if (W <= 1 || Z.isRingAtom[J] && W === 2)
    return !1;
  return !0;
}
function M11(Z, J, $) {
  if (Z.startVertex = J, Z.endVertex = $, Z.endVertex - Z.startVertex < 3)
    return;
  Z.currentRings = [];
  let { elements: X } = Z.unit, Y = [];
  for (let W = Z.startVertex;W < Z.endVertex; W++) {
    let K = Z.altLoc.value(X[W]);
    n9(Y, K);
  }
  L3(Y, "");
  let Q = 1;
  if (Y.length === 0) {
    pN0(Z);
    for (let W = 0;W < Z.count; W++) {
      if (!cN0(Z, W))
        continue;
      uN0(Z), Q = lN0(Z, W, Q);
    }
  } else
    for (let W = 0;W < Y.length; W++) {
      pN0(Z), Z.hasAltLoc = !0, Z.currentAltLoc = Y[W];
      for (let K = 0;K < Z.count; K++) {
        if (!cN0(Z, K))
          continue;
        let G = Z.altLoc.value(X[Z.startVertex + K]);
        if (G && G !== Z.currentAltLoc)
          continue;
        uN0(Z), Q = lN0(Z, K, Q);
      }
    }
  for (let W = 0, K = Z.currentRings.length;W < K; W++)
    Z.rings.push(Z.currentRings[W]);
}
function A11(Z, J, $, X) {
  if ($ < J)
    return !1;
  let { pred: Y, color: Q, left: W, right: K } = Z, G = ++Z.currentColor, H = J;
  for (let D = 0;D < wR.MaxDepth; D++)
    if (Q[H] = G, H = Y[H], H < 0)
      break;
  let N = 0, q = 0, U = !1, F = 0;
  H = $;
  for (let D = 0;D < wR.MaxDepth; D++) {
    if (Q[H] === G) {
      F = H, U = !0;
      break;
    }
    if (K[q++] = H, H = Y[H], H < 0)
      break;
  }
  if (!U)
    return !1;
  H = J;
  for (let D = 0;D < wR.MaxDepth; D++) {
    if (W[N++] = H, F === H)
      break;
    if (H = Y[H], H < 0)
      break;
  }
  let E = N + q;
  if (E < 3)
    return !1;
  let R = new Int32Array(E), z = 0;
  for (let D = 0;D < N; D++)
    R[z++] = Z.startVertex + W[D], X[W[D]] = 1;
  for (let D = q - 1;D >= 0; D--)
    R[z++] = Z.startVertex + K[D], X[K[D]] = 1;
  t$(R);
  for (let D = 0, A = Z.currentRings.length;D < A; D++) {
    let B = Z.currentRings[D];
    if (R.length === B.length) {
      if (X1.areEqual(R, B))
        return !1;
    } else if (R.length > B.length) {
      if (X1.isSubset(R, B))
        return !1;
    }
  }
  return Z.currentRings.push(X1.ofSortedArray(R)), !0;
}
function lN0(Z, J, $) {
  let { bonds: X, startVertex: Y, endVertex: Q, isRingAtom: W, marked: K, queue: G, pred: H, depth: N } = Z, { elements: q } = Z.unit, { b: U, edgeProps: { flags: F }, offset: E } = X;
  K[J] = $, N[J] = 0, G[0] = J;
  let R = 0, z = 1;
  while (R < z) {
    let D = G[R++], A = N[D], B = Y + D, T = E[B], w = E[B + 1];
    for (let V = T;V < w; V++) {
      let P = U[V];
      if (P < Y || P >= Q || !s1.isCovalent(F[V]))
        continue;
      if (Z.hasAltLoc) {
        let f = Z.altLoc.value(q[P]);
        if (f && Z.currentAltLoc !== f)
          continue;
      }
      let I = P - Y;
      if (K[I] === $) {
        if (H[I] !== D && H[D] !== I) {
          if (A11(Z, D, I, W))
            return $ + 1;
        }
        continue;
      }
      let S = Math.min(N[I], A + 1);
      if (S > wR.MaxDepth)
        continue;
      N[I] = S, K[I] = $, G[z++] = I, H[I] = D;
    }
  }
  return $ + 1;
}
function sN0(Z) {
  let J = Z.length, $ = new Array(J);
  for (let W = 0;W < J; W++)
    $[W] = Z[J - W - 1];
  let X = nN0(Z), Y = nN0($), Q = !1;
  for (let W = 0;W < J; W++) {
    let K = Z[(W + X) % J], G = $[(W + Y) % J];
    if (K !== G) {
      Q = K < G;
      break;
    }
  }
  if (Q)
    return iN0(Z, X);
  return iN0($, Y);
}
function nN0(Z) {
  let J = Z.length, $ = new Int32Array(J * 2);
  for (let W = 0;W < $.length; W++)
    $[W] = -1;
  let X = "", Y = "", Q = 0;
  for (let W = 1;W < $.length; W++) {
    let K = $[W - Q - 1];
    while (K !== -1) {
      if (X = Z[W % J], Y = Z[(Q + K + 1) % J], X === Y)
        break;
      if (X < Y)
        Q = W - K - 1;
      K = $[K];
    }
    if (K === -1)
      if (X = Z[W % J], Y = Z[(Q + K + 1) % J], X !== Y) {
        if (X < Y)
          Q = W;
        $[W - Q] = -1;
      } else
        $[W - Q] = K + 1;
    else
      $[W - Q] = K + 1;
  }
  return Q;
}
function iN0(Z, J) {
  let $ = Z.length, X = [], Y;
  for (Y = 0;Y < $ - 1; Y++)
    X.push(Z[(Y + J) % $]), X.push("-");
  return X.push(Z[(Y + J) % $]), X.join("");
}
function aN0(Z, J) {
  let $ = /* @__PURE__ */ new Map, X = /* @__PURE__ */ new Map;
  for (let G = 0, H = Z.length;G < H; G++) {
    let N = Z[G];
    for (let q = 0, U = N.length;q < U; q++) {
      let F = N[q];
      if ($.has(F))
        $.get(F).push(G);
      else
        $.set(F, [G]);
    }
  }
  for (let G = 0, H = J.length;G < H; G++) {
    let N = J[G], q = Z[N];
    for (let U = 0, F = q.length;U < F; U++) {
      let E = q[U];
      if (X.has(E))
        X.get(E).push(N);
      else
        X.set(E, [N]);
    }
  }
  let Y = new lJ.UniqueEdgeBuilder(Z.length);
  for (let G = 0, H = Z.length;G < H; G++) {
    let N = Z[G];
    for (let q = 0, U = N.length;q < U; q++) {
      let F = N[q], E = $.get(F);
      if (E.length === 1)
        continue;
      for (let R = 0, z = E.length;R < z; R++) {
        let D = E[R];
        if (G >= D)
          continue;
        Y.addEdge(G, D);
      }
    }
  }
  let Q = lJ.connectedComponents(Y.getGraph()), W = Q.componentIndex, K = [];
  for (let G = 0;G < Q.componentCount; G++)
    K[G] = [];
  for (let G = 0, H = Z.length;G < H; G++)
    K[W[G]].push(G);
  return { elementRingIndices: $, elementAromaticRingIndices: X, ringComponentIndex: W, ringComponents: K };
}

// node_modules/molstar/lib/mol-model/structure/model/properties/atomic/types.js
var l1;
(function(Z) {
  Z.H = "H", Z.D = "D", Z.T = "T", Z.HE = "HE", Z.LI = "LI", Z.BE = "BE", Z.B = "B", Z.C = "C", Z.N = "N", Z.O = "O", Z.F = "F", Z.NE = "NE", Z.NA = "NA", Z.MG = "MG", Z.AL = "AL", Z.SI = "SI", Z.P = "P", Z.S = "S", Z.CL = "CL", Z.AR = "AR", Z.K = "K", Z.CA = "CA", Z.SC = "SC", Z.TI = "TI", Z.V = "V", Z.CR = "CR", Z.MN = "MN", Z.FE = "FE", Z.CO = "CO", Z.NI = "NI", Z.CU = "CU", Z.ZN = "ZN", Z.GA = "GA", Z.GE = "GE", Z.AS = "AS", Z.SE = "SE", Z.BR = "BR", Z.KR = "KR", Z.RB = "RB", Z.SR = "SR", Z.Y = "Y", Z.ZR = "ZR", Z.NB = "NB", Z.MO = "MO", Z.TC = "TC", Z.RU = "RU", Z.RH = "RH", Z.PD = "PD", Z.AG = "AG", Z.CD = "CD", Z.IN = "IN", Z.SN = "SN", Z.SB = "SB", Z.TE = "TE", Z.I = "I", Z.XE = "XE", Z.CS = "CS", Z.BA = "BA", Z.LA = "LA", Z.CE = "CE", Z.PR = "PR", Z.ND = "ND", Z.PM = "PM", Z.SM = "SM", Z.EU = "EU", Z.GD = "GD", Z.TB = "TB", Z.DY = "DY", Z.HO = "HO", Z.ER = "ER", Z.TM = "TM", Z.YB = "YB", Z.LU = "LU", Z.HF = "HF", Z.TA = "TA", Z.W = "W", Z.RE = "RE", Z.OS = "OS", Z.IR = "IR", Z.PT = "PT", Z.AU = "AU", Z.HG = "HG", Z.TL = "TL", Z.PB = "PB", Z.BI = "BI", Z.PO = "PO", Z.AT = "AT", Z.RN = "RN", Z.FR = "FR", Z.RA = "RA", Z.AC = "AC", Z.TH = "TH", Z.PA = "PA", Z.U = "U", Z.NP = "NP", Z.PU = "PU", Z.AM = "AM", Z.CM = "CM", Z.BK = "BK", Z.CF = "CF", Z.ES = "ES", Z.FM = "FM", Z.MD = "MD", Z.NO = "NO", Z.LR = "LR", Z.RF = "RF", Z.DB = "DB", Z.SG = "SG", Z.BH = "BH", Z.HS = "HS", Z.MT = "MT", Z.DS = "DS", Z.RG = "RG", Z.CN = "CN", Z.NH = "NH", Z.FL = "FL", Z.MC = "MC", Z.LV = "LV", Z.TS = "TS", Z.OG = "OG";
})(l1 || (l1 = {}));
var rN0 = {
  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"
}, B11 = /* @__PURE__ */ new Set(["LI", "NA", "K", "RB", "CS", "FR"]);
function w11(Z) {
  return B11.has(Z);
}
var j11 = /* @__PURE__ */ new Set(["BE", "MG", "CA", "SR", "BA", "RA"]);
function T11(Z) {
  return j11.has(Z);
}
var _11 = /* @__PURE__ */ new Set(["ZN", "GA", "CD", "IN", "SN", "HG", "TI", "PB", "BI", "PO", "CN"]);
function V11(Z) {
  return _11.has(Z);
}
var I11 = /* @__PURE__ */ new Set(["F", "CL", "BR", "I", "AT"]);
function fo(Z) {
  return I11.has(Z);
}
function ho(Z) {
  let J = DR(Z);
  return J >= 21 && J <= 29 || J >= 39 && J <= 47 || J >= 72 && J <= 79 || J >= 104 && J <= 108;
}
function P11(Z) {
  let J = DR(Z);
  return J >= 57 && J <= 71;
}
function C11(Z) {
  let J = DR(Z);
  return J >= 89 && J <= 103;
}
function tN0(Z) {
  return w11(Z) || T11(Z) || P11(Z) || C11(Z) || ho(Z) || V11(Z);
}

// node_modules/molstar/lib/mol-model/structure/util.js
function k11(Z, J) {
  let $ = Z.coarseElements.entityKey[J], X = Z.model.sequence.byEntityKey[$].sequence, Y = Z.coarseElements.seq_id_begin.value(J);
  return X.compId.value(Y - 1);
}
function rM(Z, J) {
  switch (Z.kind) {
    case j0.Kind.Atomic:
      return Z.model.atomicHierarchy.derived.residue.moleculeType[Z.residueIndex[J]];
    case j0.Kind.Spheres:
    case j0.Kind.Gaussians:
      let $ = k11(Z, J), X = Z.model.properties.chemicalComponentMap.get($);
      if (X)
        return qY(X.type, $);
  }
  return e2.Unknown;
}
var v11 = /* @__PURE__ */ new Set;
function yN(Z, J) {
  let $ = cH0[Z];
  if ($ !== void 0) {
    let X = $[J];
    if (X !== void 0)
      return X;
  }
  return v11;
}
var eN0 = M.zero();
function of(Z, J) {
  let $ = Z.conformation, X = new Float32Array(J.length * 3), { elements: Y } = Z;
  for (let Q = 0, W = J.length;Q < W; ++Q)
    $.position(Y[J[Q]], eN0), M.toArray(eN0, X, Q * 3);
  return X;
}

// node_modules/molstar/lib/mol-model/structure/structure/unit/rings.js
class qz {
  get index() {
    if (this._index)
      return this._index;
    return this._index = aN0(this.all, this.aromaticRings), this._index;
  }
  get byFingerprint() {
    if (this._byFingerprint)
      return this._byFingerprint;
    return this._byFingerprint = S11(this.unit, this.all), this._byFingerprint;
  }
  get elementRingIndices() {
    return this.index.elementRingIndices;
  }
  get elementAromaticRingIndices() {
    return this.index.elementAromaticRingIndices;
  }
  get ringComponentIndex() {
    return this.index.ringComponentIndex;
  }
  get ringComponents() {
    return this.index.ringComponents;
  }
  get aromaticRings() {
    if (this._aromaticRings)
      return this._aromaticRings;
    return this._aromaticRings = b11(this.unit, this.all), this._aromaticRings;
  }
  constructor(Z, J) {
    this.unit = J, this.all = Z;
  }
}
var A5;
(function(Z) {
  function J(K, G) {
    let { elements: H } = K, { type_symbol: N } = K.model.atomicHierarchy.atoms, q = [];
    for (let U = 0, F = G.length;U < F; U++)
      q[q.length] = N.value(H[G[U]]);
    return $(q);
  }
  Z.fingerprint = J;
  function $(K) {
    return sN0(K);
  }
  Z.elementFingerprint = $;
  let X = /* @__PURE__ */ new Set([
    l1.B,
    l1.C,
    l1.N,
    l1.O,
    l1.SI,
    l1.P,
    l1.S,
    l1.GE,
    l1.AS,
    l1.SN,
    l1.SB,
    l1.BI
  ]), Y = 0.05;
  function Q(K, G) {
    let { elements: H, bonds: { b: N, offset: q, edgeProps: { flags: U } } } = K, { type_symbol: F, label_comp_id: E } = K.model.atomicHierarchy.atoms;
    if (E.value(K.elements[G[0]]) === "PRO")
      return !1;
    let R = 0, z = !1;
    for (let A = 0, B = G.length;A < B; ++A) {
      let T = G[A];
      if (!z && X.has(F.value(H[T])))
        z = !0;
      for (let w = q[T], V = q[T + 1];w < V; ++w)
        if (s1.is(s1.Flag.Aromatic, U[w])) {
          if (X1.has(G, N[w]))
            R += 1;
        }
    }
    if (R === 2 * G.length)
      return !0;
    if (!z)
      return !1;
    if (G.length < 5)
      return !1;
    if (R > 0)
      return !1;
    let D = HY.calculateMomentsAxes(of(K, G));
    return M.magnitude(D.dirC) < Y;
  }
  Z.isAromatic = Q;
  function W(K, G) {
    let { label_alt_id: H } = K.model.atomicHierarchy.atoms, { elements: N } = K;
    for (let q = 0, U = G.length;q < U; ++q) {
      let F = N[G[q]], E = H.value(F);
      if (E)
        return E;
    }
    return "";
  }
  Z.getAltId = W;
})(A5 || (A5 = {}));
(function(Z) {
  function J(X) {
    if (j0.Traits.is(X.traits, j0.Trait.Water) || j0.Traits.is(X.traits, j0.Trait.CoarseGrained))
      return new Z([], X);
    let Y = oN0(X);
    return new Z(Y, X);
  }
  Z.create = J;
  function $(X, Y) {
    let Q = /* @__PURE__ */ new Map;
    for (let W = 0, K = Y.length;W < K; W++) {
      let G = Y[W];
      h11(X, G, Q);
    }
    return Q;
  }
  Z.byFingerprintAndResidue = $;
})(qz || (qz = {}));
function S11(Z, J) {
  let $ = /* @__PURE__ */ new Map, X = 0;
  for (let Y = 0, Q = J.length;Y < Q; Y++) {
    let W = J[Y], K = A5.fingerprint(Z, W);
    if ($.has(K))
      $.get(K).push(X);
    else
      $.set(K, [X]);
    X++;
  }
  return $;
}
function f11(Z, J) {
  let { elements: $ } = Z, X = Z.model.atomicHierarchy.residueAtomSegments.index, Y = X[$[J[0]]];
  for (let Q = 1, W = J.length;Q < W; Q++)
    if (Y !== X[$[J[Q]]])
      return -1;
  return Y;
}
function h11(Z, J, $) {
  let X = Z.byFingerprint.get(J);
  if (!X)
    return;
  for (let Y = 0, Q = X.length;Y < Q; Y++) {
    let W = X[Y], K = f11(Z.unit, Z.all[W]);
    if (K >= 0)
      if ($.has(K))
        $.get(K).push(W);
      else
        $.set(K, [W]);
  }
}
function b11(Z, J) {
  let $ = [];
  for (let X = 0, Y = J.length;X < Y; ++X)
    if (A5.isAromatic(Z, J[X]))
      $.push(X);
  return $;
}

// node_modules/molstar/lib/mol-data/int/sorted-ranges.js
var XZ;
(function(Z) {
  function J(T) {
    return X1.ofSortedArray(T);
  }
  Z.ofSortedRanges = J;
  function $(T) {
    return T[0];
  }
  Z.start = $;
  function X(T) {
    return T[T.length - 1] + 1;
  }
  Z.end = X;
  function Y(T) {
    return T[0];
  }
  Z.min = Y;
  function Q(T) {
    return T[T.length - 1];
  }
  Z.max = Q;
  function W(T) {
    let w = 0;
    for (let V = 0, P = T.length;V < P; V += 2)
      w += T[V + 1] - T[V] + 1;
    return w;
  }
  Z.size = W;
  function K(T) {
    return T.length / 2;
  }
  Z.count = K;
  function G(T, w) {
    return T[w * 2];
  }
  Z.startAt = G;
  function H(T, w) {
    return T[w * 2 + 1] + 1;
  }
  Z.endAt = H;
  function N(T, w) {
    return T[w * 2];
  }
  Z.minAt = N;
  function q(T, w) {
    return T[w * 2 + 1];
  }
  Z.maxAt = q;
  function U(T, w) {
    if (T.length !== w.length)
      return !1;
    for (let V = 0, P = T.length;V < P; ++V)
      if (T[V] !== w[V])
        return !1;
    return !0;
  }
  Z.areEqual = U;
  function F(T, w) {
    let V = 0;
    for (let P = 0, I = T.length;P < I; P += 2)
      for (let S = T[P], f = T[P + 1];S <= f; ++S)
        w(S, V), ++V;
  }
  Z.forEach = F;
  function E(T, w) {
    return z(T, w) !== -1;
  }
  Z.has = E;
  function R(T, w, V) {
    return D(T, w, V) !== -1;
  }
  Z.hasFrom = R;
  function z(T, w) {
    return D(T, w, 0);
  }
  Z.firstIntersectionIndex = z;
  function D(T, w, V) {
    if (N(T, V) > f0.max(w) || Q(T) < f0.min(w))
      return -1;
    for (let P = V, I = K(T);P < I; ++P) {
      let S = k0.ofRange(N(T, P), q(T, P));
      if (f0.areIntersecting(S, w))
        return P;
    }
    return -1;
  }
  Z.firstIntersectionIndexFrom = D;
  function A(T, w) {
    return new B(T, w);
  }
  Z.transientSegments = A;

  class B {
    updateValue() {
      this.value.index = this.curIndex, this.value.start = f0.findPredecessorIndex(this.set, G(this.ranges, this.curIndex)), this.value.end = f0.findPredecessorIndex(this.set, H(this.ranges, this.curIndex));
    }
    move() {
      if (this.hasNext)
        this.updateValue(), this.curIndex = D(this.ranges, this.set, this.curIndex + 1), this.hasNext = this.curIndex !== -1;
      return this.value;
    }
    constructor(T, w) {
      this.ranges = T, this.set = w, this.value = { index: 0, start: 0, end: 0 }, this.curIndex = 0, this.hasNext = !1, this.curIndex = z(T, w), this.hasNext = this.curIndex !== -1;
    }
  }
  Z.Iterator = B;
})(XZ || (XZ = {}));

// node_modules/molstar/lib/mol-model/structure/structure/util/polymer.js
function Zq0(Z) {
  let J = [], { elements: $, model: X } = Z, { residueAtomSegments: Y } = Z.model.atomicHierarchy, { traceElementIndex: Q } = X.atomicHierarchy.derived.residue, W = XZ.transientSegments(Z.model.atomicRanges.polymerRanges, $), K = b2.transientSegments(Y, $);
  while (W.hasNext) {
    let G = W.move();
    K.setSegment(G);
    while (K.hasNext) {
      let H = K.move(), { start: N, end: q, index: U } = H;
      if (f0.areIntersecting(k0.ofRange($[N], $[q - 1]), $)) {
        let F = Q[U];
        J.push(F === -1 ? Y.offsets[U] : F);
      }
    }
  }
  return X1.ofSortedArray(J);
}
function Jq0(Z) {
  let J = [], { elements: $, model: X } = Z, { spheres: Y, gaussians: Q } = X.coarseHierarchy, W = j0.isSpheres(Z) ? Y.polymerRanges : Q.polymerRanges, K = XZ.transientSegments(W, $);
  while (K.hasNext) {
    let { start: G, end: H } = K.move();
    for (let N = G;N < H; ++N)
      J.push($[N]);
  }
  return X1.ofSortedArray(J);
}
function $q0(Z) {
  let J = [], { elements: $, model: X, residueIndex: Y } = Z, { residueAtomSegments: Q } = Z.model.atomicHierarchy, { traceElementIndex: W } = X.atomicHierarchy.derived.residue, K = XZ.transientSegments(Z.model.atomicRanges.gapRanges, Z.elements);
  while (K.hasNext) {
    let G = K.move(), H = Y[$[G.start]], N = Y[$[G.end - 1]], q = W[H], U = W[N];
    J.push(q === -1 ? Q.offsets[H] : q), J.push(U === -1 ? Q.offsets[N] : U);
  }
  return X1.ofSortedArray(J);
}
function Xq0(Z) {
  let J = [], { elements: $, model: X } = Z, { spheres: Y, gaussians: Q } = X.coarseHierarchy, W = j0.isSpheres(Z) ? Y.gapRanges : Q.gapRanges, K = XZ.transientSegments(W, $);
  while (K.hasNext) {
    let { start: G, end: H } = K.move();
    J.push($[G], $[H - 1]);
  }
  return X1.ofSortedArray(J);
}
function Yq0(Z) {
  let J = [], { elements: $, model: X } = Z, { chainAtomSegments: Y, residueAtomSegments: Q } = X.atomicHierarchy, { moleculeType: W, traceElementIndex: K } = X.atomicHierarchy.derived.residue, G = b2.transientSegments(Y, $), H = b2.transientSegments(Q, $);
  while (G.hasNext) {
    H.setSegment(G.move());
    while (H.hasNext) {
      let { index: N } = H.move();
      if (XJ(W[N])) {
        let q = K[N];
        J.push(q === -1 ? Q.offsets[N] : q);
      }
    }
  }
  return X1.ofSortedArray(J);
}
function Qq0(Z) {
  let J = [], { elements: $, model: X } = Z, { chainAtomSegments: Y, residueAtomSegments: Q } = X.atomicHierarchy, { moleculeType: W, traceElementIndex: K } = X.atomicHierarchy.derived.residue, G = b2.transientSegments(Y, $), H = b2.transientSegments(Q, $);
  while (G.hasNext) {
    H.setSegment(G.move());
    while (H.hasNext) {
      let { index: N } = H.move();
      if (Bo(W[N])) {
        let q = K[N];
        J.push(q === -1 ? Q.offsets[N] : q);
      }
    }
  }
  return X1.ofSortedArray(J);
}

// node_modules/molstar/lib/mol-model/structure/structure/util/principal-axes.js
var Wq0 = M();
function x11(Z) {
  let { elements: J, conformation: $ } = Z, X = new Float32Array(J.length * 3);
  for (let Y = 0, Q = J.length;Y < Q; Y++)
    $.invariantPosition(J[Y], Wq0), M.toArray(Wq0, X, Y * 3);
  return X;
}
function bo(Z) {
  let J = x11(Z);
  return HY.ofPositions(J);
}

// node_modules/molstar/lib/mol-math/geometry/boundary.js
var Kq0 = M.set, y11 = new $J("14"), g11 = new $J("98");
function m11(Z) {
  return Z > 1e4 ? y11 : g11;
}
function af(Z) {
  let J = t1.computeBounding(Z);
  return { box: J, sphere: C0.fromBox3D(C0(), J) };
}
var sf = M();
function GH(Z) {
  let { x: J, y: $, z: X, radius: Y, indices: Q } = Z, W = f0.size(Q);
  if (W > 250000)
    return af(Z);
  let K = m11(W);
  K.reset();
  for (let H = 0;H < W; H++) {
    let N = f0.getAt(Q, H);
    Kq0(sf, J[N], $[N], X[N]), K.includePositionRadius(sf, Y && Y[N] || 0);
  }
  K.finishedIncludeStep();
  for (let H = 0;H < W; H++) {
    let N = f0.getAt(Q, H);
    Kq0(sf, J[N], $[N], X[N]), K.radiusPositionRadius(sf, Y && Y[N] || 0);
  }
  let G = K.getSphere();
  if (!Y && C0.hasExtrema(G) && W <= G.extrema.length) {
    let H = [];
    for (let N = 0;N < W; N++) {
      let q = f0.getAt(Q, N);
      H.push(M.create(J[q], $[q], X[q]));
    }
    C0.setExtrema(G, H);
  }
  return { box: K.getBox(), sphere: G };
}

// node_modules/molstar/lib/mol-model/structure/structure/unit/bonds/element-set-intra-bond-cache.js
class rf {
  constructor() {
    this.data = /* @__PURE__ */ new Map;
  }
  get(Z) {
    let J = X1.hashCode(Z);
    if (!this.data.has(J))
      return;
    for (let [$, X] of this.data.get(J))
      if (X1.areEqual(Z, $))
        return X;
  }
  set(Z, J) {
    let $ = X1.hashCode(Z);
    if (this.data.has($)) {
      let X = this.data.get($);
      for (let Y of X)
        if (X1.areEqual(Z, Y[0])) {
          Y[1] = J;
          return;
        }
      X.push([Z, J]);
    } else
      this.data.set($, [[Z, J]]);
  }
  static get(Z) {
    if (!Z._dynamicPropertyData.ElementSetIntraBondCache)
      Z._dynamicPropertyData.ElementSetIntraBondCache = new rf;
    return Z._dynamicPropertyData.ElementSetIntraBondCache;
  }
}

// node_modules/molstar/lib/mol-model/structure/model/properties/symmetry.js
class i_ {
  get operatorGroups() {
    if (this._operators)
      return this._operators;
    return this._operators = this.operatorsProvider(), this._operators;
  }
  constructor(Z, J, $) {
    this.operatorsProvider = $, this.id = Z, this.details = J;
  }
}
(function(Z) {
  function J($, X, Y) {
    return new Z($, X, Y);
  }
  Z.create = J;
})(i_ || (i_ = {}));
var nF;
(function(Z) {
  Z.Default = { assemblies: [], spacegroup: f$.ZeroP1, isNonStandardCrystalFrame: !1 };
  function J(X, Y) {
    let Q = Y.toLocaleLowerCase(), W = T9.Provider.get(X);
    return W ? VM(W.assemblies, (K) => K.id.toLowerCase() === Q) : void 0;
  }
  Z.findAssembly = J;
  function $(X) {
    let { cell: Y, name: Q, num: W } = X.spacegroup, { size: K, anglesInRadians: G } = Y, H = K[0].toFixed(2), N = K[1].toFixed(2), q = K[2].toFixed(2), U = k$(G[0]).toFixed(2), F = k$(G[1]).toFixed(2), E = k$(G[2]).toFixed(2), R = [];
    return R.push(`Unit Cell <b>${Q}</b> #${W}`), R.push(`${H}×${N}×${q} Å`), R.push(`α=${U}° β=${F}° γ=${E}°`), R.join(" | ");
  }
  Z.getUnitcellLabel = $;
})(nF || (nF = {}));

// node_modules/molstar/lib/mol-model-formats/structure/property/assembly.js
function Gq0(Z, J, $) {
  if (!Z._rowCount)
    return [];
  let X = u11($), Y = [];
  for (let Q = 0;Q < Z._rowCount; Q++)
    Y[Y.length] = d11(Z, J, Q, X);
  return Y;
}
function d11(Z, J, $, X) {
  let Y = Z.id.value($), Q = Z.details.value($), W = [], { assembly_id: K, oper_expression: G, asym_id_list: H } = J;
  for (let N = 0, q = J._rowCount;N < q; N++) {
    if (K.value(N) !== Y)
      continue;
    W[W.length] = {
      assemblyId: Y,
      expression: G.value(N),
      asymIds: H.value(N)
    };
  }
  return i_.create(Y, Q, p11(W, X));
}
function p11(Z, J) {
  return () => {
    let $ = [], X = 0;
    for (let Y = 0;Y < Z.length; Y++) {
      let Q = Z[Y], W = n11(Q.expression), K = c11(W), G = l11(J, K, X, Q.assemblyId), H = OZ.generators.atoms({
        chainTest: OZ.pred.and(OZ.pred.eq((N) => w1.unit.operator_name(N.element), RZ.DefaultName), OZ.pred.inSet((N) => w1.chain.label_asym_id(N.element), Q.asymIds))
      });
      $[$.length] = { selector: H, operators: G, asymIds: Q.asymIds }, X += G.length;
    }
    return $;
  };
}
function u11(Z) {
  let { id: J, matrix: $, vector: X, _schema: Y } = Z, Q = /* @__PURE__ */ new Map, W = M();
  for (let K = 0, G = Z._rowCount;K < G; K++) {
    let H = M8.toMat4(e(), Y.matrix.space, $.value(K));
    M8.toVec3(W, Y.vector.space, X.value(K)), e.setTranslation(H, W), e.setValue(H, 3, 3, 1), Q.set(J.value(K), H);
  }
  return Q;
}
function c11(Z) {
  let J = [], $ = [];
  for (let X = 0;X < Z.length; X++)
    $[X] = "";
  return Hq0(Z, J, Z.length - 1, $), J;
}
function Hq0(Z, J, $, X) {
  if ($ < 0) {
    J[J.length] = X.slice(0);
    return;
  }
  let Y = Z[$], Q = Y.length;
  for (let W = 0;W < Q; W++)
    X[$] = Y[W], Hq0(Z, J, $ - 1, X);
}
function l11(Z, J, $, X) {
  let Y = [], Q = $;
  for (let W of J) {
    let K = e.identity();
    for (let N = 0;N < W.length; N++)
      e.mul(K, K, Z.get(W[N]));
    Q++;
    let G = `ASM_${Q}`, H = RZ.getAssemblyOperatorName(W);
    Y[Y.length] = RZ.create(G, K, { instanceId: H, assembly: { id: X, operId: Q, operList: W } });
  }
  return Y;
}
function n11(Z) {
  let J = /\(?([^\(\)]+)\)?]*/g, $ = [], X = [], Y;
  while (Y = J.exec(Z))
    $[$.length] = Y[1];
  return $.forEach((Q) => {
    let W = [];
    Q.split(",").forEach((K) => {
      let G = K.indexOf("-");
      if (G > 0) {
        let H = parseInt(K.substring(0, G)), N = parseInt(K.substr(G + 1));
        for (let q = H;q <= N; q++)
          W[W.length] = q.toString();
      } else
        W[W.length] = K.trim();
    }), X[X.length] = W;
  }), X;
}

// node_modules/molstar/lib/mol-model-formats/structure/property/symmetry.js
var T9;
(function(Z) {
  Z.Descriptor = {
    name: "model_symmetry"
  }, Z.Provider = e$.create(Z.Descriptor);
  function J(X) {
    let Y = Gq0(X.pdbx_struct_assembly, X.pdbx_struct_assembly_gen, X.pdbx_struct_oper_list), Q = s11(X.symmetry, X.cell), W = i11(X.atom_sites, Q);
    return { assemblies: Y, spacegroup: Q, isNonStandardCrystalFrame: W, ncsOperators: a11(X.struct_ncs_oper) };
  }
  Z.fromData = J;
  function $(X, Y) {
    let Q = d7.create("P 1", X, Y), W = f$.create(Q);
    return { assemblies: [], spacegroup: W, isNonStandardCrystalFrame: !1 };
  }
  Z.fromCell = $;
})(T9 || (T9 = {}));
function i11(Z, J) {
  if (Z._rowCount === 0)
    return !1;
  return !1;
}
function o11(Z) {
  let J = Z.Int_Tables_number.value(0), $ = Z["space_group_name_H-M"].value(0);
  if (!Z.Int_Tables_number.isDefined)
    return $;
  if (!Z["space_group_name_H-M"].isDefined)
    return J;
  return $;
}
function s11(Z, J) {
  if (Z._rowCount === 0 || J._rowCount === 0)
    return f$.ZeroP1;
  let $ = J.length_a.value(0), X = J.length_b.value(0), Y = J.length_c.value(0);
  if ($ === 0 || X === 0 || Y === 0)
    return f$.ZeroP1;
  let Q = J.angle_alpha.value(0), W = J.angle_beta.value(0), K = J.angle_gamma.value(0);
  if (Q === 0 || W === 0 || K === 0)
    return f$.ZeroP1;
  let G = o11(Z), H = d7.create(G, M.create($, X, Y), M.scale(M(), M.create(Q, W, K), Math.PI / 180));
  return f$.create(H);
}
function a11(Z) {
  if (Z._rowCount === 0)
    return;
  let { id: J, matrix: $, vector: X } = Z, Y = Q6.struct_ncs_oper.matrix.space, Q = Q6.struct_ncs_oper.vector.space, W = [];
  for (let K = 0;K < Z._rowCount; K++) {
    let G = M8.toMat3(h2(), Y, $.value(K)), H = M8.toVec3(M(), Q, X.value(K));
    if (!RZ.checkIfRotationAndTranslation(G, H))
      continue;
    if (Z.code.value(K) === "given" && !h2.isIdentity(G) && !M.isZero(H))
      continue;
    let N = J.value(K);
    W[W.length] = RZ.ofRotationAndOffset(`ncs_${N}`, G, H, N);
  }
  return W;
}

// node_modules/molstar/lib/mol-model/structure/structure/unit/resonance.js
var r11 = {
  delocalizedTriplets: {
    getThirdElement: () => {
      return;
    },
    getTripletIndices: () => {
      return;
    },
    triplets: []
  }
};
function Nq0(Z) {
  if (j0.Traits.is(Z.traits, j0.Trait.Water) || j0.Traits.is(Z.traits, j0.Trait.CoarseGrained))
    return r11;
  return {
    delocalizedTriplets: t11(Z)
  };
}
function t11(Z) {
  let J = Z.bonds, { b: $, edgeProps: X, offset: Y } = J, { order: Q, flags: W } = X, { elementAromaticRingIndices: K } = Z.rings, G = [], H = /* @__PURE__ */ new Map, N = /* @__PURE__ */ new Map, q = (U, F, E) => {
    let R = G.length;
    if (G.push(X1.ofUnsortedArray([U, F, E])), H.set(wW(U, F), E), N.has(U))
      N.get(U).push(R);
    else
      N.set(U, [R]);
  };
  for (let U = 0;U < Z.elements.length; U++) {
    if (K.has(U))
      continue;
    if (Y[U + 1] - Y[U] + 1 < 2)
      continue;
    let E = [];
    for (let R = Y[U], z = Y[U + 1];R < z; R++) {
      let D = W[R];
      if (!s1.is(D, s1.Flag.Aromatic))
        continue;
      E.push($[R]);
    }
    if (E.length >= 2) {
      q(U, E[0], E[1]);
      for (let R = 1, z = E.length;R < z; R++)
        q(U, E[R], E[0]);
    }
  }
  return {
    getThirdElement: (U, F) => {
      return H.get(wW(U, F));
    },
    getTripletIndices: (U) => {
      return N.get(U);
    },
    triplets: G
  };
}

// node_modules/molstar/lib/mol-model/structure/structure/unit.js
var j0;
(function(Z) {
  let J;
  (function(n) {
    n[n.Atomic = 0] = "Atomic", n[n.Spheres = 1] = "Spheres", n[n.Gaussians = 2] = "Gaussians";
  })(J = Z.Kind || (Z.Kind = {}));
  let $;
  (function(n) {
    n[n.Atomic = 0] = "Atomic", n[n.Spheres = 1] = "Spheres", n[n.Gaussians = 2] = "Gaussians";
  })($ = Z.Kinds || (Z.Kinds = {}));
  function X(n) {
    return n.kind === J.Atomic;
  }
  Z.isAtomic = X;
  function Y(n) {
    return n.kind === J.Spheres || n.kind === J.Gaussians;
  }
  Z.isCoarse = Y;
  function Q(n) {
    return n.kind === J.Spheres;
  }
  Z.isSpheres = Q;
  function W(n) {
    return n.kind === J.Gaussians;
  }
  Z.isGaussians = W;
  function K(n, l, u, G0, F0, t, Z0, U0, a) {
    switch (F0) {
      case J.Atomic:
        return new B(n, l, u, G0, t, U0, RZ.createMapping(Z0, t.atomicConformation, z(t)), a !== null && a !== void 0 ? a : T());
      case J.Spheres:
        return v(n, l, u, G0, t, J.Spheres, U0, RZ.createMapping(Z0, t.coarseConformation.spheres, D(t)), a !== null && a !== void 0 ? a : I());
      case J.Gaussians:
        return v(n, l, u, G0, t, J.Gaussians, U0, RZ.createMapping(Z0, t.coarseConformation.gaussians, A(t)), a !== null && a !== void 0 ? a : I());
    }
  }
  Z.create = K;
  function G(n) {
    let l = NY.Mutable();
    for (let u = 0, G0 = n.length;u < G0; u++)
      l.set(n[u].id, u);
    return l;
  }
  function H(n) {
    let l = [];
    for (let u = 0, G0 = n.length;u < G0; u++)
      l.push(n[u].id);
    return l9(l);
  }
  function N(n) {
    let l = {};
    return {
      elements: n[0].elements,
      units: n,
      get unitIndexMap() {
        if (l.unitIndexMap)
          return l.unitIndexMap;
        return l.unitIndexMap = G(n), l.unitIndexMap;
      },
      hashCode: U(n[0]),
      transformHash: H(n)
    };
  }
  Z.SymmetryGroup = N, function(n) {
    function l(G0, F0) {
      if (G0.hashCode !== F0.hashCode)
        return !1;
      return X1.areEqual(G0.elements, F0.elements);
    }
    n.areInvariantElementsEqual = l;
    function u(G0) {
      let F0 = NY.Mutable();
      for (let t = 0, Z0 = G0.length;t < Z0; ++t) {
        let U0 = G0[t];
        for (let a = 0, Q0 = U0.units.length;a < Q0; ++a)
          F0.set(U0.units[a].id, t);
      }
      return F0;
    }
    n.getUnitSymmetryGroupsIndexMap = u;
  }(N = Z.SymmetryGroup || (Z.SymmetryGroup = {}));
  function q(n) {
    return Z.isAtomic(n) ? n.model.atomicConformation.id : n.model.coarseConformation.id;
  }
  Z.conformationId = q;
  function U(n) {
    return SQ(n.invariantId, X1.hashCode(n.elements));
  }
  Z.hashUnit = U;
  let F;
  (function(n) {
    n[n.None = 0] = "None", n[n.MultiChain = 1] = "MultiChain", n[n.Partitioned = 2] = "Partitioned", n[n.FastBoundary = 4] = "FastBoundary", n[n.Water = 8] = "Water", n[n.CoarseGrained = 16] = "CoarseGrained";
  })(F = Z.Trait || (Z.Trait = {}));
  let E;
  (function(n) {
    n.is = r7.has, n.create = r7.create;
  })(E = Z.Traits || (Z.Traits = {}));
  function R() {
    return {};
  }
  function z(n) {
    let l = n.atomicHierarchy.atoms.type_symbol.value;
    return (u) => D5(l(u));
  }
  function D(n) {
    let l = n.coarseConformation.spheres.radius;
    return (u) => l[u];
  }
  function A(n) {
    return (l) => 0;
  }

  class B {
    get transientCache() {
      if (this._transientCache === void 0)
        this._transientCache = /* @__PURE__ */ new Map;
      return this._transientCache;
    }
    getChild(n) {
      if (n.length === this.elements.length)
        return this;
      return new B(this.id, this.invariantId, this.chainGroupId, this.traits, this.model, n, this.conformation, T());
    }
    getCopy(n, l, u, G0) {
      let F0 = new B(n, l, u, this.traits, this.model, this.elements, this.conformation, this.props);
      if (G0 === null || G0 === void 0 ? void 0 : G0.propagateTransientCache)
        F0._transientCache = this._transientCache;
      return F0;
    }
    applyOperator(n, l, u = !1) {
      let G0 = u ? l : RZ.compose(this.conformation.operator, l);
      return new B(n, this.invariantId, this.chainGroupId, this.traits, this.model, this.elements, RZ.createMapping(G0, this.model.atomicConformation, this.conformation.r), this.props);
    }
    remapModel(n, l, u) {
      var G0, F0;
      if (!u) {
        if (u = {
          ...this.props,
          bonds: l && !((F0 = (G0 = this.props.bonds) === null || G0 === void 0 ? void 0 : G0.props) === null || F0 === void 0 ? void 0 : F0.canRemap) ? void 0 : g(this, this.props.bonds, n, l)
        }, !Z.isSameConformation(this, n))
          u.boundary = void 0, u.lookup3d = void 0, u.principalAxes = void 0;
      }
      let t = this.conformation.operator, Z0 = T9.Provider.get(n);
      if (t.spgrOp !== -1 && Z0 && Z0 !== T9.Provider.get(this.model)) {
        let [a, Q0, $0] = t.hkl, { toFractional: R0 } = Z0.spacegroup.cell, X0 = M.transformMat4(M(), O2.getCenter(n), R0);
        t = f$.getSymmetryOperatorRef(Z0.spacegroup, t.spgrOp, a, Q0, $0, X0);
      }
      let U0 = this.model.atomicConformation !== n.atomicConformation || t !== this.conformation.operator ? RZ.createMapping(t, n.atomicConformation, z(n)) : this.conformation;
      return new B(this.id, this.invariantId, this.chainGroupId, this.traits, n, this.elements, U0, u);
    }
    get boundary() {
      if (this.props.boundary)
        return this.props.boundary;
      let { x: n, y: l, z: u } = this.model.atomicConformation, G0 = O2.getAtomicRadii(this.model);
      return this.props.boundary = E.is(this.traits, F.FastBoundary) ? af({ x: n, y: l, z: u, radius: G0, indices: this.elements }) : GH({ x: n, y: l, z: u, radius: G0, indices: this.elements }), this.props.boundary;
    }
    get lookup3d() {
      if (this.props.lookup3d)
        return this.props.lookup3d;
      let { x: n, y: l, z: u } = this.model.atomicConformation;
      return this.props.lookup3d = TW({ x: n, y: l, z: u, indices: this.elements }, this.boundary), this.props.lookup3d;
    }
    get principalAxes() {
      if (this.props.principalAxes)
        return this.props.principalAxes;
      return this.props.principalAxes = bo(this), this.props.principalAxes;
    }
    get bonds() {
      var n;
      if (this.props.bonds)
        return this.props.bonds;
      let l = rf.get(this.model), u = l.get(this.elements);
      if (!u) {
        if (u = xN0(this), (n = u.props) === null || n === void 0 ? void 0 : n.cacheable)
          l.set(this.elements, u);
      }
      return this.props.bonds = u, this.props.bonds;
    }
    get rings() {
      if (this.props.rings)
        return this.props.rings;
      return this.props.rings = qz.create(this), this.props.rings;
    }
    get resonance() {
      if (this.props.resonance)
        return this.props.resonance;
      return this.props.resonance = Nq0(this), this.props.resonance;
    }
    get polymerElements() {
      if (this.props.polymerElements)
        return this.props.polymerElements;
      return this.props.polymerElements = Zq0(this), this.props.polymerElements;
    }
    get gapElements() {
      if (this.props.gapElements)
        return this.props.gapElements;
      return this.props.gapElements = $q0(this), this.props.gapElements;
    }
    get nucleotideElements() {
      if (this.props.nucleotideElements)
        return this.props.nucleotideElements;
      return this.props.nucleotideElements = Yq0(this), this.props.nucleotideElements;
    }
    get proteinElements() {
      if (this.props.proteinElements)
        return this.props.proteinElements;
      return this.props.proteinElements = Qq0(this), this.props.proteinElements;
    }
    get residueCount() {
      if (this.props.residueCount !== void 0)
        return this.props.residueCount;
      let n = 0, l = b2.transientSegments(this.model.atomicHierarchy.residueAtomSegments, this.elements);
      while (l.hasNext)
        l.move(), n += 1;
      return this.props.residueCount = n, this.props.residueCount;
    }
    getResidueIndex(n) {
      return this.residueIndex[this.elements[n]];
    }
    constructor(n, l, u, G0, F0, t, Z0, U0) {
      this.kind = J.Atomic, this.objectPrimitive = "atomistic", this._transientCache = void 0, this.id = n, this.invariantId = l, this.chainGroupId = u, this.traits = G0, this.model = F0, this.elements = t, this.conformation = Z0, this.residueIndex = F0.atomicHierarchy.residueAtomSegments.index, this.chainIndex = F0.atomicHierarchy.chainAtomSegments.index, this.props = U0;
    }
  }
  Z.Atomic = B;
  function T() {
    return R();
  }

  class w {
    get transientCache() {
      if (this._transientCache === void 0)
        this._transientCache = /* @__PURE__ */ new Map;
      return this._transientCache;
    }
    getChild(n) {
      if (n.length === this.elements.length)
        return this;
      return v(this.id, this.invariantId, this.chainGroupId, this.traits, this.model, this.kind, n, this.conformation, I());
    }
    getCopy(n, l, u, G0) {
      let F0 = v(n, l, u, this.traits, this.model, this.kind, this.elements, this.conformation, this.props);
      if (G0 === null || G0 === void 0 ? void 0 : G0.propagateTransientCache)
        F0._transientCache = this._transientCache;
      return F0;
    }
    applyOperator(n, l, u = !1) {
      let G0 = u ? l : RZ.compose(this.conformation.operator, l);
      return v(n, this.invariantId, this.chainGroupId, this.traits, this.model, this.kind, this.elements, RZ.createMapping(G0, this.getCoarseConformation(), this.conformation.r), this.props);
    }
    remapModel(n, l, u) {
      let G0 = this.getCoarseConformation(), F0 = V(this.kind, n);
      if (!u) {
        if (u = { ...this.props }, !Z.isSameConformation(this, n))
          u.boundary = void 0, u.lookup3d = void 0, u.principalAxes = void 0;
      }
      let t = G0 !== F0 ? RZ.createMapping(this.conformation.operator, F0, this.kind === Z.Kind.Spheres ? D(n) : A(n)) : this.conformation;
      return new w(this.id, this.invariantId, this.chainGroupId, this.traits, n, this.kind, this.elements, t, u);
    }
    get boundary() {
      if (this.props.boundary)
        return this.props.boundary;
      let { x: n, y: l, z: u } = this.getCoarseConformation(), G0 = this.getCoarseRadii();
      return this.props.boundary = E.is(this.traits, F.FastBoundary) ? af({ x: n, y: l, z: u, radius: G0, indices: this.elements }) : GH({ x: n, y: l, z: u, radius: G0, indices: this.elements }), this.props.boundary;
    }
    get lookup3d() {
      if (this.props.lookup3d)
        return this.props.lookup3d;
      let { x: n, y: l, z: u } = this.getCoarseConformation();
      return this.props.lookup3d = TW({ x: n, y: l, z: u, indices: this.elements }, this.boundary), this.props.lookup3d;
    }
    get principalAxes() {
      if (this.props.principalAxes)
        return this.props.principalAxes;
      return this.props.principalAxes = bo(this), this.props.principalAxes;
    }
    get polymerElements() {
      if (this.props.polymerElements)
        return this.props.polymerElements;
      return this.props.polymerElements = Jq0(this), this.props.polymerElements;
    }
    get gapElements() {
      if (this.props.gapElements)
        return this.props.gapElements;
      return this.props.gapElements = Xq0(this), this.props.gapElements;
    }
    getCoarseConformation() {
      return V(this.kind, this.model);
    }
    getCoarseRadii() {
      return P(this.kind, this.model);
    }
    constructor(n, l, u, G0, F0, t, Z0, U0, a) {
      this._transientCache = void 0, this.kind = t, this.objectPrimitive = t === J.Spheres ? "sphere" : "gaussian", this.id = n, this.invariantId = l, this.chainGroupId = u, this.traits = G0, this.model = F0, this.elements = Z0, this.conformation = U0, this.coarseElements = t === J.Spheres ? F0.coarseHierarchy.spheres : F0.coarseHierarchy.gaussians, this.coarseConformation = t === J.Spheres ? F0.coarseConformation.spheres : F0.coarseConformation.gaussians, this.props = a;
    }
  }
  function V(n, l) {
    return n === J.Spheres ? l.coarseConformation.spheres : l.coarseConformation.gaussians;
  }
  function P(n, l) {
    return n === J.Spheres ? l.coarseConformation.spheres.radius : void 0;
  }
  function I() {
    return R();
  }

  class S extends w {
  }
  Z.Spheres = S;

  class f extends w {
  }
  Z.Gaussians = f;
  function v(n, l, u, G0, F0, t, Z0, U0, a) {
    return new w(n, l, u, G0, F0, t, Z0, U0, a);
  }
  function h(n, l) {
    return n.chainGroupId === l.chainGroupId && n.conformation.operator.name === l.conformation.operator.name;
  }
  Z.areSameChainOperatorGroup = h;
  function x(n, l) {
    return e.areEqual(n.conformation.operator.matrix, l.conformation.operator.matrix, 0.000001);
  }
  Z.areOperatorsEqual = x;
  function b(n, l) {
    if (n === l)
      return !0;
    if (!X1.areEqual(n.elements, l.elements))
      return !1;
    return m(n, l.model);
  }
  Z.areConformationsEqual = b;
  function g(n, l, u, G0) {
    var F0;
    if (!l)
      return;
    if (n.model.atomicConformation.id === u.atomicConformation.id)
      return l;
    let t = j9.Provider.get(n.model);
    if (t) {
      let Z0 = j9.Provider.get(u);
      if (!Z0 || t === Z0)
        return l;
      return;
    }
    if (((F0 = l.props) === null || F0 === void 0 ? void 0 : F0.canRemap) || !G0)
      return l;
    return m(n, u) ? l : void 0;
  }
  function m(n, l) {
    let u = O2.CoordinatesHistory.get(O2.getRoot(l));
    if (u)
      return u.areEqual(n.elements, n.kind, l);
    let G0 = n.elements, { x: F0, y: t, z: Z0 } = n.conformation.coordinates, { x: U0, y: a, z: Q0 } = i(n.kind, l);
    for (let $0 = 0, R0 = G0.length;$0 < R0; $0++) {
      let X0 = G0[$0];
      if (F0[X0] !== U0[X0] || t[X0] !== a[X0] || Z0[X0] !== Q0[X0])
        return !1;
    }
    return !0;
  }
  Z.isSameConformation = m;
  function i(n, l) {
    return n === J.Atomic ? l.atomicConformation : n === J.Spheres ? l.coarseConformation.spheres : l.coarseConformation.gaussians;
  }
  Z.getModelConformationOfKind = i;
  function r(n) {
    return i(n.kind, n.model);
  }
  Z.getConformation = r;
  function Y0(n, l) {
    return n === J.Atomic ? l.atomicHierarchy : n === J.Spheres ? l.coarseHierarchy.spheres : l.coarseHierarchy.gaussians;
  }
  Z.getModelHierarchyOfKind = Y0;
  function c(n) {
    return Y0(n.kind, n.model);
  }
  Z.getHierarchy = c;
})(j0 || (j0 = {}));

// node_modules/molstar/lib/mol-model/structure/structure/util/lookup3d.js
var Fz;
(function(Z) {
  function J(Y, Q, W, K) {
    Y.indices[Y.count] = W, Y.units[Y.count] = Q, Y.squaredDistances[Y.count] = K, Y.count++;
  }
  Z.add = J;
  function $() {
    return { count: 0, indices: [], units: [], squaredDistances: [] };
  }
  Z.create = $;
  function X(Y, Q) {
    for (let W = 0;W < Q.count; ++W)
      Y.indices[W] = Q.indices[W], Y.units[W] = Q.units[W], Y.squaredDistances[W] = Q.squaredDistances[W];
    return Y.count = Q.count, Y;
  }
  Z.copy = X;
})(Fz || (Fz = {}));
function tM() {
  return { result: Fz.create(), closeUnitsResult: KQ.create(), unitGroupResult: KQ.create() };
}

class xo {
  findUnitIndices(Z, J, $, X) {
    return this.unitLookup.find(Z, J, $, X);
  }
  find(Z, J, $, X, Y) {
    return this._find(Z, J, $, X, Y !== null && Y !== void 0 ? Y : this.findContext);
  }
  _find(Z, J, $, X, Y) {
    KQ.reset(Y.result);
    let { units: Q } = this.structure, W = this.unitLookup.find(Z, J, $, X, Y.closeUnitsResult);
    if (W.count === 0)
      return Y.result;
    for (let K = 0, G = W.count;K < G; K++) {
      let H = Q[W.indices[K]];
      if (M.set(this.pivot, Z, J, $), !H.conformation.operator.isIdentity)
        M.transformMat4(this.pivot, this.pivot, H.conformation.operator.inverse);
      let q = H.lookup3d.find(this.pivot[0], this.pivot[1], this.pivot[2], X, Y.unitGroupResult);
      for (let U = 0, F = q.count;U < F; U++)
        Fz.add(Y.result, H, q.indices[U], q.squaredDistances[U]);
    }
    return Y.result;
  }
  nearest(Z, J, $, X = 1, Y) {
    return this._nearest(Z, J, $, X, Y !== null && Y !== void 0 ? Y : this.findContext);
  }
  _nearest(Z, J, $, X, Y) {
    let Q = Y.result, W = this.heap;
    KQ.reset(Q), W.clear();
    let { units: K } = this.structure, G = 0, H = this.unitLookup.nearest(Z, J, $, K.length, (U) => (G += K[U].elements.length) >= X, Y.closeUnitsResult);
    if (H.count === 0)
      return Q;
    let N = 0, q = -Number.MAX_VALUE;
    for (let U = 0, F = H.count;U < F; U++) {
      let E = H.squaredDistances[U];
      if (N >= X && q < E)
        break;
      M.set(this.pivot, Z, J, $);
      let R = K[H.indices[U]];
      if (!R.conformation.operator.isIdentity)
        M.transformMat4(this.pivot, this.pivot, R.conformation.operator.inverse);
      let D = R.lookup3d.nearest(this.pivot[0], this.pivot[1], this.pivot[2], X, void 0, Y.unitGroupResult);
      if (D.count === 0)
        continue;
      N += D.count, q = Math.max(q, D.squaredDistances[D.count - 1]);
      for (let A = 0, B = D.count;A < B; A++)
        W.insert(D.squaredDistances[A], { index: D.indices[A], unit: R });
    }
    if (X === 1) {
      let U = W.findMinimum();
      if (U) {
        let { key: F } = U, { unit: E, index: R } = U.value;
        Fz.add(Q, E, R, F);
      }
    } else
      while (!W.isEmpty() && Q.count < X) {
        let U = W.extractMinimum(), { key: F } = U, { unit: E, index: R } = U.value;
        Fz.add(Q, E, R, F);
      }
    return Q;
  }
  findIntoBuilder(Z, J, $, X, Y) {
    let { units: Q } = this.structure, W = this.unitLookup.find(Z, J, $, X);
    if (W.count === 0)
      return;
    for (let K = 0, G = W.count;K < G; K++) {
      let H = Q[W.indices[K]];
      if (M.set(this.pivot, Z, J, $), !H.conformation.operator.isIdentity)
        M.transformMat4(this.pivot, this.pivot, H.conformation.operator.inverse);
      let q = H.lookup3d.find(this.pivot[0], this.pivot[1], this.pivot[2], X);
      if (q.count === 0)
        continue;
      let U = H.elements;
      Y.beginUnit(H.id);
      for (let F = 0, E = q.count;F < E; F++)
        Y.addElement(U[q.indices[F]]);
      Y.commitUnit();
    }
  }
  findIntoBuilderIf(Z, J, $, X, Y, Q) {
    let { units: W } = this.structure, K = this.unitLookup.find(Z, J, $, X);
    if (K.count === 0)
      return;
    let G = W0.Location.create(this.structure);
    for (let H = 0, N = K.count;H < N; H++) {
      let q = W[K.indices[H]];
      if (M.set(this.pivot, Z, J, $), !q.conformation.operator.isIdentity)
        M.transformMat4(this.pivot, this.pivot, q.conformation.operator.inverse);
      let F = q.lookup3d.find(this.pivot[0], this.pivot[1], this.pivot[2], X);
      if (F.count === 0)
        continue;
      let E = q.elements;
      G.unit = q, Y.beginUnit(q.id);
      for (let R = 0, z = F.count;R < z; R++)
        if (G.element = E[F.indices[R]], Q(G))
          Y.addElement(G.element);
      Y.commitUnit();
    }
  }
  findIntoBuilderWithRadius(Z, J, $, X, Y, Q, W, K) {
    let { units: G } = this.structure, H = this.unitLookup.find(Z, J, $, Q);
    if (H.count === 0)
      return;
    let N = W0.Location.create(this.structure), q = X + Y + Q;
    for (let U = 0, F = H.count;U < F; U++) {
      let E = G[H.indices[U]];
      if (M.set(this.pivot, Z, J, $), !E.conformation.operator.isIdentity)
        M.transformMat4(this.pivot, this.pivot, E.conformation.operator.inverse);
      let z = E.lookup3d.find(this.pivot[0], this.pivot[1], this.pivot[2], q);
      if (z.count === 0)
        continue;
      let D = E.elements;
      N.unit = E, K.beginUnit(E.id);
      for (let A = 0, B = z.count;A < B; A++) {
        N.element = D[z.indices[A]];
        let T = W(N);
        if (Math.sqrt(z.squaredDistances[A]) - X - T > Q)
          continue;
        K.addElement(D[z.indices[A]]);
      }
      K.commitUnit();
    }
  }
  check(Z, J, $, X) {
    let { units: Y } = this.structure, Q = this.unitLookup.find(Z, J, $, X);
    if (Q.count === 0)
      return !1;
    for (let W = 0, K = Q.count;W < K; W++) {
      let G = Y[Q.indices[W]];
      if (M.set(this.pivot, Z, J, $), !G.conformation.operator.isIdentity)
        M.transformMat4(this.pivot, this.pivot, G.conformation.operator.inverse);
      if (G.lookup3d.check(this.pivot[0], this.pivot[1], this.pivot[2], X))
        return !0;
    }
    return !1;
  }
  approxNearest(Z, J, $, X, Y) {
    return this._approxNearest(Z, J, $, X, Y !== null && Y !== void 0 ? Y : this.findContext);
  }
  _approxNearest(Z, J, $, X, Y) {
    KQ.reset(Y.result);
    let { units: Q } = this.structure, W = this.unitLookup.find(Z, J, $, X, Y.closeUnitsResult);
    if (W.count === 0)
      return Y.result;
    let K = Number.MAX_VALUE;
    for (let G = 0, H = W.count;G < H; G++) {
      let N = Q[W.indices[G]];
      if (M.set(this.pivot, Z, J, $), !N.conformation.operator.isIdentity)
        M.transformMat4(this.pivot, this.pivot, N.conformation.operator.inverse);
      let U = N.lookup3d.approxNearest(this.pivot[0], this.pivot[1], this.pivot[2], X, Y.unitGroupResult);
      for (let F = 0, E = U.count;F < E; F++)
        if (U.squaredDistances[F] < K)
          Fz.add(Y.result, N, U.indices[F], U.squaredDistances[F]), K = U.squaredDistances[F];
    }
    return Y.result;
  }
  get boundary() {
    return this.structure.boundary;
  }
  constructor(Z) {
    this.structure = Z, this.pivot = M(), this.heap = new S_, this.findContext = tM();
    let { units: J, boundary: $ } = Z, X = J.length, Y = new Float32Array(X), Q = new Float32Array(X), W = new Float32Array(X), K = new Float32Array(X), G = M();
    for (let N = 0;N < X; N++) {
      let q = J[N], U = q.boundary.sphere;
      M.transformMat4(G, U.center, q.conformation.operator.matrix), Y[N] = G[0], Q[N] = G[1], W[N] = G[2], K[N] = U.radius;
    }
    let H = { x: Y, y: Q, z: W, radius: K, indices: f0.ofBounds(0, X) };
    this.unitLookup = TW(H, $);
  }
}

// node_modules/molstar/lib/mol-model/structure/query/utils/structure-set.js
function iF(Z, J) {
  if (J.length === 0)
    return s0.Empty;
  if (J.length === 1)
    return J[0];
  let $ = /* @__PURE__ */ new Map, X = /* @__PURE__ */ new Set;
  for (let { units: Q } of J)
    for (let W = 0, K = Q.length;W < K; W++) {
      let G = Q[W];
      if ($.has(G.id)) {
        if (X.has(G.id))
          continue;
        let H = X1.union($.get(G.id), G.elements);
        if ($.set(G.id, H), H.length === Z.unitMap.get(G.id).elements.length)
          X.add(G.id);
      } else if ($.set(G.id, G.elements), G.elements.length === Z.unitMap.get(G.id).elements.length)
        X.add(G.id);
    }
  let Y = Z.subsetBuilder(!0);
  return $.forEach(e11, Y), Y.getStructure();
}
function e11(Z, J) {
  this.setUnit(J, Z);
}
function qq0(Z, J) {
  if (Z === J)
    return !0;
  if (Z.units.length !== J.units.length)
    return !1;
  let $ = Z.units, X = J.unitMap;
  for (let Y = 0, Q = $.length;Y < Q; Y++) {
    let W = $[Y];
    if (!X.has(W.id))
      return !1;
    let K = X.get(W.id);
    if (!X1.areEqual(W.elements, K.elements))
      return !1;
  }
  return !0;
}
function eM(Z, J) {
  if (Z === J)
    return !0;
  let $, X;
  if (Z.units.length < J.units.length)
    $ = Z, X = J;
  else
    $ = J, X = Z;
  let Y = $.units, Q = X.unitMap;
  for (let W = 0, K = Y.length;W < K; W++) {
    let G = Y[W];
    if (!Q.has(G.id))
      continue;
    let H = Q.get(G.id);
    if (X1.areIntersecting(G.elements, H.elements))
      return !0;
  }
  return !1;
}
function tf(Z, J) {
  if (Z === J)
    return Z;
  if (!eM(Z, J))
    return s0.Empty;
  let $, X;
  if (Z.units.length < J.units.length)
    $ = Z, X = J;
  else
    $ = J, X = Z;
  let Y = $.units, Q = X.unitMap, W = [];
  for (let K = 0, G = Y.length;K < G; K++) {
    let H = Y[K];
    if (!Q.has(H.id))
      continue;
    let N = Q.get(H.id);
    if (X1.areIntersecting(H.elements, N.elements)) {
      let q = X1.intersect(H.elements, N.elements);
      W[W.length] = H.getChild(q);
    }
  }
  return s0.create(W, { parent: Z.parent || J.parent });
}
function ZA(Z, J) {
  if (Z === J)
    return s0.Empty;
  if (!eM(Z, J))
    return Z;
  let $ = Z.units, X = J.unitMap, Y = [];
  for (let Q = 0, W = $.length;Q < W; Q++) {
    let K = $[Q];
    if (!X.has(K.id)) {
      Y[Y.length] = K;
      continue;
    }
    let G = X.get(K.id), H = X1.subtract(K.elements, G.elements);
    if (H.length > 0)
      Y[Y.length] = K.getChild(H);
  }
  return s0.create(Y, { parent: Z.parent || J.parent });
}

// node_modules/molstar/lib/mol-model/structure/query/selection.js
var f1;
(function(Z) {
  function J(D, A) {
    return { kind: "singletons", source: D, structure: A };
  }
  Z.Singletons = J;
  function $(D, A) {
    return { kind: "sequence", source: D, structures: A };
  }
  Z.Sequence = $;
  function X(D) {
    return J(D, s0.Empty);
  }
  Z.Empty = X;
  function Y(D) {
    return D.kind === "singletons";
  }
  Z.isSingleton = Y;
  function Q(D) {
    return Y(D) ? D.structure.units.length === 0 : D.structures.length === 0;
  }
  Z.isEmpty = Q;
  function W(D) {
    if (Y(D))
      return D.structure.elementCount;
    return D.structures.length;
  }
  Z.structureCount = W;
  function K(D) {
    if (Q(D))
      return s0.Empty;
    if (Y(D))
      return D.structure;
    return iF(D.source, D.structures);
  }
  Z.unionStructure = K;
  function G(D) {
    let A = [], { unitMap: B } = D.source;
    for (let T of K(D).units)
      if (T === B.get(T.id))
        A[A.length] = {
          unit: T,
          indices: f0.ofBounds(0, T.elements.length)
        };
      else
        A[A.length] = {
          unit: T,
          indices: f0.ofSortedArray(X1.indicesOf(B.get(T.id).elements, T.elements))
        };
    return W0.Loci(D.source, A);
  }
  Z.toLociWithCurrentUnits = G;
  function H(D) {
    let A = [], { unitMap: B } = D.source;
    for (let T of K(D).units) {
      let w = B.get(T.id);
      if (w === T)
        A[A.length] = {
          unit: w,
          indices: f0.ofBounds(0, w.elements.length)
        };
      else
        A[A.length] = {
          unit: w,
          indices: f0.ofSortedArray(X1.indicesOf(w.elements, T.elements))
        };
    }
    return W0.Loci(D.source, A);
  }
  Z.toLociWithSourceUnits = H;
  function N(D, A, B) {
    if (A.length === 0)
      return X(D);
    if (B)
      return J(D, iF(D, A));
    return $(D, A);
  }

  class q {
    add(D) {
      let A = D.elementCount;
      if (A === 0)
        return;
      if (this.structures[this.structures.length] = D, A !== 1)
        this.allSingletons = !1;
    }
    getSelection() {
      return N(this.source, this.structures, this.allSingletons);
    }
    constructor(D) {
      this.source = D, this.structures = [], this.allSingletons = !0;
    }
  }

  class U {
    add(D) {
      let A = D.elementCount;
      if (A === 0 || !this.uniqueSets.add(D))
        return;
      if (this.structures[this.structures.length] = D, A !== 1)
        this.allSingletons = !1;
    }
    getSelection() {
      return N(this.structure, this.structures, this.allSingletons);
    }
    constructor(D) {
      this.structure = D, this.structures = [], this.allSingletons = !0, this.uniqueSets = cM(s0.hashCode, s0.areUnitIdsAndIndicesEqual);
    }
  }
  function F(D) {
    return new q(D);
  }
  Z.LinearBuilder = F;
  function E(D) {
    return new U(D);
  }
  Z.UniqueBuilder = E;
  function R(D, A) {
    let B = 0;
    if (Z.isSingleton(D))
      for (let T of D.structure.units) {
        let { elements: w } = T;
        for (let V = 0, P = w.length;V < P; V++) {
          let I = s0.create([T.getChild(X1.ofSingleton(w[V]))], { parent: D.source });
          A(I, B++);
        }
      }
    else
      for (let T of D.structures)
        A(T, B++);
  }
  Z.forEach = R;
  function z(D, A) {
    if (Y(D))
      return J(A, D.structure);
    return $(A, D.structures);
  }
  Z.withInputStructure = z;
})(f1 || (f1 = {}));

// node_modules/molstar/lib/mol-model/structure/query/queries/internal.js
var mo = {};
y9(mo, {
  water: () => Q21,
  spheres: () => K21,
  defaultBondTest: () => ef,
  bundleGenerator: () => go,
  bundleElementImpl: () => yo,
  atomicSequence: () => Y21,
  atomicHet: () => W21
});

// node_modules/molstar/lib/mol-model/structure/structure/element/schema.js
function Z21(Z) {
  return !!Z.items;
}
function J21(Z) {
  let { and: J } = L0.core.logic, { eq: $, gre: X, lte: Y } = L0.core.rel, { macromolecular: Q, ihm: W, core: K } = L0.struct.atomProperty, G = {};
  if (JX(Z.label_entity_id))
    G["entity-test"] = $([Q.label_entity_id(), Z.label_entity_id]);
  let H = [];
  if (JX(Z.operator_name))
    H.push($([K.operatorName(), Z.operator_name]));
  if (JX(Z.instance_id))
    H.push($([K.instanceId(), Z.instance_id]));
  if (JX(Z.label_asym_id))
    H.push($([Q.label_asym_id(), Z.label_asym_id]));
  if (JX(Z.auth_asym_id))
    H.push($([Q.auth_asym_id(), Z.auth_asym_id]));
  if (H.length === 1)
    G["chain-test"] = H[0];
  else if (H.length > 1)
    G["chain-test"] = J(H);
  let N = [];
  if (JX(Z.label_seq_id))
    N.push(W.hasSeqId({ 0: Z.label_seq_id }));
  if (JX(Z.auth_seq_id))
    N.push($([Q.auth_seq_id(), Z.auth_seq_id]));
  if (JX(Z.residue_index))
    N.push($([Q.residueSourceIndex(), Z.residue_index]));
  if (JX(Z.pdbx_PDB_ins_code))
    N.push($([Q.pdbx_PDB_ins_code(), Z.pdbx_PDB_ins_code]));
  if (JX(Z.beg_label_seq_id) || JX(Z.end_label_seq_id))
    N.push(W.overlapsSeqIdRange({ beg: Z.beg_label_seq_id, end: Z.end_label_seq_id }));
  if (JX(Z.beg_auth_seq_id))
    N.push(X([Q.auth_seq_id(), Z.beg_auth_seq_id]));
  if (JX(Z.end_auth_seq_id))
    N.push(Y([Q.auth_seq_id(), Z.end_auth_seq_id]));
  if (N.length === 1)
    G["residue-test"] = N[0];
  else if (N.length > 1)
    G["residue-test"] = J(N);
  let q = [];
  if (JX(Z.label_comp_id))
    q.push($([Q.label_comp_id(), Z.label_comp_id]));
  if (JX(Z.auth_comp_id))
    q.push($([Q.auth_comp_id(), Z.auth_comp_id]));
  if (JX(Z.atom_id))
    q.push($([Q.id(), Z.atom_id]));
  if (JX(Z.atom_index))
    q.push($([L0.struct.atomProperty.core.sourceIndex(), Z.atom_index]));
  if (JX(Z.label_atom_id))
    q.push($([Q.label_atom_id(), Z.label_atom_id]));
  if (JX(Z.auth_atom_id))
    q.push($([Q.auth_atom_id(), Z.auth_atom_id]));
  if (JX(Z.type_symbol))
    q.push($([L0.struct.atomProperty.core.elementSymbol(), Z.type_symbol.toUpperCase()]));
  if (q.length === 1)
    G["atom-test"] = q[0];
  else if (q.length > 1)
    G["atom-test"] = J(q);
  return L0.struct.generator.atomGroups(G);
}
function Fq0(Z) {
  let J = [];
  if (Uq0(Z, ($) => J.push(J21($))), J.length === 1)
    return J[0];
  return $21(J);
}
function $21(Z) {
  return L0.struct.combinator.merge(Z.map((J) => L0.struct.modifier.union([J])));
}
function JX(Z) {
  return Z !== void 0 && Z !== null;
}
function Uq0(Z, J) {
  if (Z21(Z))
    if (Array.isArray(Z.items))
      if (Z.prefix)
        for (let $ of Z.items)
          J(Object.assign({}, Z.prefix, $));
      else
        for (let $ of Z.items)
          J($);
    else {
      let $ = { ...Z.prefix }, X = Object.keys(Z.items), Y = Z.items[X[0]].length;
      for (let Q = 0;Q < Y; Q++) {
        for (let W of X)
          $[W] = Z.items[W][Q];
        J($);
      }
    }
  else
    J(Z);
}
function Lq0(Z, J, $) {
  let X = Fq0(J);
  return B3.fromExpression(Z, X, $);
}
function X21(Z, J, $) {
  let X = Lq0(Z, J, $);
  return oF.fromLoci(X);
}
var o_ = {
  forEachItem: Uq0,
  toExpression: Fq0,
  toLoci: Lq0,
  toBundle: X21
};

// node_modules/molstar/lib/mol-model/structure/structure/element/bundle.js
var oF;
(function(Z) {
  Z.Empty = { hash: -1, elements: [] };
  function J(F, E) {
    return W(f1.toLociWithSourceUnits(f1.Singletons(F, E)));
  }
  Z.fromSubStructure = J;
  function $(F) {
    return W(f1.toLociWithSourceUnits(F));
  }
  Z.fromSelection = $;
  function X(F, E, R) {
    return W(B3.fromExpression(F, E, R));
  }
  Z.fromExpression = X;
  function Y(F, E, R) {
    return W(B3.fromQuery(F, E, R));
  }
  Z.fromQuery = Y;
  function Q(F, E, R) {
    return o_.toBundle(F, E, R);
  }
  Z.fromSchema = Q;
  function W(F) {
    let E = [];
    for (let D of F.elements) {
      let { unit: A, indices: B } = D;
      if (f0.size(B) === 0)
        continue;
      let T = [], w = [];
      if (f0.isInterval(B))
        if (f0.size(B) === 1)
          w.push(k0.min(B));
        else
          T.push(k0.min(B), k0.max(B));
      else {
        let V = 0, P = B.length;
        while (V < P) {
          let I = V;
          V++;
          while (V < P && B[V - 1] + 1 === B[V])
            V++;
          let S = V;
          if (S - I > 2)
            T.push(B[I], B[S - 1]);
          else
            for (let f = I;f < S; f++)
              w[w.length] = B[f];
        }
      }
      E.push({
        unit: A,
        set: X1.ofSortedArray(w),
        ranges: XZ.ofSortedRanges(T)
      });
    }
    let R = /* @__PURE__ */ new Map;
    for (let D = 0, A = E.length;D < A; ++D) {
      let B = E[D], T = SQ(l9(B.ranges), l9(B.set));
      if (R.has(T)) {
        let { groupedUnits: w } = R.get(T);
        if (w.has(B.unit.invariantId))
          w.get(B.unit.invariantId).push(B.unit.id);
        else
          w.set(B.unit.invariantId, [B.unit.id]);
      } else {
        let w = /* @__PURE__ */ new Map;
        w.set(B.unit.invariantId, [B.unit.id]), R.set(T, { groupedUnits: w, set: B.set, ranges: B.ranges });
      }
    }
    let z = [];
    return R.forEach((D) => {
      let A = [];
      D.groupedUnits.forEach((B) => A.push(X1.ofUnsortedArray(B))), A.sort((B, T) => B[0] - T[0]), z.push({ groupedUnits: A, set: D.set, ranges: D.ranges });
    }), { hash: F.structure.hashCode, elements: z };
  }
  Z.fromLoci = W;
  function K(F, E) {
    let R = [];
    for (let z = 0, D = F.length;z < D; ++z) {
      let A = F[z];
      if (E.unitMap.has(A))
        R.push(E.unitMap.get(A));
    }
    return R;
  }
  function G(F, E) {
    if (F.hash !== -1 && F.hash !== E.hashCode)
      new Error("Bundle not compatible with given structure");
    let R = [];
    for (let z of F.elements)
      for (let D of z.groupedUnits) {
        let A = K(D, E);
        if (A.length === 0)
          continue;
        let B;
        if (z.ranges.length === 0)
          B = z.set;
        else if (z.set.length === 0)
          if (z.ranges.length === 2)
            B = k0.ofRange(z.ranges[0], z.ranges[1]);
          else {
            let T = new Int32Array(XZ.size(z.ranges));
            XZ.forEach(z.ranges, (w, V) => T[V] = w), B = X1.ofSortedArray(T);
          }
        else {
          let T = XZ.size(z.ranges), w = new Int32Array(z.set.length + T);
          XZ.forEach(z.ranges, (V, P) => w[P] = V), w.set(z.set, T), B = X1.ofUnsortedArray(w);
        }
        for (let T of A)
          R.push({ unit: T, indices: B });
      }
    return B3(E, R);
  }
  Z.toLoci = G;
  function H(F, E) {
    if (F.hash !== -1 && F.hash !== E.hashCode)
      new Error("Bundle not compatible with given structure");
    let R = [];
    for (let z of F.elements)
      for (let D of z.groupedUnits) {
        let A = K(D, E);
        if (A.length === 0)
          continue;
        let B = A[0].elements, T = XZ.size(z.ranges), w = z.set.length, V = new Int32Array(w + T), P;
        if (T === 0) {
          for (let I = 0, S = w;I < S; ++I)
            V[I] = B[z.set[I]];
          P = X1.ofSortedArray(V);
        } else if (w === 0)
          XZ.forEach(z.ranges, (I, S) => V[S] = B[I]), P = X1.ofSortedArray(V);
        else if (X1.min(z.set) > XZ.max(z.ranges)) {
          XZ.forEach(z.ranges, (I, S) => V[S] = B[I]);
          for (let I = 0, S = w;I < S; ++I)
            V[I + T] = B[z.set[I]];
          P = X1.ofSortedArray(V);
        } else if (XZ.min(z.ranges) > X1.max(z.set)) {
          for (let I = 0, S = w;I < S; ++I)
            V[I] = B[z.set[I]];
          XZ.forEach(z.ranges, (I, S) => V[S + w] = B[I]), P = X1.ofSortedArray(V);
        } else {
          XZ.forEach(z.ranges, (I, S) => V[S] = B[I]);
          for (let I = 0, S = w;I < S; ++I)
            V[I + T] = B[z.set[I]];
          P = X1.ofUnsortedArray(V);
        }
        for (let I of A)
          R.push(I.getChild(P));
      }
    return s0.create(R, { parent: E });
  }
  Z.toStructure = H;
  function N(F) {
    return L0.internal.generator.bundleElement({
      groupedUnits: L0.core.type.list(F.groupedUnits.map((E) => L0.core.type.list(E))),
      ranges: L0.core.type.list(F.ranges),
      set: L0.core.type.list(F.set)
    });
  }
  function q(F) {
    return L0.internal.generator.bundle({
      elements: L0.core.type.list(F.elements.map(N))
    });
  }
  Z.toExpression = q;
  function U(F, E) {
    if (F.elements.length !== E.elements.length)
      return !1;
    for (let R = 0, z = F.elements.length;R < z; ++R) {
      let D = F.elements[R], A = E.elements[R];
      if (D.groupedUnits.length !== A.groupedUnits.length)
        return !1;
      for (let B = 0, T = A.groupedUnits.length;B < T; ++B)
        if (!X1.areEqual(D.groupedUnits[B], A.groupedUnits[B]))
          return !1;
      if (!X1.areEqual(D.set, A.set))
        return !1;
      if (!XZ.areEqual(D.ranges, A.ranges))
        return !1;
    }
    return !0;
  }
  Z.areEqual = U;
})(oF || (oF = {}));

// node_modules/molstar/lib/mol-model/structure/query/queries/internal.js
function ef(Z) {
  return s1.isCovalent(Z.atomicBond.type);
}
function Y21() {
  return function Z(J) {
    let { inputStructure: $ } = J, X = W0.Location.create($), Y = [];
    for (let Q of $.units) {
      if (Q.kind !== j0.Kind.Atomic)
        continue;
      X.unit = Q;
      let W = Q.elements;
      if (X.element = W[0], w1.entity.type(X) !== "polymer")
        continue;
      let K = b2.transientSegments(Q.model.atomicHierarchy.residueAtomSegments, W), G = 0;
      while (K.hasNext)
        G++, K.move();
      if (G < 8)
        continue;
      Y.push(Q);
    }
    return f1.Singletons($, s0.create(Y, { parent: $ }));
  };
}
function Q21() {
  return function Z(J) {
    let { inputStructure: $ } = J, X = W0.Location.create($), Y = [];
    for (let Q of $.units) {
      if (Q.kind !== j0.Kind.Atomic)
        continue;
      X.unit = Q;
      let W = Q.elements;
      if (X.element = W[0], w1.entity.type(X) !== "water")
        continue;
      Y.push(Q);
    }
    return f1.Singletons($, s0.create(Y, { parent: $ }));
  };
}
function W21() {
  return function Z(J) {
    let { inputStructure: $ } = J, X = W0.Location.create($), Y = [];
    for (let Q of $.units) {
      if (Q.kind !== j0.Kind.Atomic)
        continue;
      X.unit = Q;
      let W = Q.elements;
      if (X.element = W[0], w1.entity.type(X) === "water")
        continue;
      if (w1.entity.type(X) === "polymer") {
        let K = b2.transientSegments(Q.model.atomicHierarchy.residueAtomSegments, W), G = 0;
        while (K.hasNext)
          G++, K.move();
        if (G >= 8)
          continue;
      }
      Y.push(Q);
    }
    return f1.Singletons($, s0.create(Y, { parent: $ }));
  };
}
function K21() {
  return function Z(J) {
    let { inputStructure: $ } = J, X = [];
    for (let Y of $.units) {
      if (Y.kind !== j0.Kind.Spheres)
        continue;
      X.push(Y);
    }
    return f1.Singletons($, s0.create(X, { parent: $ }));
  };
}
function yo(Z, J, $) {
  return {
    groupedUnits: Z,
    ranges: J,
    set: $
  };
}
function go(Z) {
  return function J($) {
    let X = {
      hash: $.inputStructure.hashCode,
      elements: Z
    };
    return f1.Sequence($.inputStructure, [oF.toStructure(X, $.inputStructure)]);
  };
}

// node_modules/molstar/lib/mol-model/structure/query/context.js
class C9 {
  pushCurrentElement() {
    return this.currentElementStack[this.currentElementStack.length] = this.element, this.element = W0.Location.create(void 0), this.element;
  }
  popCurrentElement() {
    this.element = this.currentElementStack.pop();
  }
  pushCurrentBond() {
    if (this.atomicBond)
      this.currentAtomicBondStack.push(this.atomicBond);
    return this.atomicBond = new po, this.atomicBond;
  }
  popCurrentBond() {
    if (this.currentAtomicBondStack.length > 0)
      this.atomicBond = this.currentAtomicBondStack.pop();
    else
      this.atomicBond = void 0;
  }
  pushCurrentStructure() {
    if (this.currentStructure)
      this.currentStructureStack.push(this.currentStructure);
  }
  popCurrentStructure() {
    if (this.currentStructureStack.length)
      this.currentStructure = this.currentStructureStack.pop();
    else
      this.currentStructure = void 0;
  }
  pushInputStructure(Z) {
    this.inputStructureStack.push(this.inputStructure), this.inputStructure = Z;
  }
  popInputStructure() {
    if (this.inputStructureStack.length === 0)
      throw new Error("Must push before pop.");
    this.inputStructure = this.inputStructureStack.pop();
  }
  throwIfTimedOut() {
    if (this.timeoutMs === 0)
      return;
    if (m6() - this.timeCreated > this.timeoutMs)
      throw new Error(`The query took too long to execute (> ${this.timeoutMs / 1000}s).`);
  }
  tryGetCurrentSelection() {
    if (!this.currentSelection)
      throw new Error("The current selection is not assigned.");
    return this.currentSelection;
  }
  constructor(Z, J) {
    this.currentElementStack = [], this.currentAtomicBondStack = [], this.currentStructureStack = [], this.inputStructureStack = [], this.timeCreated = m6(), this.element = W0.Location.create(void 0), this.currentStructure = void 0, this.atomicBond = new po, this.currentSelection = void 0, this.inputStructure = Z, this.timeoutMs = J && J.timeoutMs || 0, this.currentSelection = J && J.currentSelection;
  }
}

class po {
  constructor() {
    this.a = W0.Location.create(void 0), this.aIndex = 0, this.b = W0.Location.create(void 0), this.bIndex = 0, this.type = s1.Flag.None, this.order = 0, this.key = -1, this.testFn = ef;
  }
  setStructure(Z) {
    this.a.structure = Z, this.b.structure = Z;
  }
  setTestFn(Z) {
    this.testFn = Z || ef;
  }
  test(Z, J) {
    if (this.testFn(Z))
      return !0;
    if (J)
      return this.swap(), this.testFn(Z);
    return !1;
  }
  swap() {
    let Z = this.aIndex;
    this.aIndex = this.bIndex, this.bIndex = Z;
    let J = this.a.unit;
    this.a.unit = this.b.unit, this.b.unit = J;
    let $ = this.a.element;
    this.a.element = this.b.element, this.b.element = $;
  }
  get length() {
    return W0.Location.distance(this.a, this.b);
  }
}

// node_modules/molstar/lib/mol-model/structure/query/query.js
var s_;
(function(Z) {
  function J(X, Y, Q) {
    return X(new C9(Y, Q));
  }
  Z.run = J;
  function $(X, Y, Q) {
    let W = X(new C9(Y, Q));
    return f1.toLociWithSourceUnits(W);
  }
  Z.loci = $;
})(s_ || (s_ = {}));
// node_modules/molstar/lib/mol-model/structure/query/queries/generators.js
var no = {};
y9(no, {
  rings: () => L21,
  residues: () => G21,
  querySelection: () => R21,
  none: () => Zh,
  chains: () => H21,
  bondedAtomicPairs: () => E21,
  atoms: () => lo,
  all: () => Rq0
});

// node_modules/molstar/lib/mol-model/structure/query/utils/builders.js
class a_ {
  add(Z) {
    if (!Z.elementCount)
      return;
    if (Z.elementCount !== 1)
      this.allSingletons = !1;
    if (this.set.add(Z))
      this.structures[this.structures.length] = Z;
  }
  getSelection() {
    if (this.allSingletons)
      return f1.Singletons(this.source, iF(this.source, this.structures));
    return f1.Sequence(this.source, this.structures);
  }
  constructor(Z) {
    this.source = Z, this.set = cM(s0.hashCode, s0.areUnitIdsAndIndicesEqual), this.structures = [], this.allSingletons = !0;
  }
}

class uo {
  add(Z, J, $) {
    let X = this.builderMap.get(Z);
    if (!X)
      X = this.source.subsetBuilder(!0), this.builders[this.builders.length] = X, this.builderMap.set(Z, X);
    X.addToUnit(J, $);
  }
  allSingletons() {
    for (let Z = 0, J = this.builders.length;Z < J; Z++)
      if (this.builders[Z].elementCount > 1)
        return !1;
    return !0;
  }
  singletonSelection() {
    let Z = this.source.subsetBuilder(!0), J = W0.Location.create(this.source);
    for (let $ = 0, X = this.builders.length;$ < X; $++)
      this.builders[$].setSingletonLocation(J), Z.addToUnit(J.unit.id, J.element);
    return f1.Singletons(this.source, Z.getStructure());
  }
  fullSelection() {
    let Z = new Array(this.builders.length);
    for (let J = 0, $ = this.builders.length;J < $; J++)
      Z[J] = this.builders[J].getStructure();
    return f1.Sequence(this.source, Z);
  }
  getSelection() {
    if (this.builders.length === 0)
      return f1.Empty(this.source);
    if (this.allSingletons())
      return this.singletonSelection();
    return this.fullSelection();
  }
  constructor(Z) {
    this.source = Z, this.builders = [], this.builderMap = /* @__PURE__ */ new Map;
  }
}

// node_modules/molstar/lib/mol-model/structure/query/queries/generators.js
var Zh = (Z) => f1.Sequence(Z.inputStructure, []), Rq0 = (Z) => f1.Singletons(Z.inputStructure, Z.inputStructure);
function G21(Z) {
  return lo({ ...Z, groupBy: (J) => w1.residue.key(J.element) });
}
function H21(Z) {
  return lo({ ...Z, groupBy: (J) => w1.chain.key(J.element) });
}
function jR(Z) {
  return !0;
}
function N21(Z) {
  return 0;
}
function lo(Z) {
  if (!Z || !Z.atomTest && !Z.residueTest && !Z.chainTest && !Z.entityTest && !Z.unitTest && !Z.groupBy)
    return Rq0;
  if (!!Z.atomTest && !Z.residueTest && !Z.chainTest && !Z.entityTest && !Z.unitTest && !Z.groupBy)
    return q21(Z.atomTest);
  let J = {
    unitTest: Z.unitTest || jR,
    entityTest: Z.entityTest || jR,
    chainTest: Z.chainTest || jR,
    residueTest: Z.residueTest || jR,
    atomTest: Z.atomTest || jR,
    groupBy: Z.groupBy || N21
  };
  if (!Z.groupBy)
    return F21(J);
  return U21(J);
}
function q21(Z) {
  return function J($) {
    let { inputStructure: X } = $, { units: Y } = X, Q = $.pushCurrentElement(), W = X.subsetBuilder(!0);
    Q.structure = X;
    for (let K of Y) {
      Q.unit = K;
      let G = K.elements;
      W.beginUnit(K.id);
      for (let H = 0, N = G.length;H < N; H++)
        if (Q.element = G[H], Z($))
          W.addElement(Q.element);
      W.commitUnit(), $.throwIfTimedOut();
    }
    return $.popCurrentElement(), f1.Singletons(X, W.getStructure());
  };
}
function F21({ unitTest: Z, entityTest: J, chainTest: $, residueTest: X, atomTest: Y }) {
  return function Q(W) {
    let { inputStructure: K } = W, { units: G } = K, H = W.pushCurrentElement(), N = K.subsetBuilder(!0), q = X === jR && Y === jR, U = Y === jR;
    H.structure = K;
    for (let F of G) {
      if (H.unit = F, !Z(W))
        continue;
      let { elements: E, model: R } = F;
      if (N.beginUnit(F.id), F.kind === j0.Kind.Atomic) {
        let z = b2.transientSegments(F.model.atomicHierarchy.chainAtomSegments, E), D = b2.transientSegments(F.model.atomicHierarchy.residueAtomSegments, E);
        while (z.hasNext) {
          let A = z.move();
          if (H.element = E[A.start], !J(W) || !$(W))
            continue;
          if (q) {
            N.addElementRange(E, A.start, A.end);
            continue;
          }
          D.setSegment(A);
          while (D.hasNext) {
            let B = D.move();
            if (H.element = E[B.start], !X(W))
              continue;
            if (U) {
              N.addElementRange(E, B.start, B.end);
              continue;
            }
            for (let { start: T, end: w } = B;T < w; T++)
              if (H.element = E[T], Y(W))
                N.addElement(H.element);
          }
        }
      } else {
        let { chainElementSegments: z } = F.kind === j0.Kind.Spheres ? R.coarseHierarchy.spheres : R.coarseHierarchy.gaussians, D = b2.transientSegments(z, E);
        while (D.hasNext) {
          let A = D.move();
          if (H.element = E[A.start], !J(W) || !$(W))
            continue;
          if (q) {
            N.addElementRange(E, A.start, A.end);
            continue;
          }
          for (let { start: B, end: T } = A;B < T; B++)
            if (H.element = E[B], X(W))
              N.addElement(H.element);
        }
      }
      N.commitUnit(), W.throwIfTimedOut();
    }
    return W.popCurrentElement(), f1.Singletons(K, N.getStructure());
  };
}
function U21({ unitTest: Z, entityTest: J, chainTest: $, residueTest: X, atomTest: Y, groupBy: Q }) {
  return function W(K) {
    let { inputStructure: G } = K, { units: H } = G, N = K.pushCurrentElement(), q = new uo(G);
    N.structure = G;
    for (let U of H) {
      if (N.unit = U, !Z(K))
        continue;
      let { elements: F, model: E } = U;
      if (U.kind === j0.Kind.Atomic) {
        let R = b2.transientSegments(E.atomicHierarchy.chainAtomSegments, F), z = b2.transientSegments(E.atomicHierarchy.residueAtomSegments, F);
        while (R.hasNext) {
          let D = R.move();
          if (N.element = F[D.start], !J(K) || !$(K))
            continue;
          z.setSegment(D);
          while (z.hasNext) {
            let A = z.move();
            if (N.element = F[A.start], !X(K))
              continue;
            for (let { start: B, end: T } = A;B < T; B++)
              if (N.element = F[B], Y(K))
                q.add(Q(K), U.id, N.element);
          }
        }
      } else {
        let { chainElementSegments: R } = U.kind === j0.Kind.Spheres ? E.coarseHierarchy.spheres : E.coarseHierarchy.gaussians, z = b2.transientSegments(R, F);
        while (z.hasNext) {
          let D = z.move();
          if (N.element = F[D.start], !J(K) || !$(K))
            continue;
          for (let { start: A, end: B } = D;A < B; A++)
            if (N.element = F[A], X(K))
              q.add(Q(K), U.id, N.element);
        }
      }
      K.throwIfTimedOut();
    }
    return K.popCurrentElement(), q.getSelection();
  };
}
function co(Z, J, $) {
  let X = new Int32Array(J.length);
  for (let Y = 0, Q = J.length;Y < Q; Y++)
    X[Y] = Z.elements[J[Y]];
  return s0.create([Z.getChild(X1.ofSortedArray(X))], { parent: $ });
}
function L21(Z, J) {
  return function $(X) {
    let { units: Y } = X.inputStructure, Q = f1.LinearBuilder(X.inputStructure);
    if (!Z || Z.length === 0)
      for (let W of Y) {
        if (!j0.isAtomic(W))
          continue;
        if (J)
          for (let K of W.rings.aromaticRings)
            Q.add(co(W, W.rings.all[K], X.inputStructure));
        else
          for (let K of W.rings.all)
            Q.add(co(W, K, X.inputStructure));
      }
    else {
      let W = o6.create();
      for (let K = 0;K < Z.length; K++)
        o6.add(W, Z[K], Z[K]);
      for (let K of Y) {
        if (!j0.isAtomic(K))
          continue;
        let G = K.rings;
        for (let H of W.array) {
          if (!G.byFingerprint.has(H))
            continue;
          for (let N of G.byFingerprint.get(H)) {
            if (J && !G.aromaticRings.includes(N))
              continue;
            Q.add(co(K, G.all[N], X.inputStructure));
          }
        }
      }
    }
    return Q.getSelection();
  };
}
function R21(Z, J, $ = !1) {
  return function X(Y) {
    let Q = Z(Y);
    if (f1.structureCount(Q) === 0)
      return Q;
    let W = $ ? ZA(Y.inputStructure, f1.unionStructure(Q)) : f1.unionStructure(Q);
    if (W.elementCount === 0)
      return f1.Empty(Y.inputStructure);
    Y.throwIfTimedOut(), Y.pushInputStructure(W);
    let K = J(Y);
    return Y.popInputStructure(), f1.withInputStructure(K, Y.inputStructure);
  };
}
function E21(Z) {
  return function J($) {
    let X = $.inputStructure, Y = X.interUnitBonds, Q = f1.UniqueBuilder($.inputStructure);
    $.pushCurrentBond();
    let W = $.atomicBond;
    W.setTestFn(Z), W.setStructure(X);
    for (let K of X.units) {
      if (K.kind !== j0.Kind.Atomic)
        continue;
      let { offset: G, b: H, edgeProps: { flags: N, order: q, key: U } } = K.bonds;
      W.a.unit = K, W.b.unit = K;
      for (let F = 0, E = K.elements.length;F < E; F++) {
        W.aIndex = F, W.a.element = K.elements[F];
        for (let R = G[F], z = G[F + 1];R < z; R++)
          if (W.bIndex = H[R], W.b.element = K.elements[H[R]], W.type = N[R], W.order = q[R], W.key = U[R], W.test($, !1)) {
            let D = X.subsetBuilder(!1);
            D.beginUnit(K.id), D.addElement(W.a.element), D.addElement(W.b.element), D.commitUnit(), Q.add(D.getStructure());
          }
      }
    }
    for (let K of Y.edges)
      if (W.a.unit = X.unitMap.get(K.unitA), W.a.element = W.a.unit.elements[K.indexA], W.aIndex = K.indexA, W.b.unit = X.unitMap.get(K.unitB), W.b.element = W.b.unit.elements[K.indexB], W.bIndex = K.indexB, W.order = K.props.order, W.type = K.props.flag, W.key = K.props.key, W.test($, !1)) {
        let G = X.subsetBuilder(!1);
        G.addToUnit(W.a.unit.id, W.a.element), G.addToUnit(W.b.unit.id, W.b.element), Q.add(G.getStructure());
      }
    return $.popCurrentBond(), Q.getSelection();
  };
}

// node_modules/molstar/lib/mol-model/structure/query/queries/modifiers.js
var to = {};
y9(to, {
  wholeResidues: () => Z81,
  union: () => K81,
  surroundingLigands: () => q81,
  querySelection: () => Y81,
  intersectBy: () => Q81,
  includeSurroundings: () => X81,
  includeConnected: () => H81,
  expandProperty: () => G81,
  exceptBy: () => W81
});

// node_modules/molstar/lib/mol-model/structure/structure/util/unique-subset-builder.js
class JA {
  addToUnit(Z, J) {
    let $ = this.unitMap.get(Z);
    if ($) {
      if (o6.add($, J, J))
        this.elementCount++;
    } else {
      let X = o6.create();
      o6.add(X, J, J), this.unitMap.set(Z, X), this.ids[this.ids.length] = Z, this.elementCount++;
    }
  }
  has(Z, J) {
    let $ = this.unitMap.get(Z);
    if (!$)
      return !1;
    return o6.has($, J);
  }
  beginUnit(Z) {
    if (this.parentId = Z, this.unitMap.has(Z))
      this.currentUnit = this.unitMap.get(Z);
    else
      this.currentUnit = this.currentUnit.array.length > 0 ? o6.create() : this.currentUnit;
  }
  addElement(Z) {
    if (o6.add(this.currentUnit, Z, Z))
      this.elementCount++;
  }
  commitUnit() {
    if (this.currentUnit.array.length === 0 || this.unitMap.has(this.parentId))
      return;
    this.ids[this.ids.length] = this.parentId, this.unitMap.set(this.parentId, this.currentUnit), this.parentId = -1;
  }
  getStructure() {
    if (this.isEmpty)
      return s0.Empty;
    let Z = [];
    t$(this.ids);
    let J = VW.UnitEquivalenceBuilder();
    for (let $ = 0, X = this.ids.length;$ < X; $++) {
      let Y = this.ids[$], Q = this.parent.unitMap.get(Y), W = this.unitMap.get(Y).array, K = W.length;
      if (W.length === Q.elements.length) {
        Z[Z.length] = Q, J.add(Q.id, Q);
        continue;
      }
      if (K > 1)
        t$(W);
      let G = Q.getChild(X1.ofSortedArray(W)), H = J.add(G.id, G);
      if (G !== H)
        G = H.applyOperator(G.id, G.conformation.operator, !0);
      Z[Z.length] = G;
    }
    return s0.create(Z, { parent: this.parent });
  }
  get isEmpty() {
    return this.elementCount === 0;
  }
  constructor(Z) {
    this.parent = Z, this.ids = [], this.unitMap = NY.Mutable(), this.parentId = -1, this.currentUnit = o6.create(), this.elementCount = 0;
  }
}

// node_modules/molstar/lib/mol-model/structure/model/properties/secondary-structure.js
function $A(Z, J, $, X) {
  return { type: Z, key: J, elements: $, getIndex: X };
}

// node_modules/molstar/lib/mol-model-props/computed/secondary-structure/dssp/common.js
var i1;
(function(Z) {
  Z.is = r7.has, Z.create = r7.create;
  let J;
  (function($) {
    $[$._ = 0] = "_", $[$.H = 1] = "H", $[$.B = 2] = "B", $[$.E = 4] = "E", $[$.G = 8] = "G", $[$.I = 16] = "I", $[$.S = 32] = "S", $[$.T = 64] = "T", $[$.T3 = 128] = "T3", $[$.T4 = 256] = "T4", $[$.T5 = 512] = "T5", $[$.T3S = 1024] = "T3S", $[$.T4S = 2048] = "T4S", $[$.T5S = 4096] = "T5S";
  })(J = Z.Flag || (Z.Flag = {}));
})(i1 || (i1 = {}));
var TK;
(function(Z) {
  Z[Z.PARALLEL = 0] = "PARALLEL", Z[Z.ANTI_PARALLEL = 1] = "ANTI_PARALLEL";
})(TK || (TK = {}));

class XA {
  constructor(Z, J, $) {
    this.partner1 = Math.min(Z, J), this.partner2 = Math.max(Z, J), this.type = $;
  }
}

// node_modules/molstar/lib/mol-model-props/computed/secondary-structure/dssp/bends.js
function Eq0(Z) {
  let { unit: J, flags: $, proteinInfo: X } = Z, Y = J.conformation, { traceElementIndex: Q } = J.model.atomicHierarchy.derived.residue, { residueIndices: W, nIndices: K } = X, G = W.length, H = (D, A) => D === -1 ? M.setNaN(A) : Y.position(D, A), N = M(), q = M(), U = M(), F = M(), E = M(), R = M(), z = M();
  Z:
    for (let D = 2;D < G - 2; D++) {
      for (let S = 0;S < 4; S++) {
        let f = D + S - 2;
        if (H(Q[f], F), H(K[f + 1], E), M.squaredDistance(F, E) > 6.25)
          continue Z;
      }
      let A = W[D - 2], B = W[D], T = W[D + 2], w = Q[A], V = Q[B], P = Q[T];
      H(w, N), H(V, q), H(P, U), M.sub(R, N, q), M.sub(z, q, U);
      let I = k$(M.angle(R, z));
      if (I && I > 70)
        $[D] |= i1.Flag.S;
    }
}

// node_modules/molstar/lib/mol-model-props/computed/secondary-structure/dssp/backbone-hbonds.js
var O21 = 9, Jh = -27.888, z21 = -0.5, Oq0 = -9.9;
function D21(Z, J, $, X) {
  let Y = M.distance(Z, X), Q = M.distance(J, X), W = M.distance(J, $), K = M.distance(Z, $), G = Jh / Y - Jh / Q, H = Jh / W - Jh / K, N = G + H;
  if (N < Oq0)
    return Oq0;
  return N;
}
function zq0(Z, J, $) {
  let { residueIndices: X, cIndices: Y, hIndices: Q, nIndices: W, oIndices: K } = J, { index: G } = Z.model.atomicHierarchy, H = Z.conformation, { traceElementIndex: N } = Z.model.atomicHierarchy.derived.residue, q = X.length, U = [], F = [], E = [], R = M(), z = M(), D = M(), A = M(), B = M(), T = M(), w = M();
  for (let V = 0, P = X.length;V < P; ++V) {
    let I = V, S = X[V], f = K[I], v = Y[I], h = N[S];
    if (f === -1 || v === -1)
      continue;
    if (G.findAtomOnResidue(S, "OXT") !== -1)
      continue;
    H.invariantPosition(f, R), H.invariantPosition(v, z), H.invariantPosition(h, D);
    let { indices: x, count: b } = $.find(D[0], D[1], D[2], O21);
    for (let g = 0;g < b; ++g) {
      let m = x[g];
      if (m === I || m - 1 === I || m + 1 === I)
        continue;
      let i = W[m];
      if (i === -1)
        continue;
      H.invariantPosition(i, A);
      let r = Q[m];
      if (r === -1) {
        if (m === 0)
          continue;
        let c = m - 1, n = K[c], l = Y[c];
        if (n === -1 || l === -1)
          continue;
        H.invariantPosition(n, w), H.invariantPosition(l, T), M.sub(B, T, w);
        let u = M.distance(w, T);
        M.scaleAndAdd(B, A, B, 1 / u);
      } else
        H.invariantPosition(r, B);
      let Y0 = D21(R, z, A, B);
      if (Y0 > z21)
        continue;
      U[U.length] = I, F[F.length] = m, E[E.length] = Y0;
    }
  }
  return M21(q, U, F, E);
}
function M21(Z, J, $, X) {
  let Y = new lJ.DirectedEdgeBuilder(Z, J, $), Q = new Float32Array(Y.slotCount);
  for (let W = 0, K = Y.edgeCount;W < K; W++)
    Y.addNextEdge(), Y.assignProperty(Q, X[W]);
  return Y.createGraph({ energies: X });
}

// node_modules/molstar/lib/mol-model-props/computed/secondary-structure/dssp/turns.js
function Dq0(Z) {
  let { proteinInfo: J, hbonds: $, flags: X } = Z, Y = [i1.Flag.T3S, i1.Flag.T4S, i1.Flag.T5S, i1.Flag.T3, i1.Flag.T4, i1.Flag.T5];
  for (let Q = 0;Q < 3; Q++)
    for (let W = 0, K = J.residueIndices.length - 1;W < K; ++W)
      if ($.getDirectedEdgeIndex(W, W + Q + 3) !== -1)
        if (X[W] |= Y[Q + 3] | Y[Q], Z.params.oldDefinition)
          for (let G = 1;G < Q + 3; ++G)
            X[W + G] |= Y[Q + 3] | i1.Flag.T;
        else
          for (let G = 0;G <= Q + 3; ++G)
            X[W + G] |= Y[Q + 3] | i1.Flag.T;
}

// node_modules/molstar/lib/mol-model-props/computed/secondary-structure/dssp/helices.js
function Mq0(Z) {
  let { proteinInfo: J, flags: $ } = Z, X = J.residueIndices.length, Y = [i1.Flag.T3S, i1.Flag.T4S, i1.Flag.T5S, i1.Flag.T3, i1.Flag.T4, i1.Flag.T5], Q = [0, 0, 0, i1.Flag.G, i1.Flag.H, i1.Flag.I], W = Z.params.oldOrdering ? [4, 3, 5] : [3, 4, 5];
  for (let K = 0;K < W.length; K++) {
    let G = W[K];
    for (let H = 1, N = X - G;H < N; H++) {
      let q = i1.create($[H]), U = i1.create($[H - 1]), F = i1.create($[H + 1]);
      if (Z.params.oldOrdering) {
        if (G === 3 && (i1.is(q, i1.Flag.H) || i1.is(F, i1.Flag.H)) || G === 5 && (i1.is(q, i1.Flag.H) || i1.is(q, i1.Flag.G) || (i1.is(F, i1.Flag.H) || i1.is(F, i1.Flag.G))))
          continue;
      } else if (G === 4 && (i1.is(q, i1.Flag.G) || i1.is(F, i1.Flag.G)) || G === 5 && (i1.is(q, i1.Flag.H) || i1.is(q, i1.Flag.G) || (i1.is(F, i1.Flag.H) || i1.is(F, i1.Flag.G))))
        continue;
      if (i1.is(q, Y[G]) && i1.is(q, Y[G - 3]) && i1.is(U, Y[G]) && i1.is(U, Y[G - 3]))
        if (Z.params.oldDefinition)
          for (let E = 0;E < G; E++)
            $[H + E] |= Q[G];
        else
          for (let E = -1;E <= G; E++)
            $[H + E] |= Q[G];
    }
  }
}

// node_modules/molstar/lib/mol-model-props/computed/secondary-structure/dssp/ladders.js
function A21(Z, J) {
  if (J.type !== Z.type)
    return !1;
  if (J.partner1 !== Z.firstEnd + 1)
    return !1;
  if (J.type === TK.PARALLEL) {
    if (J.partner2 === Z.secondEnd + 1)
      return !0;
  } else if (J.partner2 === Z.secondStart - 1)
    return !0;
  return !1;
}
function B21(Z, J) {
  if (!(Z.type === J.type && J.firstStart - Z.firstEnd < 6 && Z.firstStart < J.firstStart && J.nextLadder === 0))
    return !1;
  if (Z.type === TK.PARALLEL)
    return Aq0(Z, J);
  else
    return Aq0(J, Z);
}
function Aq0(Z, J) {
  return J.secondStart - Z.secondEnd > 0 && (J.secondStart - Z.secondEnd < 6 && J.firstStart - Z.firstEnd < 3 || J.secondStart - Z.secondEnd < 3);
}
function Bq0(Z) {
  let { bridges: J, ladders: $ } = Z;
  for (let X = 0;X < J.length; X++) {
    let Y = J[X], Q = !1;
    for (let W = 0;W < $.length; W++) {
      let K = $[W];
      if (A21(K, Y))
        if (Q = !0, K.firstEnd++, Y.type === TK.PARALLEL)
          K.secondEnd++;
        else
          K.secondStart--;
    }
    if (!Q)
      $[$.length] = {
        previousLadder: 0,
        nextLadder: 0,
        firstStart: Y.partner1,
        firstEnd: Y.partner1,
        secondStart: Y.partner2,
        secondEnd: Y.partner2,
        type: Y.type
      };
  }
  for (let X = 0;X < $.length; X++) {
    let Y = $[X];
    for (let Q = X;Q < $.length; Q++) {
      let W = $[Q];
      if (B21(Y, W))
        Y.nextLadder = Q, W.previousLadder = X;
    }
  }
}

// node_modules/molstar/lib/mol-model-props/computed/secondary-structure/dssp/bridges.js
function wq0(Z) {
  let { proteinInfo: J, hbonds: $, flags: X, bridges: Y } = Z, { offset: Q, b: W } = $, K, G;
  for (let H = 0, N = J.residueIndices.length;H < N; ++H)
    for (let q = Q[H], U = Q[H + 1];q < U; q++) {
      let F = W[q];
      if (H > F)
        continue;
      if (K = H + 1, G = F, K !== G && $.getDirectedEdgeIndex(G, K + 1) !== -1)
        X[K] |= i1.Flag.B, X[G] |= i1.Flag.B, Y[Y.length] = new XA(K, G, TK.PARALLEL);
      if (K = H, G = F - 1, K !== G && $.getDirectedEdgeIndex(G - 1, K) !== -1)
        X[K] |= i1.Flag.B, X[G] |= i1.Flag.B, Y[Y.length] = new XA(G, K, TK.PARALLEL);
      if (K = H, G = F, K !== G && $.getDirectedEdgeIndex(G, K) !== -1)
        X[K] |= i1.Flag.B, X[G] |= i1.Flag.B, Y[Y.length] = new XA(G, K, TK.ANTI_PARALLEL);
      if (K = H + 1, G = F - 1, K !== G && $.getDirectedEdgeIndex(G - 1, K + 1) !== -1)
        X[K] |= i1.Flag.B, X[G] |= i1.Flag.B, Y[Y.length] = new XA(G, K, TK.ANTI_PARALLEL);
    }
  Y.sort((H, N) => H.partner1 > N.partner1 ? 1 : H.partner1 < N.partner1 ? -1 : 0);
}

// node_modules/molstar/lib/mol-model-props/computed/secondary-structure/dssp/sheets.js
function jq0(Z) {
  return i1.is(Z, i1.Flag.G) || i1.is(Z, i1.Flag.H) || i1.is(Z, i1.Flag.I);
}
function Tq0(Z) {
  let { ladders: J, flags: $ } = Z;
  for (let X = 0;X < J.length; X++) {
    let Y = J[X];
    for (let W = Y.firstStart;W <= Y.firstEnd; W++) {
      let K = Y.firstStart - W, G = Y.secondStart - K;
      if (Y.firstStart !== Y.firstEnd)
        $[W] |= i1.Flag.E, $[G] |= i1.Flag.E;
      else {
        if (!jq0($[W]) && i1.is($[W], i1.Flag.E))
          $[W] |= i1.Flag.B;
        if (!jq0($[G]) && i1.is($[G], i1.Flag.E))
          $[G] |= i1.Flag.B;
      }
    }
    if (Y.nextLadder === 0)
      continue;
    let Q = J[Y.nextLadder];
    for (let W = Y.firstStart;W <= Q.firstEnd; W++)
      $[W] |= i1.Flag.E;
    if (Y.type === TK.PARALLEL)
      for (let W = Y.secondStart;W <= Q.secondEnd; W++)
        $[W] |= i1.Flag.E;
    else
      for (let W = Q.secondEnd;W <= Y.secondStart; W++)
        $[W] |= i1.Flag.E;
  }
}

// node_modules/molstar/lib/mol-model-props/computed/secondary-structure/dssp/dihedral-angles.js
function _q0(Z, J) {
  let { cIndices: $, nIndices: X, residueIndices: Y } = J, Q = Z.conformation, { index: W } = Z.model.atomicHierarchy, { traceElementIndex: K } = Z.model.atomicHierarchy.derived.residue, G = Y.length, H = (w, V) => w === -1 ? M.setNaN(V) : Q.position(w, V), N = M(), q = M(), U = M(), F = M(), E = M(), R = M(), z = M(), D = M(), A = M();
  if (G === 0)
    return { phi: new Float32Array(0), psi: new Float32Array(0) };
  let B = new Float32Array(G - 1), T = new Float32Array(G - 1);
  H(-1, N), H(-1, q), H(-1, U), H($[0], F), H(K[Y[0]], E), H(X[0], R), H($[1], z), H(K[Y[1]], D), H(X[1], A);
  for (let w = 0;w < G - 1; ++w) {
    if (W.findAtomOnResidue(Y[w], "OXT") !== -1)
      continue;
    B[w] = k$(M.dihedralAngle(N, R, E, F)), T[w] = k$(M.dihedralAngle(R, E, F, A)), N = F, q = E, U = R, F = z, E = D, R = A, H($[w + 1], z), H(K[Y[w + 1]], D), H(X[w + 1], A);
  }
  return { phi: B, psi: T };
}

// node_modules/molstar/lib/mol-model-props/computed/secondary-structure/dssp/trace-lookup.js
function Vq0(Z, J) {
  let { x: $, y: X, z: Y } = Z.model.atomicConformation, { traceElementIndex: Q } = Z.model.atomicHierarchy.derived.residue, W = new Uint32Array(J.length);
  for (let G = 0, H = J.length;G < H; ++G)
    W[G] = Q[J[G]];
  let K = { x: $, y: X, z: Y, indices: X1.ofSortedArray(W) };
  return TW(K, GH(K));
}

// node_modules/molstar/lib/mol-model-props/computed/secondary-structure/dssp/protein-info.js
function Iq0(Z) {
  let { index: J } = Z.model.atomicHierarchy, { proteinElements: $, residueIndex: X } = Z, Y = $.length, Q = new Uint32Array(Y), W = new Int32Array(Y), K = new Int32Array(Y), G = new Int32Array(Y), H = new Int32Array(Y);
  for (let N = 0;N < Y; ++N) {
    let q = X[$[N]];
    Q[N] = q, W[N] = J.findAtomOnResidue(q, "C"), K[N] = J.findAtomOnResidue(q, "H"), G[N] = J.findAtomOnResidue(q, "O"), H[N] = J.findAtomOnResidue(q, "N");
  }
  return {
    residueIndices: X1.ofSortedArray(Q),
    cIndices: W,
    hIndices: K,
    oIndices: G,
    nIndices: H
  };
}

// node_modules/molstar/lib/mol-model-props/computed/secondary-structure/dssp.js
var io = {
  oldDefinition: j.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: j.Boolean(!0, { description: "Alpha-helices are preferred over 3-10 helices" })
}, Pq0 = j.getDefaultValues(io);
async function oo(Z, J) {
  let $ = Iq0(Z), { residueIndices: X } = $, Y = Vq0(Z, X), Q = zq0(Z, $, Y), W = X.length, K = new Uint32Array(W), G = _q0(Z, $), H = [], N = [], q = J.oldDefinition ? T21 : V21, U = J.oldOrdering ? _21 : I21, F = {
    params: J,
    getResidueFlag: q,
    getFlagName: U,
    unit: Z,
    proteinInfo: $,
    flags: K,
    hbonds: Q,
    torsionAngles: G,
    ladders: H,
    bridges: N
  };
  Dq0(F), Mq0(F), Eq0(F), wq0(F), Bq0(F), Tq0(F);
  let E = P21(K, q), R = new Uint32Array(W), z = [], D = [], A = (B) => X1.indexOf(X, B);
  for (let B = 0, T = X.length;B < T; ++B) {
    let w = E[B];
    R[B] = w;
    let V = q(K[B]);
    if (D.length === 0 || V !== D[D.length - 1].flags)
      D[D.length] = w21(j21(w), K[B], q);
    z[B] = D.length - 1;
  }
  return $A(R, z, D, A);
}
function w21(Z, J, $) {
  if (Z === "helix")
    return {
      kind: "helix",
      flags: $(J)
    };
  else if (Z === "sheet")
    return {
      kind: "sheet",
      flags: $(J)
    };
  else if (Z === "turn" || Z === "bend")
    return {
      kind: "turn",
      flags: $(J)
    };
  else
    return {
      kind: "none"
    };
}
function j21(Z) {
  if (Z === m2.SecondaryStructureDssp.H || Z === m2.SecondaryStructureDssp.G || Z === m2.SecondaryStructureDssp.I)
    return "helix";
  else if (Z === m2.SecondaryStructureDssp.B || Z === m2.SecondaryStructureDssp.E)
    return "sheet";
  else if (Z === m2.SecondaryStructureDssp.T)
    return "turn";
  else if (Z === m2.SecondaryStructureDssp.S)
    return "bend";
  else
    return "none";
}
function T21(Z) {
  if (i1.is(Z, i1.Flag.H))
    return m2.SecondaryStructureDssp.H;
  if (i1.is(Z, i1.Flag.E))
    return m2.SecondaryStructureDssp.E;
  if (i1.is(Z, i1.Flag.B))
    return m2.SecondaryStructureDssp.B;
  if (i1.is(Z, i1.Flag.G))
    return m2.SecondaryStructureDssp.G;
  if (i1.is(Z, i1.Flag.I))
    return m2.SecondaryStructureDssp.I;
  if (i1.is(Z, i1.Flag.T))
    return m2.SecondaryStructureDssp.T;
  if (i1.is(Z, i1.Flag.S))
    return m2.SecondaryStructureDssp.S;
  return m2.Flag.None;
}
function _21(Z) {
  if (i1.is(Z, i1.Flag.H))
    return "H";
  if (i1.is(Z, i1.Flag.E))
    return "E";
  if (i1.is(Z, i1.Flag.B))
    return "B";
  if (i1.is(Z, i1.Flag.G))
    return "G";
  if (i1.is(Z, i1.Flag.I))
    return "I";
  if (i1.is(Z, i1.Flag.T))
    return "T";
  if (i1.is(Z, i1.Flag.S))
    return "S";
  return "-";
}
function V21(Z) {
  if (i1.is(Z, i1.Flag.I))
    return m2.SecondaryStructureDssp.I;
  if (i1.is(Z, i1.Flag.H))
    return m2.SecondaryStructureDssp.H;
  if (i1.is(Z, i1.Flag.E))
    return m2.SecondaryStructureDssp.E;
  if (i1.is(Z, i1.Flag.B))
    return m2.SecondaryStructureDssp.B;
  if (i1.is(Z, i1.Flag.G))
    return m2.SecondaryStructureDssp.G;
  if (i1.is(Z, i1.Flag.T))
    return m2.SecondaryStructureDssp.T;
  if (i1.is(Z, i1.Flag.S))
    return m2.SecondaryStructureDssp.S;
  return m2.Flag.None;
}
function I21(Z) {
  if (i1.is(Z, i1.Flag.I))
    return "I";
  if (i1.is(Z, i1.Flag.H))
    return "H";
  if (i1.is(Z, i1.Flag.E))
    return "E";
  if (i1.is(Z, i1.Flag.B))
    return "B";
  if (i1.is(Z, i1.Flag.G))
    return "G";
  if (i1.is(Z, i1.Flag.T))
    return "T";
  if (i1.is(Z, i1.Flag.S))
    return "S";
  return "-";
}
function P21(Z, J) {
  let $ = new Uint32Array(Z.length);
  for (let X = 0, Y = Z.length;X < Y; ++X) {
    let Q = i1.create(Z[X]);
    $[X] = J(Q);
  }
  return $;
}

// node_modules/molstar/lib/mol-model-props/common/custom-structure-property.js
var IW;
(function(Z) {
  function J(X) {
    let Y = X.descriptor.name, Q = X.type === "root" ? "inheritedPropertyData" : "currentPropertyData", W = (G) => {
      if (!(Y in G[Q]))
        G[Q][Y] = {
          props: { ...j.getDefaultValues(X.getParams(G)) },
          data: ON.create(void 0)
        };
      return G[Q][Y];
    }, K = (G, H, N) => {
      let q = W(G);
      G[Q][Y] = {
        props: H,
        data: ON.withValue(q.data, N)
      };
    };
    return {
      label: X.label,
      descriptor: X.descriptor,
      isHidden: X.isHidden,
      getParams: (G) => {
        let H = j.clone(X.getParams(G));
        return j.setDefaultValues(H, W(G).props), H;
      },
      defaultParams: X.defaultParams,
      isApplicable: X.isApplicable,
      attach: async (G, H, N = {}, q) => {
        if (q)
          H.customPropertyDescriptors.reference(X.descriptor, !0);
        if (X.type === "root")
          H = H.root;
        let U = W(H.root).props, F = W(H), E = j.merge(X.defaultParams, U, N);
        if (F.data.value && j.areEqual(X.defaultParams, F.props, E))
          return;
        let { value: R, assets: z } = await X.obtain(G, H, E);
        H.customPropertyDescriptors.add(X.descriptor), H.customPropertyDescriptors.assets(X.descriptor, z), K(H, E, R);
      },
      ref: (G, H) => G.customPropertyDescriptors.reference(X.descriptor, H),
      get: (G) => W(G).data,
      set: (G, H = {}, N) => {
        if (X.type === "root")
          G = G.root;
        let q = W(G), U = j.merge(X.defaultParams, q.props, H);
        if (!j.areEqual(X.defaultParams, q.props, U))
          K(G, U, N), G.customPropertyDescriptors.assets(X.descriptor);
      },
      props: (G) => W(G).props
    };
  }
  Z.createProvider = J;
  function $(X, Y, Q) {
    let W = { value: j.Value(Q, { isHidden: !0 }) };
    return J({
      label: v$(X),
      descriptor: p7({ name: X }),
      isHidden: !0,
      type: Y,
      defaultParams: W,
      getParams: () => ({ value: j.Value(Q, { isHidden: !0 }) }),
      isApplicable: () => !0,
      obtain: async (K, G, H) => {
        return { ...j.getDefaultValues(W), ...H };
      }
    });
  }
  Z.createSimple = $;
})(IW || (IW = {}));

// node_modules/molstar/lib/mol-model-formats/structure/property/secondary-structure.js
var HH;
(function(Z) {
  Z.Descriptor = {
    name: "model_secondary_structure"
  }, Z.Provider = e$.create(Z.Descriptor);
  function J($, X, Y) {
    let Q = /* @__PURE__ */ new Map, W = [{ kind: "none" }], K = C21($, X);
    k21($, K, Q, W), v21(X, K, Q, $._rowCount, W);
    let G = Y.residues._rowCount, H = (q) => q, N = {
      type: new Int32Array(G),
      key: new Int32Array(G),
      elements: W
    };
    if (Q.size > 0)
      f21(Y, K, Q, N);
    return $A(N.type, N.key, N.elements, H);
  }
  Z.fromStruct = J;
})(HH || (HH = {}));
function C21(Z, J) {
  if (Z._rowCount > 0) {
    if (Z.beg_label_seq_id.valueKind(0) !== s.ValueKinds.Present || Z.end_label_seq_id.valueKind(0) !== s.ValueKinds.Present)
      return "auth";
  } else if (J) {
    if (J.beg_label_seq_id.valueKind(0) !== s.ValueKinds.Present || J.end_label_seq_id.valueKind(0) !== s.ValueKinds.Present)
      return "auth";
  }
  return "label";
}
function k21(Z, J, $, X) {
  if (!Z._rowCount)
    return;
  let { beg_label_asym_id: Y, beg_label_seq_id: Q, beg_auth_seq_id: W, pdbx_beg_PDB_ins_code: K } = Z, { end_label_seq_id: G, end_auth_seq_id: H, pdbx_end_PDB_ins_code: N } = Z, { pdbx_PDB_helix_class: q, conf_type_id: U, details: F } = Z, E = J === "label" ? Q : W, R = J === "label" ? G : H;
  for (let z = 0, D = Z._rowCount;z < D; z++) {
    let A = m2.create(q.valueKind(z) === s.ValueKinds.Present ? m2.SecondaryStructurePdb[q.value(z)] : U.valueKind(z) === s.ValueKinds.Present ? m2.SecondaryStructureMmcif[U.value(z)] : m2.Flag.NA), B = {
      kind: "helix",
      flags: A,
      type_id: U.valueKind(z) === s.ValueKinds.Present ? U.value(z) : "helx_p",
      helix_class: q.value(z),
      details: F.valueKind(z) === s.ValueKinds.Present ? F.value(z) : void 0
    }, T = {
      startSeqId: E.value(z),
      startInsCode: K.value(z),
      endSeqId: R.value(z),
      endInsCode: N.value(z),
      type: A,
      key: X.length
    };
    X[X.length] = B;
    let w = Y.value(z);
    if ($.has(w)) {
      let V = $.get(w);
      if (V.has(T.startSeqId))
        V.get(T.startSeqId).push(T);
      else
        V.set(T.startSeqId, [T]);
    } else
      $.set(w, /* @__PURE__ */ new Map([[T.startSeqId, [T]]]));
  }
}
function v21(Z, J, $, X, Y) {
  if (!Z._rowCount)
    return;
  let { beg_label_asym_id: Q, beg_label_seq_id: W, beg_auth_seq_id: K, pdbx_beg_PDB_ins_code: G } = Z, { end_label_seq_id: H, end_auth_seq_id: N, pdbx_end_PDB_ins_code: q } = Z, { sheet_id: U } = Z, F = J === "label" ? W : K, E = J === "label" ? H : N, R = /* @__PURE__ */ new Map, z = X + 1;
  for (let D = 0, A = Z._rowCount;D < A; D++) {
    let B = U.value(D), T;
    if (R.has(B))
      T = R.get(B);
    else
      T = z++, R.set(B, T);
    let w = m2.create(m2.Flag.Beta | m2.Flag.BetaSheet), V = {
      kind: "sheet",
      flags: w,
      sheet_id: B,
      symmetry: void 0
    }, P = {
      startSeqId: F.value(D),
      startInsCode: G.value(D),
      endSeqId: E.value(D),
      endInsCode: q.value(D),
      type: w,
      key: Y.length
    };
    Y[Y.length] = V;
    let I = Q.value(D);
    if ($.has(I)) {
      let S = $.get(I);
      if (S.has(P.startSeqId))
        S.get(P.startSeqId).push(P);
      else
        S.set(P.startSeqId, [P]);
    } else
      $.set(I, /* @__PURE__ */ new Map([[P.startSeqId, [P]]]));
  }
  return;
}
function S21(Z, J, $, X, Y, Q) {
  let { auth_seq_id: W, label_seq_id: K, pdbx_PDB_ins_code: G } = Z.residues, { endSeqId: H, endInsCode: N, key: q, type: U } = $, F = J === "label" ? K : W, E = X;
  while (E < Y) {
    let R = F.value(E);
    if (Q.type[E] = U, Q.key[E] = q, R > H || R === H && G.value(E) === N)
      break;
    E++;
  }
}
function f21(Z, J, $, X) {
  let { count: Y } = Z.chainAtomSegments, { label_asym_id: Q } = Z.chains, { auth_seq_id: W, label_seq_id: K, pdbx_PDB_ins_code: G } = Z.residues, H = J === "label" ? K : W;
  for (let N = 0;N < Y; N++) {
    let q = zR.chainStartResidueIndex(Z, N), U = zR.chainEndResidueIndexExcl(Z, N), F = Q.value(N);
    if ($.has(F)) {
      let E = $.get(F);
      for (let R = q;R < U; R++) {
        let z = H.value(R);
        if (E.has(z)) {
          let D = E.get(z);
          for (let A of D) {
            let B = G.value(R);
            if (A.startInsCode !== B)
              continue;
            S21(Z, J, A, R, U, X);
          }
        }
      }
    }
  }
}

// node_modules/molstar/lib/mol-model-props/computed/secondary-structure/zhang-skolnik.js
var h21 = [5.45, 5.18, 6.37], b21 = 2.1, x21 = [6.1, 10.4, 13], y21 = 1.42, Cq0 = M(), kq0 = M();
function vq0(Z, J, $, X, Y) {
  let Q = Z.conformation, { traceElementIndex: W } = Z.model.atomicHierarchy.derived.residue;
  for (let K = Math.max(0, $ - 2);K <= $; ++K)
    for (let G = 2;G < 5; ++G) {
      if (K + G >= J.length)
        return !1;
      let H = J[K], N = J[K + G], q = W[H], U = W[N];
      if (q === -1 || U === -1)
        return !1;
      Q.invariantPosition(q, Cq0), Q.invariantPosition(U, kq0);
      let F = M.distance(Cq0, kq0);
      if (Math.abs(F - X[G - 2]) >= Y)
        return !1;
    }
  return !0;
}
async function so(Z) {
  let J = Z.proteinElements.length, $ = new Uint32Array(J), X = [], Y = [], { proteinElements: Q, residueIndex: W } = Z, K = Q.length, G = new Uint32Array(K);
  for (let q = 0;q < K; ++q) {
    let U = W[Q[q]];
    G[q] = U;
  }
  let H = X1.ofSortedArray(G), N = (q) => X1.indexOf(H, q);
  for (let q = 0, U = H.length;q < U; ++q) {
    let F = m2.Flag.None;
    if (vq0(Z, H, q, h21, b21))
      F = m2.Flag.Helix;
    else if (vq0(Z, H, q, x21, y21))
      F = m2.Flag.Beta;
    if ($[q] = F, Y.length === 0 || F !== d21(Y[Y.length - 1]))
      Y[Y.length] = g21(m21(F), F);
    X[q] = Y.length - 1;
  }
  return $A($, X, Y, N);
}
function g21(Z, J) {
  if (Z === "helix")
    return { kind: "helix", flags: J };
  else if (Z === "sheet")
    return { kind: "sheet", flags: J };
  else
    return { kind: "none" };
}
function m21(Z) {
  if (Z === m2.Flag.Helix)
    return "helix";
  else if (Z === m2.Flag.Beta)
    return "sheet";
  else
    return "none";
}
function d21(Z) {
  if (Z.kind === "helix")
    return Z.flags;
  else if (Z.kind === "sheet")
    return Z.flags;
  else
    return m2.Flag.None;
}

// node_modules/molstar/lib/mol-model-props/computed/secondary-structure.js
function fq0(Z) {
  return {
    type: j.MappedStatic("auto", {
      auto: j.EmptyGroup({ label: "Automatic" }),
      model: j.EmptyGroup({ label: "Model" }),
      dssp: j.Group(io, { label: "DSSP", isFlat: !0 }),
      "zhang-skolnick": j.EmptyGroup({ label: "Zhang-Skolnick" })
    }, { options: [["auto", "Automatic"], ["model", "Model"], ["dssp", "DSSP"], ["zhang-skolnick", "Zhang-Skolnick"]] })
  };
}
var Sq0 = fq0(), $X = IW.createProvider({
  label: "Secondary Structure",
  descriptor: p7({
    name: "molstar_computed_secondary_structure"
  }),
  type: "root",
  defaultParams: Sq0,
  getParams: fq0,
  isApplicable: (Z) => !0,
  obtain: async (Z, J, $) => {
    let X = { ...j.getDefaultValues(Sq0), ...$ };
    switch (X.type.name) {
      case "auto":
        return { value: await p21(J) };
      case "dssp":
        return { value: await u21(J, X.type.params) };
      case "model":
        return { value: await l21(J) };
      case "zhang-skolnick":
        return { value: await c21(J) };
    }
  }
});
async function p21(Z) {
  let J = /* @__PURE__ */ new Map;
  for (let $ = 0, X = Z.unitSymmetryGroups.length;$ < X; ++$) {
    let Y = Z.unitSymmetryGroups[$].units[0], Q = Y.model;
    if (O2.isFromPdbArchive(Q) && O2.isExperimental(Q) && !O2.isCoarseGrained(Q) || O2.hasSecondaryStructure(Q)) {
      let W = HH.Provider.get(Q);
      if (W)
        J.set(Y.invariantId, W);
    } else if (j0.isAtomic(Y) && !O2.isCoarseGrained(Q)) {
      let W = await oo(Y, Pq0);
      J.set(Y.invariantId, W);
    } else if (j0.isAtomic(Y)) {
      let W = await so(Y);
      J.set(Y.invariantId, W);
    }
  }
  return J;
}
async function u21(Z, J) {
  let $ = /* @__PURE__ */ new Map;
  for (let X = 0, Y = Z.unitSymmetryGroups.length;X < Y; ++X) {
    let Q = Z.unitSymmetryGroups[X].units[0];
    if (j0.isAtomic(Q) && !O2.isCoarseGrained(Q.model)) {
      let W = await oo(Q, J);
      $.set(Q.invariantId, W);
    }
  }
  return $;
}
async function c21(Z) {
  let J = /* @__PURE__ */ new Map;
  for (let $ = 0, X = Z.unitSymmetryGroups.length;$ < X; ++$) {
    let Y = Z.unitSymmetryGroups[$].units[0];
    if (j0.isAtomic(Y)) {
      let Q = await so(Y);
      J.set(Y.invariantId, Q);
    }
  }
  return J;
}
async function l21(Z) {
  let J = /* @__PURE__ */ new Map;
  for (let $ = 0, X = Z.unitSymmetryGroups.length;$ < X; ++$) {
    let Y = Z.unitSymmetryGroups[$].units[0];
    if (j0.isAtomic(Y)) {
      let Q = HH.Provider.get(Y.model);
      if (Q)
        J.set(Y.invariantId, Q);
    }
  }
  return J;
}

// node_modules/molstar/lib/mol-model/structure/structure/properties.js
function K8(Z) {
  return Z;
}
var n21 = {
  true: K8((Z) => !0),
  false: K8((Z) => !1),
  zero: K8((Z) => 0)
};
function QJ() {
  throw new Error("Property only available for atomic models.");
}
function sF(Z) {
  if (Z)
    throw new Error(`Property only available for coarse models (${Z}).`);
  throw new Error("Property only available for coarse models.");
}
var r_ = {
  key: K8((Z) => Z.element),
  x: K8((Z) => Z.unit.conformation.x(Z.element)),
  y: K8((Z) => Z.unit.conformation.y(Z.element)),
  z: K8((Z) => Z.unit.conformation.z(Z.element)),
  id: K8((Z) => !j0.isAtomic(Z.unit) ? QJ() : Z.unit.model.atomicConformation.atomId.value(Z.element)),
  occupancy: K8((Z) => !j0.isAtomic(Z.unit) ? QJ() : Z.unit.model.atomicConformation.occupancy.value(Z.element)),
  B_iso_or_equiv: K8((Z) => !j0.isAtomic(Z.unit) ? QJ() : Z.unit.model.atomicConformation.B_iso_or_equiv.value(Z.element)),
  sourceIndex: K8((Z) => j0.isAtomic(Z.unit) ? Z.unit.model.atomicHierarchy.atomSourceIndex.value(Z.element) : Z.element),
  type_symbol: K8((Z) => !j0.isAtomic(Z.unit) ? QJ() : Z.unit.model.atomicHierarchy.atoms.type_symbol.value(Z.element)),
  label_atom_id: K8((Z) => !j0.isAtomic(Z.unit) ? QJ() : Z.unit.model.atomicHierarchy.atoms.label_atom_id.value(Z.element)),
  auth_atom_id: K8((Z) => !j0.isAtomic(Z.unit) ? QJ() : Z.unit.model.atomicHierarchy.atoms.auth_atom_id.value(Z.element)),
  label_alt_id: K8((Z) => !j0.isAtomic(Z.unit) ? QJ() : Z.unit.model.atomicHierarchy.atoms.label_alt_id.value(Z.element)),
  label_comp_id: K8(t_),
  auth_comp_id: K8((Z) => !j0.isAtomic(Z.unit) ? QJ() : Z.unit.model.atomicHierarchy.atoms.auth_comp_id.value(Z.element)),
  pdbx_formal_charge: K8((Z) => !j0.isAtomic(Z.unit) ? QJ() : Z.unit.model.atomicHierarchy.atoms.pdbx_formal_charge.value(Z.element)),
  vdw_radius: K8((Z) => !j0.isAtomic(Z.unit) ? QJ() : D5(Z.unit.model.atomicHierarchy.atoms.type_symbol.value(Z.element)))
};
function t_(Z) {
  if (!j0.isAtomic(Z.unit))
    QJ();
  return Z.unit.model.atomicHierarchy.atoms.label_comp_id.value(Z.element);
}
function ao(Z) {
  return !j0.isAtomic(Z.unit) ? QJ() : Z.unit.model.atomicHierarchy.residues.label_seq_id.value(Z.unit.residueIndex[Z.element]);
}
function i21(Z) {
  if (!j0.isAtomic(Z.unit))
    QJ();
  let J = Z.unit.model.sequence.byEntityKey[dQ(Z)];
  return J && J.sequence.microHet.has(ao(Z));
}
function hq0(Z) {
  if (!j0.isAtomic(Z.unit))
    QJ();
  let J = Z.unit.model.sequence.byEntityKey[dQ(Z)];
  if (J)
    return J.sequence.microHet.get(ao(Z)) || [t_(Z)];
  else
    return [t_(Z)];
}
var o21 = {
  key: K8((Z) => !j0.isAtomic(Z.unit) ? QJ() : Z.unit.residueIndex[Z.element]),
  group_PDB: K8((Z) => !j0.isAtomic(Z.unit) ? QJ() : Z.unit.model.atomicHierarchy.residues.group_PDB.value(Z.unit.residueIndex[Z.element])),
  label_comp_id: K8(t_),
  auth_comp_id: K8((Z) => !j0.isAtomic(Z.unit) ? QJ() : Z.unit.model.atomicHierarchy.atoms.auth_comp_id.value(Z.element)),
  label_seq_id: K8(ao),
  auth_seq_id: K8((Z) => !j0.isAtomic(Z.unit) ? QJ() : Z.unit.model.atomicHierarchy.residues.auth_seq_id.value(Z.unit.residueIndex[Z.element])),
  pdbx_PDB_ins_code: K8((Z) => !j0.isAtomic(Z.unit) ? QJ() : Z.unit.model.atomicHierarchy.residues.pdbx_PDB_ins_code.value(Z.unit.residueIndex[Z.element])),
  isNonStandard: K8((Z) => !j0.isAtomic(Z.unit) ? QJ() : hq0(Z).some((J) => Z.unit.model.properties.chemicalComponentMap.get(J).mon_nstd_flag[0] === "n")),
  hasMicroheterogeneity: K8(i21),
  microheterogeneityCompIds: K8(hq0),
  secondary_structure_type: K8((Z) => {
    var J;
    if (!j0.isAtomic(Z.unit))
      QJ();
    let $ = (J = $X.get(Z.structure).value) === null || J === void 0 ? void 0 : J.get(Z.unit.invariantId);
    return $ ? $.type[$.getIndex(Z.unit.residueIndex[Z.element])] : m2.Flag.NA;
  }),
  secondary_structure_key: K8((Z) => {
    var J;
    if (!j0.isAtomic(Z.unit))
      QJ();
    let $ = (J = $X.get(Z.structure).value) === null || J === void 0 ? void 0 : J.get(Z.unit.invariantId);
    return $ ? $.key[$.getIndex(Z.unit.residueIndex[Z.element])] : -1;
  }),
  chem_comp_type: K8((Z) => !j0.isAtomic(Z.unit) ? QJ() : Z.unit.model.properties.chemicalComponentMap.get(t_(Z)).type),
  residueSourceIndex: K8((Z) => !j0.isAtomic(Z.unit) ? QJ() : Z.unit.model.atomicHierarchy.residueSourceIndex.value(Z.unit.residueIndex[Z.element]))
}, s21 = {
  key: K8((Z) => !j0.isAtomic(Z.unit) ? QJ() : Z.unit.chainIndex[Z.element]),
  label_asym_id: K8((Z) => !j0.isAtomic(Z.unit) ? Z.unit.coarseElements.asym_id.value(Z.element) : Z.unit.model.atomicHierarchy.chains.label_asym_id.value(Z.unit.chainIndex[Z.element])),
  auth_asym_id: K8((Z) => !j0.isAtomic(Z.unit) ? QJ() : Z.unit.model.atomicHierarchy.chains.auth_asym_id.value(Z.unit.chainIndex[Z.element])),
  label_entity_id: K8((Z) => !j0.isAtomic(Z.unit) ? Z.unit.coarseElements.entity_id.value(Z.element) : Z.unit.model.atomicHierarchy.chains.label_entity_id.value(Z.unit.chainIndex[Z.element]))
}, a21 = {
  key: r_.key,
  entityKey: K8((Z) => !j0.isCoarse(Z.unit) ? sF() : Z.unit.coarseElements.entityKey[Z.element]),
  x: r_.x,
  y: r_.y,
  z: r_.z,
  asym_id: K8((Z) => !j0.isCoarse(Z.unit) ? sF() : Z.unit.coarseElements.asym_id.value(Z.element)),
  entity_id: K8((Z) => !j0.isCoarse(Z.unit) ? sF() : Z.unit.coarseElements.entity_id.value(Z.element)),
  seq_id_begin: K8((Z) => !j0.isCoarse(Z.unit) ? sF() : Z.unit.coarseElements.seq_id_begin.value(Z.element)),
  seq_id_end: K8((Z) => !j0.isCoarse(Z.unit) ? sF() : Z.unit.coarseElements.seq_id_end.value(Z.element)),
  sphere_radius: K8((Z) => !j0.isSpheres(Z.unit) ? sF("spheres") : Z.unit.coarseConformation.radius[Z.element]),
  sphere_rmsf: K8((Z) => !j0.isSpheres(Z.unit) ? sF("spheres") : Z.unit.coarseConformation.rmsf[Z.element]),
  gaussian_weight: K8((Z) => !j0.isGaussians(Z.unit) ? sF("gaussians") : Z.unit.coarseConformation.weight[Z.element]),
  gaussian_covariance_matrix: K8((Z) => !j0.isGaussians(Z.unit) ? sF("gaussians") : Z.unit.coarseConformation.covariance_matrix[Z.element])
};
function dQ(Z) {
  switch (Z.unit.kind) {
    case j0.Kind.Atomic:
      return Z.unit.model.atomicHierarchy.index.getEntityFromChain(Z.unit.chainIndex[Z.element]);
    case j0.Kind.Spheres:
      return Z.unit.model.coarseHierarchy.spheres.entityKey[Z.element];
    case j0.Kind.Gaussians:
      return Z.unit.model.coarseHierarchy.gaussians.entityKey[Z.element];
  }
}
var r21 = {
  key: K8(dQ),
  id: K8((Z) => Z.unit.model.entities.data.id.value(dQ(Z))),
  type: K8((Z) => Z.unit.model.entities.data.type.value(dQ(Z))),
  src_method: K8((Z) => Z.unit.model.entities.data.src_method.value(dQ(Z))),
  pdbx_description: K8((Z) => Z.unit.model.entities.data.pdbx_description.value(dQ(Z))),
  formula_weight: K8((Z) => Z.unit.model.entities.data.formula_weight.value(dQ(Z))),
  pdbx_number_of_molecules: K8((Z) => Z.unit.model.entities.data.pdbx_number_of_molecules.value(dQ(Z))),
  details: K8((Z) => Z.unit.model.entities.data.details.value(dQ(Z))),
  pdbx_mutation: K8((Z) => Z.unit.model.entities.data.pdbx_mutation.value(dQ(Z))),
  pdbx_fragment: K8((Z) => Z.unit.model.entities.data.pdbx_fragment.value(dQ(Z))),
  pdbx_ec: K8((Z) => Z.unit.model.entities.data.pdbx_ec.value(dQ(Z))),
  pdbx_parent_entity_id: K8((Z) => Z.unit.model.entities.data.pdbx_parent_entity_id.value(dQ(Z))),
  subtype: K8((Z) => Z.unit.model.entities.subtype.value(dQ(Z))),
  prd_id: K8((Z) => {
    var J, $;
    return ($ = (J = Z.unit.model.entities.prd_id) === null || J === void 0 ? void 0 : J.value(dQ(Z))) !== null && $ !== void 0 ? $ : "";
  })
}, t21 = [], e21 = {
  id: K8((Z) => Z.unit.id),
  chainGroupId: K8((Z) => Z.unit.chainGroupId),
  multiChain: K8((Z) => j0.Traits.is(Z.unit.traits, j0.Trait.MultiChain)),
  object_primitive: K8((Z) => Z.unit.objectPrimitive),
  operator_name: K8((Z) => Z.unit.conformation.operator.name),
  instance_id: K8((Z) => Z.unit.conformation.operator.instanceId),
  operator_key: K8((Z) => Z.unit.conformation.operator.key),
  model_index: K8((Z) => Z.unit.model.modelNum),
  model_label: K8((Z) => Z.unit.model.label),
  model_entry_id: K8((Z) => Z.unit.model.entryId),
  hkl: K8((Z) => Z.unit.conformation.operator.hkl),
  spgrOp: K8((Z) => Z.unit.conformation.operator.spgrOp),
  model_num: K8((Z) => Z.unit.model.modelNum),
  pdbx_struct_assembly_id: K8((Z) => {
    var J;
    return ((J = Z.unit.conformation.operator.assembly) === null || J === void 0 ? void 0 : J.id) || RZ.DefaultName;
  }),
  pdbx_struct_oper_list_ids: K8((Z) => {
    var J;
    return ((J = Z.unit.conformation.operator.assembly) === null || J === void 0 ? void 0 : J.operList) || t21;
  }),
  struct_ncs_oper_id: K8((Z) => Z.unit.conformation.operator.ncsId)
}, w1 = {
  constant: n21,
  atom: r_,
  residue: o21,
  chain: s21,
  entity: r21,
  unit: e21,
  coarse: a21
};

// node_modules/molstar/lib/mol-model/structure/model/properties/utils/residue-set.js
class Uz {
  add(Z) {
    let J = this.index.get(Z.label_asym_id);
    if (!J)
      J = /* @__PURE__ */ new Map, this.index.set(Z.label_asym_id, J);
    let $ = J.get(Z.label_seq_id);
    if (!$)
      $ = [], J.set(Z.label_seq_id, $);
    if (!this._find(Z, $))
      return $.push(Z), !0;
    return !1;
  }
  hasLabelAsymId(Z) {
    return this.index.has(Z);
  }
  has(Z) {
    var J, $;
    let X = this._asym_id(Z);
    if (!this.index.has(X))
      return;
    let Y = this.index.get(X), Q = this._seq_id(Z);
    if (!Y.has(Q))
      return;
    let W = Y.get(Q), K = this._comp_id(Z), G = this._alt_id(Z), H = this._ins_code(Z), N = (J = this._op_name(Z)) !== null && J !== void 0 ? J : "1_555";
    for (let q of W) {
      if (q.label_comp_id !== K || q.label_alt_id !== G || q.ins_code !== H)
        continue;
      if (this.checkOperator && (($ = q.operator_name) !== null && $ !== void 0 ? $ : "1_555") !== N)
        continue;
      return q;
    }
  }
  static getLabel(Z, J = !1) {
    var $;
    return `${Z.label_asym_id} ${Z.label_comp_id} ${Z.label_seq_id}:${Z.ins_code}:${Z.label_alt_id}${J ? " " + (($ = Z.operator_name) !== null && $ !== void 0 ? $ : "1_555") : ""}`;
  }
  static getEntryFromLocation(Z) {
    var J;
    return {
      label_asym_id: w1.chain.label_asym_id(Z),
      label_comp_id: w1.atom.label_comp_id(Z),
      label_seq_id: w1.residue.label_seq_id(Z),
      label_alt_id: w1.atom.label_alt_id(Z),
      ins_code: w1.residue.pdbx_PDB_ins_code(Z),
      operator_name: (J = w1.unit.operator_name(Z)) !== null && J !== void 0 ? J : "1_555"
    };
  }
  _find(Z, J) {
    var $, X;
    for (let Y of J) {
      if (Y.label_comp_id !== Z.label_comp_id || Y.label_alt_id !== Z.label_alt_id || Y.ins_code !== Z.ins_code)
        continue;
      if (this.checkOperator && (($ = Y.operator_name) !== null && $ !== void 0 ? $ : "1_555") !== ((X = Z.operator_name) !== null && X !== void 0 ? X : "1_555"))
        continue;
      return !0;
    }
    return !1;
  }
  constructor(Z) {
    var J;
    this.index = /* @__PURE__ */ new Map, this.checkOperator = !1, this._asym_id = w1.chain.label_asym_id, this._seq_id = w1.residue.label_seq_id, this._comp_id = w1.atom.label_comp_id, this._alt_id = w1.atom.label_alt_id, this._ins_code = w1.residue.pdbx_PDB_ins_code, this._op_name = w1.unit.operator_name, this.checkOperator = (J = Z === null || Z === void 0 ? void 0 : Z.checkOperator) !== null && J !== void 0 ? J : !1;
  }
}

// node_modules/molstar/lib/mol-model/structure/query/queries/modifiers.js
function YA(Z, J, $) {
  let X = J.subsetBuilder(!0);
  for (let Y of $.units) {
    if (Y.kind !== j0.Kind.Atomic) {
      X.setUnit(Y.id, Y.elements);
      continue;
    }
    let { residueAtomSegments: Q } = Y.model.atomicHierarchy, W = J.unitMap.get(Y.id).elements, K = Y.elements;
    X.beginUnit(Y.id);
    let G = b2.transientSegments(Q, K);
    while (G.hasNext) {
      let H = G.move().index;
      for (let N = Q.offsets[H], q = Q.offsets[H + 1];N < q; N++)
        if (X1.has(W, N))
          X.addElement(N);
    }
    X.commitUnit(), Z.throwIfTimedOut();
  }
  return X.getStructure();
}
function Z81(Z) {
  return function J($) {
    let X = Z($);
    if (f1.isSingleton(X))
      return f1.Singletons($.inputStructure, YA($, $.inputStructure, X.structure));
    else {
      let Y = new a_($.inputStructure);
      for (let Q of X.structures)
        Y.add(YA($, $.inputStructure, Q));
      return Y.getSelection();
    }
  };
}
function ro(Z, J, $, X) {
  let Y = new JA(J), Q = J.lookup3d, W = X.radius;
  for (let K of $.units) {
    let { conformation: G, elements: H } = K;
    for (let N = 0, q = H.length;N < q; N++) {
      let U = H[N];
      Q.findIntoBuilder(G.x(U), G.y(U), G.z(U), W, Y);
    }
    Z.throwIfTimedOut();
  }
  return X.wholeResidues ? YA(Z, J, Y.getStructure()) : Y.getStructure();
}
function bq0(Z, J, $, X) {
  let Y = new JA(J), Q = J.lookup3d, { elementRadius: W, elementRadiusClosure: K, sourceMaxRadius: G, radius: H } = X;
  Z.pushCurrentElement(), Z.element.structure = $;
  for (let N of $.units) {
    Z.element.unit = N;
    let { conformation: q, elements: U } = N;
    for (let F = 0, E = U.length;F < E; F++) {
      let R = U[F];
      Z.element.element = R;
      let z = W(Z);
      Q.findIntoBuilderWithRadius(q.x(R), q.y(R), q.z(R), z, G, H, K, Y);
    }
    Z.throwIfTimedOut();
  }
  return Z.popCurrentElement(), X.wholeResidues ? YA(Z, J, Y.getStructure()) : Y.getStructure();
}
function J81(Z, J) {
  return ($) => {
    return Z.element.structure = $.structure, Z.element.unit = $.unit, Z.element.element = $.element, J(Z);
  };
}
function $81(Z, J) {
  let $ = 0;
  Z.element.structure = Z.inputStructure;
  for (let X of Z.inputStructure.units) {
    Z.element.unit = X;
    let Y = X.elements;
    for (let Q = 0, W = Y.length;Q < W; Q++) {
      let K = Y[Q];
      Z.element.element = K;
      let G = J(Z);
      if (G > $)
        $ = G;
    }
  }
  return Z.throwIfTimedOut(), $;
}
function X81(Z, J) {
  return function $(X) {
    let Y = Z(X);
    if (J.elementRadius) {
      let Q = {
        ...J,
        elementRadius: J.elementRadius,
        elementRadiusClosure: J81(X, J.elementRadius),
        sourceMaxRadius: $81(X, J.elementRadius)
      };
      if (f1.isSingleton(Y)) {
        let W = bq0(X, X.inputStructure, Y.structure, Q);
        return f1.Singletons(X.inputStructure, W);
      } else {
        let W = new a_(X.inputStructure);
        for (let K of Y.structures)
          W.add(bq0(X, X.inputStructure, K, Q));
        return W.getSelection();
      }
    }
    if (f1.isSingleton(Y)) {
      let Q = ro(X, X.inputStructure, Y.structure, J);
      return f1.Singletons(X.inputStructure, Q);
    } else {
      let Q = new a_(X.inputStructure);
      for (let W of Y.structures)
        Q.add(ro(X, X.inputStructure, W, J));
      return Q.getSelection();
    }
  };
}
function Y81(Z, J) {
  return function $(X) {
    let Y = Z(X);
    if (f1.structureCount(Y) === 0)
      return Y;
    let Q = f1.UniqueBuilder(X.inputStructure), W = (K) => Q.add(K);
    return f1.forEach(Y, (K, G) => {
      if (X.pushInputStructure(K), f1.forEach(J(X), W), X.popInputStructure(), G % 10 === 0)
        X.throwIfTimedOut();
    }), Q.getSelection();
  };
}
function Q81(Z, J) {
  return function $(X) {
    let Y = Z(X);
    if (f1.structureCount(Y) === 0)
      return Y;
    let Q = J(X);
    if (f1.structureCount(Q) === 0)
      return f1.Empty(X.inputStructure);
    let W = f1.unionStructure(Q), K = f1.UniqueBuilder(X.inputStructure);
    return f1.forEach(Y, (G, H) => {
      let N = tf(W, G);
      if (N.elementCount !== 0)
        K.add(N);
      if (H % 50 === 0)
        X.throwIfTimedOut();
    }), K.getSelection();
  };
}
function W81(Z, J) {
  return function $(X) {
    let Y = Z(X);
    if (f1.structureCount(Y) === 0)
      return Y;
    let Q = J(X);
    if (f1.structureCount(Q) === 0)
      return Y;
    let W = f1.unionStructure(Q), K = f1.UniqueBuilder(X.inputStructure);
    return f1.forEach(Y, (G, H) => {
      let N = ZA(G, W);
      if (N.elementCount !== 0)
        K.add(N);
      if (H % 50 === 0)
        X.throwIfTimedOut();
    }), K.getSelection();
  };
}
function K81(Z) {
  return function J($) {
    let X = f1.LinearBuilder($.inputStructure);
    return X.add(f1.unionStructure(Z($))), X.getSelection();
  };
}
function G81(Z, J) {
  return function $(X) {
    let Y = Z(X), Q = /* @__PURE__ */ new Map, W = [];
    X.pushCurrentElement(), f1.forEach(Y, (G, H) => {
      X.element.structure = G;
      for (let N of G.units) {
        X.element.unit = N;
        let q = N.elements;
        for (let U = 0, F = q.length;U < F; U++) {
          X.element.element = q[U];
          let E = J(X), R;
          if (Q.has(E))
            R = Q.get(E);
          else
            R = o6.create(), Q.set(E, R);
          o6.add(R, H, H);
        }
      }
      if (W[H] = X.inputStructure.subsetBuilder(!0), H % 10 === 0)
        X.throwIfTimedOut();
    }), X.element.structure = X.inputStructure;
    for (let G of X.inputStructure.units) {
      X.element.unit = G;
      let H = G.elements;
      for (let N = 0, q = H.length;N < q; N++) {
        X.element.element = H[N];
        let U = J(X);
        if (!Q.has(U))
          continue;
        let F = Q.get(U).array;
        for (let E = 0, R = F.length;E < R; E++)
          W[F[E]].addToUnit(G.id, H[N]);
      }
    }
    X.popCurrentElement();
    let K = f1.UniqueBuilder(X.inputStructure);
    for (let G of W)
      K.add(G.getStructure());
    return K.getSelection();
  };
}
function H81({ query: Z, layerCount: J, wholeResidues: $, bondTest: X, fixedPoint: Y }) {
  let Q = Math.max(J, 0);
  return function W(K) {
    let G = f1.UniqueBuilder(K.inputStructure), H = Z(K);
    return K.pushCurrentBond(), K.atomicBond.setTestFn(X), f1.forEach(H, (N, q) => {
      let U = N;
      if (Y)
        while (!0) {
          let F = U.elementCount;
          if (U = xq0(K, $, U), U.elementCount === F)
            break;
        }
      else
        for (let F = 0;F < Q; F++)
          U = xq0(K, $, U);
      if (G.add(U), q % 10 === 0)
        K.throwIfTimedOut();
    }), K.popCurrentBond(), G.getSelection();
  };
}
function xq0(Z, J, $) {
  let X = N81(Z, $);
  if (J)
    return YA(Z, Z.inputStructure, X);
  return X;
}
function N81(Z, J) {
  let $ = Z.inputStructure, X = $.interUnitBonds, Y = new JA($), Q = Z.atomicBond;
  for (let W of J.units) {
    if (W.kind !== j0.Kind.Atomic) {
      Y.beginUnit(W.id);
      for (let F = 0, E = W.elements.length;F < E; F++)
        Y.addElement(W.elements[F]);
      Y.commitUnit();
      continue;
    }
    let K = $.unitMap.get(W.id), { offset: G, b: H, edgeProps: { flags: N, order: q, key: U } } = K.bonds;
    Q.setStructure($), Q.a.unit = K, Q.b.unit = K;
    for (let F = 0, E = W.elements.length;F < E; F++) {
      Y.addToUnit(W.id, W.elements[F]);
      let R = X1.indexOf(K.elements, W.elements[F]);
      for (let z = G[R], D = G[R + 1];z < D; z++) {
        let A = H[z], B = K.elements[A];
        if (X1.has(W.elements, B) || Y.has(W.id, B))
          continue;
        if (Q.aIndex = R, Q.a.element = W.elements[F], Q.bIndex = A, Q.b.element = B, Q.type = N[z], Q.order = q[z], Q.key = U[z], Q.test(Z, !0))
          Y.addToUnit(W.id, B);
      }
    }
    for (let F of X.getConnectedUnits(K.id)) {
      let E = J.unitMap.get(F.unitB), R = $.unitMap.get(F.unitB);
      for (let z of F.connectedIndices) {
        if (!X1.has(W.elements, K.elements[z]))
          continue;
        for (let D of F.getEdges(z)) {
          let A = R.elements[D.indexB];
          if (E && X1.has(E.elements, A) || Y.has(F.unitB, A))
            continue;
          if (Q.a.unit = K, Q.aIndex = z, Q.a.element = K.elements[z], Q.b.unit = R, Q.bIndex = D.indexB, Q.b.element = A, Q.type = D.props.flag, Q.order = D.props.order, Q.key = D.props.key, Q.test(Z, !0))
            Y.addToUnit(F.unitB, A);
        }
      }
    }
  }
  return Y.getStructure();
}
function q81({ query: Z, radius: J, includeWater: $ }) {
  let X = w1.entity.type;
  function Y(Q) {
    return X(Q) === "water";
  }
  return function Q(W) {
    let K = f1.unionStructure(Z(W)), G = YA(W, W.inputStructure, ro(W, W.inputStructure, K, { radius: J })), H = F81(W.inputStructure), N = U81(W.inputStructure), q = W0.Location.create(G), U = /* @__PURE__ */ new Map, F = new Uz({ checkOperator: !0 });
    for (let z of G.units) {
      if (z.kind !== j0.Kind.Atomic)
        continue;
      q.unit = z;
      let { elements: D } = z, A = b2.transientSegments(z.model.atomicHierarchy.chainAtomSegments, D), B = b2.transientSegments(z.model.atomicHierarchy.residueAtomSegments, D);
      while (A.hasNext) {
        let T = A.move();
        q.element = D[T.start];
        let w = w1.chain.label_asym_id(q), V = w1.unit.operator_name(q);
        if (H.has(w)) {
          if (U.has(w))
            n9(U.get(w), V);
          else
            U.set(w, [V]);
          continue;
        }
        let P = w1.entity.type(q);
        if (P === "water" || P === "polymer")
          continue;
        B.setSegment(T);
        while (B.hasNext) {
          let I = B.move();
          q.element = D[I.start], N.addComponent(Uz.getEntryFromLocation(q), F);
        }
      }
      W.throwIfTimedOut();
    }
    let E = W.inputStructure.subsetBuilder(!0);
    for (let z of W.inputStructure.units) {
      if (z.kind !== j0.Kind.Atomic)
        continue;
      q.unit = z;
      let { elements: D } = z, A = b2.transientSegments(z.model.atomicHierarchy.chainAtomSegments, D), B = b2.transientSegments(z.model.atomicHierarchy.residueAtomSegments, D);
      E.beginUnit(z.id);
      while (A.hasNext) {
        let T = A.move();
        q.element = D[T.start];
        let w = w1.chain.label_asym_id(q), V = w1.unit.operator_name(q);
        if (U.has(w) && U.get(w).indexOf(V) >= 0) {
          E.addElementRange(D, T.start, T.end);
          continue;
        }
        if (!F.hasLabelAsymId(w))
          continue;
        B.setSegment(T);
        while (B.hasNext) {
          let P = B.move();
          if (q.element = D[P.start], !F.has(q))
            continue;
          E.addElementRange(D, P.start, P.end);
        }
      }
      E.commitUnit(), W.throwIfTimedOut();
    }
    let R = iF(W.inputStructure, [E.getStructure(), K]);
    if ($) {
      let z = new JA(W.inputStructure), D = W.inputStructure.lookup3d;
      for (let A of R.units) {
        let { conformation: B, elements: T } = A;
        for (let w = 0, V = T.length;w < V; w++) {
          let P = T[w];
          D.findIntoBuilderIf(B.x(P), B.y(P), B.z(P), J, z, Y), z.addToUnit(A.id, P);
        }
        W.throwIfTimedOut();
      }
      return f1.Sequence(W.inputStructure, [z.getStructure()]);
    } else
      return f1.Sequence(W.inputStructure, [R]);
  };
}
function F81(Z) {
  var J;
  let $ = Z.models[0], X = /* @__PURE__ */ new Set;
  if (((J = $.sourceData) === null || J === void 0 ? void 0 : J.kind) !== "mmCIF")
    return X;
  let { _rowCount: Y, asym_id: Q } = $.sourceData.data.db.pdbx_molecule;
  for (let W = 0;W < Y; W++)
    X.add(Q.value(W));
  return X;
}
function U81(Z) {
  var J, $, X;
  let Y = Z.models[0], Q = new yq0;
  if (((J = Y.sourceData) === null || J === void 0 ? void 0 : J.kind) !== "mmCIF")
    return Q;
  let W = Y.sourceData.data.db.struct_conn, { conn_type_id: K } = W, { ptnr1_label_asym_id: G, ptnr1_label_comp_id: H, ptnr1_label_seq_id: N, ptnr1_symmetry: q, pdbx_ptnr1_label_alt_id: U, pdbx_ptnr1_PDB_ins_code: F } = W, { ptnr2_label_asym_id: E, ptnr2_label_comp_id: R, ptnr2_label_seq_id: z, ptnr2_symmetry: D, pdbx_ptnr2_label_alt_id: A, pdbx_ptnr2_PDB_ins_code: B } = W;
  for (let T = 0;T < W._rowCount; T++) {
    let w = K.value(T);
    if (w !== "covale" && w !== "metalc")
      continue;
    let V = {
      label_asym_id: G.value(T),
      label_comp_id: H.value(T),
      label_seq_id: N.value(T),
      label_alt_id: U.value(T),
      ins_code: F.value(T),
      operator_name: ($ = q.value(T)) !== null && $ !== void 0 ? $ : "1_555"
    }, P = {
      label_asym_id: E.value(T),
      label_comp_id: R.value(T),
      label_seq_id: z.value(T),
      label_alt_id: A.value(T),
      ins_code: B.value(T),
      operator_name: (X = D.value(T)) !== null && X !== void 0 ? X : "1_555"
    };
    Q.addEdge(V, P);
  }
  return Q;
}

class yq0 {
  constructor() {
    this.vertices = /* @__PURE__ */ new Map, this.edges = /* @__PURE__ */ new Map;
  }
  addVertex(Z, J) {
    if (this.vertices.has(J))
      return;
    this.vertices.set(J, Z), this.edges.set(J, []);
  }
  addEdge(Z, J) {
    let $ = Uz.getLabel(Z), X = Uz.getLabel(J);
    this.addVertex(Z, $), this.addVertex(J, X), n9(this.edges.get($), X), n9(this.edges.get(X), $);
  }
  addComponent(Z, J) {
    let $ = Uz.getLabel(Z);
    if (!this.vertices.has($)) {
      J.add(Z);
      return;
    }
    let X = /* @__PURE__ */ new Set, Y = /* @__PURE__ */ new Set, Q = [$];
    Y.add($), J.add(Z);
    while (Q.length > 0) {
      let W = Q.pop();
      X.add(W);
      let K = this.vertices.get(W);
      for (let G of this.edges.get(W)) {
        if (X.has(G))
          continue;
        if (Q.push(G), Y.has(G))
          continue;
        Y.add(G);
        let H = this.vertices.get(G);
        if (K.operator_name === H.operator_name)
          J.add({ ...H, operator_name: Z.operator_name });
        else
          J.add(H);
      }
    }
  }
}

// node_modules/molstar/lib/mol-model/structure/query/queries/filters.js
var eo = {};
y9(eo, {
  within: () => D81,
  withSameAtomProperties: () => O81,
  pick: () => L81,
  isConnectedTo: () => j81,
  getCurrentStructureProperties: () => e_,
  first: () => R81,
  areIntersectedBy: () => z81
});

// node_modules/molstar/lib/mol-model/structure/query/utils/structure-distance.js
function gq0(Z, J, $, X, Y, Q) {
  if (J.elementCount === 0 || $.elementCount === 0)
    return !0;
  if (J.elementCount <= $.elementCount)
    return $h.check(Z, J, $, X, Y, Q);
  return $h.check(Z, $, J, X, Y, Q);
}
function mq0(Z, J, $, X, Y) {
  if (J.elementCount === 0 || $.elementCount === 0)
    return !0;
  if (J.elementCount <= $.elementCount)
    return Xh.check(Z, J, $, X, Y);
  return Xh.check(Z, $, J, X, Y);
}
var $h;
(function(Z) {
  let J;
  (function(K) {
    K[K.BelowMin = 0] = "BelowMin", K[K.WithinMax = 1] = "WithinMax", K[K.Miss = 2] = "Miss";
  })(J || (J = {}));
  let $ = M();
  function X(K, G, H, N, q, U, F) {
    let { elements: E, conformation: R } = G, z = $;
    K.element.unit = G;
    let D = !1;
    for (let A = 0, B = E.length;A < B; A++) {
      let T = E[A];
      K.element.element = T;
      let w = Math.max(0, M.distance(H, R.position(T, z)) - N - F(K));
      if (w < q)
        return J.BelowMin;
      if (w < U)
        D = !0;
    }
    return D ? J.WithinMax : J.Miss;
  }
  function Y(K, G, H, N, q, U, F) {
    let { units: E } = G, R = !1;
    for (let z = 0, D = E.length;z < D; z++) {
      let A = X(K, E[z], H, N, q, U, F);
      if (A === J.BelowMin)
        return J.BelowMin;
      if (A === J.WithinMax)
        R = !0;
    }
    return R ? J.WithinMax : J.Miss;
  }
  let Q = M();
  function W(K, G, H, N, q, U) {
    if (G.elementCount === 0 || H.elementCount === 0)
      return 0;
    let { units: F } = G, E = !1;
    K.element.structure = G;
    for (let R = 0, z = F.length;R < z; R++) {
      let D = F[R], { elements: A, conformation: B } = D;
      K.element.unit = D;
      for (let T = 0, w = A.length;T < w; T++) {
        let V = A[T];
        K.element.element = V;
        let P = Y(K, H, B.position(V, Q), U(K), N, q, U);
        if (P === J.BelowMin)
          return !1;
        if (P === J.WithinMax)
          E = !0;
      }
    }
    return E;
  }
  Z.check = W;
})($h || ($h = {}));
var Xh;
(function(Z) {
  let J = M();
  function $(W, K, G, H, N, q) {
    let { elements: U, conformation: F } = K, E = J;
    W.element.unit = K;
    for (let R = 0, z = U.length;R < z; R++) {
      let D = U[R];
      if (W.element.element = D, Math.max(0, M.distance(G, F.position(D, E)) - H - q(W)) <= N)
        return !0;
    }
    return !1;
  }
  function X(W, K, G, H, N, q) {
    let { units: U } = K;
    for (let F = 0, E = U.length;F < E; F++)
      if ($(W, U[F], G, H, N, q))
        return !0;
    return !1;
  }
  let Y = M();
  function Q(W, K, G, H, N) {
    if (K.elementCount === 0 || G.elementCount === 0)
      return 0;
    let { units: q } = K;
    W.element.structure = K;
    for (let U = 0, F = q.length;U < F; U++) {
      let E = q[U];
      W.element.unit = E;
      let { elements: R, conformation: z } = E;
      for (let D = 0, A = R.length;D < A; D++) {
        let B = R[D];
        if (W.element.element = B, X(W, G, z.position(B, Y), N(W), H, N))
          return !0;
      }
    }
    return !1;
  }
  Z.check = Q;
})(Xh || (Xh = {}));

// node_modules/molstar/lib/mol-model/structure/query/queries/filters.js
function L81(Z, J) {
  return ($) => {
    let X = Z($), Y = f1.LinearBuilder($.inputStructure);
    return $.pushCurrentElement(), f1.forEach(X, (Q, W) => {
      if ($.currentStructure = Q, J($))
        Y.add(Q);
      if (W % 100)
        $.throwIfTimedOut();
    }), $.popCurrentStructure(), Y.getSelection();
  };
}
function R81(Z) {
  return (J) => {
    let $ = Z(J), X = f1.LinearBuilder(J.inputStructure);
    if ($.kind === "singletons") {
      if ($.structure.elementCount > 0) {
        let Y = $.structure.units[0], Q = s0.create([Y.getChild(X1.ofSingleton(Y.elements[0]))], { parent: J.inputStructure });
        X.add(Q);
      }
    } else if ($.structures.length > 0)
      X.add($.structures[0]);
    return X.getSelection();
  };
}
function e_(Z, J, $) {
  let { units: X } = Z.currentStructure, Y = Z.pushCurrentElement();
  Y.structure = Z.currentStructure;
  for (let Q of X) {
    Y.unit = Q;
    let W = Q.elements, K = J;
    if (!K)
      continue;
    for (let G = 0, H = W.length;G < H; G++)
      Y.element = W[G], $.add(K(Z));
    Z.throwIfTimedOut();
  }
  return Z.popCurrentElement(), $;
}
function E81(Z, J, $) {
  let X = /* @__PURE__ */ new Set, Y = J(Z);
  return Z.pushCurrentElement(), f1.forEach(Y, (Q, W) => {
    if (Z.currentStructure = Q, e_(Z, $, X), W % 10)
      Z.throwIfTimedOut();
  }), Z.popCurrentElement(), X;
}
function O81(Z, J, $) {
  return (X) => {
    let Y = Z(X), Q = E81(X, J, $), W = f1.LinearBuilder(X.inputStructure);
    return X.pushCurrentStructure(), f1.forEach(Y, (K, G) => {
      X.currentStructure = K;
      let H = e_(X, $, /* @__PURE__ */ new Set);
      if (uZ.isSuperset(Q, H))
        W.add(K);
      if (G % 10)
        X.throwIfTimedOut();
    }), X.popCurrentStructure(), W.getSelection();
  };
}
function z81(Z, J) {
  return ($) => {
    let X = f1.unionStructure(J($)), Y = f1.LinearBuilder($.inputStructure);
    return f1.forEach(Z($), (Q, W) => {
      if (eM(X, Q))
        Y.add(Q);
      if (W % 10)
        $.throwIfTimedOut();
    }), Y.getSelection();
  };
}
function D81(Z) {
  return (J) => {
    let $ = {
      queryCtx: J,
      selection: Z.query(J),
      target: Z.target(J),
      maxRadius: Z.maxRadius,
      minRadius: Z.minRadius ? Math.max(0, Z.minRadius) : 0,
      elementRadius: Z.elementRadius,
      invert: !!Z.invert
    };
    if ($.minRadius === 0 && typeof Z.minRadius === "undefined")
      return M81($);
    else if ($.minRadius === 0)
      return A81($);
    else
      return B81($);
  };
}
function M81({ queryCtx: Z, selection: J, target: $, maxRadius: X, invert: Y }) {
  let Q = f1.unionStructure($).lookup3d, W = f1.LinearBuilder(Z.inputStructure), K = M.zero();
  return f1.forEach(J, (G, H) => {
    let { units: N } = G, q = !1;
    for (let U = 0, F = N.length;U < F; U++) {
      let E = N[U], { elements: R, conformation: z } = E;
      for (let D = 0, A = R.length;D < A; D++) {
        let B = R[D];
        if (z.position(B, K), Q.check(K[0], K[1], K[2], X + z.r(B))) {
          q = !0;
          break;
        }
      }
      if (q)
        break;
    }
    if (Y)
      q = !q;
    if (q)
      W.add(G);
    if (H % 10 === 0)
      Z.throwIfTimedOut();
  }), W.getSelection();
}
function A81({ queryCtx: Z, selection: J, target: $, maxRadius: X, invert: Y, elementRadius: Q }) {
  let W = f1.unionStructure($), K = f1.LinearBuilder(Z.inputStructure);
  return Z.pushCurrentElement(), f1.forEach(J, (G, H) => {
    let N = mq0(Z, W, G, X, Q);
    if (Y)
      N = !N;
    if (N)
      K.add(G);
    if (H % 10 === 0)
      Z.throwIfTimedOut();
  }), Z.popCurrentElement(), K.getSelection();
}
function B81({ queryCtx: Z, selection: J, target: $, minRadius: X, maxRadius: Y, invert: Q, elementRadius: W }) {
  let K = f1.unionStructure($), G = f1.LinearBuilder(Z.inputStructure);
  return Z.pushCurrentElement(), f1.forEach(J, (H, N) => {
    let q = gq0(Z, K, H, X, Y, W);
    if (Q)
      q = !q;
    if (q)
      G.add(H);
    if (N % 10 === 0)
      Z.throwIfTimedOut();
  }), Z.popCurrentElement(), G.getSelection();
}
function w81(Z, J) {
  let { queryCtx: $, input: X, target: Y, disjunct: Q } = Z, W = $.atomicBond, K = X.interUnitBonds;
  W.setStructure(X);
  for (let G of J.units) {
    if (!j0.isAtomic(G))
      continue;
    let H = X.unitMap.get(G.id), { offset: N, b: q, edgeProps: { flags: U, order: F, key: E } } = H.bonds, R = K.getConnectedUnits(G.id), z = R.length, D = G.elements, A = H.elements;
    for (let B = 0, T = D.length;B < T; B++) {
      let w = X1.indexOf(A, D[B]);
      W.a.unit = H, W.b.unit = H;
      for (let V = N[w], P = N[w + 1];V < P; V++) {
        if (W.b.element = H.elements[q[V]], Q && X1.has(G.elements, W.b.element))
          continue;
        if (!Y.hasElement(W.b))
          continue;
        if (W.aIndex = w, W.a.element = D[B], W.bIndex = q[V], W.type = U[V], W.order = F[V], W.key = E[V], W.test($, !0))
          return !0;
      }
      for (let V = 0;V < z; V++) {
        let P = R[V], I = X.unitMap.get(P.unitB), S = I.elements, f = P.getEdges(w);
        for (let v = 0, h = f.length;v < h; v++) {
          let x = f[v];
          if (W.b.unit = I, W.b.element = S[x.indexB], !Y.hasElement(W.b))
            continue;
          if (Q && J.hasElement(W.b))
            continue;
          if (W.a.unit = H, W.aIndex = w, W.a.element = D[B], W.bIndex = x.indexB, W.type = x.props.flag, W.order = x.props.order, W.key = x.props.key, W.test($, !0))
            return !0;
        }
      }
    }
  }
  return !1;
}
function j81({ query: Z, target: J, disjunct: $, invert: X, bondTest: Y }) {
  return (Q) => {
    let W = J(Q);
    if (f1.isEmpty(W))
      return W;
    let K = Z(Q);
    if (f1.isEmpty(K))
      return K;
    let G = {
      queryCtx: Q,
      input: Q.inputStructure,
      disjunct: $,
      target: f1.unionStructure(W)
    }, H = f1.LinearBuilder(Q.inputStructure);
    return Q.pushCurrentBond(), Q.atomicBond.setTestFn(Y), f1.forEach(K, (N, q) => {
      if (w81(G, N))
        H.add(N);
      else if (X)
        H.add(N);
      if (q % 5 === 0)
        Q.throwIfTimedOut();
    }), Q.popCurrentBond(), H.getSelection();
  };
}

// node_modules/molstar/lib/mol-model/structure/query/queries/combinators.js
var Zs = {};
y9(Zs, {
  merge: () => T81,
  intersect: () => _81
});
function T81(Z) {
  if (Z.length === 0)
    return Zh;
  else if (Z.length === 1)
    return Z[0];
  return (J) => {
    let $ = f1.UniqueBuilder(J.inputStructure);
    for (let X = 0;X < Z.length; X++)
      f1.forEach(Z[X](J), (Y, Q) => {
        if ($.add(Y), X % 100)
          J.throwIfTimedOut();
      });
    return $.getSelection();
  };
}
function _81(Z) {
  if (Z.length === 0)
    return Zh;
  else if (Z.length === 1)
    return Z[0];
  return (J) => {
    let $ = [];
    for (let K = 0;K < Z.length; K++)
      $.push(Z[K](J));
    let X = 0, Y = f1.structureCount($[0]);
    for (let K = 1;K < $.length; K++) {
      let G = f1.structureCount($[K]);
      if (G < Y)
        X = K, Y = G;
    }
    J.throwIfTimedOut();
    let Q = cM((K) => K.hashCode, s0.areUnitIdsAndIndicesEqual);
    f1.forEach($[X], (K) => Q.add(K));
    let W = f1.UniqueBuilder(J.inputStructure);
    for (let K = 0;K < $.length; K++) {
      if (K === X)
        continue;
      f1.forEach($[K], (G) => {
        if (Q.has(G))
          W.add(G);
      }), J.throwIfTimedOut();
    }
    return W.getSelection();
  };
}

// node_modules/molstar/lib/mol-model/structure/query/queries/atom-set.js
var Js = {};
y9(Js, {
  propertySet: () => P81,
  countQuery: () => I81,
  atomCount: () => V81
});
function V81(Z) {
  return Z.currentStructure.elementCount;
}
function I81(Z) {
  return (J) => {
    let $ = Z(J);
    return f1.structureCount($);
  };
}
function P81(Z) {
  return (J) => {
    return e_(J, Z, /* @__PURE__ */ new Set);
  };
}

// node_modules/molstar/lib/mol-model/structure/query/predicates.js
var Yh;
(function(Z) {
  function J(U) {
    return !!U && !!U.has;
  }
  function $(U, F) {
    return (E) => U(E) === F;
  }
  Z.eq = $;
  function X(U, F) {
    return (E) => U(E) < F;
  }
  Z.lt = X;
  function Y(U, F) {
    return (E) => U(E) <= F;
  }
  Z.lte = Y;
  function Q(U, F) {
    return (E) => U(E) > F;
  }
  Z.gt = Q;
  function W(U, F) {
    return (E) => U(E) >= F;
  }
  Z.gte = W;
  function K(U) {
    return !0;
  }
  function G(U) {
    return !1;
  }
  function H(U, F) {
    if (J(F))
      return (E) => F.has(U(E));
    else {
      if (F.length === 0)
        return G;
      let E = /* @__PURE__ */ new Set;
      for (let R = 0;R < F.length; R++)
        E.add(F[R]);
      return (R) => E.has(U(R));
    }
  }
  Z.inSet = H;
  function N(...U) {
    switch (U.length) {
      case 0:
        return K;
      case 1:
        return U[0];
      case 2: {
        let F = U[0], E = U[1];
        return (R) => F(R) && E(R);
      }
      case 3: {
        let F = U[0], E = U[1], R = U[2];
        return (z) => F(z) && E(z) && R(z);
      }
      case 4: {
        let F = U[0], E = U[1], R = U[2], z = U[3];
        return (D) => F(D) && E(D) && R(D) && z(D);
      }
      case 5: {
        let F = U[0], E = U[1], R = U[2], z = U[3], D = U[4];
        return (A) => F(A) && E(A) && R(A) && z(A) && D(A);
      }
      case 6: {
        let F = U[0], E = U[1], R = U[2], z = U[3], D = U[4], A = U[5];
        return (B) => F(B) && E(B) && R(B) && z(B) && D(B) && A(B);
      }
      default: {
        let F = U.length;
        return (E) => {
          for (let R = 0;R < F; R++)
            if (!U[R])
              return !1;
          return !0;
        };
      }
    }
  }
  Z.and = N;
  function q(...U) {
    switch (U.length) {
      case 0:
        return G;
      case 1:
        return U[0];
      case 2: {
        let F = U[0], E = U[1];
        return (R) => F(R) || E(R);
      }
      case 3: {
        let F = U[0], E = U[1], R = U[2];
        return (z) => F(z) || E(z) || R(z);
      }
      case 4: {
        let F = U[0], E = U[1], R = U[2], z = U[3];
        return (D) => F(D) || E(D) || R(D) || z(D);
      }
      case 5: {
        let F = U[0], E = U[1], R = U[2], z = U[3], D = U[4];
        return (A) => F(A) || E(A) || R(A) || z(A) || D(A);
      }
      case 6: {
        let F = U[0], E = U[1], R = U[2], z = U[3], D = U[4], A = U[5];
        return (B) => F(B) || E(B) || R(B) || z(B) || D(B) || A(B);
      }
      default: {
        let F = U.length;
        return (E) => {
          for (let R = 0;R < F; R++)
            if (U[R])
              return !0;
          return !1;
        };
      }
    }
  }
  Z.or = q;
})(Yh || (Yh = {}));

// node_modules/molstar/lib/mol-model/structure/query.js
var OZ = {
  generators: no,
  filters: eo,
  modifiers: to,
  combinators: Zs,
  pred: Yh,
  internal: mo,
  atomset: Js
};

// node_modules/molstar/lib/mol-model/structure/structure/symmetry.js
var VW;
(function(Z) {
  function J(N, q) {
    return n0.create("Build Assembly", async (U) => {
      let F = N.models;
      if (F.length !== 1)
        throw new Error("Can only build assemblies from structures based on 1 model.");
      let E = nF.findAssembly(F[0], q);
      if (!E)
        throw new Error(`Assembly '${q}' is not defined.`);
      let R = RZ.create(E.id, e.identity(), { assembly: { id: E.id, operId: 0, operList: [] } }), z = s0.Builder({
        coordinateSystem: R,
        label: N.label,
        dynamicBonds: N.dynamicBonds
      }), D = new C9(N);
      for (let A of E.operatorGroups) {
        let B = A.selector(D);
        if (f1.structureCount(B) === 0)
          continue;
        let { units: T } = f1.unionStructure(B);
        for (let w of A.operators)
          for (let V of T)
            z.addWithOperator(V, w);
      }
      return z.getStructure();
    });
  }
  Z.buildAssembly = J;
  function $(N, q, U) {
    return n0.create("Build Symmetry Assembly", async (F) => {
      let E = N.models;
      if (E.length !== 1)
        throw new Error("Can only build symmetry assemblies from structures based on 1 model.");
      let R = M(), z = s0.Builder({
        label: N.label,
        representativeModel: E[0],
        dynamicBonds: N.dynamicBonds
      }), D = new C9(N);
      for (let A of q) {
        let T = C81(A.asymIds)(D);
        if (f1.structureCount(T) === 0)
          continue;
        let { units: w } = f1.unionStructure(T);
        for (let { index: V, shift: [P, I, S] } of A.operators) {
          let f = dq0(U, V, P, I, S, R);
          for (let v of w)
            for (let h of f)
              z.addWithOperator(v, h);
        }
      }
      return z.getStructure();
    });
  }
  Z.buildSymmetryAssembly = $;
  function X(N, q) {
    return n0.create("Find Symmetry Mates", (U) => f81(U, N, q));
  }
  Z.builderSymmetryMates = X;
  function Y(N, q, U) {
    return n0.create("Build Symmetry", (F) => S81(F, N, q, U));
  }
  Z.buildSymmetryRange = Y;
  function Q(N) {
    return n0.create("Build NCS", (q) => v81(q, N));
  }
  Z.buildNcs = Q;
  function W(N, q) {
    return N.invariantId === q.invariantId && N.model.id === q.model.id && X1.areEqual(N.elements, q.elements);
  }
  Z.areUnitsEquivalent = W;
  function K() {
    return CH0(j0.hashUnit, W);
  }
  Z.UnitEquivalenceBuilder = K;
  function G(N) {
    let q = K();
    for (let F of N.units)
      q.add(F.id, F);
    let U = [];
    for (let F of q.groups)
      U.push(j0.SymmetryGroup(F.map((E) => N.unitMap.get(E))));
    return U;
  }
  Z.computeTransformGroups = G;
  function H(N, q) {
    if (N.length !== q.length)
      return !1;
    for (let U = 0, F = N.length;U < F; ++U) {
      let E = N[U].units, R = q[U].units;
      if (E.length !== R.length)
        return !1;
      if (N[U].hashCode !== q[U].hashCode)
        return !1;
      for (let z = 0, D = E.length;z < D; z++)
        if (E[z].conformation !== R[z].conformation)
          return !1;
      if (!X1.areEqual(N[U].elements, q[U].elements))
        return !1;
    }
    return !0;
  }
  Z.areTransformGroupsEquivalent = H;
})(VW || (VW = {}));
function C81(Z) {
  return OZ.generators.atoms({ chainTest: OZ.pred.and(OZ.pred.eq((J) => w1.unit.operator_name(J.element), RZ.DefaultName), OZ.pred.inSet((J) => w1.chain.label_asym_id(J.element), Z)) });
}
function dq0(Z, J, $, X, Y, Q) {
  let { spacegroup: W, ncsOperators: K } = Z, G = [], { toFractional: H } = W.cell, N = M.transformMat4(M(), Q, H), q = f$.getSymmetryOperatorRef(W, J, $, X, Y, N);
  if (K && K.length)
    for (let U = 0, F = K.length;U < F; ++U) {
      let E = K[U], R = e.mul(e(), q.matrix, E.matrix), z = RZ.create(`${q.name} ${E.name}`, R, {
        assembly: q.assembly,
        ncsId: E.ncsId,
        hkl: q.hkl,
        spgrOp: q.spgrOp
      });
      G.push(z);
    }
  else
    G.push(q);
  return G;
}
function pq0(Z, J, $, X) {
  let { spacegroup: Y, ncsOperators: Q } = Z, W = Q && Q.length || 0, K = [];
  if (!W && J[0] <= 0 && $[0] >= 0 && J[1] <= 0 && $[1] >= 0 && J[2] <= 0 && $[2] >= 0)
    K[0] = f$.getSymmetryOperator(Y, 0, 0, 0, 0);
  for (let G = 0;G < Y.operators.length; G++)
    for (let H = J[0];H <= $[0]; H++)
      for (let N = J[1];N <= $[1]; N++)
        for (let q = J[2];q <= $[2]; q++) {
          if (!W && G === 0 && H === 0 && N === 0 && q === 0)
            continue;
          K.push(...dq0(Z, G, H, N, q, X));
        }
  return K;
}
function k81(Z, J) {
  if (Z._operators_333 && M.equals(J, Z._operators_333.ref))
    return Z._operators_333.operators;
  return Z._operators_333 = {
    ref: M.clone(J),
    operators: pq0(Z, M.create(-3, -3, -3), M.create(3, 3, 3), J)
  }, Z._operators_333.operators;
}
function uq0(Z, J) {
  let $ = s0.Builder({
    label: Z.label,
    dynamicBonds: Z.dynamicBonds
  }), { units: X } = Z;
  for (let Y of J)
    for (let Q of X)
      $.addWithOperator(Q, Y);
  return $.getStructure();
}
async function v81(Z, J) {
  let $ = J.models;
  if ($.length !== 1)
    throw new Error("Can only build NCS from structures based on 1 model.");
  let X = T9.Provider.get($[0]);
  if (!X)
    return J;
  let Y = X.ncsOperators;
  if (!Y || !Y.length)
    return J;
  return uq0(J, Y);
}
async function S81(Z, J, $, X) {
  let Y = J.models;
  if (Y.length !== 1)
    throw new Error("Can only build symmetries from structures based on 1 model.");
  let Q = T9.Provider.get(Y[0]);
  if (!Q)
    return J;
  let { spacegroup: W } = Q;
  if (d7.isZero(W.cell))
    return J;
  let K = O2.getCenter(Y[0]), G = pq0(Q, $, X, K);
  return uq0(J, G);
}
async function f81(Z, J, $) {
  let X = J.models;
  if (X.length !== 1)
    throw new Error("Can only build symmetries from structures based on 1 model.");
  let Y = T9.Provider.get(X[0]);
  if (!Y)
    return J;
  let { spacegroup: Q } = Y;
  if (d7.isZero(Q.cell))
    return J;
  if (Z.shouldUpdate)
    await Z.update("Initialing...");
  let W = O2.getCenter(X[0]), K = k81(Y, W), G = J.lookup3d, H = /* @__PURE__ */ new Set;
  function N(E, R) {
    return `${E.invariantId}|${R.name}`;
  }
  let q = s0.Builder({
    label: J.label,
    dynamicBonds: J.dynamicBonds
  }), { units: U } = J, F = M.zero();
  for (let E of K) {
    for (let R of U) {
      let z = R.lookup3d.boundary.sphere;
      M.transformMat4(F, z.center, E.matrix);
      let D = G.findUnitIndices(F[0], F[1], F[2], z.radius + $);
      for (let A = 0, B = D.count;A < B; A++) {
        if (!U[D.indices[A]].lookup3d.check(F[0], F[1], F[2], z.radius + $))
          continue;
        let w = N(R, E);
        if (!H.has(w))
          q.addWithOperator(R, E), H.add(w);
      }
    }
    if (Z.shouldUpdate)
      await Z.update("Building symmetry...");
  }
  return q.getStructure();
}

// node_modules/molstar/lib/mol-model/structure/structure/util/subset-builder.js
class $s {
  addToUnit(Z, J) {
    let $ = this.unitMap.get(Z);
    if ($)
      $[$.length] = J;
    else
      this.unitMap.set(Z, [J]), this.ids[this.ids.length] = Z;
    this.elementCount++;
  }
  beginUnit(Z) {
    this.parentId = Z, this.currentUnit = this.currentUnit.length > 0 ? [] : this.currentUnit;
  }
  addElement(Z) {
    this.currentUnit[this.currentUnit.length] = Z, this.elementCount++;
  }
  addElementRange(Z, J, $) {
    for (let X = J;X < $; X++)
      this.currentUnit[this.currentUnit.length] = Z[X], this.elementCount++;
  }
  commitUnit() {
    if (this.currentUnit.length === 0)
      return;
    this.ids[this.ids.length] = this.parentId, this.unitMap.set(this.parentId, this.currentUnit), this.parentId = -1;
  }
  setUnit(Z, J) {
    this.ids[this.ids.length] = Z, this.unitMap.set(Z, J), this.elementCount += J.length;
  }
  _getStructure(Z) {
    if (this.isEmpty)
      return s0.Empty;
    let J = [];
    t$(this.ids);
    let $ = VW.UnitEquivalenceBuilder();
    for (let X = 0, Y = this.ids.length;X < Y; X++) {
      let Q = this.ids[X], W = this.parent.unitMap.get(Q), K = this.unitMap.get(Q), G = !1;
      if (Z) {
        if (!this.isSorted)
          t$(K);
        K = X1.deduplicate(X1.ofSortedArray(this.currentUnit)), G = !0;
      }
      let H = K.length;
      if (K.length === W.elements.length) {
        J[J.length] = W, $.add(W.id, W);
        continue;
      }
      if (!this.isSorted && !G && H > 1)
        t$(K);
      let N = W.getChild(X1.ofSortedArray(K)), q = $.add(N.id, N);
      if (N !== q)
        N = q.applyOperator(N.id, N.conformation.operator, !0);
      J[J.length] = N;
    }
    return s0.create(J, { parent: this.parent });
  }
  getStructure() {
    return this._getStructure(!1);
  }
  getStructureDeduplicate() {
    return this._getStructure(!0);
  }
  setSingletonLocation(Z) {
    let J = this.ids[0];
    Z.unit = this.parent.unitMap.get(J), Z.element = this.unitMap.get(J)[0];
  }
  get isEmpty() {
    return this.elementCount === 0;
  }
  constructor(Z, J) {
    this.parent = Z, this.isSorted = J, this.ids = [], this.unitMap = NY.Mutable(), this.parentId = -1, this.currentUnit = [], this.elementCount = 0;
  }
}

// node_modules/molstar/lib/mol-data/util/combination.js
function cq0(Z, J) {
  let $ = 1;
  while (J--)
    $ *= Z--;
  return $;
}
function h81(Z, J) {
  if (J > Z)
    return 0;
  return cq0(Z, J) / cq0(J, J);
}
function b81(Z) {
  let J = Z & -Z, $ = Z + J, Y = (($ & -$) / J >> 1) - 1;
  return $ | Y;
}

class lq0 {
  move() {
    if (this.hasNext) {
      let Z = 0, J = 0, $ = this.index;
      for (;$; $ >>>= 1, Z++)
        if ($ & 1)
          this.value[J++] = this.array[Z];
      this.index = b81(this.index), this.hasNext = this.index < this.maxIndex;
    }
    return this.value;
  }
  constructor(Z, J) {
    this.array = Z, this.hasNext = !1, this.index = (1 << J) - 1, this.size = h81(Z.length, J), this.maxIndex = 1 << Z.length, this.value = new Array(J), this.hasNext = J > 0 && J <= Z.length;
  }
}
function Xs(Z, J) {
  let $ = [], X = new lq0(Z, J);
  while (X.hasNext)
    $.push(X.move().slice());
  return $;
}

// node_modules/molstar/lib/mol-model/structure/structure/carbohydrates/data.js
var Lz = [], nq0 = {
  links: Lz,
  terminalLinks: Lz,
  elements: Lz,
  partialElements: Lz,
  getElementIndices: () => Lz,
  getLinkIndices: () => Lz,
  getTerminalLinkIndices: () => Lz
};

// node_modules/molstar/lib/mol-model/structure/structure/carbohydrates/compute.js
var XX = WH("C"), ZV = WH("O"), x81 = [
  A5.elementFingerprint([XX, XX, XX, ZV]),
  A5.elementFingerprint([XX, XX, XX, XX, ZV]),
  A5.elementFingerprint([XX, XX, XX, XX, XX, ZV]),
  A5.elementFingerprint([XX, XX, XX, XX, XX, XX, ZV])
];
function y81(Z, J) {
  let $ = -1, X = -1, Y = -1, Q = -1, { elements: W } = Z, { type_symbol: K, label_atom_id: G } = Z.model.atomicHierarchy.atoms, { b: H, offset: N } = Z.bonds;
  for (let q = 0, U = J.length;q < U; ++q) {
    let F = W[J[q]];
    if (K.value(F) !== XX)
      continue;
    let E = 0, R = 0;
    for (let z = N[J[q]], D = N[J[q] + 1];z < D; ++z) {
      let A = W[H[z]], B = K.value(A);
      if (B === ZV)
        ++E;
      else if (B === XX)
        ++R;
    }
    if (E === 2) {
      $ = F;
      break;
    } else if (E === 1 && R === 1)
      X = F;
    else if (G.value(F).startsWith("C1"))
      Y = F;
    else
      Q = F;
  }
  return $ !== -1 ? $ : X !== -1 ? X : Y !== -1 ? Y : Q !== -1 ? Q : W[J[0]];
}
function g81(Z, J) {
  let { elements: $ } = Z, { label_alt_id: X } = Z.model.atomicHierarchy.atoms;
  return X.value($[J]);
}
function m81(Z, J, $, X) {
  let Y = J.conformation;
  return M.normalize(Z, M.sub(Z, X, Y.position($, Z))), Z;
}
function iq0(Z, J) {
  let { elements: $ } = Z, { label_atom_id: X } = Z.model.atomicHierarchy.atoms;
  return X.value($[J]);
}
function d81(Z, J) {
  if (!J || !J.length)
    return;
  let { unit: $, all: X } = Z, Y = /* @__PURE__ */ new Set, Q = Xs(uJ(new Array(J.length)), 2);
  for (let W = 0, K = Q.length;W < K; ++W) {
    let G = Q[W], H = X[J[G[0]]], N = X[J[G[1]]];
    if (X1.areIntersecting(H, N) && A5.getAltId($, H) === A5.getAltId($, N))
      Y.add(J[G[0]]), Y.add(J[G[1]]);
  }
  if (Y.size) {
    let W = [];
    for (let K = 0, G = J.length;K < G; ++K)
      if (!Y.has(J[K]))
        W.push(J[K]);
    return W;
  } else
    return J;
}
function p81(Z, J) {
  return J.properties.saccharideComponentMap.get(Z);
}
function oq0(Z) {
  if (Z.models.reduce((U, F) => U + F.properties.saccharideComponentMap.size, 0) === 0)
    return nq0;
  let J = [], $ = [], X = [], Y = [], Q = /* @__PURE__ */ new Map;
  function W(U, F, E) {
    return `${U}|${F}|${E}`;
  }
  function K(U, F) {
    if (Q.has(U))
      Q.get(U).push(F);
    else
      Q.set(U, [F]);
  }
  function G(U, F) {
    M.sub(X[U].geometry.direction, X[F].geometry.center, X[U].geometry.center), M.normalize(X[U].geometry.direction, X[U].geometry.direction);
  }
  let H = M();
  function N(U, F, E) {
    let R = E.conformation, z = X[U].geometry;
    M.sub(z.direction, R.position(E.elements[F], H), z.center), M.normalize(z.direction, z.direction);
  }
  for (let U = 0, F = Z.units.length;U < F; ++U) {
    let E = Z.units[U];
    if (!j0.isAtomic(E))
      continue;
    let { model: R, rings: z } = E, { chainAtomSegments: D, residueAtomSegments: A, atoms: B } = R.atomicHierarchy, { label_comp_id: T } = B, w = b2.transientSegments(D, E.elements), V = b2.transientSegments(A, E.elements), P = void 0;
    while (w.hasNext) {
      V.setSegment(w.move());
      while (V.hasNext) {
        let { index: I } = V.move(), S = p81(T.value(A.offsets[I]), R);
        if (!S)
          continue;
        if (!P)
          P = qz.byFingerprintAndResidue(z, x81);
        let f = d81(z, P.get(I));
        if (!f || !f.length) {
          Y.push({ unit: E, residueIndex: I, component: S });
          continue;
        }
        let v = [];
        for (let x = 0, b = f.length;x < b; ++x) {
          let g = z.all[f[x]], m = y81(E, g), i = HY.calculateMomentsAxes(of(E, g)), r = HY.calculateNormalizedAxes(i), Y0 = M.copy(M(), r.origin), c = M.copy(M(), r.dirC), n = m81(M(), E, m, Y0);
          M.orthogonalize(n, c, n);
          let l = A5.getAltId(E, g), u = X.length;
          if (v.push(u), K(W(I, E.id, l), u), l)
            K(W(I, E.id, ""), u);
          X.push({
            geometry: { center: Y0, normal: c, direction: n },
            component: S,
            ringIndex: f[x],
            altId: l,
            unit: E,
            residueIndex: I
          });
        }
        let h = Xs(uJ(new Array(f.length)), 2);
        for (let x = 0, b = h.length;x < b; ++x) {
          let g = h[x], m = z.all[f[g[0]]], i = z.all[f[g[1]]];
          if (lJ.areVertexSetsConnected(E.bonds, m, i, 3)) {
            let r = v[g[0]], Y0 = v[g[1]];
            if (X[r].altId === X[Y0].altId)
              G(r, Y0), G(Y0, r), J.push({ carbohydrateIndexA: r, carbohydrateIndexB: Y0 }), J.push({ carbohydrateIndexA: Y0, carbohydrateIndexB: r });
          }
        }
      }
    }
  }
  function q(U, F) {
    return Q.get(W(U.getResidueIndex(F), U.id, g81(U, F))) || [];
  }
  for (let U = 0, F = X.length;U < F; ++U) {
    let E = X[U], { unit: R } = E;
    for (let z = U + 1;z < F; ++z) {
      let D = X[z];
      if (R !== D.unit || E.residueIndex === D.residueIndex)
        continue;
      let A = R.rings.all[E.ringIndex], B = R.rings.all[D.ringIndex];
      if (lJ.areVertexSetsConnected(R.bonds, A, B, 3))
        G(U, z), G(z, U), J.push({ carbohydrateIndexA: U, carbohydrateIndexB: z }), J.push({ carbohydrateIndexA: z, carbohydrateIndexB: U });
    }
  }
  for (let U = 0, F = Z.units.length;U < F; ++U) {
    let E = Z.units[U];
    if (!j0.isAtomic(E))
      continue;
    Z.interUnitBonds.getConnectedUnits(E.id).forEach((R) => {
      R.connectedIndices.forEach((z) => {
        R.getEdges(z).forEach(({ props: D, indexB: A }) => {
          if (!s1.isCovalent(D.flag))
            return;
          let B = Z.unitMap.get(R.unitA), T = Z.unitMap.get(R.unitB), w = q(B, z), V = q(T, A);
          if (w.length > 0 && V.length > 0) {
            let P = w.length, I = V.length;
            for (let S = 0, f = Math.max(P, I);S < f; ++S) {
              let v = w[Math.min(S, P - 1)], h = V[Math.min(S, I - 1)], x = iq0(B, z);
              if (x.startsWith("O1") || x.startsWith("C1"))
                G(v, h);
              J.push({
                carbohydrateIndexA: v,
                carbohydrateIndexB: h
              });
            }
          } else if (V.length === 0)
            for (let P of w) {
              let I = iq0(B, z);
              if (I.startsWith("O1") || I.startsWith("C1"))
                N(P, A, T);
              $.push({
                carbohydrateIndex: P,
                elementIndex: A,
                elementUnit: T,
                fromCarbohydrate: !0
              });
            }
          else if (w.length === 0)
            for (let P of V)
              $.push({
                carbohydrateIndex: P,
                elementIndex: z,
                elementUnit: B,
                fromCarbohydrate: !1
              });
        });
      });
    });
  }
  return { links: J, terminalLinks: $, elements: X, partialElements: Y, ...u81(X, J, $) };
}
function u81(Z, J, $) {
  function X(q, U) {
    return ZJ(q.id, U);
  }
  function Y(q, U, F) {
    let E = [], R = q.get(X(U, F));
    if (R !== void 0)
      for (let z of R)
        n9(E, z);
    return E;
  }
  let Q = /* @__PURE__ */ new Map;
  for (let q = 0, U = Z.length;q < U; ++q) {
    let { unit: F, ringIndex: E } = Z[q], R = F.rings.all[E];
    for (let z = 0, D = R.length;z < D; ++z) {
      let A = X(F, F.elements[R[z]]), B = Q.get(A);
      if (B === void 0)
        Q.set(A, [q]);
      else
        B.push(q);
    }
  }
  function W(q, U) {
    return Y(Q, q, U);
  }
  let K = /* @__PURE__ */ new Map;
  for (let q = 0, U = J.length;q < U; ++q) {
    let F = J[q], { unit: E, ringIndex: R } = Z[F.carbohydrateIndexA], z = E.rings.all[R];
    for (let D = 0, A = z.length;D < A; ++D) {
      let B = X(E, E.elements[z[D]]), T = K.get(B);
      if (T === void 0)
        K.set(B, [q]);
      else
        T.push(q);
    }
  }
  function G(q, U) {
    return Y(K, q, U);
  }
  let H = /* @__PURE__ */ new Map;
  for (let q = 0, U = $.length;q < U; ++q) {
    let { fromCarbohydrate: F, carbohydrateIndex: E, elementUnit: R, elementIndex: z } = $[q];
    if (F) {
      let { unit: D, ringIndex: A } = Z[E], B = D.rings.all[A];
      for (let T = 0, w = B.length;T < w; ++T) {
        let V = X(D, D.elements[B[T]]), P = H.get(V);
        if (P === void 0)
          H.set(V, [q]);
        else
          P.push(q);
      }
    } else {
      let D = X(R, R.elements[z]), A = H.get(D);
      if (A === void 0)
        H.set(D, [q]);
      else
        A.push(q);
    }
  }
  function N(q, U) {
    return Y(H, q, U);
  }
  return { getElementIndices: W, getLinkIndices: G, getTerminalLinkIndices: N };
}

// node_modules/molstar/lib/mol-model/structure/structure/util/boundary.js
var Qh = C0(), c81 = new $J("14"), l81 = new $J("98");
function n81(Z) {
  return Z > 500 ? c81 : l81;
}
function sq0(Z) {
  let { units: J } = Z, $ = n81(J.length);
  $.reset();
  for (let X = 0, Y = J.length;X < Y; X++) {
    let Q = J[X], W = Q.boundary, K = Q.conformation.operator;
    if (K.isIdentity)
      $.includeSphere(W.sphere);
    else
      C0.transform(Qh, W.sphere, K.matrix), $.includeSphere(Qh);
  }
  $.finishedIncludeStep();
  for (let X = 0, Y = J.length;X < Y; X++) {
    let Q = J[X], W = Q.boundary, K = Q.conformation.operator;
    if (K.isIdentity)
      $.radiusSphere(W.sphere);
    else
      C0.transform(Qh, W.sphere, K.matrix), $.radiusSphere(Qh);
  }
  return { box: $.getBox(), sphere: $.getSphere() };
}

// node_modules/molstar/lib/mol-model/structure/structure/mapping.js
function aq0(Z) {
  let { units: J, elementCount: $, unitIndexMap: X } = Z, Y = new Uint32Array(J.length), Q = new Uint32Array($), W = new Uint32Array($);
  for (let K = 0, G = 0, H = J.length;K < H; ++K) {
    Y[K] = G;
    let { elements: N } = J[K];
    for (let q = 0, U = N.length;q < U; ++q) {
      let F = G + q;
      Q[F] = K, W[F] = N[q];
    }
    G += N.length;
  }
  return {
    cumulativeUnitElementCount: Y,
    unitIndices: Q,
    elementIndices: W,
    getSerialIndex: (K, G) => Y[X.get(K.id)] + f0.indexOf(K.elements, G)
  };
}
function rq0(Z) {
  let J = 0, $ = [];
  for (let G of Z.unitSymmetryGroups) {
    $.push(J);
    let H = G.units[0];
    if (j0.isAtomic(H))
      J += H.bonds.edgeCount * 2 * G.units.length;
  }
  let X = new Uint32Array(J), Y = new Uint32Array(J), Q = new Uint32Array(J), W = 0, K = 0;
  for (let G of Z.unitSymmetryGroups) {
    let H = G.units[0];
    if (j0.isAtomic(H)) {
      let N = H.bonds.edgeCount * 2;
      for (let q = 0, U = G.units.length;q < U; ++q)
        for (let F = 0, E = N;F < E; ++F)
          X[W] = K, Y[W] = F, Q[W] = q, W += 1;
    }
    K += 1;
  }
  return { bondCount: J, unitIndex: X, unitEdgeIndex: Y, unitGroupIndex: Q, unitGroupOffset: $ };
}

// node_modules/molstar/lib/mol-model/structure/structure/structure.js
class s0 {
  subsetBuilder(Z) {
    return new $s(this, Z);
  }
  get elementCount() {
    return this.state.elementCount;
  }
  get bondCount() {
    if (this.state.bondCount === -1)
      this.state.bondCount = this.interUnitBonds.edgeCount / 2 + $2.getIntraUnitBondCount(this);
    return this.state.bondCount;
  }
  get hasCustomProperties() {
    return !!this.state.customProps && this.state.customProps.all.length > 0;
  }
  get customPropertyDescriptors() {
    if (!this.state.customProps)
      this.state.customProps = new H$;
    return this.state.customProps;
  }
  get currentPropertyData() {
    if (!this.state.propertyData)
      this.state.propertyData = Object.create(null);
    return this.state.propertyData;
  }
  get inheritedPropertyData() {
    return this.parent ? this.parent.currentPropertyData : this.currentPropertyData;
  }
  get polymerResidueCount() {
    if (this.state.polymerResidueCount === -1)
      this.state.polymerResidueCount = Z61(this);
    return this.state.polymerResidueCount;
  }
  get polymerGapCount() {
    if (this.state.polymerGapCount === -1)
      this.state.polymerGapCount = J61(this);
    return this.state.polymerGapCount;
  }
  get polymerUnitCount() {
    if (this.state.polymerUnitCount === -1)
      this.state.polymerUnitCount = $61(this);
    return this.state.polymerUnitCount;
  }
  get uniqueElementCount() {
    if (this.state.uniqueElementCount === -1)
      this.state.uniqueElementCount = e81(this);
    return this.state.uniqueElementCount;
  }
  get atomicResidueCount() {
    if (this.state.atomicResidueCount === -1)
      this.state.atomicResidueCount = X61(this);
    return this.state.atomicResidueCount;
  }
  get isCoarseGrained() {
    return this.models.some((Z) => O2.isCoarseGrained(Z));
  }
  get isEmpty() {
    return this.units.length === 0;
  }
  get hashCode() {
    if (this.state.hashCode !== -1)
      return this.state.hashCode;
    return this.computeHash();
  }
  get transformHash() {
    if (this.state.transformHash !== -1)
      return this.state.transformHash;
    return this.state.transformHash = l9(this.units.map((Z) => Z.id)), this.state.transformHash;
  }
  computeHash() {
    let Z = 23;
    for (let J = 0, $ = this.units.length;J < $; J++) {
      let X = this.units[J];
      Z = 31 * Z + X.id | 0, Z = 31 * Z + X1.hashCode(X.elements) | 0;
    }
    if (Z = 31 * Z + this.elementCount | 0, Z = bS(Z), Z === -1)
      Z = 0;
    return this.state.hashCode = Z, Z;
  }
  elementLocations() {
    return new s0.ElementLocationIterator(this);
  }
  get root() {
    var Z;
    return (Z = this.state.parent) !== null && Z !== void 0 ? Z : this;
  }
  get parent() {
    return this.state.parent;
  }
  get coordinateSystem() {
    return this.state.coordinateSystem;
  }
  get label() {
    return this.state.label;
  }
  get boundary() {
    if (this.state.boundary)
      return this.state.boundary;
    return this.state.boundary = sq0(this), this.state.boundary;
  }
  get lookup3d() {
    if (this.state.lookup3d)
      return this.state.lookup3d;
    return this.state.lookup3d = new xo(this), this.state.lookup3d;
  }
  get interUnitBonds() {
    if (this.state.interUnitBonds)
      return this.state.interUnitBonds;
    if (this.parent && this.state.dynamicBonds === this.parent.state.dynamicBonds && this.parent.state.interUnitBonds && this.parent.state.interUnitBonds.edgeCount === 0)
      this.state.interUnitBonds = new cF(/* @__PURE__ */ new Map);
    else
      this.state.interUnitBonds = dN0(this, {
        ignoreWater: !this.dynamicBonds,
        ignoreIon: !this.dynamicBonds,
        validUnit: this.state.interBondsValidUnit,
        validUnitPair: this.state.interBondsValidUnitPair
      });
    return this.state.interUnitBonds;
  }
  get dynamicBonds() {
    return this.state.dynamicBonds;
  }
  get interBondsValidUnit() {
    return this.state.interBondsValidUnit;
  }
  get interBondsValidUnitPair() {
    return this.state.interBondsValidUnitPair;
  }
  get unitSymmetryGroups() {
    if (this.state.unitSymmetryGroups)
      return this.state.unitSymmetryGroups;
    return this.state.unitSymmetryGroups = VW.computeTransformGroups(this), this.state.unitSymmetryGroups;
  }
  get unitSymmetryGroupsIndexMap() {
    if (this.state.unitSymmetryGroupsIndexMap)
      return this.state.unitSymmetryGroupsIndexMap;
    return this.state.unitSymmetryGroupsIndexMap = j0.SymmetryGroup.getUnitSymmetryGroupsIndexMap(this.unitSymmetryGroups), this.state.unitSymmetryGroupsIndexMap;
  }
  get carbohydrates() {
    if (this.state.carbohydrates)
      return this.state.carbohydrates;
    return this.state.carbohydrates = oq0(this), this.state.carbohydrates;
  }
  get models() {
    if (this.state.models)
      return this.state.models;
    return this.state.models = o81(this), this.state.models;
  }
  get uniqueResidueNames() {
    return this.state.uniqueResidueNames || (this.state.uniqueResidueNames = s81(this));
  }
  get uniqueElementSymbols() {
    return this.state.uniqueElementSymbols || (this.state.uniqueElementSymbols = a81(this));
  }
  get entityIndices() {
    return this.state.entityIndices || (this.state.entityIndices = r81(this));
  }
  get uniqueAtomicResidueIndices() {
    return this.state.uniqueAtomicResidueIndices || (this.state.uniqueAtomicResidueIndices = t81(this));
  }
  get isAtomic() {
    for (let Z of this.units)
      if (!j0.isAtomic(Z))
        return !1;
    return !0;
  }
  get hasAtomic() {
    for (let Z of this.units)
      if (j0.isAtomic(Z))
        return !0;
    return !1;
  }
  get isCoarse() {
    for (let Z of this.units)
      if (!j0.isCoarse(Z))
        return !1;
    return !0;
  }
  get hasCoarse() {
    for (let Z of this.units)
      if (j0.isCoarse(Z))
        return !0;
    return !1;
  }
  get serialMapping() {
    return this.state.serialMapping || (this.state.serialMapping = aq0(this));
  }
  get intraUnitBondMapping() {
    return this.state.intraUnitBondMapping || (this.state.intraUnitBondMapping = rq0(this));
  }
  get model() {
    if (this.state.model)
      return this.state.model;
    if (this.state.representativeModel)
      return this.state.representativeModel;
    if (this.state.masterModel)
      return this.state.masterModel;
    let Z = this.models;
    if (Z.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 = Z[0], this.state.model;
  }
  get masterModel() {
    return this.state.masterModel;
  }
  get representativeModel() {
    return this.state.representativeModel;
  }
  hasElement(Z) {
    if (!this.unitMap.has(Z.unit.id))
      return !1;
    return X1.has(this.unitMap.get(Z.unit.id).elements, Z.element);
  }
  getModelIndex(Z) {
    return this.models.indexOf(Z);
  }
  remapModel(Z) {
    let { dynamicBonds: J, interUnitBonds: $, parent: X } = this.state, Y = [];
    for (let Q of this.unitSymmetryGroups) {
      let W = Q.units[0].remapModel(Z, J);
      Y.push(W);
      for (let K = 1, G = Q.units.length;K < G; ++K) {
        let H = Q.units[K];
        Y.push(H.remapModel(Z, J, W.props));
      }
    }
    return s0.create(Y, {
      parent: X === null || X === void 0 ? void 0 : X.remapModel(Z),
      label: this.label,
      interUnitBonds: J ? void 0 : $,
      dynamicBonds: J,
      interBondsValidUnit: this.state.interBondsValidUnit,
      interBondsValidUnitPair: this.state.interBondsValidUnitPair,
      coordinateSystem: this.state.coordinateSystem,
      masterModel: this.state.masterModel,
      representativeModel: this.state.representativeModel
    });
  }
  asParent() {
    if (this._proxy)
      return this._proxy;
    if (this.parent) {
      let Z = this.parent.coordinateSystem.isIdentity ? this.parent : s0.transform(this.parent, this.parent.coordinateSystem.inverse), J = this.coordinateSystem.isIdentity ? Z : s0.transform(Z, this.coordinateSystem.matrix);
      this._proxy = new s0(J.units, J.unitMap, J.unitIndexMap, { ...J.state, dynamicBonds: this.dynamicBonds }, { child: this, target: this.parent });
    } else
      this._proxy = this;
    return this._proxy;
  }
  get child() {
    return this._child;
  }
  get target() {
    var Z;
    return (Z = this._target) !== null && Z !== void 0 ? Z : this;
  }
  constructor(Z, J, $, X, Y) {
    this.units = Z, this.unitMap = J, this.unitIndexMap = $, this.state = X, this._child = Y === null || Y === void 0 ? void 0 : Y.child, this._target = Y === null || Y === void 0 ? void 0 : Y.target, this._proxy = void 0;
  }
}
function i81(Z, J, $) {
  return Z[J].id - Z[$].id;
}
function o81(Z) {
  let { units: J } = Z, $ = o6.create();
  for (let X of J)
    o6.add($, X.model.id, X.model);
  return $.array;
}
function s81(Z) {
  let { microheterogeneityCompIds: J } = w1.residue, $ = /* @__PURE__ */ new Set, X = W0.Location.create(Z);
  for (let Y of Z.unitSymmetryGroups) {
    let Q = Y.units[0];
    if (!j0.isAtomic(Q))
      continue;
    let W = b2.transientSegments(Q.model.atomicHierarchy.residueAtomSegments, Q.elements);
    X.unit = Q;
    while (W.hasNext) {
      let K = W.move();
      X.element = Q.elements[K.start];
      let G = J(X);
      for (let H of G)
        $.add(H);
    }
  }
  return $;
}
function a81(Z) {
  let J = w1.atom.type_symbol, $ = /* @__PURE__ */ new Set, X = W0.Location.create(Z);
  for (let Y of Z.unitSymmetryGroups) {
    let Q = Y.units[0];
    if (!j0.isAtomic(Q))
      continue;
    X.unit = Q;
    for (let W = 0, K = Q.elements.length;W < K; ++W)
      X.element = Q.elements[W], $.add(J(X));
  }
  return $;
}
function r81(Z) {
  let { units: J } = Z, $ = W0.Location.create(Z), X = o6.create();
  for (let Y of J) {
    let Q = Y.kind === j0.Kind.Atomic ? w1.entity.key : w1.coarse.entityKey;
    $.unit = Y;
    let W = Y.elements, K = b2.transientSegments(Y.model.atomicHierarchy.chainAtomSegments, W);
    while (K.hasNext) {
      let G = K.move();
      $.element = W[G.start];
      let H = Q($);
      o6.add(X, H, H);
    }
  }
  return t$(X.array), X.array;
}
function t81(Z) {
  let J = /* @__PURE__ */ new Map, $ = [], X = Z.unitSymmetryGroups;
  for (let Q of X) {
    let W = Q.units[0];
    if (!j0.isAtomic(W))
      continue;
    let K;
    if (J.has(W.model.id))
      K = J.get(W.model.id);
    else
      K = o6.create(), $.push(W.model.id), J.set(W.model.id, K);
    let G = b2.transientSegments(W.model.atomicHierarchy.residueAtomSegments, W.elements);
    while (G.hasNext) {
      let H = G.move();
      o6.add(K, H.index, H.index);
    }
  }
  let Y = /* @__PURE__ */ new Map;
  for (let Q of $) {
    let W = J.get(Q).array;
    t$(W), Y.set(Q, W);
  }
  return Y;
}
function e81(Z) {
  let { unitSymmetryGroups: J } = Z, $ = 0;
  for (let X = 0, Y = J.length;X < Y; X++)
    $ += J[X].elements.length;
  return $;
}
function Z61(Z) {
  let { units: J } = Z, $ = 0;
  for (let X = 0, Y = J.length;X < Y; X++)
    $ += J[X].polymerElements.length;
  return $;
}
function J61(Z) {
  let { units: J } = Z, $ = 0;
  for (let X = 0, Y = J.length;X < Y; X++)
    $ += J[X].gapElements.length / 2;
  return $;
}
function $61(Z) {
  let { units: J } = Z, $ = 0;
  for (let X = 0, Y = J.length;X < Y; X++)
    if (J[X].polymerElements.length > 0)
      $ += 1;
  return $;
}
function X61(Z) {
  let { units: J } = Z, $ = 0;
  for (let X = 0, Y = J.length;X < Y; X++) {
    let Q = J[X];
    if (!j0.isAtomic(Q))
      continue;
    let { elements: W, residueIndex: K } = Q, G = -1, H = -1;
    for (let N = 0, q = W.length;N < q; ++N)
      if (G = K[W[N]], G !== H)
        $ += 1, H = G;
  }
  return $;
}
(function(Z) {
  Z.Empty = G([]);
  function J(t) {
    return { kind: "structure-loci", structure: t };
  }
  Z.Loci = J;
  function $(t) {
    let Z0 = [];
    for (let U0 of t.units)
      Z0.push({ unit: U0, indices: k0.ofBounds(0, U0.elements.length) });
    return W0.Loci(t, Z0);
  }
  Z.toStructureElementLoci = $;
  function X(t, Z0) {
    return f1.toLociWithSourceUnits(f1.Singletons(t, Z0));
  }
  Z.toSubStructureElementLoci = X;
  function Y(t) {
    return !!t && t.kind === "structure-loci";
  }
  Z.isLoci = Y;
  function Q(t, Z0) {
    return t.structure === Z0.structure;
  }
  Z.areLociEqual = Q;
  function W(t) {
    return t.structure.isEmpty;
  }
  Z.isLociEmpty = W;
  function K(t, Z0) {
    if (Z0 === t.structure)
      return t;
    return J(Z0);
  }
  Z.remapLoci = K;
  function G(t, Z0 = {}) {
    let U0 = NY.Mutable(), a = NY.Mutable(), Q0 = 0, $0 = !0, R0 = t.length > 0 ? t[0].id : 0;
    for (let E0 = 0, V0 = t.length;E0 < V0; E0++) {
      let u0 = t[E0];
      if (U0.set(u0.id, u0), Q0 += u0.elements.length, u0.id < R0)
        $0 = !1;
      R0 = u0.id;
    }
    if (!$0)
      Rf(t, 0, t.length, i81, bF);
    for (let E0 = 0, V0 = t.length;E0 < V0; E0++)
      a.set(t[E0].id, E0);
    let X0 = {
      hashCode: -1,
      transformHash: -1,
      elementCount: Q0,
      bondCount: -1,
      uniqueElementCount: -1,
      atomicResidueCount: -1,
      polymerResidueCount: -1,
      polymerGapCount: -1,
      polymerUnitCount: -1,
      dynamicBonds: !1,
      coordinateSystem: RZ.Default,
      label: ""
    };
    if (Z0.parent)
      X0.parent = Z0.parent.parent || Z0.parent;
    if (Z0.interUnitBonds)
      X0.interUnitBonds = Z0.interUnitBonds;
    if (Z0.interBondsValidUnit)
      X0.interBondsValidUnit = Z0.interBondsValidUnit;
    else if (Z0.parent)
      X0.interBondsValidUnit = Z0.parent.interBondsValidUnit;
    if (Z0.interBondsValidUnitPair)
      X0.interBondsValidUnitPair = Z0.interBondsValidUnitPair;
    else if (Z0.parent)
      X0.interBondsValidUnitPair = Z0.parent.interBondsValidUnitPair;
    if (Z0.dynamicBonds)
      X0.dynamicBonds = Z0.dynamicBonds;
    else if (Z0.parent)
      X0.dynamicBonds = Z0.parent.dynamicBonds;
    if (Z0.coordinateSystem)
      X0.coordinateSystem = Z0.coordinateSystem;
    else if (Z0.parent)
      X0.coordinateSystem = Z0.parent.coordinateSystem;
    if (Z0.label)
      X0.label = Z0.label;
    else if (Z0.parent)
      X0.label = Z0.parent.label;
    if (Z0.masterModel)
      X0.masterModel = Z0.masterModel;
    else if (Z0.parent)
      X0.masterModel = Z0.parent.masterModel;
    if (Z0.representativeModel)
      X0.representativeModel = Z0.representativeModel;
    else if (Z0.parent)
      X0.representativeModel = Z0.parent.representativeModel;
    return new Z(t, U0, a, X0);
  }
  Z.create = G;
  async function H(t, Z0) {
    if (t.frameCount === 0)
      return Z.Empty;
    let U0 = [], a = void 0, Q0 = 0;
    for (let $0 = 0, R0 = t.frameCount;$0 < R0; ++$0) {
      let X0 = await n0.resolveInContext(t.getFrameAtIndex($0), Z0);
      if (!a)
        a = X0;
      let E0 = N(X0);
      for (let V0 = 0, u0 = E0.units.length;V0 < u0; ++V0) {
        let N0 = E0.units[V0], q0 = N0.invariantId + Q0, A0 = N0.chainGroupId + Q0, S0 = j0.create(U0.length, q0, A0, N0.traits, N0.kind, N0.model, N0.conformation.operator, N0.elements);
        U0.push(S0);
      }
      Q0 = U0.length;
    }
    return G(U0, { representativeModel: a, label: a.label });
  }
  Z.ofTrajectory = H;
  function N(t, Z0 = {}) {
    let U0 = t.atomicHierarchy.chainAtomSegments, { index: a } = t.atomicHierarchy, { auth_asym_id: Q0 } = t.atomicHierarchy.chains, { atomicChainOperatorMappinng: $0 } = t, R0 = new R({ label: t.label, ...Z0 });
    for (let E0 = 0;E0 < U0.count; E0++) {
      let V0 = $0.get(E0) || RZ.Default, u0 = U0.offsets[E0], N0 = !1, q0 = !1;
      if (q(t, E0)) {
        q0 = !0;
        while (E0 + 1 < U0.count && q(t, E0 + 1)) {
          let a0 = $0.get(E0), D1 = $0.get(E0 + 1);
          if (a0 !== D1)
            break;
          N0 = !0, E0++;
        }
      } else
        while (E0 + 1 < U0.count && U0.offsets[E0 + 1] - U0.offsets[E0] === 1 && U0.offsets[E0 + 2] - U0.offsets[E0 + 1] === 1) {
          let a0 = a.getEntityFromChain(E0), D1 = a.getEntityFromChain(E0 + 1);
          if (a0 !== D1)
            break;
          let Y1 = Q0.value(E0), u1 = Q0.value(E0 + 1);
          if (Y1 !== u1)
            break;
          let b0 = $0.get(E0), x0 = $0.get(E0 + 1);
          if (b0 !== x0)
            break;
          N0 = !0, E0++;
        }
      let A0 = X1.ofBounds(u0, U0.offsets[E0 + 1]), S0 = j0.Trait.None;
      if (N0)
        S0 |= j0.Trait.MultiChain;
      if (q0)
        S0 |= j0.Trait.Water;
      if (O2.isCoarseGrained(t))
        S0 |= j0.Trait.CoarseGrained;
      R0.addUnit(j0.Kind.Atomic, t, V0, A0, S0);
    }
    let X0 = t.coarseHierarchy;
    if (X0.isDefined) {
      if (X0.spheres.count > 0)
        U(R0, t, t.coarseHierarchy.spheres, j0.Kind.Spheres);
      if (X0.gaussians.count > 0)
        U(R0, t, t.coarseHierarchy.gaussians, j0.Kind.Gaussians);
    }
    return R0.getStructure();
  }
  Z.ofModel = N;
  function q(t, Z0) {
    let U0 = t.atomicHierarchy.index.getEntityFromChain(Z0);
    return t.entities.data.type.value(U0) === "water";
  }
  function U(t, Z0, U0, a) {
    let { chainElementSegments: Q0 } = U0;
    for (let $0 = 0;$0 < Q0.count; $0++) {
      let R0 = X1.ofBounds(Q0.offsets[$0], Q0.offsets[$0 + 1]);
      t.addUnit(a, Z0, RZ.Default, R0, j0.Trait.None);
    }
  }
  function F(t, Z0) {
    if (e.isIdentity(Z0))
      return t;
    if (!e.isRotationAndTranslation(Z0, RZ.RotationTranslationEpsilon))
      throw new Error("Only rotation/translation combination can be applied.");
    let U0 = [];
    for (let $0 of t.units) {
      let R0 = $0.conformation.operator, X0 = RZ.create(R0.name, Z0, R0);
      U0.push($0.applyOperator($0.id, X0));
    }
    let a = t.coordinateSystem, Q0 = RZ.compose(RZ.create(a.name, Z0, a), a);
    return G(U0, { parent: t, coordinateSystem: Q0 });
  }
  Z.transform = F;
  function E(t, Z0) {
    for (let Q0 of Z0)
      if (!e.isRotationAndTranslation(Q0, RZ.RotationTranslationEpsilon))
        throw new Error("Only rotation/translation combination can be applied.");
    let U0 = [], a = 0;
    for (let Q0 of t.units) {
      let $0 = Q0.conformation.operator;
      for (let R0 of Z0) {
        if (e.isIdentity(R0)) {
          U0.push(Q0);
          continue;
        }
        let X0 = RZ.create($0.name, R0, $0);
        U0.push(Q0.applyOperator(a++, X0));
      }
    }
    return G(U0, { parent: t });
  }
  Z.instances = E;

  class R {
    beginChainGroup() {
      this.chainGroupId++, this.inChainGroup = !0;
    }
    endChainGroup() {
      this.inChainGroup = !1;
    }
    addUnit(t, Z0, U0, a, Q0, $0) {
      if ($0 === void 0)
        $0 = this.invariantId();
      let R0 = this.inChainGroup ? this.chainGroupId : ++this.chainGroupId, X0 = j0.create(this.units.length, $0, R0, Q0, t, Z0, U0, a);
      return this.add(X0);
    }
    copyUnit(t, Z0) {
      let U0 = Z0 === null || Z0 === void 0 ? void 0 : Z0.invariantId;
      if (U0 === void 0)
        U0 = this.invariantId();
      let a = this.inChainGroup ? this.chainGroupId : ++this.chainGroupId, Q0 = t.getCopy(this.units.length, U0, a, Z0);
      return this.add(Q0);
    }
    add(t) {
      if (t.elements.length === 1) {
        t.conformation.position(t.elements[0], this.p);
        let Z0 = [t.invariantId, this.p[0], this.p[1], this.p[2]].join("|");
        if (this.singleElementUnits.has(Z0))
          return this.singleElementUnits.get(Z0);
        else
          this.singleElementUnits.set(Z0, t);
      }
      return this.units.push(t), t;
    }
    addWithOperator(t, Z0, U0 = !1) {
      return this.add(t.applyOperator(this.units.length, Z0, U0));
    }
    getStructure() {
      return G(this.units, this.props);
    }
    get isEmpty() {
      return this.units.length === 0;
    }
    constructor(t = {}) {
      this.props = t, this.units = [], this.invariantId = $7(), this.chainGroupId = -1, this.inChainGroup = !1, this.p = M(), this.singleElementUnits = /* @__PURE__ */ new Map;
    }
  }
  Z.StructureBuilder = R;
  function z(t = {}) {
    return new R(t);
  }
  Z.Builder = z;
  function D(t) {
    return t.hashCode;
  }
  Z.hashCode = D;
  function A(t) {
    return O_(t.units.map((Z0) => j0.conformationId(Z0)).join("|"));
  }
  Z.conformationHash = A;
  function B(t, Z0) {
    if (t === Z0)
      return !0;
    if (t.elementCount !== Z0.elementCount)
      return !1;
    let U0 = t.units.length;
    if (U0 !== Z0.units.length)
      return !1;
    for (let a = 0;a < U0; a++)
      if (t.units[a].id !== Z0.units[a].id)
        return !1;
    return !0;
  }
  Z.areUnitIdsEqual = B;
  function T(t, Z0) {
    if (t === Z0)
      return !0;
    if (!B(t, Z0))
      return !1;
    for (let U0 = 0, a = t.units.length;U0 < a; U0++)
      if (!X1.areEqual(t.units[U0].elements, Z0.units[U0].elements))
        return !1;
    return !0;
  }
  Z.areUnitIdsAndIndicesEqual = T;
  function w(t, Z0) {
    if (t.hashCode !== Z0.hashCode)
      return !1;
    let U0 = t.models.length;
    if (U0 !== Z0.models.length)
      return !1;
    for (let a = 0;a < U0; a++)
      if (!O2.areHierarchiesEqual(t.models[a], Z0.models[a]))
        return !1;
    return !0;
  }
  Z.areHierarchiesEqual = w;
  function V(t, Z0) {
    return t === Z0 || t.hashCode === Z0.hashCode && VW.areTransformGroupsEquivalent(t.unitSymmetryGroups, Z0.unitSymmetryGroups);
  }
  Z.areEquivalent = V;
  function P(t, Z0) {
    return V(t.root, Z0.root);
  }
  Z.areRootsEquivalent = P;
  function I(t, Z0) {
    return t.root === Z0.root;
  }
  Z.areRootsEqual = I;

  class S {
    move() {
      return this.advance(), this.current.element = this.elements[this.idx], this.current;
    }
    advance() {
      if (this.idx < this.maxIdx) {
        if (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;
      }
      if (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;
    }
    constructor(t) {
      if (this.structure = t, this.unitIndex = 0, this.maxIdx = 0, this.idx = -1, this.current = W0.Location.create(t), this.hasNext = t.elementCount > 0, this.hasNext)
        this.elements = t.units[0].elements, this.maxIdx = this.elements.length - 1, this.current.unit = t.units[0];
    }
  }
  Z.ElementLocationIterator = S;
  let f = M();
  function v(t, Z0, U0) {
    let { elements: a, conformation: Q0 } = t, $0 = f, R0 = Number.MAX_VALUE;
    for (let X0 = 0, E0 = a.length;X0 < E0; X0++) {
      let V0 = a[X0], u0 = M.distance(Z0, Q0.position(V0, $0)) - U0 - Q0.r(V0);
      if (u0 < R0)
        R0 = u0;
    }
    return R0;
  }
  function h(t, Z0, U0) {
    let { units: a } = t, Q0 = Number.MAX_VALUE;
    for (let $0 = 0, R0 = a.length;$0 < R0; $0++) {
      let X0 = a[$0], E0 = v(X0, Z0, U0);
      if (E0 < Q0)
        Q0 = E0;
    }
    return Q0;
  }
  Z.minDistanceToPoint = h;
  let x = M();
  function b(t, Z0) {
    if (t.elementCount === 0 || Z0.elementCount === 0)
      return 0;
    let { units: U0 } = t, a = Number.MAX_VALUE;
    for (let Q0 = 0, $0 = U0.length;Q0 < $0; Q0++) {
      let R0 = U0[Q0], { elements: X0, conformation: E0 } = R0;
      for (let V0 = 0, u0 = X0.length;V0 < u0; V0++) {
        let N0 = X0[V0], q0 = h(Z0, E0.position(N0, x), E0.r(N0));
        if (q0 < a)
          a = q0;
      }
    }
    return a;
  }
  Z.distance = b;
  function g(t) {
    return t.elementCount === 1 ? "1 element" : `${t.elementCount} elements`;
  }
  Z.elementDescription = g;
  function m(t, Z0, U0) {
    return t.masterModel ? Z0.model === U0.model || Z0.model === t.masterModel || U0.model === t.masterModel : Z0.model === U0.model;
  }
  Z.validUnitPair = m;
  function i(t, Z0, U0) {
    let { maxRadius: a, validUnit: Q0, validUnitPair: $0 } = U0;
    if (!t.units.some((E0) => Q0(E0)))
      return;
    let R0 = t.lookup3d, X0 = M();
    for (let E0 of t.units) {
      if (!Q0(E0))
        continue;
      let V0 = E0.boundary.sphere;
      M.transformMat4(X0, V0.center, E0.conformation.operator.matrix);
      let u0 = R0.findUnitIndices(X0[0], X0[1], X0[2], V0.radius + a);
      for (let N0 = 0;N0 < u0.count; N0++) {
        let q0 = t.units[u0.indices[N0]];
        if (E0.id >= q0.id)
          continue;
        if (!Q0(q0) || !$0(E0, q0))
          continue;
        if (q0.elements.length >= E0.elements.length)
          Z0(E0, q0);
        else
          Z0(q0, E0);
      }
    }
  }
  Z.eachUnitPair = i;
  function r(t, { chain: Z0, residue: U0, atom: a }) {
    let Q0 = W0.Location.create(t);
    for (let $0 of t.units) {
      if ($0.kind !== j0.Kind.Atomic)
        continue;
      Q0.unit = $0;
      let { elements: R0 } = $0, X0 = b2.transientSegments($0.model.atomicHierarchy.chainAtomSegments, R0), E0 = b2.transientSegments($0.model.atomicHierarchy.residueAtomSegments, R0);
      while (X0.hasNext) {
        let V0 = X0.move();
        if (Z0)
          Q0.element = R0[V0.start], Z0(Q0);
        if (!U0 && !a)
          continue;
        E0.setSegment(V0);
        while (E0.hasNext) {
          let u0 = E0.move();
          if (U0)
            Q0.element = R0[u0.start], U0(Q0);
          if (!a)
            continue;
          for (let { start: N0, end: q0 } = u0;N0 < q0; N0++)
            Q0.element = R0[N0], a(Q0);
        }
      }
    }
  }
  Z.eachAtomicHierarchyElement = r, Z.DefaultSizeThresholds = {
    smallResidueCount: 10,
    mediumResidueCount: 5000,
    largeResidueCount: 30000,
    highSymmetryUnitCount: 10,
    fiberResidueCount: 15
  };
  function Y0(t) {
    return t.unitSymmetryGroups.filter((Z0) => Z0.units[0].polymerElements.length > 0);
  }
  function c(t, Z0) {
    let U0 = Y0(t);
    return U0.length === 1 && U0[0].units.length > 2 && U0[0].units[0].polymerElements.length < Z0.fiberResidueCount;
  }
  function n(t, Z0) {
    let U0 = Y0(t);
    return U0.length >= 1 && U0[0].units.length > Z0.highSymmetryUnitCount;
  }
  let l;
  (function(t) {
    t[t.Small = 0] = "Small", t[t.Medium = 1] = "Medium", t[t.Large = 2] = "Large", t[t.Huge = 3] = "Huge", t[t.Gigantic = 4] = "Gigantic";
  })(l = Z.Size || (Z.Size = {}));
  function u(t, Z0 = {}, U0 = 1) {
    let a = { ...Z.DefaultSizeThresholds, ...Z0 };
    if (t.polymerResidueCount >= a.largeResidueCount * U0)
      if (n(t, a))
        return l.Huge;
      else
        return l.Gigantic;
    else if (c(t, a))
      return l.Small;
    else if (t.polymerResidueCount < a.smallResidueCount * U0)
      return l.Small;
    else if (t.polymerResidueCount < a.mediumResidueCount * U0)
      return l.Medium;
    else
      return l.Large;
  }
  Z.getSize = u, Z.Index = IW.createSimple("index", "root"), Z.MaxIndex = IW.createSimple("max_index", "root");
  let G0 = "__PrincipalAxes__";
  function F0(t) {
    if (t.currentPropertyData[G0])
      return t.currentPropertyData[G0];
    let Z0 = W0.Loci.getPrincipalAxes(Z.toStructureElementLoci(t));
    return t.currentPropertyData[G0] = Z0, Z0;
  }
  Z.getPrincipalAxes = F0;
})(s0 || (s0 = {}));

// node_modules/molstar/lib/mol-script/runtime/query/base.js
class ZF0 {
  constructor() {
    this.map = /* @__PURE__ */ new Map;
  }
  removeSymbol(Z) {
    this.map.delete(Z.symbol.id);
  }
  addSymbol(Z) {
    if (this.map.has(Z.symbol.id))
      console.warn(`Symbol '${Z.symbol.id}' already added. Call removeSymbol/removeCustomProps re-adding the symbol.`);
    this.map.set(Z.symbol.id, Z);
  }
  addCustomProp(Z) {
    if (!Z.symbols)
      return;
    for (let J of Object.keys(Z.symbols))
      this.addSymbol(Z.symbols[J]);
  }
  removeCustomProp(Z) {
    if (!Z.symbols)
      return;
    for (let J of Object.keys(Z.symbols))
      this.removeSymbol(Z.symbols[J]);
  }
  getRuntime(Z) {
    return this.map.get(Z);
  }
}
var WA = new ZF0;

class JF0 {
  constructor(Z) {
    this.table = Z, this.constQueryContext = new C9(s0.Empty);
  }
}
var tq0;
(function(Z) {
  function J(X) {
    return { kind: "const", value: X };
  }
  Z.Const = J;
  function $(X) {
    return { kind: "dynamic", runtime: X };
  }
  Z.Dynamic = $;
})(tq0 || (tq0 = {}));
var Rz;
(function(Z) {
  function J(X) {
    return { isConst: !0, fn: function Y(Q) {
      return X;
    } };
  }
  Z.Const = J;
  function $(X) {
    return { isConst: !1, fn: X };
  }
  Z.Dynamic = $;
})(Rz || (Rz = {}));
var QA;
(function(Z) {
  function J($, X, Y, Q) {
    if (typeof $.length === "number")
      for (let W = 0, K = $.length;W < K; W++)
        Y($[W](X), W, Q);
    else {
      let W = 0;
      for (let K of Object.keys($))
        Y($[K](X), W++, Q);
    }
    return Q;
  }
  Z.forEachEval = J;
})(QA || (QA = {}));
var NH;
(function(Z) {
  function J(X, Y) {
    return new Ys(X, Y, !0);
  }
  Z.Const = J;
  function $(X, Y) {
    return new Ys(X, Y, !1);
  }
  Z.Dynamic = $;
})(NH || (NH = {}));

class Ys {
  compile(Z, J) {
    let $, X = !1;
    if (!J)
      $ = void 0, X = !0;
    else if (VJ.isArgumentsArray(J)) {
      $ = [], X = !0;
      for (let Y of J) {
        let Q = Qs(Z, Y);
        X = X && Q.isConst, $.push(Q.fn);
      }
    } else {
      $ = Object.create(null), X = !0;
      for (let Y of Object.keys(J)) {
        let Q = Qs(Z, J[Y]);
        X = X && Q.isConst, $[Y] = Q.fn;
      }
    }
    if (this.isConst) {
      if (this.isConst && X)
        return Rz.Const(this.fn(Z.constQueryContext, $));
      return Rz.Dynamic(eq0(this.fn, $));
    }
    return Rz.Dynamic(eq0(this.fn, $));
  }
  constructor(Z, J, $) {
    this.symbol = Z, this.fn = J, this.isConst = $;
  }
}
function eq0(Z, J) {
  return function $(X) {
    return Z(X, J);
  };
}
function Qs(Z, J) {
  if (VJ.isLiteral(J))
    return Rz.Const(J);
  if (VJ.isSymbol(J)) {
    let X = Z.table.getRuntime(J.name);
    if (!X)
      return Rz.Const(J.name);
    return X.compile(Z);
  }
  if (!VJ.isSymbol(J.head))
    throw new Error("Can only apply symbols.");
  let $ = Z.table.getRuntime(J.head.name);
  if (!$)
    throw new Error(`Symbol '${J.head.name}' is not implemented.`);
  return $.compile(Z, J.args);
}
function PW(Z) {
  let J = new JF0(WA);
  return Qs(J, Z).fn;
}

// node_modules/molstar/lib/mol-model/structure/structure/element/loci.js
var Y61 = JJ.diff;
function B3(Z, J) {
  return { kind: "element-loci", structure: Z, elements: J };
}
(function(Z) {
  function J($0) {
    return !!$0 && $0.kind === "element-loci";
  }
  Z.is = J;
  function $($0, R0) {
    if ($0.structure !== R0.structure)
      return !1;
    if ($0.elements.length !== R0.elements.length)
      return !1;
    for (let X0 = 0, E0 = $0.elements.length;X0 < E0; ++X0) {
      let V0 = $0.elements[X0], u0 = R0.elements[X0];
      if (V0.unit.id !== u0.unit.id)
        return !1;
      if (!f0.areEqual(V0.indices, u0.indices))
        return !1;
    }
    return !0;
  }
  Z.areEqual = $;
  function X($0) {
    for (let R0 of $0.elements)
      if (f0.size(R0.indices) > 0)
        return !1;
    return !0;
  }
  Z.isEmpty = X;
  function Y($0) {
    return Q($0) === $0.structure.elementCount;
  }
  Z.isWholeStructure = Y;
  function Q($0) {
    let R0 = 0;
    for (let { indices: X0 } of $0.elements)
      if (typeof X0 === "number")
        R0 += Y61(X0);
      else
        R0 += X0.length;
    return R0;
  }
  Z.size = Q;
  function W($0) {
    return Z($0, $0.units.map((R0) => ({
      unit: R0,
      indices: f0.ofBounds(0, R0.elements.length)
    })));
  }
  Z.all = W;
  function K($0) {
    return Z($0, []);
  }
  Z.none = K;
  function G($0, R0, X0) {
    let E0;
    if (typeof R0 === "function")
      E0 = R0(L0);
    else
      E0 = R0;
    let V0 = PW(E0)(X0 !== null && X0 !== void 0 ? X0 : new C9($0));
    return f1.toLociWithSourceUnits(V0);
  }
  Z.fromExpression = G;
  function H($0, R0, X0) {
    let E0 = R0(X0 !== null && X0 !== void 0 ? X0 : new C9($0));
    return f1.toLociWithSourceUnits(E0);
  }
  Z.fromQuery = H;
  function N($0, R0, X0) {
    return o_.toLoci($0, R0, X0);
  }
  Z.fromSchema = N;
  function q($0, R0) {
    if (X($0))
      return;
    let X0 = $0.elements[0].unit, E0 = X0.elements[f0.getAt($0.elements[0].indices, 0)];
    if (R0)
      return R0.structure = $0.structure, R0.unit = $0.elements[0].unit, R0.element = E0, R0;
    return H9.create($0.structure, X0, E0);
  }
  Z.getFirstLocation = q;
  function U($0) {
    if (X($0))
      return $0;
    return Z($0.structure, [{
      unit: $0.elements[0].unit,
      indices: f0.ofSingleton(f0.start($0.elements[0].indices))
    }]);
  }
  Z.firstElement = U;
  function F($0) {
    if (X($0))
      return $0;
    return I(U($0));
  }
  Z.firstResidue = F;
  function E($0) {
    if (X($0))
      return $0;
    return x(U($0));
  }
  Z.firstChain = E;
  function R($0) {
    let R0 = [];
    for (let X0 of $0.elements) {
      let { unit: E0, indices: V0 } = X0, u0 = new Int32Array(f0.size(V0));
      f0.forEach(V0, (N0, q0) => u0[q0] = E0.elements[N0]), R0.push(E0.getChild(X1.ofSortedArray(u0)));
    }
    return s0.create(R0, { parent: $0.structure.parent });
  }
  Z.toStructure = R;
  function z($0, R0, X0) {
    if (Z.isEmpty($0))
      return;
    let E0 = X0 ? X0 : H9.create($0.structure);
    E0.structure = $0.structure;
    for (let V0 of $0.elements) {
      let { unit: u0, indices: N0 } = V0;
      E0.unit = u0;
      let { elements: q0 } = V0.unit;
      for (let A0 = 0, S0 = f0.size(N0);A0 < S0; A0++)
        E0.element = q0[f0.getAt(N0, A0)], R0(E0);
    }
  }
  Z.forEachLocation = z;
  function D($0, R0) {
    if (R0 === $0.structure)
      return $0;
    let X0 = [];
    return $0.elements.forEach((E0) => {
      if (!R0.unitMap.has(E0.unit.id))
        return;
      let V0 = R0.unitMap.get(E0.unit.id), u0 = f0.indexedIntersect(E0.indices, E0.unit.elements, V0.elements);
      if (f0.size(u0) > 0)
        X0.push({ unit: V0, indices: u0 });
    }), Z(R0, X0);
  }
  Z.remap = D;
  function A($0, R0) {
    if ($0.elements.length > R0.elements.length)
      return A(R0, $0);
    if (Z.isEmpty($0))
      return R0;
    let X0 = /* @__PURE__ */ new Map;
    for (let V0 of $0.elements)
      X0.set(V0.unit.id, V0.indices);
    let E0 = [];
    for (let V0 of R0.elements)
      if (X0.has(V0.unit.id))
        E0[E0.length] = { unit: V0.unit, indices: f0.union(X0.get(V0.unit.id), V0.indices) }, X0.delete(V0.unit.id);
      else
        E0[E0.length] = V0;
    return X0.forEach((V0, u0) => {
      E0[E0.length] = { unit: $0.structure.unitMap.get(u0), indices: V0 };
    }), Z($0.structure, E0);
  }
  Z.union = A;
  function B($0, R0) {
    let X0 = /* @__PURE__ */ new Map;
    for (let V0 of R0.elements)
      X0.set(V0.unit.id, V0.indices);
    let E0 = [];
    for (let V0 of $0.elements)
      if (X0.has(V0.unit.id)) {
        let u0 = f0.subtract(V0.indices, X0.get(V0.unit.id));
        if (f0.size(u0) === 0)
          continue;
        E0[E0.length] = { unit: V0.unit, indices: u0 };
      } else
        E0[E0.length] = V0;
    return Z($0.structure, E0);
  }
  Z.subtract = B;
  function T($0, R0) {
    let X0 = /* @__PURE__ */ new Map;
    for (let V0 of $0.elements)
      X0.set(V0.unit.id, V0.indices);
    let E0 = [];
    for (let V0 of R0.elements) {
      if (!X0.has(V0.unit.id))
        continue;
      let u0 = f0.intersect(X0.get(V0.unit.id), V0.indices);
      if (f0.size(u0) === 0)
        continue;
      E0[E0.length] = { unit: V0.unit, indices: u0 };
    }
    return Z($0.structure, E0);
  }
  Z.intersect = T;
  function w($0, R0) {
    if ($0.elements.length > R0.elements.length)
      return w(R0, $0);
    if (Z.isEmpty($0))
      return Z.isEmpty(R0);
    let X0 = /* @__PURE__ */ new Map;
    for (let E0 of $0.elements)
      X0.set(E0.unit.id, E0.indices);
    for (let E0 of R0.elements) {
      if (!X0.has(E0.unit.id))
        continue;
      if (f0.areIntersecting(X0.get(E0.unit.id), E0.indices))
        return !0;
    }
    return !1;
  }
  Z.areIntersecting = w;
  function V($0, R0) {
    if (Z.isEmpty($0))
      return Z.isEmpty(R0);
    let X0 = /* @__PURE__ */ new Map;
    for (let V0 of $0.elements)
      X0.set(V0.unit.id, V0.indices);
    let E0 = !1;
    for (let V0 of R0.elements) {
      if (!X0.has(V0.unit.id))
        return !1;
      if (!f0.isSubset(X0.get(V0.unit.id), V0.indices))
        return !1;
      else
        E0 = !0;
    }
    return E0;
  }
  Z.isSubset = V;
  function P($0) {
    if ($0.length > 3 && X1.isRange($0))
      return k0.ofRange($0[0], $0[$0.length - 1]);
    else
      return X1.ofSortedArray($0);
  }
  function I($0, R0) {
    let X0 = [], E0 = /* @__PURE__ */ new Set;
    for (let V0 of $0.elements) {
      if (f(V0)) {
        X0[X0.length] = V0;
        continue;
      }
      if (V0.unit.kind === j0.Kind.Atomic) {
        let u0 = V0.unit.elements, N0 = V0.unit.model.atomicHierarchy, { label_alt_id: q0 } = V0.unit.model.atomicHierarchy.atoms, { index: A0, offsets: S0 } = N0.residueAtomSegments, a0 = [], D1 = V0.indices, Y1 = f0.size(D1), u1 = 0;
        while (u1 < Y1) {
          E0.clear();
          let b0 = u0[f0.getAt(D1, u1)], x0 = A0[b0];
          E0.add(q0.value(b0)), u1++;
          while (u1 < Y1) {
            let e0 = u0[f0.getAt(D1, u1)];
            if (A0[e0] !== x0)
              break;
            E0.add(q0.value(e0)), u1++;
          }
          let m0 = E0.has("");
          for (let e0 = S0[x0], p = S0[x0 + 1];e0 < p; e0++) {
            let J0 = f0.indexOf(u0, e0);
            if (J0 >= 0) {
              let T0 = q0.value(e0);
              if (!R0 || m0 || !T0 || E0.has(T0))
                a0[a0.length] = J0;
            }
          }
        }
        X0[X0.length] = { unit: V0.unit, indices: P(a0) };
      } else
        X0[X0.length] = V0;
    }
    return Z($0.structure, X0);
  }
  Z.extendToWholeResidues = I;
  function S($0) {
    switch ($0.kind) {
      case j0.Kind.Atomic:
        return $0.model.atomicHierarchy.chainAtomSegments;
      case j0.Kind.Spheres:
        return $0.model.coarseHierarchy.spheres.chainElementSegments;
      case j0.Kind.Gaussians:
        return $0.model.coarseHierarchy.gaussians.chainElementSegments;
    }
  }
  function f($0) {
    return $0.unit.elements.length === f0.size($0.indices);
  }
  function v($0, R0, X0) {
    let { index: E0 } = S($0), V0 = $0.elements, u0 = 0;
    for (let q0 = 0, A0 = V0.length;q0 < A0; q0++) {
      let S0 = V0[q0], a0 = E0[S0];
      if (!R0.has(a0))
        continue;
      u0++;
    }
    if (u0 === $0.elements.length) {
      X0[X0.length] = { unit: $0, indices: k0.ofBounds(0, u0) };
      return;
    }
    let N0 = new Int32Array(u0);
    u0 = 0;
    for (let q0 = 0, A0 = V0.length;q0 < A0; q0++) {
      let S0 = V0[q0], a0 = E0[S0];
      if (!R0.has(a0))
        continue;
      N0[u0++] = q0;
    }
    if (N0.length > 0)
      X0[X0.length] = { unit: $0, indices: P(N0) };
  }
  function h($0, R0, X0, E0, V0) {
    let { index: u0 } = S($0.elements[0].unit), N0 = /* @__PURE__ */ new Set;
    for (let q0 = R0;q0 < X0; q0++) {
      let A0 = $0.elements[q0], S0 = A0.indices, a0 = A0.unit.elements;
      for (let D1 = 0, Y1 = f0.size(S0);D1 < Y1; D1++)
        N0.add(u0[a0[f0.getAt(S0, D1)]]);
    }
    if (E0) {
      let q0 = $0.elements[0].unit;
      for (let A0 of $0.structure.units) {
        if (!j0.areSameChainOperatorGroup(A0, q0))
          continue;
        v(A0, N0, V0);
      }
    } else
      for (let q0 = R0;q0 < X0; q0++)
        v($0.elements[q0].unit, N0, V0);
  }
  function x($0) {
    let R0 = [];
    for (let X0 = 0, E0 = $0.elements.length;X0 < E0; X0++) {
      let V0 = $0.elements[X0];
      if (j0.Traits.is(V0.unit.traits, j0.Trait.Partitioned)) {
        let u0 = X0;
        while (X0 < E0 && j0.areSameChainOperatorGroup($0.elements[X0].unit, V0.unit))
          X0++;
        let N0 = X0;
        X0--, h($0, u0, N0, !0, R0);
      } else if (f(V0))
        R0[R0.length] = V0;
      else
        h($0, X0, X0 + 1, !1, R0);
    }
    return Z($0.structure, R0);
  }
  Z.extendToWholeChains = x;
  function b($0) {
    return `${$0.unit.model.id}|${w1.entity.id($0)}`;
  }
  function g($0) {
    let R0 = [], X0 = H9.create($0.structure), E0 = /* @__PURE__ */ new Set, { units: V0 } = $0.structure;
    for (let u0 = 0, N0 = $0.elements.length;u0 < N0; u0++) {
      let q0 = $0.elements[u0];
      X0.unit = q0.unit, X0.element = q0.unit.elements[0], E0.add(b(X0));
    }
    for (let u0 = 0, N0 = V0.length;u0 < N0; ++u0) {
      let q0 = V0[u0];
      if (X0.unit = q0, X0.element = q0.elements[0], E0.has(b(X0))) {
        let A0 = f0.ofBounds(0, q0.elements.length);
        R0[R0.length] = { unit: q0, indices: A0 };
      }
    }
    return Z($0.structure, R0);
  }
  Z.extendToWholeEntities = g;
  function m($0) {
    let R0 = [], X0 = /* @__PURE__ */ new Set, { units: E0 } = $0.structure;
    for (let V0 = 0, u0 = $0.elements.length;V0 < u0; V0++) {
      let N0 = $0.elements[V0];
      X0.add(N0.unit.model.id);
    }
    for (let V0 = 0, u0 = E0.length;V0 < u0; ++V0) {
      let N0 = E0[V0];
      if (X0.has(N0.model.id)) {
        let q0 = f0.ofBounds(0, N0.elements.length);
        R0[R0.length] = { unit: N0, indices: q0 };
      }
    }
    return Z($0.structure, R0);
  }
  Z.extendToWholeModels = m;
  function i($0, R0) {
    let X0 = [];
    for (let E0 = 0, V0 = f0.size(R0);E0 < V0; ++E0)
      X0.push($0[f0.getAt(R0, E0)]);
    return X1.ofSortedArray(X0);
  }
  function r($0, R0) {
    if (X1.isRange($0) && X1.areEqual($0, R0))
      return k0.ofLength($0.length);
    return P(X1.indicesOf($0, R0));
  }
  function Y0($0) {
    let R0 = [], X0 = /* @__PURE__ */ new Map;
    for (let E0 = 0, V0 = $0.elements.length;E0 < V0; E0++) {
      let u0 = $0.elements[E0], { model: N0 } = u0.unit, q0 = i(u0.unit.elements, u0.indices);
      if (X0.has(N0))
        X0.set(N0, X1.union(q0, X0.get(N0)));
      else
        X0.set(N0, q0);
    }
    for (let E0 = 0, V0 = $0.structure.units.length;E0 < V0; ++E0) {
      let u0 = $0.structure.units[E0], N0 = X0.get(u0.model);
      if (!N0)
        continue;
      let q0 = r(u0.elements, N0);
      if (f0.size(q0))
        R0[R0.length] = { unit: u0, indices: q0 };
    }
    return Z($0.structure, R0);
  }
  Z.extendToAllInstances = Y0;
  function c($0) {
    let R0 = [], X0 = /* @__PURE__ */ new Set, { units: E0 } = $0.structure;
    for (let V0 = 0, u0 = $0.elements.length;V0 < u0; V0++) {
      let N0 = $0.elements[V0];
      X0.add(N0.unit.conformation.operator.name);
    }
    for (let V0 = 0, u0 = E0.length;V0 < u0; ++V0) {
      let N0 = E0[V0];
      if (X0.has(N0.conformation.operator.name)) {
        let q0 = f0.ofBounds(0, N0.elements.length);
        R0[R0.length] = { unit: N0, indices: q0 };
      }
    }
    return Z($0.structure, R0);
  }
  Z.extendToWholeOperators = c;
  let n = new $J("98"), l = M();
  function u($0, R0, X0) {
    n.reset();
    for (let E0 of $0.elements) {
      let { indices: V0 } = E0, { elements: u0, conformation: N0 } = E0.unit;
      for (let q0 = 0, A0 = f0.size(V0);q0 < A0; q0++) {
        let S0 = u0[f0.getAt(V0, q0)];
        if (N0.position(S0, l), R0)
          M.transformMat4(l, l, R0);
        n.includePositionRadius(l, N0.r(S0));
      }
    }
    n.finishedIncludeStep();
    for (let E0 of $0.elements) {
      let { indices: V0 } = E0, { elements: u0, conformation: N0 } = E0.unit;
      for (let q0 = 0, A0 = f0.size(V0);q0 < A0; q0++) {
        let S0 = u0[f0.getAt(V0, q0)];
        if (N0.position(S0, l), R0)
          M.transformMat4(l, l, R0);
        n.radiusPositionRadius(l, N0.r(S0));
      }
    }
    if (X0) {
      if (X0.box)
        n.getBox(X0.box);
      if (X0.sphere)
        n.getSphere(X0.sphere);
      return X0;
    }
    return { box: n.getBox(), sphere: n.getSphere() };
  }
  Z.getBoundary = u;
  let G0 = M();
  function F0($0, R0, X0 = 0) {
    let E0 = X0;
    for (let V0 of $0.elements) {
      let { indices: u0 } = V0, { elements: N0, conformation: q0 } = V0.unit, A0 = f0.size(u0);
      for (let S0 = 0;S0 < A0; S0++) {
        let a0 = N0[f0.getAt(u0, S0)];
        q0.position(a0, G0), M.toArray(G0, R0, E0 + S0 * 3);
      }
      E0 += A0 * 3;
    }
    return R0;
  }
  Z.toPositionsArray = F0;
  function t($0) {
    let R0 = Q($0), X0 = F0($0, new Float32Array(3 * R0));
    return HY.ofPositions(X0);
  }
  Z.getPrincipalAxes = t;
  function Z0($0) {
    let R0 = 0;
    $0.forEach((V0) => {
      R0 += Q(V0);
    });
    let X0 = new Float32Array(3 * R0), E0 = 0;
    return $0.forEach((V0) => {
      F0(V0, X0, E0), E0 += Q(V0) * 3;
    }), HY.ofPositions(X0);
  }
  Z.getPrincipalAxesMany = Z0;
  function U0($0, R0) {
    return j0.isAtomic($0) ? $0.model.atomicHierarchy.atomSourceIndex.value(R0) : R0;
  }
  function a($0) {
    if (Z.isEmpty($0))
      return L0.struct.generator.empty();
    let R0 = $0.structure.models, X0 = /* @__PURE__ */ new Map;
    for (let q0 of $0.elements) {
      let { indices: A0 } = q0, { elements: S0 } = q0.unit, a0 = q0.unit.conformation.operator.name, D1;
      if (X0.has(a0))
        D1 = X0.get(a0).xs;
      else
        D1 = o6.create(), X0.set(a0, { modelLabel: q0.unit.model.label, modelIndex: q0.unit.model.modelNum, xs: D1 });
      for (let Y1 = 0, u1 = f0.size(A0);Y1 < u1; Y1++) {
        let b0 = U0(q0.unit, S0[f0.getAt(A0, Y1)]);
        o6.add(D1, b0, b0);
      }
    }
    let E0 = [], V0 = X0.keys();
    while (!0) {
      let q0 = V0.next();
      if (q0.done)
        break;
      let A0 = X0.get(q0.value);
      E0.push(Q0(q0.value, A0.xs.array, R0.length > 1, A0.modelLabel, A0.modelIndex));
    }
    let u0 = /* @__PURE__ */ new Map;
    for (let q0 = 0, A0 = E0.length;q0 < A0; ++q0) {
      let S0 = E0[q0], D1 = `${SQ(l9(S0.atom.ranges), l9(S0.atom.set))}|${S0.entity ? S0.entity.modelLabel + S0.entity.modelIndex : ""}`;
      if (u0.has(D1))
        u0.get(D1).chain.opName.push(...S0.chain.opName);
      else
        u0.set(D1, S0);
    }
    let N0 = [];
    return u0.forEach((q0) => {
      let { ranges: A0, set: S0 } = q0.atom, { opName: a0 } = q0.chain, D1 = L0.struct.atomProperty.core.operatorName(), Y1 = L0.struct.atomProperty.core.sourceIndex(), u1 = [];
      if (S0.length > 0)
        u1[u1.length] = L0.core.set.has([L0.core.type.set(S0), Y1]);
      for (let b0 = 0, x0 = A0.length / 2;b0 < x0; b0++)
        u1[u1.length] = L0.core.rel.inRange([Y1, A0[2 * b0], A0[2 * b0 + 1]]);
      if (q0.entity) {
        let { modelLabel: b0, modelIndex: x0 } = q0.entity;
        N0.push(L0.struct.generator.atomGroups({
          "atom-test": u1.length > 1 ? L0.core.logic.or(u1) : u1[0],
          "chain-test": a0.length > 1 ? L0.core.set.has([L0.core.type.set(a0), D1]) : L0.core.rel.eq([D1, a0[0]]),
          "entity-test": L0.core.logic.and([
            L0.core.rel.eq([L0.struct.atomProperty.core.modelLabel(), b0]),
            L0.core.rel.eq([L0.struct.atomProperty.core.modelIndex(), x0])
          ])
        }));
      } else
        N0.push(L0.struct.generator.atomGroups({
          "atom-test": u1.length > 1 ? L0.core.logic.or(u1) : u1[0],
          "chain-test": a0.length > 1 ? L0.core.set.has([L0.core.type.set(a0), D1]) : L0.core.rel.eq([D1, a0[0]])
        }));
    }), L0.struct.modifier.union([
      N0.length === 1 ? N0[0] : L0.struct.combinator.merge(N0.map((q0) => L0.struct.modifier.union([q0])))
    ]);
  }
  Z.toExpression = a;
  function Q0($0, R0, X0, E0, V0) {
    t$(R0);
    let u0 = [], N0 = [], q0 = 0, A0 = R0.length;
    while (q0 < A0) {
      let S0 = q0;
      q0++;
      while (q0 < A0 && R0[q0 - 1] + 1 === R0[q0])
        q0++;
      let a0 = q0;
      if (a0 - S0 > 12)
        u0[u0.length] = R0[S0], u0[u0.length] = R0[a0 - 1];
      else
        for (let D1 = S0;D1 < a0; D1++)
          N0[N0.length] = R0[D1];
    }
    return X0 ? {
      atom: { set: N0, ranges: u0 },
      chain: { opName: [$0] },
      entity: { modelLabel: E0, modelIndex: V0 }
    } : {
      atom: { set: N0, ranges: u0 },
      chain: { opName: [$0] }
    };
  }
})(B3 || (B3 = {}));
// node_modules/molstar/lib/mol-model/structure/structure/element/stats.js
var Ws;
(function(Z) {
  function J() {
    return {
      elementCount: 0,
      conformationCount: 0,
      residueCount: 0,
      chainCount: 0,
      unitCount: 0,
      structureCount: 0,
      firstElementLoc: H9.create(void 0),
      firstConformationLoc: H9.create(void 0),
      firstResidueLoc: H9.create(void 0),
      firstChainLoc: H9.create(void 0),
      firstUnitLoc: H9.create(void 0),
      firstStructureLoc: H9.create(void 0)
    };
  }
  Z.create = J;
  function $(G, H, N) {
    let q = G.get(H) || 0;
    G.set(H, q + N);
  }
  function X(G, H, N) {
    let { indices: q, unit: U } = N, { elements: F } = U, E = f0.size(q), R = /* @__PURE__ */ new Map, z = /* @__PURE__ */ new Map;
    if (E > 0)
      H9.set(G.firstElementLoc, H, U, F[f0.start(q)]);
    if (E === F.length) {
      if (G.unitCount += 1, G.unitCount === 1)
        H9.set(G.firstUnitLoc, H, U, F[f0.start(q)]);
    } else if (E === 1) {
      if (j0.Traits.is(U.traits, j0.Trait.MultiChain))
        return;
      else if (G.elementCount += 1, G.elementCount === 1)
        H9.set(G.firstElementLoc, H, U, F[f0.start(q)]);
    } else if (j0.isAtomic(U)) {
      let { index: D, offsets: A } = U.model.atomicHierarchy.residueAtomSegments, { label_alt_id: B } = U.model.atomicHierarchy.atoms, T = 0;
      while (T < E) {
        R.clear();
        let w = 0, V = F[f0.getAt(q, T)], P = D[V];
        $(R, B.value(V), 1), ++T, ++w;
        while (T < E) {
          let I = F[f0.getAt(q, T)];
          if (D[I] !== P)
            break;
          $(R, B.value(I), 1), ++T, ++w;
        }
        if (A[P + 1] - A[P] === w) {
          if (G.residueCount += 1, G.residueCount === 1)
            H9.set(G.firstResidueLoc, H, U, A[P]);
        } else {
          z.clear();
          for (let I = A[P], S = A[P + 1];I < S; ++I)
            $(z, B.value(I), 1);
          if (z.get("") === R.get(""))
            R.forEach((I, S) => {
              if (z.get(S) !== I)
                return;
              if (S !== "") {
                if (G.conformationCount += 1, G.conformationCount === 1) {
                  for (let f = A[P], v = A[P + 1];f < v; ++f)
                    if (S === B.value(f)) {
                      H9.set(G.firstConformationLoc, H, U, f);
                      break;
                    }
                }
              }
              w -= I;
            });
          G.elementCount += w;
        }
      }
    } else if (G.elementCount += E, G.elementCount === 1)
      H9.set(G.firstElementLoc, H, U, F[f0.start(q)]);
  }
  function Y(G, H, N) {
    let { indices: q, unit: U } = N, F = f0.size(q);
    if (F === 0)
      return;
    let { elements: E } = U;
    if (!j0.Traits.is(U.traits, j0.Trait.MultiChain)) {
      if (F === E.length) {
        if (G.chainCount += 1, G.chainCount === 1)
          H9.set(G.firstChainLoc, H, U, E[f0.start(q)]);
      }
      return;
    }
    let R = j0.isAtomic(U) ? U.model.atomicHierarchy.chainAtomSegments : j0.isSpheres(U) ? U.model.coarseHierarchy.spheres.chainElementSegments : j0.isGaussians(U) ? U.model.coarseHierarchy.gaussians.chainElementSegments : void 0;
    if (!R) {
      console.warn("StructureElement loci stats: unknown unit type");
      return;
    }
    let { index: z, offsets: D } = R, A = 0;
    while (A < F) {
      let B = 0, T = E[f0.getAt(q, A)], w = z[T];
      ++A, ++B;
      while (A < F) {
        let V = E[f0.getAt(q, A)];
        if (z[V] !== w)
          break;
        ++A, ++B;
      }
      if (D[w + 1] - D[w] === B) {
        if (G.chainCount += 1, G.chainCount === 1)
          H9.set(G.firstChainLoc, H, U, D[w]);
      } else if (F === 1) {
        if (G.elementCount += 1, G.elementCount === 1)
          H9.set(G.firstElementLoc, H, U, T);
      }
    }
  }
  function Q(G, H, N, q, U) {
    let F = N[q], E = j0.isAtomic(F.unit) ? F.unit.model.atomicHierarchy.chainAtomSegments : j0.isSpheres(F.unit) ? F.unit.model.coarseHierarchy.spheres.chainElementSegments : j0.isGaussians(F.unit) ? F.unit.model.coarseHierarchy.gaussians.chainElementSegments : void 0;
    if (!E) {
      console.warn("StructureElement loci stats: unknown unit type");
      return;
    }
    let { index: R, offsets: z } = E, D = /* @__PURE__ */ new Map;
    for (let B = q;B < U; B++) {
      F = N[B];
      let { indices: T, unit: w } = F, V = f0.size(T);
      if (V === 0)
        continue;
      let { elements: P } = w;
      if (!j0.Traits.is(w.traits, j0.Trait.MultiChain)) {
        let S = P[f0.start(T)];
        $(D, R[S], P.length);
        continue;
      }
      let I = 0;
      while (I < V) {
        let S = 0, f = P[f0.getAt(T, I)], v = R[f];
        ++I, ++S;
        while (I < V) {
          let h = P[f0.getAt(T, I)];
          if (R[h] !== v)
            break;
          ++I, ++S;
        }
        $(D, v, S);
      }
    }
    let A = -1;
    if (D.forEach((B, T) => {
      if (z[T + 1] - z[T] === B) {
        if (G.chainCount += 1, G.chainCount === 1)
          A = T;
      }
    }), A < 0)
      return;
    for (let B = q;B < U; B++) {
      F = N[B];
      let { indices: T, unit: w } = F, V = f0.size(T);
      if (V === 0)
        continue;
      let { elements: P } = w, I = 0;
      while (I < V) {
        let S = P[f0.getAt(T, I)];
        if (R[S] === A) {
          H9.set(G.firstChainLoc, H, w, S);
          return;
        }
      }
    }
  }
  function W(G) {
    let H = J();
    if (B3.isEmpty(G))
      return H;
    let N = !1;
    if (B3.isWholeStructure(G)) {
      if (H.structureCount += 1, H.structureCount === 1) {
        let { unit: q, indices: U } = G.elements[0];
        H9.set(H.firstStructureLoc, G.structure, q, q.elements[f0.min(U)]);
      }
    } else
      for (let q of G.elements)
        if (X(H, G.structure, q), !j0.Traits.is(q.unit.traits, j0.Trait.Partitioned))
          Y(H, G.structure, q);
        else
          N = !0;
    if (N)
      for (let q = 0, U = G.elements.length;q < U; q++) {
        let F = G.elements[q];
        if (!j0.Traits.is(F.unit.traits, j0.Trait.Partitioned))
          continue;
        let E = q;
        while (q < U && j0.areSameChainOperatorGroup(G.elements[q].unit, F.unit))
          q++;
        let R = q;
        if (q--, R - E === 1)
          Y(H, G.structure, F);
        else
          Q(H, G.structure, G.elements, E, R);
      }
    return H;
  }
  Z.ofLoci = W;
  function K(G, H, N) {
    if (H.elementCount === 1 && N.elementCount === 0)
      H9.copy(G.firstElementLoc, H.firstElementLoc);
    else if (H.elementCount === 0 && N.elementCount === 1)
      H9.copy(G.firstElementLoc, N.firstElementLoc);
    if (H.conformationCount === 1 && N.conformationCount === 0)
      H9.copy(G.firstConformationLoc, H.firstConformationLoc);
    else if (H.conformationCount === 0 && N.conformationCount === 1)
      H9.copy(G.firstConformationLoc, N.firstConformationLoc);
    if (H.residueCount === 1 && N.residueCount === 0)
      H9.copy(G.firstResidueLoc, H.firstResidueLoc);
    else if (H.residueCount === 0 && N.residueCount === 1)
      H9.copy(G.firstResidueLoc, N.firstResidueLoc);
    if (H.chainCount === 1 && N.chainCount === 0)
      H9.copy(G.firstChainLoc, H.firstChainLoc);
    else if (H.chainCount === 0 && N.chainCount === 1)
      H9.copy(G.firstChainLoc, N.firstChainLoc);
    if (H.unitCount === 1 && N.unitCount === 0)
      H9.copy(G.firstUnitLoc, H.firstUnitLoc);
    else if (H.unitCount === 0 && N.unitCount === 1)
      H9.copy(G.firstUnitLoc, N.firstUnitLoc);
    if (H.structureCount === 1 && N.structureCount === 0)
      H9.copy(G.firstStructureLoc, H.firstStructureLoc);
    else if (H.structureCount === 0 && N.structureCount === 1)
      H9.copy(G.firstStructureLoc, N.firstStructureLoc);
    return G.elementCount = H.elementCount + N.elementCount, G.conformationCount = H.conformationCount + N.conformationCount, G.residueCount = H.residueCount + N.residueCount, G.chainCount = H.chainCount + N.chainCount, G.unitCount = H.unitCount + N.unitCount, G.structureCount = H.structureCount + N.structureCount, G;
  }
  Z.add = K;
})(Ws || (Ws = {}));
// node_modules/molstar/lib/mol-model/structure/structure/element/util.js
function Ks(Z) {
  return Z;
}
function $F0(Z) {
  throw new Error(`Property only available for ${Z} models.`);
}
function Q61(Z) {
  return Ks((J) => j0.isAtomic(J.unit) ? Z(J) : $F0("atomic"));
}
function W61(Z) {
  return Ks((J) => j0.isCoarse(J.unit) ? Z(J) : $F0("coarse"));
}
function K61(Z) {
  if (j0.isAtomic(Z.unit))
    return Z.unit.residueIndex[Z.element];
  else
    return -1;
}
function G61(Z) {
  if (j0.isAtomic(Z.unit))
    return Z.unit.chainIndex[Z.element];
  else
    return -1;
}
function H61(Z) {
  return w1.entity.key(Z);
}
// node_modules/molstar/lib/mol-io/reader/common/text/tokenizer.js
function Z2(Z) {
  return {
    data: Z,
    position: 0,
    length: Z.length,
    lineNumber: 1,
    tokenStart: 0,
    tokenEnd: 0
  };
}
(function(Z) {
  function J(B) {
    return B.data.substring(B.tokenStart, B.tokenEnd);
  }
  Z.getTokenString = J;
  function $(B) {
    B.position = 0, B.lineNumber = 1, B.tokenStart = 0, B.tokenEnd = 0;
  }
  Z.reset = $;
  function X(B) {
    let { data: T } = B;
    while (B.position < B.length)
      switch (T.charCodeAt(B.position)) {
        case 10:
          return B.tokenEnd = B.position, ++B.position, ++B.lineNumber, !0;
        case 13:
          if (B.tokenEnd = B.position, ++B.position, ++B.lineNumber, T.charCodeAt(B.position) === 10)
            ++B.position;
          return !0;
        default:
          ++B.position;
          break;
      }
    return B.tokenEnd = B.position, B.tokenStart !== B.tokenEnd;
  }
  Z.eatLine = X;
  function Y(B) {
    B.tokenStart = B.position;
  }
  Z.markStart = Y;
  function Q(B) {
    return B.tokenStart = B.position, X(B);
  }
  Z.markLine = Q;
  function W(B) {
    return Q(B), J(B);
  }
  Z.readLine = W;
  function K(B) {
    Q(B);
    let T = B.position;
    return A(B, B.tokenStart, B.tokenEnd), B.position = T, J(B);
  }
  Z.readLineTrim = K;
  function G(B, T, w) {
    let V = 0;
    for (let P = 0;P < T; P++) {
      if (!Q(B))
        return V;
      G1.addUnchecked(w, B.tokenStart, B.tokenEnd), V++;
    }
    return V;
  }
  function H(B, T) {
    let w = G1.create(B.data, T * 2);
    return G(B, T, w), w;
  }
  Z.markLines = H;
  function N(B, T) {
    let w = [];
    for (let V = 0;V < T; V++)
      w.push(Z.readLine(B));
    return w;
  }
  Z.readLines = N;
  async function q(B, T, w, V = 1e5) {
    let P = G1.create(B.data, T * 2), I = 0;
    return await K$(w, V, B, (S, f) => {
      let v = Math.min(T - I, S);
      return G(f, v, P), I += v, v;
    }, (S, f) => S.update({ message: "Parsing...", current: f.position, max: f.length })), P;
  }
  Z.readLinesAsync = q;
  function U(B) {
    let T = Z(B), w = G1.create(T.data, Math.max(B.length / 80, 2));
    while (Q(T))
      G1.add(w, T.tokenStart, T.tokenEnd);
    return w;
  }
  Z.readAllLines = U;
  function F(B, T, w) {
    let V = 0;
    for (let P = 0;P < T; P++) {
      if (!Q(B))
        return V;
      G1.add(w, B.tokenStart, B.tokenEnd), V++;
    }
    return V;
  }
  async function E(B, T, w = 1e5) {
    let V = Z(B), P = G1.create(V.data, Math.max(B.length / 80, 2));
    return await K$(T, w, V, (I, S) => {
      return F(S, I, P), S.position < S.length ? I : 0;
    }, (I, S) => I.update({ message: "Parsing...", current: S.position, max: S.length })), P;
  }
  Z.readAllLinesAsync = E;
  function R(B) {
    while (B.position < B.length)
      switch (B.data.charCodeAt(B.position)) {
        case 9:
        case 10:
        case 13:
        case 32:
          B.tokenEnd = B.position;
          return;
        default:
          ++B.position;
          break;
      }
    B.tokenEnd = B.position;
  }
  Z.eatValue = R;
  function z(B) {
    let T = -1;
    while (B.position < B.length) {
      let w = B.data.charCodeAt(B.position);
      switch (w) {
        case 9:
        case 32:
          T = w, ++B.position;
          break;
        case 10:
          if (T !== 13)
            ++B.lineNumber;
          T = w, ++B.position;
          break;
        case 13:
          T = w, ++B.position, ++B.lineNumber;
          break;
        default:
          return T;
      }
    }
    return T;
  }
  Z.skipWhitespace = z;
  function D(B) {
    let T = -1;
    while (B.position < B.length) {
      let w = B.data.charCodeAt(B.position);
      switch (w) {
        case 9:
        case 32:
          T = w, ++B.position;
          break;
        default:
          return T;
      }
    }
    return T;
  }
  Z.skipStrictWhitespace = D;
  function A(B, T, w) {
    let { data: V } = B, P = T, I = w - 1, S = V.charCodeAt(P);
    while ((S === 9 || S === 32) && P <= I)
      S = V.charCodeAt(++P);
    S = V.charCodeAt(I);
    while ((S === 9 || S === 32) && I >= P)
      S = V.charCodeAt(--I);
    return B.tokenStart = P, B.tokenEnd = I + 1, B.position = w, B;
  }
  Z.trim = A;
})(Z2 || (Z2 = {}));
function XF0(Z, J, $) {
  let X = J, Y = $ - 1, Q = Z.charCodeAt(X);
  while ((Q === 9 || Q === 32) && X <= Y)
    Q = Z.charCodeAt(++X);
  Q = Z.charCodeAt(Y);
  while ((Q === 9 || Q === 32) && Y >= X)
    Q = Z.charCodeAt(--Y);
  return Z.substring(X, Y + 1);
}
var G1;
(function(Z) {
  function J(W) {
    let K = new Uint32Array(1.61 * W.indices.length | 0);
    K.set(W.indices), W.indices = K, W.indicesLenMinus2 = K.length - 2 | 0;
  }
  function $(W, K, G) {
    let H = W;
    if (H.offset > H.indicesLenMinus2)
      J(H);
    H.indices[H.offset++] = K, H.indices[H.offset++] = G, W.count++;
  }
  Z.add = $;
  function X(W, K) {
    $(W, K.tokenStart, K.tokenEnd);
  }
  Z.addToken = X;
  function Y(W, K, G) {
    W.indices[W.offset++] = K, W.indices[W.offset++] = G, W.count++;
  }
  Z.addUnchecked = Y;
  function Q(W, K) {
    return K = Math.max(10, K), {
      data: W,
      indicesLenMinus2: K - 2 | 0,
      count: 0,
      offset: 0,
      indices: new Uint32Array(K)
    };
  }
  Z.create = Q;
})(G1 || (G1 = {}));

// node_modules/molstar/lib/mol-io/reader/result.js
var a8;
(function(Z) {
  function J(Q, W = -1) {
    return new X(Q, W);
  }
  Z.error = J;
  function $(Q, W = []) {
    return new Y(Q, W);
  }
  Z.success = $;

  class X {
    toString() {
      if (this.line >= 0)
        return `[Line ${this.line}] ${this.message}`;
      return this.message;
    }
    constructor(Q, W) {
      this.message = Q, this.line = W, this.isError = !0;
    }
  }
  Z.Error = X;

  class Y {
    constructor(Q, W) {
      this.result = Q, this.warnings = W, this.isError = !1;
    }
  }
  Z.Success = Y;
})(a8 || (a8 = {}));

// node_modules/molstar/lib/mol-io/reader/cif/text/parser.js
var EJ;
(function(Z) {
  Z[Z.Data = 0] = "Data", Z[Z.Save = 1] = "Save", Z[Z.Loop = 2] = "Loop", Z[Z.Value = 3] = "Value", Z[Z.ColumnName = 4] = "ColumnName", Z[Z.Comment = 5] = "Comment", Z[Z.End = 6] = "End";
})(EJ || (EJ = {}));
function YF0(Z) {
  while (Z.position < Z.length)
    switch (Z.data.charCodeAt(Z.position)) {
      case 9:
      case 10:
      case 13:
      case 32:
        Z.tokenEnd = Z.position;
        return;
      default:
        ++Z.position;
        break;
    }
  Z.tokenEnd = Z.position;
}
function N61(Z, J) {
  let $, X;
  ++Z.position;
  while (Z.position < Z.length)
    if (X = Z.data.charCodeAt(Z.position), X === J)
      switch ($ = Z.data.charCodeAt(Z.position + 1), $) {
        case 9:
        case 10:
        case 13:
        case 32:
          Z.tokenStart++, Z.tokenEnd = Z.position, Z.isEscaped = !0, ++Z.position;
          return;
        default:
          if (!Number.isFinite($)) {
            Z.tokenStart++, Z.tokenEnd = Z.position, Z.isEscaped = !0, ++Z.position;
            return;
          }
          ++Z.position;
          break;
      }
    else {
      if (X === 10 || X === 13) {
        Z.tokenEnd = Z.position;
        return;
      }
      ++Z.position;
    }
  Z.tokenEnd = Z.position;
}
function q61(Z) {
  Z.position += 3;
  while (Z.position < Z.length) {
    if (Z.data.charCodeAt(Z.position) === 39 && KF0(Z)) {
      Z.tokenStart += 3, Z.tokenEnd = Z.position, Z.isEscaped = !0, Z.position += 3;
      return;
    }
    ++Z.position;
  }
  Z.tokenEnd = Z.position;
}
function F61(Z) {
  let J = 59, $ = Z.position + 1, X;
  while ($ < Z.length)
    if (X = Z.data.charCodeAt($), X === 59 && (J === 10 || J === 13)) {
      Z.position = $ + 1, Z.tokenStart++, $--, X = Z.data.charCodeAt($);
      while (X === 10 || X === 13)
        $--, X = Z.data.charCodeAt($);
      Z.tokenEnd = $ + 1, Z.isEscaped = !0;
      return;
    } else {
      if (X === 13)
        Z.lineNumber++;
      else if (X === 10 && J !== 13)
        Z.lineNumber++;
      J = X, ++$;
    }
  return Z.position = $, J;
}
function U61(Z) {
  while (Z.position < Z.length)
    switch (Z.data.charCodeAt(Z.position)) {
      case 93:
        ++Z.position, Z.tokenEnd = Z.position, Z.isImportGet = !1;
        return;
      default:
        ++Z.position;
        break;
    }
}
function L61(Z) {
  while (Z.position < Z.length) {
    let J = Z.data.charCodeAt(Z.position);
    if (J === 10 || J === 13)
      return;
    ++Z.position;
  }
}
function R61(Z) {
  let J = 10;
  while (Z.position < Z.length) {
    let $ = Z.data.charCodeAt(Z.position);
    switch ($) {
      case 9:
      case 32:
        J = $, ++Z.position;
        break;
      case 10:
        if (J !== 13)
          ++Z.lineNumber;
        J = $, ++Z.position;
        break;
      case 13:
        J = $, ++Z.position, ++Z.lineNumber;
        break;
      default:
        return J;
    }
  }
  return J;
}
function KF0(Z) {
  if (Z.length - Z.position < 2)
    return !1;
  if (Z.data.charCodeAt(Z.position + 1) !== 39)
    return !1;
  if (Z.data.charCodeAt(Z.position + 2) !== 39)
    return !1;
  return !0;
}
function E61(Z) {
  let J = Z.data.charCodeAt(Z.tokenStart);
  if (J !== 68 && J !== 100)
    return !1;
  if (J = Z.data.charCodeAt(Z.tokenStart + 1), J !== 65 && J !== 97)
    return !1;
  if (J = Z.data.charCodeAt(Z.tokenStart + 2), J !== 84 && J !== 116)
    return !1;
  if (J = Z.data.charCodeAt(Z.tokenStart + 3), J !== 65 && J !== 97)
    return !1;
  return !0;
}
function O61(Z) {
  let J = Z.data.charCodeAt(Z.tokenStart);
  if (J !== 83 && J !== 115)
    return !1;
  if (J = Z.data.charCodeAt(Z.tokenStart + 1), J !== 65 && J !== 97)
    return !1;
  if (J = Z.data.charCodeAt(Z.tokenStart + 2), J !== 86 && J !== 118)
    return !1;
  if (J = Z.data.charCodeAt(Z.tokenStart + 3), J !== 69 && J !== 101)
    return !1;
  return !0;
}
function z61(Z) {
  if (Z.tokenEnd - Z.tokenStart !== 5)
    return !1;
  let J = Z.data.charCodeAt(Z.tokenStart);
  if (J !== 76 && J !== 108)
    return !1;
  if (J = Z.data.charCodeAt(Z.tokenStart + 1), J !== 79 && J !== 111)
    return !1;
  if (J = Z.data.charCodeAt(Z.tokenStart + 2), J !== 79 && J !== 111)
    return !1;
  if (J = Z.data.charCodeAt(Z.tokenStart + 3), J !== 80 && J !== 112)
    return !1;
  return !0;
}
function D61(Z) {
  if (Z.tokenEnd - Z.tokenStart !== 11)
    return !1;
  if (Z.data.charCodeAt(Z.tokenStart + 1) !== 105)
    return !1;
  if (Z.data.charCodeAt(Z.tokenStart + 2) !== 109)
    return !1;
  if (Z.data.charCodeAt(Z.tokenStart + 3) !== 112)
    return !1;
  if (Z.data.charCodeAt(Z.tokenStart + 4) !== 111)
    return !1;
  if (Z.data.charCodeAt(Z.tokenStart + 5) !== 114)
    return !1;
  if (Z.data.charCodeAt(Z.tokenStart + 6) !== 116)
    return !1;
  if (Z.data.charCodeAt(Z.tokenStart + 7) !== 46)
    return !1;
  if (Z.data.charCodeAt(Z.tokenStart + 8) !== 103)
    return !1;
  if (Z.data.charCodeAt(Z.tokenStart + 9) !== 101)
    return !1;
  if (Z.data.charCodeAt(Z.tokenStart + 10) !== 116)
    return !1;
  return !0;
}
function M61(Z, J, $) {
  let X, Y = $ - J, Q = Z.tokenStart - J, W = Z.tokenEnd - Z.tokenStart;
  if (W < Y)
    return !1;
  for (X = J;X < $; ++X)
    if (Z.data.charCodeAt(X) !== Z.data.charCodeAt(X + Q))
      return !1;
  if (Y === W)
    return !0;
  if (Z.data.charCodeAt(X + Q) === 46)
    return !0;
  return !1;
}
function GF0(Z) {
  let J;
  for (J = Z.tokenStart;J < Z.tokenEnd; ++J)
    if (Z.data.charCodeAt(J) === 46)
      return J;
  return J;
}
function HF0(Z, J) {
  return Z.data.substring(Z.tokenStart, J);
}
function A61(Z) {
  let J;
  for (J = Z.tokenStart;J < Z.tokenEnd; ++J)
    if (Z.data.charCodeAt(J) === 46)
      return !1;
  return !0;
}
function Gs(Z) {
  return Z.data.substring(Z.tokenStart, Z.tokenEnd);
}
function QF0(Z) {
  let J = R61(Z);
  if (Z.position >= Z.length) {
    Z.tokenType = EJ.End;
    return;
  }
  Z.tokenStart = Z.position, Z.tokenEnd = Z.position, Z.isEscaped = !1;
  let $ = Z.data.charCodeAt(Z.position);
  switch ($) {
    case 35:
      L61(Z), Z.tokenType = EJ.Comment;
      break;
    case 39:
      if (KF0(Z)) {
        q61(Z), Z.tokenType = EJ.Value;
        break;
      }
    case 34:
      N61(Z, $), Z.tokenType = EJ.Value;
      break;
    case 59:
      if (J === 10 || J === 13)
        F61(Z);
      else
        YF0(Z);
      Z.tokenType = EJ.Value;
      break;
    default:
      if (Z.isImportGet)
        U61(Z);
      else
        YF0(Z);
      if (Z.isEscaped)
        Z.tokenType = EJ.Value;
      else if (Z.data.charCodeAt(Z.tokenStart) === 95) {
        if (Z.inSaveFrame && D61(Z))
          Z.isImportGet = !0;
        Z.tokenType = EJ.ColumnName;
      } else if (Z.tokenEnd - Z.tokenStart >= 5 && Z.data.charCodeAt(Z.tokenStart + 4) === 95)
        if (E61(Z))
          Z.tokenType = EJ.Data;
        else if (O61(Z))
          Z.tokenType = EJ.Save;
        else if (z61(Z))
          Z.tokenType = EJ.Loop;
        else
          Z.tokenType = EJ.Value;
      else
        Z.tokenType = EJ.Value;
      break;
  }
}
function TR(Z) {
  QF0(Z);
  while (Z.tokenType === EJ.Comment)
    QF0(Z);
}
function B61(Z, J) {
  return {
    data: Z,
    length: Z.length,
    position: 0,
    tokenStart: 0,
    tokenEnd: 0,
    tokenType: EJ.End,
    lineNumber: 1,
    isEscaped: !1,
    isImportGet: !1,
    inSaveFrame: !1,
    runtimeCtx: J
  };
}
function Wh() {
  return { categoryNames: [], categoryData: Object.create(null) };
}
function Ns(Z, J) {
  let $ = Object.create(null);
  for (let X of Z) {
    let Y = J[X];
    $[X] = YJ(Y.name, Y.rowCount, Y.fieldNames, Y.fields);
  }
  return $;
}
function WF0(Z, J, $) {
  return m_(Z.categoryNames, Ns(Z.categoryNames, Z.categoryData), J, $);
}
function w61(Z, J) {
  return m_(Z.categoryNames, Ns(Z.categoryNames, Z.categoryData), J);
}
function Hs(Z, J, $, X, Y) {
  if (J in Z.categoryData) {
    let Q = Z.categoryData[J];
    Q.fieldNames.push(...X), Object.assign(Q.fields, Y);
  } else
    Z.categoryData[J] = { name: J, rowCount: $, fieldNames: X, fields: Y }, Z.categoryNames.push(J);
}
function j61(Z, J) {
  let $ = Z.tokenStart, X = GF0(Z), Y = HF0(Z, X), Q = Object.create(null), W = [], K = !0;
  while (K) {
    if (Z.tokenType !== EJ.ColumnName || !M61(Z, $, X)) {
      K = !1;
      break;
    }
    let G = Gs(Z).substring(Y.length + 1);
    if (TR(Z), Z.tokenType !== EJ.Value)
      return {
        hasError: !0,
        errorLine: Z.lineNumber,
        errorMessage: "Expected value."
      };
    Q[G] = K2.ofTokens({ data: Z.data, indices: [Z.tokenStart, Z.tokenEnd], count: 1 }), W[W.length] = G, TR(Z);
  }
  return Hs(J, Y.substr(1), 1, W, Q), {
    hasError: !1,
    errorLine: 0,
    errorMessage: ""
  };
}
function T61(Z, J) {
  let { tokenizer: $, tokens: X, fieldCount: Y } = J, Q = J.tokenCount, W = 0;
  while ($.tokenType === EJ.Value && W < Z)
    G1.add(X[Q++ % Y], $.tokenStart, $.tokenEnd), TR($), W++;
  return J.tokenCount = Q, W;
}
function _61(Z, J) {
  return Z.update({ message: "Parsing...", current: J.tokenizer.position, max: J.tokenizer.data.length });
}
async function V61(Z, J) {
  let $ = Z.lineNumber;
  TR(Z);
  let X = HF0(Z, GF0(Z)), Y = A61(Z), Q = [];
  while (Z.tokenType === EJ.ColumnName)
    Q[Q.length] = Y ? Gs(Z) : Gs(Z).substring(X.length + 1), TR(Z);
  let W = X === "_atom_site" ? Z.data.length / 100 | 0 : 32, K = [], G = Q.length;
  for (let q = 0;q < G; q++)
    K[q] = G1.create(Z.data, W);
  let H = {
    fieldCount: G,
    tokenCount: 0,
    tokenizer: Z,
    tokens: K
  };
  if (await K$(Z.runtimeCtx, 1e6, H, T61, _61), H.tokenCount % G !== 0)
    return {
      hasError: !0,
      errorLine: Z.lineNumber,
      errorMessage: `The number of values for loop starting at line ${$} is not a multiple of the number of columns.`
    };
  let N = H.tokenCount / G | 0;
  if (Y)
    for (let q = 0;q < G; q++) {
      let U = { "": K2.ofTokens(K[q]) };
      Hs(J, Q[q].substr(1), N, [""], U);
    }
  else {
    let q = Object.create(null);
    for (let U = 0;U < G; U++)
      q[Q[U]] = K2.ofTokens(K[U]);
    Hs(J, X.substr(1), N, Q, q);
  }
  return {
    hasError: !1,
    errorLine: 0,
    errorMessage: ""
  };
}
function KA(Z, J) {
  return a8.error(J, Z);
}
function I61(Z) {
  return a8.success(Z);
}
async function P61(Z, J) {
  let $ = [], X = B61(Z, J), Y = "", Q = Wh(), W = [], K = Wh(), G = WN0(K.categoryNames, Ns(K.categoryNames, K.categoryData), ""), H = "";
  J.update({ message: "Parsing...", current: 0, max: Z.length }), TR(X);
  while (X.tokenType !== EJ.End) {
    let N = X.tokenType;
    if (N === EJ.Data) {
      if (X.inSaveFrame)
        return KA(X.lineNumber, "Unexpected data block inside a save frame.");
      if (Q.categoryNames.length > 0)
        $.push(WF0(Q, Y, W));
      Y = Z.substring(X.tokenStart + 5, X.tokenEnd), Q = Wh(), W = [], TR(X);
    } else if (N === EJ.Save) {
      if (X.tokenEnd - X.tokenStart === 5) {
        if (K.categoryNames.length > 0)
          W[W.length] = w61(K, H);
        X.inSaveFrame = !1;
      } else {
        if (X.inSaveFrame)
          return KA(X.lineNumber, "Save frames cannot be nested.");
        X.inSaveFrame = !0, H = Z.substring(X.tokenStart + 5, X.tokenEnd), K = Wh();
      }
      TR(X);
    } else if (N === EJ.Loop) {
      let q = await V61(X, X.inSaveFrame ? K : Q);
      if (q.hasError)
        return KA(q.errorLine, q.errorMessage);
    } else if (N === EJ.ColumnName) {
      let q = j61(X, X.inSaveFrame ? K : Q);
      if (q.hasError)
        return KA(q.errorLine, q.errorMessage);
    } else
      return console.log(X.tokenType, Z2.getTokenString(X)), KA(X.lineNumber, "Unexpected token. Expected data_, loop_, or data name.");
  }
  if (X.inSaveFrame)
    return KA(X.lineNumber, `Unfinished save frame (${G.header}).`);
  if (Q.categoryNames.length > 0 || W.length > 0)
    $.push(WF0(Q, Y, W));
  return I61(hf($));
}
function qs(Z) {
  return n0.create("Parse CIF", async (J) => {
    return await P61(Z, J);
  });
}

// node_modules/molstar/lib/mol-io/reader/cif/binary/field.js
function NF0(Z) {
  let J = Z.mask ? sM(Z.mask) : void 0, $ = sM(Z.data), X = w7.isTypedArray($), Y = X ? J ? (H) => J[H] === s.ValueKinds.Present ? "" + $[H] : "" : (H) => "" + $[H] : J ? (H) => J[H] === s.ValueKinds.Present ? $[H] : "" : (H) => $[H], Q = X ? (H) => $[H] : (H) => {
    let N = $[H];
    return z3(N, 0, N.length);
  }, W = X ? (H) => $[H] : (H) => {
    let N = $[H];
    return _W(N, 0, N.length);
  }, K = J ? (H) => J[H] : (H) => s.ValueKinds.Present, G = $.length;
  return {
    __array: $,
    binaryEncoding: Z.data.encoding,
    isDefined: !0,
    rowCount: G,
    str: Y,
    int: Q,
    float: W,
    valueKind: K,
    areValuesEqual: (H, N) => $[H] === $[N],
    toStringArray: (H) => w7.createAndFillArray(G, Y, H),
    toIntArray: X ? (H) => w7.typedArrayWindow($, H) : (H) => w7.createAndFillArray(G, Q, H),
    toFloatArray: X ? (H) => w7.typedArrayWindow($, H) : (H) => w7.createAndFillArray(G, W, H)
  };
}

// node_modules/molstar/lib/mol-io/common/msgpack/decode.js
function Hh(Z) {
  return Gh({ buffer: Z, offset: 0, dataView: new DataView(Z.buffer) });
}
function Fs(Z, J) {
  let $ = {};
  for (let X = 0;X < J; X++) {
    let Y = Gh(Z);
    $[Y] = Gh(Z);
  }
  return $;
}
function Us(Z, J) {
  let $ = new Uint8Array(J), X = Z.offset;
  for (let Y = 0;Y < J; Y++)
    $[Y] = Z.buffer[Y + X];
  return Z.offset += J, $;
}
function Kh(Z, J) {
  let $ = IN(Z.buffer, Z.offset, J);
  return Z.offset += J, $;
}
function Ls(Z, J) {
  let $ = new Array(J);
  for (let X = 0;X < J; X++)
    $[X] = Gh(Z);
  return $;
}
function Gh(Z) {
  let J = Z.buffer[Z.offset], $, X;
  if ((J & 128) === 0)
    return Z.offset++, J;
  if ((J & 240) === 128)
    return X = J & 15, Z.offset++, Fs(Z, X);
  if ((J & 240) === 144)
    return X = J & 15, Z.offset++, Ls(Z, X);
  if ((J & 224) === 160)
    return X = J & 31, Z.offset++, Kh(Z, X);
  if ((J & 224) === 224)
    return $ = Z.dataView.getInt8(Z.offset), Z.offset++, $;
  switch (J) {
    case 192:
      return Z.offset++, null;
    case 194:
      return Z.offset++, !1;
    case 195:
      return Z.offset++, !0;
    case 196:
      return X = Z.dataView.getUint8(Z.offset + 1), Z.offset += 2, Us(Z, X);
    case 197:
      return X = Z.dataView.getUint16(Z.offset + 1), Z.offset += 3, Us(Z, X);
    case 198:
      return X = Z.dataView.getUint32(Z.offset + 1), Z.offset += 5, Us(Z, X);
    case 202:
      return $ = Z.dataView.getFloat32(Z.offset + 1), Z.offset += 5, $;
    case 203:
      return $ = Z.dataView.getFloat64(Z.offset + 1), Z.offset += 9, $;
    case 204:
      return $ = Z.buffer[Z.offset + 1], Z.offset += 2, $;
    case 205:
      return $ = Z.dataView.getUint16(Z.offset + 1), Z.offset += 3, $;
    case 206:
      return $ = Z.dataView.getUint32(Z.offset + 1), Z.offset += 5, $;
    case 208:
      return $ = Z.dataView.getInt8(Z.offset + 1), Z.offset += 2, $;
    case 209:
      return $ = Z.dataView.getInt16(Z.offset + 1), Z.offset += 3, $;
    case 210:
      return $ = Z.dataView.getInt32(Z.offset + 1), Z.offset += 5, $;
    case 217:
      return X = Z.dataView.getUint8(Z.offset + 1), Z.offset += 2, Kh(Z, X);
    case 218:
      return X = Z.dataView.getUint16(Z.offset + 1), Z.offset += 3, Kh(Z, X);
    case 219:
      return X = Z.dataView.getUint32(Z.offset + 1), Z.offset += 5, Kh(Z, X);
    case 220:
      return X = Z.dataView.getUint16(Z.offset + 1), Z.offset += 3, Ls(Z, X);
    case 221:
      return X = Z.dataView.getUint32(Z.offset + 1), Z.offset += 5, Ls(Z, X);
    case 222:
      return X = Z.dataView.getUint16(Z.offset + 1), Z.offset += 3, Fs(Z, X);
    case 223:
      return X = Z.dataView.getUint32(Z.offset + 1), Z.offset += 5, Fs(Z, X);
  }
  throw new Error("Unknown type 0x" + J.toString(16));
}

// node_modules/molstar/lib/mol-io/reader/cif/binary/parser.js
function C61(Z, J) {
  for (let $ = 0;$ < 2; $++)
    if (Z[$] > J[$])
      return !1;
  return !0;
}
function k61(Z) {
  let J = Object.create(null), $ = Object.create(null);
  for (let X of Z.columns)
    J[X.name] = X;
  return {
    rowCount: Z.rowCount,
    name: Z.name.substring(1),
    fieldNames: Z.columns.map((X) => X.name),
    getField(X) {
      let Y = J[X];
      if (!Y)
        return;
      if ($[X])
        return $[X];
      return $[X] = NF0(Y), $[X];
    }
  };
}
function Rs(Z) {
  return n0.create("Parse BinaryCIF", async (J) => {
    let $ = [0, 3];
    try {
      let X = Hh(Z);
      if (!C61($, X.version.match(/(\d)\.(\d)\.\d/).slice(1).map((Q) => +Q)))
        return a8.error(`Unsupported format version. Current ${X.version}, required ${$.join(".")}.`);
      let Y = hf(X.dataBlocks.map((Q) => {
        let W = Object.create(null);
        for (let K of Q.categories)
          W[K.name.substring(1)] = k61(K);
        return m_(Q.categories.map((K) => K.name.substring(1)), W, Q.header);
      }));
      return a8.success(Y);
    } catch (X) {
      return a8.error("" + X);
    }
  });
}

// node_modules/molstar/lib/mol-io/reader/cif/schema/ccd.js
var Ez = s.Schema, s9 = Ez.str, v61 = Ez.float, qF0 = Ez.List, gN = Ez.lstr, _K = Ez.Aliased, JV = Ez.int, GA = Ez.coord, FF0 = {
  chem_comp: {
    formula: s9,
    formula_weight: v61,
    id: s9,
    mon_nstd_parent_comp_id: qF0(",", (Z) => Z),
    name: s9,
    one_letter_code: s9,
    three_letter_code: s9,
    type: _K(gN),
    pdbx_synonyms: qF0(";", (Z) => Z),
    pdbx_type: s9,
    pdbx_ambiguous_flag: s9,
    pdbx_replaced_by: s9,
    pdbx_replaces: s9,
    pdbx_formal_charge: JV,
    pdbx_model_coordinates_details: s9,
    pdbx_model_coordinates_db_code: s9,
    pdbx_ideal_coordinates_details: s9,
    pdbx_ideal_coordinates_missing_flag: _K(gN),
    pdbx_model_coordinates_missing_flag: _K(gN),
    pdbx_initial_date: s9,
    pdbx_modified_date: s9,
    pdbx_release_status: _K(s9),
    pdbx_processing_site: _K(s9)
  },
  chem_comp_atom: {
    alt_atom_id: s9,
    atom_id: s9,
    charge: JV,
    model_Cartn_x: GA,
    model_Cartn_y: GA,
    model_Cartn_z: GA,
    comp_id: s9,
    type_symbol: s9,
    pdbx_align: JV,
    pdbx_ordinal: JV,
    pdbx_model_Cartn_x_ideal: GA,
    pdbx_model_Cartn_y_ideal: GA,
    pdbx_model_Cartn_z_ideal: GA,
    pdbx_stereo_config: _K(gN),
    pdbx_aromatic_flag: _K(gN),
    pdbx_leaving_atom_flag: _K(gN)
  },
  chem_comp_bond: {
    atom_id_1: s9,
    atom_id_2: s9,
    comp_id: s9,
    value_order: _K(gN),
    pdbx_ordinal: JV,
    pdbx_stereo_config: _K(gN),
    pdbx_aromatic_flag: _K(gN)
  },
  pdbx_chem_comp_descriptor: {
    comp_id: s9,
    descriptor: s9,
    type: _K(gN),
    program: s9,
    program_version: s9
  },
  pdbx_chem_comp_identifier: {
    comp_id: s9,
    identifier: s9,
    type: _K(s9),
    program: s9,
    program_version: s9
  }
};

// node_modules/molstar/lib/mol-io/reader/cif/schema/bird.js
var $V = s.Schema, $6 = $V.str, S61 = $V.float, aF = $V.lstr, CW = $V.Aliased, w3 = $V.int, UF0 = {
  pdbx_reference_molecule: {
    prd_id: $6,
    formula_weight: S61,
    formula: $6,
    type: CW(aF),
    type_evidence_code: $6,
    class: CW(aF),
    class_evidence_code: $6,
    name: $6,
    represent_as: CW(aF),
    chem_comp_id: $6,
    compound_details: $6,
    description: $6,
    representative_PDB_id_code: $6,
    release_status: CW(aF),
    replaces: $6,
    replaced_by: $6
  },
  pdbx_reference_entity_list: {
    prd_id: $6,
    ref_entity_id: $6,
    type: CW(aF),
    details: $6,
    component_id: w3
  },
  pdbx_reference_entity_nonpoly: {
    prd_id: $6,
    ref_entity_id: $6,
    name: $6,
    chem_comp_id: $6
  },
  pdbx_reference_entity_link: {
    link_id: w3,
    prd_id: $6,
    details: $6,
    ref_entity_id_1: $6,
    ref_entity_id_2: $6,
    entity_seq_num_1: w3,
    entity_seq_num_2: w3,
    comp_id_1: $6,
    comp_id_2: $6,
    atom_id_1: $6,
    atom_id_2: $6,
    value_order: CW(aF),
    component_1: w3,
    component_2: w3,
    link_class: CW($6)
  },
  pdbx_reference_entity_poly_link: {
    link_id: w3,
    prd_id: $6,
    ref_entity_id: $6,
    component_id: w3,
    entity_seq_num_1: w3,
    entity_seq_num_2: w3,
    comp_id_1: $6,
    comp_id_2: $6,
    atom_id_1: $6,
    atom_id_2: $6,
    value_order: CW(aF)
  },
  pdbx_reference_entity_poly: {
    prd_id: $6,
    ref_entity_id: $6,
    type: CW($6),
    db_code: $6,
    db_name: $6
  },
  pdbx_reference_entity_poly_seq: {
    prd_id: $6,
    ref_entity_id: $6,
    mon_id: $6,
    parent_mon_id: $6,
    num: w3,
    observed: CW(aF),
    hetero: CW(aF)
  },
  pdbx_reference_entity_sequence: {
    prd_id: $6,
    ref_entity_id: $6,
    type: CW($6),
    NRP_flag: CW($6),
    one_letter_codes: $6
  },
  pdbx_reference_entity_src_nat: {
    prd_id: $6,
    ref_entity_id: $6,
    ordinal: w3,
    organism_scientific: $6,
    taxid: $6,
    db_code: $6,
    db_name: $6
  },
  pdbx_prd_audit: {
    prd_id: $6,
    date: $6,
    processing_site: CW($6),
    action_type: CW($6)
  }
};

// node_modules/molstar/lib/mol-io/reader/cif/schema/dic.js
var LF0 = s.Schema, U$ = LF0.str, f61 = LF0.float, h61 = {
  id: U$,
  description: U$
}, b61 = {
  title: U$,
  datablock_id: U$,
  version: U$
}, x61 = {
  version: U$,
  update: U$,
  revision: U$
}, y61 = {
  id: U$,
  description: U$
}, g61 = {
  id: U$,
  parent_id: U$,
  description: U$
}, m61 = {
  code: U$,
  primitive_code: U$,
  construct: U$,
  detail: U$
}, d61 = {
  code: U$,
  detail: U$
}, p61 = {
  from_code: U$,
  to_code: U$,
  operator: U$,
  factor: f61
}, RF0 = {
  datablock: h61,
  dictionary: b61,
  dictionary_history: x61,
  sub_category: y61,
  category_group_list: g61,
  item_type_list: m61,
  item_units_list: d61,
  item_units_conversion: p61
};

// node_modules/molstar/lib/mol-io/reader/cif/schema/density-server.js
var XV = s.Schema, mN = XV.str, Nh = XV.int, rF = XV.float, qh = XV.Aliased, _R = XV.Vector, NJ2 = {
  density_server_result: {
    server_version: mN,
    datetime_utc: mN,
    guid: mN,
    is_empty: qh(mN),
    has_error: qh(mN),
    error: mN,
    query_source_id: mN,
    query_type: qh(mN),
    query_box_type: qh(mN),
    query_box_a: _R(3),
    query_box_b: _R(3)
  }
}, Fh = {
  volume_data_3d_info: {
    name: mN,
    axis_order: _R(3, Nh),
    origin: _R(3),
    dimensions: _R(3),
    sample_rate: Nh,
    sample_count: _R(3, Nh),
    spacegroup_number: Nh,
    spacegroup_cell_size: _R(3),
    spacegroup_cell_angles: _R(3),
    mean_source: rF,
    mean_sampled: rF,
    sigma_source: rF,
    sigma_sampled: rF,
    min_source: rF,
    min_sampled: rF,
    max_source: rF,
    max_sampled: rF
  },
  volume_data_3d: {
    values: rF
  }
};

// node_modules/molstar/lib/mol-io/reader/cif/schema/cif-core.js
var Uh = s.Schema, OJ = Uh.float, Y7 = Uh.str, EF0 = Uh.int, u61 = Uh.Matrix, OF0 = {
  cell: {
    angle_alpha: OJ,
    angle_beta: OJ,
    angle_gamma: OJ,
    formula_units_z: OJ,
    length_a: OJ,
    length_b: OJ,
    length_c: OJ,
    volume: OJ
  },
  chemical: {
    melting_point: OJ,
    name_common: Y7,
    name_systematic: Y7
  },
  chemical_formula: {
    moiety: Y7,
    sum: Y7,
    weight: OJ
  },
  space_group: {
    crystal_system: Y7,
    it_number: EF0,
    "name_h-m_full": Y7
  },
  space_group_symop: {
    operation_xyz: Y7
  },
  geom_bond: {
    atom_site_label_1: Y7,
    atom_site_label_2: Y7,
    distance: OJ,
    publ_flag: Y7,
    site_symmetry_1: Y7,
    site_symmetry_2: Y7,
    valence: OJ
  },
  audit: {
    block_doi: Y7
  },
  database_code: {
    cod: Y7,
    csd: Y7,
    depnum_ccdc_archive: Y7,
    depnum_ccdc_fiz: Y7,
    icsd: Y7,
    mdf: Y7,
    nbs: Y7
  },
  atom_site: {
    adp_type: Y7,
    calc_flag: Y7,
    disorder_assembly: Y7,
    disorder_group: Y7,
    fract_x: OJ,
    fract_y: OJ,
    fract_z: OJ,
    label: Y7,
    occupancy: OJ,
    refinement_flags: Y7,
    site_symmetry_multiplicity: EF0,
    type_symbol: Y7,
    u_iso_or_equiv: OJ
  },
  atom_site_aniso: {
    label: Y7,
    u_11: OJ,
    u: u61(3, 3),
    u_12: OJ,
    u_13: OJ,
    u_22: OJ,
    u_23: OJ,
    u_33: OJ
  },
  atom_type: {
    description: Y7,
    symbol: Y7
  },
  atom_type_scat: {
    dispersion_imag: OJ,
    dispersion_real: OJ,
    source: Y7
  }
}, zF0 = {
  "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"
  ]
};

// node_modules/molstar/lib/mol-io/reader/cif/schema/segmentation.js
var c61 = s.Schema, Es = c61.int, DF0 = {
  volume_data_3d_info: Fh.volume_data_3d_info,
  segmentation_data_table: {
    set_id: Es,
    segment_id: Es
  },
  segmentation_data_3d: {
    values: Es
  }
};

// node_modules/molstar/lib/mol-io/reader/cif.js
var kW = {
  parse: (Z) => oL.is(Z) ? qs(Z) : Rs(Z),
  parseText: qs,
  parseBinary: Rs,
  toDatabaseCollection: NN0,
  toDatabase: HQ,
  schema: {
    mmCIF: (Z) => HQ(Q6, Z),
    CCD: (Z) => HQ(FF0, Z),
    BIRD: (Z) => HQ(UF0, Z),
    dic: (Z) => HQ(RF0, Z),
    cifCore: (Z) => HQ(OF0, Z, zF0),
    densityServer: (Z) => HQ(Fh, Z),
    segmentation: (Z) => HQ(DF0, Z)
  }
};

// node_modules/molstar/lib/mol-model-formats/structure/property/anisotropic.js
var l61 = {
  U: Q6.atom_site_anisotrop.U,
  U_esd: Q6.atom_site_anisotrop.U_esd
}, vW;
(function(Z) {
  Z.Schema = l61, Z.Descriptor = {
    name: "atom_site_anisotrop",
    cifExport: {
      prefix: "",
      categories: [{
        name: "atom_site_anisotrop",
        instance(X) {
          if (!Z.Provider.get(X.firstModel))
            return m9.Category.Empty;
          if (!S6.is(X.firstModel.sourceData))
            return m9.Category.Empty;
          return m9.Category.ofTable(X.firstModel.sourceData.data.db.atom_site_anisotrop);
        }
      }]
    }
  }, Z.Provider = e$.create(Z.Descriptor);
  function J(X, Y) {
    let Q = new Int32Array(X.rowCount);
    Q.fill(-1);
    for (let K = 0, G = X.rowCount;K < G; K++)
      Q[X.value(K)] = K;
    let W = new Int32Array(X.rowCount);
    W.fill(-1);
    for (let K = 0, G = Y.rowCount;K < G; ++K) {
      let H = Q[Y.value(K)];
      if (H !== -1)
        W[H] = K;
    }
    return W;
  }
  Z.getElementToAnsiotrop = J;
  function $(X, Y) {
    let Q = {};
    for (let K = 0, G = X.rowCount;K < G; K++)
      Q[X.value(K)] = K;
    let W = new Int32Array(X.rowCount);
    W.fill(-1);
    for (let K = 0, G = Y.rowCount;K < G; ++K) {
      let H = Q[Y.value(K)];
      if (H !== void 0)
        W[H] = K;
    }
    return W;
  }
  Z.getElementToAnsiotropFromLabel = $;
})(vW || (vW = {}));

// node_modules/molstar/lib/mol-model/structure/model/properties/global-transform.js
var dN;
(function(Z) {
  Z.Schema = {
    ["molstar_global_model_transform_info"]: {
      matrix: s.Schema.Matrix(4, 4, s.Schema.float)
    }
  }, Z.Descriptor = p7({
    name: "molstar_global_model_transform_info",
    cifExport: {
      categories: [{
        name: "molstar_global_model_transform_info",
        instance(K) {
          let G = X(K.firstModel);
          if (!G)
            return m9.Category.Empty;
          let H = A8.ofRows(Z.Schema.molstar_global_model_transform_info, [{ matrix: G }]);
          return m9.Category.ofTable(H);
        }
      }],
      prefix: "molstar"
    }
  }), Z.Provider = e$.create(Z.Descriptor);
  function $(K, G) {
    if (!K.customProperties.has(Z.Descriptor))
      K.customProperties.add(Z.Descriptor);
    Z.Provider.set(K, G);
  }
  Z.attach = $;
  function X(K) {
    return Z.Provider.get(K);
  }
  Z.get = X;
  function Y(K) {
    if (!S6.is(K.sourceData))
      return;
    let G = K.sourceData.data.frame.categories.molstar_global_model_transform_info;
    if (!G)
      return;
    let H = qN0(Z.Schema.molstar_global_model_transform_info, G);
    if (H._rowCount === 0)
      return;
    return H.matrix.value(0);
  }
  Z.fromMmCif = Y;
  function Q(K) {
    if (!S6.is(K.sourceData))
      return !1;
    let G = K.sourceData.data.frame.categories.molstar_global_model_transform_info;
    return !!G && G.rowCount > 0;
  }
  Z.hasData = Q;
  function W(K, G) {
    K.writeCategory({
      name: "molstar_global_model_transform_info",
      instance() {
        let H = A8.ofRows(Z.Schema.molstar_global_model_transform_info, [{ matrix: G }]);
        return m9.Category.ofTable(H);
      }
    });
  }
  Z.writeMmCif = W;
})(dN || (dN = {}));

// node_modules/molstar/lib/mol-io/reader/cif/schema/mmcif-extras.js
var cJ2 = {
  label_comp_id: Q6.atom_site.label_comp_id,
  label_seq_id: Q6.atom_site.label_seq_id,
  pdbx_PDB_ins_code: Q6.atom_site.pdbx_PDB_ins_code,
  label_asym_id: Q6.atom_site.label_asym_id,
  label_entity_id: Q6.atom_site.label_entity_id,
  auth_comp_id: Q6.atom_site.auth_atom_id,
  auth_seq_id: Q6.atom_site.auth_seq_id,
  auth_asym_id: Q6.atom_site.auth_asym_id
}, lJ2 = {
  ...Q6.chem_comp_bond,
  molstar_protonation_variant: s.Schema.Str()
}, MF0 = {
  ...Q6.chem_comp,
  type: s.Schema.Aliased(s.Schema.str)
};

// node_modules/molstar/lib/mol-model-formats/structure/basic/util.js
function BF0(Z, J) {
  let { ihm_model_group: $, ihm_model_group_link: X } = J, Y = A8.pickRow(X, (Q) => X.model_id.value(Q) === Z);
  if (Y) {
    let Q = A8.pickRow($, (W) => $.id.value(W) === Y.group_id);
    if (Q)
      return Q.name;
  }
  return "";
}
function AF0(Z) {
  for (let J = 0, $ = Z.rowCount;J < $; J++)
    if (Z.valueKind(J) === s.ValueKinds.Present)
      return !0;
  return !1;
}
function YV(Z, J, $) {
  if (!Z[J].isDefined || !AF0(Z[J]))
    Z[J] = Z[$];
  if (!Z[$].isDefined || !AF0(Z[$]))
    Z[$] = Z[J];
}
function wF0(Z) {
  let J = A8.ofColumns(Z._schema, Z);
  return YV(J, "label_atom_id", "auth_atom_id"), YV(J, "label_comp_id", "auth_comp_id"), YV(J, "label_seq_id", "auth_seq_id"), YV(J, "label_asym_id", "auth_asym_id"), YV(J, "label_entity_id", "label_asym_id"), J;
}

// node_modules/molstar/lib/mol-model-formats/structure/basic/schema.js
var E9 = {
  entry: Q6.entry,
  struct: Q6.struct,
  struct_asym: Q6.struct_asym,
  ihm_model_list: Q6.ihm_model_list,
  ihm_model_group: Q6.ihm_model_group,
  ihm_model_group_link: Q6.ihm_model_group_link,
  entity: Q6.entity,
  entity_poly: Q6.entity_poly,
  entity_poly_seq: Q6.entity_poly_seq,
  pdbx_entity_branch: Q6.pdbx_entity_branch,
  chem_comp: MF0,
  pdbx_chem_comp_identifier: Q6.pdbx_chem_comp_identifier,
  atom_site: Q6.atom_site,
  ihm_sphere_obj_site: Q6.ihm_sphere_obj_site,
  ihm_gaussian_obj_site: Q6.ihm_gaussian_obj_site,
  pdbx_unobs_or_zero_occ_residues: Q6.pdbx_unobs_or_zero_occ_residues,
  pdbx_molecule: Q6.pdbx_molecule
};
function u7(Z, J = !1) {
  let $ = Object.create(null);
  for (let X of Object.keys(E9))
    if (X in Z)
      $[X] = Z[X];
    else
      $[X] = A8.ofUndefinedColumns(E9[X], 0);
  if (J)
    $.atom_site = wF0($.atom_site);
  return $;
}

// node_modules/molstar/lib/mol-model-formats/structure/common/entity.js
class c7 {
  constructor() {
    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;
  }
  set(Z, J) {
    this.count += 1, this.ids.push(`${this.count}`), this.types.push(Z), this.descriptions.push([J]);
  }
  getEntityId(Z, J, $, X) {
    if (J === e2.Water) {
      if (this.waterId === void 0)
        this.set("water", (X === null || X === void 0 ? void 0 : X.customName) || "Water"), this.waterId = `${this.count}`;
      return this.waterId;
    } else if (MR(J))
      if (this.compoundsMap.has($))
        return this.compoundsMap.get($);
      else {
        if (!this.chainMap.has($))
          this.set("polymer", (X === null || X === void 0 ? void 0 : X.customName) || `Polymer ${this.chainMap.size + 1}`), this.chainMap.set($, `${this.count}`);
        return this.chainMap.get($);
      }
    else {
      if (!this.heteroMap.has(Z))
        this.set("non-polymer", (X === null || X === void 0 ? void 0 : X.customName) || this.namesMap.get(Z) || Z), this.heteroMap.set(Z, `${this.count}`);
      return this.heteroMap.get(Z);
    }
  }
  getEntityTable() {
    return A8.ofPartialColumns(E9.entity, {
      id: s.ofStringArray(this.ids),
      type: s.ofStringAliasArray(this.types),
      pdbx_description: s.ofStringListArray(this.descriptions)
    }, this.count);
  }
  setCompounds(Z) {
    for (let J = 0, $ = Z.length;J < $; ++J) {
      let { chains: X, description: Y } = Z[J];
      this.set("polymer", Y);
      for (let Q = 0, W = X.length;Q < W; ++Q)
        this.compoundsMap.set(X[Q], `${this.count}`);
    }
  }
  setNames(Z) {
    Z.forEach((J) => this.namesMap.set(J[0], J[1]));
  }
}

// node_modules/molstar/lib/mol-model-formats/structure/common/component.js
var n61 = [
  /* @__PURE__ */ new Set(["CA"]),
  /* @__PURE__ */ new Set(["C"]),
  /* @__PURE__ */ new Set(["N"])
], i61 = [
  /* @__PURE__ */ new Set(["P", "O3'", "O3*"]),
  /* @__PURE__ */ new Set(["C4'", "C4*"]),
  /* @__PURE__ */ new Set(["O2'", "O2*", "F2'", "F2*"])
], o61 = [
  /* @__PURE__ */ new Set(["P", "O3'", "O3*"]),
  /* @__PURE__ */ new Set(["C3'", "C3*"]),
  /* @__PURE__ */ new Set(["O2'", "O2*", "F2'", "F2*"])
], s61 = /* @__PURE__ */ new Set([
  "FMN",
  "NCN",
  "FNS",
  "FMA",
  "ATP",
  "ADP",
  "AMP",
  "GTP",
  "GDP",
  "GMP",
  "LIG"
]), jF0 = function() {
  let Z = /* @__PURE__ */ new Map;
  return [
    { id: "HIS", name: "HISTIDINE", type: "l-peptide linking" },
    { id: "ARG", name: "ARGININE", type: "l-peptide linking" },
    { id: "LYS", name: "LYSINE", type: "l-peptide linking" },
    { id: "ILE", name: "ISOLEUCINE", type: "l-peptide linking" },
    { id: "PHE", name: "PHENYLALANINE", type: "l-peptide linking" },
    { id: "LEU", name: "LEUCINE", type: "l-peptide linking" },
    { id: "TRP", name: "TRYPTOPHAN", type: "l-peptide linking" },
    { id: "ALA", name: "ALANINE", type: "l-peptide linking" },
    { id: "MET", name: "METHIONINE", type: "l-peptide linking" },
    { id: "CYS", name: "CYSTEINE", type: "l-peptide linking" },
    { id: "ASN", name: "ASPARAGINE", type: "l-peptide linking" },
    { id: "VAL", name: "VALINE", type: "l-peptide linking" },
    { id: "GLY", name: "GLYCINE", type: "peptide linking" },
    { id: "SER", name: "SERINE", type: "l-peptide linking" },
    { id: "GLN", name: "GLUTAMINE", type: "l-peptide linking" },
    { id: "TYR", name: "TYROSINE", type: "l-peptide linking" },
    { id: "ASP", name: "ASPARTIC ACID", type: "l-peptide linking" },
    { id: "GLU", name: "GLUTAMIC ACID", type: "l-peptide linking" },
    { id: "THR", name: "THREONINE", type: "l-peptide linking" },
    { id: "PRO", name: "PROLINE", type: "l-peptide linking" },
    { id: "SEC", name: "SELENOCYSTEINE", type: "l-peptide linking" },
    { id: "PYL", name: "PYRROLYSINE", type: "l-peptide linking" },
    { id: "MSE", name: "SELENOMETHIONINE", type: "l-peptide linking" },
    { id: "SEP", name: "PHOSPHOSERINE", type: "l-peptide linking" },
    { id: "TPO", name: "PHOSPHOTHREONINE", type: "l-peptide linking" },
    { id: "PTR", name: "O-PHOSPHOTYROSINE", type: "l-peptide linking" },
    { id: "PCA", name: "PYROGLUTAMIC ACID", type: "l-peptide linking" },
    { id: "A", name: "ADENOSINE-5'-MONOPHOSPHATE", type: "rna linking" },
    { id: "C", name: "CYTIDINE-5'-MONOPHOSPHATE", type: "rna linking" },
    { id: "T", name: "THYMIDINE-5'-MONOPHOSPHATE", type: "rna linking" },
    { id: "G", name: "GUANOSINE-5'-MONOPHOSPHATE", type: "rna linking" },
    { id: "I", name: "INOSINIC ACID", type: "rna linking" },
    { id: "U", name: "URIDINE-5'-MONOPHOSPHATE", type: "rna linking" },
    { id: "DA", name: "2'-DEOXYADENOSINE-5'-MONOPHOSPHATE", type: "dna linking" },
    { id: "DC", name: "2'-DEOXYCYTIDINE-5'-MONOPHOSPHATE", type: "dna linking" },
    { id: "DT", name: "THYMIDINE-5'-MONOPHOSPHATE", type: "dna linking" },
    { id: "DG", name: "2'-DEOXYGUANOSINE-5'-MONOPHOSPHATE", type: "dna linking" },
    { id: "DI", name: "2'-DEOXYINOSINE-5'-MONOPHOSPHATE", type: "dna linking" },
    { id: "DU", name: "2'-DEOXYURIDINE-5'-MONOPHOSPHATE", type: "dna linking" }
  ].forEach(($) => Z.set($.id, $)), Z;
}(), TF0 = function() {
  let Z = /* @__PURE__ */ new Map;
  return [
    { id: "ZN2", name: "ZINC ION", type: "ion" },
    { id: "SOD", name: "SODIUM ION", type: "ion" },
    { id: "CES", name: "CESIUM ION", type: "ion" },
    { id: "CLA", name: "CHLORIDE ION", type: "ion" },
    { id: "CAL", name: "CALCIUM ION", type: "ion" },
    { id: "POT", name: "POTASSIUM ION", type: "ion" }
  ].forEach(($) => Z.set($.id, $)), Z;
}();

class l7 {
  set(Z) {
    this.comps.set(Z.id, Z), this.ids.push(Z.id), this.names.push(Z.name), this.types.push(Z.type), this.mon_nstd_flags.push(uF.has(Z.id) ? "y" : "n");
  }
  getAtomIds(Z) {
    let J = /* @__PURE__ */ new Set, $ = this.seqId.value(Z);
    while (Z < this.seqId.rowCount) {
      let X = this.seqId.value(Z);
      if (X !== $)
        break;
      J.add(this.atomId.value(Z)), $ - X, Z += 1;
    }
    return J;
  }
  hasAtomIds(Z, J) {
    for (let $ = 0, X = J.length;$ < X; ++$)
      if (!uZ.areIntersecting(Z, J[$]))
        return !1;
    return !0;
  }
  getType(Z) {
    if (this.hasAtomIds(Z, n61))
      return "peptide linking";
    else if (this.hasAtomIds(Z, i61))
      return "rna linking";
    else if (this.hasAtomIds(Z, o61))
      return "dna linking";
    else
      return "other";
  }
  has(Z) {
    return this.comps.has(Z);
  }
  get(Z) {
    return this.comps.get(Z);
  }
  add(Z, J) {
    if (!this.has(Z))
      if (jF0.has(Z))
        this.set(jF0.get(Z));
      else if (mM.has(Z))
        this.set({ id: Z, name: "WATER", type: "non-polymer" });
      else if (s61.has(Z.toUpperCase()))
        this.set({ id: Z, name: this.namesMap.get(Z) || Z, type: "non-polymer" });
      else if (D3.has(Z.toUpperCase()))
        this.set({ id: Z, name: this.namesMap.get(Z) || Z, type: "saccharide" });
      else {
        let $ = this.getAtomIds(J);
        if ($.size === 1 && TF0.has(Z))
          this.set(TF0.get(Z));
        else {
          let X = this.getType($);
          this.set({ id: Z, name: this.namesMap.get(Z) || Z, type: X });
        }
      }
    return this.get(Z);
  }
  getChemCompTable() {
    return A8.ofPartialColumns(E9.chem_comp, {
      id: s.ofStringArray(this.ids),
      name: s.ofStringArray(this.names),
      type: s.ofStringAliasArray(this.types),
      mon_nstd_flag: s.ofStringAliasArray(this.mon_nstd_flags)
    }, this.ids.length);
  }
  setNames(Z) {
    Z.forEach((J) => this.namesMap.set(J[0], J[1]));
  }
  constructor(Z, J) {
    this.seqId = Z, this.atomId = J, this.namesMap = /* @__PURE__ */ new Map, this.comps = /* @__PURE__ */ new Map, this.ids = [], this.names = [], this.types = [], this.mon_nstd_flags = [];
  }
}

// node_modules/molstar/lib/mol-model/structure/export/categories/molstar_bond_site.js
var _F0 = {
  molstar_bond_site: {
    atom_id_1: s.Schema.int,
    atom_id_2: s.Schema.int,
    value_order: s.Schema.Aliased(s.Schema.lstr),
    type_id: s.Schema.Aliased(s.Schema.lstr)
  }
}, R$2 = m9.fields().int("atom_id_1", (Z, J) => J[Z].atom_id_1).int("atom_id_2", (Z, J) => J[Z].atom_id_2).str("value_order", (Z, J) => {
  var $;
  return ($ = J[Z].value_order) !== null && $ !== void 0 ? $ : "";
}, {
  valueKind: (Z, J) => J[Z].value_order === void 0 ? s.ValueKinds.NotPresent : s.ValueKinds.Present
}).str("type_id", (Z, J) => {
  var $;
  return ($ = J[Z].type_id) !== null && $ !== void 0 ? $ : "";
}, {
  valueKind: (Z, J) => J[Z].type_id === void 0 ? s.ValueKinds.NotPresent : s.ValueKinds.Present
}).getFields();

// node_modules/molstar/lib/mol-model-formats/structure/mmcif.js
function a61(Z) {
  if (!S6.is(Z.sourceData))
    return;
  return T9.fromData(Z.sourceData.data.db);
}
T9.Provider.formatRegistry.add("mmCIF", a61);
function r61(Z) {
  if (!S6.is(Z.sourceData))
    return;
  let { struct_conf: J, struct_sheet_range: $ } = Z.sourceData.data.db;
  return HH.fromStruct(J, $, Z.atomicHierarchy);
}
HH.Provider.formatRegistry.add("mmCIF", r61);
function t61(Z) {
  if (!S6.is(Z.sourceData))
    return;
  let { atom_site_anisotrop: J } = Z.sourceData.data.db, $ = A8.ofColumns(vW.Schema, J), X = vW.getElementToAnsiotrop(Z.atomicConformation.atomId, J.id);
  return { data: $, elementToAnsiotrop: X };
}
function e61(Z) {
  if (!S6.is(Z.sourceData))
    return !1;
  return Z.sourceData.data.db.atom_site_anisotrop.U.isDefined;
}
vW.Provider.formatRegistry.add("mmCIF", t61, e61);
function ZZ1(Z) {
  if (!S6.is(Z.sourceData))
    return;
  let { chem_comp_bond: J } = Z.sourceData.data.db;
  if (J._rowCount === 0)
    return;
  return {
    data: J,
    entries: lF.getEntriesFromChemCompBond(J)
  };
}
lF.Provider.formatRegistry.add("mmCIF", ZZ1);
function JZ1(Z) {
  if (!S6.is(Z.sourceData))
    return;
  let { struct_conn: J } = Z.sourceData.data.db;
  if (J._rowCount === 0)
    return;
  let $ = mQ.getEntriesFromStructConn(J, Z), X = /* @__PURE__ */ new Set;
  for (let Y of $)
    if (Y.partnerA.residueIndex !== Y.partnerB.residueIndex)
      X.add(wW(Y.partnerA.residueIndex, Y.partnerB.residueIndex));
  return {
    data: J,
    byAtomIndex: mQ.getAtomIndexFromEntries($),
    residueCantorPairs: X,
    entries: $
  };
}
mQ.Provider.formatRegistry.add("mmCIF", JZ1);
function $Z1(Z) {
  if (!S6.is(Z.sourceData))
    return;
  let { molstar_bond_site: J } = HQ(_F0, Z.sourceData.data.frame);
  if (J._rowCount === 0)
    return;
  let $ = /* @__PURE__ */ new Map, { atomId: X } = Z.atomicConformation;
  for (let F = 0;F < X.rowCount; F++)
    $.set(X.value(F), F);
  let Y = [], Q = [], W = [], K = [], { atom_id_1: G, atom_id_2: H, value_order: N, type_id: q } = J;
  for (let F = 0;F < J._rowCount; F++) {
    Y.push($.get(G.value(F))), Q.push($.get(H.value(F)));
    let E = s1.Flag.None, R = 1;
    switch (N.value(F)) {
      case "sing":
        R = 1;
        break;
      case "doub":
        R = 2;
        break;
      case "trip":
        R = 3;
        break;
      case "quad":
        R = 4;
        break;
      case "arom":
        R = 1, E = s1.Flag.Aromatic;
        break;
      default:
        break;
    }
    switch (q.value(F)) {
      case "covale":
        E |= s1.Flag.Covalent;
        break;
      case "disulf":
        E |= s1.Flag.Covalent | s1.Flag.Disulfide;
        break;
      case "hydrog":
        E |= s1.Flag.HydrogenBond;
        break;
      case "metalc":
        E |= s1.Flag.MetallicCoordination;
        break;
    }
    W.push(R), K.push(E);
  }
  return j9.fromData({
    pairs: {
      indexA: s.ofIntArray(Y),
      indexB: s.ofIntArray(Q),
      order: s.ofIntArray(W),
      flag: s.ofArray({ array: K, schema: s.Schema.int })
    },
    count: Z.atomicHierarchy.atoms._rowCount
  }, { maxDistance: 1 / 0 });
}
j9.Provider.formatRegistry.add("mmCIF", $Z1);
dN.Provider.formatRegistry.add("mmCIF", dN.fromMmCif, dN.hasData);
var S6;
(function(Z) {
  function J(X) {
    return (X === null || X === void 0 ? void 0 : X.kind) === "mmCIF";
  }
  Z.is = J;
  function $(X, Y, Q, W) {
    if (!Y)
      Y = kW.schema.mmCIF(X);
    return { kind: "mmCIF", name: Y._name, data: { db: Y, file: W, frame: X, source: Q } };
  }
  Z.fromFrame = $;
})(S6 || (S6 = {}));
function Lh(Z, J) {
  let $ = S6.fromFrame(Z, void 0, void 0, J), X = u7($.data.db, !0);
  return n0.create("Create mmCIF Model", (Y) => nJ(X, $, Y));
}
var QV;
(function(Z) {
  Z.CoordinateType = {
    get(Y) {
      return Y._staticPropertyData.__CcdCoordinateType__;
    },
    set(Y, Q) {
      return Y._staticPropertyData.__CcdCoordinateType__ = Q;
    }
  };
  function $(Y) {
    return (Y === null || Y === void 0 ? void 0 : Y.kind) === "CCD";
  }
  Z.is = $;
  function X(Y, Q) {
    if (!Q)
      Q = kW.schema.CCD(Y);
    return { kind: "CCD", name: Q._name, data: { db: Q, frame: Y } };
  }
  Z.fromFrame = X;
})(QV || (QV = {}));
function IF0(Z) {
  let J = QV.fromFrame(Z);
  return n0.create("Create CCD Models", ($) => XZ1(J.data.db, QV.fromFrame(Z), $));
}
async function XZ1(Z, J, $) {
  let X = await VF0(Z, J, { coordinateType: "ideal", cartn_x: "pdbx_model_Cartn_x_ideal", cartn_y: "pdbx_model_Cartn_y_ideal", cartn_z: "pdbx_model_Cartn_z_ideal" }, $), Y = await VF0(Z, J, { coordinateType: "model", cartn_x: "model_Cartn_x", cartn_y: "model_Cartn_y", cartn_z: "model_Cartn_z" }, $), Q = [];
  if (X)
    Q.push(X);
  if (Y)
    Q.push(Y);
  for (let W = 0, K = Q.length;W < K; ++W)
    O2.TrajectoryInfo.set(Q[W], { index: W, size: Q.length });
  return new UY(Q);
}
async function VF0(Z, J, $, X) {
  let { chem_comp: Y, chem_comp_atom: Q, chem_comp_bond: W } = Z, { coordinateType: K, cartn_x: G, cartn_y: H, cartn_z: N } = $, q = Y.name.value(0), U = Y.id.value(0), { atom_id: F, charge: E, comp_id: R, pdbx_ordinal: z, type_symbol: D } = Q, A = Q._rowCount, B = [];
  for (let F0 = 0;F0 < A; F0++) {
    if (Q[G].valueKind(F0) > 0)
      continue;
    B[B.length] = F0;
  }
  let T = B.length, w = s.ofConst("A", T, s.Schema.str), V = s.ofConst(1, T, s.Schema.int), P = s.ofConst("1", T, s.Schema.str), I = s.ofConst(1, T, s.Schema.float), S = s.ofConst(1, T, s.Schema.int), f = s.view(F, B), v = s.view(R, B), h = s.view(Q[G], B), x = s.view(Q[H], B), b = s.view(Q[N], B), g = s.view(z, B), m = s.view(D, B), i = s.view(E, B), r = A8.ofPartialColumns(E9.atom_site, {
    auth_asym_id: w,
    auth_atom_id: f,
    auth_comp_id: v,
    auth_seq_id: V,
    Cartn_x: h,
    Cartn_y: x,
    Cartn_z: b,
    id: g,
    label_asym_id: w,
    label_atom_id: f,
    label_comp_id: v,
    label_seq_id: V,
    label_entity_id: P,
    occupancy: I,
    type_symbol: m,
    pdbx_PDB_model_num: S,
    pdbx_formal_charge: i
  }, T), Y0 = new c7;
  Y0.setNames([[U, `${q} (${K})`]]), Y0.getEntityId(U, e2.Unknown, "A");
  let c = new l7(V, D);
  c.setNames([[U, `${q} (${K})`]]), c.add(U, 0);
  let n = u7({
    entity: Y0.getEntityTable(),
    chem_comp: c.getChemCompTable(),
    atom_site: r
  }), l = await nJ(n, J, X);
  if (!l.representative)
    return;
  let u = l.representative, G0 = lF.getEntriesFromChemCompBond(W);
  return lF.Provider.set(u, { data: W, entries: G0 }), QV.CoordinateType.set(u, K), l.representative;
}

// node_modules/molstar/lib/mol-model-props/common/custom-model-property.js
var j3;
(function(Z) {
  function J(X) {
    let Y = X.descriptor.name, Q = X.type === "static" ? "_staticPropertyData" : "_dynamicPropertyData", W = (G) => {
      if (!(Y in G[Q]))
        G[Q][Y] = {
          props: { ...j.getDefaultValues(X.getParams(G)) },
          data: ON.create(void 0)
        };
      return G[Q][Y];
    }, K = (G, H, N) => {
      let q = W(G);
      G[Q][Y] = {
        props: H,
        data: ON.withValue(q.data, N)
      };
    };
    return {
      label: X.label,
      descriptor: X.descriptor,
      isHidden: X.isHidden,
      getParams: (G) => {
        let H = j.clone(X.getParams(G));
        return j.setDefaultValues(H, W(G).props), H;
      },
      defaultParams: X.defaultParams,
      isApplicable: X.isApplicable,
      attach: async (G, H, N = {}, q) => {
        if (q)
          H.customProperties.reference(X.descriptor, !0);
        let U = W(H), F = j.merge(X.defaultParams, U.props, N);
        if (U.data.value && j.areEqual(X.defaultParams, U.props, F))
          return;
        let { value: E, assets: R } = await X.obtain(G, H, F);
        H.customProperties.add(X.descriptor), H.customProperties.assets(X.descriptor, R), K(H, F, E);
      },
      ref: (G, H) => G.customProperties.reference(X.descriptor, H),
      get: (G) => {
        var H;
        return (H = W(G)) === null || H === void 0 ? void 0 : H.data;
      },
      set: (G, H = {}, N) => {
        let q = W(G), U = j.merge(X.defaultParams, q.props, H);
        if (!j.areEqual(X.defaultParams, q.props, U))
          K(G, U, N), G.customProperties.assets(X.descriptor);
      },
      props: (G) => W(G).props
    };
  }
  Z.createProvider = J;
  function $(X, Y, Q) {
    let W = { value: j.Value(Q, { isHidden: !0 }) };
    return J({
      label: v$(X),
      descriptor: p7({ name: X }),
      isHidden: !0,
      type: Y,
      defaultParams: W,
      getParams: () => ({ value: j.Value(Q, { isHidden: !0 }) }),
      isApplicable: () => !0,
      obtain: async (K, G, H) => {
        return { ...j.getDefaultValues(W), ...H };
      }
    });
  }
  Z.createSimple = $;
})(j3 || (j3 = {}));

// node_modules/molstar/lib/mol-model-props/sequence/sifts-mapping.js
var pQ;
(function(Z) {
  Z.Provider = j3.createProvider({
    label: "SIFTS Mapping",
    descriptor: p7({
      name: "sifts_sequence_mapping"
    }),
    type: "static",
    defaultParams: {},
    getParams: () => ({}),
    isApplicable: (Q) => J(Q),
    obtain: async (Q, W) => {
      return { value: Y(W) };
    }
  });
  function J(Q) {
    if (!S6.is(Q.sourceData))
      return !1;
    let { pdbx_sifts_xref_db_name: W, pdbx_sifts_xref_db_acc: K, pdbx_sifts_xref_db_num: G, pdbx_sifts_xref_db_res: H } = Q.sourceData.data.db.atom_site;
    return W.isDefined && K.isDefined && G.isDefined && H.isDefined;
  }
  Z.isAvailable = J;
  function $(Q) {
    let W = Q.unit.model, K = Z.Provider.get(W).value;
    if (!K)
      return "";
    let G = W.atomicHierarchy.residueAtomSegments.index[Q.element];
    return K.accession[G];
  }
  Z.getKey = $;
  function X(Q) {
    let W = Q.unit.model, K = Z.Provider.get(W).value;
    if (!K)
      return;
    let G = W.atomicHierarchy.residueAtomSegments.index[Q.element], H = K.dbName[G];
    if (!H)
      return;
    return `${H} ${K.accession[G]} ${K.num[G]} ${K.residue[G]}`;
  }
  Z.getLabel = X;
  function Y(Q) {
    if (!S6.is(Q.sourceData))
      return;
    let { pdbx_sifts_xref_db_name: W, pdbx_sifts_xref_db_acc: K, pdbx_sifts_xref_db_num: G, pdbx_sifts_xref_db_res: H } = Q.sourceData.data.db.atom_site;
    if (!W.isDefined || !K.isDefined || !G.isDefined || !H.isDefined)
      return;
    let { atomSourceIndex: N } = Q.atomicHierarchy, { count: q, offsets: U } = Q.atomicHierarchy.residueAtomSegments, F = new Array(q), E = new Array(q), R = new Array(q), z = new Array(q);
    for (let D = 0;D < q; D++) {
      let A = N.value(U[D]);
      if (W.valueKind(A) !== s.ValueKinds.Present) {
        F[D] = "", E[D] = "", R[D] = "", z[D] = "";
        continue;
      }
      F[D] = W.value(A), E[D] = K.value(A), R[D] = G.value(A), z[D] = H.value(A);
    }
    return { dbName: F, accession: E, num: R, residue: z };
  }
})(pQ || (pQ = {}));

// node_modules/molstar/lib/mol-model/structure/export/categories/atom_site.js
var t$2 = m9.Field, e$2 = m9.Encodings;

// node_modules/molstar/lib/mol-model/structure/export/categories/secondary-structure.js
var QX2 = m9.Field;

// node_modules/molstar/lib/mol-model/structure/export/categories/utils.js
function Os(Z, J) {
  if (!S6.is(Z.sourceData))
    return;
  return Z.sourceData.data.db[J];
}
function PF0(Z) {
  if (Z.length === 0)
    return /* @__PURE__ */ new Set;
  let J = Z[0].model.entities.data.id;
  return new Set(CF0(Z).map(($) => J.value($)));
}
function CF0(Z) {
  if (Z.length === 0)
    return [];
  if (Z.length === 1)
    return Z[0].entityIndices;
  let J = o6.create();
  for (let $ of Z)
    for (let X of $.entityIndices)
      o6.add(J, X, X);
  return t$(J.array), J.array;
}

// node_modules/molstar/lib/mol-model/structure/export/categories/misc.js
var BX2 = m9.Category;

// node_modules/molstar/lib/mol-model/structure/export/categories/sequence.js
var kF0 = m9.Category, YZ1 = zs("struct_asym"), QZ1 = zs("entity_poly"), WZ1 = zs("entity_poly_seq");
function zs(Z) {
  return {
    name: Z,
    instance({ structures: J, cache: $ }) {
      return KZ1(J, Z, $);
    }
  };
}
function KZ1(Z, J, $) {
  let X = Os(Z[0].model, J);
  if (!X)
    return kF0.Empty;
  let { entity_id: Y } = X, Q = $.uniqueEntityIds || ($.uniqueEntityIds = PF0(Z)), W = s.indicesOf(Y, (K) => Q.has(K));
  return kF0.ofTable(X, W);
}

// node_modules/molstar/lib/mol-model/structure/export/mmcif.js
var mX2 = m9.Category, vF0;
(function(Z) {
  function J($) {
    let X = Array.isArray($) ? $ : [$];
    return {
      structures: X,
      firstModel: X[0].model,
      cache: Object.create(null)
    };
  }
  Z.create = J;
})(vF0 || (vF0 = {}));
var SF0;
(function(Z) {
  Z.AtomSitePositionsFieldNames = /* @__PURE__ */ new Set(["id", "Cartn_x", "Cartn_y", "Cartn_z"]);
})(SF0 || (SF0 = {}));
// node_modules/molstar/lib/mol-model/structure/export/categories/atom_site_operator_mapping.js
var hF0 = {
  molstar_atom_site_operator_mapping: {
    label_asym_id: s.Schema.Str(),
    auth_asym_id: s.Schema.Str(),
    operator_name: s.Schema.Str(),
    suffix: s.Schema.Str(),
    assembly_id: s.Schema.Str(),
    assembly_operator_id: s.Schema.Int(),
    symmetry_operator_index: s.Schema.Int(),
    symmetry_hkl: s.Schema.Vector(3),
    ncs_id: s.Schema.Int()
  }
}, fF0 = (Z, J) => typeof J[Z].operator.assembly === "undefined" ? s.ValueKinds.NotPresent : s.ValueKinds.Present, Ds = (Z, J) => J[Z].operator.spgrOp === -1 ? s.ValueKinds.NotPresent : s.ValueKinds.Present, qY2 = m9.fields().str("label_asym_id", (Z, J) => J[Z].label_asym_id).str("auth_asym_id", (Z, J) => J[Z].auth_asym_id).str("operator_name", (Z, J) => J[Z].operator.name).str("suffix", (Z, J) => J[Z].operator.suffix).str("assembly_id", (Z, J) => {
  var $;
  return (($ = J[Z].operator.assembly) === null || $ === void 0 ? void 0 : $.id) || "";
}, { valueKind: fF0 }).int("assembly_operator_id", (Z, J) => {
  var $;
  return (($ = J[Z].operator.assembly) === null || $ === void 0 ? void 0 : $.operId) || 0;
}, { valueKind: fF0 }).int("symmetry_operator_index", (Z, J) => J[Z].operator.spgrOp, { valueKind: Ds }).vec("symmetry_hkl", [(Z, J) => J[Z].operator.hkl[0], (Z, J) => J[Z].operator.hkl[1], (Z, J) => J[Z].operator.hkl[2]], { valueKind: Ds }).int("ncs_id", (Z, J) => J[Z].operator.ncsId, { valueKind: Ds }).getFields();

// node_modules/molstar/lib/mol-model/structure/model/properties/utils/atomic-derived.js
function bF0(Z, J, $, X) {
  let { label_comp_id: Y, type_symbol: Q, _rowCount: W } = Z.atoms, { _rowCount: K } = Z.residues, { offsets: G } = J.residueAtomSegments, H = new Uint8Array(W);
  for (let D = 0;D < W; ++D)
    H[D] = DR(Q.value(D));
  let N = new Int32Array(K), q = new Int32Array(K), U = new Int32Array(K), F = new Uint8Array(K), E = new Uint8Array(K), R = /* @__PURE__ */ new Map, z = /* @__PURE__ */ new Map;
  for (let D = 0;D < K; ++D) {
    let A = Y.value(G[D]), B = X, T, w;
    if (R.has(A))
      T = R.get(A), w = z.get(A);
    else {
      let f;
      if (B.has(A))
        f = B.get(A).type;
      else {
        if (!aL)
          console.info("chemComp not found", A);
        f = Ao(A);
      }
      T = qY(f, A), w = JN0(f, T), R.set(A, T), z.set(A, w);
    }
    F[D] = T, E[D] = w;
    let V = yN(w, "trace"), P = $.findAtomsOnResidue(D, V);
    if (P === -1) {
      let f = yN(w, "coarseBackbone");
      if (P = $.findAtomsOnResidue(D, f), P === -1 && MR(T))
        P = $.findElementOnResidue(D, WH("C"));
    }
    N[D] = P;
    let I = yN(w, "directionFrom");
    q[D] = $.findAtomsOnResidue(D, I);
    let S = yN(w, "directionTo");
    U[D] = $.findAtomsOnResidue(D, S);
  }
  return {
    atom: {
      atomicNumber: H
    },
    residue: {
      traceElementIndex: N,
      directionFromElementIndex: q,
      directionToElementIndex: U,
      moleculeType: F,
      polymerType: E
    }
  };
}

// node_modules/molstar/lib/mol-model/structure/model/properties/utils/atomic-index.js
function HA(Z, J) {
  if (!J)
    return Z;
  if (J.length === 1)
    return ZJ(J.charCodeAt(0), Z);
  if (J.length === 2)
    return ZJ(J.charCodeAt(0), ZJ(J.charCodeAt(1), Z));
  return `${Z} ${J}`;
}
function GZ1(Z, J, $, X) {
  if (Z.has(J)) {
    let Y = Z.get(J);
    if (!Y.has($))
      Y.set($, X);
  } else {
    let Y = /* @__PURE__ */ new Map;
    Z.set(J, Y), Y.set($, X);
  }
}
function HZ1(Z) {
  throw new Error(`Missing entity entry for entity id '${Z}'.`);
}
function NZ1(Z, J, $) {
  return {
    entities: Z,
    segments: $,
    label_seq_id: X1.ofSortedArray(J.residues.label_seq_id.toArray({ array: Int32Array })),
    label_atom_id: J.atoms.label_atom_id,
    auth_atom_id: J.atoms.auth_atom_id,
    label_alt_id: J.atoms.label_alt_id,
    type_symbol: J.atoms.type_symbol,
    chain_index_entity_index: new Int32Array(J.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 WV = Pf.EmptyResidueKey();

class xF0 {
  getEntityFromChain(Z) {
    return this.map.chain_index_entity_index[Z];
  }
  findEntity(Z) {
    let J = this.map.label_asym_id.get(Z);
    return J !== void 0 ? J : -1;
  }
  findChainLabel(Z) {
    let J = this.entityIndex(Z.label_entity_id);
    if (J < 0 || !this.map.entity_index_label_asym_id.has(J))
      return -1;
    let $ = this.map.entity_index_label_asym_id.get(J);
    if (!$)
      return -1;
    return $.has(Z.label_asym_id) ? $.get(Z.label_asym_id) : -1;
  }
  findChainAuth(Z) {
    if (!this.map.auth_asym_id_auth_seq_id.has(Z.auth_asym_id))
      return -1;
    let J = this.map.auth_asym_id_auth_seq_id.get(Z.auth_asym_id);
    return J.has(Z.auth_seq_id) ? J.get(Z.auth_seq_id) : -1;
  }
  findResidue(Z, J, $, X) {
    let Y;
    if (arguments.length === 1)
      Y = Z;
    else
      WV.label_entity_id = Z, WV.label_asym_id = J, WV.auth_seq_id = $, WV.pdbx_PDB_ins_code = X, Y = WV;
    let Q = this.findChainLabel(Y);
    if (Q < 0)
      return -1;
    let W = this.map.chain_index_auth_seq_id.get(Q), K = HA(Y.auth_seq_id, Y.pdbx_PDB_ins_code || "");
    return W.has(K) ? W.get(K) : -1;
  }
  findResidueLabel(Z) {
    let J = this.findChainLabel(Z);
    if (J < 0)
      return -1;
    let $ = this.map.chain_index_label_seq_id.get(J), X = HA(Z.label_seq_id, Z.pdbx_PDB_ins_code || "");
    return $.has(X) ? $.get(X) : -1;
  }
  findResidueAuth(Z) {
    let J = this.findChainAuth(Z);
    if (J < 0)
      return -1;
    let $ = this.map.chain_index_auth_seq_id.get(J), X = HA(Z.auth_seq_id, Z.pdbx_PDB_ins_code || "");
    return $.has(X) ? $.get(X) : -1;
  }
  findResidueInsertion(Z) {
    let J = this.findChainLabel(Z);
    if (J < 0)
      return -1;
    let $ = this.map.chain_index_label_seq_id.get(J), X = HA(Z.label_seq_id, Z.pdbx_PDB_ins_code || "");
    if ($.has(X))
      return $.get(X);
    let Y = X1.findPredecessorIndex(this.map.label_seq_id, Z.label_seq_id), Q = zR.chainStartResidueIndex(this.map.segments, J);
    if (Y < Q)
      return Q;
    let W = zR.chainEndResidueIndexExcl(this.map.segments, J) - 1;
    if (Y >= W)
      return W;
    return Y;
  }
  findAtom(Z) {
    let J = this.findResidue(Z);
    if (J < 0)
      return -1;
    if (typeof Z.label_alt_id === "undefined")
      return Ms(this.residueOffsets[J], this.residueOffsets[J + 1], this.map.label_atom_id, Z.label_atom_id);
    return As(this.residueOffsets[J], this.residueOffsets[J + 1], this.map.label_atom_id, this.map.label_alt_id, Z.label_atom_id, Z.label_alt_id);
  }
  findAtomAuth(Z) {
    let J = this.findResidueAuth(Z);
    if (J < 0)
      return -1;
    if (typeof Z.label_alt_id === "undefined")
      return Ms(this.residueOffsets[J], this.residueOffsets[J + 1], this.map.auth_atom_id, Z.auth_atom_id);
    return As(this.residueOffsets[J], this.residueOffsets[J + 1], this.map.auth_atom_id, this.map.label_alt_id, Z.auth_atom_id, Z.label_alt_id);
  }
  findAtomOnResidue(Z, J, $) {
    if (typeof $ === "undefined")
      return Ms(this.residueOffsets[Z], this.residueOffsets[Z + 1], this.map.label_atom_id, J);
    return As(this.residueOffsets[Z], this.residueOffsets[Z + 1], this.map.label_atom_id, this.map.label_alt_id, J, $);
  }
  findAtomsOnResidue(Z, J) {
    return qZ1(this.residueOffsets[Z], this.residueOffsets[Z + 1], this.map.label_atom_id, J);
  }
  findElementOnResidue(Z, J) {
    return FZ1(this.residueOffsets[Z], this.residueOffsets[Z + 1], this.map.type_symbol, J);
  }
  constructor(Z) {
    this.map = Z, this.entityIndex = Z.entities.getEntityIndex, this.residueOffsets = this.map.segments.residueAtomSegments.offsets;
  }
}
function Ms(Z, J, $, X) {
  for (let Y = Z;Y < J; Y++)
    if ($.value(Y) === X)
      return Y;
  return -1;
}
function qZ1(Z, J, $, X) {
  for (let Y = Z;Y < J; Y++)
    if (X.has($.value(Y)))
      return Y;
  return -1;
}
function As(Z, J, $, X, Y, Q) {
  for (let W = Z;W < J; W++)
    if ($.value(W) === Y && X.value(W) === Q)
      return W;
  return -1;
}
function FZ1(Z, J, $, X) {
  for (let Y = Z;Y < J; Y++)
    if ($.value(Y) === X)
      return Y;
  return -1;
}
function yF0(Z, J, $) {
  let X = NZ1(J, Z, $), { label_seq_id: Y, auth_seq_id: Q, pdbx_PDB_ins_code: W } = Z.residues, { label_entity_id: K, label_asym_id: G, auth_asym_id: H } = Z.chains, N = k0.ofBounds(0, Z.atoms._rowCount), q = b2.transientSegments($.chainAtomSegments, N);
  while (q.hasNext) {
    let U = q.move(), F = U.index, E = J.getEntityIndex(K.value(F));
    if (E < 0)
      HZ1(K.value(F));
    X.chain_index_entity_index[F] = E;
    let R = H.value(F), z = X.auth_asym_id_auth_seq_id.get(R);
    if (!z)
      z = /* @__PURE__ */ new Map, X.auth_asym_id_auth_seq_id.set(R, z);
    let D = G.value(F);
    if (!X.label_asym_id.has(D))
      X.label_asym_id.set(D, E);
    GZ1(X.entity_index_label_asym_id, E, D, F);
    let A = /* @__PURE__ */ new Map, B = /* @__PURE__ */ new Map;
    X.chain_index_label_seq_id.set(F, A), X.chain_index_auth_seq_id.set(F, B);
    let T = b2.transientSegments($.residueAtomSegments, N, U);
    while (T.hasNext) {
      let V = T.move().index, P = Q.value(V), I = W.value(V);
      A.set(HA(Y.value(V), I), V), B.set(HA(P, I), V), z.set(P, F);
    }
  }
  return new xF0(X);
}

// node_modules/molstar/lib/mol-model-formats/structure/basic/atomic.js
function UZ1(Z) {
  if (Z._rowCount === 0)
    return { residues: [], chains: [] };
  let J = 0, $ = Z._rowCount, X = [J], Y = [J], { label_entity_id: Q, label_asym_id: W, label_seq_id: K, auth_seq_id: G, pdbx_PDB_ins_code: H } = Z;
  for (let N = J + 1;N < $; N++) {
    let q = !Q.areValuesEqual(N - 1, N) || !W.areValuesEqual(N - 1, N);
    if (q || !K.areValuesEqual(N - 1, N) || !G.areValuesEqual(N - 1, N) || !H.areValuesEqual(N - 1, N))
      X[X.length] = N;
    if (q)
      Y[Y.length] = N;
  }
  return { residues: X, chains: Y };
}
function LZ1(Z, J, $) {
  let X = A8.ofColumns(wH0, {
    type_symbol: s.ofArray({ array: s.mapToArray(Z.type_symbol, WH), schema: s.Schema.Aliased(s.Schema.str) }),
    label_atom_id: Z.label_atom_id,
    auth_atom_id: Z.auth_atom_id,
    label_alt_id: Z.label_alt_id,
    label_comp_id: Z.label_comp_id,
    auth_comp_id: Z.auth_comp_id,
    pdbx_formal_charge: Z.pdbx_formal_charge
  }), Y = A8.view(Z, jH0, $.residues), Q = A8.view(Z, TH0, $.chains);
  if (!Y.label_seq_id.isDefined) {
    let K = new Int32Array(Y.label_seq_id.rowCount), { residues: G, chains: H } = $, N = 0, q = 0;
    for (let U = 0, F = K.length;U < F; ++U) {
      if (G[U] >= H[N + 1])
        N += 1, q = 0;
      K[U] = ++q;
    }
    Y.label_seq_id = s.ofIntArray(K);
  }
  A8.columnToArray(Y, "label_seq_id", Int32Array), A8.columnToArray(Y, "auth_seq_id", Int32Array);
  let W = RZ1(J, $.residues.length, $.residues);
  return { atoms: X, residues: Y, chains: Q, atomSourceIndex: J, residueSourceIndex: W };
}
function RZ1(Z, J, $) {
  let X = new Uint32Array(J);
  for (let Q = 0;Q < J; Q++) {
    let W = $[Q], K = Q + 1 < J ? $[Q + 1] : Z.rowCount, G = Z.value(W);
    for (let H = W + 1;H < K; H++) {
      let N = Z.value(H);
      if (N < G)
        G = N;
    }
    X[Q] = G;
  }
  let Y = yK0(J).sort((Q, W) => X[Q] - X[W]);
  for (let Q = 0;Q < J; Q++)
    X[Y[Q]] = Q;
  return s.ofIntArray(X);
}
function EZ1(Z) {
  return {
    id: R6.create22(),
    atomId: Z.id,
    occupancy: Z.occupancy.isDefined ? Z.occupancy : s.ofConst(1, Z._rowCount, s.Schema.float),
    B_iso_or_equiv: Z.B_iso_or_equiv,
    xyzDefined: Z.Cartn_x.isDefined && Z.Cartn_y.isDefined && Z.Cartn_z.isDefined,
    x: Z.Cartn_x.toArray({ array: Float32Array }),
    y: Z.Cartn_y.toArray({ array: Float32Array }),
    z: Z.Cartn_z.toArray({ array: Float32Array })
  };
}
function OZ1(Z, J) {
  return A8.areEqual(Z.chains, J.chains) && A8.areEqual(Z.residues, J.residues) && A8.areEqual(Z.atoms, J.atoms);
}
function zZ1(Z, J) {
  let $ = /* @__PURE__ */ new Map;
  if (!S6.is(J))
    return $;
  let { molstar_atom_site_operator_mapping: X } = HQ(hF0, J.data.frame);
  if (X._rowCount === 0)
    return $;
  let Y = /* @__PURE__ */ new Map, Q = /* @__PURE__ */ new Map;
  for (let N = 0;N < X._rowCount; N++) {
    let q = X.assembly_operator_id.valueKind(N) === s.ValueKinds.Present ? { id: X.assembly_id.value(N), operList: [], operId: X.assembly_operator_id.value(N) } : void 0, U = RZ.create(X.operator_name.value(N), e.identity(), {
      assembly: q,
      spgrOp: X.symmetry_operator_index.valueKind(N) === s.ValueKinds.Present ? X.symmetry_operator_index.value(N) : void 0,
      hkl: M.ofArray(X.symmetry_hkl.value(N)),
      ncsId: X.ncs_id.value(N)
    }), F = X.suffix.value(N), E = X.label_asym_id.value(N);
    Y.set(`${E}${F}`, { name: E, operator: U });
    let R = X.auth_asym_id.value(N);
    Q.set(`${R}${F}`, R);
  }
  let { label_asym_id: W, auth_asym_id: K } = Z.chains, G = new Array(W.rowCount), H = new Array(W.rowCount);
  for (let N = 0;N < W.rowCount; N++) {
    let q = W.value(N), U = K.value(N);
    if (!Y.has(q)) {
      G[N] = q, H[N] = U;
      continue;
    }
    let { name: F, operator: E } = Y.get(q);
    $.set(N, E), G[N] = F, H[N] = Q.get(U) || U;
  }
  return Z.chains.label_asym_id = s.ofArray({ array: G, valueKind: Z.chains.label_asym_id.valueKind, schema: Z.chains.label_asym_id.schema }), Z.chains.auth_asym_id = s.ofArray({ array: H, valueKind: Z.chains.auth_asym_id.valueKind, schema: Z.chains.auth_asym_id.schema }), $;
}
function DZ1(Z, J, $, X, Y, Q) {
  let W = UZ1(Z), K = LZ1(Z, J, W), G = zZ1(K, Y);
  if (Q && OZ1(Q.atomicHierarchy, K))
    return {
      sameAsPrevious: !0,
      hierarchy: Q.atomicHierarchy,
      chainOperatorMapping: G
    };
  let H = {
    residueAtomSegments: b2.ofOffsets(W.residues, k0.ofBounds(0, Z._rowCount)),
    chainAtomSegments: b2.ofOffsets(W.chains, k0.ofBounds(0, Z._rowCount))
  }, N = yF0(K, $, H), q = bF0(K, H, N, X);
  return { sameAsPrevious: !1, hierarchy: { ...K, ...H, index: N, derived: q }, chainOperatorMapping: G };
}
function Bs(Z, J, $, X, Y, Q) {
  let { sameAsPrevious: W, hierarchy: K, chainOperatorMapping: G } = DZ1(Z, J, $, X, Y, Q), H = EZ1(Z);
  return { sameAsPrevious: W, hierarchy: K, conformation: H, chainOperatorMapping: G };
}
// node_modules/molstar/lib/mol-model/structure/model/properties/utils/coarse-index.js
function mF0(Z) {
  return new uF0(Z);
}

class dF0 {
  findElement(Z, J) {
    return J.kind = void 0, J.index = -1, !1;
  }
  findSphereElement(Z) {
    return -1;
  }
  findGaussianElement(Z) {
    return -1;
  }
}
var pF0 = new dF0;

class uF0 {
  get sphereMapping() {
    if (!this._sphereMapping)
      this._sphereMapping = gF0(this.data.spheres);
    return this._sphereMapping;
  }
  get gaussianMapping() {
    if (!this._gaussianMapping)
      this._gaussianMapping = gF0(this.data.gaussians);
    return this._gaussianMapping;
  }
  findSphereElement(Z) {
    var J;
    let X = this.sphereMapping[Z.label_entity_id];
    if (!X)
      return -1;
    if (X = X[Z.label_asym_id], !X)
      return -1;
    return (J = X[Z.label_seq_id]) !== null && J !== void 0 ? J : -1;
  }
  findGaussianElement(Z) {
    var J;
    let X = this.gaussianMapping[Z.label_entity_id];
    if (!X)
      return -1;
    if (X = X[Z.label_asym_id], !X)
      return -1;
    return (J = X[Z.label_seq_id]) !== null && J !== void 0 ? J : -1;
  }
  findElement(Z, J) {
    let $ = this.findSphereElement(Z);
    if ($ >= 0)
      return J.kind = "spheres", J.index = $, !0;
    let X = this.findGaussianElement(Z);
    if (X >= 0)
      return J.kind = "gaussians", J.index = X, !0;
    return !1;
  }
  constructor(Z) {
    this.data = Z, this._sphereMapping = void 0, this._gaussianMapping = void 0;
  }
}
function gF0({ count: Z, entity_id: J, asym_id: $, seq_id_begin: X, seq_id_end: Y }) {
  let Q = {};
  for (let W = 0;W < Z; W++) {
    let K = J.value(W), G = $.value(W);
    if (!Q[K])
      Q[K] = {};
    if (!Q[K][G])
      Q[K][G] = {};
    let H = Q[K][G], N = X.value(W), q = Y.value(W);
    for (let U = N;U <= q; U++)
      H[U] = W;
  }
  return Q;
}

// node_modules/molstar/lib/mol-model/structure/model/properties/coarse/hierarchy.js
var cF0 = {
  chainKey: [],
  entityKey: [],
  findSequenceKey: () => -1,
  findChainKey: () => -1,
  getEntityFromChain: () => -1,
  count: 0,
  entity_id: s.Undefined(0, s.Schema.str),
  asym_id: s.Undefined(0, s.Schema.str),
  seq_id_begin: s.Undefined(0, s.Schema.int),
  seq_id_end: s.Undefined(0, s.Schema.int),
  chainElementSegments: b2.create([]),
  polymerRanges: XZ.ofSortedRanges([]),
  gapRanges: XZ.ofSortedRanges([])
};
var Rh;
(function(Z) {
  Z.Empty = {
    isDefined: !1,
    spheres: cF0,
    gaussians: cF0,
    index: pF0
  };
})(Rh || (Rh = {}));
// node_modules/molstar/lib/mol-model/structure/model/properties/utils/coarse-keys.js
function MZ1(Z, J, $) {
  if (Z.has(J))
    return Z.get(J);
  let X = $.index++;
  return Z.set(J, X), X;
}
function AZ1(Z, J) {
  if (Z.has(J))
    return Z.get(J);
  let $ = /* @__PURE__ */ new Map;
  return Z.set(J, $), $;
}
function BZ1(Z, J, $) {
  let X = Z.getEntityIndex;
  return { findChainKey: (W, K) => {
    let G = X(W);
    if (G < 0)
      return -1;
    let H = J.get(G);
    if (!H.has(K))
      return -1;
    return H.get(K);
  }, findSequenceKey: (W, K, G) => {
    let H = X(W);
    if (H < 0)
      return -1;
    let N = J.get(H);
    if (N === void 0)
      return -1;
    let q = N.get(K);
    if (q === void 0)
      return -1;
    let U = $.get(q), { elementIndices: F, seqRanges: E } = U, R = XZ.firstIntersectionIndex(E, f0.ofSingleton(G));
    return R !== -1 ? F[R] : -1;
  } };
}
function wZ1(Z) {
  throw new Error(`Missing entity entry for entity id '${Z}'.`);
}
function ws(Z, J) {
  let { entity_id: $, asym_id: X, seq_id_begin: Y, seq_id_end: Q, count: W, chainElementSegments: K } = Z, G = /* @__PURE__ */ new Map, H = /* @__PURE__ */ new Map, N = { index: 0 }, q = new Int32Array(W), U = new Int32Array(W), F = new Int32Array(K.count);
  for (let D = 0;D < W; D++)
    if (U[D] = J.getEntityIndex($.value(D)), U[D] < 0)
      wZ1($.value(D));
  for (let D = 0;D < K.count; D++) {
    let A = K.offsets[D], B = K.offsets[D + 1], T = U[A];
    F[D] = T;
    let w = AZ1(H, T), V = MZ1(w, X.value(A), N);
    for (let f = A;f < B; f++)
      q[f] = V;
    let P = [], I = [];
    for (let f = A;f < B; f++) {
      let v = Y.value(f), h = Q.value(f);
      P.push(f), I.push(v, h);
    }
    let S = { elementIndices: P, seqRanges: XZ.ofSortedRanges(I) };
    G.set(V, S);
  }
  let { findChainKey: E, findSequenceKey: R } = BZ1(J, H, G);
  return { chainKey: q, entityKey: U, findSequenceKey: R, findChainKey: E, getEntityFromChain: (D) => {
    return F[D];
  } };
}

// node_modules/molstar/lib/mol-model/structure/model/properties/utils/coarse-ranges.js
function js(Z, J) {
  let $ = [], X = [], Y = b2.transientSegments(Z.chainElementSegments, k0.ofBounds(0, Z.count)), { seq_id_begin: Q, seq_id_end: W } = Z;
  while (Y.hasNext) {
    let { start: K, end: G } = Y.move(), H = -1, N = -1;
    for (let q = K;q < G; ++q) {
      let U = W.value(q);
      if (q === K)
        H = q, N = W.value(q);
      else if (Q.value(q) - N > 1)
        $.push(H, q - 1), X.push(q - 1, q), H = q;
      if (q === G - 1)
        $.push(H, q);
      N = U;
    }
  }
  return {
    polymerRanges: XZ.ofSortedRanges($),
    gapRanges: XZ.ofSortedRanges(X)
  };
}

// node_modules/molstar/lib/mol-model-formats/structure/basic/coarse.js
var Ts = { hierarchy: Rh.Empty, conformation: void 0 };
function nF0(Z, J) {
  let { ihm_sphere_obj_site: $, ihm_gaussian_obj_site: X } = Z;
  if ($._rowCount === 0 && X._rowCount === 0)
    return Ts;
  let Y = lF0($), Q = jZ1($), W = ws(Y, Z.entities), K = js(Y, J), G = lF0(X), H = TZ1(X), N = ws(G, Z.entities), q = js(G, J);
  return {
    hierarchy: {
      isDefined: !0,
      spheres: { ...Y, ...W, ...K },
      gaussians: { ...G, ...N, ...q },
      index: mF0({ spheres: Y, gaussians: G })
    },
    conformation: {
      id: R6.create22(),
      spheres: Q,
      gaussians: H
    }
  };
}
function jZ1(Z) {
  return {
    x: Z.Cartn_x.toArray({ array: Float32Array }),
    y: Z.Cartn_y.toArray({ array: Float32Array }),
    z: Z.Cartn_z.toArray({ array: Float32Array }),
    radius: Z.object_radius.toArray({ array: Float32Array }),
    rmsf: Z.rmsf.toArray({ array: Float32Array })
  };
}
function TZ1(Z) {
  let J = E9.ihm_gaussian_obj_site.covariance_matrix.space, $ = [], { covariance_matrix: X } = Z;
  for (let Y = 0, Q = X.rowCount;Y < Q; Y++)
    $[Y] = M8.toMat3(h2(), J, X.value(Y));
  return {
    x: Z.mean_Cartn_x.toArray({ array: Float32Array }),
    y: Z.mean_Cartn_y.toArray({ array: Float32Array }),
    z: Z.mean_Cartn_z.toArray({ array: Float32Array }),
    weight: Z.weight.toArray({ array: Float32Array }),
    covariance_matrix: $
  };
}
function _Z1(Z, J, $) {
  let X = [0];
  for (let Y = 1, Q = Z.rowCount;Y < Q; Y++)
    if (!Z.areValuesEqual(Y - 1, Y))
      X[X.length] = Y;
  return {
    chainElementSegments: b2.ofOffsets(X, k0.ofBounds(0, Z.rowCount))
  };
}
function lF0(Z) {
  let { entity_id: J, seq_id_begin: $, seq_id_end: X, asym_id: Y } = Z;
  return { count: J.rowCount, entity_id: J, asym_id: Y, seq_id_begin: $, seq_id_end: X, ..._Z1(Y, $, X) };
}

// node_modules/molstar/lib/mol-model/sequence/constants.js
var VZ1 = {
  HIS: "H",
  ARG: "R",
  LYS: "K",
  ILE: "I",
  PHE: "F",
  LEU: "L",
  TRP: "W",
  ALA: "A",
  MET: "M",
  PRO: "P",
  CYS: "C",
  ASN: "N",
  VAL: "V",
  GLY: "G",
  SER: "S",
  GLN: "Q",
  TYR: "Y",
  ASP: "D",
  GLU: "E",
  THR: "T",
  SEC: "U",
  PYL: "O",
  HSD: "H",
  HSE: "H",
  HSP: "H",
  LSN: "K",
  ASPP: "D",
  GLUP: "E",
  HID: "H",
  HIE: "H",
  HIP: "H",
  LYN: "K",
  ASH: "D",
  GLH: "E"
}, IZ1 = {
  DA: "A",
  DC: "C",
  DG: "G",
  DT: "T",
  DU: "U"
}, PZ1 = {
  A: "A",
  C: "C",
  G: "G",
  T: "T",
  U: "U"
};
function _s(Z) {
  return VZ1[Z] || "X";
}
function Vs(Z) {
  return PZ1[Z] || "X";
}
function Is(Z) {
  return IZ1[Z] || "X";
}

// node_modules/molstar/lib/mol-model/sequence/sequence.js
var Oz;
(function(Z) {
  let J;
  (function(H) {
    H.Protein = "protein", H.RNA = "RNA", H.DNA = "DNA", H.Generic = "generic";
  })(J = Z.Kind || (Z.Kind = {}));
  function $(H) {
    let N = H.code.toArray();
    return (N instanceof Array ? N : Array.from(N)).join("");
  }
  Z.getSequenceString = $;
  function X(H) {
    for (let N = 0, q = Math.min(H.rowCount, 10);N < q; N++) {
      let U = H.value(N) || "";
      if (_s(U) !== "X")
        return J.Protein;
      if (Vs(U) !== "X")
        return J.RNA;
      if (Is(U) !== "X")
        return J.DNA;
    }
    return J.Generic;
  }
  function Y(H, N) {
    let q;
    switch (H) {
      case J.Protein:
        q = _s;
        break;
      case J.DNA:
        q = Is;
        break;
      case J.RNA:
        q = Vs;
        break;
      case J.Generic:
        q = () => "X";
        break;
      default:
        T8(H);
    }
    if (N && N.size > 0)
      return (U) => {
        let F = q(U);
        if (F !== "X" || !N.has(U))
          return F;
        return q(N.get(U));
      };
    return q;
  }
  function Q(H, N) {
    if (N.rowCount === 0)
      throw new Error("cannot be empty");
    let q = X(H);
    return new W(q, H, N);
  }
  Z.ofResidueNames = Q;

  class W {
    index(H) {
      return this.indexMap.get(H);
    }
    constructor(H, N, q) {
      this.kind = H, this.microHet = /* @__PURE__ */ new Map;
      let U = Y(H), F = [], E = [], R = [], z = /* @__PURE__ */ new Map, D = 0, A = /* @__PURE__ */ new Map;
      for (let T = 0, w = q.rowCount;T < w; ++T) {
        let V = q.value(T);
        if (!A.has(V)) {
          A.set(V, D);
          let P = N.value(T);
          E[D] = P, R[D] = V, F[D] = U(P), D += 1;
        } else if (!z.has(V))
          z.set(V, [E[A.get(V)], N.value(T)]);
        else
          z.get(V).push(N.value(T));
      }
      let B = [];
      for (let T = 0, w = D;T < w; ++T) {
        let V = z.get(R[T]);
        if (V) {
          let P = V.map((I) => {
            let S = U(I);
            return S === "X" ? I : S;
          });
          B[T] = `(${P.join("|")})`;
        } else
          B[T] = F[T] === "X" ? E[T] : F[T];
      }
      this.length = D, this.code = s.ofStringArray(F), this.compId = s.ofStringArray(E), this.seqId = s.ofIntArray(R), this.label = s.ofStringArray(B), this.microHet = z, this.indexMap = A;
    }
  }
  function K(H, N) {
    let q = J.Generic;
    return new G(q, H, N);
  }
  Z.ofSequenceRanges = K;

  class G {
    index(H) {
      return H - this.minSeqId;
    }
    constructor(H, N, q) {
      this.kind = H, this.seqIdStart = N, this.seqIdEnd = q, this.microHet = /* @__PURE__ */ new Map;
      let U = 0, F = Number.MAX_SAFE_INTEGER;
      for (let R = 0, z = this.seqIdStart.rowCount;R < z; R++) {
        let D = this.seqIdStart.value(R), A = this.seqIdEnd.value(R);
        if (D < F)
          F = D;
        if (U < A)
          U = A;
      }
      let E = U - F + 1;
      this.code = s.ofConst("X", E, s.Schema.str), this.label = s.ofConst("", E, s.Schema.str), this.seqId = s.ofLambda({
        value: (R) => R + F + 1,
        rowCount: E,
        schema: s.Schema.int
      }), this.compId = s.ofConst("", E, s.Schema.str), this.length = E, this.minSeqId = F;
    }
  }
})(Oz || (Oz = {}));
// node_modules/molstar/lib/mol-model/structure/model/properties/sequence.js
var KV;
(function(Z) {
  let J = { byEntityKey: {}, sequences: [] };
  function $(...K) {
    let G = [], H = {};
    for (let N = 0, q = K.length;N < q; ++N)
      G.push(...K[N].sequences), Object.assign(H, K[N].byEntityKey);
    return { sequences: G, byEntityKey: H };
  }
  function X(K, G, H) {
    let N = Y(K, G), q = H.isDefined ? Q(K, H) : J;
    return $(N, q);
  }
  Z.fromHierarchy = X;
  function Y(K, G) {
    let { label_comp_id: H } = G.atoms, { label_seq_id: N } = G.residues, { chainAtomSegments: q, residueAtomSegments: U } = G, { count: F, offsets: E } = q, R = {}, z = [];
    if (F === 1 && E[0] === 0 && E[1] === 0)
      return { byEntityKey: R, sequences: z };
    for (let D = 0, A = G.chains._rowCount;D < A; D++) {
      let B = G.index.getEntityFromChain(D);
      if (R[B] !== void 0 || K.data.type.value(B) !== "polymer")
        continue;
      let T = D;
      D++;
      while (D < A && B === G.index.getEntityFromChain(D) && K.data.type.value(B) !== "polymer")
        D++;
      D--;
      let w = U.index[E[T]], V = U.index[E[D + 1] - 1] + 1, P = s.window(N, w, V), I = [];
      for (let f = w;f < V; ++f)
        I.push(H.value(U.offsets[f]));
      let S = s.ofStringArray(I);
      R[B] = {
        entityId: K.data.id.value(B),
        sequence: Oz.ofResidueNames(S, P)
      }, z.push(R[B]);
    }
    return { byEntityKey: R, sequences: z };
  }
  Z.fromAtomicHierarchy = Y;
  function Q(K, G) {
    let H = W(K, G.spheres), N = W(K, G.gaussians);
    return $(H, N);
  }
  Z.fromCoarseHierarchy = Q;
  function W(K, G) {
    let { chainElementSegments: H, seq_id_begin: N, seq_id_end: q } = G, { count: U, offsets: F } = H, E = {}, R = [];
    if (U === 1 && F[0] === 0 && F[1] === 0)
      return { byEntityKey: E, sequences: R };
    for (let z = 0, D = U;z < D; z++) {
      let A = G.getEntityFromChain(z);
      if (E[A] !== void 0)
        continue;
      let B = z;
      z++;
      while (z < D && A === G.getEntityFromChain(z))
        z++;
      z--;
      let T = F[B], w = F[z + 1] - 1, V = s.window(N, T, w), P = s.window(q, T, w);
      E[A] = {
        entityId: K.data.id.value(A),
        sequence: Oz.ofSequenceRanges(V, P)
      }, R.push(E[A]);
    }
    return { byEntityKey: E, sequences: R };
  }
  Z.fromCoarseElements = W;
})(KV || (KV = {}));

// node_modules/molstar/lib/mol-model-formats/structure/basic/sequence.js
function Ps(Z, J, $, X) {
  if (!Z.entity_poly_seq || !Z.entity_poly_seq._rowCount)
    return KV.fromHierarchy(J, $, X);
  let { entity_id: Y, num: Q, mon_id: W } = Z.entity_poly_seq, K = {}, G = [], H = Y.rowCount, N = 0;
  while (N < H) {
    let q = N;
    while (N < H - 1 && Y.areValuesEqual(N, N + 1))
      N++;
    N++;
    let U = Y.value(q), F = s.window(W, q, N), E = s.window(Q, q, N), R = J.getEntityIndex(U);
    K[R] = {
      entityId: U,
      sequence: Oz.ofResidueNames(F, E)
    }, G.push(K[R]);
  }
  return { byEntityKey: K, sequences: G };
}

// node_modules/molstar/lib/mol-model-formats/structure/basic/sort.js
async function Cs(Z, J, $, X) {
  let Y = E_($, X - 1), { label_entity_id: Q, label_asym_id: W, label_seq_id: K } = J, G = Cf(Y, Q.value);
  if (Z.shouldUpdate)
    await Z.update();
  for (let H = 0, N = G.length - 1;H < N; H++) {
    let q = Cf(Y, W.value, { start: G[H], end: G[H + 1] });
    for (let U = 0, F = q.length - 1;U < F; U++) {
      let E = q[U];
      if (K.valueKind(E) !== s.ValueKinds.Present)
        continue;
      if (Cf(Y, K.value, { sort: !0, start: E, end: q[U + 1] }), Z.shouldUpdate)
        await Z.update();
    }
    if (Z.shouldUpdate)
      await Z.update();
  }
  if (xK0(Y) && Y.length === J._rowCount)
    return { atom_site: J, sourceIndex: s.ofIntArray(Y) };
  return {
    atom_site: A8.view(J, J._schema, Y),
    sourceIndex: s.ofIntArray(Y)
  };
}

// node_modules/molstar/lib/mol-model/structure/model/properties/utils/atomic-ranges.js
function iF0(Z, J, $, X, Y) {
  let { polymerType: Q, traceElementIndex: W, directionFromElementIndex: K, directionToElementIndex: G } = Y.residue, H = Q[Z], N = Q[J];
  if (H === q$.NA || N === q$.NA)
    return !1;
  if (W[Z] === -1 || W[J] === -1)
    return !1;
  let q = X.findAtomsOnResidue(Z, yN(H, "backboneStart")), U = X.findAtomsOnResidue(J, yN(N, "backboneEnd"));
  if (q === -1 || U === -1)
    q = X.findAtomsOnResidue(Z, yN(H, "coarseBackbone")), U = X.findAtomsOnResidue(J, yN(N, "coarseBackbone"));
  let { x: F, y: E, z: R } = $, z = M.create(F[q], E[q], R[q]), D = M.create(F[U], E[U], R[U]), A = K[Z] === -1 || G[Z] === -1 || K[J] === -1 || G[J] === -1;
  return M.distance(z, D) < (A ? 10 : 3);
}
function ks(Z, J, $, X) {
  let Y = [], Q = [], W = /* @__PURE__ */ new Map, K = b2.transientSegments(Z.chainAtomSegments, k0.ofBounds(0, Z.atoms._rowCount)), G = b2.transientSegments(Z.residueAtomSegments, k0.ofBounds(0, Z.atoms._rowCount)), { index: H, derived: N } = Z, { label_seq_id: q } = Z.residues, { label_entity_id: U } = Z.chains, { moleculeType: F, traceElementIndex: E } = N.residue, R, z, D, A;
  while (K.hasNext) {
    let B = K.move();
    G.setSegment(B), R = -1, z = -1, D = -1, A = -1;
    let T = J.getEntityIndex(U.value(B.index)), w = X.byEntityKey[T], V = w ? w.sequence.seqId.value(w.sequence.seqId.rowCount - 1) : -1, P = Z.residueAtomSegments.index[B.start], I = Z.residueAtomSegments.index[B.end - 1], S = q.value(P), f = q.value(I);
    if (S === 1 && f === V && $.xyzDefined && iF0(P, I, $, H, N))
      W.set(P, I), W.set(I, P);
    while (G.hasNext) {
      let v = G.move(), h = v.index, x = q.value(h);
      if (MR(F[h]) && E[h] !== -1)
        if (A !== -1)
          if (x !== R + 1)
            Y.push(A, D - 1), Q.push(z, v.end - 1), A = v.start;
          else if (!G.hasNext)
            Y.push(A, v.end - 1);
          else {
            let b = Z.residueAtomSegments.index[v.start], g = Z.residueAtomSegments.index[D - 1];
            if ($.xyzDefined && !iF0(b, g, $, Z.index, N))
              Y.push(A, D - 1), Q.push(z, v.end - 1), A = v.start;
          }
        else
          A = v.start;
      else if (A !== -1)
        Y.push(A, D - 1), A = -1;
      z = v.start, D = v.end, R = x;
    }
  }
  return {
    polymerRanges: XZ.ofSortedRanges(Y),
    gapRanges: XZ.ofSortedRanges(Q),
    cyclicPolymerMap: W
  };
}

// node_modules/molstar/lib/mol-model-formats/structure/basic/properties.js
function oF0(Z) {
  let J = /* @__PURE__ */ new Map, $ = (Y, Q, W) => {
    return `${Y}|${Q}|${W}`;
  }, X = Z.pdbx_unobs_or_zero_occ_residues;
  for (let Y = 0, Q = X._rowCount;Y < Q; ++Y) {
    let W = $(X.PDB_model_num.value(Y), X.label_asym_id.value(Y), X.label_seq_id.value(Y));
    J.set(W, { polymer_flag: X.polymer_flag.value(Y), occupancy_flag: X.occupancy_flag.value(Y) });
  }
  return {
    has: (Y, Q, W) => {
      return J.has($(Y, Q, W));
    },
    get: (Y, Q, W) => {
      return J.get($(Y, Q, W));
    },
    size: J.size
  };
}
function sF0(Z) {
  let J = /* @__PURE__ */ new Map;
  if (Z.chem_comp._rowCount > 0) {
    let { id: $ } = Z.chem_comp;
    for (let X = 0, Y = $.rowCount;X < Y; ++X)
      J.set($.value(X), A8.getRow(Z.chem_comp, X));
  } else
    rF0(Z).forEach((X) => {
      J.set(X, $N0(X));
    });
  return J;
}
function aF0(Z) {
  let J = /* @__PURE__ */ new Map;
  if (Z.pdbx_chem_comp_identifier._rowCount > 0) {
    let { comp_id: $, type: X, identifier: Y } = Z.pdbx_chem_comp_identifier;
    for (let Q = 0, W = $.rowCount;Q < W; ++Q)
      if (X.value(Q) === "SNFG CARBOHYDRATE SYMBOL" || X.value(Q) === "SNFG CARB SYMBOL") {
        let K = Y.value(Q), G = hH0.get(K);
        if (G)
          J.set($.value(Q), G);
        else
          console.warn(`Unknown SNFG name '${K}'`);
      }
  }
  if (Z.chem_comp._rowCount > 0) {
    let { id: $, type: X } = Z.chem_comp;
    for (let Y = 0, Q = $.rowCount;Y < Q; ++Y) {
      let W = $.value(Y);
      if (J.has(W))
        continue;
      let K = X.value(Y);
      if (D3.has(W))
        J.set(W, D3.get(W));
      else if (qY(K, W) === e2.Saccharide)
        J.set(W, kf);
    }
  } else {
    let $ = rF0(Z);
    D3.forEach((X, Y) => {
      if (!J.has(Y) && $.has(Y))
        J.set(Y, X);
    });
  }
  return J;
}
var rF0 = QH((Z) => {
  let J = /* @__PURE__ */ new Set, { label_comp_id: $, auth_comp_id: X } = Z.atom_site, Y = $.isDefined ? $ : X;
  for (let Q = 0, W = Y.rowCount;Q < W; ++Q)
    J.add(Y.value(Q));
  return J;
});
function vs(Z, J) {
  let $ = /* @__PURE__ */ new Map, { auth_asym_id: X, label_asym_id: Y, label_entity_id: Q } = Z.chains;
  for (let W = 0, K = Z.chains._rowCount;W < K; W++) {
    let G = Y.value(W);
    $.set(G, { id: G, auth_id: X.value(W), entity_id: Q.value(W) });
  }
  if (J === null || J === void 0 ? void 0 : J.struct_asym._rowCount) {
    let { id: W, entity_id: K } = J.struct_asym;
    for (let G = 0, H = W.rowCount;G < H; ++G) {
      let N = W.value(G);
      if (!$.has(N))
        $.set(N, {
          id: N,
          auth_id: "",
          entity_id: K.value(G)
        });
    }
  }
  return $;
}

// node_modules/molstar/lib/mol-model/structure/model/properties/common.js
var tF0 = s.Schema.Aliased(s.Schema.Str());

// node_modules/molstar/lib/mol-model-formats/structure/basic/entities.js
function Ss(Z) {
  let J;
  if (!Z.entity.id.isDefined) {
    let K = /* @__PURE__ */ new Set, G = [], H = [], { label_entity_id: N, label_comp_id: q } = Z.atom_site;
    for (let E = 0, R = Z.atom_site._rowCount;E < R; E++) {
      let z = N.value(E);
      if (!K.has(z))
        G.push(z), H.push(XN0(q.value(E))), K.add(z);
    }
    let { entity_id: U } = Z.ihm_sphere_obj_site;
    for (let E = 0, R = Z.ihm_sphere_obj_site._rowCount;E < R; E++) {
      let z = U.value(E);
      if (!K.has(z))
        G.push(z), H.push("polymer"), K.add(z);
    }
    let { entity_id: F } = Z.ihm_gaussian_obj_site;
    for (let E = 0, R = Z.ihm_gaussian_obj_site._rowCount;E < R; E++) {
      let z = F.value(E);
      if (!K.has(z))
        G.push(z), H.push("polymer"), K.add(z);
    }
    J = A8.ofPartialColumns(E9.entity, {
      id: s.ofArray({ array: G, schema: E9.entity.id }),
      type: s.ofArray({ array: H, schema: E9.entity.type })
    }, G.length);
  } else
    J = Z.entity;
  let $ = s.createIndexer(J.id), X = new Array(J._rowCount);
  X.fill("other");
  let Y = /* @__PURE__ */ new Set, Q = !1;
  if (Z.entity_poly && Z.entity_poly.type.isDefined) {
    let { entity_id: K, type: G, _rowCount: H } = Z.entity_poly;
    for (let N = 0;N < H; ++N) {
      let q = K.value(N);
      X[$(q)] = G.value(N), Y.add(q);
    }
  } else
    Q = !0;
  if (Z.pdbx_entity_branch && Z.pdbx_entity_branch.entity_id.isDefined) {
    let { entity_id: K, type: G, _rowCount: H } = Z.pdbx_entity_branch;
    for (let N = 0;N < H; ++N) {
      let q = K.value(N);
      X[$(q)] = G.value(N), Y.add(q);
    }
  } else
    Q = !0;
  if (Y.size < X.length)
    Q = !0;
  if (Q) {
    let K = /* @__PURE__ */ new Map;
    if (Z.chem_comp) {
      let { id: G, type: H } = Z.chem_comp;
      for (let N = 0, q = Z.chem_comp._rowCount;N < q; N++)
        K.set(G.value(N), H.value(N));
    }
    if (Z.atom_site) {
      let { label_entity_id: G, label_comp_id: H } = Z.atom_site;
      for (let N = 0, q = Z.atom_site._rowCount;N < q; N++) {
        let U = G.value(N);
        if (!Y.has(U)) {
          let F = H.value(N), E = K.get(F) || "other";
          X[$(U)] = YN0(F, E), Y.add(U);
        }
      }
    }
  }
  let W = s.ofArray({ array: X, schema: tF0 });
  return {
    data: J,
    subtype: W,
    getEntityIndex: $
  };
}
function fs(Z, J, $) {
  var X;
  if (!Z.pdbx_molecule || !Z.pdbx_molecule.prd_id.isDefined)
    return J;
  let Y = new Array(J.data._rowCount);
  Y.fill("");
  let { asym_id: Q, prd_id: W, _rowCount: K } = Z.pdbx_molecule;
  for (let H = 0;H < K; ++H) {
    let N = Q.value(H), q = (X = $.get(N)) === null || X === void 0 ? void 0 : X.entity_id;
    if (q !== void 0)
      Y[J.getEntityIndex(q)] = W.value(H);
  }
  let G = s.ofArray({ array: Y, schema: s.Schema.str });
  return {
    ...J,
    prd_id: G
  };
}

// node_modules/molstar/lib/mol-model/structure/trajectory.js
class UY {
  getFrameAtIndex(Z) {
    return this.frames[Z];
  }
  constructor(Z) {
    this.frames = Z, this.frameCount = Z.length, this.representative = Z[0], this.duration = Z.length;
  }
}

// node_modules/molstar/lib/mol-model-formats/structure/basic/parser.js
async function nJ(Z, J, $) {
  let X = CZ1(Z, J), Y = Z.ihm_model_list._rowCount > 0 ? await fZ1($, Z, X, J) : await SZ1($, Z, X, J);
  for (let Q = 0;Q < Y.length; Q++)
    O2.TrajectoryInfo.set(Y[Q], { index: Q, size: Y.length });
  return new UY(Y);
}
function CZ1(Z, J) {
  return {
    missingResidues: oF0(Z),
    chemicalComponentMap: sF0(Z),
    saccharideComponentMap: aF0(Z)
  };
}
function kZ1(Z, J, $, X, Y, Q, W) {
  let K = Bs(J, $, X, Y.chemicalComponentMap, Q, W), G = J.pdbx_PDB_model_num.value(0);
  if (W && K.sameAsPrevious)
    return {
      ...W,
      id: R6.create22(),
      modelNum: G,
      atomicConformation: K.conformation,
      _dynamicPropertyData: Object.create(null)
    };
  let H = Ts, N = Ps(Z, X, K.hierarchy, H.hierarchy), q = ks(K.hierarchy, X, K.conformation, N), U = vs(K.hierarchy), F = Z.entry.id.valueKind(0) === s.ValueKinds.Present ? Z.entry.id.value(0) : Q.name, E = [];
  if (F)
    E.push(F);
  if (Z.struct.title.valueKind(0) === s.ValueKinds.Present)
    E.push(Z.struct.title.value(0));
  return {
    id: R6.create22(),
    entryId: F,
    label: E.join(" | "),
    entry: F,
    sourceData: Q,
    modelNum: G,
    parent: void 0,
    entities: fs(Z, X, U),
    sequence: N,
    atomicHierarchy: K.hierarchy,
    atomicConformation: K.conformation,
    atomicRanges: q,
    atomicChainOperatorMappinng: K.chainOperatorMapping,
    coarseHierarchy: H.hierarchy,
    coarseConformation: H.conformation,
    properties: {
      ...Y,
      structAsymMap: U
    },
    customProperties: new H$,
    _staticPropertyData: Object.create(null),
    _dynamicPropertyData: Object.create(null)
  };
}
function vZ1(Z, J, $, X) {
  let Y = Bs(J.atom_site, J.atom_site_sourceIndex, J.entities, $.chemicalComponentMap, X), Q = nF0(J, $.chemicalComponentMap), W = Ps(Z, J.entities, Y.hierarchy, Q.hierarchy), K = ks(Y.hierarchy, J.entities, Y.conformation, W), G = Z.entry.id.valueKind(0) === s.ValueKinds.Present ? Z.entry.id.value(0) : X.name, H = [];
  if (G)
    H.push(G);
  if (Z.struct.title.valueKind(0) === s.ValueKinds.Present)
    H.push(Z.struct.title.value(0));
  if (J.model_name)
    H.push(J.model_name);
  if (J.model_group_name)
    H.push(J.model_group_name);
  let N = vs(Y.hierarchy, Z);
  return {
    id: R6.create22(),
    entryId: G,
    label: H.join(" | "),
    entry: G,
    sourceData: X,
    modelNum: J.model_id,
    parent: void 0,
    entities: fs(Z, J.entities, N),
    sequence: W,
    atomicHierarchy: Y.hierarchy,
    atomicConformation: Y.conformation,
    atomicRanges: K,
    atomicChainOperatorMappinng: Y.chainOperatorMapping,
    coarseHierarchy: Q.hierarchy,
    coarseConformation: Q.conformation,
    properties: {
      ...$,
      structAsymMap: N
    },
    customProperties: new H$,
    _staticPropertyData: Object.create(null),
    _dynamicPropertyData: Object.create(null)
  };
}
function eF0(Z, J) {
  let $ = Z.rowCount;
  if (!Z.isDefined)
    return $;
  let X = J + 1;
  while (X < $ && Z.areValuesEqual(J, X))
    X++;
  return X;
}
async function SZ1(Z, J, $, X) {
  let Y = [];
  if (J.atom_site) {
    let Q = J.atom_site.id.rowCount, W = Ss(J), K = 0;
    while (K < Q) {
      let G = eF0(J.atom_site.pdbx_PDB_model_num, K), { atom_site: H, sourceIndex: N } = await Cs(Z, J.atom_site, K, G), q = kZ1(J, H, N, W, $, X, Y.length > 0 ? Y[Y.length - 1] : void 0);
      Y.push(q), K = G;
    }
  }
  return Y;
}
function hs(Z, J) {
  let $ = /* @__PURE__ */ new Map, X = Z._rowCount, Y = 0;
  while (Y < X) {
    let Q = eF0(J, Y), W = J.value(Y);
    $.set(W, {
      table: A8.window(Z, Z._schema, Y, Q),
      start: Y,
      end: Q
    }), Y = Q;
  }
  return $;
}
async function fZ1(Z, J, $, X) {
  let Y = Ss(J), Q = J.atom_site.ihm_model_id.isDefined ? J.atom_site.ihm_model_id : J.atom_site.pdbx_PDB_model_num, W = hs(J.atom_site, Q), K = hs(J.ihm_sphere_obj_site, J.ihm_sphere_obj_site.model_id), G = hs(J.ihm_gaussian_obj_site, J.ihm_gaussian_obj_site.model_id), H = [];
  if (J.ihm_model_list) {
    let { model_id: N, model_name: q } = J.ihm_model_list;
    for (let U = 0;U < J.ihm_model_list._rowCount; U++) {
      let F = N.value(U), E, R;
      if (W.has(F)) {
        let A = W.get(F), { atom_site: B, sourceIndex: T } = await Cs(Z, J.atom_site, A.start, A.end);
        E = B, R = T;
      } else
        E = A8.window(J.atom_site, J.atom_site._schema, 0, 0), R = s.ofIntArray([]);
      let z = {
        model_id: F,
        model_name: q.value(U),
        model_group_name: BF0(F, J),
        entities: Y,
        atom_site: E,
        atom_site_sourceIndex: R,
        ihm_sphere_obj_site: K.has(F) ? K.get(F).table : A8.window(J.ihm_sphere_obj_site, J.ihm_sphere_obj_site._schema, 0, 0),
        ihm_gaussian_obj_site: G.has(F) ? G.get(F).table : A8.window(J.ihm_gaussian_obj_site, J.ihm_gaussian_obj_site._schema, 0, 0)
      }, D = vZ1(J, z, $, X);
      H.push(D);
    }
  }
  return H;
}

// node_modules/molstar/lib/mol-model/structure/model/model.js
var O2;
(function(Z) {
  function J(u, G0) {
    let F0 = [], { frames: t } = G0, Z0 = $(u), U0 = B(u), a = u.atomicHierarchy.atoms._rowCount;
    for (let Q0 = 0, $0 = t.length;Q0 < $0; ++Q0) {
      let R0 = t[Q0];
      if (R0.elementCount !== a)
        throw new Error(`Frame element count mismatch, got ${R0.elementCount} but expected ${a}.`);
      let X0 = {
        ...u,
        id: R6.create22(),
        modelNum: Q0,
        atomicConformation: Q(u, R0),
        customProperties: new H$,
        _staticPropertyData: Object.create(null),
        _dynamicPropertyData: Object.create(null)
      };
      if (R0.cell) {
        let E0 = T9.fromCell(R0.cell.size, R0.cell.anglesInRadians);
        T9.Provider.set(X0, E0);
      }
      Z.TrajectoryInfo.set(X0, { index: Q0, size: t.length }), Z.CoarseGrained.set(X0, U0), F0.push(X0);
    }
    return { trajectory: F0, srcIndexArray: Z0 };
  }
  function $(u) {
    let G0 = u.atomicHierarchy.atomSourceIndex, F0 = void 0;
    if ("__srcIndexArray__" in u._staticPropertyData)
      F0 = u._dynamicPropertyData.__srcIndexArray__;
    else
      F0 = s.isIdentity(G0) ? void 0 : G0.toArray({ array: Int32Array }), u._dynamicPropertyData.__srcIndexArray__ = F0;
    return F0;
  }
  function X(u, G0) {
    return new UY(J(u, G0).trajectory);
  }
  Z.trajectoryFromModelAndCoordinates = X;
  function Y(u, G0) {
    return n0.create("Create Trajectory", async (F0) => {
      let t = await nJ(u.basic, u.sourceData, F0);
      if (t.frameCount === 0)
        throw new Error("found no model");
      let Z0 = t.representative, { trajectory: U0 } = J(Z0, G0), a = { pairs: u.bonds, count: Z0.atomicHierarchy.atoms._rowCount }, Q0 = j9.fromData(a), $0 = B(Z0), R0 = 0;
      for (let X0 of U0)
        j9.Provider.set(X0, Q0), Z.TrajectoryInfo.set(X0, { index: R0++, size: U0.length }), Z.CoarseGrained.set(X0, $0);
      return new UY(U0);
    });
  }
  Z.trajectoryFromTopologyAndCoordinates = Y;
  function Q(u, G0) {
    return z5.getAtomicConformation(G0, {
      atomId: u.atomicConformation.atomId,
      occupancy: u.atomicConformation.occupancy,
      B_iso_or_equiv: u.atomicConformation.B_iso_or_equiv
    }, $(u));
  }
  Z.getAtomicConformationFromFrame = Q;
  let W = "__Center__";
  function K(u) {
    if (u._dynamicPropertyData[W])
      return u._dynamicPropertyData[W];
    let G0 = VH0(u.atomicConformation, u.coarseConformation);
    return u._dynamicPropertyData[W] = G0, G0;
  }
  Z.getCenter = K;
  let G = "__AtomicRadii__";
  function H(u) {
    if (u._dynamicPropertyData[G])
      return u._dynamicPropertyData[G];
    let G0 = u.atomicHierarchy.atoms._rowCount, F0 = u.atomicHierarchy.atoms.type_symbol.value, t = new Float32Array(G0);
    for (let Z0 = 0;Z0 < G0; Z0++)
      t[Z0] = D5(F0(Z0));
    return u._dynamicPropertyData[G] = t, t;
  }
  Z.getAtomicRadii = H;
  function N(u) {
    let G0 = new Int32Array(u.rowCount), F0 = !1;
    for (let t = 0, Z0 = u.rowCount;t < Z0; t++) {
      let U0 = u.value(t);
      if (U0 !== t)
        F0 = !1;
      G0[U0] = t;
    }
    return { isIdentity: F0, invertedIndex: G0 };
  }
  let q = "__InvertedAtomSrcIndex__";
  function U(u) {
    if (u._staticPropertyData[q])
      return u._staticPropertyData[q];
    let G0 = N(u.atomicHierarchy.atomSourceIndex);
    return u._staticPropertyData[q] = G0, G0;
  }
  Z.getInvertedAtomSourceIndex = U;
  let F = "__TrajectoryInfo__";
  Z.TrajectoryInfo = {
    get(u) {
      return u._dynamicPropertyData[F] || { index: 0, size: 1 };
    },
    set(u, G0) {
      return u._dynamicPropertyData[F] = G0;
    }
  };
  let E = "__AsymIdCount__";
  Z.AsymIdCount = {
    get(u) {
      if (u._dynamicPropertyData[E])
        return u._dynamicPropertyData[E];
      let G0 = IH0(u);
      return u._dynamicPropertyData[E] = G0, G0;
    }
  }, Z.AsymIdOffset = j3.createSimple("asym_id_offset", "static"), Z.Index = j3.createSimple("index", "static"), Z.MaxIndex = j3.createSimple("max_index", "static");
  function R(u) {
    return u.parent || u;
  }
  Z.getRoot = R;
  function z(u, G0) {
    return u.atomicHierarchy === G0.atomicHierarchy && u.coarseHierarchy === G0.coarseHierarchy;
  }
  Z.areHierarchiesEqual = z;
  let D = "__CoordinatesHistory__";
  Z.CoordinatesHistory = {
    get(u) {
      return u._staticPropertyData[D];
    },
    set(u, G0) {
      return u._staticPropertyData[D] = G0;
    }
  };
  let A = "__CoarseGrained__";
  Z.CoarseGrained = {
    get(u) {
      return u._staticPropertyData[A];
    },
    set(u, G0) {
      return u._staticPropertyData[A] = G0;
    }
  };
  function B(u) {
    let G0 = Z.CoarseGrained.get(u);
    if (G0 === void 0) {
      let F0 = 0, t = 0, { polymerType: Z0, directionToElementIndex: U0 } = u.atomicHierarchy.derived.residue;
      for (let X0 = 0;X0 < Z0.length; ++X0)
        if (Z0[X0] !== q$.NA) {
          if (F0 += 1, U0[X0] !== -1)
            t += 1;
        }
      let a = !1, Q0 = !1, { label_atom_id: $0, _rowCount: R0 } = u.atomicHierarchy.atoms;
      for (let X0 = 0;X0 < R0; ++X0) {
        let E0 = $0.value(X0);
        if (!a && E0 === "BB")
          a = !0;
        if (!Q0 && E0 === "SC1")
          Q0 = !0;
        if (a && Q0)
          break;
      }
      if (G0 = !1, R0 > 0 && F0 > 0) {
        if (a && Q0)
          G0 = !0;
        else if (R0 / F0 < 3)
          G0 = !0;
        else if (t === 0)
          G0 = !0;
      }
      Z.CoarseGrained.set(u, G0);
    }
    return G0;
  }
  Z.isCoarseGrained = B;
  function T(u) {
    return u.properties.saccharideComponentMap.size > 0;
  }
  Z.hasCarbohydrate = T;
  function w(u) {
    let { subtype: G0 } = u.entities;
    for (let F0 = 0, t = G0.rowCount;F0 < t; ++F0)
      if (G0.value(F0).startsWith("polypeptide"))
        return !0;
    return !1;
  }
  Z.hasProtein = w;
  function V(u) {
    let { subtype: G0 } = u.entities;
    for (let F0 = 0, t = G0.rowCount;F0 < t; ++F0) {
      let Z0 = G0.value(F0);
      if (Z0.endsWith("ribonucleotide hybrid") || Z0.endsWith("ribonucleotide"))
        return !0;
    }
    return !1;
  }
  Z.hasNucleic = V;
  function P(u) {
    if (!S6.is(u.sourceData))
      return !1;
    let { db: G0 } = u.sourceData.data;
    for (let F0 = 0, t = G0.database_2.database_id.rowCount;F0 < t; ++F0)
      if (G0.database_2.database_id.value(F0) === "pdb")
        return !0;
    return !1;
  }
  Z.isFromPdbArchive = P;
  function I(u) {
    if (!S6.is(u.sourceData))
      return !1;
    return u.entryId.match(/^[1-9][a-z0-9]{3,3}$/i) !== null || u.entryId.match(/^pdb_[0-9]{4,4}[1-9][a-z0-9]{3,3}$/i) !== null;
  }
  Z.hasPdbId = I;
  function S(u) {
    if (S6.is(u.sourceData)) {
      let { db: G0 } = u.sourceData.data;
      return G0.struct_conf.id.isDefined || G0.struct_sheet_range.id.isDefined;
    } else
      return HH.Provider.isApplicable(u);
  }
  Z.hasSecondaryStructure = S;
  let f = M.create(1.5707963, 1.5707963, 1.5707963), v = M.create(1, 1, 1);
  function h(u) {
    var G0;
    let F0 = (G0 = T9.Provider.get(u)) === null || G0 === void 0 ? void 0 : G0.spacegroup;
    return !!F0 && !(F0.num === 1 && M.equals(F0.cell.anglesInRadians, f) && M.equals(F0.cell.size, v));
  }
  Z.hasCrystalSymmetry = h;
  function x(u) {
    if (!S6.is(u.sourceData))
      return !1;
    let { db: G0 } = u.sourceData.data;
    for (let F0 = 0;F0 < G0.exptl.method.rowCount; F0++)
      if (G0.exptl.method.value(F0).toUpperCase().indexOf("DIFFRACTION") >= 0)
        return !0;
    return !1;
  }
  Z.isFromXray = x;
  function b(u) {
    if (!S6.is(u.sourceData))
      return !1;
    let { db: G0 } = u.sourceData.data;
    for (let F0 = 0;F0 < G0.exptl.method.rowCount; F0++)
      if (G0.exptl.method.value(F0).toUpperCase().indexOf("MICROSCOPY") >= 0)
        return !0;
    return !1;
  }
  Z.isFromEm = b;
  function g(u) {
    if (!S6.is(u.sourceData))
      return !1;
    let { db: G0 } = u.sourceData.data;
    for (let F0 = 0;F0 < G0.exptl.method.rowCount; F0++)
      if (G0.exptl.method.value(F0).toUpperCase().indexOf("NMR") >= 0)
        return !0;
    return !1;
  }
  Z.isFromNmr = g;
  function m(u) {
    if (!S6.is(u.sourceData))
      return !1;
    let { db: G0 } = u.sourceData.data;
    for (let F0 = 0;F0 < G0.struct.pdbx_structure_determination_methodology.rowCount; F0++)
      if (G0.struct.pdbx_structure_determination_methodology.value(F0).toLowerCase() === "experimental")
        return !0;
    return !1;
  }
  Z.isExperimental = m;
  function i(u) {
    if (!S6.is(u.sourceData))
      return !1;
    let { db: G0 } = u.sourceData.data;
    for (let F0 = 0;F0 < G0.struct.pdbx_structure_determination_methodology.rowCount; F0++)
      if (G0.struct.pdbx_structure_determination_methodology.value(F0).toLowerCase() === "integrative")
        return !0;
    return !1;
  }
  Z.isIntegrative = i;
  function r(u) {
    if (!S6.is(u.sourceData))
      return !1;
    let { db: G0 } = u.sourceData.data;
    for (let F0 = 0;F0 < G0.struct.pdbx_structure_determination_methodology.rowCount; F0++)
      if (G0.struct.pdbx_structure_determination_methodology.value(F0).toLowerCase() === "computational")
        return !0;
    return !1;
  }
  Z.isComputational = r;
  function Y0(u) {
    if (!S6.is(u.sourceData))
      return !1;
    if (!x(u))
      return !1;
    let { db: G0 } = u.sourceData.data, { status_code_sf: F0 } = G0.pdbx_database_status;
    return F0.isDefined && F0.value(0) === "REL";
  }
  Z.hasXrayMap = Y0;
  function c(u) {
    if (!S6.is(u.sourceData))
      return !1;
    let { db: G0 } = u.sourceData.data, { db_name: F0, content_type: t } = G0.pdbx_database_related;
    for (let Z0 = 0, U0 = G0.pdbx_database_related._rowCount;Z0 < U0; ++Z0)
      if (F0.value(Z0).toUpperCase() === "EMDB" && t.value(Z0) === "associated EM volume")
        return !0;
    return !1;
  }
  Z.hasEmMap = c;
  function n(u) {
    if (!S6.is(u.sourceData))
      return !1;
    return Y0(u) || c(u);
  }
  Z.hasDensityMap = n;
  function l(u) {
    if (!S6.is(u.sourceData))
      return !1;
    if (Z.isIntegrative(u))
      return !1;
    let { db: G0 } = u.sourceData.data;
    return n(u) || I(u) && (!G0.exptl.method.isDefined || x(u) && (!G0.pdbx_database_status.status_code_sf.isDefined || G0.pdbx_database_status.status_code_sf.valueKind(0) === s.ValueKinds.Unknown) || b(u) && !G0.pdbx_database_related.db_name.isDefined);
  }
  Z.probablyHasDensityMap = l;
})(O2 || (O2 = {}));

// node_modules/molstar/lib/mol-model/structure/model/properties/custom/indexed.js
var ZU0;
(function(Z) {
  function J(q, U, F) {
    if (!U)
      return { rowCount: 0 };
    if (F && F[U.id])
      return F[U.id];
    let E = U.getElements(q), R = { data: E, rowCount: E.elements.length };
    if (F)
      F[U.id] = R;
    return R;
  }
  Z.getCifDataSource = J;
  function $(q) {
    return new xs(q);
  }
  Z.fromAtomMap = $;
  function X(q) {
    return new xs(bs(q));
  }
  Z.fromAtomArray = X;
  let Y = (q) => q.atomicHierarchy.residueAtomSegments;
  function Q(q) {
    return new GV("residue", q, Y, j0.Kind.Atomic);
  }
  Z.fromResidueMap = Q;
  function W(q) {
    return new GV("residue", bs(q), Y, j0.Kind.Atomic);
  }
  Z.fromResidueArray = W;
  let K = (q) => q.atomicHierarchy.chainAtomSegments;
  function G(q) {
    return new GV("chain", q, K, j0.Kind.Atomic);
  }
  Z.fromChainMap = G;
  function H(q) {
    return new GV("chain", bs(q), K, j0.Kind.Atomic);
  }
  Z.fromChainArray = H;
  function N(q) {
    return new JU0(q);
  }
  Z.fromEntityMap = N;
})(ZU0 || (ZU0 = {}));
function bs(Z) {
  let J = /* @__PURE__ */ new Map;
  for (let $ = 0, X = Z.length;$ < X; $++)
    J.set($, Z[$]);
  return J;
}

class GV {
  has(Z) {
    return this.map.has(Z);
  }
  get(Z) {
    return this.map.get(Z);
  }
  getStructureElements(Z) {
    let J = Z.models;
    if (J.length !== 1)
      throw new Error("Only works on structures with a single model.");
    let $ = /* @__PURE__ */ new Set, X = Z.unitSymmetryGroups, Y = [], Q = this.segmentGetter(J[0]);
    for (let W of X) {
      let K = W.units[0];
      if (K.kind !== this.kind)
        continue;
      let G = b2.transientSegments(Q, K.elements);
      while (G.hasNext) {
        let H = G.move();
        if (!this.has(H.index) || $.has(H.index))
          continue;
        $.add(H.index), Y[Y.length] = W0.Location.create(Z, K, K.elements[H.start]);
      }
    }
    return Y.sort((W, K) => W.element - K.element), Y;
  }
  getElements(Z) {
    let J = this.segmentGetter(Z.model).index, $ = this.getStructureElements(Z);
    return { elements: $, property: (X) => this.get(J[$[X].element]) };
  }
  constructor(Z, J, $, X) {
    this.level = Z, this.map = J, this.segmentGetter = $, this.id = R6.create22(), this.kind = X;
  }
}

class xs {
  has(Z) {
    return this.map.has(Z);
  }
  get(Z) {
    return this.map.get(Z);
  }
  getStructureElements(Z) {
    if (Z.models.length !== 1)
      throw new Error("Only works on structures with a single model.");
    let $ = /* @__PURE__ */ new Set, X = Z.unitSymmetryGroups, Y = [];
    for (let Q of X) {
      let W = Q.units[0];
      if (W.kind !== this.kind)
        continue;
      let K = W.elements;
      for (let G = 0, H = K.length;G < H; G++) {
        let N = K[G];
        if (!this.has(N) || $.has(N))
          continue;
        $.add(K[G]), Y[Y.length] = W0.Location.create(Z, W, N);
      }
    }
    return Y.sort((Q, W) => Q.element - W.element), Y;
  }
  getElements(Z) {
    let J = this.getStructureElements(Z);
    return { elements: J, property: ($) => this.get(J[$].element) };
  }
  constructor(Z) {
    this.map = Z, this.id = R6.create22(), this.level = "atom", this.kind = j0.Kind.Atomic;
  }
}

class JU0 {
  has(Z) {
    return this.map.has(Z);
  }
  get(Z) {
    return this.map.get(Z);
  }
  getStructureElements(Z) {
    let J = Z.models;
    if (J.length !== 1)
      throw new Error("Only works on structures with a single model.");
    let $ = J[0].atomicHierarchy.index, X = /* @__PURE__ */ new Set, Y = Z.unitSymmetryGroups, Q = [], W = J[0].atomicHierarchy.chainAtomSegments;
    for (let K of Y) {
      let G = K.units[0];
      if (G.kind !== this.kind)
        continue;
      let H = b2.transientSegments(W, G.elements);
      while (H.hasNext) {
        let N = H.move(), q = $.getEntityFromChain(N.index);
        if (!this.has(q) || X.has(q))
          continue;
        X.add(q), Q[Q.length] = W0.Location.create(Z, G, G.elements[N.start]);
      }
    }
    return Q.sort((K, G) => K.element - G.element), Q;
  }
  getElements(Z) {
    let J = this.getStructureElements(Z), $ = Z.model.atomicHierarchy.chainAtomSegments.index, X = Z.model.atomicHierarchy.index;
    return { elements: J, property: (Y) => this.get(X.getEntityFromChain($[J[Y].element])) };
  }
  constructor(Z) {
    this.map = Z, this.id = R6.create22(), this.level = "entity", this.kind = j0.Kind.Atomic;
  }
}
// node_modules/molstar/lib/mol-util/browser.js
function $U0() {
  if (typeof navigator === "undefined" || typeof window === "undefined")
    return !1;
  let Z = !1;
  return function(J) {
    if (/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(J) || /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(J.substr(0, 4)))
      Z = !0;
  }(navigator.userAgent || navigator.vendor || window.opera), Z;
}
function ys() {
  if (typeof navigator === "undefined" || typeof window === "undefined")
    return !1;
  let Z = /iPad|iPhone|iPod/.test(navigator.userAgent), J = navigator.userAgent.includes("Macintosh"), $ = navigator.maxTouchPoints >= 4;
  return !window.MSStream && (Z || J && $);
}
function XU0() {
  if (typeof navigator === "undefined")
    return !1;
  if (!("xr" in navigator))
    return !1;
  let Z = navigator.userAgent || "";
  return /OculusBrowser\//.test(Z) || /PicoBrowser\//.test(Z);
}

// node_modules/molstar/lib/mol-plugin/features.js
var gs = {
  get defaultTransparency() {
    return ys() ? "blended" : "wboit";
  },
  get preferWebGl1() {
    if (typeof navigator === "undefined" || typeof window === "undefined")
      return !1;
    if ([
      "Version/15.1 Safari",
      "Version/15.2 Safari",
      "Version/15.3 Safari"
    ].some((J) => navigator.userAgent.indexOf(J) > 0))
      return !0;
    return ys();
  }
};

// node_modules/molstar/lib/mol-plugin/config.js
class YU0 {
  toString() {
    return this.key;
  }
  valueOf() {
    return this.key;
  }
  constructor(Z, J) {
    this.key = Z, this.defaultValue = J;
  }
}
function O9(Z, J) {
  return new YU0(Z, J);
}
var W8 = {
  item: O9,
  General: {
    IsBusyTimeoutMs: O9("plugin-config.is-busy-timeout", 750),
    DisableAntialiasing: O9("plugin-config.disable-antialiasing", !1),
    DisablePreserveDrawingBuffer: O9("plugin-config.disable-preserve-drawing-buffer", !1),
    PixelScale: O9("plugin-config.pixel-scale", 1),
    PickScale: O9("plugin-config.pick-scale", 0.25),
    Transparency: O9("plugin-config.transparency", gs.defaultTransparency),
    PreferWebGl1: O9("plugin-config.prefer-webgl1", gs.preferWebGl1),
    AllowMajorPerformanceCaveat: O9("plugin-config.allow-major-performance-caveat", !1),
    PowerPreference: O9("plugin-config.power-preference", "high-performance"),
    ResolutionMode: O9("plugin-config.resolution-mode", "auto")
  },
  State: {
    DefaultServer: O9("plugin-state.server", "https://webchem.ncbr.muni.cz/molstar-state"),
    CurrentServer: O9("plugin-state.server", "https://webchem.ncbr.muni.cz/molstar-state"),
    HistoryCapacity: O9("history-capacity.server", 5)
  },
  VolumeStreaming: {
    Enabled: O9("volume-streaming.enabled", !0),
    DefaultServer: O9("volume-streaming.server", "https://ds.litemol.org"),
    CanStream: O9("volume-streaming.can-stream", (Z, J) => {
      return Z.models.length === 1 && O2.probablyHasDensityMap(Z.models[0]);
    }),
    EmdbHeaderServer: O9("volume-streaming.emdb-header-server", "https://files.wwpdb.org/pub/emdb/structures")
  },
  Viewport: {
    ShowReset: O9("viewer.show-reset-button", !0),
    ShowExpand: O9("viewer.show-expand-button", !0),
    ShowToggleFullscreen: O9("viewer.show-toggle-fullscreen-button", !0),
    ShowControls: O9("viewer.show-controls-button", !0),
    ShowSettings: O9("viewer.show-settings-button", !0),
    ShowSelectionMode: O9("viewer.show-selection-model-button", !0),
    ShowAnimation: O9("viewer.show-animation-button", !0),
    ShowTrajectoryControls: O9("viewer.show-trajectory-controls", !0),
    ShowScreenshotControls: O9("viewer.show-screenshot-controls", !0),
    ShowIllumination: O9("viewer.show-illumination-button", !0),
    ShowXR: O9("viewer.show-xr", "always")
  },
  Download: {
    DefaultPdbProvider: O9("download.default-pdb-provider", "pdbe"),
    DefaultEmdbProvider: O9("download.default-emdb-provider", "pdbe")
  },
  Structure: {
    SizeThresholds: O9("structure.size-thresholds", s0.DefaultSizeThresholds),
    DefaultRepresentationPreset: O9("structure.default-representation-preset", "auto"),
    DefaultRepresentationPresetParams: O9("structure.default-representation-preset-params", {}),
    SaccharideCompIdMapType: O9("structure.saccharide-comp-id-map-type", "default")
  },
  Background: {
    Styles: O9("background.styles", [])
  }
};

class ms {
  get(Z) {
    if (!this._config.has(Z))
      return Z.defaultValue;
    return this._config.get(Z);
  }
  set(Z, J) {
    this._config.set(Z, J);
  }
  delete(Z) {
    this._config.delete(Z);
  }
  constructor(Z) {
    if (this._config = /* @__PURE__ */ new Map, !Z)
      return;
    Z.forEach(([J, $]) => this._config.set(J, $));
  }
}

// node_modules/molstar/lib/mol-plugin/behavior/dynamic/volume-streaming/util.js
function QU0(Z, J = "x-ray") {
  if (!Z)
    return J;
  let $ = Z.models[0];
  if (!S6.is($.sourceData))
    return J;
  if (O2.hasEmMap($))
    return "em";
  if (O2.hasXrayMap($))
    return "x-ray";
  if (O2.isFromEm($))
    return "em";
  if (O2.isFromXray($))
    return "x-ray";
  return J;
}
function hZ1(Z) {
  let J = [];
  if (!S6.is(Z.sourceData))
    return [Z.entryId];
  let { db_id: $, db_name: X, content_type: Y } = Z.sourceData.data.db.pdbx_database_related;
  if (!X.isDefined)
    return [Z.entryId];
  for (let Q = 0, W = X.rowCount;Q < W; ++Q)
    if (X.value(Q).toUpperCase() === "EMDB" && Y.value(Q) === "associated EM volume")
      J.push($.value(Q));
  return J;
}
function bZ1(Z) {
  return [Z.entryId];
}
function WU0(Z, J) {
  if (!J || !J.models.length)
    return [];
  let $ = J.models[0];
  switch (Z) {
    case "em":
      return hZ1($);
    case "x-ray":
      return bZ1($);
  }
}
async function ds(Z, J, $, X) {
  switch (Z) {
    case "emdb":
      return ps(J, $, X);
    case "pdbe":
      return xZ1(J, $, X);
  }
}
async function ps(Z, J, $) {
  let X = Z.config.get(W8.VolumeStreaming.EmdbHeaderServer), W = (await Z.fetch({ url: `${X}/${$.toUpperCase()}/header/${$.toLowerCase()}.xml`, type: "xml" }).runInContext(J)).getElementsByTagName("map")[0].getElementsByTagName("contour"), K = W[0];
  for (let H = 1;H < W.length; H++)
    if (W[H].getAttribute("primary") === "true") {
      K = W[H];
      break;
    }
  return parseFloat(K.getElementsByTagName("level")[0].textContent);
}
async function xZ1(Z, J, $) {
  var X, Y, Q, W;
  $ = $.toUpperCase();
  let K = await Z.fetch({ url: `https://www.ebi.ac.uk/emdb/api/entry/map/${$}`, type: "json" }).runInContext(J), G = (Y = (X = K === null || K === void 0 ? void 0 : K.map) === null || X === void 0 ? void 0 : X.contour_list) === null || Y === void 0 ? void 0 : Y.contour;
  if (!G || G.length === 0)
    return yZ1(Z, J, $);
  return (W = (Q = G.find((H) => H.primary)) === null || Q === void 0 ? void 0 : Q.level) !== null && W !== void 0 ? W : G[0].level;
}
async function yZ1(Z, J, $) {
  var X, Y, Q;
  $ = $.toUpperCase();
  let W = await Z.fetch({ url: `https://www.ebi.ac.uk/pdbe/api/emdb/entry/map/${$}`, type: "json" }).runInContext(J), K = W === null || W === void 0 ? void 0 : W[$], G = void 0;
  if (((Q = (Y = (X = K === null || K === void 0 ? void 0 : K[0]) === null || X === void 0 ? void 0 : X.map) === null || Y === void 0 ? void 0 : Y.contour_level) === null || Q === void 0 ? void 0 : Q.value) !== void 0)
    G = +K[0].map.contour_level.value;
  return G;
}
async function KU0(Z, J, $) {
  var X;
  let Y = await Z.fetch({ url: `https://www.ebi.ac.uk/pdbe/api/pdb/entry/summary/${$}`, type: "json" }).runInContext(J), Q = Y === null || Y === void 0 ? void 0 : Y[$], W = [];
  if ((X = Q === null || Q === void 0 ? void 0 : Q[0]) === null || X === void 0 ? void 0 : X.related_structures) {
    let K = Q[0].related_structures.filter((G) => G.resource === "EMDB" && G.relationship === "associated EM volume");
    if (!K.length)
      throw new Error(`No related EMDB entry found for '${$}'.`);
    W.push(...K.map((G) => G.accession));
  } else
    throw new Error(`No related EMDB entry found for '${$}'.`);
  return W;
}

// node_modules/molstar/lib/mol-plugin/behavior/behavior.js
var i8;
(function(Z) {

  class J extends D0.Create({ name: "Root", typeClass: "Root" }) {
  }
  Z.Root = J;

  class $ extends D0.Create({ name: "Category", typeClass: "Object" }) {
  }
  Z.Category = $;

  class X extends D0.CreateBehavior({ name: "Behavior" }) {
  }
  Z.Behavior = X, Z.Categories = {
    common: "Common",
    representation: "Representation",
    interaction: "Interaction",
    "custom-props": "Custom Properties",
    misc: "Miscellaneous"
  }, Z.CreateCategory = B2.BuiltIn({
    name: "create-behavior-category",
    display: { name: "Behavior Category" },
    from: J,
    to: $,
    params: {
      label: j.Text("", { isHidden: !0 })
    }
  })({
    apply({ params: N }) {
      return new $({}, { label: N.label });
    }
  });
  let Y = /* @__PURE__ */ new Map;
  function Q(N) {
    return Y.get(N.id);
  }
  Z.getCategoryId = Q;
  function W(N) {
    let q = B2.CreateBuiltIn({
      name: N.name,
      display: N.display,
      from: [J],
      to: [X],
      params: N.params,
      apply({ params: U }, F) {
        let E = N.label ? N.label(U) : { label: N.display.name, description: N.display.description };
        return new X(new N.ctor(F, U), E);
      },
      update({ b: U, newParams: F }) {
        return n0.create("Update Behavior", async () => {
          if (!U.data.update)
            return T1.UpdateResult.Unchanged;
          return await U.data.update(F) ? T1.UpdateResult.Updated : T1.UpdateResult.Unchanged;
        });
      },
      canAutoUpdate: N.canAutoUpdate
    });
    return Y.set(q.id, N.category), q;
  }
  Z.create = W;
  function K(N, q) {
    return class {
      register() {
        this.sub = N.subscribe(this.ctx, (U) => q(U, this.ctx));
      }
      dispose() {
        if (this.sub)
          this.sub.unsubscribe();
        this.sub = void 0;
      }
      constructor(U) {
        this.ctx = U, this.sub = void 0;
      }
    };
  }
  Z.simpleCommandHandler = K;

  class G {
    subscribeCommand(N, q) {
      this.subs.push(N.subscribe(this.ctx, q));
    }
    subscribeObservable(N, q) {
      this.subs.push(N.subscribe(q));
    }
    track(N) {
      this.subs.push(N);
    }
    dispose() {
      for (let N of this.subs)
        N.unsubscribe();
      this.subs = [];
    }
    update(N) {
      if (zN(N, this.params))
        return !1;
      return this.params = N, !0;
    }
    constructor(N, q) {
      this.ctx = N, this.params = q, this.subs = [];
    }
  }
  Z.Handler = G;

  class H {
    subscribeCommand(N, q) {
      this.subs.push(N.subscribe(this.plugin, q));
    }
    subscribeObservable(N, q) {
      let U = N.subscribe(q);
      return this.subs.push(U), {
        unsubscribe: () => {
          let F = this.subs.indexOf(U);
          if (F >= 0)
            this.subs.splice(F, 1), U.unsubscribe();
        }
      };
    }
    dispose() {
      for (let N of this.subs)
        N.unsubscribe();
      this.subs = [];
    }
    constructor(N, q) {
      this.plugin = N, this.params = q, this.subs = [];
    }
  }
  Z.WithSubscribers = H;
})(i8 || (i8 = {}));

// node_modules/molstar/lib/mol-util/lru-cache.js
var NA;
(function(Z) {
  function J(W, K) {
    return { key: W, data: K };
  }
  function $(W) {
    return {
      entries: d_(),
      capacity: Math.max(1, W)
    };
  }
  Z.create = $;
  function X(W, K) {
    for (let G = W.entries.first;G; G = G.next)
      if (G.value.key === K)
        return W.entries.remove(G), W.entries.addLast(G.value), G.value.data;
    return;
  }
  Z.get = X;
  function Y(W, K, G) {
    let H = void 0;
    if (W.entries.count >= W.capacity) {
      let N = W.entries.first;
      H = N.value.data, W.entries.remove(N);
    }
    return W.entries.addLast(J(K, G)), H;
  }
  Z.set = Y;
  function Q(W, K) {
    for (let G = W.entries.first;G; G = G.next)
      if (G.value.key === K) {
        W.entries.remove(G);
        break;
      }
  }
  Z.remove = Q;
})(NA || (NA = {}));

// node_modules/molstar/lib/mol-plugin/command.js
function d9() {
  let Z = (J, $) => J.commands.dispatch(Z, $ || {});
  return Z.subscribe = (J, $) => J.commands.subscribe(Z, $), Z.id = R6.create22(), Z;
}

class us {
  constructor() {
    this.subs = /* @__PURE__ */ new Map, this.disposing = !1;
  }
  subscribe(Z, J) {
    let $ = this.subs.get(Z.id);
    if (!$)
      $ = [], this.subs.set(Z.id, $);
    return $.push(J), {
      unsubscribe: () => {
        let X = this.subs.get(Z.id);
        if (!X)
          return;
        let Y = X.indexOf(J);
        if (Y < 0)
          return;
        for (let Q = Y + 1;Q < X.length; Q++)
          X[Q - 1] = X[Q];
        X.pop();
      }
    };
  }
  dispatch(Z, J) {
    return new Promise(($, X) => {
      if (this.disposing) {
        X("disposed");
        return;
      }
      if (!this.subs.get(Z.id)) {
        $();
        return;
      }
      this.resolve({ cmd: Z, params: J, resolve: $, reject: X });
    });
  }
  dispose() {
    this.subs.clear();
  }
  async resolve(Z) {
    let J = this.subs.get(Z.cmd.id);
    if (!J) {
      Z.resolve();
      return;
    }
    try {
      for (let $ of J)
        await $(Z.params);
      Z.resolve();
    } catch ($) {
      Z.reject($);
    }
  }
}

// node_modules/molstar/lib/mol-plugin/commands.js
var h1 = {
  State: {
    SetCurrentObject: d9(),
    ApplyAction: d9(),
    Update: d9(),
    RemoveObject: d9(),
    ToggleExpanded: d9(),
    ToggleVisibility: d9(),
    Snapshots: {
      Add: d9(),
      Replace: d9(),
      Move: d9(),
      Remove: d9(),
      Apply: d9(),
      Clear: d9(),
      Upload: d9(),
      Fetch: d9(),
      DownloadToFile: d9(),
      OpenFile: d9(),
      OpenUrl: d9()
    }
  },
  Interactivity: {
    Object: {
      Highlight: d9()
    },
    Structure: {
      Highlight: d9(),
      Select: d9()
    },
    ClearHighlights: d9()
  },
  Layout: {
    Update: d9()
  },
  Toast: {
    Show: d9(),
    Hide: d9()
  },
  Camera: {
    Reset: d9(),
    SetSnapshot: d9(),
    Focus: d9(),
    FocusObject: d9(),
    OrientAxes: d9(),
    ResetAxes: d9()
  },
  Canvas3D: {
    SetSettings: d9(),
    ResetSettings: d9()
  }
};

// node_modules/molstar/lib/mol-geo/util.js
function gZ1(Z, J) {
  for (let $ = 0, X = J * 3;$ < X; $ += 3) {
    let Y = Z[$], Q = Z[$ + 1], W = Z[$ + 2], K = 1 / Math.sqrt(Y * Y + Q * Q + W * W);
    Z[$] = Y * K, Z[$ + 1] = Q * K, Z[$ + 2] = W * K;
  }
  return Z;
}
var B5 = M();
function SW(Z, J, $, X) {
  for (let Y = 0, Q = X * 3;Y < Q; Y += 3)
    M.fromArray(B5, J, $ + Y), M.transformMat4(B5, B5, Z), M.toArray(B5, J, $ + Y);
}
function qU0(Z, J, $, X) {
  for (let Y = 0, Q = X * 3;Y < Q; Y += 3)
    M.fromArray(B5, J, $ + Y), M.transformMat3(B5, B5, Z), M.toArray(B5, J, $ + Y);
}
function FU0(Z, J) {
  for (let $ = 0, X = Z.length;$ < X; $ += 3)
    M.fromArray(B5, Z, $), M.normalize(B5, B5), M.scale(B5, B5, J), M.toArray(B5, Z, $);
}
var GU0 = M(), cs = M(), HU0 = M(), T3 = M(), NU0 = M();
function Eh(Z, J, $, X, Y) {
  for (let Q = 0, W = Y * 3;Q < W; Q += 3) {
    let K = J[Q] * 3, G = J[Q + 1] * 3, H = J[Q + 2] * 3;
    M.fromArray(GU0, Z, K), M.fromArray(cs, Z, G), M.fromArray(HU0, Z, H), M.sub(T3, HU0, cs), M.sub(NU0, GU0, cs), M.cross(T3, T3, NU0), $[K] += T3[0], $[K + 1] += T3[1], $[K + 2] += T3[2], $[G] += T3[0], $[G + 1] += T3[1], $[G + 2] += T3[2], $[H] += T3[0], $[H + 1] += T3[1], $[H + 2] += T3[2];
  }
  return gZ1($, X);
}
function _3(Z, J, $ = 1) {
  let X = yX(Z), Y = new Int32Array(X + 2), Q = new Int32Array(J), W = new Int32Array(J);
  for (let H = 0, N = J * $;H < N; H += $)
    ++W[Z[H]];
  let K = 0;
  for (let H = 0;H < J; H++)
    Y[H] = K, K += W[H];
  Y[J] = K;
  let G = new Int32Array(K);
  for (let H = 0, N = J * $;H < N; H += $) {
    let q = Z[H], U = Y[q] + Q[q];
    G[U] = H, ++Q[q];
  }
  return { indices: G, offsets: Y };
}

// node_modules/molstar/lib/mol-gl/renderable/util.js
var ls = M.fromArray, Oh = M.transformMat4Offset;
function mZ1(Z, J) {
  Z = Math.max(Z, 2);
  let $ = Math.sqrt(Z), X = Math.ceil($);
  X = X + (J - X % J) % J;
  let Y = X > 0 ? Math.ceil(Z / X) : 0;
  return { width: X, height: Y, length: X * Y * J };
}
function Z9(Z, J, $, X) {
  let { length: Y, width: Q, height: W } = mZ1(Z, J);
  return X = X && X.length >= Y ? X : new $(Y), { array: X, width: Q, height: W };
}
var V3 = M(), dZ1 = new $J("14"), pZ1 = new $J("98");
function UU0(Z) {
  return Z > 1e5 ? dZ1 : pZ1;
}
function w5(Z, J, $) {
  let X = $ * 3, Y = UU0(J);
  Y.reset();
  for (let W = 0, K = J * 3;W < K; W += X)
    ls(V3, Z, W), Y.includePosition(V3);
  Y.finishedIncludeStep();
  for (let W = 0, K = J * 3;W < K; W += X)
    ls(V3, Z, W), Y.radiusPosition(V3);
  let Q = Y.getSphere();
  if (J <= 14) {
    let W = [];
    for (let K = 0, G = J * 3;K < G; K += X)
      W.push(ls(M(), Z, K));
    C0.setExtrema(Q, W);
  }
  return Q;
}
var ns = e();
function j7(Z, J, $, X) {
  if ($ === 1) {
    e.fromArray(ns, J, X);
    let G = C0.clone(Z);
    return e.isIdentity(ns) ? G : C0.transform(G, G, ns);
  }
  let Y = UU0($);
  Y.reset();
  let { center: Q, radius: W, extrema: K } = Z;
  if (K && $ <= 14) {
    for (let G = 0, H = $;G < H; ++G)
      for (let N of K)
        Oh(V3, N, J, 0, 0, G * 16 + X), Y.includePosition(V3);
    Y.finishedIncludeStep();
    for (let G = 0, H = $;G < H; ++G)
      for (let N of K)
        Oh(V3, N, J, 0, 0, G * 16 + X), Y.radiusPosition(V3);
  } else {
    for (let G = 0, H = $;G < H; ++G)
      Oh(V3, Q, J, 0, 0, G * 16 + X), Y.includePositionRadius(V3, W);
    Y.finishedIncludeStep();
    for (let G = 0, H = $;G < H; ++G)
      Oh(V3, Q, J, 0, 0, G * 16 + X), Y.radiusPositionRadius(V3, W);
  }
  return Y.getSphere();
}

// node_modules/molstar/lib/mol-geo/geometry/marker-data.js
var NQ = new Uint8Array(772);
NQ[1] = 1;
NQ[2] = 1;
NQ[3] = 1;
NQ[256] = 1;
NQ[512] = 1;
NQ[768] = 1;
NQ[257] = 2;
NQ[513] = 2;
NQ[769] = 2;
NQ[258] = 2;
NQ[514] = 2;
NQ[770] = 2;
NQ[259] = 2;
NQ[515] = 2;
NQ[771] = 2;
function is(Z, J) {
  if (J === 0)
    return 0;
  let $ = new Uint32Array(Z.buffer, 0, Z.buffer.byteLength >> 2), X = J - 4 >> 2, Y = 4 * X, Q = 0;
  if (X < 0)
    for (let W = 0;W < J; ++W)
      Q += Z[W] && 1;
  else {
    for (let W = 0;W < X; ++W) {
      let K = $[W];
      Q += NQ[K & 65535] + NQ[K >> 16];
    }
    for (let W = Y;W < J; ++W)
      Q += Z[W] && 1;
  }
  return Q / J;
}
function rZ(Z, J, $) {
  let X = Z9(Math.max(1, Z), 1, Uint8Array, $ && $.tMarker.ref.value.array), Y = is(X.array, Z), Q = Y === 0 ? 0 : -1;
  if ($)
    return C.updateIfChanged($.uMarker, 0), C.update($.tMarker, X), C.update($.uMarkerTexDim, h0.create(X.width, X.height)), C.updateIfChanged($.markerAverage, Y), C.updateIfChanged($.markerStatus, Q), C.updateIfChanged($.dMarkerType, J), $;
  else
    return {
      uMarker: C.create(0),
      tMarker: C.create(X),
      uMarkerTexDim: C.create(h0.create(X.width, X.height)),
      markerAverage: C.create(Y),
      markerStatus: C.create(Q),
      dMarkerType: C.create(J)
    };
}
var O52 = { array: new Uint8Array(1), width: 1, height: 1 };

// node_modules/molstar/lib/mol-model/location.js
var qQ = { kind: "null-location" };
function zh(Z, J, $) {
  return { kind: "data-location", tag: Z, data: J, element: $ };
}

// node_modules/molstar/lib/mol-geo/util/location-iterator.js
function X6(Z, J, $, X, Y = !1, Q = () => !1, W) {
  if (Z % $ !== 0)
    throw new Error("incompatible groupCount and stride");
  let K = {
    location: qQ,
    location2: qQ,
    index: 0,
    groupIndex: 0,
    instanceIndex: 0,
    isSecondary: !1
  }, G = K.groupIndex < Z, H = !1, N = 0, q = 0, U = !1, F = !!W;
  return {
    get hasNext() {
      return G;
    },
    get isNextNewInstance() {
      return H;
    },
    groupCount: Z,
    instanceCount: J,
    count: Z * J,
    stride: $,
    nonInstanceable: Y,
    hasLocation2: F,
    move() {
      if (G) {
        if (K.groupIndex = N, K.instanceIndex = q, K.index = q * Z + N, K.location = X(N, U ? -1 : q), F)
          K.location2 = W(N, U ? -1 : q);
        if (K.isSecondary = Q(N, U ? -1 : q), N += $, N === Z) {
          if (++q, H = !0, q < J)
            N = 0;
        } else
          H = !1;
        G = N < Z;
      }
      return K;
    },
    reset() {
      K.location = qQ, K.location2 = qQ, K.index = 0, K.groupIndex = 0, K.instanceIndex = 0, K.isSecondary = !1, G = K.groupIndex < Z, H = !1, N = 0, q = 0, U = !1;
    },
    skipInstance() {
      if (G && K.instanceIndex === q)
        ++q, N = 0, G = q < J;
    },
    voidInstances() {
      U = !0;
    }
  };
}
var pN = {
  get hasNext() {
    return !1;
  },
  get isNextNewInstance() {
    return !1;
  },
  groupCount: 0,
  instanceCount: 0,
  count: 0,
  stride: 0,
  nonInstanceable: !1,
  hasLocation2: !1,
  move() {
    return {
      location: qQ,
      location2: qQ,
      index: 0,
      groupIndex: 0,
      instanceIndex: 0,
      isSecondary: !1
    };
  },
  reset() {},
  skipInstance() {},
  voidInstances() {}
};
function b$(Z, J) {
  return {
    kind: "position-location",
    position: Z ? M.clone(Z) : M(),
    normal: J ? M.clone(J) : M()
  };
}
function qA(Z) {
  return !!Z && Z.kind === "position-location";
}

// node_modules/molstar/lib/mol-gl/webgl/framebuffer.js
var RU0 = $7();
function uZ1(Z, J) {
  switch (J) {
    case Z.FRAMEBUFFER_COMPLETE:
      return "complete";
    case Z.FRAMEBUFFER_INCOMPLETE_ATTACHMENT:
      return "incomplete attachment";
    case Z.FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT:
      return "incomplete missing attachment";
    case Z.FRAMEBUFFER_INCOMPLETE_DIMENSIONS:
      return "incomplete dimensions";
    case Z.FRAMEBUFFER_UNSUPPORTED:
      return "unsupported";
  }
  if (_2(Z))
    switch (J) {
      case Z.FRAMEBUFFER_INCOMPLETE_MULTISAMPLE:
        return "incomplete multisample";
      case Z.RENDERBUFFER_SAMPLES:
        return "renderbuffer samples";
    }
  return "unknown error";
}
function FA(Z, J) {
  let $ = Z.checkFramebufferStatus(Z.FRAMEBUFFER);
  if ($ !== Z.FRAMEBUFFER_COMPLETE) {
    let X = uZ1(Z, $);
    throw new Error(`Framebuffer status: ${X}${J ? ` (${J})` : ""}`);
  }
}
function LU0(Z) {
  let J = Z.createFramebuffer();
  if (J === null)
    throw new Error("Could not create WebGL framebuffer");
  return J;
}
function EU0(Z) {
  let J = LU0(Z), $ = !1;
  return {
    id: RU0(),
    bind: () => Z.bindFramebuffer(Z.FRAMEBUFFER, J),
    reset: () => {
      J = LU0(Z);
    },
    destroy: () => {
      if ($)
        return;
      Z.deleteFramebuffer(J), $ = !0;
    }
  };
}
function OU0() {
  return {
    id: RU0(),
    bind: () => {},
    reset: () => {},
    destroy: () => {}
  };
}

// node_modules/molstar/lib/mol-gl/webgl/extensions.js
function os(Z) {
  let J = DU0(Z);
  if (J === null)
    throw new Error('Could not find support for "instanced_arrays"');
  let $ = AU0(Z);
  if ($ === null)
    throw new Error('Could not find support for "element_index_uint"');
  let X = MU0(Z);
  if (X === null)
    throw new Error('Could not find support for "standard_derivatives"');
  let Y = wU0(Z);
  if (y2 && Y === null)
    console.log('Could not find support for "texture_float"');
  let Q = jU0(Z);
  if (y2 && Q === null)
    console.log('Could not find support for "texture_float_linear"');
  let W = TU0(Z);
  if (y2 && W === null)
    console.log('Could not find support for "texture_half_float"');
  let K = _U0(Z);
  if (y2 && K === null)
    console.log('Could not find support for "texture_half_float_linear"');
  let G = fU0(Z);
  if (y2 && G === null)
    console.log('Could not find support for "depth_texture"');
  let H = VU0(Z);
  if (y2 && H === null)
    console.log('Could not find support for "blend_minmax"');
  let N = BU0(Z);
  if (y2 && N === null)
    console.log('Could not find support for "vertex_array_object"');
  let q = IU0(Z);
  if (y2 && q === null)
    console.log('Could not find support for "frag_depth"');
  let U = PU0(Z);
  if (y2 && U === null)
    console.log('Could not find support for "color_buffer_float"');
  let F = CU0(Z);
  if (y2 && F === null)
    console.log('Could not find support for "color_buffer_half_float"');
  let E = kU0(Z);
  if (y2 && E === null)
    console.log('Could not find support for "draw_buffers"');
  let R = vU0(Z);
  if (y2 && R === null)
    console.log('Could not find support for "draw_buffers_indexed"');
  let z = SU0(Z);
  if (y2 && z === null)
    console.log('Could not find support for "shader_texture_lod"');
  let D = hU0(Z);
  if (y2 && D === null)
    console.log('Could not find support for "sRGB"');
  let A = bU0(Z);
  if (y2 && A === null)
    console.log('Could not find support for "disjoint_timer_query"');
  let B = xU0(Z);
  if (y2 && B === null)
    console.log('Could not find support for "multi_draw"');
  let T = yU0(Z);
  if (y2 && T === null)
    console.log('Could not find support for "draw_instanced_base_vertex_base_instance"');
  let w = gU0(Z);
  if (y2 && w === null)
    console.log('Could not find support for "multi_draw_instanced_base_vertex_base_instance"');
  let V = mU0(Z);
  if (y2 && V === null)
    console.log('Could not find support for "parallel_shader_compile"');
  let P = dU0(Z);
  if (y2 && P === null)
    console.log('Could not find support for "fbo_render_mipmap"');
  let I = pU0(Z);
  if (y2 && I === null)
    console.log('Could not find support for "provoking_vertex"');
  let S = uU0(Z);
  if (y2 && S === null)
    console.log('Could not find support for "clip_cull_distance"');
  let f = cU0(Z);
  if (y2 && f === null)
    console.log('Could not find support for "conservative_depth"');
  let v = lU0(Z);
  if (y2 && v === null)
    console.log('Could not find support for "stencil_texturing"');
  let h = nU0(Z);
  if (y2 && h === null)
    console.log('Could not find support for "clip_control"');
  let x = iU0(Z);
  if (y2 && x === null)
    console.log('Could not find support for "render_snorm"');
  let b = oU0(Z);
  if (y2 && b === null)
    console.log('Could not find support for "render_shared_exponent"');
  let g = sU0(Z);
  if (y2 && g === null)
    console.log('Could not find support for "texture_norm16"');
  let m = aU0(Z);
  if (y2 && m === null)
    console.log('Could not find support for "depth_clamp"');
  let i = rU0(Z);
  if (y2 && i === null)
    console.log('Could not find support for "multiview2"');
  let r = tU0(Z);
  return {
    instancedArrays: J,
    standardDerivatives: X,
    elementIndexUint: $,
    textureFloat: Y,
    textureFloatLinear: Q,
    textureHalfFloat: W,
    textureHalfFloatLinear: K,
    depthTexture: G,
    blendMinMax: H,
    vertexArrayObject: N,
    fragDepth: q,
    colorBufferFloat: U,
    colorBufferHalfFloat: F,
    drawBuffers: E,
    drawBuffersIndexed: R,
    shaderTextureLod: z,
    sRGB: D,
    disjointTimerQuery: A,
    multiDraw: B,
    drawInstancedBaseVertexBaseInstance: T,
    multiDrawInstancedBaseVertexBaseInstance: w,
    parallelShaderCompile: V,
    fboRenderMipmap: P,
    provokingVertex: I,
    clipCullDistance: S,
    conservativeDepth: f,
    stencilTexturing: v,
    clipControl: h,
    renderSnorm: x,
    renderSharedExponent: b,
    textureNorm16: g,
    depthClamp: m,
    multiview2: i,
    noNonInstancedActiveAttribs: r
  };
}
function zU0(Z, J) {
  let $ = os(Z);
  B7(J, (X, Y) => {
    if (Y === "noNonInstancedActiveAttribs")
      J.noNonInstancedActiveAttribs = $.noNonInstancedActiveAttribs;
    else if (X !== null)
      if ($[Y] === null)
        J[Y] = null;
      else
        Object.assign(X, $[Y]);
  });
}

// node_modules/molstar/lib/mol-gl/webgl/state.js
function eU0(Z, J) {
  let $ = {}, X = Z.getParameter(Z.FRONT_FACE), Y = Z.getParameter(Z.CULL_FACE_MODE), Q = Z.getParameter(Z.DEPTH_WRITEMASK), W = Z.getParameter(Z.DEPTH_CLEAR_VALUE), K = Z.getParameter(Z.DEPTH_FUNC), G = Z.getParameter(Z.COLOR_WRITEMASK), H = Z.getParameter(Z.COLOR_CLEAR_VALUE), N = Z.getParameter(Z.BLEND_SRC_RGB), q = Z.getParameter(Z.BLEND_DST_RGB), U = Z.getParameter(Z.BLEND_SRC_ALPHA), F = Z.getParameter(Z.BLEND_DST_ALPHA), E = Z.getParameter(Z.BLEND_COLOR), R = Z.getParameter(Z.BLEND_EQUATION_RGB), z = Z.getParameter(Z.BLEND_EQUATION_ALPHA), D = Z.getParameter(Z.STENCIL_FUNC), A = Z.getParameter(Z.STENCIL_VALUE_MASK), B = Z.getParameter(Z.STENCIL_REF), T = Z.getParameter(Z.STENCIL_BACK_FUNC), w = Z.getParameter(Z.STENCIL_BACK_VALUE_MASK), V = Z.getParameter(Z.STENCIL_BACK_REF), P = Z.getParameter(Z.STENCIL_WRITEMASK), I = Z.getParameter(Z.STENCIL_BACK_WRITEMASK), S = Z.getParameter(Z.STENCIL_FAIL), f = Z.getParameter(Z.STENCIL_PASS_DEPTH_PASS), v = Z.getParameter(Z.STENCIL_PASS_DEPTH_FAIL), h = Z.getParameter(Z.STENCIL_BACK_FAIL), x = Z.getParameter(Z.STENCIL_BACK_PASS_DEPTH_PASS), b = Z.getParameter(Z.STENCIL_BACK_PASS_DEPTH_FAIL), g = Z.getParameter(Z.MAX_VERTEX_ATTRIBS), m = [], i = Z.getParameter(Z.VIEWPORT), r = Z.getParameter(Z.SCISSOR_BOX), Y0 = J.clipControl ? Z.getParameter(J.clipControl.CLIP_ORIGIN) : -1, c = J.clipControl ? Z.getParameter(J.clipControl.CLIP_DEPTH_MODE) : -1, n = () => {
    for (let l = 0;l < g; ++l)
      m[l] = 0;
  };
  return n(), {
    currentProgramId: -1,
    currentMaterialId: -1,
    currentRenderItemId: -1,
    enable: (l) => {
      if ($[l] !== !0)
        Z.enable(l), $[l] = !0;
    },
    disable: (l) => {
      if ($[l] !== !1)
        Z.disable(l), $[l] = !1;
    },
    frontFace: (l) => {
      if (l !== X)
        Z.frontFace(l), X = l;
    },
    cullFace: (l) => {
      if (l !== Y)
        Z.cullFace(l), Y = l;
    },
    depthMask: (l) => {
      if (l !== Q)
        Z.depthMask(l), Q = l;
    },
    clearDepth: (l) => {
      if (l !== W)
        Z.clearDepth(l), W = l;
    },
    depthFunc: (l) => {
      if (l !== K)
        Z.depthFunc(l), K = l;
    },
    colorMask: (l, u, G0, F0) => {
      if (l !== G[0] || u !== G[1] || G0 !== G[2] || F0 !== G[3])
        Z.colorMask(l, u, G0, F0), G[0] = l, G[1] = u, G[2] = G0, G[3] = F0;
    },
    clearColor: (l, u, G0, F0) => {
      if (l !== H[0] || u !== H[1] || G0 !== H[2] || F0 !== H[3])
        Z.clearColor(l, u, G0, F0), H[0] = l, H[1] = u, H[2] = G0, H[3] = F0;
    },
    blendFunc: (l, u) => {
      if (l !== N || u !== q || l !== U || u !== F)
        Z.blendFunc(l, u), N = l, q = u, U = l, F = u;
    },
    blendFuncSeparate: (l, u, G0, F0) => {
      if (l !== N || u !== q || G0 !== U || F0 !== F)
        Z.blendFuncSeparate(l, u, G0, F0), N = l, q = u, U = G0, F = F0;
    },
    blendEquation: (l) => {
      if (l !== R || l !== z)
        Z.blendEquation(l), R = l, z = l;
    },
    blendEquationSeparate: (l, u) => {
      if (l !== R || u !== z)
        Z.blendEquationSeparate(l, u), R = l, z = u;
    },
    blendColor: (l, u, G0, F0) => {
      if (l !== E[0] || u !== E[1] || G0 !== E[2] || F0 !== E[3])
        Z.blendColor(l, u, G0, F0), E[0] = l, E[1] = u, E[2] = G0, E[3] = F0;
    },
    stencilFunc: (l, u, G0) => {
      if (l !== D || u !== B || G0 !== A || l !== T || u !== V || G0 !== w)
        Z.stencilFunc(l, u, G0), D = l, B = u, A = G0, T = l, V = u, w = G0;
    },
    stencilFuncSeparate: (l, u, G0, F0) => {
      if (l === Z.FRONT) {
        if (u !== D || G0 !== B || F0 !== A)
          Z.stencilFuncSeparate(l, u, G0, F0), D = u, B = G0, A = F0;
      } else if (l === Z.BACK) {
        if (u !== T || G0 !== V || F0 !== w)
          Z.stencilFuncSeparate(l, u, G0, F0), T = u, V = G0, w = F0;
      } else if (l === Z.FRONT_AND_BACK) {
        if (u !== D || G0 !== B || F0 !== A || u !== T || G0 !== V || F0 !== w)
          Z.stencilFuncSeparate(l, u, G0, F0), D = u, B = G0, A = F0, T = u, V = G0, w = F0;
      }
    },
    stencilMask: (l) => {
      if (l !== P || l !== I)
        Z.stencilMask(l), P = l, I = l;
    },
    stencilMaskSeparate: (l, u) => {
      if (l === Z.FRONT) {
        if (u !== P)
          Z.stencilMaskSeparate(l, u), P = u;
      } else if (l === Z.BACK) {
        if (u !== I)
          Z.stencilMaskSeparate(l, u), I = u;
      } else if (l === Z.FRONT_AND_BACK) {
        if (u !== P || u !== I)
          Z.stencilMaskSeparate(l, u), P = u, I = u;
      }
    },
    stencilOp: (l, u, G0) => {
      if (l !== S || u !== v || G0 !== f || l !== h || u !== b || G0 !== x)
        Z.stencilOp(l, u, G0), S = l, v = u, f = G0, h = l, b = u, x = G0;
    },
    stencilOpSeparate: (l, u, G0, F0) => {
      if (l === Z.FRONT) {
        if (u !== S || G0 !== v || F0 !== f)
          Z.stencilOpSeparate(l, u, G0, F0), S = u, v = G0, f = F0;
      } else if (l === Z.BACK) {
        if (u !== h || G0 !== b || F0 !== x)
          Z.stencilOpSeparate(l, u, G0, F0), h = u, b = G0, x = F0;
      } else if (l === Z.FRONT_AND_BACK) {
        if (u !== S || G0 !== v || F0 !== f || u !== h || G0 !== b || F0 !== x)
          Z.stencilOpSeparate(l, u, G0, F0), S = u, v = G0, f = F0, h = u, b = G0, x = F0;
      }
    },
    enableVertexAttrib: (l) => {
      Z.enableVertexAttribArray(l), m[l] = 1;
    },
    clearVertexAttribsState: n,
    disableUnusedVertexAttribs: () => {
      for (let l = 0;l < g; ++l)
        if (m[l] === 0)
          Z.disableVertexAttribArray(l);
    },
    viewport: (l, u, G0, F0) => {
      if (l !== i[0] || u !== i[1] || G0 !== i[2] || F0 !== i[3])
        Z.viewport(l, u, G0, F0), i[0] = l, i[1] = u, i[2] = G0, i[3] = F0;
    },
    scissor: (l, u, G0, F0) => {
      if (l !== r[0] || u !== r[1] || G0 !== r[2] || F0 !== r[3])
        Z.scissor(l, u, G0, F0), r[0] = l, r[1] = u, r[2] = G0, r[3] = F0;
    },
    clipControl: J.clipControl ? (l, u) => {
      if (l !== Y0 || u !== c)
        J.clipControl.clipControl(l, u), Y0 = l, c = u;
    } : void 0,
    reset: () => {
      $ = {}, X = Z.getParameter(Z.FRONT_FACE), Y = Z.getParameter(Z.CULL_FACE_MODE), Q = Z.getParameter(Z.DEPTH_WRITEMASK), W = Z.getParameter(Z.DEPTH_CLEAR_VALUE), K = Z.getParameter(Z.DEPTH_FUNC), G = Z.getParameter(Z.COLOR_WRITEMASK), H = Z.getParameter(Z.COLOR_CLEAR_VALUE), N = Z.getParameter(Z.BLEND_SRC_RGB), q = Z.getParameter(Z.BLEND_DST_RGB), U = Z.getParameter(Z.BLEND_SRC_ALPHA), F = Z.getParameter(Z.BLEND_DST_ALPHA), E = Z.getParameter(Z.BLEND_COLOR), R = Z.getParameter(Z.BLEND_EQUATION_RGB), z = Z.getParameter(Z.BLEND_EQUATION_ALPHA), D = Z.getParameter(Z.STENCIL_FUNC), A = Z.getParameter(Z.STENCIL_VALUE_MASK), B = Z.getParameter(Z.STENCIL_REF), T = Z.getParameter(Z.STENCIL_BACK_FUNC), w = Z.getParameter(Z.STENCIL_BACK_VALUE_MASK), V = Z.getParameter(Z.STENCIL_BACK_REF), P = Z.getParameter(Z.STENCIL_WRITEMASK), I = Z.getParameter(Z.STENCIL_BACK_WRITEMASK), S = Z.getParameter(Z.STENCIL_FAIL), f = Z.getParameter(Z.STENCIL_PASS_DEPTH_PASS), v = Z.getParameter(Z.STENCIL_PASS_DEPTH_FAIL), h = Z.getParameter(Z.STENCIL_BACK_FAIL), x = Z.getParameter(Z.STENCIL_BACK_PASS_DEPTH_PASS), b = Z.getParameter(Z.STENCIL_BACK_PASS_DEPTH_FAIL), g = Z.getParameter(Z.MAX_VERTEX_ATTRIBS), m.length = 0;
      for (let l = 0;l < g; ++l)
        m[l] = 0;
      i = Z.getParameter(Z.VIEWPORT), r = Z.getParameter(Z.SCISSOR_BOX), Y0 = J.clipControl ? Z.getParameter(J.clipControl.CLIP_ORIGIN) : -1, c = J.clipControl ? Z.getParameter(J.clipControl.CLIP_DEPTH_MODE) : -1;
    }
  };
}

// node_modules/molstar/lib/mol-gl/shader/chunks/apply-fog.glsl.js
var ZL0 = `
float preFogAlpha = gl_FragColor.a;
if (uFog) {
    float viewZ = depthToViewZ(uIsOrtho, fragmentDepth, uNear, uFar);
    float fogFactor = smoothstep(uFogNear, uFogFar, abs(viewZ));
    float fogAlpha = (1.0 - fogFactor) * 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 {
        #if defined(dRenderVariant_colorDpoit) && !defined(dGeometryType_directVolume)
            if (gl_FragColor.a < 1.0) {
                // transparent objects are blended with background color
                gl_FragColor.a = fogAlpha;
            } else {
                // opaque objects need to be pre-multiplied alpha
                gl_FragColor.rgb *= fogAlpha;
                gl_FragColor.a = fogAlpha;
            }
        #else
            // pre-multiplied alpha expected for transparent background
            gl_FragColor.rgb *= fogAlpha;
            gl_FragColor.a = fogAlpha;
        #endif
    }
} else if (uTransparentBackground) {
    #if !defined(dRenderVariant_colorDpoit) && !defined(dGeometryType_directVolume)
        // pre-multiplied alpha expected for transparent background
        gl_FragColor.rgb *= gl_FragColor.a;
    #endif
}
`;

// node_modules/molstar/lib/mol-gl/shader/chunks/apply-interior-color.glsl.js
var JL0 = `
if (interior) {
    material.rgb = mix(material.rgb, uInteriorColor.rgb, uInteriorColor.a);

    float isf = clamp(uInteriorSubstance.a, 0.0, 0.99); // clamp to avoid artifacts
    metalness = mix(metalness, uInteriorSubstance.r, isf);
    roughness = mix(roughness, uInteriorSubstance.g, isf);
    bumpiness = mix(bumpiness, uInteriorSubstance.b, isf);

    #ifdef dTransparentBackfaces_opaque
        material.a = 1.0;
    #endif
}
`;

// node_modules/molstar/lib/mol-gl/shader/chunks/apply-light-color.glsl.js
var $L0 = `
#if defined(dIgnoreLight)
    #ifdef bumpEnabled
        if (uBumpFrequency > 0.0 && uBumpAmplitude > 0.0 && bumpiness > 0.0) {
            material.rgb += fbm(vModelPosition * uBumpFrequency) * uBumpAmplitude * bumpiness;
            material.rgb -= 0.5 * uBumpAmplitude * bumpiness;
        }
    #endif

    #if defined(dRenderVariant_color)
        material.rgb += material.rgb * emissive;
    #endif

    gl_FragColor = material;
#else
    #ifdef bumpEnabled
        if (uBumpFrequency > 0.0 && uBumpAmplitude > 0.0 && bumpiness > 0.0) {
            normal = perturbNormal(-vViewPosition, normal, fbm(vModelPosition * uBumpFrequency), (uBumpAmplitude * bumpiness) / uBumpFrequency);
        }
    #endif

    vec4 color = material;

    #if defined(dCelShaded)
        // clamp to avoid artifacts
        metalness = clamp(metalness, 0.0, 0.99);
        roughness = clamp(roughness, 0.05, 1.0);
    #endif

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

    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;

    IncidentLight directLight;

    vec3 outgoingLight = vec3(0.0);

    #if defined(dCelShaded)
        float celDiffuse;
        float celSpecular;
        float celIntensity;

        #pragma unroll_loop_start
        for (int i = 0; i < dLightCount; ++i) {
            directLight.direction = uLightDirection[i];
            directLight.color = uLightColor[i] * PI; // * PI for punctual light

            celDiffuse = RECIPROCAL_PI * max(dot(geometry.normal, directLight.direction), 0.0) * (1.0 - metalness);
            celSpecular = luminance(saturate(dot(geometry.normal, directLight.direction)) * BRDF_GGX(directLight.direction, geometry.viewDir, geometry.normal, physicalMaterial.specularColor, physicalMaterial.specularF90, roughness));

            celIntensity = celDiffuse + celSpecular;
            celIntensity = ceil(celIntensity * uCelSteps) / uCelSteps;

            outgoingLight += color.rgb * directLight.color * celIntensity;
        }
        #pragma unroll_loop_end

        outgoingLight += physicalMaterial.diffuseColor * luminance(uAmbientColor);
    #else
        ReflectedLight reflectedLight = ReflectedLight(vec3(0.0), vec3(0.0), vec3(0.0), vec3(0.0));

        #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);

        outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular;
    #endif
    outgoingLight = clamp(outgoingLight, 0.01, 0.99); // prevents black artifacts on specular highlight with transparent background

    #if defined(dRenderVariant_color)
        outgoingLight += color.rgb * emissive;
    #endif

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

gl_FragColor.rgb *= uExposure;
`;

// node_modules/molstar/lib/mol-gl/shader/chunks/apply-marker-color.glsl.js
var XL0 = `

#if defined(dColorMarker)
    if (marker > 0.0) {
        if ((uMarkerPriority == 1 && marker != 2.0) || (uMarkerPriority != 1 && marker == 1.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
        }
    } else if (uMarkerAverage > 0.0) {
        gl_FragColor.rgb = mix(gl_FragColor.rgb, uDimColor, uDimStrength);
        gl_FragColor.a = max(gl_FragColor.a, uDimStrength * 0.002); // for direct-volume rendering
    }
#endif
`;

// node_modules/molstar/lib/mol-gl/shader/chunks/assign-clipping-varying.glsl.js
var YL0 = `
#if dClipObjectCount != 0 && defined(dClipping)
    #if defined(dClippingType_instance)
        vClipping = readFromTexture(tClipping, aInstance, uClippingTexDim).a;
    #elif defined(dMarkerType_groupInstance)
        vClipping = readFromTexture(tClipping, aInstance * float(uGroupCount) + group, uClippingTexDim).a;
    #endif
#endif
`;

// node_modules/molstar/lib/mol-gl/shader/chunks/assign-color-varying.glsl.js
var QL0 = `
#if defined(dRenderVariant_color) || defined(dRenderVariant_tracing)
    #if defined(dColorType_attribute)
        vColor.rgb = aColor;
    #elif defined(dColorType_instance)
        vColor.rgb = readFromTexture(tColor, aInstance, uColorTexDim).rgb;
    #elif defined(dColorType_group)
        #if defined(dDualColor)
            vec4 color2;
            if (aColorMode == 2.0) {
                vColor.rgb = readFromTexture(tColor, group, uColorTexDim).rgb;
            } else {
                vColor.rgb = readFromTexture(tColor, group * 2.0, uColorTexDim).rgb;
                color2.rgb = readFromTexture(tColor, group * 2.0 + 1.0, uColorTexDim).rgb;
            }
        #else
            vColor.rgb = readFromTexture(tColor, group, uColorTexDim).rgb;
        #endif
    #elif defined(dColorType_groupInstance)
        #if defined(dDualColor)
            vec4 color2;
            if (aColorMode == 2.0) {
                vColor.rgb = readFromTexture(tColor, aInstance * float(uGroupCount) + group, uColorTexDim).rgb;
            } else {
                vColor.rgb = readFromTexture(tColor, (aInstance * float(uGroupCount) + group) * 2.0, uColorTexDim).rgb;
                color2.rgb = readFromTexture(tColor, (aInstance * float(uGroupCount) + group) * 2.0 + 1.0, uColorTexDim).rgb;
            }
        #else
            vColor.rgb = readFromTexture(tColor, aInstance * float(uGroupCount) + group, uColorTexDim).rgb;
        #endif
    #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 / uModelScale - 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) / PALETTE_SCALE;
    #endif

    #ifdef dOverpaint
        #if defined(dOverpaintType_instance)
            vOverpaint = readFromTexture(tOverpaint, aInstance, uOverpaintTexDim);
        #elif 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 / uModelScale - 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
        vOverpaint *= uOverpaintStrength;
    #endif

    #ifdef dEmissive
        #if defined(dEmissiveType_instance)
            vEmissive = readFromTexture(tEmissive, aInstance, uEmissiveTexDim).a;
        #elif defined(dEmissiveType_groupInstance)
            vEmissive = readFromTexture(tEmissive, aInstance * float(uGroupCount) + group, uEmissiveTexDim).a;
        #elif defined(dEmissiveType_vertexInstance)
            vEmissive = readFromTexture(tEmissive, int(aInstance) * uVertexCount + vertexId, uEmissiveTexDim).a;
        #elif defined(dEmissiveType_volumeInstance)
            vec3 egridPos = (uEmissiveGridTransform.w * (vModelPosition / uModelScale - uEmissiveGridTransform.xyz)) / uEmissiveGridDim;
            vEmissive = texture3dFrom2dLinear(tEmissiveGrid, egridPos, uEmissiveGridDim, uEmissiveTexDim).a;
        #endif
        vEmissive *= uEmissiveStrength;
    #endif

    #ifdef dSubstance
        #if defined(dSubstanceType_instance)
            vSubstance = readFromTexture(tSubstance, aInstance, uSubstanceTexDim);
        #elif 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 / uModelScale - 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);
        vSubstance *= uSubstanceStrength;
    #endif
#elif defined(dRenderVariant_emissive)
    #ifdef dEmissive
        #if defined(dEmissiveType_instance)
            vEmissive = readFromTexture(tEmissive, aInstance, uEmissiveTexDim).a;
        #elif defined(dEmissiveType_groupInstance)
            vEmissive = readFromTexture(tEmissive, aInstance * float(uGroupCount) + group, uEmissiveTexDim).a;
        #elif defined(dEmissiveType_vertexInstance)
            vEmissive = readFromTexture(tEmissive, int(aInstance) * uVertexCount + vertexId, uEmissiveTexDim).a;
        #elif defined(dEmissiveType_volumeInstance)
            vec3 egridPos = (uEmissiveGridTransform.w * (vModelPosition / uModelScale - uEmissiveGridTransform.xyz)) / uEmissiveGridDim;
            vEmissive = texture3dFrom2dLinear(tEmissiveGrid, egridPos, uEmissiveGridDim, uEmissiveTexDim).a;
        #endif
        vEmissive *= uEmissiveStrength;
    #endif
#elif defined(dRenderVariant_pick)
    #ifdef requiredDrawBuffers
        vObject = vec4(packIntToRGB(float(uObjectId)), 1.0);
        vInstance = vec4(packIntToRGB(aInstance), 1.0);
        vGroup = vec4(packIntToRGB(group), 1.0);
    #else
        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
#endif

#ifdef dTransparency
    #if defined(dTransparencyType_instance)
        vTransparency = readFromTexture(tTransparency, aInstance, uTransparencyTexDim).a;
    #elif 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 / uModelScale - uTransparencyGridTransform.xyz)) / uTransparencyGridDim;
        vTransparency = texture3dFrom2dLinear(tTransparencyGrid, tgridPos, uTransparencyGridDim, uTransparencyTexDim).a;
    #endif
    vTransparency *= uTransparencyStrength;
#endif
`;

// node_modules/molstar/lib/mol-gl/shader/chunks/assign-group.glsl.js
var WL0 = `
#ifdef dGeometryType_textureMesh
    float group = unpackRGBToInt(readFromTexture(tGroup, vertexId, uGeoTexDim).rgb);
#else
    float group = aGroup;
#endif
`;

// node_modules/molstar/lib/mol-gl/shader/chunks/assign-marker-varying.glsl.js
var KL0 = `
#if defined(dNeedsMarker)
    #if defined(dMarkerType_instance)
        vMarker = readFromTexture(tMarker, aInstance, uMarkerTexDim).a;
    #elif defined(dMarkerType_groupInstance)
        vMarker = readFromTexture(tMarker, aInstance * float(uGroupCount) + group, uMarkerTexDim).a;
    #endif
#endif
`;

// node_modules/molstar/lib/mol-gl/shader/chunks/assign-material-color.glsl.js
var GL0 = `
#if defined(dNeedsMarker)
    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) || defined(dRenderVariant_tracing)
    #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 emissive = uEmissive;
    #ifdef dEmissive
        emissive += vEmissive;
    #endif

    float metalness = uMetalness;
    float roughness = uRoughness;
    float bumpiness = uBumpiness;
    #ifdef dSubstance
        float sf = clamp(vSubstance.a, 0.0, 0.99); // clamp to avoid artifacts
        metalness = mix(metalness, vSubstance.r, sf);
        roughness = mix(roughness, vSubstance.g, sf);
        bumpiness = mix(bumpiness, vSubstance.b, sf);
    #endif

    #if defined(dXrayShaded)
        material.a = calcXrayShadedAlpha(material.a, normal);
    #endif
#elif defined(dRenderVariant_depth)
    if (fragmentDepth > getDepth(gl_FragCoord.xy / uDrawingBufferSize)) {
        discard;
    }
    vec4 material;
    if (uRenderMask == MaskOpaque) {
        #if defined(dXrayShaded)
            discard;
        #endif
        #if defined(dTransparency)
            float dta = 1.0 - vTransparency;
            #if __VERSION__ == 100 || defined(dVaryingGroup)
                if (vTransparency < 0.1) dta = 1.0; // hard cutoff to avoid artifacts
            #endif

            if (uAlpha * dta < 1.0) {
                discard;
            }
        #else
            if (uAlpha < 1.0) {
                discard;
            }
        #endif
        material = packDepthToRGBA(fragmentDepth);
    } else if (uRenderMask == MaskTransparent) {
        float alpha = uAlpha;
        #if defined(dTransparency)
            float dta = 1.0 - vTransparency;
            alpha *= dta;
        #endif

        #ifdef dXrayShaded
            alpha = calcXrayShadedAlpha(alpha, normal);
        #else
            if (alpha == 1.0) {
                discard;
            }
        #endif
        material = packDepthWithAlphaToRGBA(fragmentDepth, alpha);
    }
#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 >= getDepthPacked(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);
    }
#elif defined(dRenderVariant_emissive)
    float emissive = uEmissive;
    #ifdef dEmissive
        emissive += vEmissive;
    #endif
    vec4 material = vec4(emissive);
#endif

// apply per-group transparency
#if defined(dTransparency) && (defined(dRenderVariant_pick) || defined(dRenderVariant_color) || defined(dRenderVariant_emissive) || defined(dRenderVariant_tracing))
    float ta = 1.0 - vTransparency;
    if (vTransparency < 0.09) ta = 1.0; // hard cutoff looks better

    #if defined(dRenderVariant_pick)
        if (ta * uAlpha < uPickingAlphaThreshold)
            discard; // ignore so the element below can be picked
    #elif defined(dRenderVariant_emissive)
        if (ta < 1.0)
            discard; // emissive not supported with transparency
    #elif defined(dRenderVariant_color) || defined(dRenderVariant_tracing)
        material.a *= ta;
    #endif
#endif
`;

// node_modules/molstar/lib/mol-gl/shader/chunks/assign-position.glsl.js
var HL0 = `
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;
`;

// node_modules/molstar/lib/mol-gl/shader/chunks/assign-size.glsl.js
var NL0 = `
#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;
`;

// node_modules/molstar/lib/mol-gl/shader/chunks/check-picking-alpha.glsl.js
var qL0 = `
float viewZ = depthToViewZ(uIsOrtho, fragmentDepth, uNear, uFar);
float fogFactor = smoothstep(uFogNear, uFogFar, abs(viewZ));
float fogAlpha = (1.0 - fogFactor) * uAlpha;
float alpha = uAlpha;
#ifdef dXrayShaded
    // add bias to make picking xray shaded elements easier
    alpha = calcXrayShadedAlpha(alpha, normal) + (0.3 * uPickingAlphaThreshold);
#endif
// if not opaque enough ignore so the element below can be picked
if (alpha < uPickingAlphaThreshold || fogAlpha < 0.1) {
    #ifdef dTransparentBackfaces_opaque
        if (!interior) discard;
    #else
        discard;
    #endif
}
`;

// node_modules/molstar/lib/mol-gl/shader/chunks/check-transparency.glsl.js
var FL0 = `
#if defined(dRenderVariant_color) || defined(dRenderVariant_tracing)
    #if defined(dTransparentBackfaces_off)
        if (interior && material.a < 1.0) discard;
    #elif defined(dTransparentBackfaces_opaque)
        if (interior) material.a = 1.0;
    #endif

    #if !defined(dXrayShaded)
        if ((uRenderMask == MaskOpaque && material.a < 1.0) ||
            (uRenderMask == MaskTransparent && material.a == 1.0)
        ) {
            discard;
        }
    #endif
#endif

#if defined(dRenderVariant_depth)
    #if defined(dTransparentBackfaces_off)
        if (interior) discard;
    #endif
#endif
`;

// node_modules/molstar/lib/mol-gl/shader/chunks/clip-instance.glsl.js
var UL0 = `
#if defined(dClipVariant_instance) && dClipObjectCount != 0
    vec3 mCenter = (uModel * aTransform * vec4(uInvariantBoundingSphere.xyz, 1.0)).xyz;
    if (clipTest(mCenter / uModelScale)) {
        // move out of [ -w, +w ] to 'discard' in vert shader
        gl_Position.z = 2.0 * gl_Position.w;
    }
#endif
`;

// node_modules/molstar/lib/mol-gl/shader/chunks/clip-pixel.glsl.js
var LL0 = `
#if defined(dClipVariant_pixel) && dClipObjectCount != 0
    if (clipTest(vModelPosition / uModelScale))
        discard;
#endif
`;

// node_modules/molstar/lib/mol-gl/shader/chunks/color-frag-params.glsl.js
var RL0 = `
uniform float uMetalness;
uniform float uRoughness;
uniform float uBumpiness;
#ifdef bumpEnabled
    uniform float uBumpFrequency;
    uniform float uBumpAmplitude;
#endif
uniform float uEmissive;

// Density value to estimate object thickness
uniform float uDensity;

#if defined(dRenderVariant_color) || defined(dRenderVariant_tracing)
    #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 dEmissive
        varying float vEmissive;
    #endif

    #ifdef dSubstance
        varying vec4 vSubstance;
    #endif
#elif defined(dRenderVariant_emissive)
    #ifdef dEmissive
        varying float vEmissive;
    #endif
#elif defined(dRenderVariant_pick)
    #if __VERSION__ == 100 || !defined(dVaryingGroup)
        #ifdef requiredDrawBuffers
            varying vec4 vObject;
            varying vec4 vInstance;
            varying vec4 vGroup;
        #else
            varying vec4 vColor;
        #endif
    #else
        #ifdef requiredDrawBuffers
            flat in vec4 vObject;
            flat in vec4 vInstance;
            flat in vec4 vGroup;
        #else
            flat in vec4 vColor;
        #endif
    #endif
#endif

#ifdef dTransparency
    varying float vTransparency;
#endif
`;

// node_modules/molstar/lib/mol-gl/shader/chunks/color-vert-params.glsl.js
var EL0 = `
uniform float uMetalness;
uniform float uRoughness;
uniform float uBumpiness;

#if defined(dRenderVariant_color) || defined(dRenderVariant_tracing)
    #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;
    #elif defined(dColorType_direct)
        varying vec4 vColor;
    #endif

    #ifdef dUsePalette
        varying float vPaletteV;
    #endif

    #ifdef dOverpaint
        #if defined(dOverpaintType_instance) || 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
        uniform float uOverpaintStrength;
    #endif

    #ifdef dEmissive
        #if defined(dEmissiveType_instance) || defined(dEmissiveType_groupInstance) || defined(dEmissiveType_vertexInstance)
            varying float vEmissive;
            uniform vec2 uEmissiveTexDim;
            uniform sampler2D tEmissive;
        #elif defined(dEmissiveType_volumeInstance)
            varying float vEmissive;
            uniform vec2 uEmissiveTexDim;
            uniform vec3 uEmissiveGridDim;
            uniform vec4 uEmissiveGridTransform;
            uniform sampler2D tEmissiveGrid;
        #endif
        uniform float uEmissiveStrength;
    #endif

    #ifdef dSubstance
        #if defined(dSubstanceType_instance) || 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
        uniform float uSubstanceStrength;
    #endif
#elif defined(dRenderVariant_emissive)
    #ifdef dEmissive
        #if defined(dEmissiveType_instance) || defined(dEmissiveType_groupInstance) || defined(dEmissiveType_vertexInstance)
            varying float vEmissive;
            uniform vec2 uEmissiveTexDim;
            uniform sampler2D tEmissive;
        #elif defined(dEmissiveType_volumeInstance)
            varying float vEmissive;
            uniform vec2 uEmissiveTexDim;
            uniform vec3 uEmissiveGridDim;
            uniform vec4 uEmissiveGridTransform;
            uniform sampler2D tEmissiveGrid;
        #endif
        uniform float uEmissiveStrength;
    #endif
#elif defined(dRenderVariant_pick)
    #if __VERSION__ == 100 || !defined(dVaryingGroup)
        #ifdef requiredDrawBuffers
            varying vec4 vObject;
            varying vec4 vInstance;
            varying vec4 vGroup;
        #else
            varying vec4 vColor;
        #endif
    #else
        #ifdef requiredDrawBuffers
            flat out vec4 vObject;
            flat out vec4 vInstance;
            flat out vec4 vGroup;
        #else
            flat out vec4 vColor;
        #endif
    #endif
#endif

#ifdef dTransparency
    #if defined(dTransparencyType_instance) || 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
    uniform float uTransparencyStrength;
#endif
`;

// node_modules/molstar/lib/mol-gl/shader/chunks/common-clip.glsl.js
var OL0 = `
vec3 quaternionTransform(const in vec4 q, const in vec3 v) {
    vec3 t = 2.0 * cross(q.xyz, v);
    return v + q.w * t + cross(q.xyz, t);
}

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

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

float sphereSD(const in vec3 position, const in vec4 rotation, const in vec3 size, const in 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(const in vec3 position, const in vec4 rotation, const in vec3 size, const in 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(const in vec3 position, const in vec4 rotation, const in vec3 size, const in 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(const in vec3 position, const in vec4 rotation, const in vec3 size, const in 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(const in vec3 center, const in int type, const in vec3 position, const in vec4 rotation, const in vec3 scale, const in mat4 transform) {
    vec3 c = (transform * vec4(center, 1.0)).xyz;
    if (type == 1) {
        vec3 normal = quaternionTransform(rotation, vec3(0.0, 1.0, 0.0));
        vec4 plane = computePlane(normal, position);
        return planeSD(plane, c);
    } else if (type == 2) {
        return sphereSD(position, rotation, scale * 0.5, c);
    } else if (type == 3) {
        return cubeSD(position, rotation, scale * 0.5, c);
    } else if (type == 4) {
        return cylinderSD(position, rotation, scale * 0.5, c);
    } else if (type == 5) {
        return infiniteConeSD(position, rotation, scale * 0.5, c);
    } else {
        return 0.1;
    }
}

#if __VERSION__ == 100
    // 8-bit
    int bitwiseAnd(in int a, in 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(const in int mask, const in int bit) {
        return bitwiseAnd(mask, bit) == 0;
    }
#else
    bool hasBit(const in int mask, const in int bit) {
        return (mask & bit) == 0;
    }
#endif

#if dClipObjectCount != 0
    bool clipTest(const in vec3 center) {
        // flag is a bit-flag for clip-objects to ignore (note, object ids start at 1 not 0)
        #if defined(dClipping)
            int flag = int(floor(vClipping * 255.0 + 0.5));
        #else
            int flag = 0;
        #endif

        #pragma unroll_loop_start
        for (int i = 0; i < dClipObjectCount; ++i) {
            if (flag == 0 || hasBit(flag, UNROLLED_LOOP_INDEX + 1)) {
                bool test = getSignedDistance(center, uClipObjectType[i], uClipObjectPosition[i], uClipObjectRotation[i], uClipObjectScale[i], uClipObjectTransform[i]) <= 0.0;
                if ((!uClipObjectInvert[i] && test) || (uClipObjectInvert[i] && !test)) {
                    return true;
                }
            }
        }
        #pragma unroll_loop_end
        return false;
    }
#endif
`;

// node_modules/molstar/lib/mol-gl/shader/chunks/common-frag-params.glsl.js
var zL0 = `
uniform int uObjectId;
uniform int uInstanceCount;
uniform int uGroupCount;

uniform int uPickType;
uniform int uMarkingType;

uniform vec4 uCameraPlane;
uniform vec4 uLod;

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

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

#if defined(dColorMarker)
    uniform vec3 uHighlightColor;
    uniform vec3 uSelectColor;
    uniform vec3 uDimColor;
    uniform float uHighlightStrength;
    uniform float uSelectStrength;
    uniform float uDimStrength;
    uniform int uMarkerPriority;
    uniform float uMarkerAverage;
#endif

#if defined(dNeedsMarker)
    uniform float uMarker;
    #if __VERSION__ == 100 || defined(dMarkerType_instance) || !defined(dVaryingGroup)
        varying float vMarker;
    #else
        flat in float vMarker;
    #endif
#endif

#if defined(dRenderVariant_colorDpoit)
    #define MAX_DPOIT_DEPTH 99999.0 // NOTE constant also set in TypeScript
    uniform sampler2D tDpoitDepth;
    uniform sampler2D tDpoitFrontColor;
#endif

varying vec3 vModelPosition;
varying vec3 vViewPosition;

uniform vec2 uViewOffset;
uniform float uModelScale;

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

uniform bool uFog;
uniform float uFogNear;
uniform float uFogFar;
uniform vec3 uFogColor;

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

uniform bool uDoubleSided;
bool interior;

uniform float uXrayEdgeFalloff;
uniform float uCelSteps;
uniform float uExposure;

uniform mat4 uProjection;

uniform int uRenderMask;
uniform bool uMarkingDepthTest;

uniform sampler2D tDepth;
uniform vec2 uDrawingBufferSize;

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

float getDepth(const in vec2 coords) {
    #ifdef depthTextureSupport
        return texture2D(tDepth, coords).r;
    #else
        return unpackRGBAToDepth(texture2D(tDepth, coords));
    #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;
}

// "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);
    if (det == 0.0) return normal;

    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;
}

#ifdef dXrayShaded
    float calcXrayShadedAlpha(in float alpha, const in vec3 normal) {
        #if defined(dXrayShaded_on)
            alpha *= 1.0 - pow(abs(dot(normal, vec3(0.0, 0.0, 1.0))), uXrayEdgeFalloff);
        #elif defined(dXrayShaded_inverted)
            alpha *= pow(abs(dot(normal, vec3(0.0, 0.0, 1.0))), uXrayEdgeFalloff);
        #endif
        return clamp(alpha, 0.001, 0.999);
    }
#endif
`;

// node_modules/molstar/lib/mol-gl/shader/chunks/common-vert-params.glsl.js
var DL0 = `
uniform mat4 uProjection, uModel, uView;
uniform vec3 uCameraPosition;
uniform vec4 uCameraPlane;

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

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];
    uniform mat4 uClipObjectTransform[dClipObjectCount];

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

#if defined(dNeedsMarker)
    uniform float uMarker;
    uniform vec2 uMarkerTexDim;
    uniform sampler2D tMarker;
    #if __VERSION__ == 100 || defined(dMarkerType_instance) || !defined(dVaryingGroup)
        varying float vMarker;
    #else
        flat out float vMarker;
    #endif
#endif

varying vec3 vModelPosition;
varying vec3 vViewPosition;

uniform float uModelScale;

#if defined(noNonInstancedActiveAttribs)
    // int() is needed for some Safari versions
    // see https://bugs.webkit.org/show_bug.cgi?id=244152
    #define VertexID int(gl_VertexID)
#else
    attribute float aVertex;
    #define VertexID int(aVertex)
#endif

#if defined(enabledMultiDraw)
    #define DrawID gl_DrawID
#else
    #define DrawID uDrawId
#endif
`;

// node_modules/molstar/lib/mol-gl/shader/chunks/common.glsl.js
var ML0 = `
// TODO find a better place for these convenience defines

#if defined(dRenderVariant_colorBlended) || defined(dRenderVariant_colorWboit) || defined(dRenderVariant_colorDpoit)
    #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

#if ((defined(dRenderVariant_color) || defined(dRenderVariant_tracing)) && defined(dColorMarker)) || defined(dRenderVariant_marking)
    #define dNeedsMarker
#endif

#if defined(dXrayShaded_on) || defined(dXrayShaded_inverted)
    #define dXrayShaded
#endif

#if defined(dRenderVariant_color) || defined(dRenderVariant_tracing) || ((defined(dRenderVariant_depth) || defined(dRenderVariant_pick)) && defined(dXrayShaded))
    #define dNeedsNormal
#endif

#define MaskAll 0
#define MaskOpaque 1
#define MaskTransparent 2

//

#define PI 3.14159265
#define RECIPROCAL_PI 0.31830988618
#define EPSILON 1e-6
#define ONE_MINUS_EPSILON 1.0 - EPSILON
#define TWO_PI 6.2831853
#define HALF_PI 1.570796325

#define PALETTE_SCALE 16777214.0 // (1 << 24) - 2

#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));
}

float pack2x4(vec2 v) {
    vec2 clamped_v = clamp(v, 0.0, 1.0);
    vec2 scaled_v = floor(clamped_v * 15.0 + 0.5); // round to 0–15
    float c = scaled_v.x + scaled_v.y * 16.0;
    return c / 255.0;
}

vec2 unpack2x4(float f) {
    float c = floor(f * 255.0 + 0.5);
    float lo = mod(c, 16.0);
    float hi = floor(c / 16.0);
    return vec2(lo, hi) / 15.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 packDepthWithAlphaToRGBA(const in float depth, const in float alpha){
    vec3 r = vec3(fract(depth * PackFactors.yz), depth);
    r.yz -= r.xy * ShiftRight8; // tidy overflow
    return vec4(r * PackUpscale, alpha);
}
vec2 unpackRGBAToDepthWithAlpha(const in vec4 v) {
    return vec2(dot(v.xyz, UnpackFactors.yzw), v.w);
}

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 luminance(vec3 c) {
    // https://www.w3.org/TR/WCAG21/#dfn-relative-luminance
    const vec3 W = vec3(0.2125, 0.7154, 0.0721);
    return dot(c, W);
}

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);
}

// see https://github.com/graphitemaster/normals_revisited and https://www.shadertoy.com/view/3s33zj
mat3 adjoint(const in mat4 m) {
    return mat3(
        cross(m[1].xyz, m[2].xyz),
        cross(m[2].xyz, m[0].xyz),
        cross(m[0].xyz, m[1].xyz)
    );
}

#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
`;

// node_modules/molstar/lib/mol-gl/shader/chunks/fade-lod.glsl.js
var AL0 = `
if (uLod.w == 0.0 && (uLod.x != 0.0 || uLod.y != 0.0)) {
    float d = (dot(uCameraPlane.xyz, vModelPosition) + uCameraPlane.w) / uModelScale;
    float ta = min(
        smoothstep(uLod.x, uLod.x + uLod.z, d),
        1.0 - smoothstep(uLod.y - uLod.z, uLod.y, d)
    );

    #if defined(dRenderVariant_color) || defined(dRenderVariant_tracing)
        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;
        }
    #else
        if (ta < uPickingAlphaThreshold) {
            discard;
        }
    #endif
}
`;

// node_modules/molstar/lib/mol-gl/shader/chunks/float-to-rgba.glsl.js
var BL0 = `
    // 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)
        );
    }
`;

// node_modules/molstar/lib/mol-gl/shader/chunks/light-frag-params.glsl.js
var wL0 = `
#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;
}
`;

// node_modules/molstar/lib/mol-gl/shader/chunks/normal-frag-params.glsl.js
var jL0 = `
varying vec3 vNormal;
`;

// node_modules/molstar/lib/mol-gl/shader/chunks/read-from-texture.glsl.js
var TL0 = `
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);
}
`;

// node_modules/molstar/lib/mol-gl/shader/chunks/rgba-to-float.glsl.js
var _L0 = `
    // 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);
    }
`;

// node_modules/molstar/lib/mol-gl/shader/chunks/size-vert-params.glsl.js
var VL0 = `
#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;
`;

// node_modules/molstar/lib/mol-gl/shader/chunks/texture3d-from-1d-trilinear.glsl.js
var IL0 = `
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);
}
`;

// node_modules/molstar/lib/mol-gl/shader/chunks/texture3d-from-2d-linear.glsl.js
var PL0 = `
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);
}
`;

// node_modules/molstar/lib/mol-gl/shader/chunks/texture3d-from-2d-nearest.glsl.js
var CL0 = `
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);
}
`;

// node_modules/molstar/lib/mol-gl/shader/chunks/wboit-write.glsl.js
var kL0 = `
#if defined(dRenderVariant_colorWboit)
    if (uRenderMask == MaskOpaque) {
        if (preFogAlpha < 1.0) {
            discard;
        }
    } else if (uRenderMask == MaskTransparent) {
        if (preFogAlpha != 1.0 && fragmentDepth < getDepth(gl_FragCoord.xy / uDrawingBufferSize)) {
            #ifdef dTransparentBackfaces_off
                if (interior) discard;
            #endif
            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
`;

// node_modules/molstar/lib/mol-gl/shader/chunks/dpoit-write.glsl.js
var vL0 = `
#if defined(dRenderVariant_colorDpoit)
    if (uRenderMask == MaskOpaque) {
        if (preFogAlpha < 1.0) {
            discard;
        }
    } else if (uRenderMask == MaskTransparent) {
        vec2 coords = gl_FragCoord.xy / uDrawingBufferSize;
        if (preFogAlpha != 1.0 && fragmentDepth < getDepth(coords)) {
            #ifdef dTransparentBackfaces_off
                if (interior) discard;
            #endif

            // adapted from https://github.com/tsherif/webgl2examples
            // The MIT License, Copyright 2017 Tarek Sherif, Shuai Shao

            vec2 lastDepth = texture2D(tDpoitDepth, coords).rg;
            vec4 lastFrontColor = texture2D(tDpoitFrontColor, coords);

            vec4 fragColor = gl_FragColor;

            // depth value always increases
            // so we can use MAX blend equation
            gl_FragData[2].rg = vec2(-MAX_DPOIT_DEPTH);

            // front color always increases
            // so we can use MAX blend equation
            gl_FragColor = lastFrontColor;

            // back color is separately blend afterwards each pass
            gl_FragData[1] = vec4(0.0);

            float nearestDepth = -lastDepth.x;
            float furthestDepth = lastDepth.y;
            float alphaMultiplier = 1.0 - lastFrontColor.a;

            if (fragmentDepth < nearestDepth || fragmentDepth > furthestDepth) {
                // Skip this depth since it's been peeled.
                return;
            }

            if (fragmentDepth > nearestDepth && fragmentDepth < furthestDepth) {
                // This needs to be peeled.
                // The ones remaining after MAX blended for
                // all need-to-peel will be peeled next pass.
                gl_FragData[2].rg = vec2(-fragmentDepth, fragmentDepth);
                return;
            }

            // write to back and front color buffer
            if (fragmentDepth == nearestDepth) {
                gl_FragColor.rgb += fragColor.rgb * fragColor.a * alphaMultiplier;
                gl_FragColor.a = 1.0 - alphaMultiplier * (1.0 - fragColor.a);
            } else {
                gl_FragData[1] += fragColor;
            }

        } else {
            discard;
        }
    }
#endif
`;

// node_modules/molstar/lib/mol-gl/shader/points.vert.js
var SL0 = `
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(){
    int vertexId = VertexID;

    #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
}
`;

// node_modules/molstar/lib/mol-gl/shader/points.frag.js
var fL0 = `
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 fade_lod
    #include clip_pixel

    float fragmentDepth = gl_FragCoord.z;
    #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(dPointStyle_fuzzy) && (defined(dRenderVariant_color) || defined(dRenderVariant_tracing))
        material.a *= fuzzyAlpha;
    #endif

    #include check_transparency

    #if defined(dRenderVariant_pick)
        #include check_picking_alpha
        #ifdef requiredDrawBuffers
            gl_FragColor = vObject;
            gl_FragData[1] = vInstance;
            gl_FragData[2] = vGroup;
            gl_FragData[3] = packDepthToRGBA(fragmentDepth);
        #else
            gl_FragColor = vColor;
        #endif
    #elif defined(dRenderVariant_depth)
        gl_FragColor = material;
    #elif defined(dRenderVariant_marking)
        gl_FragColor = material;
    #elif defined(dRenderVariant_emissive)
        gl_FragColor = material;
    #elif defined(dRenderVariant_color) || defined(dRenderVariant_tracing)
        gl_FragColor = material;
        #include apply_marker_color

        #if defined(dRenderVariant_color)
            #include apply_fog
            #include wboit_write
            #include dpoit_write
        #elif defined(dRenderVariant_tracing)
            gl_FragData[1] = vec4(normalize(vViewPosition), emissive);
            gl_FragData[2] = vec4(material.rgb, uDensity);
        #endif
    #endif
}
`;

// node_modules/molstar/lib/mol-gl/shader/spheres.vert.js
var hL0 = `
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;
uniform float uIsOrtho;
uniform bool uIsAsymmetricProjection;

uniform vec2 uTexDim;
uniform sampler2D tPositionGroup;

attribute mat4 aTransform;
attribute float aInstance;

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

/**
 * Bounding rectangle of a clipped, perspective-projected 3D Sphere.
 * Michael Mara, Morgan McGuire. 2013
 *
 * Specialization by Arseny Kapoulkine, MIT License Copyright (c) 2018
 * https://github.com/zeux/niagara
 *
 * Only works for for symmetric projections.
 */
void sphereProjection(const in vec3 p, const in float r, const in vec2 mapping) {
    vec3 pr = p * r;
    float pzr2 = p.z * p.z - r * r;

    float vx = sqrt(p.x * p.x + pzr2);
    float minx = ((vx * p.x - pr.z) / (vx * p.z + pr.x)) * uProjection[0][0];
    float maxx = ((vx * p.x + pr.z) / (vx * p.z - pr.x)) * uProjection[0][0];

    float vy = sqrt(p.y * p.y + pzr2);
    float miny = ((vy * p.y - pr.z) / (vy * p.z + pr.y)) * uProjection[1][1];
    float maxy = ((vy * p.y + pr.z) / (vy * p.z - pr.y)) * uProjection[1][1];

    gl_Position.xy = vec2(maxx + minx, maxy + miny) * -0.5;
    gl_Position.xy -= mapping * vec2(maxx - minx, maxy - miny) * 0.5;
    gl_Position.xy *= gl_Position.w;
}

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 vec3 position, const in float radius, const in vec2 mapping) {
    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 -= mapping * vec2(sx, sy);
    gl_Position.xy *= gl_Position.w;
}

void main(void){
    vec2 mapping = vec2(1.0, 1.0); // vertices 2 and 5
    #if __VERSION__ == 100
        int m = imod(VertexID, 6);
    #else
        int m = VertexID % 6;
    #endif
    if (m == 0) {
        mapping = vec2(-1.0, 1.0);
    } else if (m == 1 || m == 3) {
        mapping = vec2(-1.0, -1.0);
    } else if (m == 4) {
        mapping = vec2(1.0, -1.0);
    }

    int vertexId = VertexID / 6;

    vec4 positionGroup = readFromTexture(tPositionGroup, vertexId, uTexDim);
    vec3 position = positionGroup.rgb;
    float group = positionGroup.a;

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

    vRadius = size * uModelScale;

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

    float d;
    if (uLod.w != 0.0 && (uLod.x != 0.0 || uLod.y != 0.0)) {
        if (uModelScale != 1.0) {
            vRadius *= uLod.w;
        } else {
            d = (dot(uCameraPlane.xyz, vModelPosition) + uCameraPlane.w) / uModelScale;
            float f = min(
                smoothstep(uLod.x, uLod.x + uLod.z, d),
                1.0 - smoothstep(uLod.y - uLod.z, uLod.y, d)
            ) * uLod.w;
            vRadius *= f;
        }
    }

    vec4 mvPosition = uModelView * aTransform * position4;

    #ifdef dApproximate
        vec4 mvCorner = vec4(mvPosition.xyz, 1.0);
        mvCorner.xy += mapping * vRadius;
        gl_Position = uProjection * mvCorner;
    #else
        if (uIsOrtho == 1.0) {
            vec4 mvCorner = vec4(mvPosition.xyz, 1.0);
            mvCorner.xy += mapping * vRadius;
            gl_Position = uProjection * mvCorner;
        } else if (uIsAsymmetricProjection) {
            gl_Position = uProjection * vec4(mvPosition.xyz, 1.0);
            quadraticProjection(position, vRadius / uModelScale, mapping);
        } else {
            gl_Position = uProjection * vec4(mvPosition.xyz, 1.0);
            sphereProjection(mvPosition.xyz, vRadius, mapping);
        }
    #endif

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

    if (gl_Position.z < -gl_Position.w) {
        mvPosition.z -= 2.0 * vRadius; // avoid clipping
        gl_Position.z = (uProjection * vec4(mvPosition.xyz, 1.0)).z;
    }

    if (uModelScale == 1.0) {
        if (uLod.w != 0.0 && (uLod.x != 0.0 || uLod.y != 0.0)) {
            if (d < uLod.x || d > uLod.y) {
                // move out of [ -w, +w ] to 'discard' in vert shader
                gl_Position.z = 2.0 * gl_Position.w;
            }
        }
    }

    #if defined(dClipPrimitive) && !defined(dClipVariant_instance) && dClipObjectCount != 0
        if (clipTest(vModelPosition / uModelScale)) {
            // move out of [ -w, +w ] to 'discard' in vert shader
            gl_Position.z = 2.0 * gl_Position.w;
        }
    #else
        #include clip_instance
    #endif
}
`;

// node_modules/molstar/lib/mol-gl/shader/spheres.frag.js
var bL0 = `
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;
uniform float uAlphaThickness;

uniform vec4 uInteriorColor;
uniform vec4 uInteriorSubstance;

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

#ifdef dSolidInterior
    const bool solidInterior = true;
#else
    const bool solidInterior = false;
#endif

bool SphereImpostor(out vec3 modelPos, out vec3 cameraPos, out vec3 cameraNormal, out bool interior, out float fragmentDepth){
    vec3 cameraSpherePos = -vPointViewPosition;

    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 + vRadius * vRadius - dot(cameraSphereDir, cameraSphereDir);

    if (det < 0.0) return false;

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

    cameraPos = rayDirection * negT + rayOrigin;
    modelPos = (uInvView * vec4(cameraPos, 1.0)).xyz;
    fragmentDepth = calcDepth(cameraPos);

    bool objectClipped = false;

    #if !defined(dClipPrimitive) && defined(dClipVariant_pixel) && dClipObjectCount != 0
        if (clipTest(modelPos)) {
            objectClipped = true;
            fragmentDepth = -1.0;
        }
    #endif

    if (fragmentDepth > 0.0) {
        cameraNormal = normalize(cameraPos - cameraSpherePos);
        interior = false;
        return true;
    } else if (uDoubleSided || solidInterior) {
        cameraPos = rayDirection * posT + rayOrigin;
        modelPos = (uInvView * vec4(cameraPos, 1.0)).xyz;
        fragmentDepth = calcDepth(cameraPos);
        cameraNormal = -normalize(cameraPos - cameraSpherePos);
        interior = true;
        if (fragmentDepth > 0.0) {
            #ifdef dSolidInterior
                if (!objectClipped) {
                    fragmentDepth = 0.0 + (0.0000001 / vRadius);
                    cameraNormal = -mix(normalize(vPoint), vec3(0.0, 0.0, -1.0), uIsOrtho);

                    // intersection of ray with near plane
                    float nearT = - (uNear + dot(rayOrigin, vec3(0.0, 0.0, 1.0))) / dot(rayDirection, vec3(0.0, 0.0, 1.0));
                    cameraPos = rayDirection * nearT + rayOrigin;
                    modelPos = (uInvView * vec4(cameraPos, 1.0)).xyz;
                }
            #endif
            return true;
        }
    }

    return false;
}

void main(void){
    vec3 cameraNormal;
    float fragmentDepth;

    #ifdef dApproximate
        vec3 pointDir = -vPointViewPosition - vPoint;
        if (dot(pointDir, pointDir) > vRadius * vRadius) discard;
        vec3 vViewPosition = -vPointViewPosition;
        fragmentDepth = gl_FragCoord.z;
        #if !defined(dIgnoreLight) || defined(dXrayShaded) || defined(dRenderVariant_tracing)
            pointDir.z -= cos(length(pointDir)) * vRadius * 0.5;
            cameraNormal = -normalize(pointDir);
        #endif
        interior = false;
    #else
        vec3 modelPos;
        vec3 cameraPos;
        bool hit = SphereImpostor(modelPos, cameraPos, cameraNormal, interior, fragmentDepth);
        if (!hit) discard;

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

        gl_FragDepthEXT = fragmentDepth;

        vec3 vModelPosition = modelPos;
        vec3 vViewPosition = cameraPos;
    #endif

    #include fade_lod
    #if !defined(dClipPrimitive) && defined(dClipVariant_pixel) && dClipObjectCount != 0
        #include clip_pixel
    #endif

    #ifdef dNeedsNormal
        vec3 normal = -cameraNormal;
    #endif

    #include assign_material_color

    #if defined(dRenderVariant_color) || defined(dRenderVariant_tracing)
        if (uRenderMask == MaskTransparent && uAlphaThickness > 0.0) {
            material.a *= min(1.0, vRadius / (uAlphaThickness * uModelScale));
        }
    #endif

    #include check_transparency

    #if defined(dRenderVariant_pick)
        #include check_picking_alpha
        #ifdef requiredDrawBuffers
            gl_FragColor = vObject;
            gl_FragData[1] = vInstance;
            gl_FragData[2] = vGroup;
            gl_FragData[3] = packDepthToRGBA(fragmentDepth);
        #else
            gl_FragColor = vColor;
        #endif
    #elif defined(dRenderVariant_depth)
        gl_FragColor = material;
    #elif defined(dRenderVariant_marking)
        gl_FragColor = material;
    #elif defined(dRenderVariant_emissive)
        gl_FragColor = material;
    #elif defined(dRenderVariant_color) || defined(dRenderVariant_tracing)
        #include apply_interior_color
        #include apply_light_color
        #include apply_marker_color

        #if defined(dRenderVariant_color)
            #include apply_fog
            #include wboit_write
            #include dpoit_write
        #elif defined(dRenderVariant_tracing)
            gl_FragData[1] = vec4(normal, emissive);
            gl_FragData[2] = vec4(material.rgb, uDensity);
        #endif
    #endif
}
`;

// node_modules/molstar/lib/mol-gl/shader/cylinders.vert.js
var xL0 = `
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;
attribute float aColorMode;

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

uniform float uIsOrtho;
uniform vec3 uCameraDir;

void main() {
    int vertexId = VertexID;

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

    mat4 modelTransform = uModel * aTransform;

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

    vModelPosition = (vStart + vEnd) * 0.5;
    vec3 camDir = -mix(normalize(vModelPosition - uCameraPosition), uCameraDir, uIsOrtho);
    vec3 dir = vEnd - vStart;
    float f = aMapping.x > 0.0 ? 1.0 : 0.0;
    // ensure cylinder 'dir' is pointing towards the camera
    if(dot(camDir, dir) < 0.0) {
        dir = -dir;
        f = 1.0 - f;
    }

    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;

    if (gl_Position.z < -gl_Position.w) {
        mvPosition.z -= 2.0 * (length(vEnd - vStart) + vSize); // avoid clipping
        gl_Position.z = (uProjection * mvPosition).z;
    }

    #if defined(dDualColor) && defined(dRenderVariant_color) && (defined(dColorType_group) || defined(dColorType_groupInstance))
        // dual-color mixing
        // - for aColorMode between 0 and 1 use aColorMode to interpolate
        // - for aColorMode == 2 do nothing, i.e., use vColor
        // - for aColorMode == 3 use position on cylinder axis to interpolate
        if (aColorMode <= 1.0){
            vColor.rgb = mix(vColor.rgb, color2.rgb, aColorMode);
        } else if (aColorMode == 3.0) {
            vColor.rgb = mix(vColor.rgb, color2.rgb, mix(-0.25, 1.25, f / 1.5));
        }
    #endif

    #include clip_instance
}
`;

// node_modules/molstar/lib/mol-gl/shader/cylinders.frag.js
var yL0 = `
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;

uniform vec4 uInteriorColor;
uniform vec4 uInteriorSubstance;

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

#ifdef dSolidInterior
    const bool solidInterior = true;
#else
    const bool solidInterior = false;
#endif

// 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 vec3 cameraNormal, out bool interior,
    out vec3 modelPosition, out vec3 viewPosition, out float fragmentDepth
){
    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;

    #ifdef dSolidInterior
        bool topInterior = !topCap;
        bool bottomInterior = !bottomCap;
        topCap = true;
        bottomCap = true;
    #else
        bool topInterior = false;
        bool bottomInterior = false;
    #endif

    bool clipped = false;
    bool objectClipped = false;

    // body outside
    h = sqrt(h);
    float t = (-k1 - h) / k2;
    float y = baoc + t * bard;
    if (y > 0.0 && y < baba) {
        interior = false;
        cameraNormal = (oc + t * rayDir - ba * y / baba) / radius;
        modelPosition = rayOrigin + t * rayDir;
        viewPosition = (uView * vec4(modelPosition, 1.0)).xyz;
        fragmentDepth = calcDepth(viewPosition);
        #if defined(dClipVariant_pixel) && dClipObjectCount != 0
            if (clipTest(modelPosition)) {
                objectClipped = true;
                fragmentDepth = -1.0;
                #ifdef dSolidInterior
                    topCap = !topInterior;
                    bottomCap = !bottomInterior;
                #endif
            }
        #endif
        if (fragmentDepth > 0.0) return true;
        clipped = true;
    }

    if (!clipped) {
        if (topCap && y < 0.0) {
            // top cap
            t = -baoc / bard;
            if (abs(k1 + k2 * t) < h) {
                interior = topInterior;
                cameraNormal = -ba / baba;
                modelPosition = rayOrigin + t * rayDir;
                viewPosition = (uView * vec4(modelPosition, 1.0)).xyz;
                fragmentDepth = calcDepth(viewPosition);
                #if defined(dClipVariant_pixel) && dClipObjectCount != 0
                    if (clipTest(modelPosition)) {
                        objectClipped = true;
                        fragmentDepth = -1.0;
                        #ifdef dSolidInterior
                            topCap = !topInterior;
                            bottomCap = !bottomInterior;
                        #endif
                    }
                #endif
                if (fragmentDepth > 0.0) {
                    #ifdef dSolidInterior
                        if (interior) cameraNormal = -rayDir;
                    #endif
                    #if defined(dClipVariant_pixel) && dClipObjectCount != 0
                        return true;
                    #else
                        return !interior;
                    #endif
                }
            }
        } else if (bottomCap && y >= 0.0) {
            // bottom cap
            t = (baba - baoc) / bard;
            if (abs(k1 + k2 * t) < h) {
                interior = bottomInterior;
                cameraNormal = ba / baba;
                modelPosition = rayOrigin + t * rayDir;
                viewPosition = (uView * vec4(modelPosition, 1.0)).xyz;
                fragmentDepth = calcDepth(viewPosition);
                #if defined(dClipVariant_pixel) && dClipObjectCount != 0
                    if (clipTest(modelPosition)) {
                        objectClipped = true;
                        fragmentDepth = -1.0;
                        #ifdef dSolidInterior
                            topCap = !topInterior;
                            bottomCap = !bottomInterior;
                        #endif
                    }
                #endif
                if (fragmentDepth > 0.0) {
                    #ifdef dSolidInterior
                        if (interior) cameraNormal = -rayDir;
                    #endif
                    #if defined(dClipVariant_pixel) && dClipObjectCount != 0
                        return true;
                    #else
                        return !interior;
                    #endif
                }
            }
        }
    }

    if (uDoubleSided || solidInterior) {
        // body inside
        h = -h;
        t = (-k1 - h) / k2;
        y = baoc + t * bard;
        if (y > 0.0 && y < baba) {
            interior = true;
            cameraNormal = -(oc + t * rayDir - ba * y / baba) / radius;
            modelPosition = rayOrigin + t * rayDir;
            viewPosition = (uView * vec4(modelPosition, 1.0)).xyz;
            fragmentDepth = calcDepth(viewPosition);
            if (fragmentDepth > 0.0) {
                #ifdef dSolidInterior
                    if (!objectClipped) {
                        fragmentDepth = 0.0 + (0.0000002 / vSize);
                        cameraNormal = -rayDir;

                        // intersection of ray in model space with near plane in camera space
                        vec3 cameraRayOrigin = (uView * vec4(rayOrigin, 1.0)).xyz;
                        vec3 cameraRayDir = (uView * vec4(rayDir, 0.0)).xyz;
                        float nearT = - (uNear + cameraRayOrigin.z) / cameraRayDir.z;
                        viewPosition = cameraRayOrigin + nearT * cameraRayDir;
                        modelPosition = (uInvView * vec4(viewPosition, 1.0)).xyz;
                    }
                #endif
                return true;
            }
        }

        if (topCap && y < 0.0) {
            // top cap
            t = -baoc / bard;
            if (abs(k1 + k2 * t) < -h) {
                interior = true;
                cameraNormal = ba / baba;
                modelPosition = rayOrigin + t * rayDir;
                viewPosition = (uView * vec4(modelPosition, 1.0)).xyz;
                fragmentDepth = calcDepth(viewPosition);
                if (fragmentDepth > 0.0) {
                    #ifdef dSolidInterior
                        if (!objectClipped) {
                            fragmentDepth = 0.0 + (0.0000002 / vSize);
                            cameraNormal = -rayDir;

                            // intersection of ray in model space with near plane in camera space
                            vec3 cameraRayOrigin = (uView * vec4(rayOrigin, 1.0)).xyz;
                            vec3 cameraRayDir = (uView * vec4(rayDir, 0.0)).xyz;
                            float nearT = - (uNear + cameraRayOrigin.z) / cameraRayDir.z;
                            viewPosition = cameraRayOrigin + nearT * cameraRayDir;
                            modelPosition = (uInvView * vec4(viewPosition, 1.0)).xyz;
                        }
                    #endif
                    return true;
                }
            }
        } else if (bottomCap && y >= 0.0) {
            // bottom cap
            t = (baba - baoc) / bard;
            if (abs(k1 + k2 * t) < -h) {
                interior = true;
                cameraNormal = -ba / baba;
                modelPosition = rayOrigin + t * rayDir;
                viewPosition = (uView * vec4(modelPosition, 1.0)).xyz;
                fragmentDepth = calcDepth(viewPosition);
                if (fragmentDepth > 0.0) {
                    #ifdef dSolidInterior
                        if (!objectClipped) {
                            fragmentDepth = 0.0 + (0.0000002 / vSize);
                            cameraNormal = -rayDir;

                            // intersection of ray in model space with near plane in camera space
                            vec3 cameraRayOrigin = (uView * vec4(rayOrigin, 1.0)).xyz;
                            vec3 cameraRayDir = (uView * vec4(rayDir, 0.0)).xyz;
                            float nearT = - (uNear + cameraRayOrigin.z) / cameraRayDir.z;
                            viewPosition = cameraRayOrigin + nearT * cameraRayDir;
                            modelPosition = (uInvView * vec4(viewPosition, 1.0)).xyz;
                        }
                    #endif
                    return true;
                }
            }
        }
    }

    return false;
}

void main() {
    vec3 rayOrigin = vModelPosition;
    vec3 rayDir = mix(normalize(vModelPosition - uCameraPosition), uCameraDir, uIsOrtho);

    vec3 cameraNormal;
    vec3 modelPosition;
    vec3 viewPosition;
    float fragmentDepth;
    bool hit = CylinderImpostor(rayOrigin, rayDir, vStart, vEnd, vSize, cameraNormal, interior, modelPosition, viewPosition, fragmentDepth);
    if (!hit) discard;

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

    gl_FragDepthEXT = fragmentDepth;

    vec3 vViewPosition = viewPosition;
    vec3 vModelPosition = modelPosition;

    #include fade_lod
    #include clip_pixel

    #ifdef dNeedsNormal
        mat3 normalMatrix = adjoint(uView);
        vec3 normal = normalize(normalMatrix * -normalize(cameraNormal));
    #endif

    #include assign_material_color
    #include check_transparency

    #if defined(dRenderVariant_pick)
        #include check_picking_alpha
        #ifdef requiredDrawBuffers
            gl_FragColor = vObject;
            gl_FragData[1] = vInstance;
            gl_FragData[2] = vGroup;
            gl_FragData[3] = packDepthToRGBA(fragmentDepth);
        #else
            gl_FragColor = vColor;
        #endif
    #elif defined(dRenderVariant_depth)
        gl_FragColor = material;
    #elif defined(dRenderVariant_marking)
        gl_FragColor = material;
    #elif defined(dRenderVariant_emissive)
        gl_FragColor = material;
    #elif defined(dRenderVariant_color) || defined(dRenderVariant_tracing)
        #include apply_interior_color
        #include apply_light_color
        #include apply_marker_color

        #if defined(dRenderVariant_color)
            #include apply_fog
            #include wboit_write
            #include dpoit_write
        #elif defined(dRenderVariant_tracing)
            gl_FragData[1] = vec4(normal, emissive);
            gl_FragData[2] = vec4(material.rgb, uDensity);
        #endif
    #endif
}
`;

// node_modules/molstar/lib/mol-gl/shader/text.vert.js
var gL0 = `
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 float uIsOrtho;
uniform float uPixelRatio;
uniform vec4 uViewport;
uniform mat4 uInvHeadRotation;
uniform bool uHasHeadRotation;
uniform mat4 uModelViewEye;
uniform mat4 uInvModelViewEye;
uniform bool uHasEyeCamera;

varying vec2 vTexCoord;

void main(void){
    int vertexId = VertexID;

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

    vTexCoord = aTexCoord;

    float scale = uModelScale;

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

    vec4 position4 = vec4(aPosition, 1.0);
    vec4 mvPosition = uHasEyeCamera
         ? uModelViewEye * aTransform * position4
         : 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);
    }

    vec3 cornerOffset = vec3(0.0);
    cornerOffset.xy += aMapping * size * scale;
    cornerOffset.x += offsetX;
    cornerOffset.y += offsetY;

    if (uHasHeadRotation) {
        mvCorner.xyz += (uInvHeadRotation * vec4(cornerOffset, 1.0)).xyz;
    } else {
        mvCorner.xyz += cornerOffset;
    }

    if (!uHasEyeCamera) {
        if (uIsOrtho == 1.0) {
            mvCorner.z += offsetZ;
        } else {
            mvCorner.xyz += normalize(-mvCorner.xyz) * offsetZ;
        }
    }

    if (uHasEyeCamera) {
        mvCorner = uModelView * uInvModelViewEye * mvCorner;
    }

    gl_Position = uProjection * mvCorner;

    vViewPosition = -mvCorner.xyz;

    #include clip_instance
}
`;

// node_modules/molstar/lib/mol-gl/shader/text.frag.js
var mL0 = `
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;

void main(){
    #include fade_lod
    #include clip_pixel

    float fragmentDepth = gl_FragCoord.z;
    #include assign_material_color

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

        if (sdf < 0.5) discard;

        #if defined(dRenderVariant_color) || defined(dRenderVariant_tracing)
            // add border
            float t = 0.5 + uBorderWidth;
            if (uBorderWidth > 0.0 && sdf < t) {
                material.xyz = uBorderColor;
            }
        #endif
    }

    #include check_transparency

    #if defined(dRenderVariant_pick)
        #include check_picking_alpha
        #ifdef requiredDrawBuffers
            gl_FragColor = vObject;
            gl_FragData[1] = vInstance;
            gl_FragData[2] = vGroup;
            gl_FragData[3] = packDepthToRGBA(fragmentDepth);
        #else
            gl_FragColor = vColor;
        #endif
    #elif defined(dRenderVariant_depth)
        gl_FragColor = material;
    #elif defined(dRenderVariant_marking)
        gl_FragColor = material;
    #elif defined(dRenderVariant_emissive)
        gl_FragColor = material;
    #elif defined(dRenderVariant_color) || defined(dRenderVariant_tracing)
        gl_FragColor = material;
        #include apply_marker_color

        #if defined(dRenderVariant_color)
            #include apply_fog
            #include wboit_write
            #include dpoit_write
        #elif defined(dRenderVariant_tracing)
            gl_FragData[1] = vec4(-normalize(vViewPosition), emissive);
            gl_FragData[2] = vec4(material.rgb, uDensity);
        #endif
    #endif
}
`;

// node_modules/molstar/lib/mol-gl/shader/lines.vert.js
var dL0 = `
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;
    int vertexId = VertexID;

    #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
}
`;

// node_modules/molstar/lib/mol-gl/shader/lines.frag.js
var pL0 = `
precision highp float;
precision highp int;

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

void main(){
    #include fade_lod
    #include clip_pixel

    float fragmentDepth = gl_FragCoord.z;
    #include assign_material_color
    #include check_transparency

    #if defined(dRenderVariant_pick)
        #include check_picking_alpha
        #ifdef requiredDrawBuffers
            gl_FragColor = vObject;
            gl_FragData[1] = vInstance;
            gl_FragData[2] = vGroup;
            gl_FragData[3] = packDepthToRGBA(fragmentDepth);
        #else
            gl_FragColor = vColor;
        #endif
    #elif defined(dRenderVariant_depth)
        gl_FragColor = material;
    #elif defined(dRenderVariant_marking)
        gl_FragColor = material;
    #elif defined(dRenderVariant_emissive)
        gl_FragColor = material;
    #elif defined(dRenderVariant_color) || defined(dRenderVariant_tracing)
        gl_FragColor = material;
        #include apply_marker_color

        #if defined(dRenderVariant_color)
            #include apply_fog
            #include wboit_write
            #include dpoit_write
        #elif defined(dRenderVariant_tracing)
            gl_FragData[1] = vec4(normalize(vViewPosition), emissive);
            gl_FragData[2] = vec4(material.rgb, uDensity);
        #endif
    #endif
}
`;

// node_modules/molstar/lib/mol-gl/shader/mesh.vert.js
var uL0 = `
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(){
    int vertexId = VertexID;

    #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 = adjoint(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;
}
`;

// node_modules/molstar/lib/mol-gl/shader/mesh.frag.js
var cL0 = `
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

uniform vec4 uInteriorColor;
uniform vec4 uInteriorSubstance;

void main() {
    #include fade_lod
    #include clip_pixel

    interior = !gl_FrontFacing;

    float fragmentDepth = gl_FragCoord.z;

    #ifdef dNeedsNormal
        #if defined(dFlatShaded)
            vec3 fdx = dFdx(vViewPosition);
            vec3 fdy = dFdy(vViewPosition);
            vec3 normal = -normalize(cross(fdx,fdy));
        #else
            vec3 normal = -normalize(vNormal);
            if (uDoubleSided) normal *= float(gl_FrontFacing) * 2.0 - 1.0;
        #endif

        #if defined(dFlipSided)
            normal *= -1.0;
        #endif
    #endif

    #include assign_material_color
    #include check_transparency

    #if defined(dRenderVariant_pick)
        #include check_picking_alpha
        #ifdef requiredDrawBuffers
            gl_FragColor = vObject;
            gl_FragData[1] = vInstance;
            gl_FragData[2] = vGroup;
            gl_FragData[3] = packDepthToRGBA(fragmentDepth);
        #else
            gl_FragColor = vColor;
        #endif
    #elif defined(dRenderVariant_depth)
        gl_FragColor = material;
    #elif defined(dRenderVariant_marking)
        gl_FragColor = material;
    #elif defined(dRenderVariant_emissive)
        gl_FragColor = material;
    #elif defined(dRenderVariant_color) || defined(dRenderVariant_tracing)
        #include apply_interior_color
        #include apply_light_color
        #include apply_marker_color

        #if defined(dRenderVariant_color)
            #include apply_fog
            #include wboit_write
            #include dpoit_write
        #elif defined(dRenderVariant_tracing)
            gl_FragData[1] = vec4(normal, emissive);
            gl_FragData[2] = vec4(material.rgb, uDensity);
        #endif
    #endif
}
`;

// node_modules/molstar/lib/mol-gl/shader/direct-volume.vert.js
var lL0 = `
precision highp float;

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

uniform mat4 uModel;
uniform mat4 uModelView;
uniform mat4 uProjection;
uniform vec4 uInvariantBoundingSphere;
uniform float uModelScale;

varying vec3 vModelPosition;
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;

    vModelPosition = (uModel * aTransform * uUnitToCartn * unitCoord).xyz;
    vInstance = aInstance;
    vBoundingSphere = vec4(
        (uModel * aTransform * vec4(uInvariantBoundingSphere.xyz, 1.0)).xyz,
        uModelScale * 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;
}
`;

// node_modules/molstar/lib/mol-gl/shader/direct-volume.frag.js
var nL0 = `
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];
    uniform mat4 uClipObjectTransform[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 float uModelScale;

uniform sampler2D tDepth;
uniform vec2 uDrawingBufferSize;

varying vec3 vModelPosition;
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;

#if defined(dColorMarker)
    uniform vec3 uHighlightColor;
    uniform vec3 uSelectColor;
    uniform vec3 uDimColor;
    uniform float uHighlightStrength;
    uniform float uSelectStrength;
    uniform float uDimStrength;
    uniform int uMarkerPriority;
    uniform float uMarkerAverage;

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

uniform float uMetalness;
uniform float uRoughness;
uniform float uEmissive;

// Density value to estimate object thickness
uniform float uDensity;

uniform bool uFog;
uniform float uFogNear;
uniform float uFogFar;
uniform vec3 uFogColor;

uniform float uAlpha;
uniform bool uTransparentBackground;
uniform float uXrayEdgeFalloff;
uniform float uCelSteps;
uniform float uExposure;

uniform int uRenderMask;

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 vec2 uPaletteDomain;
    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
        return texture2D(tDepth, coords).r;
    #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 = adjoint(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;
    float emissive = uEmissive;

    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 / uModelScale, 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 / uModelScale, 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 modelPosition = v3m4(unitPos * uGridDim, modelTransform);
            if (clipTest(modelPosition)) {
                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)
            float paletteValue = (value - uPaletteDomain[0]) / (uPaletteDomain[1] - uPaletteDomain[0]);
            material.rgb = texture2D(tPalette, vec2(clamp(paletteValue, 0.0, 1.0), 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, unitPos, uGridDim, uColorTexDim, 0.0).rgb;
        #elif defined(dColorType_vertexInstance)
            material.rgb = texture3dFrom1dTrilinear(tColor, unitPos, 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, unitPos, uGridDim, uOverpaintTexDim, vInstance * float(uVertexCount));
            #endif

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

        #if defined(dIgnoreLight)
            gl_FragColor.rgb = material.rgb;
        #else
            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;
            }
        #endif

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

        #if defined(dColorMarker)
            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
            }
        #endif
        #include apply_marker_color

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

        src = gl_FragColor;

        if (!uTransparentBackground || !uFog) {
            // 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 defined(dRenderVariant_tracing) || defined(dRenderVariant_emissive)
        discard;
    #else
        if (gl_FrontFacing)
            discard;

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

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

        float fragmentDepth = calcDepth((uView * vec4(start, 1.0)).xyz);
        float preFogAlpha = clamp(preFogAlphaBlended, 0.0, 1.0);
        #include wboit_write
    #endif
}
`;

// node_modules/molstar/lib/mol-gl/shader/image.vert.js
var iL0 = `
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() {
    int vertexId = VertexID;

    #include assign_position

    vUv = aUv;
    vInstance = aInstance;
}
`;

// node_modules/molstar/lib/mol-gl/shader/image.frag.js
var oL0 = `
precision highp float;
precision highp int;

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

uniform float uEmissive;

// Density value to estimate object thickness
uniform float uDensity;

#if defined(dRenderVariant_color) || defined(dRenderVariant_tracing)
    #ifdef dOverpaint
        #if defined(dOverpaintType_instance) || defined(dOverpaintType_groupInstance)
            varying vec4 vOverpaint;
            uniform vec2 uOverpaintTexDim;
            uniform sampler2D tOverpaint;
        #endif
        uniform float uOverpaintStrength;
    #endif
#endif

#if defined(dRenderVariant_color) || defined(dRenderVariant_tracing) || defined(dRenderVariant_emissive)
    #ifdef dEmissive
        #if defined(dEmissiveType_instance) || defined(dEmissiveType_groupInstance)
            varying float vEmissive;
            uniform vec2 uEmissiveTexDim;
            uniform sampler2D tEmissive;
        #endif
        uniform float uEmissiveStrength;
    #endif
#endif

#ifdef dTransparency
    #if defined(dTransparencyType_instance) || defined(dTransparencyType_groupInstance)
        varying float vTransparency;
        uniform vec2 uTransparencyTexDim;
        uniform sampler2D tTransparency;
    #endif
    uniform float uTransparencyStrength;
#endif

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

uniform vec2 uMarkerTexDim;
uniform sampler2D tMarker;

varying vec2 vUv;
varying float vInstance;

#ifdef dUsePalette
    uniform sampler2D tPalette;
    uniform vec3 uPaletteDefault;
#endif

uniform int uTrimType;
uniform vec3 uTrimCenter;
uniform vec4 uTrimRotation;
uniform vec3 uTrimScale;
uniform mat4 uTrimTransform;

uniform float uIsoLevel;

#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 = abs(cubicFilter(m - cell.x) * cubicFilter(-n + cell.y));
                nSum += vecData * c;
                nDenom += c;
            }
        }
        return nSum / nDenom;
    }
#endif

void main() {
    if (uTrimType != 0 && getSignedDistance(vModelPosition, uTrimType, uTrimCenter, uTrimRotation, uTrimScale, uTrimTransform) > 0.0) discard;

    #include fade_lod
    #include clip_pixel

    #if defined(dInterpolation_cubic)
        #ifdef dUsePalette
            vec4 material = texture2D(tImageTex, vUv);
            if (material.rgb != vec3(1.0)) {
                material = biCubic(tImageTex, vUv);
            }
        #else
            vec4 material = biCubic(tImageTex, vUv);
        #endif
    #else
        vec4 material = texture2D(tImageTex, vUv);
    #endif

    if (uIsoLevel >= 0.0) {
        if (texture2D(tValueTex, vUv).r < uIsoLevel) discard;

        material.a = uAlpha;
    } else {
        if (material.a == 0.0) discard;

        material.a *= uAlpha;
    }

    float fragmentDepth = gl_FragCoord.z;

    vec3 packedGroup = texture2D(tGroupTex, vUv).rgb;
    float group = packedGroup == vec3(0.0) ? -1.0 : unpackRGBToInt(packedGroup);

    // apply per-group transparency
    #if defined(dTransparency) && (defined(dRenderVariant_pick) || defined(dRenderVariant_color) || defined(dRenderVariant_emissive) || defined(dRenderVariant_tracing))
        float transparency = 0.0;
        #if defined(dTransparencyType_instance)
            transparency = readFromTexture(tTransparency, vInstance, uTransparencyTexDim).a;
        #elif defined(dTransparencyType_groupInstance)
            transparency = readFromTexture(tTransparency, vInstance * float(uGroupCount) + group, uTransparencyTexDim).a;
        #endif
        transparency *= uTransparencyStrength;

        float ta = 1.0 - transparency;
        if (transparency < 0.09) ta = 1.0; // hard cutoff looks better

        #if defined(dRenderVariant_pick)
            if (ta * uAlpha < uPickingAlphaThreshold)
                discard; // ignore so the element below can be picked
        #elif defined(dRenderVariant_emissive)
            if (ta < 1.0)
                discard; // emissive not supported with transparency
        #elif defined(dRenderVariant_color) || defined(dRenderVariant_tracing)
            material.a *= ta;
        #endif
    #endif

    if ((uRenderMask == MaskOpaque && material.a < 1.0) ||
        (uRenderMask == MaskTransparent && material.a == 1.0)
    ) {
        discard;
    }

    #if defined(dNeedsMarker)
        float marker = uMarker;
        if (group == -1.0) {
            marker = 0.0;
        } else 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
        }
    #endif

    #if defined(dRenderVariant_color) || defined(dRenderVariant_tracing) || defined(dRenderVariant_emissive)
        float emissive = uEmissive;
        if (group == -1.0) {
            emissive = 0.0;
        } else {
            #ifdef dEmissive
                #if defined(dEmissiveType_instance)
                    emissive += readFromTexture(tEmissive, vInstance, uEmissiveTexDim).a * uEmissiveStrength;
                #elif defined(dEmissiveType_groupInstance)
                    emissive += readFromTexture(tEmissive, vInstance * float(uGroupCount) + group, uEmissiveTexDim).a * uEmissiveStrength;
                #endif
            #endif
        }
    #endif

    #if defined(dRenderVariant_pick)
        if (group == -1.0) discard;

        #include check_picking_alpha
        #ifdef requiredDrawBuffers
            gl_FragColor = vec4(packIntToRGB(float(uObjectId)), 1.0);
            gl_FragData[1] = vec4(packIntToRGB(vInstance), 1.0);
            gl_FragData[2] = vec4(packIntToRGB(group), 1.0);
            gl_FragData[3] = packDepthToRGBA(fragmentDepth);
        #else
            gl_FragColor = vColor;
            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(packIntToRGB(group), 1.0);
            }
        #endif
    #elif defined(dRenderVariant_depth)
        if (uRenderMask == MaskOpaque) {
            gl_FragColor = packDepthToRGBA(fragmentDepth);
        } else if (uRenderMask == MaskTransparent) {
            gl_FragColor = packDepthWithAlphaToRGBA(fragmentDepth, material.a);
        }
    #elif defined(dRenderVariant_marking)
        if (uMarkingType == 1) {
            if (marker > 0.0)
                discard;
            gl_FragColor = packDepthToRGBA(fragmentDepth);
        } else {
            if (marker == 0.0)
                discard;
            float depthTest = 1.0;
            if (uMarkingDepthTest) {
                depthTest = (fragmentDepth >= getDepthPacked(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;
            gl_FragColor = vec4(0.0, depthTest, isHighlight ? 1.0 : 0.0, 1.0 - fogFactor);
        }
    #elif defined(dRenderVariant_emissive)
        gl_FragColor = vec4(emissive);
    #elif defined(dRenderVariant_color) || defined(dRenderVariant_tracing)
        #ifdef dUsePalette
            if (material.rgb == vec3(1.0)) {
                material.rgb = uPaletteDefault;
            } else {
                float v = ((material.r * 256.0 * 256.0 * 255.0 + material.g * 256.0 * 255.0 + material.b * 255.0) - 1.0) / PALETTE_SCALE;
                material.rgb = texture2D(tPalette, vec2(v, 0.0)).rgb;
            }
        #endif

        // mix material with overpaint
        #if defined(dOverpaint)
            vec4 overpaint = vec4(0.0);
            if (group != -1.0) {
                #if defined(dOverpaintType_instance)
                    overpaint = readFromTexture(tOverpaint, vInstance, uOverpaintTexDim);
                #elif defined(dOverpaintType_groupInstance)
                    overpaint = readFromTexture(tOverpaint, vInstance * float(uGroupCount) + group, uOverpaintTexDim);
                #endif
                overpaint *= uOverpaintStrength;
            }
            material.rgb = mix(material.rgb, overpaint.rgb, overpaint.a);
        #endif

        gl_FragColor = material;
        #include apply_marker_color

        #if defined(dRenderVariant_color)
            #include apply_fog
            #include wboit_write
            #include dpoit_write
        #elif defined(dRenderVariant_tracing)
            gl_FragData[1] = vec4(normalize(vViewPosition), emissive);
            gl_FragData[2] = vec4(material.rgb, uDensity);
        #endif
    #endif
}
`;

// node_modules/molstar/lib/mol-gl/shader-code.js
var tL0 = $7(), cZ1 = {
  apply_fog: ZL0,
  apply_interior_color: JL0,
  apply_light_color: $L0,
  apply_marker_color: XL0,
  assign_clipping_varying: YL0,
  assign_color_varying: QL0,
  assign_group: WL0,
  assign_marker_varying: KL0,
  assign_material_color: GL0,
  assign_position: HL0,
  assign_size: NL0,
  check_picking_alpha: qL0,
  check_transparency: FL0,
  clip_instance: UL0,
  clip_pixel: LL0,
  color_frag_params: RL0,
  color_vert_params: EL0,
  common_clip: OL0,
  common_frag_params: zL0,
  common_vert_params: DL0,
  common: ML0,
  fade_lod: AL0,
  float_to_rgba: BL0,
  light_frag_params: wL0,
  normal_frag_params: jL0,
  read_from_texture: TL0,
  rgba_to_float: _L0,
  size_vert_params: VL0,
  texture3d_from_1d_trilinear: IL0,
  texture3d_from_2d_linear: PL0,
  texture3d_from_2d_nearest: CL0,
  wboit_write: kL0,
  dpoit_write: vL0
}, lZ1 = /^(?!\/\/)\s*#include\s+(\S+)/gm, nZ1 = /#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, iZ1 = /[ \t]*\/\/.*\n/g, oZ1 = /[ \t]*\/\*[\s\S]*?\*\//g, sZ1 = /\n{2,}/g;
function sL0(Z) {
  return Z.replace(lZ1, (J, $) => {
    let X = cZ1[$];
    if (!X)
      throw new Error(`empty chunk, '${$}'`);
    return X;
  }).trim().replace(iZ1, `
`).replace(oZ1, `
`).replace(sZ1, `
`);
}
function aZ1(Z) {
  return Z.replace(nZ1, rZ1);
}
function rZ1(Z, J, $, X) {
  let Y = "";
  for (let Q = parseInt(J);Q < parseInt($); ++Q)
    Y += X.replace(/\[\s*i\s*\]/g, `[${Q}]`).replace(/UNROLLED_LOOP_INDEX/g, `${Q}`);
  return Y;
}
function tZ1(Z, J) {
  if (J.dLightCount)
    Z = Z.replace(/dLightCount/g, `${J.dLightCount.ref.value}`);
  if (J.dClipObjectCount)
    Z = Z.replace(/dClipObjectCount/g, `${J.dClipObjectCount.ref.value}`);
  return Z;
}
function aL0(Z, J) {
  return aZ1(tZ1(Z, J));
}
function v8(Z, J, $, X = {}, Y = {}, Q) {
  return { id: tL0(), name: Z, vert: sL0(J), frag: sL0($), extensions: X, outTypes: Y, ignoreDefine: Q };
}
function HV(Z, J, $) {
  var X;
  if (J.startsWith("color") || J === "tracing") {
    if (Z === "dLightCount")
      return !!((X = $.dIgnoreLight) === null || X === void 0 ? void 0 : X.ref.value);
  } else {
    let Y = [
      "dColorType",
      "dUsePalette",
      "dOverpaintType",
      "dOverpaint",
      "dSubstanceType",
      "dSubstance",
      "dColorMarker",
      "dCelShaded",
      "dLightCount"
    ];
    if (J !== "depth" && !J.startsWith("pick"))
      Y.push("dXrayShaded");
    if (J !== "emissive")
      Y.push("dEmissiveType", "dEmissive");
    return Y.includes(Z);
  }
  return !1;
}
function Dh(Z, J, $) {
  if (Z === "dLightCount")
    return !0;
  return HV(Z, J, $);
}
var eL0 = v8("points", SL0, fL0, { drawBuffers: "optional" }, {}, Dh), ZR0 = v8("spheres", hL0, bL0, { fragDepth: "required", drawBuffers: "optional" }, {}, HV), JR0 = v8("cylinders", xL0, yL0, { fragDepth: "required", drawBuffers: "optional" }, {}, HV), $R0 = v8("text", gL0, mL0, { drawBuffers: "optional" }, {}, Dh), XR0 = v8("lines", dL0, pL0, { drawBuffers: "optional" }, {}, Dh), Mh = v8("mesh", uL0, cL0, { drawBuffers: "optional" }, {}, HV), YR0 = v8("direct-volume", lL0, nL0, { fragDepth: "optional", drawBuffers: "optional" }, {}, HV), QR0 = v8("image", iL0, oL0, { drawBuffers: "optional" }, {}, Dh);
function rL0(Z, J) {
  var $;
  if (Z === void 0)
    return "";
  let X = (($ = Z.dRenderVariant) === null || $ === void 0 ? void 0 : $.ref.value) || "", Y = [];
  for (let Q in Z) {
    if (J === null || J === void 0 ? void 0 : J(Q, X, Z))
      continue;
    let K = Z[Q].ref.value;
    if (K !== void 0)
      if (typeof K === "string")
        Y.push(`#define ${Q}_${K}`);
      else if (typeof K === "number")
        Y.push(`#define ${Q} ${K}`);
      else if (typeof K === "boolean") {
        if (K)
          Y.push(`#define ${Q}`);
      } else
        T8(K);
  }
  return Y.join(`
`) + `
`;
}
function eZ1(Z, J) {
  let $ = [];
  if (J.drawBuffers) {
    if (Z.drawBuffers)
      $.push("#define requiredDrawBuffers");
    else if (J.drawBuffers === "required")
      throw new Error("required 'GL_EXT_draw_buffers' extension not available");
  }
  if (J.multiDraw) {
    if (Z.multiDraw)
      $.push("#extension GL_ANGLE_multi_draw : require"), $.push("#define enabledMultiDraw");
    else if (J.multiDraw === "required")
      throw new Error("required 'GL_ANGLE_multi_draw' extension not available");
  }
  return $.join(`
`) + `
`;
}
function Z91(Z, J) {
  let $ = [
    "#extension GL_OES_standard_derivatives : enable"
  ];
  if (J.fragDepth) {
    if (Z.fragDepth)
      $.push("#extension GL_EXT_frag_depth : enable"), $.push("#define enabledFragDepth");
    else if (J.fragDepth === "required")
      throw new Error("required 'GL_EXT_frag_depth' extension not available");
  }
  if (J.drawBuffers) {
    if (Z.drawBuffers)
      $.push("#extension GL_EXT_draw_buffers : require"), $.push("#define requiredDrawBuffers"), $.push("#define gl_FragColor gl_FragData[0]");
    else if (J.drawBuffers === "required")
      throw new Error("required 'GL_EXT_draw_buffers' extension not available");
  }
  if (J.shaderTextureLod) {
    if (Z.shaderTextureLod)
      $.push("#extension GL_EXT_shader_texture_lod : enable"), $.push("#define enabledShaderTextureLod");
    else if (J.shaderTextureLod === "required")
      throw new Error("required 'GL_EXT_shader_texture_lod' extension not available");
  }
  if (Z.depthTexture)
    $.push("#define depthTextureSupport");
  return $.join(`
`) + `
`;
}
var J91 = `
#define attribute in
#define varying out
#define texture2D texture
`, $91 = `
#define varying in
#define texture2D texture
#define textureCube texture
#define texture2DLodEXT textureLod
#define textureCubeLodEXT textureLod

#define gl_FragColor out_FragData0
#define gl_FragDepthEXT gl_FragDepth
`;
function X91(Z, J) {
  let $ = [
    "#version 300 es"
  ];
  if (J.drawBuffers) {
    if (Z.drawBuffers)
      $.push("#define requiredDrawBuffers");
  }
  if (J.multiDraw) {
    if (Z.multiDraw)
      $.push("#extension GL_ANGLE_multi_draw : require"), $.push("#define enabledMultiDraw");
    else if (J.multiDraw === "required")
      throw new Error("required 'GL_ANGLE_multi_draw' extension not available");
  }
  if (J.clipCullDistance) {
    if (Z.clipCullDistance)
      $.push("#extension GL_ANGLE_clip_cull_distance : enable"), $.push("#define enabledClipCullDistance");
    else if (J.clipCullDistance === "required")
      throw new Error("required 'GL_ANGLE_clip_cull_distance' extension not available");
  }
  if (J.conservativeDepth) {
    if (Z.conservativeDepth)
      $.push("#extension GL_EXT_conservative_depth : enable"), $.push("#define enabledConservativeDepth");
    else if (J.conservativeDepth === "required")
      throw new Error("required 'GL_EXT_conservative_depth' extension not available");
  }
  if (J.multiview2) {
    if (Z.multiview2)
      $.push("#extension GL_OVR_multiview2 : require"), $.push("#define enabledMultiview2");
    else if (J.multiview2 === "required")
      throw new Error("required 'GL_OVR_multiview2' extension not available");
  }
  if (Z.noNonInstancedActiveAttribs)
    $.push("#define noNonInstancedActiveAttribs");
  return $.push(J91), $.join(`
`) + `
`;
}
function Y91(Z, J, $, X) {
  let Y = [
    "#version 300 es",
    `layout(location = 0) out highp ${X[0] || "vec4"} out_FragData0;`
  ];
  if ($.fragDepth) {
    if (Z.fragDepth)
      Y.push("#define enabledFragDepth");
  }
  if ($.drawBuffers) {
    if (Z.drawBuffers) {
      Y.push("#define requiredDrawBuffers");
      for (let Q = 1, W = J.maxDrawBuffers;Q < W; ++Q)
        Y.push(`layout(location = ${Q}) out highp ${X[Q] || "vec4"} out_FragData${Q};`);
    }
  }
  if ($.shaderTextureLod) {
    if (Z.shaderTextureLod)
      Y.push("#define enabledShaderTextureLod");
  }
  if (Z.depthTexture)
    Y.push("#define depthTextureSupport");
  return Y.push($91), Y.join(`
`) + `
`;
}
function Q91(Z) {
  return Z.replace(/gl_FragData\[([0-9]+)\]/g, "out_FragData$1");
}
function WR0(Z, J, $, X, Y) {
  let Q = rL0(X, Y.ignoreDefine), W = rL0(X, Y.ignoreDefine), K = _2(Z) ? X91(J, Y.extensions) : eZ1(J, Y.extensions), G = _2(Z) ? Y91(J, $, Y.extensions, Y.outTypes) : Z91(J, Y.extensions), H = _2(Z) ? Q91(Y.frag) : Y.frag;
  return {
    id: tL0(),
    name: Y.name,
    vert: `${K}${Q}${aL0(Y.vert, X)}`,
    frag: `${G}${W}${aL0(H, X)}`,
    extensions: Y.extensions,
    outTypes: Y.outTypes
  };
}

// node_modules/molstar/lib/mol-gl/webgl/uniform.js
function HR0(Z, J) {
  switch (J) {
    case "b":
    case "b[]":
      return Z.BOOL;
    case "f":
    case "f[]":
      return Z.FLOAT;
    case "i":
    case "i[]":
      return Z.INT;
    case "v2":
    case "v2[]":
      return Z.FLOAT_VEC2;
    case "v3":
    case "v3[]":
      return Z.FLOAT_VEC3;
    case "v4":
    case "v4[]":
      return Z.FLOAT_VEC4;
    case "q":
    case "q[]":
      return Z.FLOAT_VEC4;
    case "iv2":
    case "iv2[]":
      return Z.INT_VEC2;
    case "iv3":
    case "iv3[]":
      return Z.INT_VEC3;
    case "iv4":
    case "iv4[]":
      return Z.INT_VEC4;
    case "m3":
    case "m3[]":
      return Z.FLOAT_MAT3;
    case "m4":
    case "m4[]":
      return Z.FLOAT_MAT4;
    default:
      console.error(`unknown uniform kind '${J}'`);
  }
}
function NR0(Z) {
  return Z.endsWith("[]");
}
function W91(Z, J, $) {
  Z.uniform1f(J, $);
}
function K91(Z, J, $) {
  Z.uniform1fv(J, $);
}
function G91(Z, J, $) {
  Z.uniform1i(J, $);
}
function H91(Z, J, $) {
  Z.uniform1iv(J, $);
}
function N91(Z, J, $) {
  Z.uniform2fv(J, $);
}
function q91(Z, J, $) {
  Z.uniform3fv(J, $);
}
function KR0(Z, J, $) {
  Z.uniform4fv(J, $);
}
function F91(Z, J, $) {
  Z.uniform2iv(J, $);
}
function U91(Z, J, $) {
  Z.uniform3iv(J, $);
}
function L91(Z, J, $) {
  Z.uniform4iv(J, $);
}
function R91(Z, J, $) {
  Z.uniformMatrix3fv(J, !1, $);
}
function E91(Z, J, $) {
  Z.uniformMatrix4fv(J, !1, $);
}
function GR0(Z) {
  switch (Z) {
    case "f":
      return W91;
    case "f[]":
      return K91;
    case "i":
    case "t":
    case "b":
      return G91;
    case "i[]":
    case "t[]":
    case "b[]":
      return H91;
    case "v2":
    case "v2[]":
      return N91;
    case "v3":
    case "v3[]":
      return q91;
    case "v4":
    case "v4[]":
      return KR0;
    case "q":
    case "q[]":
      return KR0;
    case "iv2":
    case "iv2[]":
      return F91;
    case "iv3":
    case "iv3[]":
      return U91;
    case "iv4":
    case "iv4[]":
      return L91;
    case "m3":
    case "m3[]":
      return R91;
    case "m4":
    case "m4[]":
      return E91;
  }
}
function qR0(Z) {
  let J = {};
  return Object.keys(Z).forEach(($) => {
    let X = Z[$];
    if (X.type === "uniform")
      J[$] = GR0(X.kind);
    else if (X.type === "texture")
      J[$] = GR0("t");
  }), J;
}
function FR0(Z) {
  let J = {};
  return Object.keys(Z).forEach(($) => {
    J[$] = C.create(W$(Z[$].ref.value));
  }), J;
}

// node_modules/molstar/lib/mol-gl/webgl/buffer.js
var UR0 = $7();
function O91(Z, J) {
  switch (J) {
    case "static":
      return Z.STATIC_DRAW;
    case "dynamic":
      return Z.DYNAMIC_DRAW;
    case "stream":
      return Z.STREAM_DRAW;
    default:
      T8(J);
  }
}
function z91(Z, J) {
  if (J instanceof Uint8Array)
    return Z.UNSIGNED_BYTE;
  else if (J instanceof Int8Array)
    return Z.BYTE;
  else if (J instanceof Uint16Array)
    return Z.UNSIGNED_SHORT;
  else if (J instanceof Int16Array)
    return Z.SHORT;
  else if (J instanceof Uint32Array)
    return Z.UNSIGNED_INT;
  else if (J instanceof Int32Array)
    return Z.INT;
  else if (J instanceof Float32Array)
    return Z.FLOAT;
  T8(J);
}
function D91(Z, J) {
  switch (J) {
    case "attribute":
      return Z.ARRAY_BUFFER;
    case "elements":
      return Z.ELEMENT_ARRAY_BUFFER;
    case "uniform":
      if (_2(Z))
        return Z.UNIFORM_BUFFER;
      else
        throw new Error("WebGL2 is required for uniform buffers");
    case "pixel-pack":
      if (_2(Z))
        return Z.PIXEL_PACK_BUFFER;
      else
        throw new Error("WebGL2 is required for pixel-pack buffers");
  }
}
function Ah(Z) {
  let J = Z.createBuffer();
  if (J === null)
    throw new Error("Could not create WebGL buffer");
  return J;
}
function LR0(Z, J, $, X) {
  let Y = Ah(Z), Q = O91(Z, $), W = D91(Z, X), K = z91(Z, J), G = J.BYTES_PER_ELEMENT, H = J.length;
  function N(U) {
    Z.bindBuffer(W, Y), Z.bufferData(W, U, Q);
  }
  N(J);
  let q = !1;
  return {
    id: UR0(),
    _usageHint: Q,
    _bufferType: W,
    _dataType: K,
    _bpe: G,
    length: H,
    getByteCount: () => {
      return G * H;
    },
    getBuffer: () => Y,
    updateData: N,
    updateSubData: (U, F, E) => {
      if (Z.bindBuffer(W, Y), E - F === U.length)
        Z.bufferSubData(W, 0, U);
      else
        Z.bufferSubData(W, F * G, U.subarray(F, F + E));
    },
    reset: () => {
      Y = Ah(Z), N(J);
    },
    destroy: () => {
      if (q)
        return;
      Z.deleteBuffer(Y), q = !0;
    }
  };
}
function RR0(Z, J, $) {
  switch (J) {
    case "float32":
      switch ($) {
        case 1:
          return Z.FLOAT;
        case 2:
          return Z.FLOAT_VEC2;
        case 3:
          return Z.FLOAT_VEC3;
        case 4:
          return Z.FLOAT_VEC4;
        case 16:
          return Z.FLOAT_MAT4;
      }
    default:
      T8(J);
  }
}
function ER0(Z, J, $, X, Y, Q, W = "static") {
  let { instancedArrays: K } = $, G = LR0(Z, X, W, "attribute"), { _bufferType: H, _dataType: N, _bpe: q } = G;
  return {
    ...G,
    divisor: Q,
    bind: (U) => {
      if (Z.bindBuffer(H, G.getBuffer()), Y === 16)
        for (let F = 0;F < 4; ++F)
          J.enableVertexAttrib(U + F), Z.vertexAttribPointer(U + F, 4, N, !1, 16 * q, F * 4 * q), K.vertexAttribDivisor(U + F, Q);
      else
        J.enableVertexAttrib(U), Z.vertexAttribPointer(U, Y, N, !1, 0, 0), K.vertexAttribDivisor(U, Q);
    },
    changeOffset: (U, F) => {
      let E = F * q * Y;
      if (Z.bindBuffer(H, G.getBuffer()), Y === 16)
        for (let R = 0;R < 4; ++R)
          Z.vertexAttribPointer(U + R, 4, N, !1, 16 * q, R * 4 * q + E);
      else
        Z.vertexAttribPointer(U, Y, N, !1, 0, E);
    }
  };
}
function OR0(Z, J, $) {
  let X = [];
  return Object.keys(J).forEach((Y) => {
    let Q = J[Y];
    if (Q.type === "attribute")
      X[X.length] = [Y, Z.resources.attribute($[Y].ref.value, Q.itemSize, Q.divisor)];
  }), X;
}
function zR0(Z, J, $ = "static") {
  let X = LR0(Z, J, $, "elements");
  return {
    ...X,
    bind: () => {
      Z.bindBuffer(Z.ELEMENT_ARRAY_BUFFER, X.getBuffer());
    }
  };
}
function DR0(Z, J, $, X) {
  let Y = Ah(Z), Q = as(Z, J, X), W = Bh(Z, $, X), K = ss($, X), G = 0, H = 0;
  function N(F, E, R, z) {
    G = R, H = z, Z.bindBuffer(Z.PIXEL_PACK_BUFFER, Y), Z.bufferData(Z.PIXEL_PACK_BUFFER, R * z * K, Z.STREAM_READ), Z.readPixels(F, E, R, z, W, Q, 0), Z.bindBuffer(Z.PIXEL_PACK_BUFFER, null);
  }
  function q(F) {
    Z.bindBuffer(Z.PIXEL_PACK_BUFFER, Y), Z.getBufferSubData(Z.PIXEL_PACK_BUFFER, 0, F), Z.bindBuffer(Z.PIXEL_PACK_BUFFER, null);
  }
  let U = !1;
  return {
    id: UR0(),
    _type: Q,
    _format: W,
    _bpe: K,
    getByteCount: () => {
      return K * G * H;
    },
    read: N,
    getSubData: q,
    reset: () => {
      Y = Ah(Z);
    },
    destroy: () => {
      if (U)
        return;
      Z.deleteBuffer(Y), U = !0;
    }
  };
}

// node_modules/molstar/lib/mol-gl/webgl/program.js
var M91 = $7();
function A91(Z, J, $) {
  let X = {};
  return Object.keys($).forEach((Y) => {
    let Q = $[Y];
    if (Q.type === "attribute") {
      let W = Z.getAttribLocation(J, Y);
      X[Y] = W;
    } else if (Q.type === "uniform") {
      let W = Z.getUniformLocation(J, Y);
      if (W === null && NR0(Q.kind))
        W = Z.getUniformLocation(J, Y + "[0]");
      X[Y] = W;
    } else if (Q.type === "texture") {
      let W = Z.getUniformLocation(J, Y);
      X[Y] = W;
    }
  }), X;
}
function B91(Z, J, $) {
  let X = Z.getProgramParameter(J, Z.ACTIVE_ATTRIBUTES);
  for (let Y = 0;Y < X; ++Y) {
    let Q = Z.getActiveAttrib(J, Y);
    if (Q) {
      let { name: W, type: K } = Q;
      if (W.startsWith("__activeAttribute"))
        continue;
      if (W === "gl_InstanceID")
        continue;
      if (W === "gl_VertexID")
        continue;
      if (W === "gl_DrawID")
        continue;
      if (W === "gl_ViewID_OVR")
        continue;
      let G = $[W];
      if (G === void 0)
        throw new Error(`missing 'uniform' or 'texture' with name '${W}' in schema`);
      if (G.type !== "attribute")
        throw new Error(`'${W}' must be of type 'attribute' but is '${G.type}'`);
      let H = RR0(Z, G.kind, G.itemSize);
      if (H !== K)
        throw new Error(`unexpected attribute type '${H}' for ${W}, expected '${K}'`);
    }
  }
}
function w91(Z, J, $) {
  let X = Z.getProgramParameter(J, Z.ACTIVE_UNIFORMS);
  for (let Y = 0;Y < X; ++Y) {
    let Q = Z.getActiveUniform(J, Y);
    if (Q) {
      let { name: W, type: K } = Q;
      if (W.startsWith("__activeUniform"))
        continue;
      if (W === "gl_InstanceID")
        continue;
      if (W === "gl_VertexID")
        continue;
      if (W === "gl_DrawID")
        continue;
      if (W === "gl_ViewID_OVR")
        continue;
      let G = W.replace(/[[0-9]+\]$/, ""), H = $[G];
      if (H === void 0)
        throw new Error(`missing 'uniform' or 'texture' with name '${W}' in schema`);
      if (H.type === "uniform") {
        if (HR0(Z, H.kind) !== K)
          throw new Error(`unexpected uniform type for ${W}`);
      } else if (H.type === "texture") {
        if (H.kind === "image-float32" || H.kind === "image-uint8") {
          if (K !== Z.SAMPLER_2D)
            throw new Error(`unexpected sampler type for '${W}'`);
        } else if (H.kind === "volume-float32" || H.kind === "volume-uint8")
          if (_2(Z)) {
            if (K !== Z.SAMPLER_3D)
              throw new Error(`unexpected sampler type for '${W}'`);
          } else
            throw new Error("WebGL2 is required to use SAMPLER_3D");
      } else
        throw new Error(`'${W}' must be of type 'uniform' or 'texture' but is '${H.type}'`);
    }
  }
}
function j91(Z, J) {
  if (!Z.getProgramParameter(J, Z.LINK_STATUS))
    throw new Error(`Could not compile WebGL program. 

${Z.getProgramInfoLog(J)}`);
}
function wh(Z) {
  let J = Z.createProgram();
  if (J === null)
    throw new Error("Could not create WebGL program");
  return J;
}
function T91(Z) {
  if (typeof Z !== "string")
    throw new Error(`unknown program variant: ${Z}`);
  if (Z.startsWith("color"))
    return "color";
  if (Z.startsWith("pick"))
    return "pick";
  return Z;
}
function MR0(Z, J, $, X, Y, Q) {
  let { defineValues: W, shaderCode: K, schema: G } = Q, H = wh(Z), N = M91(), q = T91(W.dRenderVariant.ref.value), U = WR0(Z, $, X, W, K), F = Y("vert", U.vert), E = Y("frag", U.frag), R, z, D = !1, A = !1, B = !1;
  function T() {
    if (F.attach(H), E.attach(H), Z.linkProgram(H), y2)
      j91(Z, H);
    D = !0;
  }
  if (q === "compute")
    T();
  function w() {
    if (R = A91(Z, H, G), z = qR0(G), y2)
      B91(Z, H, G), w91(Z, H, G);
    A = !0;
  }
  return {
    id: N,
    variant: q,
    isReady: () => {
      return A;
    },
    link: () => {
      if (!D)
        T();
    },
    finalize(V) {
      if (!D)
        T();
      if (!A && (V || !$.parallelShaderCompile || Z.getProgramParameter(H, $.parallelShaderCompile.COMPLETION_STATUS)))
        w();
      return A;
    },
    use: () => {
      if (y2 && !A)
        throw new Error(`program not finalized: ${q}`);
      J.currentProgramId = N, Z.useProgram(H);
    },
    setUniforms: (V) => {
      for (let P = 0, I = V.length;P < I; ++P) {
        let [S, f] = V[P];
        if (f) {
          let v = R[S];
          if (v !== null)
            z[S](Z, v, f.ref.value);
        }
      }
    },
    uniform: (V, P) => {
      let I = R[V];
      if (I !== null)
        z[V](Z, I, P);
    },
    bindAttributes: (V) => {
      J.clearVertexAttribsState();
      for (let P = 0, I = V.length;P < I; ++P) {
        let [S, f] = V[P], v = R[S];
        if (v !== -1)
          f.bind(v);
      }
      J.disableUnusedVertexAttribs();
    },
    offsetAttributes: (V, P) => {
      for (let I = 0, S = V.length;I < S; ++I) {
        let [f, v] = V[I], h = R[f];
        if (h !== -1)
          v.changeOffset(h, P);
      }
    },
    bindTextures: (V, P) => {
      for (let I = 0, S = V.length;I < S; ++I) {
        let [f, v] = V[I], h = R[f];
        if (h !== null && h !== void 0)
          v.bind(I + P), z[f](Z, h, I + P);
      }
    },
    reset: () => {
      if (H = wh(Z), D)
        T();
      if (A)
        w();
    },
    destroy: () => {
      if (B)
        return;
      F.destroy(), E.destroy(), Z.deleteProgram(H), B = !0;
    }
  };
}

// node_modules/molstar/lib/mol-gl/webgl/shader.js
var _91 = $7();
function V91(Z) {
  let J = Z.split(`
`);
  for (let $ = 0;$ < J.length; ++$)
    J[$] = $ + 1 + ": " + J[$];
  return J.join(`
`);
}
function NV(Z, J) {
  let { type: $, source: X } = J, Y = Z.createShader($ === "vert" ? Z.VERTEX_SHADER : Z.FRAGMENT_SHADER);
  if (Y === null)
    throw new Error(`Error creating ${$} shader`);
  if (Z.shaderSource(Y, X), Z.compileShader(Y), y2 && Z.getShaderParameter(Y, Z.COMPILE_STATUS) === !1)
    throw console.warn(`'${$}' shader info log '${Z.getShaderInfoLog(Y)}'
${V91(X)}`), new Error(`Error compiling ${$} shader`);
  return Y;
}
function AR0(Z, J) {
  let $ = NV(Z, J);
  return {
    id: _91(),
    attach: (X) => {
      Z.attachShader(X, $);
    },
    reset: () => {
      $ = NV(Z, J);
    },
    destroy: () => {
      Z.deleteShader($);
    }
  };
}

// node_modules/molstar/lib/mol-util/reference-cache.js
function I91(Z, J = 0) {
  return { value: Z, usageCount: J };
}
function P91(Z) {
  return {
    free: () => {
      Z.usageCount -= 1;
    },
    value: Z.value
  };
}
function rs(Z, J, $) {
  let X = /* @__PURE__ */ new Map, Y = [];
  return {
    get: (Q) => {
      let W = Z(Q), K = X.get(W);
      if (!K)
        K = I91(J(Q)), X.set(W, K), Y.push(K.value);
      return K.usageCount += 1, P91(K);
    },
    clear: () => {
      X.forEach((Q, W) => {
        if (Q.usageCount <= 0) {
          if (Q.usageCount < 0)
            console.warn("Reference usageCount below zero.");
          $(Q.value), X.delete(W), ZH(Y, Q.value);
        }
      });
    },
    get count() {
      return X.size;
    },
    values: Y,
    dispose: () => {
      X.forEach((Q) => $(Q.value)), X.clear(), Y.length = 0;
    }
  };
}

// node_modules/molstar/lib/mol-gl/webgl/renderbuffer.js
var C91 = $7();
function k91(Z, J) {
  switch (J) {
    case "depth16":
      return Z.DEPTH_COMPONENT16;
    case "stencil8":
      return Z.STENCIL_INDEX8;
    case "rgba4":
      return Z.RGBA4;
    case "depth-stencil":
      return Z.DEPTH_STENCIL;
    case "depth24":
      if (_2(Z))
        return Z.DEPTH_COMPONENT24;
      else
        throw new Error("WebGL2 needed for `depth24` renderbuffer format");
    case "depth32f":
      if (_2(Z))
        return Z.DEPTH_COMPONENT32F;
      else
        throw new Error("WebGL2 needed for `depth32f` renderbuffer format");
    case "depth24-stencil8":
      if (_2(Z))
        return Z.DEPTH24_STENCIL8;
      else
        throw new Error("WebGL2 needed for `depth24-stencil8` renderbuffer format");
    case "depth32f-stencil8":
      if (_2(Z))
        return Z.DEPTH32F_STENCIL8;
      else
        throw new Error("WebGL2 needed for `depth32f-stencil8` renderbuffer format");
  }
}
function v91(Z) {
  switch (Z) {
    case "depth16":
      return 4;
    case "stencil8":
      return 2;
    case "rgba4":
      return 4;
    case "depth-stencil":
      return 4;
    case "depth24":
      return 3;
    case "depth32f":
      return 4;
    case "depth24-stencil8":
      return 4;
    case "depth32f-stencil8":
      return 5;
  }
}
function S91(Z, J) {
  switch (J) {
    case "depth":
      return Z.DEPTH_ATTACHMENT;
    case "stencil":
      return Z.STENCIL_ATTACHMENT;
    case "depth-stencil":
      return Z.DEPTH_STENCIL_ATTACHMENT;
    case "color0":
      return Z.COLOR_ATTACHMENT0;
  }
}
function BR0(Z) {
  let J = Z.createRenderbuffer();
  if (J === null)
    throw new Error("Could not create WebGL renderbuffer");
  return J;
}
function wR0(Z, J, $, X, Y) {
  let Q = BR0(Z), W = () => Z.bindRenderbuffer(Z.RENDERBUFFER, Q), K = k91(Z, J), G = S91(Z, $);
  function H() {
    W(), Z.renderbufferStorage(Z.RENDERBUFFER, K, X, Y);
  }
  H();
  let N = !1;
  return {
    id: C91(),
    getByteCount: () => v91(J) * X * Y,
    bind: W,
    attachFramebuffer: (q) => {
      if (q.bind(), W(), Z.framebufferRenderbuffer(Z.FRAMEBUFFER, G, Z.RENDERBUFFER, Q), y2)
        FA(Z);
    },
    detachFramebuffer: (q) => {
      if (q.bind(), W(), Z.framebufferRenderbuffer(Z.FRAMEBUFFER, G, Z.RENDERBUFFER, null), y2)
        FA(Z);
    },
    setSize: (q, U) => {
      X = q, Y = U, H();
    },
    reset: () => {
      Q = BR0(Z), H();
    },
    destroy: () => {
      if (N)
        return;
      Z.deleteRenderbuffer(Q), N = !0;
    }
  };
}

// node_modules/molstar/lib/mol-gl/webgl/vertex-array.js
var f91 = $7();
function jR0(Z) {
  let { vertexArrayObject: J } = Z;
  if (!J)
    throw new Error("VertexArrayObject not supported");
  let $ = J.createVertexArray();
  if (!$)
    throw new Error("Could not create WebGL vertex array");
  return $;
}
function TR0(Z) {
  let { vertexArrayObject: J } = Z;
  if (J === null)
    throw new Error("VertexArrayObject not supported");
  return J;
}
function _R0(Z, J, $, X, Y) {
  let Q = f91(), W = jR0(J), K = TR0(J);
  function G() {
    if (K.bindVertexArray(W), Y)
      Y.bind();
    $.bindAttributes(X), K.bindVertexArray(null), H = !0;
  }
  let H = !1, N = !1;
  return {
    id: Q,
    bind: () => {
      if (!H)
        G();
      K.bindVertexArray(W);
    },
    update: G,
    reset: () => {
      W = jR0(J), K = TR0(J), H = !1;
    },
    destroy: () => {
      if (N)
        return;
      if (Y)
        K.bindVertexArray(W), Z.bindBuffer(Z.ELEMENT_ARRAY_BUFFER, null);
      K.deleteVertexArray(W), N = !0;
    }
  };
}

// node_modules/molstar/lib/mol-gl/webgl/resources.js
function h91(Z) {
  return typeof Z === "boolean" ? Z ? 1 : 0 : typeof Z === "number" ? Z * 1e4 : O_(Z);
}
function VR0(Z) {
  return {
    ...Z.value,
    destroy: () => {
      Z.free();
    }
  };
}
function IR0(Z, J, $, X, Y) {
  let Q = {
    attribute: /* @__PURE__ */ new Set,
    elements: /* @__PURE__ */ new Set,
    pixelPack: /* @__PURE__ */ new Set,
    framebuffer: /* @__PURE__ */ new Set,
    program: /* @__PURE__ */ new Set,
    renderbuffer: /* @__PURE__ */ new Set,
    shader: /* @__PURE__ */ new Set,
    texture: /* @__PURE__ */ new Set,
    cubeTexture: /* @__PURE__ */ new Set,
    vertexArray: /* @__PURE__ */ new Set
  };
  function W(q, U) {
    return Q[q].add(U), $.resourceCounts[q] += 1, {
      ...U,
      destroy: () => {
        U.destroy(), Q[q].delete(U), $.resourceCounts[q] -= 1;
      }
    };
  }
  let K = rs((q) => JSON.stringify(q), (q) => W("shader", AR0(Z, q)), (q) => {
    q.destroy();
  });
  function G(q, U) {
    return VR0(K.get({ type: q, source: U }));
  }
  let H = /* @__PURE__ */ new Set, N = rs((q) => {
    var U;
    let F = [q.shaderCode.id], E = ((U = q.defineValues.dRenderVariant) === null || U === void 0 ? void 0 : U.ref.value) || "";
    return Object.keys(q.defineValues).forEach((R) => {
      var z, D;
      if (!((D = (z = q.shaderCode).ignoreDefine) === null || D === void 0 ? void 0 : D.call(z, R, E, q.defineValues)))
        F.push(O_(R), h91(q.defineValues[R].ref.value));
    }), l9(F).toString();
  }, (q) => {
    let U = MR0(Z, J, X, Y, G, q);
    if (U.variant !== "compute")
      H.add(U);
    return W("program", U);
  }, (q) => {
    H.delete(q), q.destroy();
  });
  return {
    attribute: (q, U, F, E) => {
      return W("attribute", ER0(Z, J, X, q, U, F, E));
    },
    elements: (q, U) => {
      return W("elements", zR0(Z, q, U));
    },
    pixelPack: (q, U) => {
      if (!_2(Z))
        throw new Error("WebGL2 is required for pixel-pack buffers");
      return W("pixelPack", DR0(Z, X, q, U));
    },
    framebuffer: () => {
      return W("framebuffer", EU0(Z));
    },
    program: (q, U, F) => {
      return VR0(N.get({ defineValues: q, shaderCode: U, schema: F }));
    },
    renderbuffer: (q, U, F, E) => {
      return W("renderbuffer", wR0(Z, q, U, F, E));
    },
    shader: G,
    texture: (q, U, F, E) => {
      return W("texture", PR0(Z, X, q, U, F, E));
    },
    cubeTexture: (q, U, F) => {
      return W("cubeTexture", CR0(Z, q, U, F));
    },
    vertexArray: (q, U, F) => {
      return W("vertexArray", _R0(Z, X, q, U, F));
    },
    getByteCounts: () => {
      let q = 0;
      Q.texture.forEach((D) => {
        q += D.getByteCount();
      });
      let U = 0;
      Q.cubeTexture.forEach((D) => {
        U += D.getByteCount();
      });
      let F = 0;
      Q.attribute.forEach((D) => {
        F += D.getByteCount();
      });
      let E = 0;
      Q.elements.forEach((D) => {
        E += D.getByteCount();
      });
      let R = 0;
      Q.pixelPack.forEach((D) => {
        R += D.getByteCount();
      });
      let z = 0;
      return Q.renderbuffer.forEach((D) => {
        z += D.getByteCount();
      }), { texture: q, cubeTexture: U, attribute: F, elements: E, pixelPack: R, renderbuffer: z };
    },
    linkPrograms: (q) => {
      for (let U of H) {
        if (q && !q.includes(U.variant))
          continue;
        U.link();
      }
    },
    finalizePrograms: (q, U) => {
      let F = !0, E = 0;
      for (let A of H) {
        if (A.isReady())
          H.delete(A);
        if (!q || q.includes(A.variant))
          F = !1, E += 1;
      }
      if (F)
        return !0;
      let R = !0, z = 0, D = m6();
      for (let A of H) {
        if (q && !q.includes(A.variant))
          continue;
        if (!A.finalize(U))
          R = !1;
        else
          H.delete(A), z += 1;
        if (!U && m6() - D > 16) {
          R = !1;
          break;
        }
      }
      if (K1)
        console.log(`Finalized ${z} of ${E} programs (${q ? q.join(", ") : "all"}) in ${(m6() - D).toFixed(2)} ms`);
      return R;
    },
    reset: () => {
      Q.attribute.forEach((q) => q.reset()), Q.elements.forEach((q) => q.reset()), Q.pixelPack.forEach((q) => q.reset()), Q.framebuffer.forEach((q) => q.reset()), Q.renderbuffer.forEach((q) => q.reset()), Q.shader.forEach((q) => q.reset()), Q.program.forEach((q) => q.reset()), Q.vertexArray.forEach((q) => q.reset()), Q.texture.forEach((q) => q.reset()), Q.cubeTexture.forEach((q) => q.reset());
    },
    destroy: () => {
      Q.attribute.forEach((q) => q.destroy()), Q.elements.forEach((q) => q.destroy()), Q.pixelPack.forEach((q) => q.destroy()), Q.framebuffer.forEach((q) => q.destroy()), Q.renderbuffer.forEach((q) => q.destroy()), Q.shader.forEach((q) => q.destroy()), Q.program.forEach((q) => q.destroy()), Q.vertexArray.forEach((q) => q.destroy()), Q.texture.forEach((q) => q.destroy()), Q.cubeTexture.forEach((q) => q.destroy()), K.clear(), N.clear(), H.clear();
    }
  };
}

// node_modules/molstar/lib/mol-gl/webgl/render-target.js
var b91 = $7();
function kR0(Z, J, $, X, Y = !0, Q = "uint8", W = "nearest", K = "rgba") {
  if (K === "alpha" && !_2(Z))
    throw new Error("cannot render to alpha format in webgl1");
  let G = J.framebuffer(), H = Q === "fp16" ? J.texture("image-float16", K, "fp16", W) : Q === "float32" ? J.texture("image-float32", K, "float", W) : J.texture("image-uint8", K, "ubyte", W), N = !Y ? null : _2(Z) ? J.renderbuffer("depth32f", "depth", $, X) : J.renderbuffer("depth16", "depth", $, X);
  function q() {
    if (H.define($, X), H.attachFramebuffer(G, "color0"), N)
      N.attachFramebuffer(G);
  }
  q();
  let U = !1;
  return {
    id: b91(),
    texture: H,
    framebuffer: G,
    depthRenderbuffer: N,
    getByteCount: () => H.getByteCount() + (N ? N.getByteCount() : 0),
    getWidth: () => $,
    getHeight: () => X,
    bind: () => {
      G.bind();
    },
    setSize: (F, E) => {
      if ($ === F && X === E)
        return;
      if ($ = F, X = E, H.define($, X), N)
        N.setSize($, X);
    },
    reset: () => {
      q();
    },
    destroy: () => {
      if (U)
        return;
      if (H.destroy(), G.destroy(), N)
        N.destroy();
      U = !0;
    }
  };
}

// node_modules/molstar/lib/mol-gl/webgl/timer.js
function x91(Z, J, $) {
  return Z -= Z / $, Z += J / $, Z;
}

class ts {
  add(Z, J) {
    let $ = this.avgs.get(Z) || J;
    return $ = x91($, J, this.count), this.avgs.set(Z, $), $;
  }
  get(Z) {
    return this.avgs.get(Z);
  }
  stats() {
    return Object.fromEntries(this.avgs.entries());
  }
  clear() {
    this.avgs.clear();
  }
  constructor(Z) {
    this.count = Z, this.avgs = /* @__PURE__ */ new Map;
  }
}
function y91(Z) {
  Z.calls.drawInstanced = 0, Z.calls.drawInstancedBase = 0, Z.calls.multiDrawInstancedBase = 0, Z.calls.counts = 0, Z.culled.lod = 0, Z.culled.frustum = 0, Z.culled.occlusion = 0;
}
function g91(Z) {
  return Z.disjointTimerQuery ? Z.disjointTimerQuery.createQuery() : null;
}
function vR0(Z, J, $, X) {
  var Y;
  let Q = J.disjointTimerQuery, W = (Y = X === null || X === void 0 ? void 0 : X.avgCount) !== null && Y !== void 0 ? Y : 30, K = /* @__PURE__ */ new Map, G = /* @__PURE__ */ new Map, H = [], N = new ts(W), q = new ts(W), U = [], F = null, E = !1, R = () => {
    if (G.clear(), H.length = 0, N.clear(), q.clear(), U = [], F = null, E = !1, Q)
      K.forEach((D, A) => {
        Q.deleteQuery(A);
      });
    K.clear();
  }, z = () => {
    if (!Q)
      return;
    let D = g91(J);
    if (!D)
      return;
    Q.beginQuery(Q.TIME_ELAPSED, D), G.forEach((A, B) => {
      A.queries.push(D);
    }), K.set(D, { refCount: G.size }), F = D;
  };
  return {
    resolve: () => {
      let D = [];
      if (!Q || !U.length || E)
        return D;
      K.forEach((B, T) => {
        if (B.timeElapsed !== void 0)
          return;
        let w = Q.getQueryParameter(T, Q.QUERY_RESULT_AVAILABLE), V = Z.getParameter(Q.GPU_DISJOINT);
        if (w && !V) {
          let P = Q.getQueryParameter(T, Q.QUERY_RESULT);
          B.timeElapsed = P;
        }
        if (w || V)
          Q.deleteQuery(T);
      });
      let A = [];
      for (let B of U)
        if (B.queries.every((T) => {
          var w;
          return ((w = K.get(T)) === null || w === void 0 ? void 0 : w.timeElapsed) !== void 0;
        })) {
          let T = 0;
          for (let w of B.queries) {
            let V = K.get(w);
            T += V.timeElapsed, V.refCount -= 1;
          }
          if (B.timeElapsed = T, B.root) {
            let w = [], V = (I, S) => {
              for (let f of I) {
                let v = f.timeElapsed, h = f.cpu.end - f.cpu.start, x = {
                  label: f.label,
                  gpuElapsed: v,
                  gpuAvg: N.add(f.label, v),
                  cpuElapsed: h,
                  cpuAvg: q.add(f.label, h),
                  children: [],
                  calls: f.calls,
                  note: f.note
                };
                S.push(x), V(f.children, x.children);
              }
            };
            V(B.children, w);
            let P = B.cpu.end - B.cpu.start;
            D.push({
              label: B.label,
              gpuElapsed: T,
              gpuAvg: N.add(B.label, T),
              cpuElapsed: P,
              cpuAvg: q.add(B.label, P),
              children: w,
              calls: B.calls,
              note: B.note
            });
          }
        } else
          A.push(B);
      return U = A, K.forEach((B, T) => {
        if (B.refCount === 0)
          K.delete(T);
      }), D;
    },
    mark: (D, A) => {
      var B;
      if (!Q)
        return;
      if (G.has(D))
        throw new Error(`Timer mark for '${D}' already exists`);
      let T = (B = A === null || A === void 0 ? void 0 : A.captureStats) !== null && B !== void 0 ? B : !1;
      if (F !== null)
        Q.endQuery(Q.TIME_ELAPSED);
      let w = {
        label: D,
        queries: [],
        children: [],
        root: F === null,
        cpu: { start: m6(), end: -1 },
        captureStats: T
      };
      if (A === null || A === void 0 ? void 0 : A.note)
        w.note = A.note;
      if (G.set(D, w), H.length)
        H[H.length - 1].children.push(w);
      if (H.push(w), T) {
        if (E)
          throw new Error("Already capturing stats");
        y91($), E = !0;
      }
      z();
    },
    markEnd: (D) => {
      var A;
      if (!Q)
        return;
      let B = G.get(D);
      if (!B)
        throw new Error(`Timer mark for '${D}' does not exist`);
      if (((A = H.pop()) === null || A === void 0 ? void 0 : A.label) !== D)
        throw new Error(`Timer mark for '${D}' has pending nested mark`);
      if (Q.endQuery(Q.TIME_ELAPSED), G.delete(D), B.cpu.end = m6(), B.captureStats)
        B.calls = { ...$.calls }, E = !1;
      if (U.push(B), G.size > 0)
        z();
      else
        F = null;
    },
    stats: () => {
      return {
        gpu: N.stats(),
        cpu: q.stats()
      };
    },
    formatedStats: () => {
      let D = {}, A = N.stats(), B = q.stats();
      for (let T of Object.keys(A)) {
        let w = `${(A[T] / 1000 / 1000).toFixed(2)}`, V = `${B[T].toFixed(2)}`;
        D[T] = `${w} ms | CPU: ${V} ms`;
      }
      return D;
    },
    clear: R,
    destroy: () => {
      R();
    }
  };
}
function m91(Z) {
  let J = `${(Z.gpuElapsed / 1000 / 1000).toFixed(2)}`, $ = `${(Z.gpuAvg / 1000 / 1000).toFixed(2)}`, X = `${Z.cpuElapsed.toFixed(2)}`, Y = `${Z.cpuAvg.toFixed(2)}`;
  return `${Z.label} ${J} ms (avg. ${$} ms) | CPU: ${X} ms (avg. ${Y} ms)`;
}
function qV(Z) {
  Z.map((J) => {
    let $ = m91(J);
    if (J.children.length || J.calls || J.note) {
      if (console.groupCollapsed($), J.calls)
        console.log(J.calls);
      if (J.note)
        console.log(J.note);
      qV(J.children), console.groupEnd();
    } else
      console.log($);
  });
}

// node_modules/molstar/lib/mol-gl/webgl/context.js
function hR0(Z, J) {
  function $(Y) {
    try {
      return Z.getContext(Y, J);
    } catch (Q) {
      return null;
    }
  }
  let X = ((J === null || J === void 0 ? void 0 : J.preferWebGl1) ? null : $("webgl2")) || $("webgl") || $("experimental-webgl");
  if (y2)
    console.log(`isWebgl2: ${_2(X)}`);
  return X;
}
function Za(Z, J) {
  switch (J) {
    case Z.NO_ERROR:
      return "no error";
    case Z.INVALID_ENUM:
      return "invalid enum";
    case Z.INVALID_VALUE:
      return "invalid value";
    case Z.INVALID_OPERATION:
      return "invalid operation";
    case Z.INVALID_FRAMEBUFFER_OPERATION:
      return "invalid framebuffer operation";
    case Z.OUT_OF_MEMORY:
      return "out of memory";
    case Z.CONTEXT_LOST_WEBGL:
      return "context lost";
  }
  return "unknown error";
}
function bR0(Z, J) {
  let $ = Z.getError();
  if ($ !== Z.NO_ERROR)
    console.log(`WebGL error: '${Za(Z, $)}'${J ? ` (${J})` : ""}`);
}
function d91(Z) {
  let J = Z.getParameter(Z.MAX_TEXTURE_IMAGE_UNITS);
  for (let Y = 0;Y < J; ++Y)
    if (Z.activeTexture(Z.TEXTURE0 + Y), Z.bindTexture(Z.TEXTURE_2D, null), Z.bindTexture(Z.TEXTURE_CUBE_MAP, null), _2(Z))
      Z.bindTexture(Z.TEXTURE_2D_ARRAY, null), Z.bindTexture(Z.TEXTURE_3D, null);
  let $ = Z.createBuffer();
  Z.bindBuffer(Z.ARRAY_BUFFER, $);
  let X = Z.getParameter(Z.MAX_VERTEX_ATTRIBS);
  for (let Y = 0;Y < X; ++Y)
    Z.vertexAttribPointer(Y, 1, Z.FLOAT, !1, 0, 0);
  if (Z.bindBuffer(Z.ARRAY_BUFFER, null), Z.bindBuffer(Z.ELEMENT_ARRAY_BUFFER, null), Z.bindRenderbuffer(Z.RENDERBUFFER, null), Z.bindFramebuffer(Z.FRAMEBUFFER, null), _2(Z))
    Z.bindBuffer(Z.UNIFORM_BUFFER, null), Z.bindBuffer(Z.PIXEL_PACK_BUFFER, null);
}
var xR0 = new Uint8Array(4);
function yR0(Z, J, $) {
  if (Z.getSyncParameter(J, Z.SYNC_STATUS) === Z.SIGNALED)
    Z.deleteSync(J), $();
  else
    rG.setImmediate(yR0, Z, J, $);
}
function p91(Z, J) {
  let $ = Z.fenceSync(Z.SYNC_GPU_COMMANDS_COMPLETE, 0);
  if (!$)
    console.warn("Could not create a WebGLSync object"), Z.readPixels(0, 0, 1, 1, Z.RGBA, Z.UNSIGNED_BYTE, xR0), J();
  else
    rG.setImmediate(yR0, Z, $, J);
}
var SR0 = !1;
function u91(Z) {
  return new Promise((J) => {
    if (_2(Z))
      p91(Z, J);
    else {
      if (!SR0)
        console.info("Sync object not supported in WebGL"), SR0 = !0;
      gR0(Z), J();
    }
  });
}
function gR0(Z) {
  Z.bindFramebuffer(Z.FRAMEBUFFER, null), Z.readPixels(0, 0, 1, 1, Z.RGBA, Z.UNSIGNED_BYTE, xR0);
}
function c91(Z, J, $, X, Y, Q) {
  if (y2)
    FA(Z);
  if (Q instanceof Uint8Array)
    Z.readPixels(J, $, X, Y, Z.RGBA, Z.UNSIGNED_BYTE, Q);
  else if (Q instanceof Float32Array)
    Z.readPixels(J, $, X, Y, Z.RGBA, Z.FLOAT, Q);
  else if (Q instanceof Int32Array && _2(Z))
    Z.readPixels(J, $, X, Y, Z.RGBA_INTEGER, Z.INT, Q);
  else
    throw new Error("unsupported readPixels buffer type");
  if (y2)
    bR0(Z);
}
function es(Z, J) {
  if (J)
    Z.bindFramebuffer(Z.FRAMEBUFFER, J.framebuffer);
  else
    Z.bindFramebuffer(Z.FRAMEBUFFER, null);
}
function jh(Z, J, $) {
  var X, Y;
  let Q = (X = J === null || J === void 0 ? void 0 : J.framebufferWidth) !== null && X !== void 0 ? X : Z.drawingBufferWidth;
  if ($ === "screen-space")
    Q *= 2;
  let W = (Y = J === null || J === void 0 ? void 0 : J.framebufferHeight) !== null && Y !== void 0 ? Y : Z.drawingBufferHeight;
  return { width: Q, height: W };
}
function UA(Z, J, $, X) {
  let Y = J === "vertex" ? Z.VERTEX_SHADER : Z.FRAGMENT_SHADER, Q = Z[`${$.toUpperCase()}_${X.toUpperCase()}`];
  return Z.getShaderPrecisionFormat(Y, Q);
}
function fR0(Z, J) {
  return {
    lowFloat: UA(Z, J, "low", "float"),
    mediumFloat: UA(Z, J, "medium", "float"),
    highFloat: UA(Z, J, "high", "float"),
    lowInt: UA(Z, J, "low", "int"),
    mediumInt: UA(Z, J, "medium", "int"),
    highInt: UA(Z, J, "high", "int")
  };
}
function l91() {
  return {
    resourceCounts: {
      attribute: 0,
      elements: 0,
      pixelPack: 0,
      framebuffer: 0,
      program: 0,
      renderbuffer: 0,
      shader: 0,
      texture: 0,
      cubeTexture: 0,
      vertexArray: 0
    },
    drawCount: 0,
    instanceCount: 0,
    instancedDrawCount: 0,
    calls: {
      drawInstanced: 0,
      drawInstancedBase: 0,
      multiDrawInstancedBase: 0,
      counts: 0
    },
    culled: {
      lod: 0,
      frustum: 0,
      occlusion: 0
    }
  };
}
function n91(Z, J) {
  return {
    maxTextureSize: Z.getParameter(Z.MAX_TEXTURE_SIZE),
    max3dTextureSize: _2(Z) ? Z.getParameter(Z.MAX_3D_TEXTURE_SIZE) : 0,
    maxRenderbufferSize: Z.getParameter(Z.MAX_RENDERBUFFER_SIZE),
    maxDrawBuffers: J.drawBuffers ? Z.getParameter(J.drawBuffers.MAX_DRAW_BUFFERS) : 0,
    maxTextureImageUnits: Z.getParameter(Z.MAX_TEXTURE_IMAGE_UNITS),
    maxVertexTextureImageUnits: Z.getParameter(Z.MAX_VERTEX_TEXTURE_IMAGE_UNITS)
  };
}
function mR0(Z, J = {}) {
  let $ = os(Z), X = eU0(Z, $), Y = l91(), Q = n91(Z, $), W = IR0(Z, X, Y, $, Q), K = vR0(Z, $, Y);
  if (Q.maxVertexTextureImageUnits < 8)
    throw new Error('Need "MAX_VERTEX_TEXTURE_IMAGE_UNITS" >= 8');
  let G = {
    vertex: fR0(Z, "vertex"),
    fragment: fR0(Z, "fragment")
  };
  if (y2)
    console.log({ parameters: Q, shaderPrecisionFormats: G });
  let H = $.provokingVertex;
  H === null || H === void 0 || H.provokingVertex(H.FIRST_VERTEX_CONVENTION);
  let N = !1, q = new P6, U = J.pixelScale || 1, F = {
    session: void 0,
    layer: void 0,
    changed: new P6,
    clear: () => {
      F.layer = void 0, F.session = void 0, F.changed.next();
    }
  }, E = /* @__PURE__ */ new Set;
  return {
    gl: Z,
    isWebGL2: _2(Z),
    get pixelRatio() {
      return (typeof window !== "undefined" ? window.devicePixelRatio || 1 : 1) * (U || 1);
    },
    extensions: $,
    state: X,
    stats: Y,
    resources: W,
    timer: K,
    get maxTextureSize() {
      return Q.maxTextureSize;
    },
    get max3dTextureSize() {
      return Q.max3dTextureSize;
    },
    get maxRenderbufferSize() {
      return Q.maxRenderbufferSize;
    },
    get maxDrawBuffers() {
      return Q.maxDrawBuffers;
    },
    get maxTextureImageUnits() {
      return Q.maxTextureImageUnits;
    },
    get shaderPrecisionFormats() {
      return G;
    },
    namedComputeRenderables: Object.create(null),
    namedFramebuffers: Object.create(null),
    namedTextures: Object.create(null),
    get isContextLost() {
      return N || Z.isContextLost();
    },
    contextRestored: q,
    setContextLost: () => {
      N = !0, K.clear();
    },
    handleContextRestored: (R) => {
      zU0(Z, $), X.reset(), X.currentMaterialId = -1, X.currentProgramId = -1, X.currentRenderItemId = -1, W.reset(), E.forEach((z) => z.reset()), R === null || R === void 0 || R(), N = !1, q.next(m6());
    },
    xr: {
      get session() {
        return F.session;
      },
      changed: F.changed,
      set: async (R, z) => {
        var D, A;
        if (F.session === R)
          return;
        if (await ((D = F.session) === null || D === void 0 ? void 0 : D.end()), R === void 0)
          return;
        try {
          await Z.makeXRCompatible(), F.session = R, F.layer = new XRWebGLLayer(F.session, Z, {
            antialias: !0,
            alpha: !0,
            depth: !0,
            framebufferScaleFactor: U * ((A = z === null || z === void 0 ? void 0 : z.resolutionScale) !== null && A !== void 0 ? A : 1)
          }), await F.session.updateRenderState({ baseLayer: F.layer }), F.session.addEventListener("end", F.clear), F.changed.next();
        } catch (B) {
          if (R)
            await R.end();
          else
            F.layer = void 0, F.session = void 0;
          throw B;
        }
      },
      end: async () => {
        var R;
        return (R = F.session) === null || R === void 0 ? void 0 : R.end();
      }
    },
    setPixelScale: (R) => {
      U = R;
    },
    createRenderTarget: (R, z, D, A, B, T) => {
      let w = kR0(Z, W, R, z, D, A, B, T);
      return E.add(w), {
        ...w,
        destroy: () => {
          w.destroy(), E.delete(w);
        }
      };
    },
    createDrawTarget: () => {
      return {
        id: -1,
        texture: k9(Z),
        framebuffer: OU0(),
        depthRenderbuffer: null,
        getByteCount: () => 0,
        getWidth: () => {
          var R;
          return jh(Z, F.layer, (R = F.session) === null || R === void 0 ? void 0 : R.interactionMode).width;
        },
        getHeight: () => {
          var R;
          return jh(Z, F.layer, (R = F.session) === null || R === void 0 ? void 0 : R.interactionMode).height;
        },
        bind: () => {
          es(Z, F.layer);
        },
        setSize: () => {},
        reset: () => {},
        destroy: () => {}
      };
    },
    bindDrawingBuffer: () => es(Z, F.layer),
    getDrawingBufferSize: () => {
      var R;
      return jh(Z, F.layer, (R = F.session) === null || R === void 0 ? void 0 : R.interactionMode);
    },
    readPixels: (R, z, D, A, B) => {
      c91(Z, R, z, D, A, B);
    },
    waitForGpuCommandsComplete: () => u91(Z),
    waitForGpuCommandsCompleteSync: () => gR0(Z),
    getFenceSync: () => {
      return _2(Z) ? Z.fenceSync(Z.SYNC_GPU_COMMANDS_COMPLETE, 0) : null;
    },
    checkSyncStatus: (R) => {
      if (!_2(Z))
        return !0;
      if (Z.getSyncParameter(R, Z.SYNC_STATUS) === Z.SIGNALED)
        return Z.deleteSync(R), !0;
      else
        return !1;
    },
    deleteSync: (R) => {
      if (_2(Z))
        Z.deleteSync(R);
    },
    clear: (R, z, D, A) => {
      let B = jh(Z, F.layer);
      es(Z, F.layer), X.enable(Z.SCISSOR_TEST), X.depthMask(!0), X.colorMask(!0, !0, !0, !0), X.clearColor(R, z, D, A), X.viewport(0, 0, B.width, B.height), X.scissor(0, 0, B.width, B.height), Z.clear(Z.COLOR_BUFFER_BIT | Z.DEPTH_BUFFER_BIT);
    },
    checkError: (R) => {
      bR0(Z, R);
    },
    checkFramebufferStatus: (R) => {
      FA(Z, R);
    },
    destroy: (R) => {
      var z, D, A, B;
      if (W.destroy(), d91(Z), (z = F.session) === null || z === void 0 || z.removeEventListener("end", F.clear), (D = F.session) === null || D === void 0 || D.end(), q.complete(), F.changed.complete(), !(R === null || R === void 0 ? void 0 : R.doNotForceWebGLContextLoss))
        (A = Z.getExtension("WEBGL_lose_context")) === null || A === void 0 || A.loseContext(), (B = Z.getExtension("STACKGL_destroy_context")) === null || B === void 0 || B.destroy();
    }
  };
}

// node_modules/molstar/lib/mol-gl/webgl/compat.js
function _2(Z) {
  return typeof WebGL2RenderingContext !== "undefined" && Z instanceof WebGL2RenderingContext;
}
function DU0(Z) {
  if (_2(Z))
    return {
      drawArraysInstanced: Z.drawArraysInstanced.bind(Z),
      drawElementsInstanced: Z.drawElementsInstanced.bind(Z),
      vertexAttribDivisor: Z.vertexAttribDivisor.bind(Z),
      VERTEX_ATTRIB_ARRAY_DIVISOR: Z.VERTEX_ATTRIB_ARRAY_DIVISOR
    };
  else {
    let J = Z.getExtension("ANGLE_instanced_arrays");
    if (J === null)
      return null;
    return {
      drawArraysInstanced: J.drawArraysInstancedANGLE.bind(J),
      drawElementsInstanced: J.drawElementsInstancedANGLE.bind(J),
      vertexAttribDivisor: J.vertexAttribDivisorANGLE.bind(J),
      VERTEX_ATTRIB_ARRAY_DIVISOR: J.VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE
    };
  }
}
function MU0(Z) {
  if (_2(Z))
    return { FRAGMENT_SHADER_DERIVATIVE_HINT: Z.FRAGMENT_SHADER_DERIVATIVE_HINT };
  else {
    let J = Z.getExtension("OES_standard_derivatives");
    if (J === null)
      return null;
    return { FRAGMENT_SHADER_DERIVATIVE_HINT: J.FRAGMENT_SHADER_DERIVATIVE_HINT_OES };
  }
}
function AU0(Z) {
  return _2(Z) ? {} : Z.getExtension("OES_element_index_uint");
}
function BU0(Z) {
  if (_2(Z))
    return {
      VERTEX_ARRAY_BINDING: Z.VERTEX_ARRAY_BINDING,
      bindVertexArray: Z.bindVertexArray.bind(Z),
      createVertexArray: Z.createVertexArray.bind(Z),
      deleteVertexArray: Z.deleteVertexArray.bind(Z),
      isVertexArray: Z.isVertexArray.bind(Z)
    };
  else {
    let J = Z.getExtension("OES_vertex_array_object");
    if (J === null)
      return null;
    return {
      VERTEX_ARRAY_BINDING: J.VERTEX_ARRAY_BINDING_OES,
      bindVertexArray: J.bindVertexArrayOES.bind(J),
      createVertexArray: J.createVertexArrayOES.bind(J),
      deleteVertexArray: J.deleteVertexArrayOES.bind(J),
      isVertexArray: J.isVertexArrayOES.bind(J)
    };
  }
}
function wU0(Z) {
  return _2(Z) ? {} : Z.getExtension("OES_texture_float");
}
function jU0(Z) {
  return Z.getExtension("OES_texture_float_linear");
}
function TU0(Z) {
  if (_2(Z))
    return { HALF_FLOAT: Z.HALF_FLOAT };
  else {
    let J = Z.getExtension("OES_texture_half_float");
    if (J === null)
      return null;
    return { HALF_FLOAT: J.HALF_FLOAT_OES };
  }
}
function _U0(Z) {
  return Z.getExtension("OES_texture_half_float_linear");
}
function VU0(Z) {
  if (_2(Z))
    return { MIN: Z.MIN, MAX: Z.MAX };
  else {
    let J = Z.getExtension("EXT_blend_minmax");
    if (J === null)
      return null;
    return { MIN: J.MIN_EXT, MAX: J.MAX_EXT };
  }
}
function IU0(Z) {
  return _2(Z) ? {} : Z.getExtension("EXT_frag_depth");
}
function PU0(Z) {
  if (_2(Z)) {
    if (Z.getExtension("EXT_color_buffer_float") === null)
      return null;
    return Z.getExtension("EXT_float_blend"), { RGBA32F: Z.RGBA32F };
  } else {
    let J = Z.getExtension("WEBGL_color_buffer_float");
    if (J === null)
      return Z.getExtension("OES_texture_float"), dR0(Z, Z.FLOAT) ? { RGBA32F: 34836 } : null;
    return Z.getExtension("EXT_float_blend"), { RGBA32F: J.RGBA32F_EXT };
  }
}
function CU0(Z) {
  if (_2(Z)) {
    if (Z.getExtension("EXT_color_buffer_half_float") === null)
      return null;
    return Z.getExtension("EXT_float_blend"), { RGBA16F: Z.RGBA16F };
  } else {
    let J = Z.getExtension("EXT_color_buffer_half_float");
    if (J === null)
      return Z.getExtension("OES_texture_half_float"), dR0(Z, 36193) ? { RGBA16F: 34842 } : null;
    return Z.getExtension("EXT_float_blend"), { RGBA16F: J.RGBA16F_EXT };
  }
}
function kU0(Z) {
  if (_2(Z))
    return {
      drawBuffers: Z.drawBuffers.bind(Z),
      COLOR_ATTACHMENT0: Z.COLOR_ATTACHMENT0,
      COLOR_ATTACHMENT1: Z.COLOR_ATTACHMENT1,
      COLOR_ATTACHMENT2: Z.COLOR_ATTACHMENT2,
      COLOR_ATTACHMENT3: Z.COLOR_ATTACHMENT3,
      COLOR_ATTACHMENT4: Z.COLOR_ATTACHMENT4,
      COLOR_ATTACHMENT5: Z.COLOR_ATTACHMENT5,
      COLOR_ATTACHMENT6: Z.COLOR_ATTACHMENT6,
      COLOR_ATTACHMENT7: Z.COLOR_ATTACHMENT7,
      DRAW_BUFFER0: Z.DRAW_BUFFER0,
      DRAW_BUFFER1: Z.DRAW_BUFFER1,
      DRAW_BUFFER2: Z.DRAW_BUFFER2,
      DRAW_BUFFER3: Z.DRAW_BUFFER3,
      DRAW_BUFFER4: Z.DRAW_BUFFER4,
      DRAW_BUFFER5: Z.DRAW_BUFFER5,
      DRAW_BUFFER6: Z.DRAW_BUFFER6,
      DRAW_BUFFER7: Z.DRAW_BUFFER7,
      MAX_COLOR_ATTACHMENTS: Z.MAX_COLOR_ATTACHMENTS,
      MAX_DRAW_BUFFERS: Z.MAX_DRAW_BUFFERS
    };
  else {
    let J = Z.getExtension("WEBGL_draw_buffers");
    if (J === null)
      return null;
    return {
      drawBuffers: J.drawBuffersWEBGL.bind(J),
      COLOR_ATTACHMENT0: J.COLOR_ATTACHMENT0_WEBGL,
      COLOR_ATTACHMENT1: J.COLOR_ATTACHMENT1_WEBGL,
      COLOR_ATTACHMENT2: J.COLOR_ATTACHMENT2_WEBGL,
      COLOR_ATTACHMENT3: J.COLOR_ATTACHMENT3_WEBGL,
      COLOR_ATTACHMENT4: J.COLOR_ATTACHMENT4_WEBGL,
      COLOR_ATTACHMENT5: J.COLOR_ATTACHMENT5_WEBGL,
      COLOR_ATTACHMENT6: J.COLOR_ATTACHMENT6_WEBGL,
      COLOR_ATTACHMENT7: J.COLOR_ATTACHMENT7_WEBGL,
      DRAW_BUFFER0: J.DRAW_BUFFER0_WEBGL,
      DRAW_BUFFER1: J.DRAW_BUFFER1_WEBGL,
      DRAW_BUFFER2: J.DRAW_BUFFER2_WEBGL,
      DRAW_BUFFER3: J.DRAW_BUFFER3_WEBGL,
      DRAW_BUFFER4: J.DRAW_BUFFER4_WEBGL,
      DRAW_BUFFER5: J.DRAW_BUFFER5_WEBGL,
      DRAW_BUFFER6: J.DRAW_BUFFER6_WEBGL,
      DRAW_BUFFER7: J.DRAW_BUFFER7_WEBGL,
      MAX_COLOR_ATTACHMENTS: J.MAX_COLOR_ATTACHMENTS_WEBGL,
      MAX_DRAW_BUFFERS: J.MAX_DRAW_BUFFERS_WEBGL
    };
  }
}
function vU0(Z) {
  let J = Z.getExtension("OES_draw_buffers_indexed");
  if (J === null)
    return null;
  return {
    enablei: J.enableiOES.bind(J),
    disablei: J.disableiOES.bind(J),
    blendEquationi: J.blendEquationiOES.bind(J),
    blendEquationSeparatei: J.blendEquationSeparateiOES.bind(J),
    blendFunci: J.blendFunciOES.bind(J),
    blendFuncSeparatei: J.blendFuncSeparateiOES.bind(J),
    colorMaski: J.colorMaskiOES.bind(J)
  };
}
function SU0(Z) {
  return _2(Z) ? {} : Z.getExtension("EXT_shader_texture_lod");
}
function fU0(Z) {
  if (_2(Z))
    return {
      UNSIGNED_INT_24_8: Z.UNSIGNED_INT_24_8
    };
  else {
    let J = Z.getExtension("WEBGL_depth_texture");
    if (J === null)
      return null;
    return {
      UNSIGNED_INT_24_8: J.UNSIGNED_INT_24_8_WEBGL
    };
  }
}
function hU0(Z) {
  if (_2(Z))
    return {
      FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING: Z.FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING,
      SRGB8_ALPHA8: Z.SRGB8_ALPHA8,
      SRGB8: Z.SRGB8,
      SRGB: Z.SRGB
    };
  else {
    let J = Z.getExtension("EXT_sRGB");
    if (J === null)
      return null;
    return {
      FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING: J.FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING_EXT,
      SRGB8_ALPHA8: J.SRGB8_ALPHA8_EXT,
      SRGB8: J.SRGB_ALPHA_EXT,
      SRGB: J.SRGB_EXT
    };
  }
}
function bU0(Z) {
  if (_2(Z)) {
    let J = Z.getExtension("EXT_disjoint_timer_query_webgl2") || Z.getExtension("EXT_disjoint_timer_query");
    if (J === null)
      return null;
    return {
      QUERY_COUNTER_BITS: J.QUERY_COUNTER_BITS_EXT,
      CURRENT_QUERY: Z.CURRENT_QUERY,
      QUERY_RESULT: Z.QUERY_RESULT,
      QUERY_RESULT_AVAILABLE: Z.QUERY_RESULT_AVAILABLE,
      TIME_ELAPSED: J.TIME_ELAPSED_EXT,
      TIMESTAMP: J.TIMESTAMP_EXT,
      GPU_DISJOINT: J.GPU_DISJOINT_EXT,
      createQuery: Z.createQuery.bind(Z),
      deleteQuery: Z.deleteQuery.bind(Z),
      isQuery: Z.isQuery.bind(Z),
      beginQuery: Z.beginQuery.bind(Z),
      endQuery: Z.endQuery.bind(Z),
      queryCounter: J.queryCounterEXT.bind(J),
      getQuery: Z.getQuery.bind(Z),
      getQueryParameter: Z.getQueryParameter.bind(Z)
    };
  } else {
    let J = Z.getExtension("EXT_disjoint_timer_query");
    if (J === null)
      return null;
    return {
      QUERY_COUNTER_BITS: J.QUERY_COUNTER_BITS_EXT,
      CURRENT_QUERY: J.CURRENT_QUERY_EXT,
      QUERY_RESULT: J.QUERY_RESULT_EXT,
      QUERY_RESULT_AVAILABLE: J.QUERY_RESULT_AVAILABLE_EXT,
      TIME_ELAPSED: J.TIME_ELAPSED_EXT,
      TIMESTAMP: J.TIMESTAMP_EXT,
      GPU_DISJOINT: J.GPU_DISJOINT_EXT,
      createQuery: J.createQueryEXT.bind(J),
      deleteQuery: J.deleteQueryEXT.bind(J),
      isQuery: J.isQueryEXT.bind(J),
      beginQuery: J.beginQueryEXT.bind(J),
      endQuery: J.endQueryEXT.bind(J),
      queryCounter: J.queryCounterEXT.bind(J),
      getQuery: J.getQueryEXT.bind(J),
      getQueryParameter: J.getQueryObjectEXT.bind(J)
    };
  }
}
function xU0(Z) {
  let J = Z.getExtension("WEBGL_multi_draw");
  if (J)
    return {
      multiDrawArrays: J.multiDrawArraysWEBGL.bind(J),
      multiDrawElements: J.multiDrawElementsWEBGL.bind(J),
      multiDrawArraysInstanced: J.multiDrawArraysInstancedWEBGL.bind(J),
      multiDrawElementsInstanced: J.multiDrawElementsInstancedWEBGL.bind(J)
    };
  else
    return null;
}
function yU0(Z) {
  let J = Z.getExtension("WEBGL_draw_instanced_base_vertex_base_instance");
  if (J)
    return {
      drawArraysInstancedBaseInstance: J.drawArraysInstancedBaseInstanceWEBGL.bind(J),
      drawElementsInstancedBaseVertexBaseInstance: J.drawElementsInstancedBaseVertexBaseInstanceWEBGL.bind(J)
    };
  else
    return null;
}
function gU0(Z) {
  let J = Z.getExtension("WEBGL_multi_draw_instanced_base_vertex_base_instance");
  if (J)
    return {
      multiDrawArraysInstancedBaseInstance: J.multiDrawArraysInstancedBaseInstanceWEBGL.bind(J),
      multiDrawElementsInstancedBaseVertexBaseInstance: J.multiDrawElementsInstancedBaseVertexBaseInstanceWEBGL.bind(J)
    };
  else
    return null;
}
function mU0(Z) {
  let J = Z.getExtension("KHR_parallel_shader_compile");
  if (J === null)
    return null;
  return {
    COMPLETION_STATUS: J.COMPLETION_STATUS_KHR
  };
}
function dU0(Z) {
  return _2(Z) ? {} : Z.getExtension("OES_fbo_render_mipmap");
}
function pU0(Z) {
  if (_2(Z)) {
    let J = Z.getExtension("WEBGL_provoking_vertex");
    if (J)
      return {
        FIRST_VERTEX_CONVENTION: J.FIRST_VERTEX_CONVENTION_WEBGL,
        LAST_VERTEX_CONVENTION: J.LAST_VERTEX_CONVENTION_WEBGL,
        PROVOKING_VERTEX: J.PROVOKING_VERTEX_WEBGL,
        provokingVertex: J.provokingVertexWEBGL.bind(J)
      };
  }
  return null;
}
function uU0(Z) {
  if (_2(Z)) {
    let J = Z.getExtension("WEBGL_clip_cull_distance");
    if (J)
      return {
        MAX_CLIP_DISTANCES: J.MAX_CLIP_DISTANCES_WEBGL,
        MAX_CULL_DISTANCES: J.MAX_CULL_DISTANCES_WEBGL,
        MAX_COMBINED_CLIP_AND_CULL_DISTANCES: J.MAX_COMBINED_CLIP_AND_CULL_DISTANCES_WEBGL,
        CLIP_DISTANCE0: J.CLIP_DISTANCE0_WEBGL,
        CLIP_DISTANCE1: J.CLIP_DISTANCE1_WEBGL,
        CLIP_DISTANCE2: J.CLIP_DISTANCE2_WEBGL,
        CLIP_DISTANCE3: J.CLIP_DISTANCE3_WEBGL,
        CLIP_DISTANCE4: J.CLIP_DISTANCE4_WEBGL,
        CLIP_DISTANCE5: J.CLIP_DISTANCE5_WEBGL,
        CLIP_DISTANCE6: J.CLIP_DISTANCE6_WEBGL,
        CLIP_DISTANCE7: J.CLIP_DISTANCE7_WEBGL
      };
  }
  return null;
}
function cU0(Z) {
  if (_2(Z)) {
    if (Z.getExtension("EXT_conservative_depth"))
      return {};
  }
  return null;
}
function lU0(Z) {
  if (_2(Z)) {
    let J = Z.getExtension("WEBGL_stencil_texturing");
    if (J)
      return {
        DEPTH_STENCIL_TEXTURE_MODE: J.DEPTH_STENCIL_TEXTURE_MODE_WEBGL,
        STENCIL_INDEX: J.STENCIL_INDEX_WEBGL
      };
  }
  return null;
}
function nU0(Z) {
  let J = Z.getExtension("EXT_clip_control");
  if (J)
    return {
      LOWER_LEFT: J.LOWER_LEFT_EXT,
      UPPER_LEFT: J.UPPER_LEFT_EXT,
      NEGATIVE_ONE_TO_ONE: J.NEGATIVE_ONE_TO_ONE_EXT,
      ZERO_TO_ONE: J.ZERO_TO_ONE_EXT,
      CLIP_ORIGIN: J.CLIP_ORIGIN_EXT,
      CLIP_DEPTH_MODE: J.CLIP_DEPTH_MODE_EXT,
      clipControl: J.clipControlEXT.bind(J)
    };
  return null;
}
function iU0(Z) {
  if (_2(Z)) {
    if (Z.getExtension("EXT_render_snorm"))
      return {};
  }
  return null;
}
function oU0(Z) {
  if (_2(Z)) {
    if (Z.getExtension("WEBGL_render_shared_exponent"))
      return {};
  }
  return null;
}
function sU0(Z) {
  let J = Z.getExtension("EXT_texture_norm16");
  if (J)
    return {
      R16: J.R16_EXT,
      RG16: J.RG16_EXT,
      RGB16: J.RGB16_EXT,
      RGBA16: J.RGBA16_EXT,
      R16_SNORM: J.R16_SNORM_EXT,
      RG16_SNORM: J.RG16_SNORM_EXT,
      RGB16_SNORM: J.RGB16_SNORM_EXT,
      RGBA16_SNORM: J.RGBA16_SNORM_EXT
    };
  return null;
}
function aU0(Z) {
  let J = Z.getExtension("EXT_depth_clamp");
  if (J)
    return {
      DEPTH_CLAMP: J.DEPTH_CLAMP_EXT
    };
  return null;
}
function rU0(Z) {
  if (_2(Z)) {
    let J = Z.getExtension("OVR_multiview2");
    if (J)
      return {
        FRAMEBUFFER_ATTACHMENT_TEXTURE_NUM_VIEWS: J.FRAMEBUFFER_ATTACHMENT_TEXTURE_NUM_VIEWS_OVR,
        FRAMEBUFFER_ATTACHMENT_TEXTURE_BASE_VIEW_INDEX: J.FRAMEBUFFER_ATTACHMENT_TEXTURE_BASE_VIEW_INDEX_OVR,
        MAX_VIEWS: J.MAX_VIEWS_OVR,
        FRAMEBUFFER_INCOMPLETE_VIEW_TARGETS: J.FRAMEBUFFER_INCOMPLETE_VIEW_TARGETS_OVR,
        framebufferTextureMultiview: J.framebufferTextureMultiviewOVR.bind(J)
      };
  }
  return null;
}
function tU0(Z) {
  if (!_2(Z))
    return !1;
  if (typeof navigator !== "undefined") {
    let J = window.navigator.userAgent.match(/Firefox\/([0-9]+)\./);
    if (!J)
      return !0;
    return parseInt(J[1]) >= 85;
  }
  return !1;
}
var i91 = `
attribute vec4 aPosition;

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

void main() {
    gl_FragColor = texture2D(uTexture, vec2(0.5, 0.5)) * uColor;
}`, s91 = new Float32Array([
  -1,
  -1,
  1,
  -1,
  -1,
  1,
  -1,
  1,
  1,
  -1,
  1,
  1
]);
function dR0(Z, J) {
  let $ = NV(Z, { type: "vert", source: i91 }), X = NV(Z, { type: "frag", source: o91 });
  if (!$ || !X)
    return !1;
  let Y = wh(Z);
  Z.attachShader(Y, $), Z.attachShader(Y, X), Z.linkProgram(Y), Z.useProgram(Y);
  let Q = Z.getAttribLocation(Y, "aPosition"), W = Z.getUniformLocation(Y, "uColor");
  if (!W) {
    if (y2)
      console.log("error getting 'uColor' uniform location");
    return !1;
  }
  let K = Z.createBuffer();
  Z.bindBuffer(Z.ARRAY_BUFFER, K), Z.bufferData(Z.ARRAY_BUFFER, s91, Z.STATIC_DRAW), Z.enableVertexAttribArray(Q), Z.vertexAttribPointer(Q, 2, Z.FLOAT, !1, 0, 0);
  let G = Z.createTexture(), H = new Uint8Array([255, 255, 255, 255]);
  Z.bindTexture(Z.TEXTURE_2D, G), Z.texImage2D(Z.TEXTURE_2D, 0, Z.RGBA, 1, 1, 0, Z.RGBA, Z.UNSIGNED_BYTE, H);
  let N = Z.createTexture();
  Z.bindTexture(Z.TEXTURE_2D, N), Z.texImage2D(Z.TEXTURE_2D, 0, Z.RGBA, 1, 1, 0, Z.RGBA, J, null), Z.texParameteri(Z.TEXTURE_2D, Z.TEXTURE_MIN_FILTER, Z.NEAREST), Z.texParameteri(Z.TEXTURE_2D, Z.TEXTURE_MAG_FILTER, Z.NEAREST);
  let q = Z.createFramebuffer();
  if (Z.bindFramebuffer(Z.FRAMEBUFFER, q), Z.framebufferTexture2D(Z.FRAMEBUFFER, Z.COLOR_ATTACHMENT0, Z.TEXTURE_2D, N, 0), Z.checkFramebufferStatus(Z.FRAMEBUFFER) !== Z.FRAMEBUFFER_COMPLETE) {
    if (y2)
      console.log(`error creating framebuffer for '${J}'`);
    return !1;
  }
  Z.bindTexture(Z.TEXTURE_2D, G), Z.uniform4fv(W, [0, 10, 20, 1]), Z.drawArrays(Z.TRIANGLES, 0, 6), Z.bindTexture(Z.TEXTURE_2D, N), Z.bindFramebuffer(Z.FRAMEBUFFER, null), Z.clearColor(1, 0, 0, 1), Z.clear(Z.COLOR_BUFFER_BIT), Z.uniform4fv(W, [0, 0.1, 0.05, 1]), Z.drawArrays(Z.TRIANGLES, 0, 6);
  let F = new Uint8Array(4);
  if (Z.readPixels(0, 0, 1, 1, Z.RGBA, Z.UNSIGNED_BYTE, F), F[0] !== 0 || F[1] < 248 || F[2] < 248 || F[3] < 254) {
    if (y2)
      console.log(`not able to actually render to '${J}' texture`);
    return !1;
  }
  if (J === Z.FLOAT) {
    Z.bindFramebuffer(Z.FRAMEBUFFER, q);
    let E = new Float32Array(4);
    Z.readPixels(0, 0, 1, 1, Z.RGBA, Z.FLOAT, E);
    let R = Z.getError();
    if (R) {
      if (y2)
        console.log(`error reading float pixels: '${Za(Z, R)}'`);
      return !1;
    }
  }
  return !0;
}

// node_modules/molstar/lib/mol-gl/webgl/texture.js
var $a = $7();
function a91(Z, J) {
  switch (J) {
    case "image-uint8":
      return Z.TEXTURE_2D;
    case "image-float32":
      return Z.TEXTURE_2D;
    case "image-float16":
      return Z.TEXTURE_2D;
    case "image-depth":
      return Z.TEXTURE_2D;
  }
  if (_2(Z))
    switch (J) {
      case "image-int32":
        return Z.TEXTURE_2D;
      case "volume-uint8":
        return Z.TEXTURE_3D;
      case "volume-float32":
        return Z.TEXTURE_3D;
      case "volume-float16":
        return Z.TEXTURE_3D;
    }
  throw new Error(`unknown texture kind '${J}'`);
}
function Bh(Z, J, $) {
  switch (J) {
    case "alpha":
      if (_2(Z) && ($ === "float" || $ === "fp16"))
        return Z.RED;
      else if (_2(Z) && $ === "int")
        return Z.RED_INTEGER;
      else
        return Z.ALPHA;
    case "rgb":
      if (_2(Z) && $ === "int")
        return Z.RGB_INTEGER;
      return Z.RGB;
    case "rg":
      if (_2(Z) && ($ === "float" || $ === "fp16"))
        return Z.RG;
      else if (_2(Z) && $ === "int")
        return Z.RG_INTEGER;
      else
        throw new Error('texture format "rg" requires webgl2 and type "float" or int"');
    case "rgba":
      if (_2(Z) && $ === "int")
        return Z.RGBA_INTEGER;
      return Z.RGBA;
    case "depth":
      return Z.DEPTH_COMPONENT;
  }
}
function r91(Z, J, $) {
  if (_2(Z))
    switch (J) {
      case "alpha":
        switch ($) {
          case "ubyte":
            return Z.ALPHA;
          case "float":
            return Z.R32F;
          case "fp16":
            return Z.R16F;
          case "int":
            return Z.R32I;
        }
      case "rg":
        switch ($) {
          case "ubyte":
            return Z.RG;
          case "float":
            return Z.RG32F;
          case "fp16":
            return Z.RG16F;
          case "int":
            return Z.RG32I;
        }
      case "rgb":
        switch ($) {
          case "ubyte":
            return Z.RGB;
          case "float":
            return Z.RGB32F;
          case "fp16":
            return Z.RGB16F;
          case "int":
            return Z.RGB32I;
        }
      case "rgba":
        switch ($) {
          case "ubyte":
            return Z.RGBA;
          case "float":
            return Z.RGBA32F;
          case "fp16":
            return Z.RGBA16F;
          case "int":
            return Z.RGBA32I;
        }
      case "depth":
        switch ($) {
          case "ushort":
            return Z.DEPTH_COMPONENT16;
          case "float":
            return Z.DEPTH_COMPONENT32F;
        }
    }
  return Bh(Z, J, $);
}
function lR0(Z, J, $, X, Y) {
  return ss(Z, J) * $ * X * (Y || 1);
}
function ss(Z, J) {
  return t91(Z) * e91(J);
}
function t91(Z) {
  switch (Z) {
    case "alpha":
      return 1;
    case "rg":
      return 2;
    case "rgb":
      return 3;
    case "rgba":
      return 4;
    case "depth":
      return 4;
  }
}
function e91(Z) {
  switch (Z) {
    case "ubyte":
      return 1;
    case "ushort":
      return 2;
    case "float":
      return 4;
    case "fp16":
      return 2;
    case "int":
      return 4;
  }
}
function as(Z, J, $) {
  switch ($) {
    case "ubyte":
      return Z.UNSIGNED_BYTE;
    case "ushort":
      return Z.UNSIGNED_SHORT;
    case "float":
      return Z.FLOAT;
    case "fp16":
      if (J.textureHalfFloat)
        return J.textureHalfFloat.HALF_FLOAT;
      else
        throw new Error('extension "texture_half_float" unavailable');
    case "int":
      if (_2(Z))
        return Z.INT;
      else
        throw new Error('texture type "int" requires webgl2');
  }
}
function pR0(Z, J) {
  switch (J) {
    case "nearest":
      return Z.NEAREST;
    case "linear":
      return Z.LINEAR;
  }
}
function Th(Z, J, $) {
  switch ($) {
    case "depth":
      return Z.DEPTH_ATTACHMENT;
    case "stencil":
      return Z.STENCIL_ATTACHMENT;
    case "color0":
    case 0:
      return Z.COLOR_ATTACHMENT0;
  }
  if (J.drawBuffers)
    switch ($) {
      case "color1":
      case 1:
        return J.drawBuffers.COLOR_ATTACHMENT1;
      case "color2":
      case 2:
        return J.drawBuffers.COLOR_ATTACHMENT2;
      case "color3":
      case 3:
        return J.drawBuffers.COLOR_ATTACHMENT3;
      case "color4":
      case 4:
        return J.drawBuffers.COLOR_ATTACHMENT4;
      case "color5":
      case 5:
        return J.drawBuffers.COLOR_ATTACHMENT5;
      case "color6":
      case 6:
        return J.drawBuffers.COLOR_ATTACHMENT6;
      case "color7":
      case 7:
        return J.drawBuffers.COLOR_ATTACHMENT7;
    }
  throw new Error("unknown texture attachment");
}
function uR0(Z) {
  return typeof HTMLImageElement !== "undefined" && Z instanceof HTMLImageElement;
}
function Z71(Z, J, $) {
  return J === $.TEXTURE_2D;
}
function cR0(Z, J, $) {
  return J === $.TEXTURE_3D;
}
function Ja(Z) {
  let J = Z.createTexture();
  if (J === null)
    throw new Error("Could not create WebGL texture");
  return J;
}
function PR0(Z, J, $, X, Y, Q) {
  let W = $a(), K = Ja(Z);
  if ($.endsWith("float32") && Y !== "float" || $.endsWith("float16") && Y !== "fp16" || $.endsWith("uint8") && Y !== "ubyte" || $.endsWith("int32") && Y !== "int" || $.endsWith("depth") && Y !== "ushort" && Y !== "float")
    throw new Error(`texture kind '${$}' and type '${Y}' are incompatible`);
  if (!J.depthTexture && X === "depth")
    throw new Error("extension 'WEBGL_depth_texture' needed for 'depth' texture format");
  let G = a91(Z, $), H = pR0(Z, Q), N = Bh(Z, X, Y), q = r91(Z, X, Y), U = as(Z, J, Y);
  function F() {
    Z.bindTexture(G, K), Z.texParameteri(G, Z.TEXTURE_MAG_FILTER, H), Z.texParameteri(G, Z.TEXTURE_MIN_FILTER, H), Z.texParameteri(G, Z.TEXTURE_WRAP_S, Z.CLAMP_TO_EDGE), Z.texParameteri(G, Z.TEXTURE_WRAP_T, Z.CLAMP_TO_EDGE), Z.bindTexture(G, null);
  }
  F();
  let E = 0, R = 0, z = 0, D, A = !1, B = !1;
  function T(I, S, f) {
    if (I === 0 || S === 0 || _2(Z) && G === Z.TEXTURE_3D && f === 0)
      throw new Error("empty textures are not allowed");
    if (E === I && R === S && z === (f || 0))
      return;
    if (E = I, R = S, z = f || 0, Z.bindTexture(G, K), G === Z.TEXTURE_2D)
      Z.texImage2D(G, 0, q, E, R, 0, N, U, null);
    else if (_2(Z) && G === Z.TEXTURE_3D && z !== void 0)
      Z.texImage3D(G, 0, q, E, R, z, 0, N, U, null);
    else
      throw new Error("unknown texture target");
  }
  T(1, 1, _2(Z) && G === Z.TEXTURE_3D ? 1 : 0);
  function w(I, S = !1) {
    if (I.width === 0 || I.height === 0 || !uR0(I) && _2(Z) && cR0(I, G, Z) && I.depth === 0)
      throw new Error("empty textures are not allowed");
    if (Z.bindTexture(G, K), Z.pixelStorei(Z.UNPACK_ALIGNMENT, 1), Z.pixelStorei(Z.UNPACK_COLORSPACE_CONVERSION_WEBGL, Z.NONE), Z.pixelStorei(Z.UNPACK_PREMULTIPLY_ALPHA_WEBGL, 0), uR0(I))
      E = I.width, R = I.height, Z.pixelStorei(Z.UNPACK_FLIP_Y_WEBGL, !1), Z.bindTexture(Z.TEXTURE_2D, K), Z.texImage2D(Z.TEXTURE_2D, 0, q, N, U, I);
    else if (Z71(I, G, Z)) {
      let f = I.filter ? pR0(Z, I.filter) : H;
      if (Z.texParameteri(G, Z.TEXTURE_MAG_FILTER, f), Z.texParameteri(G, Z.TEXTURE_MIN_FILTER, f), Z.pixelStorei(Z.UNPACK_FLIP_Y_WEBGL, !!I.flipY), S)
        Z.texSubImage2D(G, 0, 0, 0, I.width, I.height, N, U, I.array);
      else
        E = I.width, R = I.height, Z.texImage2D(G, 0, q, E, R, 0, N, U, I.array);
    } else if (_2(Z) && cR0(I, G, Z))
      if (Z.pixelStorei(Z.UNPACK_FLIP_Y_WEBGL, !1), S)
        Z.texSubImage3D(G, 0, 0, 0, 0, I.width, I.height, I.depth, N, U, I.array);
      else
        E = I.width, R = I.height, z = I.depth, Z.texImage3D(G, 0, q, E, R, z, 0, N, U, I.array);
    else
      throw new Error("unknown texture target");
    Z.bindTexture(G, null), D = I;
  }
  function V() {
    if (G !== Z.TEXTURE_2D)
      throw new Error("mipmap only supported for 2d textures");
    if (_2(Z) || nL(E) && nL(R))
      Z.bindTexture(G, K), Z.texParameteri(G, Z.TEXTURE_MIN_FILTER, Z.LINEAR_MIPMAP_LINEAR), Z.generateMipmap(G), Z.bindTexture(G, null), A = !0;
    else
      throw new Error("mipmap unsupported for non-power-of-two textures and webgl1");
  }
  function P(I, S, f) {
    if (I.bind(), G === Z.TEXTURE_2D)
      Z.framebufferTexture2D(Z.FRAMEBUFFER, Th(Z, J, S), Z.TEXTURE_2D, K, 0);
    else if (_2(Z) && G === Z.TEXTURE_3D) {
      if (f === void 0)
        throw new Error("need `layer` to attach 3D texture");
      Z.framebufferTextureLayer(Z.FRAMEBUFFER, Th(Z, J, S), K, 0, f);
    } else
      throw new Error("unknown/unsupported texture target");
  }
  return {
    id: W,
    target: G,
    format: N,
    internalFormat: q,
    type: U,
    filter: H,
    getWidth: () => E,
    getHeight: () => R,
    getDepth: () => z,
    getByteCount: () => lR0(X, Y, E, R, z),
    define: T,
    load: w,
    mipmap: V,
    bind: (I) => {
      Z.activeTexture(Z.TEXTURE0 + I), Z.bindTexture(G, K);
    },
    unbind: (I) => {
      Z.activeTexture(Z.TEXTURE0 + I), Z.bindTexture(G, null);
    },
    attachFramebuffer: P,
    detachFramebuffer: (I, S) => {
      if (I.bind(), G === Z.TEXTURE_2D)
        Z.framebufferTexture2D(Z.FRAMEBUFFER, Th(Z, J, S), Z.TEXTURE_2D, null, 0);
      else if (_2(Z) && G === Z.TEXTURE_3D)
        Z.framebufferTextureLayer(Z.FRAMEBUFFER, Th(Z, J, S), null, 0, 0);
      else
        throw new Error("unknown texture target");
    },
    reset: () => {
      K = Ja(Z), F();
      let [I, S, f] = [E, R, z];
      if (E = 0, R = 0, z = 0, T(I, S, f), D)
        w(D);
      if (A)
        V();
    },
    destroy: () => {
      if (B)
        return;
      Z.deleteTexture(K), B = !0;
    }
  };
}
function Xa(Z, J, $) {
  let { resources: X } = Z, Y = [];
  return Object.keys(J).forEach((Q) => {
    let W = J[Q];
    if (W.type === "texture") {
      let K = $[Q];
      if (K)
        if (W.kind === "texture")
          Y[Y.length] = [Q, K.ref.value];
        else {
          let G = X.texture(W.kind, W.format, W.dataType, W.filter);
          G.load(K.ref.value), Y[Y.length] = [Q, G];
        }
    }
  }), Y;
}
function Ya(Z, J, $) {
  let X = new Image;
  X.onload = function() {
    $.load(X), C.update(J, $);
  }, X.src = Z;
}
function J71(Z, J) {
  switch (J) {
    case "nx":
      return Z.TEXTURE_CUBE_MAP_NEGATIVE_X;
    case "ny":
      return Z.TEXTURE_CUBE_MAP_NEGATIVE_Y;
    case "nz":
      return Z.TEXTURE_CUBE_MAP_NEGATIVE_Z;
    case "px":
      return Z.TEXTURE_CUBE_MAP_POSITIVE_X;
    case "py":
      return Z.TEXTURE_CUBE_MAP_POSITIVE_Y;
    case "pz":
      return Z.TEXTURE_CUBE_MAP_POSITIVE_Z;
  }
}
function CR0(Z, J, $, X) {
  let { TEXTURE_CUBE_MAP: Y, LINEAR: Q, RGBA: W, RGBA: K, UNSIGNED_BYTE: G } = Z, H = 0, N = Z.createTexture();
  Z.bindTexture(Y, N);
  function q(R, z, D, A) {
    if (H === 0)
      H = D.width;
    if (Z.bindTexture(Y, N), Z.texImage2D(R, z, W, H, H, 0, K, G, null), Z.pixelStorei(Z.UNPACK_ALIGNMENT, 4), Z.pixelStorei(Z.UNPACK_COLORSPACE_CONVERSION_WEBGL, Z.NONE), Z.pixelStorei(Z.UNPACK_PREMULTIPLY_ALPHA_WEBGL, 0), Z.pixelStorei(Z.UNPACK_FLIP_Y_WEBGL, !1), Z.bindTexture(Y, N), Z.texImage2D(R, z, W, K, G, D), F += 1, F === 6) {
      if (!E) {
        if ($)
          Z.texParameteri(Y, Z.TEXTURE_MIN_FILTER, Z.LINEAR_MIPMAP_LINEAR), Z.generateMipmap(Y);
        else
          Z.texParameteri(Y, Z.TEXTURE_MIN_FILTER, Q);
        Z.texParameteri(Y, Z.TEXTURE_MAG_FILTER, Q);
      }
      if (!A)
        X === null || X === void 0 || X(E);
    }
  }
  let U = [], F = 0;
  B7(J, (R, z) => {
    if (!R)
      return;
    let D = 0, A = J71(Z, z), B = new Image;
    if (R instanceof File)
      B.src = URL.createObjectURL(R);
    else if (lL(R))
      R.then((T) => {
        B.src = URL.createObjectURL(T);
      });
    else
      B.src = R;
    U.push({ cubeTarget: A, level: D, image: B }), B.addEventListener("load", () => {
      q(A, D, B, !1);
    }), B.addEventListener("error", () => {
      X === null || X === void 0 || X(!0);
    });
  });
  let E = !1;
  return {
    id: $a(),
    target: Y,
    format: K,
    internalFormat: W,
    type: G,
    filter: Q,
    getWidth: () => H,
    getHeight: () => H,
    getDepth: () => 0,
    getByteCount: () => {
      return lR0("rgba", "ubyte", H, H, 0) * 6 * ($ ? 2 : 1);
    },
    define: () => {},
    load: () => {},
    mipmap: () => {},
    bind: (R) => {
      Z.activeTexture(Z.TEXTURE0 + R), Z.bindTexture(Y, N);
    },
    unbind: (R) => {
      Z.activeTexture(Z.TEXTURE0 + R), Z.bindTexture(Y, null);
    },
    attachFramebuffer: () => {},
    detachFramebuffer: () => {},
    reset: () => {
      N = Ja(Z), Z.bindTexture(Y, N), F = 0;
      for (let { cubeTarget: R, level: z, image: D } of U)
        q(R, z, D, !0);
    },
    destroy: () => {
      if (E)
        return;
      Z.deleteTexture(N), E = !0;
    }
  };
}
var nR0 = -1;
function iR0(Z) {
  return Z.format === nR0;
}
function k9(Z) {
  var J;
  let $ = (J = Z === null || Z === void 0 ? void 0 : Z.TEXTURE_2D) !== null && J !== void 0 ? J : 3553;
  return {
    id: $a(),
    target: $,
    format: nR0,
    internalFormat: 0,
    type: 0,
    filter: 0,
    getWidth: () => 0,
    getHeight: () => 0,
    getDepth: () => 0,
    getByteCount: () => 0,
    define: () => {},
    load: () => {},
    mipmap: () => {},
    bind: (X) => {
      if (Z)
        Z.activeTexture(Z.TEXTURE0 + X), Z.bindTexture($, null);
    },
    unbind: (X) => {
      if (Z)
        Z.activeTexture(Z.TEXTURE0 + X), Z.bindTexture($, null);
    },
    attachFramebuffer: () => {
      throw new Error("cannot attach null-texture to a framebuffer");
    },
    detachFramebuffer: () => {
      throw new Error("cannot detach null-texture from a framebuffer");
    },
    reset: () => {},
    destroy: () => {}
  };
}

// node_modules/molstar/lib/mol-geo/geometry/color-data.js
function WJ(Z, J, $, X) {
  var Y;
  let Q = $71(Z, J, $, X);
  if ($.palette) {
    C.updateIfChanged(Q.dUsePalette, !0);
    let [W, K] = $.palette.domain || [0, 1];
    C.update(Q.uPaletteDomain, h0.set(Q.uPaletteDomain.ref.value, W, K)), C.update(Q.uPaletteDefault, i0.toVec3Normalized(Q.uPaletteDefault.ref.value, (Y = $.palette.defaultColor) !== null && Y !== void 0 ? Y : i0(13421772))), X71($.palette, Q.tPalette);
  } else
    C.updateIfChanged(Q.dUsePalette, !1);
  return Q;
}
function $71(Z, J, $, X) {
  switch ($.granularity) {
    case "uniform":
      return Q71(Z, $.color, X);
    case "instance":
      return Z.nonInstanceable ? oR0(Z, $.color, X) : W71(Z, $.color, X);
    case "group":
      return oR0(Z, $.color, X);
    case "groupInstance":
      return K71(Z, $.color, X);
    case "vertex":
      return G71(J, $.color, X);
    case "vertexInstance":
      return H71(J, $.color, X);
    case "volume":
      return sR0($.grid, "volume", X);
    case "volumeInstance":
      return sR0($.grid, "volumeInstance", X);
    case "direct":
      return N71(X);
  }
}
function X71(Z, J) {
  let $ = !0, X = J.ref.value;
  if (Z.colors.length !== X.width || X.filter !== Z.filter)
    $ = !1;
  else {
    let W = X.array, K = 0;
    for (let G of Z.colors) {
      let [H, N, q] = i0.toRgb(G);
      if (W[K++] !== H || W[K++] !== N || W[K++] !== q) {
        $ = !1;
        break;
      }
    }
  }
  if ($)
    return;
  let Y = new Uint8Array(Z.colors.length * 3), Q = 0;
  for (let W of Z.colors) {
    let [K, G, H] = i0.toRgb(W);
    Y[Q++] = K, Y[Q++] = G, Y[Q++] = H;
  }
  C.update(J, { array: Y, height: 1, width: Z.colors.length, filter: Z.filter });
}
function Y71(Z, J) {
  if (J)
    return C.update(J.uColor, i0.toVec3Normalized(J.uColor.ref.value, Z)), C.updateIfChanged(J.dColorType, "uniform"), J;
  else
    return {
      uColor: C.create(i0.toVec3Normalized(M(), Z)),
      tColor: C.create({ array: new Uint8Array(3), width: 1, height: 1 }),
      tColorGrid: C.create(k9()),
      uPaletteDomain: C.create(h0.create(0, 1)),
      uPaletteDefault: C.create(M()),
      tPalette: C.create({ array: new Uint8Array(3), width: 1, height: 1 }),
      uColorTexDim: C.create(h0.create(1, 1)),
      uColorGridDim: C.create(M.create(1, 1, 1)),
      uColorGridTransform: C.create(E2.create(0, 0, 0, 1)),
      dColorType: C.create("uniform"),
      dUsePalette: C.create(!1)
    };
}
function Q71(Z, J, $) {
  Z.reset();
  let X = Z.hasNext ? Z.move() : { location: qQ, isSecondary: !1 };
  return Y71(J(X.location, X.isSecondary), $);
}
function FV(Z, J, $) {
  if ($)
    return C.update($.tColor, Z), C.update($.uColorTexDim, h0.create(Z.width, Z.height)), C.updateIfChanged($.dColorType, J), $;
  else
    return {
      uColor: C.create(M()),
      tColor: C.create(Z),
      tColorGrid: C.create(k9()),
      uPaletteDomain: C.create(h0.create(0, 1)),
      uPaletteDefault: C.create(M()),
      tPalette: C.create({ array: new Uint8Array(3), width: 1, height: 1 }),
      uColorTexDim: C.create(h0.create(Z.width, Z.height)),
      uColorGridDim: C.create(M.create(1, 1, 1)),
      uColorGridTransform: C.create(E2.create(0, 0, 0, 1)),
      dColorType: C.create(J),
      dUsePalette: C.create(!1)
    };
}
function W71(Z, J, $) {
  let { instanceCount: X } = Z, Y = Z9(Math.max(1, X), 3, Uint8Array, $ && $.tColor.ref.value.array);
  Z.reset();
  while (Z.hasNext) {
    let { location: Q, isSecondary: W, instanceIndex: K } = Z.move();
    i0.toArray(J(Q, W), Y.array, K * 3), Z.skipInstance();
  }
  return FV(Y, "instance", $);
}
function oR0(Z, J, $) {
  let { groupCount: X, hasLocation2: Y } = Z, Q = Z9(Math.max(1, X * (Y ? 2 : 1)), 3, Uint8Array, $ && $.tColor.ref.value.array);
  Z.reset();
  let W = Y ? 6 : 3;
  while (Z.hasNext && !Z.isNextNewInstance) {
    let { location: K, location2: G, isSecondary: H, groupIndex: N } = Z.move();
    if (i0.toArray(J(K, H), Q.array, N * W), Y)
      i0.toArray(J(G, H), Q.array, N * W + 3);
  }
  return FV(Q, "group", $);
}
function K71(Z, J, $) {
  let { groupCount: X, instanceCount: Y, hasLocation2: Q } = Z, W = Y * X * (Q ? 2 : 1), K = Z9(Math.max(1, W), 3, Uint8Array, $ && $.tColor.ref.value.array);
  Z.reset();
  let G = Q ? 6 : 3;
  while (Z.hasNext) {
    let { location: H, location2: N, isSecondary: q, index: U } = Z.move();
    if (i0.toArray(J(H, q), K.array, U * G), Q)
      i0.toArray(J(N, q), K.array, U * G + 3);
  }
  return FV(K, "groupInstance", $);
}
function G71(Z, J, $) {
  let { groupCount: X, stride: Y } = Z, Q = Z9(Math.max(1, X), 3, Uint8Array, $ && $.tColor.ref.value.array);
  Z.reset(), Z.voidInstances();
  while (Z.hasNext && !Z.isNextNewInstance) {
    let { location: W, isSecondary: K, groupIndex: G } = Z.move(), H = J(W, K);
    for (let N = 0;N < Y; ++N)
      i0.toArray(H, Q.array, (G + N) * 3);
  }
  return FV(Q, "vertex", $);
}
function H71(Z, J, $) {
  let { groupCount: X, instanceCount: Y, stride: Q } = Z, W = Y * X, K = Z9(Math.max(1, W), 3, Uint8Array, $ && $.tColor.ref.value.array);
  Z.reset();
  while (Z.hasNext) {
    let { location: G, isSecondary: H, index: N } = Z.move(), q = J(G, H);
    for (let U = 0;U < Q; ++U)
      i0.toArray(q, K.array, (N + U) * 3);
  }
  return FV(K, "vertexInstance", $);
}
function sR0(Z, J, $) {
  let { colors: X, dimension: Y, transform: Q } = Z, W = X.getWidth(), K = X.getHeight();
  if ($)
    return C.update($.tColorGrid, X), C.update($.uColorTexDim, h0.create(W, K)), C.update($.uColorGridDim, M.clone(Y)), C.update($.uColorGridTransform, E2.clone(Q)), C.updateIfChanged($.dColorType, J), $;
  else
    return {
      uColor: C.create(M()),
      tColor: C.create({ array: new Uint8Array(3), width: 1, height: 1 }),
      tColorGrid: C.create(X),
      uPaletteDomain: C.create(h0.create(0, 1)),
      uPaletteDefault: C.create(M()),
      tPalette: C.create({ array: new Uint8Array(3), width: 1, height: 1 }),
      uColorTexDim: C.create(h0.create(W, K)),
      uColorGridDim: C.create(M.clone(Y)),
      uColorGridTransform: C.create(E2.clone(Q)),
      dColorType: C.create(J),
      dUsePalette: C.create(!1)
    };
}
function N71(Z) {
  if (Z)
    return C.updateIfChanged(Z.dColorType, "direct"), Z;
  else
    return {
      uColor: C.create(M()),
      tColor: C.create({ array: new Uint8Array(3), width: 1, height: 1 }),
      tColorGrid: C.create(k9()),
      uPaletteDomain: C.create(h0.create(0, 1)),
      uPaletteDefault: C.create(M()),
      tPalette: C.create({ array: new Uint8Array(3), width: 1, height: 1 }),
      uColorTexDim: C.create(h0.create(1, 1)),
      uColorGridDim: C.create(M.create(1, 1, 1)),
      uColorGridTransform: C.create(E2.create(0, 0, 0, 1)),
      dColorType: C.create("direct"),
      dUsePalette: C.create(!1)
    };
}

// node_modules/molstar/lib/mol-math/geometry/instance-grid.js
var Qa = M.transformMat4Offset, q71 = M.fromArray, _h = t1.add;
function aR0() {
  return {
    cellSize: 0,
    cellCount: 0,
    cellOffsets: new Uint32Array,
    cellSpheres: new Float32Array,
    cellTransform: new Float32Array,
    cellInstance: new Float32Array,
    batchSize: 0,
    batchCount: 0,
    batchOffsets: new Uint32Array,
    batchSpheres: new Float32Array,
    batchCell: new Uint32Array
  };
}
function rR0(Z, J, $) {
  let X = F71(Z, J), Y = U71(X, $), Q = new Uint32Array(X.cellOffsets.length), W = new Float32Array(X.cellSpheres.length), K = new Float32Array(X.cellInstance.length), G = 0;
  for (let N = 0, q = Y.batchCell.length;N < q; ++N) {
    let U = Y.batchCell[N], F = X.cellOffsets[U], R = X.cellOffsets[U + 1] - F;
    Q[N + 1] = Q[N] + R;
    for (let z = 0;z < 4; ++z)
      W[N * 4 + z] = X.cellSpheres[U * 4 + z];
    for (let z = 0;z < R; ++z) {
      let D = F + z, A = X.cellInstance[D];
      for (let B = 0;B < 16; ++B)
        X.cellTransform[G * 16 + B] = Z.transform[A * 16 + B];
      K[G] = A, G += 1;
    }
  }
  return {
    cellSize: X.cellSize,
    cellCount: X.cellCount,
    cellOffsets: Q,
    cellSpheres: W,
    cellTransform: X.cellTransform,
    cellInstance: K,
    batchSize: Y.batchSize,
    batchCount: Y.batchCount,
    batchOffsets: Y.batchOffsets,
    batchSpheres: Y.batchSpheres,
    batchCell: uJ(Y.batchCell)
  };
}
function F71(Z, J) {
  let { instanceCount: $, instance: X, transform: Y, invariantBoundingSphere: Q } = Z, W = new Float32Array($), K = new Float32Array($), G = new Float32Array($), H = f0.ofBounds(0, $), N = t1.setEmpty(t1()), { center: q, radius: U } = Q, F = M.create(U, U, U), E = M();
  for (let x = 0;x < $; ++x)
    Qa(E, q, Y, 0, 0, x * 16), W[x] = E[0], K[x] = E[1], G[x] = E[2], _h(N, E);
  t1.expand(N, N, F);
  let R = { x: W, y: K, z: G, indices: H }, z = { box: N, sphere: C0.fromBox3D(C0(), N) }, D = TW(R, z, M.create(J, J, J)), { array: A, offset: B, count: T } = D.buckets, w = B.length, V = new Uint32Array(w + 1), P = new Float32Array(w * 4), I = new Float32Array($ * 16), S = new Float32Array($), f = t1(), v = C0(), h = 0;
  for (let x = 0;x < w; ++x) {
    let b = B[x], g = T[x];
    V[x] = b;
    let m = h;
    for (let i = b, r = b + g;i < r; ++i) {
      let Y0 = A[i];
      S[h] = X[Y0];
      for (let c = 0;c < 16; ++c)
        I[h * 16 + c] = Y[Y0 * 16 + c];
      h += 1;
    }
    if (g === 1)
      Qa(P, q, I, x * 4, 0, m * 16), P[x * 4 + 3] = U;
    else {
      t1.setEmpty(f);
      let i = m * 16;
      for (let r = 0;r < g; ++r)
        Qa(E, q, I, 0, 0, r * 16 + i), _h(f, E);
      t1.expand(f, f, F), C0.fromBox3D(v, f), C0.toArray(v, P, x * 4);
    }
  }
  return V[w] = B[w - 1] + T[w - 1], {
    cellSize: J,
    cellCount: w,
    cellOffsets: V,
    cellSpheres: P,
    cellTransform: I,
    cellInstance: S
  };
}
function U71(Z, J) {
  let { cellCount: $, cellSpheres: X } = Z, Y = new Float32Array($), Q = new Float32Array($), W = new Float32Array($), K = f0.ofBounds(0, $), G = t1.setEmpty(t1()), H = M(), N = 0;
  for (let S = 0;S < $; ++S) {
    let f = S * 4;
    q71(H, X, f), Y[S] = H[0], Q[S] = H[1], W[S] = H[2], _h(G, H), N = Math.max(N, X[f + 3]);
  }
  let q = M.create(N, N, N);
  t1.expand(G, G, q);
  let U = { x: Y, y: Q, z: W, indices: K }, F = { box: G, sphere: C0.fromBox3D(C0(), G) }, E = TW(U, F, M.create(J, J, J)), { array: R, offset: z, count: D } = E.buckets, A = z.length, B = new Uint32Array(A + 1), T = new Float32Array(A * 4), w = new Uint32Array($), V = t1(), P = C0(), I = 0;
  for (let S = 0;S < A; ++S) {
    let f = z[S], v = D[S];
    B[S] = f;
    for (let h = f, x = f + v;h < x; ++h)
      w[I] = R[h], I += 1;
    if (v === 1) {
      let h = R[f];
      T[S * 4] = X[h * 4], T[S * 4 + 1] = X[h * 4 + 1], T[S * 4 + 2] = X[h * 4 + 2], T[S * 4 + 3] = X[h * 4 + 3];
    } else {
      t1.setEmpty(V), N = 0;
      for (let h = f, x = f + v;h < x; ++h) {
        let b = R[h];
        H[0] = X[b * 4], H[1] = X[b * 4 + 1], H[2] = X[b * 4 + 2], _h(V, H), N = Math.max(N, X[b * 4 + 3]);
      }
      M.set(q, N, N, N), t1.expand(V, V, q), C0.fromBox3D(P, V), C0.toArray(P, T, S * 4);
    }
  }
  return B[A] = z[A - 1] + D[A - 1], {
    batchSize: J,
    batchCount: A,
    batchOffsets: B,
    batchSpheres: T,
    batchCell: w
  };
}

// node_modules/molstar/lib/mol-geo/geometry/transform-data.js
var tR0 = h2(), L71 = e();
function R71(Z, J) {
  for (let $ = 0;$ < J; $++)
    if (h2.fromMat4(tR0, e.fromArray(L71, Z, $ * 16)), h2.determinant(tR0) < 0)
      return !0;
  return !1;
}
function zz(Z, J, $, X, Y, Q) {
  let W = R71(Z, J);
  if (Q) {
    C.update(Q.matrix, Q.matrix.ref.value);
    let K = Q.transform.ref.value.length >= J * 16 ? Q.transform.ref.value : new Float32Array(J * 16);
    K.set(Z), C.update(Q.transform, K), C.updateIfChanged(Q.uInstanceCount, J), C.updateIfChanged(Q.instanceCount, J);
    let G = Q.aTransform.ref.value.length >= J * 16 ? Q.aTransform.ref.value : new Float32Array(J * 16);
    C.update(Q.aTransform, G);
    let H = Q.extraTransform.ref.value.length >= J * 16 ? Q.extraTransform.ref.value : new Float32Array(J * 16);
    C.update(Q.extraTransform, LA(H, J));
    let N = Q.aInstance.ref.value.length >= J ? Q.aInstance.ref.value : new Float32Array(J);
    C.update(Q.aInstance, uJ(N, J)), C.update(Q.hasReflection, W);
  } else
    Q = {
      aTransform: C.create(new Float32Array(J * 16)),
      matrix: C.create(e.identity()),
      transform: C.create(new Float32Array(Z)),
      extraTransform: C.create(LA(new Float32Array(J * 16), J)),
      uInstanceCount: C.create(J),
      instanceCount: C.create(J),
      aInstance: C.create(uJ(new Float32Array(J))),
      hasReflection: C.create(W),
      instanceGrid: C.create(aR0())
    };
  return Ka(Q, $, X, Y), Q;
}
var Wa = new Float32Array(16);
e.toArray(e.identity(), Wa, 0);
function Vh(Z) {
  return zz(new Float32Array(Wa), 1, void 0, 0, 0, Z);
}
function LA(Z, J) {
  for (let $ = 0;$ < J; $++)
    Z.set(Wa, $ * 16);
  return Z;
}
function Ka(Z, J, $, X) {
  let Y = Z.aTransform.ref.value, Q = Z.aInstance.ref.value, W = Z.instanceCount.ref.value, K = Z.matrix.ref.value, G = Z.transform.ref.value, H = Z.extraTransform.ref.value;
  for (let N = 0;N < W; N++) {
    let q = N * 16;
    e.mulOffset(Y, H, G, q, q, q), e.mulOffset(Y, K, Y, q, 0, q), Q[N] = N;
  }
  if (J && W > 0) {
    let N = rR0({
      instanceCount: W,
      instance: Q,
      transform: Y,
      invariantBoundingSphere: J
    }, $, X);
    C.update(Z.instanceGrid, N), C.update(Z.aInstance, N.cellInstance), C.update(Z.aTransform, N.cellTransform);
  } else
    C.update(Z.aInstance, Q), C.update(Z.aTransform, Y);
}

// node_modules/molstar/lib/mol-util/color/names.js
var c2 = QQ({
  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
}), KH2 = function() {
  let Z = /* @__PURE__ */ new Map;
  return Object.keys(c2).forEach((J) => {
    Z.set(c2[J], J);
  }), Z;
}();

// node_modules/molstar/lib/mol-theme/color/categories.js
var $8 = {
  Atom: "Atom Property",
  Chain: "Chain Property",
  Residue: "Residue Property",
  Symmetry: "Symmetry",
  Validation: "Validation",
  Misc: "Miscellaneous"
};

// node_modules/molstar/lib/mol-theme/color/uniform.js
var eR0 = i0(13421772), E71 = "Gives everything the same, uniform color.", tF = {
  value: j.Color(eR0),
  saturation: j.Numeric(0, { min: -6, max: 6, step: 0.1 }),
  lightness: j.Numeric(0, { min: -6, max: 6, step: 0.1 })
};
function O71(Z) {
  return tF;
}
function qH(Z, J) {
  let $ = t7(J.value, eR0);
  return $ = i0.saturate($, J.saturation), $ = i0.lighten($, J.lightness), {
    factory: qH,
    granularity: "uniform",
    color: () => $,
    props: J,
    description: E71,
    legend: ZX([["uniform", $]])
  };
}
var ZE0 = {
  name: "uniform",
  label: "Uniform",
  category: $8.Misc,
  factory: qH,
  getParams: O71,
  defaultValues: j.getDefaultValues(tF),
  isApplicable: (Z) => !0
};

// node_modules/molstar/lib/mol-theme/size/uniform.js
var z71 = "Gives everything the same, uniform size.", JE0 = {
  value: j.Numeric(1, { min: 0, max: 20, step: 0.1 })
};
function D71(Z) {
  return JE0;
}
function Ih(Z, J) {
  let $ = J.value;
  return {
    factory: Ih,
    granularity: "uniform",
    size: () => $,
    props: J,
    description: z71
  };
}
var $E0 = {
  name: "uniform",
  label: "Uniform",
  category: "",
  factory: Ih,
  getParams: D71,
  defaultValues: j.getDefaultValues(JE0),
  isApplicable: (Z) => !0
};

// node_modules/molstar/lib/mol-util/material.js
function C7(Z) {
  return { ...C7.Zero, ...Z };
}
(function(Z) {
  Z.Zero = { metalness: 0, roughness: 0, bumpiness: 0 };
  function J(W, K, G) {
    return K[G] = W.metalness * 255, K[G + 1] = W.roughness * 255, K[G + 2] = W.bumpiness * 255, K;
  }
  Z.toArray = J;
  function $(W, K, G) {
    return K[G] = W.metalness, K[G + 1] = W.roughness, K[G + 2] = W.bumpiness, K;
  }
  Z.toArrayNormalized = $;
  function X(W, K) {
    return W.metalness === K.metalness && W.roughness === K.roughness && W.bumpiness === K.bumpiness;
  }
  Z.areEqual = X;
  function Y({ metalness: W, roughness: K, bumpiness: G }) {
    return `M ${W.toFixed(2)} | R ${K.toFixed(2)} | B ${G.toFixed(2)}`;
  }
  Z.toString = Y;
  function Q(W) {
    return j.Group({
      metalness: j.Numeric(0, { min: 0, max: 1, step: 0.01 }),
      roughness: j.Numeric(1, { min: 0, max: 1, step: 0.01 }),
      bumpiness: j.Numeric(0, { min: 0, max: 1, step: 0.01 })
    }, {
      ...W,
      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"]
      ]
    });
  }
  Z.getParam = Q;
})(C7 || (C7 = {}));

// node_modules/molstar/lib/mol-util/clip.js
function FH() {}
(function(Z) {
  Z.Type = {
    none: 0,
    plane: 1,
    sphere: 2,
    cube: 3,
    cylinder: 4,
    infiniteCone: 5
  }, Z.Params = {
    variant: j.Select("pixel", j.arrayToOptions(["instance", "pixel"])),
    objects: j.ObjectList({
      type: j.Select("plane", j.objectToOptions(Z.Type, (N) => v$(N))),
      invert: j.Boolean(!1),
      position: j.Vec3(M()),
      rotation: j.Group({
        axis: j.Vec3(M.create(1, 0, 0)),
        angle: j.Numeric(0, { min: -180, max: 180, step: 1 }, { description: "Angle in Degrees" })
      }, { isExpanded: !0 }),
      scale: j.Vec3(M.create(1, 1, 1)),
      transform: j.Mat4(e.identity())
    }, (N) => v$(N.type))
  };
  function J(N) {
    return {
      count: 0,
      type: new Array(N).fill(1),
      invert: new Array(N).fill(!1),
      position: new Array(N * 3).fill(0),
      rotation: new Array(N * 4).fill(0),
      scale: new Array(N * 3).fill(1),
      transform: new Array(N * 16).fill(0)
    };
  }
  let $ = k8(), X = k8(), Y = M(), Q = M(), W = e(), K = e();
  function G(N, q) {
    let U = N.objects.length, { type: F, invert: E, position: R, rotation: z, scale: D, transform: A } = (q === null || q === void 0 ? void 0 : q.objects) || J(U);
    for (let B = 0;B < U; ++B) {
      let T = N.objects[B];
      F[B] = Z.Type[T.type], E[B] = T.invert, M.toArray(T.position, R, B * 3), k8.toArray(k8.setAxisAngle($, T.rotation.axis, _8(T.rotation.angle)), z, B * 4), M.toArray(T.scale, D, B * 3), e.toArray(T.transform, A, B * 16);
    }
    return {
      variant: N.variant,
      objects: { count: U, type: F, invert: E, position: R, rotation: z, scale: D, transform: A }
    };
  }
  Z.getClip = G;
  function H(N, q) {
    if (N.variant !== q.variant)
      return !1;
    if (N.objects.count !== q.objects.count)
      return !1;
    let U = N.objects, F = q.objects;
    for (let E = 0, R = U.count;E < R; ++E) {
      if (U.invert[E] !== F.invert[E])
        return !1;
      if (U.type[E] !== F.type[E])
        return !1;
      if (M.fromArray(Y, U.position, E * 3), M.fromArray(Q, F.position, E * 3), !M.equals(Y, Q))
        return !1;
      if (M.fromArray(Y, U.scale, E * 3), M.fromArray(Q, F.scale, E * 3), !M.equals(Y, Q))
        return !1;
      if (k8.fromArray($, U.rotation, E * 4), k8.fromArray(X, F.rotation, E * 4), !k8.equals($, X))
        return !1;
      if (e.fromArray(W, U.transform, E * 16), e.fromArray(K, F.transform, E * 16), !e.areEqual(W, K, u8))
        return !1;
    }
    return !0;
  }
  Z.areEqual = H;
})(FH || (FH = {}));

// node_modules/molstar/lib/mol-geo/geometry/base.js
var M71 = {
  custom: {},
  auto: {},
  highest: {},
  higher: {},
  high: {},
  medium: {},
  low: {},
  lower: {},
  lowest: {}
}, A71 = Object.keys(M71), UV = j.arrayToOptions(A71), Ph = {
  smoothColors: j.MappedStatic("auto", {
    auto: j.Group({}),
    on: j.Group({
      resolutionFactor: j.Numeric(2, { min: 0.5, max: 6, step: 0.1 }),
      sampleStride: j.Numeric(3, { min: 1, max: 12, step: 1 })
    }),
    off: j.Group({})
  })
};
function j5(Z) {
  return !!Z.smoothColors;
}
function FQ(Z, J, $) {
  if ((Z.name === "on" || Z.name === "auto" && J) && $ && $ < 3) {
    let X = 3;
    if (Z.name === "on")
      $ *= Z.params.resolutionFactor, X = Z.params.sampleStride;
    else if ($ *= 2 - MS(0, 1.1, $), $ = Math.max(0.5, $), $ > 1.2)
      X = 2;
    return { resolution: $, stride: X };
  }
}
var q1;
(function(Z) {
  Z.MaterialCategory = { category: "Material" }, Z.ShadingCategory = { category: "Shading" }, Z.CullingLodCategory = { category: "Culling & LOD" }, Z.CustomQualityParamInfo = {
    category: "Custom Quality",
    hideIf: (W) => typeof W.quality !== "undefined" && W.quality !== "custom"
  }, Z.Params = {
    alpha: j.Numeric(1, { min: 0, max: 1, step: 0.01 }, { label: "Opacity", isEssential: !0, description: "How opaque/transparent the representation is rendered." }),
    quality: j.Select("auto", UV, { isEssential: !0, description: "Visual/rendering quality of the representation." }),
    material: C7.getParam(),
    clip: j.Group(FH.Params),
    emissive: j.Numeric(0, { min: 0, max: 1, step: 0.01 }),
    density: j.Numeric(0.2, { min: 0, max: 1, step: 0.01 }, { description: "Density value to estimate object thickness." }),
    instanceGranularity: j.Boolean(!1, { description: "Use instance granularity for marker, transparency, clipping, overpaint, substance data to save memory." }),
    lod: j.Vec3(M(), void 0, { ...Z.CullingLodCategory, description: "Level of detail.", fieldLabels: { x: "Min Distance", y: "Max Distance", z: "Overlap (Shader)" } }),
    cellSize: j.Numeric(200, { min: 0, max: 5000, step: 100 }, { ...Z.CullingLodCategory, description: "Instance grid cell size." }),
    batchSize: j.Numeric(2000, { min: 0, max: 50000, step: 500 }, { ...Z.CullingLodCategory, description: "Instance grid batch size." })
  };
  function J(W = c2.grey, K = 1, G) {
    if (!G)
      G = Vh();
    let H = X6(1, G.instanceCount.ref.value, 1, () => qQ, !1, () => !1), N = {
      color: qH({}, { value: W, lightness: 0, saturation: 0 }),
      size: Ih({}, { value: K })
    };
    return { transform: G, locationIterator: H, theme: N };
  }
  Z.createSimple = J;
  function $(W, K) {
    let G = FH.getClip(W.clip);
    return {
      alpha: C.create(W.alpha),
      uAlpha: C.create(W.alpha),
      uVertexCount: C.create(K.vertexCount),
      uGroupCount: C.create(K.groupCount),
      drawCount: C.create(K.drawCount),
      uMetalness: C.create(W.material.metalness),
      uRoughness: C.create(W.material.roughness),
      uBumpiness: C.create(W.material.bumpiness),
      uEmissive: C.create(W.emissive),
      uDensity: C.create(W.density),
      dClipObjectCount: C.create(G.objects.count),
      dClipVariant: C.create(G.variant),
      uClipObjectType: C.create(G.objects.type),
      uClipObjectInvert: C.create(G.objects.invert),
      uClipObjectPosition: C.create(G.objects.position),
      uClipObjectRotation: C.create(G.objects.rotation),
      uClipObjectScale: C.create(G.objects.scale),
      uClipObjectTransform: C.create(G.objects.transform),
      instanceGranularity: C.create(W.instanceGranularity),
      uLod: C.create(E2.create(W.lod[0], W.lod[1], W.lod[2], 0))
    };
  }
  Z.createValues = $;
  function X(W, K) {
    C.updateIfChanged(W.alpha, K.alpha), C.updateIfChanged(W.uMetalness, K.material.metalness), C.updateIfChanged(W.uRoughness, K.material.roughness), C.updateIfChanged(W.uBumpiness, K.material.bumpiness), C.updateIfChanged(W.uEmissive, K.emissive), C.updateIfChanged(W.uDensity, K.density);
    let G = FH.getClip(K.clip);
    C.updateIfChanged(W.dClipObjectCount, G.objects.count), C.updateIfChanged(W.dClipVariant, G.variant), C.update(W.uClipObjectType, G.objects.type), C.update(W.uClipObjectInvert, G.objects.invert), C.update(W.uClipObjectPosition, G.objects.position), C.update(W.uClipObjectRotation, G.objects.rotation), C.update(W.uClipObjectScale, G.objects.scale), C.update(W.uClipObjectTransform, G.objects.transform), C.updateIfChanged(W.instanceGranularity, K.instanceGranularity), C.update(W.uLod, E2.set(W.uLod.ref.value, K.lod[0], K.lod[1], K.lod[2], 0));
  }
  Z.updateValues = X;
  function Y(W = {}) {
    let K = W.alpha === void 0 ? !0 : W.alpha === 1;
    return {
      disposed: !1,
      visible: !0,
      alphaFactor: 1,
      pickable: !0,
      colorOnly: !1,
      opaque: K,
      writeDepth: K
    };
  }
  Z.createRenderableState = Y;
  function Q(W, K) {
    W.opaque = K.alpha * W.alphaFactor >= 1, W.writeDepth = W.opaque;
  }
  Z.updateRenderableState = Q;
})(q1 || (q1 = {}));

// node_modules/molstar/lib/mol-geo/geometry/overpaint-data.js
function YE0(Z, J, $, X) {
  for (let Y = J;Y < $; ++Y)
    i0.toArray(X, Z, Y * 4), Z[Y * 4 + 3] = 255;
  return !0;
}
function Ga(Z, J, $) {
  return Z.fill(0, J * 4, $ * 4), !0;
}
function QE0(Z, J, $) {
  let X = Z9(Math.max(1, Z), 4, Uint8Array, $ && $.tOverpaint.ref.value.array);
  if ($)
    return C.update($.tOverpaint, X), C.update($.uOverpaintTexDim, h0.create(X.width, X.height)), C.updateIfChanged($.dOverpaint, Z > 0), C.updateIfChanged($.dOverpaintType, J), $;
  else
    return {
      tOverpaint: C.create(X),
      uOverpaintTexDim: C.create(h0.create(X.width, X.height)),
      dOverpaint: C.create(Z > 0),
      tOverpaintGrid: C.create(k9()),
      uOverpaintGridDim: C.create(M.create(1, 1, 1)),
      uOverpaintGridTransform: C.create(E2.create(0, 0, 0, 1)),
      dOverpaintType: C.create(J),
      uOverpaintStrength: C.create(1)
    };
}
var XE0 = { array: new Uint8Array(4), width: 1, height: 1 };
function LY(Z) {
  if (Z)
    return C.update(Z.tOverpaint, XE0), C.update(Z.uOverpaintTexDim, h0.create(1, 1)), Z;
  else
    return {
      tOverpaint: C.create(XE0),
      uOverpaintTexDim: C.create(h0.create(1, 1)),
      dOverpaint: C.create(!1),
      tOverpaintGrid: C.create(k9()),
      uOverpaintGridDim: C.create(M.create(1, 1, 1)),
      uOverpaintGridTransform: C.create(E2.create(0, 0, 0, 1)),
      dOverpaintType: C.create("groupInstance"),
      uOverpaintStrength: C.create(1)
    };
}

// node_modules/molstar/lib/mol-geo/geometry/transparency-data.js
function KE0(Z, J, $, X) {
  for (let Y = J;Y < $; ++Y)
    Z[Y] = X * 255;
  return !0;
}
function Ha(Z, J) {
  if (J === 0 || Z.length < J)
    return 0;
  let $ = 0;
  for (let X = 0;X < J; ++X)
    $ += Z[X];
  return $ / (255 * J);
}
function Na(Z, J) {
  if (J === 0 || Z.length < J)
    return 1;
  let $ = 255;
  for (let X = 0;X < J; ++X)
    if (Z[X] > 0 && Z[X] < $)
      $ = Z[X];
  return $ / 255;
}
function GE0(Z, J, $) {
  Z.fill(0, J, $);
}
function HE0(Z, J, $) {
  let X = Z9(Math.max(1, Z), 1, Uint8Array, $ && $.tTransparency.ref.value.array);
  if ($)
    return C.update($.tTransparency, X), C.update($.uTransparencyTexDim, h0.create(X.width, X.height)), C.updateIfChanged($.dTransparency, Z > 0), C.updateIfChanged($.transparencyAverage, Ha(X.array, Z)), C.updateIfChanged($.transparencyMin, Na(X.array, Z)), C.updateIfChanged($.dTransparencyType, J), $;
  else
    return {
      tTransparency: C.create(X),
      uTransparencyTexDim: C.create(h0.create(X.width, X.height)),
      dTransparency: C.create(Z > 0),
      transparencyAverage: C.create(0),
      transparencyMin: C.create(1),
      tTransparencyGrid: C.create(k9()),
      uTransparencyGridDim: C.create(M.create(1, 1, 1)),
      uTransparencyGridTransform: C.create(E2.create(0, 0, 0, 1)),
      dTransparencyType: C.create(J),
      uTransparencyStrength: C.create(1)
    };
}
var WE0 = { array: new Uint8Array(1), width: 1, height: 1 };
function RY(Z) {
  if (Z)
    return C.update(Z.tTransparency, WE0), C.update(Z.uTransparencyTexDim, h0.create(1, 1)), Z;
  else
    return {
      tTransparency: C.create(WE0),
      uTransparencyTexDim: C.create(h0.create(1, 1)),
      dTransparency: C.create(!1),
      transparencyAverage: C.create(0),
      transparencyMin: C.create(1),
      tTransparencyGrid: C.create(k9()),
      uTransparencyGridDim: C.create(M.create(1, 1, 1)),
      uTransparencyGridTransform: C.create(E2.create(0, 0, 0, 1)),
      dTransparencyType: C.create("groupInstance"),
      uTransparencyStrength: C.create(1)
    };
}

// node_modules/molstar/lib/mol-geo/geometry/clipping-data.js
function qE0(Z, J, $, X) {
  return Z.fill(X, J, $), !0;
}
function FE0(Z, J, $) {
  Z.fill(0, J, $);
}
function UE0(Z, J, $) {
  let X = Z9(Math.max(1, Z), 1, Uint8Array, $ && $.tClipping.ref.value.array);
  if ($)
    return C.update($.tClipping, X), C.update($.uClippingTexDim, h0.create(X.width, X.height)), C.updateIfChanged($.dClipping, Z > 0), C.updateIfChanged($.dClippingType, J), $;
  else
    return {
      tClipping: C.create(X),
      uClippingTexDim: C.create(h0.create(X.width, X.height)),
      dClipping: C.create(Z > 0),
      dClippingType: C.create(J)
    };
}
var NE0 = { array: new Uint8Array(1), width: 1, height: 1 };
function EY(Z) {
  if (Z)
    return C.update(Z.tClipping, NE0), C.update(Z.uClippingTexDim, h0.create(1, 1)), C.updateIfChanged(Z.dClipping, !1), Z;
  else
    return {
      tClipping: C.create(NE0),
      uClippingTexDim: C.create(h0.create(1, 1)),
      dClipping: C.create(!1),
      dClippingType: C.create("groupInstance")
    };
}

// node_modules/molstar/lib/mol-geo/geometry/substance-data.js
function RE0(Z, J, $, X) {
  for (let Y = J;Y < $; ++Y)
    C7.toArray(X, Z, Y * 4), Z[Y * 4 + 3] = 255;
  return !0;
}
function qa(Z, J, $) {
  return Z.fill(0, J * 4, $ * 4), !0;
}
function EE0(Z, J, $) {
  let X = Z9(Math.max(1, Z), 4, Uint8Array, $ && $.tSubstance.ref.value.array);
  if ($)
    return C.update($.tSubstance, X), C.update($.uSubstanceTexDim, h0.create(X.width, X.height)), C.updateIfChanged($.dSubstance, Z > 0), C.updateIfChanged($.dSubstanceType, J), $;
  else
    return {
      tSubstance: C.create(X),
      uSubstanceTexDim: C.create(h0.create(X.width, X.height)),
      dSubstance: C.create(Z > 0),
      tSubstanceGrid: C.create(k9()),
      uSubstanceGridDim: C.create(M.create(1, 1, 1)),
      uSubstanceGridTransform: C.create(E2.create(0, 0, 0, 1)),
      dSubstanceType: C.create(J),
      uSubstanceStrength: C.create(1)
    };
}
var LE0 = { array: new Uint8Array(4), width: 1, height: 1 };
function OY(Z) {
  if (Z)
    return C.update(Z.tSubstance, LE0), C.update(Z.uSubstanceTexDim, h0.create(1, 1)), Z;
  else
    return {
      tSubstance: C.create(LE0),
      uSubstanceTexDim: C.create(h0.create(1, 1)),
      dSubstance: C.create(!1),
      tSubstanceGrid: C.create(k9()),
      uSubstanceGridDim: C.create(M.create(1, 1, 1)),
      uSubstanceGridTransform: C.create(E2.create(0, 0, 0, 1)),
      dSubstanceType: C.create("groupInstance"),
      uSubstanceStrength: C.create(1)
    };
}

// node_modules/molstar/lib/mol-geo/geometry/emissive-data.js
function zE0(Z, J, $, X) {
  for (let Y = J;Y < $; ++Y)
    Z[Y] = X * 255;
  return !0;
}
function Fa(Z, J) {
  if (J === 0 || Z.length < J)
    return 0;
  let $ = 0;
  for (let X = 0;X < J; ++X)
    $ += Z[X];
  return $ / (255 * J);
}
function DE0(Z, J, $) {
  Z.fill(0, J, $);
}
function ME0(Z, J, $) {
  let X = Z9(Math.max(1, Z), 1, Uint8Array, $ && $.tEmissive.ref.value.array);
  if ($)
    return C.update($.tEmissive, X), C.update($.uEmissiveTexDim, h0.create(X.width, X.height)), C.updateIfChanged($.dEmissive, Z > 0), C.updateIfChanged($.emissiveAverage, Fa(X.array, Z)), C.updateIfChanged($.dEmissiveType, J), $;
  else
    return {
      tEmissive: C.create(X),
      uEmissiveTexDim: C.create(h0.create(X.width, X.height)),
      dEmissive: C.create(Z > 0),
      emissiveAverage: C.create(0),
      tEmissiveGrid: C.create(k9()),
      uEmissiveGridDim: C.create(M.create(1, 1, 1)),
      uEmissiveGridTransform: C.create(E2.create(0, 0, 0, 1)),
      dEmissiveType: C.create(J),
      uEmissiveStrength: C.create(1)
    };
}
var OE0 = { array: new Uint8Array(1), width: 1, height: 1 };
function zY(Z) {
  if (Z)
    return C.update(Z.tEmissive, OE0), C.update(Z.uEmissiveTexDim, h0.create(1, 1)), Z;
  else
    return {
      tEmissive: C.create(OE0),
      uEmissiveTexDim: C.create(h0.create(1, 1)),
      dEmissive: C.create(!1),
      emissiveAverage: C.create(0),
      tEmissiveGrid: C.create(k9()),
      uEmissiveGridDim: C.create(M.create(1, 1, 1)),
      uEmissiveGridTransform: C.create(E2.create(0, 0, 0, 1)),
      dEmissiveType: C.create("groupInstance"),
      uEmissiveStrength: C.create(1)
    };
}

// node_modules/molstar/lib/mol-geo/geometry/interior.js
function I3() {
  return j.Group({
    color: j.Color(i0.fromRgb(76, 76, 76)),
    colorStrength: j.Numeric(1, { min: 0, max: 1, step: 0.01 }),
    substance: C7.getParam(),
    substanceStrength: j.Numeric(1, { min: 0, max: 1, step: 0.01 })
  });
}
function AE0(Z, J) {
  return Z.color === J.color && Z.colorStrength === J.colorStrength && C7.areEqual(Z.substance, J.substance) && Z.substanceStrength === J.substanceStrength;
}
function P3(Z, J) {
  return i0.toArrayNormalized(Z.color, J, 0), J[3] = Z.colorStrength, J;
}
function C3(Z, J) {
  return C7.toArrayNormalized(Z.substance, J, 0), J[3] = Z.substanceStrength, J;
}

// node_modules/molstar/lib/mol-geo/geometry/mesh/mesh.js
var n1;
(function(Z) {
  function J(v, h, x, b, g, m, i) {
    return i ? Q(v, h, x, b, g, m, i) : Y(v, h, x, b, g, m);
  }
  Z.create = J;
  function $(v) {
    let h = v ? v.vertexBuffer.ref.value : new Float32Array(0), x = v ? v.indexBuffer.ref.value : new Uint32Array(0), b = v ? v.normalBuffer.ref.value : new Float32Array(0), g = v ? v.groupBuffer.ref.value : new Float32Array(0);
    return J(h, x, b, g, 0, 0, v);
  }
  Z.createEmpty = $;
  function X(v) {
    return l9([
      v.vertexCount,
      v.triangleCount,
      v.vertexBuffer.ref.version,
      v.indexBuffer.ref.version,
      v.normalBuffer.ref.version,
      v.groupBuffer.ref.version
    ]);
  }
  function Y(v, h, x, b, g, m) {
    let i = C0(), r, Y0 = -1, c = -1, n = {
      kind: "mesh",
      vertexCount: g,
      triangleCount: m,
      vertexBuffer: C.create(v),
      indexBuffer: C.create(h),
      normalBuffer: C.create(x),
      groupBuffer: C.create(b),
      varyingGroup: C.create(!1),
      get boundingSphere() {
        let l = X(n);
        if (l !== Y0) {
          let u = w5(n.vertexBuffer.ref.value, n.vertexCount, 1);
          C0.copy(i, u), Y0 = l;
        }
        return i;
      },
      get groupMapping() {
        if (n.groupBuffer.ref.version !== c)
          r = _3(n.groupBuffer.ref.value, n.vertexCount), c = n.groupBuffer.ref.version;
        return r;
      },
      setBoundingSphere(l) {
        C0.copy(i, l), Y0 = X(n);
      },
      meta: {}
    };
    return n;
  }
  function Q(v, h, x, b, g, m, i) {
    return i.vertexCount = g, i.triangleCount = m, C.update(i.vertexBuffer, v), C.update(i.indexBuffer, h), C.update(i.normalBuffer, x), C.update(i.groupBuffer, b), i;
  }
  function W(v) {
    let { vertexCount: h, triangleCount: x } = v, b = v.vertexBuffer.ref.value, g = v.indexBuffer.ref.value, m = v.normalBuffer.ref.value.length >= h * 3 ? v.normalBuffer.ref.value : new Float32Array(h * 3);
    if (m === v.normalBuffer.ref.value)
      m.fill(0, 0, h * 3);
    Eh(b, g, m, h, x), C.update(v.normalBuffer, m);
  }
  Z.computeNormals = W;
  function K(v, h = 3) {
    let x = v.vertexBuffer.ref.value, b = /* @__PURE__ */ new Map, g = (r, Y0) => `${r[0].toFixed(Y0)}|${r[1].toFixed(Y0)}|${r[2].toFixed(Y0)}`, m = 0, i = M();
    for (let r = 0, Y0 = v.vertexCount;r < Y0; ++r) {
      M.fromArray(i, x, r * 3);
      let c = g(i, h), n = b.get(c);
      if (n !== void 0)
        m += 1, b.set(c, n + 1);
      else
        b.set(c, 1);
    }
    return m;
  }
  Z.checkForDuplicateVertices = K;
  let G = h2();
  function H(v, h) {
    let x = v.vertexBuffer.ref.value;
    if (SW(h, x, 0, v.vertexCount), !e.isTranslationAndUniformScaling(h)) {
      let b = h2.directionTransform(G, h);
      qU0(b, v.normalBuffer.ref.value, 0, v.vertexCount);
    }
    C.update(v.vertexBuffer, x);
  }
  Z.transform = H;
  function N(v) {
    let { originalData: h } = "kind" in v ? v.meta : v.meta.ref.value;
    return h;
  }
  Z.getOriginalData = N;
  function q(v, h = !0) {
    let { indexBuffer: x, vertexBuffer: b, groupBuffer: g, normalBuffer: m, triangleCount: i, vertexCount: r } = v, Y0 = x.ref.value, c = b.ref.value, n = g.ref.value, l = m.ref.value, u = B1.create(Uint32Array, 3, 1024, i), G0 = B1.create(Float32Array, 3, 1024, c);
    G0.currentIndex = r * 3, G0.elementCount = r;
    let F0 = B1.create(Float32Array, 3, 1024, l);
    F0.currentIndex = r * 3, F0.elementCount = r;
    let t = B1.create(Float32Array, 1, 1024, n);
    t.currentIndex = r, t.elementCount = r;
    let Z0 = M(), U0 = M(), a = M(), Q0 = M(), $0 = M(), R0 = M();
    function X0(Y1) {
      M.fromArray(Z0, c, Y1 * 3), M.fromArray(Q0, l, Y1 * 3), B1.add3(G0, Z0[0], Z0[1], Z0[2]), B1.add3(F0, Q0[0], Q0[1], Q0[2]);
    }
    function E0(Y1, u1) {
      M.fromArray(Z0, c, Y1 * 3), M.fromArray(U0, c, u1 * 3), M.scale(Z0, M.add(Z0, Z0, U0), 0.5), M.fromArray(Q0, l, Y1 * 3), M.fromArray($0, l, u1 * 3), M.scale(Q0, M.add(Q0, Q0, $0), 0.5), B1.add3(G0, Z0[0], Z0[1], Z0[2]), B1.add3(F0, Q0[0], Q0[1], Q0[2]);
    }
    function V0(Y1, u1, b0) {
      M.fromArray(Z0, c, Y1 * 3), M.fromArray(U0, c, u1 * 3), M.fromArray(a, c, b0 * 3), M.scale(Z0, M.add(Z0, M.add(Z0, Z0, U0), a), 0.3333333333333333), M.fromArray(Q0, l, Y1 * 3), M.fromArray($0, l, u1 * 3), M.fromArray(R0, l, b0 * 3), M.scale(Q0, M.add(Q0, M.add(Q0, Q0, $0), R0), 0.3333333333333333), B1.add3(G0, Z0[0], Z0[1], Z0[2]), B1.add3(F0, Q0[0], Q0[1], Q0[2]);
    }
    function u0(Y1, u1, b0, x0, m0) {
      ++q0, X0(Y1), E0(Y1, u1), E0(Y1, b0), B1.add3(u, N0, N0 + 1, N0 + 2);
      for (let e0 = 0;e0 < 3; ++e0)
        B1.add(t, x0);
      N0 += 3, q0 += 2, X0(u1), X0(b0), E0(Y1, u1), E0(Y1, b0), B1.add3(u, N0, N0 + 1, N0 + 3), B1.add3(u, N0, N0 + 3, N0 + 2);
      for (let e0 = 0;e0 < 4; ++e0)
        B1.add(t, m0);
      N0 += 4;
    }
    let N0 = r, q0 = 0;
    if (h)
      for (let Y1 = 0, u1 = i;Y1 < u1; ++Y1) {
        let b0 = Y0[Y1 * 3], x0 = Y0[Y1 * 3 + 1], m0 = Y0[Y1 * 3 + 2], e0 = n[b0], p = n[x0], J0 = n[m0];
        if (e0 === p && e0 === J0)
          ++q0, B1.add3(u, b0, x0, m0);
        else if (e0 === p)
          u0(m0, b0, x0, J0, e0);
        else if (e0 === J0)
          u0(x0, m0, b0, p, J0);
        else if (p === J0)
          u0(b0, x0, m0, e0, p);
        else {
          q0 += 2, X0(b0), E0(b0, x0), E0(b0, m0), V0(b0, x0, m0), B1.add3(u, N0, N0 + 1, N0 + 3), B1.add3(u, N0, N0 + 3, N0 + 2);
          for (let T0 = 0;T0 < 4; ++T0)
            B1.add(t, e0);
          N0 += 4, q0 += 2, X0(x0), E0(x0, m0), E0(x0, b0), V0(b0, x0, m0), B1.add3(u, N0, N0 + 1, N0 + 3), B1.add3(u, N0, N0 + 3, N0 + 2);
          for (let T0 = 0;T0 < 4; ++T0)
            B1.add(t, p);
          N0 += 4, q0 += 2, X0(m0), E0(m0, x0), E0(m0, b0), V0(b0, x0, m0), B1.add3(u, N0 + 3, N0 + 1, N0), B1.add3(u, N0 + 2, N0 + 3, N0);
          for (let T0 = 0;T0 < 4; ++T0)
            B1.add(t, J0);
          N0 += 4;
        }
      }
    else
      for (let Y1 = 0, u1 = i;Y1 < u1; ++Y1) {
        let b0 = Y0[Y1 * 3], x0 = Y0[Y1 * 3 + 1], m0 = Y0[Y1 * 3 + 2], e0 = n[b0], p = n[x0], J0 = n[m0];
        if (e0 !== p || e0 !== J0) {
          ++q0, X0(b0), X0(x0), X0(m0), B1.add3(u, N0, N0 + 1, N0 + 2);
          let T0 = p === J0 ? p : e0;
          for (let o0 = 0;o0 < 3; ++o0)
            B1.add(t, T0);
          N0 += 3;
        } else
          ++q0, B1.add3(u, b0, x0, m0);
      }
    let A0 = B1.compact(u), S0 = B1.compact(G0), a0 = B1.compact(F0), D1 = B1.compact(t);
    return v.vertexCount = N0, v.triangleCount = q0, C.update(b, S0), C.update(g, D1), C.update(x, A0), C.update(m, a0), v.meta.originalData = { indexBuffer: Y0, vertexCount: r, triangleCount: i }, v;
  }
  Z.uniformTriangleGroup = q;
  function U(v) {
    let { vertexCount: h, triangleCount: x } = v, b = v.indexBuffer.ref.value, g = [];
    for (let m = 0;m < h; ++m)
      g[m] = [];
    for (let m = 0;m < x; ++m) {
      let i = b[m * 3], r = b[m * 3 + 1], Y0 = b[m * 3 + 2];
      n9(g[i], r), n9(g[i], Y0), n9(g[r], i), n9(g[r], Y0), n9(g[Y0], i), n9(g[Y0], r);
    }
    return g;
  }
  function F(v) {
    let { triangleCount: h } = v, x = v.indexBuffer.ref.value, b = /* @__PURE__ */ new Map, g = (m, i) => {
      let r = wW(m, i), Y0 = b.get(r) || 0;
      b.set(r, Y0 + 1);
    };
    for (let m = 0;m < h; ++m) {
      let i = x[m * 3], r = x[m * 3 + 1], Y0 = x[m * 3 + 2];
      g(i, r), g(i, Y0), g(r, Y0);
    }
    return b;
  }
  function E(v) {
    let h = /* @__PURE__ */ new Set, x = [0, 0];
    return v.forEach((b, g) => {
      if (b === 1)
        PM(x, g), h.add(x[0]), h.add(x[1]);
    }), h;
  }
  function R(v, h, x) {
    let b = /* @__PURE__ */ new Map, g = (m, i) => {
      if (b.has(m))
        n9(b.get(m), i);
      else
        b.set(m, [i]);
    };
    return h.forEach((m) => {
      let i = v[m];
      for (let r of i)
        if (h.has(r) && x.get(wW(m, r)) === 1)
          g(m, r);
    }), b;
  }
  function z(v, h) {
    let { indexBuffer: x, triangleCount: b } = v, g = x.ref.value, m = B1.create(Uint32Array, 3, 1024, b), i = 0;
    for (let Y0 = 0;Y0 < b; ++Y0) {
      let c = g[Y0 * 3], n = g[Y0 * 3 + 1], l = g[Y0 * 3 + 2];
      if (h[c].length === 2 || h[n].length === 2 || h[l].length === 2)
        continue;
      B1.add3(m, c, n, l), i += 1;
    }
    let r = B1.compact(m);
    return v.triangleCount = i, C.update(x, r), v;
  }
  function D(v, h, x, b) {
    var g;
    let { vertexBuffer: m, indexBuffer: i, normalBuffer: r, triangleCount: Y0 } = v, c = m.ref.value, n = i.ref.value, l = r.ref.value, u = B1.create(Uint32Array, 3, 1024, Y0), G0 = 0;
    for (let A0 = 0;A0 < Y0; ++A0)
      B1.add3(u, n[A0 * 3], n[A0 * 3 + 1], n[A0 * 3 + 2]), G0 += 1;
    let F0 = M(), t = M(), Z0 = M(), U0 = M(), a = M(), Q0 = M(), $0 = M(), R0 = M(), X0 = M(), E0 = M(), V0 = _8(120), u0 = /* @__PURE__ */ new Set, N0 = Array.from(x.keys()).filter((A0) => x.get(A0).length < 2).map((A0) => {
      let S0 = x.get(A0);
      return M.fromArray(F0, c, A0 * 3), M.fromArray(t, c, S0[0] * 3), M.fromArray(Z0, c, S0[1] * 3), M.sub(a, t, F0), M.sub(Q0, Z0, F0), [A0, M.angle(a, Q0)];
    });
    N0.sort(([, A0], [, S0]) => A0 - S0);
    for (let [A0, S0] of N0) {
      if (u0.has(A0) || S0 > V0)
        continue;
      let a0 = x.get(A0);
      if (h[a0[0]].includes(a0[1]) && !((g = x.get(a0[0])) === null || g === void 0 ? void 0 : g.includes(a0[1])))
        continue;
      if (M.fromArray(F0, c, A0 * 3), M.fromArray(t, c, a0[0] * 3), M.fromArray(Z0, c, a0[1] * 3), M.sub(a, t, F0), M.sub(Q0, Z0, F0), M.add(R0, a, Q0), M.squaredDistance(F0, t) >= b)
        continue;
      let D1 = !1;
      for (let Y1 of h[A0]) {
        if (a0.includes(Y1))
          continue;
        if (M.fromArray(U0, c, Y1 * 3), M.sub($0, U0, F0), M.dot(R0, $0) < 0) {
          D1 = !0;
          break;
        }
      }
      if (!D1)
        continue;
      if (M.fromArray(X0, l, A0 * 3), M.triangleNormal(E0, F0, t, Z0), M.dot(E0, X0) > 0)
        B1.add3(u, A0, a0[0], a0[1]);
      else
        B1.add3(u, a0[1], a0[0], A0);
      u0.add(A0), u0.add(a0[0]), u0.add(a0[1]), G0 += 1;
    }
    let q0 = B1.compact(u);
    return v.triangleCount = G0, C.update(i, q0), v;
  }
  function A(v, h, x) {
    let { iterations: b, lambda: g } = x, m = M(), i = M(), r = M(), Y0 = M(), c = -g, n = new Float32Array(v.vertexBuffer.ref.value.length), l = (u) => {
      let G0 = v.vertexBuffer.ref.value;
      n.set(G0), h.forEach((t, Z0) => {
        if (t.length !== 2)
          return;
        M.fromArray(m, G0, Z0 * 3), M.fromArray(i, G0, t[0] * 3), M.fromArray(r, G0, t[1] * 3);
        let U0 = 1 / M.distance(m, i), a = 1 / M.distance(m, r);
        M.scale(i, i, U0), M.scale(r, r, a), M.add(Y0, i, r), M.scale(Y0, Y0, 1 / (U0 + a)), M.sub(Y0, Y0, m), M.scale(Y0, Y0, u), M.add(Y0, m, Y0), M.toArray(Y0, n, Z0 * 3);
      });
      let F0 = v.vertexBuffer.ref.value;
      C.update(v.vertexBuffer, n), n = F0;
    };
    for (let u = 0;u < b; ++u)
      l(g), l(c);
  }
  function B(v, h) {
    z(v, U(v));
    for (let i = 0;i < 10; ++i) {
      let r = v.triangleCount, Y0 = F(v), c = U(v), n = E(Y0), l = R(c, n, Y0);
      if (D(v, c, l, h.maxNewEdgeLength * h.maxNewEdgeLength), v.triangleCount === r)
        break;
    }
    let x = F(v), b = U(v), g = E(x), m = R(b, g, x);
    return A(v, m, { iterations: h.iterations, lambda: 0.5 }), v;
  }
  Z.smoothEdges = B, Z.Params = {
    ...q1.Params,
    doubleSided: j.Boolean(!1, q1.CustomQualityParamInfo),
    flipSided: j.Boolean(!1, q1.ShadingCategory),
    flatShaded: j.Boolean(!1, q1.ShadingCategory),
    ignoreLight: j.Boolean(!1, q1.ShadingCategory),
    celShaded: j.Boolean(!1, q1.ShadingCategory),
    xrayShaded: j.Select(!1, [[!1, "Off"], [!0, "On"], ["inverted", "Inverted"]], q1.ShadingCategory),
    transparentBackfaces: j.Select("off", j.arrayToOptions(["off", "on", "opaque"]), q1.ShadingCategory),
    bumpFrequency: j.Numeric(0, { min: 0, max: 10, step: 0.1 }, q1.ShadingCategory),
    bumpAmplitude: j.Numeric(1, { min: 0, max: 5, step: 0.1 }, q1.ShadingCategory),
    interior: I3()
  }, Z.Utils = {
    Params: Z.Params,
    createEmpty: $,
    createValues: w,
    createValuesSimple: V,
    updateValues: P,
    updateBoundingSphere: I,
    createRenderableState: S,
    updateRenderableState: f,
    createPositionIterator: T
  };
  function T(v, h) {
    let x = v.vertexCount, b = h.instanceCount.ref.value, g = b$(), m = g.position, i = g.normal, r = v.vertexBuffer.ref.value, Y0 = v.normalBuffer.ref.value, c = h.aTransform.ref.value;
    return X6(x, b, 1, (l, u) => {
      if (u < 0)
        M.fromArray(m, r, l * 3), M.fromArray(i, Y0, l * 3);
      else
        M.transformMat4Offset(m, r, c, 0, l * 3, u * 16), M.transformDirectionOffset(i, Y0, c, 0, l * 3, u * 16);
      return g;
    });
  }
  function w(v, h, x, b, g) {
    let { instanceCount: m, groupCount: i } = x, r = T(v, h), Y0 = WJ(x, r, b.color), c = g.instanceGranularity ? rZ(m, "instance") : rZ(m * i, "groupInstance"), n = LY(), l = RY(), u = zY(), G0 = OY(), F0 = EY(), t = { drawCount: v.triangleCount * 3, vertexCount: v.vertexCount, groupCount: i, instanceCount: m }, Z0 = C0.clone(v.boundingSphere), U0 = j7(Z0, h.aTransform.ref.value, m, 0);
    return {
      dGeometryType: C.create("mesh"),
      aPosition: v.vertexBuffer,
      aNormal: v.normalBuffer,
      aGroup: v.groupBuffer,
      elements: v.indexBuffer,
      dVaryingGroup: v.varyingGroup,
      boundingSphere: C.create(U0),
      invariantBoundingSphere: C.create(Z0),
      uInvariantBoundingSphere: C.create(E2.ofSphere(Z0)),
      ...Y0,
      ...c,
      ...n,
      ...l,
      ...u,
      ...G0,
      ...F0,
      ...h,
      ...q1.createValues(g, t),
      uDoubleSided: C.create(g.doubleSided),
      dFlatShaded: C.create(g.flatShaded),
      dFlipSided: C.create(g.flipSided),
      dIgnoreLight: C.create(g.ignoreLight),
      dCelShaded: C.create(g.celShaded),
      dXrayShaded: C.create(g.xrayShaded === "inverted" ? "inverted" : g.xrayShaded === !0 ? "on" : "off"),
      dTransparentBackfaces: C.create(g.transparentBackfaces),
      uBumpFrequency: C.create(g.bumpFrequency),
      uBumpAmplitude: C.create(g.bumpAmplitude),
      uInteriorColor: C.create(P3(g.interior, E2())),
      uInteriorSubstance: C.create(C3(g.interior, E2())),
      meta: C.create(v.meta)
    };
  }
  function V(v, h, x, b, g) {
    let m = q1.createSimple(x, b, g), i = { ...j.getDefaultValues(Z.Params), ...h };
    return w(v, m.transform, m.locationIterator, m.theme, i);
  }
  function P(v, h) {
    q1.updateValues(v, h), C.updateIfChanged(v.uDoubleSided, h.doubleSided), C.updateIfChanged(v.dFlatShaded, h.flatShaded), C.updateIfChanged(v.dFlipSided, h.flipSided), C.updateIfChanged(v.dIgnoreLight, h.ignoreLight), C.updateIfChanged(v.dCelShaded, h.celShaded), C.updateIfChanged(v.dXrayShaded, h.xrayShaded === "inverted" ? "inverted" : h.xrayShaded === !0 ? "on" : "off"), C.updateIfChanged(v.dTransparentBackfaces, h.transparentBackfaces), C.updateIfChanged(v.uBumpFrequency, h.bumpFrequency), C.updateIfChanged(v.uBumpAmplitude, h.bumpAmplitude), C.update(v.uInteriorColor, P3(h.interior, v.uInteriorColor.ref.value)), C.update(v.uInteriorSubstance, C3(h.interior, v.uInteriorSubstance.ref.value));
  }
  function I(v, h) {
    let x = C0.clone(h.boundingSphere), b = j7(x, v.aTransform.ref.value, v.instanceCount.ref.value, 0);
    if (!C0.equals(b, v.boundingSphere.ref.value))
      C.update(v.boundingSphere, b);
    if (!C0.equals(x, v.invariantBoundingSphere.ref.value))
      C.update(v.invariantBoundingSphere, x), C.update(v.uInvariantBoundingSphere, E2.fromSphere(v.uInvariantBoundingSphere.ref.value, x));
  }
  function S(v) {
    let h = q1.createRenderableState(v);
    return f(h, v), h;
  }
  function f(v, h) {
    q1.updateRenderableState(v, h), v.opaque = v.opaque && !h.xrayShaded, v.writeDepth = v.opaque;
  }
})(n1 || (n1 = {}));

// node_modules/molstar/lib/mol-util/number-packing.js
function UH(Z, J, $) {
  return Z = x8(Math.round(Z), 0, 16777215) + 1, J[$ + 2] = Z % 256, Z = Math.floor(Z / 256), J[$ + 1] = Z % 256, Z = Math.floor(Z / 256), J[$] = Z % 256, J;
}
function VR(Z, J, $) {
  return Math.floor(Z) * 256 * 256 + Math.floor(J) * 256 + Math.floor($) - 1;
}
var Ch = 0.99609375, Ua = M.create(16777216, 65536, 256), B71 = E2.create(Ch / Ua[0], Ch / Ua[1], Ch / Ua[2], Ch / 1), BE0 = E2();
function wE0(Z, J, $, X) {
  return E2.set(BE0, Z / 255, J / 255, $ / 255, X / 255), E2.dot(BE0, B71);
}
function jE0(Z, J) {
  let $ = -1 / 0;
  for (let X = 0, Y = Z.length;X < Y; X += J) {
    let Q = VR(Z[X], Z[X + 1], Z[X + 2]);
    if (Q > $)
      $ = Q;
  }
  return $;
}

// node_modules/molstar/lib/mol-geo/geometry/size-data.js
function DY(Z, J, $) {
  switch (n7.getGranularity(Z, J.granularity)) {
    case "uniform":
      return _71(Z, J.size, $);
    case "group":
      return I71(Z, J.size, $);
    case "groupInstance":
      return P71(Z, J.size, $);
    case "instance":
      return V71(Z, J.size, $);
  }
}
var kh = 100;
function IR(Z) {
  switch (Z.dSizeType.ref.value) {
    case "uniform":
      return Z.uSize.ref.value;
    case "instance":
    case "group":
    case "groupInstance":
      let $ = 0, X = Z.tSize.ref.value.array;
      for (let Y = 0, Q = X.length;Y < Q; Y += 3) {
        let W = VR(X[Y], X[Y + 1], X[Y + 2]);
        if ($ < W)
          $ = W;
      }
      return $ / kh;
  }
}
var w71 = { array: new Uint8Array(3), width: 1, height: 1 };
function j71() {
  return {
    tSize: C.create(w71),
    uSizeTexDim: C.create(h0.create(1, 1))
  };
}
function T71(Z, J) {
  if (J)
    return C.update(J.uSize, Z), C.updateIfChanged(J.dSizeType, "uniform"), J;
  else
    return {
      uSize: C.create(Z),
      ...j71(),
      dSizeType: C.create("uniform")
    };
}
function _71(Z, J, $) {
  Z.reset();
  let X = Z.hasNext ? Z.move().location : qQ;
  return T71(J(X), $);
}
function La(Z, J, $) {
  if ($)
    return C.update($.tSize, Z), C.update($.uSizeTexDim, h0.create(Z.width, Z.height)), C.updateIfChanged($.dSizeType, J), $;
  else
    return {
      uSize: C.create(0),
      tSize: C.create(Z),
      uSizeTexDim: C.create(h0.create(Z.width, Z.height)),
      dSizeType: C.create(J)
    };
}
function V71(Z, J, $) {
  let { instanceCount: X } = Z, Y = Z9(Math.max(1, X), 3, Uint8Array, $ && $.tSize.ref.value.array);
  Z.reset();
  while (Z.hasNext && !Z.isNextNewInstance) {
    let Q = Z.move();
    UH(J(Q.location) * kh, Y.array, Q.instanceIndex * 3), Z.skipInstance();
  }
  return La(Y, "instance", $);
}
function I71(Z, J, $) {
  let { groupCount: X } = Z, Y = Z9(Math.max(1, X), 3, Uint8Array, $ && $.tSize.ref.value.array);
  Z.reset();
  while (Z.hasNext && !Z.isNextNewInstance) {
    let Q = Z.move();
    UH(J(Q.location) * kh, Y.array, Q.groupIndex * 3);
  }
  return La(Y, "group", $);
}
function P71(Z, J, $) {
  let { groupCount: X, instanceCount: Y } = Z, Q = Y * X, W = Z9(Math.max(1, Q), 3, Uint8Array, $ && $.tSize.ref.value.array);
  Z.reset();
  while (Z.hasNext) {
    let K = Z.move();
    UH(J(K.location) * kh, W.array, K.index * 3);
  }
  return La(W, "groupInstance", $);
}

// node_modules/molstar/lib/mol-geo/geometry/points/points.js
var YX;
(function(Z) {
  function J(E, R, z, D) {
    return D ? Q(E, R, z, D) : Y(E, R, z);
  }
  Z.create = J;
  function $(E) {
    let R = E ? E.centerBuffer.ref.value : new Float32Array(0), z = E ? E.groupBuffer.ref.value : new Float32Array(0);
    return J(R, z, 0, E);
  }
  Z.createEmpty = $;
  function X(E) {
    return l9([
      E.pointCount,
      E.centerBuffer.ref.version,
      E.groupBuffer.ref.version
    ]);
  }
  function Y(E, R, z) {
    let D = C0(), A, B = -1, T = -1, w = {
      kind: "points",
      pointCount: z,
      centerBuffer: C.create(E),
      groupBuffer: C.create(R),
      get boundingSphere() {
        let V = X(w);
        if (V !== B) {
          let P = w5(w.centerBuffer.ref.value, w.pointCount, 1);
          C0.copy(D, P), B = V;
        }
        return D;
      },
      get groupMapping() {
        if (w.groupBuffer.ref.version !== T)
          A = _3(w.groupBuffer.ref.value, w.pointCount), T = w.groupBuffer.ref.version;
        return A;
      },
      setBoundingSphere(V) {
        C0.copy(D, V), B = X(w);
      }
    };
    return w;
  }
  function Q(E, R, z, D) {
    return D.pointCount = z, C.update(D.centerBuffer, E), C.update(D.groupBuffer, R), D;
  }
  function W(E, R) {
    let z = E.centerBuffer.ref.value;
    SW(R, z, 0, E.pointCount), C.update(E.centerBuffer, z);
  }
  Z.transform = W, Z.StyleTypes = {
    square: "Square",
    circle: "Circle",
    fuzzy: "Fuzzy"
  }, Z.StyleTypeNames = Object.keys(Z.StyleTypes), Z.Params = {
    ...q1.Params,
    sizeFactor: j.Numeric(3, { min: 0, max: 10, step: 0.1 }),
    pointSizeAttenuation: j.Boolean(!1),
    pointStyle: j.Select("square", j.objectToOptions(Z.StyleTypes))
  }, Z.Utils = {
    Params: Z.Params,
    createEmpty: $,
    createValues: G,
    createValuesSimple: H,
    updateValues: N,
    updateBoundingSphere: q,
    createRenderableState: U,
    updateRenderableState: F,
    createPositionIterator: K
  };
  function K(E, R) {
    let z = E.pointCount, D = R.instanceCount.ref.value, A = b$(), B = A.position, T = E.centerBuffer.ref.value, w = R.aTransform.ref.value;
    return X6(z, D, 1, (P, I) => {
      if (I < 0)
        M.fromArray(B, T, P * 3);
      else
        M.transformMat4Offset(B, T, w, 0, P * 3, I * 16);
      return A;
    });
  }
  function G(E, R, z, D, A) {
    let { instanceCount: B, groupCount: T } = z, w = K(E, R), V = WJ(z, w, D.color), P = DY(z, D.size), I = A.instanceGranularity ? rZ(B, "instance") : rZ(B * T, "groupInstance"), S = LY(), f = RY(), v = zY(), h = OY(), x = EY(), b = { drawCount: E.pointCount, vertexCount: E.pointCount, groupCount: T, instanceCount: B }, g = C0.clone(E.boundingSphere), m = j7(g, R.aTransform.ref.value, B, 0);
    return {
      dGeometryType: C.create("points"),
      aPosition: E.centerBuffer,
      aGroup: E.groupBuffer,
      boundingSphere: C.create(m),
      invariantBoundingSphere: C.create(g),
      uInvariantBoundingSphere: C.create(E2.ofSphere(g)),
      ...V,
      ...P,
      ...I,
      ...S,
      ...f,
      ...v,
      ...h,
      ...x,
      ...R,
      ...q1.createValues(A, b),
      uSizeFactor: C.create(A.sizeFactor),
      dPointSizeAttenuation: C.create(A.pointSizeAttenuation),
      dPointStyle: C.create(A.pointStyle)
    };
  }
  function H(E, R, z, D, A) {
    let B = q1.createSimple(z, D, A), T = { ...j.getDefaultValues(Z.Params), ...R };
    return G(E, B.transform, B.locationIterator, B.theme, T);
  }
  function N(E, R) {
    q1.updateValues(E, R), C.updateIfChanged(E.uSizeFactor, R.sizeFactor), C.updateIfChanged(E.dPointSizeAttenuation, R.pointSizeAttenuation), C.updateIfChanged(E.dPointStyle, R.pointStyle);
  }
  function q(E, R) {
    let z = C0.clone(R.boundingSphere), D = j7(z, E.aTransform.ref.value, E.instanceCount.ref.value, 0);
    if (!C0.equals(D, E.boundingSphere.ref.value))
      C.update(E.boundingSphere, D);
    if (!C0.equals(z, E.invariantBoundingSphere.ref.value))
      C.update(E.invariantBoundingSphere, z), C.update(E.uInvariantBoundingSphere, E2.fromSphere(E.uInvariantBoundingSphere.ref.value, z));
  }
  function U(E) {
    let R = q1.createRenderableState(E);
    return F(R, E), R;
  }
  function F(E, R) {
    q1.updateRenderableState(E, R), E.opaque = E.opaque && R.pointStyle !== "fuzzy", E.writeDepth = E.opaque;
  }
})(YX || (YX = {}));

// node_modules/molstar/lib/mol-math/geometry/distance-transform.js
function Ra(Z, J, $, X, Y, Q, W) {
  for (let K = 0;K < J; K++) {
    for (let G = 0;G < $; G++)
      X[G] = Z[G * J + K];
    TE0(X, Y, Q, W, $);
    for (let G = 0;G < $; G++)
      Z[G * J + K] = Y[G];
  }
  for (let K = 0;K < $; K++) {
    for (let G = 0;G < J; G++)
      X[G] = Z[K * J + G];
    TE0(X, Y, Q, W, J);
    for (let G = 0;G < J; G++)
      Z[K * J + G] = Math.sqrt(Y[G]);
  }
}
function TE0(Z, J, $, X, Y) {
  $[0] = 0, X[0] = Number.MIN_SAFE_INTEGER, X[1] = Number.MAX_SAFE_INTEGER;
  for (let Q = 1, W = 0;Q < Y; Q++) {
    let K = (Z[Q] + Q * Q - (Z[$[W]] + $[W] * $[W])) / (2 * Q - 2 * $[W]);
    while (K <= X[W])
      W--, K = (Z[Q] + Q * Q - (Z[$[W]] + $[W] * $[W])) / (2 * Q - 2 * $[W]);
    W++, $[W] = Q, X[W] = K, X[W + 1] = Number.MAX_SAFE_INTEGER;
  }
  for (let Q = 0, W = 0;Q < Y; Q++) {
    while (X[W + 1] < Q)
      W++;
    J[Q] = (Q - $[W]) * (Q - $[W]) + Z[$[W]];
  }
}

// node_modules/molstar/lib/mol-geo/geometry/text/font-atlas.js
var Ea = {};
function VE0(Z) {
  let J = JSON.stringify(Z);
  if (Ea[J] === void 0)
    Ea[J] = new IE0(Z);
  return Ea[J];
}
var Oa = {
  fontFamily: j.Select("sans-serif", [["sans-serif", "Sans Serif"], ["monospace", "Monospace"], ["serif", "Serif"], ["cursive", "Cursive"]]),
  fontQuality: j.Select(3, [[0, "lower"], [1, "low"], [2, "medium"], [3, "high"], [4, "higher"]]),
  fontStyle: j.Select("normal", [["normal", "Normal"], ["italic", "Italic"], ["oblique", "Oblique"]]),
  fontVariant: j.Select("normal", [["normal", "Normal"], ["small-caps", "Small Caps"]]),
  fontWeight: j.Select("normal", [["normal", "Normal"], ["bold", "Bold"]])
};

class IE0 {
  constructor(Z = {}) {
    this.mapped = {}, this.scratchW = 0, this.scratchH = 0, this.currentX = 0, this.currentY = 0, this.cutoff = 0.5;
    let J = { ...j.getDefaultValues(Oa), ...Z };
    this.props = J;
    let $ = 32 * (J.fontQuality + 1);
    this.buffer = $ / 8, this.radius = $ / 3, this.lineHeight = Math.round($ + 2 * this.buffer + this.radius), this.maxWidth = Math.round(this.lineHeight * 0.75), this.texture = Z9(350 * this.lineHeight * this.maxWidth, 1, Uint8Array), this.scratchContext = k71(this.maxWidth, this.lineHeight, { willReadFrequently: !0 }), this.scratchContext.font = `${J.fontStyle} ${J.fontVariant} ${J.fontWeight} ${$}px ${J.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(String.fromCharCode(65533));
  }
  get(Z) {
    if (this.mapped[Z] === void 0) {
      this.draw(Z);
      let { array: J, width: $, height: X } = this.texture, Y = this.scratchData;
      if (this.currentX + this.scratchW > $)
        this.currentX = 0, this.currentY += this.scratchH;
      if (this.currentY + this.scratchH > X)
        return console.warn("canvas to small"), this.placeholder;
      this.mapped[Z] = {
        x: this.currentX,
        y: this.currentY,
        w: this.scratchW,
        h: this.scratchH,
        nw: this.scratchW / this.lineHeight,
        nh: this.scratchH / this.lineHeight
      };
      for (let Q = 0;Q < this.scratchH; ++Q)
        for (let W = 0;W < this.scratchW; ++W)
          J[$ * (this.currentY + Q) + this.currentX + W] = Y[Q * this.scratchW + W];
      this.currentX += this.scratchW;
    }
    return this.mapped[Z];
  }
  draw(Z) {
    let J = this.lineHeight, $ = this.scratchContext, X = this.scratchData, Y = $.measureText(Z), Q = Math.min(this.maxWidth, Math.ceil(Y.width + 2 * this.buffer)), W = Q * J;
    $.clearRect(0, 0, Q, J), $.fillText(Z, this.buffer, this.middle);
    let K = $.getImageData(0, 0, Q, J);
    for (let G = 0;G < W; G++) {
      let H = K.data[G * 4 + 3] / 255;
      this.gridOuter[G] = H === 1 ? 0 : H === 0 ? Number.MAX_SAFE_INTEGER : Math.pow(Math.max(0, 0.5 - H), 2), this.gridInner[G] = H === 1 ? Number.MAX_SAFE_INTEGER : H === 0 ? 0 : Math.pow(Math.max(0, H - 0.5), 2);
    }
    Ra(this.gridOuter, Q, J, this.f, this.d, this.v, this.z), Ra(this.gridInner, Q, J, this.f, this.d, this.v, this.z);
    for (let G = 0;G < W; G++) {
      let H = this.gridOuter[G] - this.gridInner[G];
      X[G] = Math.max(0, Math.min(255, Math.round(255 - 255 * (H / this.radius + this.cutoff))));
    }
    this.scratchW = Q, this.scratchH = J;
  }
}
var _E0;
function C71() {
  if (!_E0)
    throw new Error("When running in Node.js and wanting to use Canvas API, call mol-util/data-source's setCanvasModule function first and pass imported `canvas` module to it.");
  return _E0;
}
function k71(Z, J, $) {
  if (tG)
    return C71().createCanvas(Z, J).getContext("2d", $);
  else {
    let X = document.createElement("canvas");
    return X.width = Z, X.height = J, X.getContext("2d", $);
  }
}

// node_modules/molstar/lib/mol-geo/geometry/text/text.js
var IJ;
(function(Z) {
  function J(F, E, R, z, D, A, B, T, w) {
    return w ? Q(F, E, R, z, D, A, B, T, w) : Y(F, E, R, z, D, A, B, T);
  }
  Z.create = J;
  function $(F) {
    let E = F ? F.fontTexture.ref.value : Z9(0, 1, Uint8Array), R = F ? F.centerBuffer.ref.value : new Float32Array(0), z = F ? F.mappingBuffer.ref.value : new Float32Array(0), D = F ? F.depthBuffer.ref.value : new Float32Array(0), A = F ? F.indexBuffer.ref.value : new Uint32Array(0), B = F ? F.groupBuffer.ref.value : new Float32Array(0), T = F ? F.tcoordBuffer.ref.value : new Float32Array(0);
    return J(E, R, z, D, A, B, T, 0, F);
  }
  Z.createEmpty = $;
  function X(F) {
    return l9([
      F.charCount,
      F.fontTexture.ref.version,
      F.centerBuffer.ref.version,
      F.mappingBuffer.ref.version,
      F.depthBuffer.ref.version,
      F.indexBuffer.ref.version,
      F.groupBuffer.ref.version,
      F.tcoordBuffer.ref.version
    ]);
  }
  function Y(F, E, R, z, D, A, B, T) {
    let w = C0(), V, P = -1, I = -1, S = {
      kind: "text",
      charCount: T,
      fontTexture: C.create(F),
      centerBuffer: C.create(E),
      mappingBuffer: C.create(R),
      depthBuffer: C.create(z),
      indexBuffer: C.create(D),
      groupBuffer: C.create(A),
      tcoordBuffer: C.create(B),
      get boundingSphere() {
        let f = X(S);
        if (f !== P) {
          let v = w5(S.centerBuffer.ref.value, S.charCount * 4, 4);
          C0.copy(w, v), P = f;
        }
        return w;
      },
      get groupMapping() {
        if (S.groupBuffer.ref.version !== I)
          V = _3(S.groupBuffer.ref.value, S.charCount, 4), I = S.groupBuffer.ref.version;
        return V;
      },
      setBoundingSphere(f) {
        C0.copy(w, f), P = X(S);
      }
    };
    return S;
  }
  function Q(F, E, R, z, D, A, B, T, w) {
    return w.charCount = T, C.update(w.fontTexture, F), C.update(w.centerBuffer, E), C.update(w.mappingBuffer, R), C.update(w.depthBuffer, z), C.update(w.indexBuffer, D), C.update(w.groupBuffer, A), C.update(w.tcoordBuffer, B), w;
  }
  Z.Params = {
    ...q1.Params,
    ...Oa,
    sizeFactor: j.Numeric(1, { min: 0, max: 10, step: 0.1 }),
    borderWidth: j.Numeric(0, { min: 0, max: 0.5, step: 0.01 }),
    borderColor: j.Color(c2.grey),
    offsetX: j.Numeric(0, { min: 0, max: 10, step: 0.1 }),
    offsetY: j.Numeric(0, { min: 0, max: 10, step: 0.1 }),
    offsetZ: j.Numeric(0, { min: 0, max: 10, step: 0.1 }),
    background: j.Boolean(!1),
    backgroundMargin: j.Numeric(0.2, { min: 0, max: 1, step: 0.01 }),
    backgroundColor: j.Color(c2.grey),
    backgroundOpacity: j.Numeric(1, { min: 0, max: 1, step: 0.01 }),
    tether: j.Boolean(!1),
    tetherLength: j.Numeric(1, { min: 0, max: 5, step: 0.1 }),
    tetherBaseWidth: j.Numeric(0.3, { min: 0, max: 1, step: 0.01 }),
    attachment: j.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"]
    ])
  }, Z.Utils = {
    Params: Z.Params,
    createEmpty: $,
    createValues: K,
    createValuesSimple: G,
    updateValues: H,
    updateBoundingSphere: N,
    createRenderableState: q,
    updateRenderableState: U,
    createPositionIterator: W
  };
  function W(F, E) {
    let R = F.charCount * 4, z = E.instanceCount.ref.value, D = b$(), A = D.position, B = F.centerBuffer.ref.value, T = E.aTransform.ref.value;
    return X6(R, z, 4, (V, P) => {
      if (P < 0)
        M.fromArray(A, B, V * 3);
      else
        M.transformMat4Offset(A, B, T, 0, V * 3, P * 16);
      return D;
    });
  }
  function K(F, E, R, z, D) {
    let { instanceCount: A, groupCount: B } = R, T = W(F, E), w = WJ(R, T, z.color), V = DY(R, z.size), P = D.instanceGranularity ? rZ(A, "instance") : rZ(A * B, "groupInstance"), I = LY(), S = RY(), f = zY(), v = OY(), h = EY(), x = { drawCount: F.charCount * 2 * 3, vertexCount: F.charCount * 4, groupCount: B, instanceCount: A }, b = IR(V) * D.sizeFactor, g = PE0(F.mappingBuffer.ref.value, F.depthBuffer.ref.value, F.charCount, b), m = C0.expand(C0(), F.boundingSphere, g), i = j7(m, E.aTransform.ref.value, A, 0);
    return {
      dGeometryType: C.create("text"),
      aPosition: F.centerBuffer,
      aMapping: F.mappingBuffer,
      aDepth: F.depthBuffer,
      aGroup: F.groupBuffer,
      elements: F.indexBuffer,
      boundingSphere: C.create(i),
      invariantBoundingSphere: C.create(m),
      uInvariantBoundingSphere: C.create(E2.ofSphere(m)),
      ...w,
      ...V,
      ...P,
      ...I,
      ...S,
      ...f,
      ...v,
      ...h,
      ...E,
      aTexCoord: F.tcoordBuffer,
      tFont: F.fontTexture,
      padding: C.create(g),
      ...q1.createValues(D, x),
      uSizeFactor: C.create(D.sizeFactor),
      uBorderWidth: C.create(x8(D.borderWidth, 0, 0.5)),
      uBorderColor: C.create(i0.toArrayNormalized(D.borderColor, M.zero(), 0)),
      uOffsetX: C.create(D.offsetX),
      uOffsetY: C.create(D.offsetY),
      uOffsetZ: C.create(D.offsetZ),
      uBackgroundColor: C.create(i0.toArrayNormalized(D.backgroundColor, M.zero(), 0)),
      uBackgroundOpacity: C.create(D.backgroundOpacity)
    };
  }
  function G(F, E, R, z, D) {
    let A = q1.createSimple(R, z, D), B = { ...j.getDefaultValues(Z.Params), ...E };
    return K(F, A.transform, A.locationIterator, A.theme, B);
  }
  function H(F, E) {
    if (q1.updateValues(F, E), C.updateIfChanged(F.uSizeFactor, E.sizeFactor), C.updateIfChanged(F.uBorderWidth, E.borderWidth), i0.fromNormalizedArray(F.uBorderColor.ref.value, 0) !== E.borderColor)
      i0.toArrayNormalized(E.borderColor, F.uBorderColor.ref.value, 0), C.update(F.uBorderColor, F.uBorderColor.ref.value);
    if (C.updateIfChanged(F.uOffsetX, E.offsetX), C.updateIfChanged(F.uOffsetY, E.offsetY), C.updateIfChanged(F.uOffsetZ, E.offsetZ), i0.fromNormalizedArray(F.uBackgroundColor.ref.value, 0) !== E.backgroundColor)
      i0.toArrayNormalized(E.backgroundColor, F.uBackgroundColor.ref.value, 0), C.update(F.uBackgroundColor, F.uBackgroundColor.ref.value);
    C.updateIfChanged(F.uBackgroundOpacity, E.backgroundOpacity);
  }
  function N(F, E) {
    let R = IR(F) * F.uSizeFactor.ref.value, z = PE0(F.aMapping.ref.value, F.aDepth.ref.value, E.charCount, R), D = C0.expand(C0(), E.boundingSphere, z), A = j7(D, F.aTransform.ref.value, F.instanceCount.ref.value, 0);
    if (!C0.equals(A, F.boundingSphere.ref.value))
      C.update(F.boundingSphere, A);
    if (!C0.equals(D, F.invariantBoundingSphere.ref.value))
      C.update(F.invariantBoundingSphere, D), C.update(F.uInvariantBoundingSphere, E2.fromSphere(F.uInvariantBoundingSphere.ref.value, D));
    C.update(F.padding, z);
  }
  function q(F) {
    let E = q1.createRenderableState(F);
    return U(E, F), E;
  }
  function U(F, E) {
    q1.updateRenderableState(F, E), F.pickable = !1, F.opaque = !1, F.writeDepth = !0;
  }
})(IJ || (IJ = {}));
function PE0(Z, J, $, X) {
  let Y = 0, Q = 0;
  for (let W = 0, K = $ * 4;W < K; ++W) {
    let G = 2 * W, H = Math.abs(Z[G]);
    if (H > Y)
      Y = H;
    let N = Math.abs(Z[G + 1]);
    if (N > Y)
      Y = N;
    let q = Math.abs(J[W]);
    if (q > Q)
      Q = q;
  }
  return Math.max(Q, X * Y);
}

// node_modules/molstar/lib/mol-geo/geometry/lines/lines-builder.js
var fW = M(), LH = M(), LV = M(), CE0 = B1.add, vh = B1.add3, L$;
(function(Z) {
  function J($ = 2048, X = 1024, Y) {
    let Q = B1.create(Float32Array, 1, X, Y ? Y.groupBuffer.ref.value : $), W = B1.create(Float32Array, 3, X, Y ? Y.startBuffer.ref.value : $), K = B1.create(Float32Array, 3, X, Y ? Y.endBuffer.ref.value : $), G = (q, U, F, E, R, z, D) => {
      for (let A = 0;A < 4; ++A)
        vh(W, q, U, F), vh(K, E, R, z), CE0(Q, D);
    }, H = (q, U, F) => {
      for (let E = 0;E < 4; ++E)
        vh(W, q[0], q[1], q[2]), vh(K, U[0], U[1], U[2]), CE0(Q, F);
    }, N = (q, U, F, E) => {
      let R = M.distance(q, U), z = F % 2 !== 0, D = Math.floor((F + 1) / 2), A = R / (F + 0.5);
      M.setMagnitude(LV, M.sub(LV, U, q), A), M.copy(fW, q);
      for (let B = 0;B < D; ++B) {
        if (M.add(fW, fW, LV), z && B === D - 1)
          M.copy(LH, U);
        else
          M.add(LH, fW, LV);
        G(fW[0], fW[1], fW[2], LH[0], LH[1], LH[2], E), M.add(fW, fW, LV);
      }
    };
    return {
      add: G,
      addVec: H,
      addFixedCountDashes: N,
      addFixedLengthDashes: (q, U, F, E) => {
        let R = M.distance(q, U);
        N(q, U, R / F, E);
      },
      addCage: (q, U, F) => {
        let { vertices: E, edges: R } = U;
        for (let z = 0, D = R.length;z < D; z += 2)
          M.fromArray(fW, E, R[z] * 3), M.fromArray(LH, E, R[z + 1] * 3), M.transformMat4(fW, fW, q), M.transformMat4(LH, LH, q), G(fW[0], fW[1], fW[2], LH[0], LH[1], LH[2], F);
      },
      getLines: () => {
        let q = Q.elementCount / 4, U = B1.compact(Q, !0), F = B1.compact(W, !0), E = B1.compact(K, !0), R = Y && q <= Y.lineCount ? Y.mappingBuffer.ref.value : new Float32Array(q * 8), z = Y && q <= Y.lineCount ? Y.indexBuffer.ref.value : new Uint32Array(q * 6);
        if (!Y || q > Y.lineCount)
          v71(q, R, z);
        return f6.create(R, z, U, F, E, q, Y);
      }
    };
  }
  Z.create = J;
})(L$ || (L$ = {}));
function v71(Z, J, $) {
  for (let X = 0;X < Z; ++X) {
    let Y = X * 8;
    J[Y] = -1, J[Y + 1] = -1, J[Y + 2] = 1, J[Y + 3] = -1, J[Y + 4] = -1, J[Y + 5] = 1, J[Y + 6] = 1, J[Y + 7] = 1;
  }
  for (let X = 0;X < Z; ++X) {
    let Y = X * 4, Q = X * 6;
    $[Q] = Y, $[Q + 1] = Y + 1, $[Q + 2] = Y + 2, $[Q + 3] = Y + 1, $[Q + 4] = Y + 3, $[Q + 5] = Y + 2;
  }
}

// node_modules/molstar/lib/mol-geo/geometry/lines/lines.js
var f6;
(function(Z) {
  function J(F, E, R, z, D, A, B) {
    return B ? W(F, E, R, z, D, A, B) : Q(F, E, R, z, D, A);
  }
  Z.create = J;
  function $(F) {
    let E = F ? F.mappingBuffer.ref.value : new Float32Array(0), R = F ? F.indexBuffer.ref.value : new Uint32Array(0), z = F ? F.groupBuffer.ref.value : new Float32Array(0), D = F ? F.startBuffer.ref.value : new Float32Array(0), A = F ? F.endBuffer.ref.value : new Float32Array(0);
    return J(E, R, z, D, A, 0, F);
  }
  Z.createEmpty = $;
  function X(F, E) {
    let R = F.vertexBuffer.ref.value, z = F.indexBuffer.ref.value, D = F.groupBuffer.ref.value, A = L$.create(F.triangleCount * 3, F.triangleCount / 10, E);
    for (let B = 0, T = F.triangleCount * 3;B < T; B += 3) {
      let w = z[B], V = z[B + 1], P = z[B + 2], I = R[w * 3], S = R[w * 3 + 1], f = R[w * 3 + 2], v = R[V * 3], h = R[V * 3 + 1], x = R[V * 3 + 2], b = R[P * 3], g = R[P * 3 + 1], m = R[P * 3 + 2];
      A.add(I, S, f, v, h, x, D[w]), A.add(I, S, f, b, g, m, D[w]), A.add(v, h, x, b, g, m, D[V]);
    }
    return A.getLines();
  }
  Z.fromMesh = X;
  function Y(F) {
    return l9([
      F.lineCount,
      F.mappingBuffer.ref.version,
      F.indexBuffer.ref.version,
      F.groupBuffer.ref.version,
      F.startBuffer.ref.version,
      F.endBuffer.ref.version
    ]);
  }
  function Q(F, E, R, z, D, A) {
    let B = C0(), T, w = -1, V = -1, P = {
      kind: "lines",
      lineCount: A,
      mappingBuffer: C.create(F),
      indexBuffer: C.create(E),
      groupBuffer: C.create(R),
      startBuffer: C.create(z),
      endBuffer: C.create(D),
      get boundingSphere() {
        let I = Y(P);
        if (I !== w) {
          let S = w5(P.startBuffer.ref.value, P.lineCount * 4, 4), f = w5(P.endBuffer.ref.value, P.lineCount * 4, 4);
          C0.expandBySphere(B, S, f), w = I;
        }
        return B;
      },
      get groupMapping() {
        if (P.groupBuffer.ref.version !== V)
          T = _3(P.groupBuffer.ref.value, P.lineCount, 4), V = P.groupBuffer.ref.version;
        return T;
      },
      setBoundingSphere(I) {
        C0.copy(B, I), w = Y(P);
      }
    };
    return P;
  }
  function W(F, E, R, z, D, A, B) {
    if (A > B.lineCount)
      C.update(B.mappingBuffer, F), C.update(B.indexBuffer, E);
    return B.lineCount = A, C.update(B.groupBuffer, R), C.update(B.startBuffer, z), C.update(B.endBuffer, D), B;
  }
  function K(F, E) {
    let R = F.startBuffer.ref.value;
    SW(E, R, 0, F.lineCount * 4), C.update(F.startBuffer, R);
    let z = F.endBuffer.ref.value;
    SW(E, z, 0, F.lineCount * 4), C.update(F.endBuffer, z);
  }
  Z.transform = K, Z.Params = {
    ...q1.Params,
    sizeFactor: j.Numeric(2, { min: 0, max: 10, step: 0.1 }),
    lineSizeAttenuation: j.Boolean(!1)
  }, Z.Utils = {
    Params: Z.Params,
    createEmpty: $,
    createValues: H,
    createValuesSimple: N,
    updateValues: q,
    updateBoundingSphere: U,
    createRenderableState: q1.createRenderableState,
    updateRenderableState: q1.updateRenderableState,
    createPositionIterator: G
  };
  function G(F, E) {
    let R = F.lineCount * 4, z = E.instanceCount.ref.value, D = b$(), A = D.position, B = F.startBuffer.ref.value, T = F.endBuffer.ref.value, w = E.aTransform.ref.value;
    return X6(R, z, 2, (P, I) => {
      let S = P % 4 === 0 ? B : T;
      if (I < 0)
        M.fromArray(A, S, P * 3);
      else
        M.transformMat4Offset(A, S, w, 0, P * 3, I * 16);
      return D;
    });
  }
  function H(F, E, R, z, D) {
    let { instanceCount: A, groupCount: B } = R, T = G(F, E), w = WJ(R, T, z.color), V = DY(R, z.size), P = D.instanceGranularity ? rZ(A, "instance") : rZ(A * B, "groupInstance"), I = LY(), S = RY(), f = zY(), v = OY(), h = EY(), x = { drawCount: F.lineCount * 2 * 3, vertexCount: F.lineCount * 4, groupCount: B, instanceCount: A }, b = C0.clone(F.boundingSphere), g = j7(b, E.aTransform.ref.value, A, 0);
    return {
      dGeometryType: C.create("lines"),
      aMapping: F.mappingBuffer,
      aGroup: F.groupBuffer,
      aStart: F.startBuffer,
      aEnd: F.endBuffer,
      elements: F.indexBuffer,
      boundingSphere: C.create(g),
      invariantBoundingSphere: C.create(b),
      uInvariantBoundingSphere: C.create(E2.ofSphere(b)),
      ...w,
      ...V,
      ...P,
      ...I,
      ...S,
      ...f,
      ...v,
      ...h,
      ...E,
      ...q1.createValues(D, x),
      uSizeFactor: C.create(D.sizeFactor),
      dLineSizeAttenuation: C.create(D.lineSizeAttenuation),
      uDoubleSided: C.create(!0),
      dFlipSided: C.create(!1)
    };
  }
  function N(F, E, R, z, D) {
    let A = q1.createSimple(R, z, D), B = { ...j.getDefaultValues(Z.Params), ...E };
    return H(F, A.transform, A.locationIterator, A.theme, B);
  }
  function q(F, E) {
    q1.updateValues(F, E), C.updateIfChanged(F.uSizeFactor, E.sizeFactor), C.updateIfChanged(F.dLineSizeAttenuation, E.lineSizeAttenuation);
  }
  function U(F, E) {
    let R = C0.clone(E.boundingSphere), z = j7(R, F.aTransform.ref.value, F.instanceCount.ref.value, 0);
    if (!C0.equals(z, F.boundingSphere.ref.value))
      C.update(F.boundingSphere, z);
    if (!C0.equals(R, F.invariantBoundingSphere.ref.value))
      C.update(F.invariantBoundingSphere, R), C.update(F.uInvariantBoundingSphere, E2.fromSphere(F.uInvariantBoundingSphere.ref.value, R));
  }
})(f6 || (f6 = {}));

// node_modules/molstar/lib/mol-geo/primitive/primitive.js
var kE0 = M(), vE0 = M(), SE0 = M();
function Dz(Z, J) {
  let $ = J.length, X = RH($ / 3);
  for (let Y = 0;Y < $; Y += 3)
    M.fromArray(kE0, Z, J[Y] * 3), M.fromArray(vE0, Z, J[Y + 1] * 3), M.fromArray(SE0, Z, J[Y + 2] * 3), X.add(kE0, vE0, SE0);
  return X.getPrimitive();
}
var Sh = M();
function RH(Z, J) {
  if (J === void 0)
    J = Z * 3;
  let $ = new Float32Array(J * 3), X = new Float32Array(J * 3), Y = new Uint32Array(Z * 3), Q = 0, W = 0;
  return {
    add: (K, G, H) => {
      M.toArray(K, $, Q), M.toArray(G, $, Q + 3), M.toArray(H, $, Q + 6), M.triangleNormal(Sh, K, G, H);
      for (let N = 0;N < 3; ++N)
        M.toArray(Sh, X, Q + 3 * N), Y[W + N] = Q / 3 + N;
      Q += 9, W += 3;
    },
    addQuad: (K, G, H, N) => {
      M.toArray(K, $, Q), M.toArray(G, $, Q + 3), M.toArray(H, $, Q + 6), M.toArray(N, $, Q + 9), M.triangleNormal(Sh, K, G, H);
      for (let U = 0;U < 4; ++U)
        M.toArray(Sh, X, Q + 3 * U);
      let q = Q / 3;
      Y[W] = q, Y[W + 1] = q + 1, Y[W + 2] = q + 2, Y[W + 3] = q + 2, Y[W + 4] = q + 3, Y[W + 5] = q, Q += 12, W += 6;
    },
    getPrimitive: () => ({ vertices: $, normals: X, indices: Y })
  };
}
var RA = M(), S71 = h2();
function EA(Z, J) {
  let { vertices: $, normals: X } = Z, Y = h2.directionTransform(S71, J);
  for (let Q = 0, W = $.length;Q < W; Q += 3)
    M.transformMat4(RA, M.fromArray(RA, $, Q), J), M.toArray(RA, $, Q), M.transformMat3(RA, M.fromArray(RA, X, Q), Y), M.toArray(RA, X, Q);
  return Z;
}

// node_modules/molstar/lib/mol-geo/primitive/polygon.js
function hW(Z, J, $ = -1) {
  let X = new Float32Array(Z * 3), Y = $ === -1 ? Z <= 4 ? Math.sqrt(2) / 2 : 0.6 : $, Q = J ? 1 : 0;
  for (let W = 0, K = Z;W < K; ++W) {
    let G = (W * 2 + Q) / Z * Math.PI;
    X[W * 3] = Math.cos(G) * Y, X[W * 3 + 1] = Math.sin(G) * Y, X[W * 3 + 2] = 0;
  }
  return X;
}

// node_modules/molstar/lib/mol-geo/primitive/cage.js
function uN(Z, J) {
  return { vertices: Z, edges: J };
}
function Da(Z) {
  return {
    vertices: new Float32Array(Z.vertices),
    edges: new Uint32Array(Z.edges)
  };
}
var za = M.zero();
function Ma(Z, J) {
  let { vertices: $ } = Z;
  for (let X = 0, Y = $.length;X < Y; X += 3)
    M.transformMat4(za, M.fromArray(za, $, X), J), M.toArray(za, $, X);
  return Z;
}

// node_modules/molstar/lib/mol-geo/primitive/box.js
var eF = M(), ZU = M(), JU = M(), OA = M(), PJ = hW(4, !0);
function fE0(Z) {
  let X = RH(12, Z ? 36 : 24);
  for (let Y = 0;Y < 4; ++Y) {
    let Q = (Y + 1) % 4;
    if (M.set(eF, PJ[Y * 3], PJ[Y * 3 + 1], -0.5), M.set(ZU, PJ[Q * 3], PJ[Q * 3 + 1], -0.5), M.set(JU, PJ[Q * 3], PJ[Q * 3 + 1], 0.5), M.set(OA, PJ[Y * 3], PJ[Y * 3 + 1], 0.5), Z)
      X.add(eF, ZU, JU);
    else
      X.addQuad(eF, ZU, JU, OA);
  }
  if (M.set(eF, PJ[0], PJ[1], -0.5), M.set(ZU, PJ[3], PJ[4], -0.5), M.set(JU, PJ[6], PJ[7], -0.5), M.set(OA, PJ[9], PJ[10], -0.5), Z)
    X.add(JU, ZU, eF);
  else
    X.addQuad(OA, JU, ZU, eF);
  if (M.set(eF, PJ[0], PJ[1], 0.5), M.set(ZU, PJ[3], PJ[4], 0.5), M.set(JU, PJ[6], PJ[7], 0.5), M.set(OA, PJ[9], PJ[10], 0.5), Z)
    X.add(eF, ZU, JU);
  else
    X.addQuad(eF, ZU, JU, OA);
  return X.getPrimitive();
}
var Aa;
function zA() {
  if (!Aa)
    Aa = fE0(!1);
  return Aa;
}
var Ba;
function hE0() {
  if (!Ba)
    Ba = fE0(!0);
  return Ba;
}
var wa;
function fh() {
  if (!wa)
    wa = uN([
      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
    ]);
  return wa;
}

// node_modules/molstar/lib/mol-geo/geometry/direct-volume/transfer-function.js
function ja(Z) {
  return Z.map((J) => ({ x: J[0], alpha: J[1] }));
}
function Ta(Z, J) {
  let $ = [
    { x: 0, alpha: 0 },
    { x: 0, alpha: 0 },
    ...Z,
    { x: 1, alpha: 0 },
    { x: 1, alpha: 0 }
  ], X = 256, Y = J ? J.ref.value.array : new Uint8Array(256), Q = 0, W, K, G, H, N, q, U = Z.length + 1;
  for (let E = 0;E < U; ++E) {
    W = $[E + 1].x, K = $[E + 2].x, G = $[E].alpha, H = $[E + 1].alpha, N = $[E + 2].alpha, q = $[E + 3].alpha;
    let R = Math.round((K - W) * 256);
    for (let z = 0;z < R; ++z) {
      let D = z / R;
      Y[Q] = Math.max(0, DM(G, H, N, q, D, 0.5) * 255), ++Q;
    }
  }
  let F = { array: Y, width: 256, height: 1 };
  if (J)
    return C.update(J, F), J;
  else
    return C.create(F);
}

// node_modules/molstar/lib/mol-geo/geometry/direct-volume/direct-volume.js
var _a = zA(), gX;
(function(Z) {
  function J(z, D, A, B, T, w, V, P, I, S, f) {
    return f ? Y(z, D, A, B, T, w, V, P, I, S, f) : X(z, D, A, B, T, w, V, P, I, S);
  }
  Z.create = J;
  function $(z) {
    return l9([
      z.bboxSize.ref.version,
      z.gridDimension.ref.version,
      z.gridTexture.ref.version,
      z.transform.ref.version,
      z.gridStats.ref.version
    ]);
  }
  function X(z, D, A, B, T, w, V, P, I, S) {
    let f = C0(), v = -1, h = w.getWidth(), x = w.getHeight(), b = w.getDepth(), g = {
      kind: "direct-volume",
      gridDimension: C.create(D),
      gridTexture: C.create(w),
      gridTextureDim: C.create(M.create(h, x, b)),
      gridStats: C.create(E2.create(V.min, V.max, V.mean, V.sigma)),
      bboxMin: C.create(z.min),
      bboxMax: C.create(z.max),
      bboxSize: C.create(M.sub(M(), z.max, z.min)),
      transform: C.create(A),
      cellDim: C.create(T),
      unitToCartn: C.create(B),
      cartnToUnit: C.create(e.invert(e(), B)),
      get boundingSphere() {
        let m = $(g);
        if (m !== v) {
          let i = f71(g.gridDimension.ref.value, g.transform.ref.value);
          C0.copy(f, i), v = m;
        }
        return f;
      },
      packedGroup: C.create(P),
      axisOrder: C.create(I),
      dataType: C.create(S),
      setBoundingSphere(m) {
        C0.copy(f, m), v = $(g);
      },
      meta: {}
    };
    return g;
  }
  function Y(z, D, A, B, T, w, V, P, I, S, f) {
    let v = w.getWidth(), h = w.getHeight(), x = w.getDepth();
    return C.update(f.gridDimension, D), C.update(f.gridTexture, w), C.update(f.gridTextureDim, M.set(f.gridTextureDim.ref.value, v, h, x)), C.update(f.gridStats, E2.set(f.gridStats.ref.value, V.min, V.max, V.mean, V.sigma)), C.update(f.bboxMin, z.min), C.update(f.bboxMax, z.max), C.update(f.bboxSize, M.sub(f.bboxSize.ref.value, z.max, z.min)), C.update(f.transform, A), C.update(f.cellDim, T), C.update(f.unitToCartn, B), C.update(f.cartnToUnit, e.invert(e(), B)), C.updateIfChanged(f.packedGroup, P), C.updateIfChanged(f.axisOrder, M.fromArray(f.axisOrder.ref.value, I, 0)), C.updateIfChanged(f.dataType, S), f;
  }
  function Q(z) {
    let D = t1(), A = M(), B = e.identity(), T = e.identity(), w = M(), V = k9(), P = s6.One.stats, I = !1, S = M.create(0, 1, 2), f = "byte";
    return J(D, A, B, T, w, V, P, !1, S, "byte", z);
  }
  Z.createEmpty = Q, Z.Params = {
    ...q1.Params,
    ignoreLight: j.Boolean(!1, q1.ShadingCategory),
    celShaded: j.Boolean(!1, q1.ShadingCategory),
    xrayShaded: j.Select(!1, [[!1, "Off"], [!0, "On"], ["inverted", "Inverted"]], q1.ShadingCategory),
    controlPoints: j.LineGraph([
      h0.create(0.19, 0),
      h0.create(0.2, 0.05),
      h0.create(0.25, 0.05),
      h0.create(0.26, 0),
      h0.create(0.79, 0),
      h0.create(0.8, 0.05),
      h0.create(0.85, 0.05),
      h0.create(0.86, 0)
    ], { isEssential: !0 }),
    stepsPerCell: j.Numeric(3, { min: 1, max: 10, step: 1 }),
    jumpLength: j.Numeric(0, { min: 0, max: 20, step: 0.1 })
  }, Z.Utils = {
    Params: Z.Params,
    createEmpty: Q,
    createValues: N,
    createValuesSimple: q,
    updateValues: U,
    updateBoundingSphere: F,
    createRenderableState: E,
    updateRenderableState: R,
    createPositionIterator: W
  };
  function W(z, D) {
    let A = z.transform.ref.value, [B, T, w] = z.gridDimension.ref.value, V = B * T * w, P = D.instanceCount.ref.value, I = b$(), S = I.position, f = D.aTransform.ref.value;
    return X6(V, P, 1, (h, x) => {
      let b = Math.floor(h / w);
      if (S[0] = Math.floor(b / T), S[1] = b % T, S[2] = h % w, M.transformMat4(S, S, A), x >= 0)
        M.transformMat4Offset(S, S, f, 0, 0, x * 16);
      return I;
    });
  }
  function K(z, D) {
    return Math.ceil(M.magnitude(z) * D);
  }
  function G(z, D) {
    return Math.min(...z) * (1 / D);
  }
  function H(z) {
    return 1 / z;
  }
  function N(z, D, A, B, T) {
    let { gridTexture: w, gridTextureDim: V, gridStats: P } = z, { bboxSize: I, bboxMin: S, bboxMax: f, gridDimension: v, transform: h } = z, { instanceCount: x, groupCount: b } = A, g = W(z, D), m = WJ(A, g, B.color), i = T.instanceGranularity ? rZ(x, "instance") : rZ(x * b, "groupInstance"), r = LY(), Y0 = RY(), c = zY(), n = OY(), l = EY(), [u, G0, F0] = v.ref.value, t = { drawCount: _a.indices.length, vertexCount: u * G0 * F0, groupCount: b, instanceCount: x }, Z0 = C0.clone(z.boundingSphere), U0 = j7(Z0, D.aTransform.ref.value, x, 0), a = ja(T.controlPoints), Q0 = Ta(a);
    return {
      dGeometryType: C.create("directVolume"),
      ...m,
      ...i,
      ...r,
      ...Y0,
      ...c,
      ...n,
      ...l,
      ...D,
      ...q1.createValues(T, t),
      aPosition: C.create(_a.vertices),
      elements: C.create(_a.indices),
      boundingSphere: C.create(U0),
      invariantBoundingSphere: C.create(Z0),
      uInvariantBoundingSphere: C.create(E2.ofSphere(Z0)),
      uBboxMin: S,
      uBboxMax: f,
      uBboxSize: I,
      uMaxSteps: C.create(K(v.ref.value, T.stepsPerCell)),
      uStepScale: C.create(G(z.cellDim.ref.value, T.stepsPerCell)),
      uJumpLength: C.create(T.jumpLength),
      uTransform: h,
      uGridDim: v,
      tTransferTex: Q0,
      uTransferScale: C.create(H(T.stepsPerCell)),
      dGridTexType: C.create(w.ref.value.getDepth() > 0 ? "3d" : "2d"),
      uGridTexDim: V,
      tGridTex: w,
      uGridStats: P,
      uCellDim: z.cellDim,
      uCartnToUnit: z.cartnToUnit,
      uUnitToCartn: z.unitToCartn,
      dPackedGroup: z.packedGroup,
      dAxisOrder: C.create(z.axisOrder.ref.value.join("")),
      dIgnoreLight: C.create(T.ignoreLight),
      dCelShaded: C.create(T.celShaded),
      dXrayShaded: C.create(T.xrayShaded === "inverted" ? "inverted" : T.xrayShaded === !0 ? "on" : "off"),
      meta: C.create(z.meta)
    };
  }
  function q(z, D, A, B, T) {
    let w = q1.createSimple(A, B, T), V = { ...j.getDefaultValues(Z.Params), ...D };
    return N(z, w.transform, w.locationIterator, w.theme, V);
  }
  function U(z, D) {
    q1.updateValues(z, D), C.updateIfChanged(z.dIgnoreLight, D.ignoreLight), C.updateIfChanged(z.dCelShaded, D.celShaded), C.updateIfChanged(z.dXrayShaded, D.xrayShaded === "inverted" ? "inverted" : D.xrayShaded === !0 ? "on" : "off");
    let A = ja(D.controlPoints);
    Ta(A, z.tTransferTex), C.updateIfChanged(z.uMaxSteps, K(z.uGridDim.ref.value, D.stepsPerCell)), C.updateIfChanged(z.uStepScale, G(z.uCellDim.ref.value, D.stepsPerCell)), C.updateIfChanged(z.uTransferScale, H(D.stepsPerCell)), C.updateIfChanged(z.uJumpLength, D.jumpLength);
  }
  function F(z, D) {
    let A = C0.clone(D.boundingSphere), B = j7(A, z.aTransform.ref.value, z.instanceCount.ref.value, 0);
    if (!C0.equals(B, z.boundingSphere.ref.value))
      C.update(z.boundingSphere, B);
    if (!C0.equals(A, z.invariantBoundingSphere.ref.value))
      C.update(z.invariantBoundingSphere, A), C.update(z.uInvariantBoundingSphere, E2.fromSphere(z.uInvariantBoundingSphere.ref.value, A));
  }
  function E(z) {
    let D = q1.createRenderableState(z);
    return D.opaque = !1, D.writeDepth = !1, D;
  }
  function R(z, D) {
    q1.updateRenderableState(z, D), z.opaque = !1, z.writeDepth = !1;
  }
})(gX || (gX = {}));
function f71(Z, J) {
  return C0.fromDimensionsAndTransform(C0(), Z, J);
}

// node_modules/molstar/lib/mol-geo/geometry/spheres/spheres.js
var R$;
(function(Z) {
  function J(B, T, w, V) {
    return V ? Q(B, T, w, V) : Y(B, T, w);
  }
  Z.create = J;
  function $(B) {
    let T = B ? B.centerBuffer.ref.value : new Float32Array(0), w = B ? B.groupBuffer.ref.value : new Float32Array(0);
    return J(T, w, 0, B);
  }
  Z.createEmpty = $;
  function X(B) {
    return l9([
      B.sphereCount,
      B.centerBuffer.ref.version,
      B.groupBuffer.ref.version
    ]);
  }
  function Y(B, T, w) {
    let V = C0(), P, I = -1, S = -1, f = C.create(Z9(1, 4, Float32Array)), v = C.create(h0.create(0, 0)), h = C.create([]), x = C.create(0), b = {
      kind: "spheres",
      sphereCount: w,
      centerBuffer: C.create(B),
      groupBuffer: C.create(T),
      get boundingSphere() {
        let g = X(b);
        if (g !== I) {
          let m = w5(b.centerBuffer.ref.value, b.sphereCount, 1);
          C0.copy(V, m), I = g;
        }
        return V;
      },
      get groupMapping() {
        if (b.groupBuffer.ref.version !== S)
          P = _3(b.groupBuffer.ref.value, b.sphereCount), S = b.groupBuffer.ref.version;
        return P;
      },
      setBoundingSphere(g) {
        C0.copy(V, g), I = X(b);
      },
      shaderData: {
        positionGroup: f,
        texDim: v,
        lodLevels: h,
        sizeFactor: x,
        update(g) {
          var m, i;
          let r = (m = g === null || g === void 0 ? void 0 : g.lodLevels) !== null && m !== void 0 ? m : H(h.ref.value), Y0 = (i = g === null || g === void 0 ? void 0 : g.sizeFactor) !== null && i !== void 0 ? i : x.ref.value, c = q(r, Y0), n = Z9(b.sphereCount, 4, Float32Array, f.ref.value.array), l = W(n, b.centerBuffer.ref.value, b.groupBuffer.ref.value, b.sphereCount, c), u = l ? G(r, Y0, l, b.sphereCount) : [];
          C.update(f, n), C.update(v, h0.set(v.ref.value, n.width, n.height)), C.update(h, u), C.update(x, Y0);
        }
      }
    };
    return b.shaderData.update(), b;
  }
  function Q(B, T, w, V) {
    return V.sphereCount = w, C.update(V.centerBuffer, B), C.update(V.groupBuffer, T), V.shaderData.update(), V;
  }
  function W(B, T, w, V, P) {
    let { array: I } = B;
    if (P.length === 0) {
      for (let v = 0;v < V; ++v)
        I[v * 4 + 0] = T[v * 3 + 0], I[v * 4 + 1] = T[v * 3 + 1], I[v * 4 + 2] = T[v * 3 + 2], I[v * 4 + 3] = w[v];
      return;
    }
    let S = [0], f = 0;
    for (let v = 0, h = P.length;v < h; ++v) {
      let x = P[v];
      for (let b = 0;b < V; ++b) {
        let g = !1;
        for (let m = 0;m < v; ++m)
          if (b % P[m] === 0) {
            g = !0;
            break;
          }
        if (!g && b % x === 0)
          I[f * 4 + 0] = T[b * 3 + 0], I[f * 4 + 1] = T[b * 3 + 1], I[f * 4 + 2] = T[b * 3 + 2], I[f * 4 + 3] = w[b], f += 1;
      }
      S.push(f * 6);
    }
    return S;
  }
  function K(B, T) {
    if (B.length !== T.length)
      return !1;
    for (let w = 0, V = B.length;w < V; ++w) {
      if (B[w].maxDistance !== T[w].maxDistance)
        return !1;
      if (B[w].minDistance !== T[w].minDistance)
        return !1;
      if (B[w].overlap !== T[w].overlap)
        return !1;
      if (B[w].stride !== T[w].stride)
        return !1;
      if (B[w].scaleBias !== T[w].scaleBias)
        return !1;
    }
    return !0;
  }
  function G(B, T, w, V) {
    return B.map((P, I) => {
      let S = N(P, T);
      return [
        P.minDistance,
        P.maxDistance,
        P.overlap,
        w[w.length - 1 - I],
        Math.pow(Math.min(V, S), 1 / P.scaleBias),
        P.stride,
        P.scaleBias
      ];
    });
  }
  function H(B) {
    return B.map((T) => ({
      minDistance: T[0],
      maxDistance: T[1],
      overlap: T[2],
      stride: T[5],
      scaleBias: T[6]
    }));
  }
  function N(B, T) {
    return Math.max(1, Math.round(B.stride / Math.pow(T, B.scaleBias)));
  }
  function q(B, T) {
    return B.map((w) => N(w, T)).reverse();
  }
  Z.Params = {
    ...q1.Params,
    sizeFactor: j.Numeric(1, { min: 0, max: 10, step: 0.1 }),
    doubleSided: j.Boolean(!1, q1.CustomQualityParamInfo),
    ignoreLight: j.Boolean(!1, q1.ShadingCategory),
    celShaded: j.Boolean(!1, q1.ShadingCategory),
    xrayShaded: j.Select(!1, [[!1, "Off"], [!0, "On"], ["inverted", "Inverted"]], q1.ShadingCategory),
    transparentBackfaces: j.Select("off", j.arrayToOptions(["off", "on", "opaque"]), q1.ShadingCategory),
    solidInterior: j.Boolean(!0, q1.ShadingCategory),
    clipPrimitive: j.Boolean(!1, { ...q1.ShadingCategory, description: "Clip whole sphere instead of cutting it." }),
    approximate: j.Boolean(!1, { ...q1.ShadingCategory, description: "Faster rendering, but has artifacts." }),
    alphaThickness: j.Numeric(0, { min: 0, max: 20, step: 1 }, { ...q1.ShadingCategory, description: "If not zero, adjusts alpha for radius." }),
    bumpFrequency: j.Numeric(0, { min: 0, max: 10, step: 0.1 }, q1.ShadingCategory),
    bumpAmplitude: j.Numeric(1, { min: 0, max: 5, step: 0.1 }, q1.ShadingCategory),
    interior: I3(),
    lodLevels: j.ObjectList({
      minDistance: j.Numeric(0),
      maxDistance: j.Numeric(0),
      overlap: j.Numeric(0),
      stride: j.Numeric(0),
      scaleBias: j.Numeric(3, { min: 0.1, max: 10, step: 0.1 })
    }, (B) => `${B.stride}`, {
      ...q1.CullingLodCategory,
      defaultValue: []
    })
  }, Z.Utils = {
    Params: Z.Params,
    createEmpty: $,
    createValues: F,
    createValuesSimple: E,
    updateValues: R,
    updateBoundingSphere: z,
    createRenderableState: D,
    updateRenderableState: A,
    createPositionIterator: U
  };
  function U(B, T) {
    let w = B.sphereCount, V = T.instanceCount.ref.value, P = b$(), I = P.position, S = B.centerBuffer.ref.value, f = T.aTransform.ref.value;
    return X6(w, V, 1, (h, x) => {
      if (x < 0)
        M.fromArray(I, S, h * 3);
      else
        M.transformMat4Offset(I, S, f, 0, h * 3, x * 16);
      return P;
    });
  }
  function F(B, T, w, V, P) {
    let { instanceCount: I, groupCount: S } = w, f = U(B, T), v = WJ(w, f, V.color), h = DY(w, V.size), x = P.instanceGranularity ? rZ(I, "instance") : rZ(I * S, "groupInstance"), b = LY(), g = RY(), m = zY(), i = OY(), r = EY(), Y0 = { drawCount: B.sphereCount * 2 * 3, vertexCount: B.sphereCount * 6, groupCount: S, instanceCount: I }, c = B.boundingSphere.radius ? IR(h) * P.sizeFactor : 0, n = C0.expand(C0(), B.boundingSphere, c), l = j7(n, T.aTransform.ref.value, I, 0);
    return B.shaderData.update({ lodLevels: P.lodLevels, sizeFactor: P.sizeFactor }), {
      dGeometryType: C.create("spheres"),
      uTexDim: B.shaderData.texDim,
      tPositionGroup: B.shaderData.positionGroup,
      boundingSphere: C.create(l),
      invariantBoundingSphere: C.create(n),
      uInvariantBoundingSphere: C.create(E2.ofSphere(n)),
      ...v,
      ...h,
      ...x,
      ...b,
      ...g,
      ...m,
      ...i,
      ...r,
      ...T,
      padding: C.create(c),
      ...q1.createValues(P, Y0),
      uSizeFactor: B.shaderData.sizeFactor,
      uDoubleSided: C.create(P.doubleSided),
      dIgnoreLight: C.create(P.ignoreLight),
      dCelShaded: C.create(P.celShaded),
      dXrayShaded: C.create(P.xrayShaded === "inverted" ? "inverted" : P.xrayShaded === !0 ? "on" : "off"),
      dTransparentBackfaces: C.create(P.transparentBackfaces),
      dSolidInterior: C.create(P.solidInterior),
      dClipPrimitive: C.create(P.clipPrimitive),
      dApproximate: C.create(P.approximate),
      uAlphaThickness: C.create(P.alphaThickness),
      uBumpFrequency: C.create(P.bumpFrequency),
      uBumpAmplitude: C.create(P.bumpAmplitude),
      uInteriorColor: C.create(P3(P.interior, E2())),
      uInteriorSubstance: C.create(C3(P.interior, E2())),
      lodLevels: B.shaderData.lodLevels,
      centerBuffer: B.centerBuffer,
      groupBuffer: B.groupBuffer
    };
  }
  function E(B, T, w, V, P) {
    let I = q1.createSimple(w, V, P), S = { ...j.getDefaultValues(Z.Params), ...T };
    return F(B, I.transform, I.locationIterator, I.theme, S);
  }
  function R(B, T) {
    q1.updateValues(B, T), C.updateIfChanged(B.uSizeFactor, T.sizeFactor), C.updateIfChanged(B.uDoubleSided, T.doubleSided), C.updateIfChanged(B.dIgnoreLight, T.ignoreLight), C.updateIfChanged(B.dCelShaded, T.celShaded), C.updateIfChanged(B.dXrayShaded, T.xrayShaded === "inverted" ? "inverted" : T.xrayShaded === !0 ? "on" : "off"), C.updateIfChanged(B.dTransparentBackfaces, T.transparentBackfaces), C.updateIfChanged(B.dSolidInterior, T.solidInterior), C.updateIfChanged(B.dClipPrimitive, T.clipPrimitive), C.updateIfChanged(B.dApproximate, T.approximate), C.updateIfChanged(B.uAlphaThickness, T.alphaThickness), C.updateIfChanged(B.uBumpFrequency, T.bumpFrequency), C.updateIfChanged(B.uBumpAmplitude, T.bumpAmplitude), C.update(B.uInteriorColor, P3(T.interior, B.uInteriorColor.ref.value)), C.update(B.uInteriorSubstance, C3(T.interior, B.uInteriorSubstance.ref.value));
    let w = H(B.lodLevels.ref.value);
    if (!K(T.lodLevels, w)) {
      let V = B.uVertexCount.ref.value / 6, P = q(T.lodLevels, T.sizeFactor), I = W(B.tPositionGroup.ref.value, B.centerBuffer.ref.value, B.groupBuffer.ref.value, V, P), S = I ? G(T.lodLevels, T.sizeFactor, I, V) : [];
      C.update(B.tPositionGroup, B.tPositionGroup.ref.value), C.update(B.lodLevels, S);
    }
  }
  function z(B, T) {
    let w = T.boundingSphere.radius ? IR(B) * B.uSizeFactor.ref.value : 0, V = C0.expand(C0(), T.boundingSphere, w), P = j7(V, B.aTransform.ref.value, B.instanceCount.ref.value, 0);
    if (!C0.equals(P, B.boundingSphere.ref.value))
      C.update(B.boundingSphere, P);
    if (!C0.equals(V, B.invariantBoundingSphere.ref.value))
      C.update(B.invariantBoundingSphere, V), C.update(B.uInvariantBoundingSphere, E2.fromSphere(B.uInvariantBoundingSphere.ref.value, V));
    C.update(B.padding, w);
  }
  function D(B) {
    let T = q1.createRenderableState(B);
    return A(T, B), T;
  }
  function A(B, T) {
    q1.updateRenderableState(B, T), B.opaque = B.opaque && !T.xrayShaded, B.writeDepth = B.opaque;
  }
})(R$ || (R$ = {}));

// node_modules/molstar/lib/mol-geo/geometry/texture-mesh/texture-mesh.js
var iJ;
(function(Z) {

  class J {
    constructor() {
      this.index = 0, this.textures = [];
    }
    get() {
      return this.textures[this.index];
    }
    set(U, F, E) {
      this.textures[this.index] = Object.assign(this.textures[this.index] || {}, {
        vertex: U,
        group: F,
        normal: E
      }), this.index = (this.index + 1) % 2;
    }
    destroy() {
      for (let U of this.textures)
        U.vertex.destroy(), U.group.destroy(), U.normal.destroy();
    }
  }
  Z.DoubleBuffer = J;
  function $(U, F, E, R, z, D, A) {
    let B = E.getWidth(), T = E.getHeight();
    if (A)
      return A.vertexCount = U, A.groupCount = F, C.update(A.geoTextureDim, h0.set(A.geoTextureDim.ref.value, B, T)), C.update(A.vertexTexture, E), C.update(A.groupTexture, R), C.update(A.normalTexture, z), A.doubleBuffer.set(E, R, z), C0.copy(A.boundingSphere, D), A;
    else
      return {
        kind: "texture-mesh",
        vertexCount: U,
        groupCount: F,
        geoTextureDim: C.create(h0.create(B, T)),
        vertexTexture: C.create(E),
        groupTexture: C.create(R),
        normalTexture: C.create(z),
        varyingGroup: C.create(!1),
        doubleBuffer: new J,
        boundingSphere: C0.clone(D),
        meta: {}
      };
  }
  Z.create = $;
  function X(U) {
    let F = U ? U.vertexTexture.ref.value : k9(), E = U ? U.groupTexture.ref.value : k9(), R = U ? U.normalTexture.ref.value : k9(), z = U ? U.boundingSphere : C0();
    return $(0, 0, F, E, R, z, U);
  }
  Z.createEmpty = X, Z.Params = {
    ...q1.Params,
    doubleSided: j.Boolean(!1, q1.CustomQualityParamInfo),
    flipSided: j.Boolean(!1, q1.ShadingCategory),
    flatShaded: j.Boolean(!1, q1.ShadingCategory),
    ignoreLight: j.Boolean(!1, q1.ShadingCategory),
    celShaded: j.Boolean(!1, q1.ShadingCategory),
    xrayShaded: j.Select(!1, [[!1, "Off"], [!0, "On"], ["inverted", "Inverted"]], q1.ShadingCategory),
    transparentBackfaces: j.Select("off", j.arrayToOptions(["off", "on", "opaque"]), q1.ShadingCategory),
    bumpFrequency: j.Numeric(0, { min: 0, max: 10, step: 0.1 }, q1.ShadingCategory),
    bumpAmplitude: j.Numeric(1, { min: 0, max: 5, step: 0.1 }, q1.ShadingCategory),
    interior: I3()
  }, Z.Utils = {
    Params: Z.Params,
    createEmpty: X,
    createValues: W,
    createValuesSimple: K,
    updateValues: G,
    updateBoundingSphere: H,
    createRenderableState: N,
    updateRenderableState: q,
    createPositionIterator: Q
  };
  let Y = "texture-mesh";
  function Q(U, F) {
    let E = U.meta.webgl;
    if (!E)
      return X6(1, 1, 1, () => qQ);
    if (!E.namedFramebuffers[Y])
      E.namedFramebuffers[Y] = E.resources.framebuffer();
    let R = E.namedFramebuffers[Y], [z, D] = U.geoTextureDim.ref.value, A = void 0, B = () => {
      if (!A) {
        let v = new Float32Array(z * D * 4);
        R.bind(), U.vertexTexture.ref.value.attachFramebuffer(R, 0), E.readPixels(0, 0, z, D, v);
        let h = new Float32Array(z * D * 4);
        R.bind(), U.normalTexture.ref.value.attachFramebuffer(R, 0), E.readPixels(0, 0, z, D, h), A = { vertices: v, normals: h };
      }
      return A;
    }, T = U.vertexCount, w = F.instanceCount.ref.value, V = b$(), P = V.position, I = V.normal, S = F.aTransform.ref.value;
    return X6(T, w, 1, (v, h) => {
      let { vertices: x, normals: b } = B();
      if (h < 0)
        M.fromArray(P, x, v * 4), M.fromArray(I, b, v * 4);
      else
        M.transformMat4Offset(P, x, S, 0, v * 4, h * 16), M.transformDirectionOffset(I, b, S, 0, v * 4, h * 16);
      return V;
    });
  }
  function W(U, F, E, R, z) {
    let { instanceCount: D, groupCount: A } = E, B = Z.Utils.createPositionIterator(U, F), T = WJ(E, B, R.color), w = z.instanceGranularity ? rZ(D, "instance") : rZ(D * A, "groupInstance"), V = LY(), P = RY(), I = zY(), S = OY(), f = EY(), v = { drawCount: U.vertexCount, vertexCount: U.vertexCount, groupCount: A, instanceCount: D }, h = C0.clone(U.boundingSphere), x = j7(h, F.aTransform.ref.value, D, 0);
    return {
      dGeometryType: C.create("textureMesh"),
      uGeoTexDim: U.geoTextureDim,
      tPosition: U.vertexTexture,
      tGroup: U.groupTexture,
      tNormal: U.normalTexture,
      dVaryingGroup: U.varyingGroup,
      boundingSphere: C.create(x),
      invariantBoundingSphere: C.create(h),
      uInvariantBoundingSphere: C.create(E2.ofSphere(h)),
      ...T,
      ...w,
      ...V,
      ...P,
      ...I,
      ...S,
      ...f,
      ...F,
      ...q1.createValues(z, v),
      uDoubleSided: C.create(z.doubleSided),
      dFlatShaded: C.create(z.flatShaded),
      dFlipSided: C.create(z.flipSided),
      dIgnoreLight: C.create(z.ignoreLight),
      dCelShaded: C.create(z.celShaded),
      dXrayShaded: C.create(z.xrayShaded === "inverted" ? "inverted" : z.xrayShaded === !0 ? "on" : "off"),
      dTransparentBackfaces: C.create(z.transparentBackfaces),
      uBumpFrequency: C.create(z.bumpFrequency),
      uBumpAmplitude: C.create(z.bumpAmplitude),
      uInteriorColor: C.create(P3(z.interior, E2())),
      uInteriorSubstance: C.create(C3(z.interior, E2())),
      meta: C.create(U.meta)
    };
  }
  function K(U, F, E, R, z) {
    let D = q1.createSimple(E, R, z), A = { ...j.getDefaultValues(Z.Params), ...F };
    return W(U, D.transform, D.locationIterator, D.theme, A);
  }
  function G(U, F) {
    q1.updateValues(U, F), C.updateIfChanged(U.uDoubleSided, F.doubleSided), C.updateIfChanged(U.dFlatShaded, F.flatShaded), C.updateIfChanged(U.dFlipSided, F.flipSided), C.updateIfChanged(U.dIgnoreLight, F.ignoreLight), C.updateIfChanged(U.dCelShaded, F.celShaded), C.updateIfChanged(U.dXrayShaded, F.xrayShaded === "inverted" ? "inverted" : F.xrayShaded === !0 ? "on" : "off"), C.updateIfChanged(U.dTransparentBackfaces, F.transparentBackfaces), C.updateIfChanged(U.uBumpFrequency, F.bumpFrequency), C.updateIfChanged(U.uBumpAmplitude, F.bumpAmplitude), C.update(U.uInteriorColor, P3(F.interior, U.uInteriorColor.ref.value)), C.update(U.uInteriorSubstance, C3(F.interior, U.uInteriorSubstance.ref.value));
  }
  function H(U, F) {
    let E = C0.clone(F.boundingSphere), R = j7(E, U.aTransform.ref.value, U.instanceCount.ref.value, 0);
    if (!C0.equals(R, U.boundingSphere.ref.value))
      C.update(U.boundingSphere, R);
    if (!C0.equals(E, U.invariantBoundingSphere.ref.value))
      C.update(U.invariantBoundingSphere, E), C.update(U.uInvariantBoundingSphere, E2.fromSphere(U.uInvariantBoundingSphere.ref.value, E));
  }
  function N(U) {
    let F = q1.createRenderableState(U);
    return q(F, U), F;
  }
  function q(U, F) {
    q1.updateRenderableState(U, F), U.opaque = U.opaque && !F.xrayShaded, U.writeDepth = U.opaque;
  }
})(iJ || (iJ = {}));

// node_modules/molstar/lib/mol-gl/renderable/schema.js
function bE0(Z, J) {
  let $ = {}, X = {}, Y = {}, Q = {}, W = {}, K = {}, G = {};
  return Object.keys(Z).forEach((H) => {
    let N = Z[H];
    if (N.type === "attribute")
      $[H] = J[H];
    if (N.type === "define")
      X[H] = J[H];
    if (N.type === "texture" && J[H] !== void 0)
      if (N.variant === "material")
        Q[H] = J[H];
      else
        Y[H] = J[H];
    if (N.type === "uniform" && J[H] !== void 0)
      if (N.variant === "material")
        K[H] = J[H];
      else if (N.variant === "buffered")
        G[H] = J[H];
      else
        W[H] = J[H];
  }), { attributeValues: $, defineValues: X, textureValues: Y, materialTextureValues: Q, uniformValues: W, materialUniformValues: K, bufferedUniformValues: G };
}
function xE0(Z) {
  let J = {};
  return Object.keys(Z).forEach(($) => {
    J[$] = Z[$].ref.version;
  }), J;
}
function a6(Z, J, $) {
  return { type: "attribute", kind: Z, itemSize: J, divisor: $ };
}
function _0(Z, J) {
  return { type: "uniform", kind: Z, variant: J };
}
function o1(Z, J, $, X, Y) {
  return { type: "texture", kind: Z, format: J, dataType: $, filter: X, variant: Y };
}
function k3(Z) {
  return { type: "elements", kind: Z };
}
function p1(Z, J) {
  return { type: "define", kind: Z, options: J };
}
function zZ(Z) {
  return { type: "value", kind: Z };
}
var MY = {
  uDrawId: _0("i"),
  uModel: _0("m4"),
  uView: _0("m4"),
  uInvView: _0("m4"),
  uModelView: _0("m4"),
  uInvModelView: _0("m4"),
  uProjection: _0("m4"),
  uInvProjection: _0("m4"),
  uModelViewProjection: _0("m4"),
  uInvModelViewProjection: _0("m4"),
  uHasHeadRotation: _0("b"),
  uInvHeadRotation: _0("m4"),
  uIsAsymmetricProjection: _0("b"),
  uHasEyeCamera: _0("b"),
  uModelViewEye: _0("m4"),
  uInvModelViewEye: _0("m4"),
  uIsOrtho: _0("f"),
  uPixelRatio: _0("f"),
  uViewport: _0("v4"),
  uViewOffset: _0("v2"),
  uModelScale: _0("f"),
  uDrawingBufferSize: _0("v2"),
  uCameraPosition: _0("v3"),
  uCameraDir: _0("v3"),
  uCameraPlane: _0("v4"),
  uNear: _0("f"),
  uFar: _0("f"),
  uFog: _0("b"),
  uFogNear: _0("f"),
  uFogFar: _0("f"),
  uFogColor: _0("v3"),
  uTransparentBackground: _0("b"),
  uLightDirection: _0("v3[]"),
  uLightColor: _0("v3[]"),
  uAmbientColor: _0("v3"),
  uPickingAlphaThreshold: _0("f"),
  uHighlightColor: _0("v3"),
  uSelectColor: _0("v3"),
  uDimColor: _0("v3"),
  uHighlightStrength: _0("f"),
  uSelectStrength: _0("f"),
  uDimStrength: _0("f"),
  uMarkerPriority: _0("i"),
  uMarkerAverage: _0("f"),
  uXrayEdgeFalloff: _0("f"),
  uCelSteps: _0("f"),
  uExposure: _0("f"),
  uRenderMask: _0("i"),
  uMarkingDepthTest: _0("b"),
  uMarkingType: _0("i"),
  uPickType: _0("i")
}, AY = {
  tDepth: o1("texture", "depth", "ushort", "nearest"),
  tDpoitDepth: o1("texture", "rg", "float", "nearest"),
  tDpoitFrontColor: o1("texture", "rgba", "float", "nearest"),
  tDpoitBackColor: o1("texture", "rgba", "float", "nearest")
}, BY = {
  dLightCount: p1("number"),
  dColorMarker: p1("boolean")
}, wY = {
  uObjectId: _0("i")
}, h71 = {
  uColor: _0("v3", "material"),
  uColorTexDim: _0("v2"),
  uColorGridDim: _0("v3"),
  uColorGridTransform: _0("v4"),
  uPaletteDomain: _0("v2"),
  uPaletteDefault: _0("v3"),
  tColor: o1("image-uint8", "rgb", "ubyte", "nearest"),
  tPalette: o1("image-uint8", "rgb", "ubyte", "nearest"),
  tColorGrid: o1("texture", "rgb", "ubyte", "linear"),
  dColorType: p1("string", ["uniform", "attribute", "instance", "group", "groupInstance", "vertex", "vertexInstance", "volume", "volumeInstance", "direct"]),
  dUsePalette: p1("boolean")
}, cN = {
  uSize: _0("f", "material"),
  uSizeTexDim: _0("v2"),
  tSize: o1("image-uint8", "rgb", "ubyte", "nearest"),
  dSizeType: p1("string", ["uniform", "attribute", "instance", "group", "groupInstance"]),
  uSizeFactor: _0("f", "material")
}, b71 = {
  uMarker: _0("f"),
  uMarkerTexDim: _0("v2"),
  tMarker: o1("image-uint8", "alpha", "ubyte", "nearest"),
  markerAverage: zZ("number"),
  markerStatus: zZ("number"),
  dMarkerType: p1("string", ["instance", "groupInstance"])
}, x71 = {
  uOverpaintTexDim: _0("v2"),
  tOverpaint: o1("image-uint8", "rgba", "ubyte", "nearest"),
  dOverpaint: p1("boolean"),
  uOverpaintGridDim: _0("v3"),
  uOverpaintGridTransform: _0("v4"),
  tOverpaintGrid: o1("texture", "rgba", "ubyte", "linear"),
  dOverpaintType: p1("string", ["instance", "groupInstance", "volumeInstance"]),
  uOverpaintStrength: _0("f", "material")
}, y71 = {
  uTransparencyTexDim: _0("v2"),
  tTransparency: o1("image-uint8", "alpha", "ubyte", "nearest"),
  dTransparency: p1("boolean"),
  transparencyAverage: zZ("number"),
  transparencyMin: zZ("number"),
  uTransparencyGridDim: _0("v3"),
  uTransparencyGridTransform: _0("v4"),
  tTransparencyGrid: o1("texture", "alpha", "ubyte", "linear"),
  dTransparencyType: p1("string", ["instance", "groupInstance", "volumeInstance"]),
  uTransparencyStrength: _0("f", "material")
}, g71 = {
  uEmissiveTexDim: _0("v2"),
  tEmissive: o1("image-uint8", "alpha", "ubyte", "nearest"),
  dEmissive: p1("boolean"),
  emissiveAverage: zZ("number"),
  uEmissiveGridDim: _0("v3"),
  uEmissiveGridTransform: _0("v4"),
  tEmissiveGrid: o1("texture", "alpha", "ubyte", "linear"),
  dEmissiveType: p1("string", ["instance", "groupInstance", "volumeInstance"]),
  uEmissiveStrength: _0("f", "material")
}, m71 = {
  uSubstanceTexDim: _0("v2"),
  tSubstance: o1("image-uint8", "rgba", "ubyte", "nearest"),
  dSubstance: p1("boolean"),
  uSubstanceGridDim: _0("v3"),
  uSubstanceGridTransform: _0("v4"),
  tSubstanceGrid: o1("texture", "rgba", "ubyte", "linear"),
  dSubstanceType: p1("string", ["instance", "groupInstance", "volumeInstance"]),
  uSubstanceStrength: _0("f", "material")
}, d71 = {
  uClippingTexDim: _0("v2"),
  tClipping: o1("image-uint8", "alpha", "ubyte", "nearest"),
  dClipping: p1("boolean"),
  dClippingType: p1("string", ["instance", "groupInstance"])
}, jY = {
  dGeometryType: p1("string", ["cylinders", "directVolume", "image", "lines", "mesh", "points", "spheres", "text", "textureMesh"]),
  ...h71,
  ...b71,
  ...x71,
  ...y71,
  ...g71,
  ...m71,
  ...d71,
  dClipObjectCount: p1("number"),
  dClipVariant: p1("string", ["instance", "pixel"]),
  uClipObjectType: _0("i[]", "material"),
  uClipObjectInvert: _0("b[]", "material"),
  uClipObjectPosition: _0("v3[]", "material"),
  uClipObjectRotation: _0("v4[]", "material"),
  uClipObjectScale: _0("v3[]", "material"),
  uClipObjectTransform: _0("m4[]", "material"),
  aInstance: a6("float32", 1, 1),
  aTransform: a6("float32", 16, 1),
  uAlpha: _0("f", "material"),
  uMetalness: _0("f", "material"),
  uRoughness: _0("f", "material"),
  uBumpiness: _0("f", "material"),
  uEmissive: _0("f", "material"),
  uDensity: _0("f", "material"),
  uVertexCount: _0("i"),
  uInstanceCount: _0("i"),
  uGroupCount: _0("i"),
  uInvariantBoundingSphere: _0("v4"),
  uLod: _0("v4"),
  drawCount: zZ("number"),
  instanceCount: zZ("number"),
  alpha: zZ("number"),
  matrix: zZ("m4"),
  transform: zZ("float32"),
  extraTransform: zZ("float32"),
  hasReflection: zZ("boolean"),
  instanceGranularity: zZ("boolean"),
  boundingSphere: zZ("sphere"),
  invariantBoundingSphere: zZ("sphere"),
  instanceGrid: zZ("instanceGrid")
};

// node_modules/molstar/lib/mol-gl/shader/copy.frag.js
var yE0 = `
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);
}
`;

// node_modules/molstar/lib/mol-gl/shader/quad.vert.js
var p6 = `
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);
}
`;

// node_modules/molstar/lib/mol-gl/webgl/render-item.js
var p71 = 30000000, u71 = $7();
function c71(Z, J) {
  let { gl: $ } = Z;
  switch (J) {
    case "points":
      return $.POINTS;
    case "lines":
      return $.LINES;
    case "line-strip":
      return $.LINE_STRIP;
    case "line-loop":
      return $.LINE_LOOP;
    case "triangles":
      return $.TRIANGLES;
    case "triangle-strip":
      return $.TRIANGLE_STRIP;
    case "triangle-fan":
      return $.TRIANGLE_FAN;
  }
}
var l71 = { color: "", pick: "", depth: "", marking: "", emissive: "", tracing: "" }, n71 = Object.keys(l71), i71 = { compute: "" }, o71 = Object.keys(i71);
function Va(Z, J, $, X, Y) {
  if ($ = { ...$, dRenderVariant: C.create(J) }, Y.dRenderVariant === void 0)
    Object.defineProperty(Y, "dRenderVariant", { value: p1("string") });
  return Z.resources.program($, X, Y);
}
function s71() {
  return {
    attributes: !1,
    defines: !1,
    elements: !1,
    textures: !1
  };
}
function a71(Z) {
  Z.attributes = !1, Z.defines = !1, Z.elements = !1, Z.textures = !1;
}
function Ia(Z, J) {
  if (Z === "color")
    switch (J) {
      case "blended":
        return "colorBlended";
      case "wboit":
        return "colorWboit";
      case "dpoit":
        return "colorDpoit";
    }
  return Z;
}
function TY(Z, J, $, X, Y, Q, W) {
  return gE0(Z, J, $, X, Y, Q, n71, W);
}
function t8(Z, J, $, X, Y, Q = -1) {
  return gE0(Z, J, $, X, Y, Q, o71, void 0);
}
function gE0(Z, J, $, X, Y, Q, W, K) {
  let G = u71(), { stats: H, state: N, resources: q } = Z, { instancedArrays: U, vertexArrayObject: F, multiDrawInstancedBaseVertexBaseInstance: E, drawInstancedBaseVertexBaseInstance: R } = Z.extensions;
  if (W = W.filter((Z0) => {
    if (Z0 === "tracing")
      return !!Z.extensions.drawBuffers;
    return !0;
  }), Y.uVertexCount && !Z.extensions.noNonInstancedActiveAttribs) {
    let Z0 = Y.uVertexCount.ref.value;
    Y.aVertex = C.create(uJ(new Float32Array(Z0))), X.aVertex = a6("float32", 1, 0);
  }
  let { attributeValues: z, defineValues: D, textureValues: A, materialTextureValues: B, uniformValues: T, materialUniformValues: w, bufferedUniformValues: V } = bE0(X, Y), P = Object.entries(T), I = Object.entries(w), S = Object.entries(V), f = Object.entries(FR0(V)), v = Object.entries(D), h = xE0(Y), x = c71(Z, J), b = {};
  for (let Z0 of W)
    b[Z0] = Va(Z, Ia(Z0, K), D, $, X);
  let g = Xa(Z, X, A), m = Xa(Z, X, B), i = OR0(Z, X, z), r = [];
  for (let Z0 = 0, U0 = i.length;Z0 < U0; ++Z0) {
    let a = i[Z0];
    if (a[1].divisor === 1)
      r.push(a);
  }
  let Y0, c = Y.elements;
  if (c && c.ref.value)
    Y0 = q.elements(c.ref.value);
  let n = {};
  for (let Z0 of W)
    n[Z0] = F ? q.vertexArray(b[Z0], i, Y0) : null;
  let l = Y.drawCount.ref.value, u = Y.instanceCount.ref.value;
  H.drawCount += l, H.instanceCount += u, H.instancedDrawCount += u * l;
  let G0 = s71(), F0 = !1, t = -1;
  return {
    id: G,
    materialId: Q,
    getByteCount() {
      let Z0 = 0;
      for (let U0 = 0, a = i.length;U0 < a; ++U0)
        Z0 += i[U0][1].getByteCount();
      if (Y0)
        Z0 += Y0.getByteCount();
      for (let U0 = 0, a = g.length;U0 < a; ++U0)
        Z0 += g[U0][1].getByteCount();
      for (let U0 = 0, a = m.length;U0 < a; ++U0)
        Z0 += m[U0][1].getByteCount();
      return Z0;
    },
    getProgram: (Z0) => b[Z0],
    setTransparency: (Z0) => {
      if (Z0 === K)
        return;
      K = Z0;
      for (let U0 of W)
        b[U0].destroy(), b[U0] = Va(Z, Ia(U0, K), D, $, X);
    },
    render: (Z0, U0, a) => {
      if (l === 0 || u === 0)
        return;
      let Q0 = b[Z0];
      if (Q0.id === t && N.currentRenderItemId === G)
        Q0.setUniforms(P), Q0.bindTextures(g, U0);
      else {
        let $0 = n[Z0];
        if (Q0.id !== N.currentProgramId || Q0.id !== t || Q === -1 || Q !== N.currentMaterialId) {
          if (Q0.id !== N.currentProgramId)
            Q0.use();
          Q0.setUniforms(I), Q0.bindTextures(m, U0 + g.length), N.currentMaterialId = Q, t = Q0.id;
        }
        if (Q0.setUniforms(P), Q0.setUniforms(f), Q0.bindTextures(g, U0), $0) {
          if ($0.bind(), Y0)
            Y0.bind();
        } else {
          if (Y0)
            Y0.bind();
          Q0.bindAttributes(i);
        }
        N.currentRenderItemId = G;
      }
      if (y2)
        Z.checkFramebufferStatus(`Framebuffer error rendering item id ${G}`);
      if (a)
        for (let $0 of a) {
          if ($0.count === 0)
            continue;
          if (Q0.setUniforms($0.uniforms), E)
            if (Y0)
              E.multiDrawElementsInstancedBaseVertexBaseInstance(x, $0.counts, 0, Y0._dataType, $0.offsets, 0, $0.instanceCounts, 0, $0.baseVertices, 0, $0.baseInstances, 0, $0.count);
            else
              E.multiDrawArraysInstancedBaseInstance(x, $0.firsts, 0, $0.counts, 0, $0.instanceCounts, 0, $0.baseInstances, 0, $0.count);
          else if (R) {
            if (Y0) {
              for (let R0 = 0;R0 < $0.count; ++R0)
                if ($0.counts[R0] > 0)
                  Q0.uniform("uDrawId", R0), R.drawElementsInstancedBaseVertexBaseInstance(x, $0.counts[R0], Y0._dataType, $0.offsets[R0], $0.instanceCounts[R0], $0.baseVertices[R0], $0.baseInstances[R0]);
            } else
              for (let R0 = 0;R0 < $0.count; ++R0)
                if ($0.counts[R0] > 0)
                  Q0.uniform("uDrawId", R0), R.drawArraysInstancedBaseInstance(x, $0.firsts[R0], $0.counts[R0], $0.instanceCounts[R0], $0.baseInstances[R0]);
          } else if (Y0) {
            for (let R0 = 0;R0 < $0.count; ++R0)
              if ($0.counts[R0] > 0)
                Q0.uniform("uDrawId", R0), Q0.offsetAttributes(r, $0.baseInstances[R0]), U.drawElementsInstanced(x, $0.counts[R0], Y0._dataType, $0.offsets[R0], $0.instanceCounts[R0]);
          } else
            for (let R0 = 0;R0 < $0.count; ++R0)
              if ($0.counts[R0] > 0)
                Q0.uniform("uDrawId", R0), Q0.offsetAttributes(r, $0.baseInstances[R0]), U.drawArraysInstanced(x, 0, $0.counts[R0], $0.instanceCounts[R0]);
          if (K1) {
            if (E)
              H.calls.multiDrawInstancedBase += 1;
            else if (R)
              H.calls.drawInstancedBase += $0.count;
            else
              H.calls.drawInstanced += $0.count;
            for (let R0 = 0;R0 < $0.count; ++R0)
              H.calls.counts += $0.instanceCounts[R0];
          }
        }
      else {
        let $0 = 0;
        while (!0) {
          let R0 = Math.min(l - $0, p71);
          if (Y0)
            U.drawElementsInstanced(x, R0, Y0._dataType, $0 * Y0._bpe, u);
          else
            U.drawArraysInstanced(x, $0, R0, u);
          if ($0 += R0, $0 >= l)
            break;
        }
        if (K1)
          H.calls.drawInstanced += 1, H.calls.counts += u;
      }
      if (y2)
        Z.checkError(`Draw error rendering item id ${G}`);
    },
    update: () => {
      if (a71(G0), Y.aVertex) {
        let Z0 = Y.uVertexCount.ref.value;
        if (Y.aVertex.ref.value.length < Z0)
          C.update(Y.aVertex, uJ(new Float32Array(Z0)));
      }
      for (let Z0 = 0, U0 = v.length;Z0 < U0; ++Z0) {
        let [a, Q0] = v[Z0];
        if (Q0.ref.version !== h[a])
          G0.defines = !0, h[a] = Q0.ref.version;
      }
      if (G0.defines)
        for (let Z0 of W)
          b[Z0].destroy(), b[Z0] = Va(Z, Ia(Z0, K), D, $, X);
      if (Y.drawCount.ref.version !== h.drawCount)
        H.drawCount += Y.drawCount.ref.value - l, H.instancedDrawCount += u * Y.drawCount.ref.value - u * l, l = Y.drawCount.ref.value, h.drawCount = Y.drawCount.ref.version;
      if (Y.instanceCount.ref.version !== h.instanceCount)
        H.instanceCount += Y.instanceCount.ref.value - u, H.instancedDrawCount += Y.instanceCount.ref.value * l - u * l, u = Y.instanceCount.ref.value, h.instanceCount = Y.instanceCount.ref.version;
      for (let Z0 = 0, U0 = i.length;Z0 < U0; ++Z0) {
        let [a, Q0] = i[Z0], $0 = z[a];
        if ($0.ref.version !== h[a]) {
          if (Q0.length >= $0.ref.value.length)
            Q0.updateSubData($0.ref.value, 0, Q0.length);
          else {
            Q0.destroy();
            let { itemSize: R0, divisor: X0 } = X[a];
            i[Z0][1] = q.attribute($0.ref.value, R0, X0), G0.attributes = !0;
          }
          h[a] = $0.ref.version;
        }
      }
      if (Y0 && Y.elements.ref.version !== h.elements) {
        if (Y0.length >= Y.elements.ref.value.length)
          Y0.updateSubData(Y.elements.ref.value, 0, Y0.length);
        else
          Y0.destroy(), Y0 = q.elements(Y.elements.ref.value), G0.elements = !0;
        h.elements = Y.elements.ref.version;
      }
      if (G0.attributes || G0.defines || G0.elements)
        for (let Z0 of W) {
          let U0 = n[Z0];
          if (U0)
            U0.destroy();
          n[Z0] = F ? q.vertexArray(b[Z0], i, Y0) : null;
        }
      for (let Z0 = 0, U0 = g.length;Z0 < U0; ++Z0) {
        let [a, Q0] = g[Z0], $0 = A[a];
        if ($0.ref.version !== h[a]) {
          if (X[a].kind !== "texture")
            Q0.load($0.ref.value), G0.textures = !0;
          else
            g[Z0][1] = $0.ref.value;
          h[a] = $0.ref.version;
        }
      }
      for (let Z0 = 0, U0 = m.length;Z0 < U0; ++Z0) {
        let [a, Q0] = m[Z0], $0 = B[a];
        if ($0.ref.version !== h[a]) {
          if (X[a].kind !== "texture")
            Q0.load($0.ref.value), G0.textures = !0;
          else
            m[Z0][1] = $0.ref.value;
          h[a] = $0.ref.version;
        }
      }
      for (let Z0 = 0, U0 = S.length;Z0 < U0; ++Z0) {
        let [a, Q0] = S[Z0];
        if (Q0.ref.version !== h[a])
          C.update(f[Z0][1], W$(Q0.ref.value)), h[a] = Q0.ref.version;
      }
    },
    destroy: () => {
      if (!F0) {
        for (let Z0 of W) {
          b[Z0].destroy();
          let U0 = n[Z0];
          if (U0)
            U0.destroy();
        }
        if (g.forEach(([Z0, U0]) => {
          if (X[Z0].kind !== "texture")
            U0.destroy();
        }), m.forEach(([Z0, U0]) => {
          if (X[Z0].kind !== "texture")
            U0.destroy();
        }), i.forEach(([Z0, U0]) => U0.destroy()), Y0)
          Y0.destroy();
        H.drawCount -= l, H.instanceCount -= u, H.instancedDrawCount -= u * l, F0 = !0;
      }
    }
  };
}

// node_modules/molstar/lib/mol-math/geometry/primitives/plane3d.js
function tZ() {
  return tZ.create(M.create(1, 0, 0), 0);
}
(function(Z) {
  function J(z, D) {
    return { normal: z, constant: D };
  }
  Z.create = J;
  function $(z, D) {
    return M.copy(z.normal, D.normal), z.constant = D.constant, z;
  }
  Z.copy = $;
  function X(z) {
    return $(Z(), z);
  }
  Z.clone = X;
  function Y(z, D) {
    let A = 1 / M.magnitude(D.normal);
    return M.scale(z.normal, D.normal, A), z.constant = D.constant * A, z;
  }
  Z.normalize = Y;
  function Q(z, D) {
    return M.negate(z.normal, D.normal), z.constant = -D.constant, z;
  }
  Z.negate = Q;
  function W(z, D, A) {
    return M.toArray(z.normal, D, A), D[A + 3] = z.constant, D;
  }
  Z.toArray = W;
  function K(z, D, A) {
    return M.fromArray(z.normal, D, A), z.constant = D[A + 3], z;
  }
  Z.fromArray = K;
  function G(z, D, A) {
    return M.copy(z.normal, D), z.constant = -M.dot(z.normal, A), z;
  }
  Z.fromNormalAndCoplanarPoint = G;
  function H(z, D, A, B) {
    let T = M.triangleNormal(M(), D, A, B);
    return G(z, T, D), z;
  }
  Z.fromCoplanarPoints = H;
  let N = M();
  function q(z, D, A, B, T) {
    M.set(N, D, A, B);
    let w = 1 / M.magnitude(N);
    return M.scale(z.normal, N, w), z.constant = T * w, z;
  }
  Z.setUnnormalized = q;
  function U(z, D) {
    return M.dot(z.normal, D) + z.constant;
  }
  Z.distanceToPoint = U;
  function F(z, D) {
    return U(z, D.center) - D.radius;
  }
  Z.distanceToSphere3D = F;
  function E(z, D, A) {
    return M.scaleAndAdd(z, A, D.normal, -U(D, A));
  }
  Z.projectPoint = E;
  function R(z, D, A) {
    let B = M.dot(D.normal, A.direction);
    if (B === 0)
      return !1;
    let T = -(M.dot(D.normal, A.origin) + D.constant) / B;
    if (T < 0)
      return !1;
    return M.scaleAndAdd(z, A.origin, A.direction, T), !0;
  }
  Z.intersectRay3D = R;
})(tZ || (tZ = {}));

// node_modules/molstar/lib/mol-math/geometry/primitives/frustum3d.js
function lN() {
  return lN.create(tZ(), tZ(), tZ(), tZ(), tZ(), tZ());
}
(function(Z) {
  let J;
  (function(N) {
    N[N.Right = 0] = "Right", N[N.Left = 1] = "Left", N[N.Bottom = 2] = "Bottom", N[N.Top = 3] = "Top", N[N.Far = 4] = "Far", N[N.Near = 5] = "Near";
  })(J = Z.PlaneIndex || (Z.PlaneIndex = {}));
  function $(N, q, U, F, E, R) {
    return [N, q, U, F, E, R];
  }
  Z.create = $;
  function X(N, q) {
    for (let U = 0;U < 6; ++U)
      tZ.copy(N[U], q[U]);
    return N;
  }
  Z.copy = X;
  function Y(N) {
    return X(Z(), N);
  }
  Z.clone = Y;
  function Q(N, q) {
    let U = q[0], F = q[1], E = q[2], R = q[3], z = q[4], D = q[5], A = q[6], B = q[7], T = q[8], w = q[9], V = q[10], P = q[11], I = q[12], S = q[13], f = q[14], v = q[15];
    return tZ.setUnnormalized(N[0], R - U, B - z, P - T, v - I), tZ.setUnnormalized(N[1], R + U, B + z, P + T, v + I), tZ.setUnnormalized(N[2], R + F, B + D, P + w, v + S), tZ.setUnnormalized(N[3], R - F, B - D, P - w, v - S), tZ.setUnnormalized(N[4], R - E, B - A, P - V, v - f), tZ.setUnnormalized(N[5], R + E, B + A, P + V, v + f), N;
  }
  Z.fromProjectionMatrix = Q;
  function W(N, q) {
    let U = q.center, F = -q.radius;
    for (let E = 0;E < 6; ++E)
      if (tZ.distanceToPoint(N[E], U) < F)
        return !1;
    return !0;
  }
  Z.intersectsSphere3D = W;
  let K = M();
  function G(N, q) {
    for (let U = 0;U < 6; ++U) {
      let F = N[U];
      if (K[0] = F.normal[0] > 0 ? q.max[0] : q.min[0], K[1] = F.normal[1] > 0 ? q.max[1] : q.min[1], K[2] = F.normal[2] > 0 ? q.max[2] : q.min[2], tZ.distanceToPoint(F, K) < 0)
        return !1;
    }
    return !0;
  }
  Z.intersectsBox3D = G;
  function H(N, q) {
    for (let U = 0;U < 6; ++U)
      if (tZ.distanceToPoint(N[U], q) < 0)
        return !1;
    return !0;
  }
  Z.containsPoint = H;
})(lN || (lN = {}));

// node_modules/molstar/lib/mol-gl/renderable.js
var hh = tZ.distanceToPoint, bh = lN.intersectsSphere3D, xh = C0.fromArray, mE0 = $7();
function Pa(Z, J) {
  if (J && J.instanceCounts.length >= Z)
    return J;
  else
    return {
      firsts: new Int32Array(Z),
      counts: new Int32Array(Z),
      offsets: new Int32Array(Z),
      instanceCounts: new Int32Array(Z),
      baseVertices: new Int32Array(Z),
      baseInstances: new Uint32Array(Z),
      count: 0,
      uniforms: []
    };
}
function _Y(Z, J, $) {
  let X = mE0(), Y = Pa(0), Q = [], W = !1, K = -1, G = C0(), H = () => {
    var N;
    let q = (N = J.lodLevels) === null || N === void 0 ? void 0 : N.ref.value;
    if (q && q.length > 0) {
      let { cellCount: U } = J.instanceGrid.ref.value;
      Q.length = q.length;
      for (let F = 0, E = q.length;F < E; ++F)
        Q[F] = Pa(U, Q[F]), Q[F].count = 0;
      if (J.lodLevels.ref.version !== K) {
        for (let F = 0, E = q.length;F < E; ++F) {
          if (Q[F].uniforms.length !== 1)
            Q[F].uniforms.length = 1, Q[F].uniforms[0] = ["uLod", C.create(E2())];
          C.update(Q[F].uniforms[0][1], E2.set(Q[F].uniforms[0][1].ref.value, q[F][0], q[F][1], q[F][2], q[F][4]));
        }
        K = J.lodLevels.ref.version;
      }
    }
  };
  return H(), {
    id: X,
    materialId: Z.materialId,
    values: J,
    state: $,
    cull: (N, q, U, F) => {
      var E, R;
      if (W = !1, J.drawCount.ref.value === 0)
        return;
      if (J.instanceCount.ref.value === 0)
        return;
      if (J.instanceGrid.ref.value.cellSize <= 1)
        return;
      let { cellOffsets: z, cellSpheres: D, cellCount: A, batchOffsets: B, batchSpheres: T, batchCount: w, batchCell: V, batchSize: P } = J.instanceGrid.ref.value, [I, S] = J.uLod.ref.value, f = I !== 0 || S !== 0, v = 2 * P, h = (E = J.lodLevels) === null || E === void 0 ? void 0 : E.ref.value;
      if (h && h.length > 0) {
        if (((R = J.lodLevels) === null || R === void 0 ? void 0 : R.ref.version) !== K)
          H();
        else
          for (let x = 0, b = h.length;x < b; ++x)
            Q[x].count = 0;
        for (let x = 0;x < w; ++x) {
          let b = B[x], g = B[x + 1];
          if (g - b === 0)
            continue;
          xh(G, T, x * 4);
          let i = hh(N, G.center);
          if (f) {
            if (i + G.radius < I || i - G.radius > S) {
              if (K1)
                F.culled.lod += z[V[g - 1] + 1] - z[V[b]];
              continue;
            }
          }
          if (!bh(q, G)) {
            if (K1)
              F.culled.frustum += z[V[g - 1] + 1] - z[V[b]];
            continue;
          }
          if (U !== null && U(G)) {
            if (K1)
              F.culled.occlusion += z[V[g - 1] + 1] - z[V[b]];
            continue;
          }
          for (let r = b;r < g; ++r) {
            let Y0 = V[r], c = z[Y0], l = z[Y0 + 1] - c;
            if (l === 0)
              continue;
            xh(G, D, Y0 * 4);
            let u = hh(N, G.center);
            if (f) {
              if (u + G.radius < I || u - G.radius > S) {
                if (K1)
                  F.culled.lod += l;
                continue;
              }
            }
            if (!bh(q, G)) {
              if (K1)
                F.culled.frustum += l;
              continue;
            }
            if (U !== null && u - G.radius < v && U(G)) {
              if (K1)
                F.culled.occlusion += l;
              continue;
            }
            for (let G0 = 0, F0 = h.length;G0 < F0; ++G0) {
              if (u + G.radius < h[G0][0] || u - G.radius > h[G0][1])
                continue;
              let t = Q[G0], Z0 = t.count;
              if (Z0 > 0 && t.baseInstances[Z0 - 1] + t.instanceCounts[Z0 - 1] === c && t.counts[Z0 - 1] === h[G0][3])
                t.instanceCounts[Z0 - 1] += l;
              else
                t.counts[Z0] = h[G0][3], t.instanceCounts[Z0] = l, t.baseInstances[Z0] = c, t.count += 1;
            }
          }
        }
      } else {
        Y = Pa(A, Y);
        let { baseInstances: x, instanceCounts: b, counts: g } = Y, m = 0;
        for (let i = 0;i < w; ++i) {
          let r = B[i], Y0 = B[i + 1];
          if (Y0 - r === 0)
            continue;
          if (xh(G, T, i * 4), f) {
            let n = hh(N, G.center);
            if (n + G.radius < I || n - G.radius > S) {
              if (K1)
                F.culled.lod += z[V[Y0 - 1] + 1] - z[V[r]];
              continue;
            }
          }
          if (!bh(q, G)) {
            if (K1)
              F.culled.frustum += z[V[Y0 - 1] + 1] - z[V[r]];
            continue;
          }
          if (U !== null && U(G)) {
            if (K1)
              F.culled.occlusion += z[V[Y0 - 1] + 1] - z[V[r]];
            continue;
          }
          for (let n = r;n < Y0; ++n) {
            let l = V[n], u = z[l], F0 = z[l + 1] - u;
            if (F0 === 0)
              continue;
            xh(G, D, l * 4);
            let t = hh(N, G.center);
            if (f) {
              if (t + G.radius < I || t - G.radius > S) {
                if (K1)
                  F.culled.lod += F0;
                continue;
              }
            }
            if (!bh(q, G)) {
              if (K1)
                F.culled.frustum += F0;
              continue;
            }
            if (U !== null && t - G.radius < v && U(G)) {
              if (K1)
                F.culled.occlusion += F0;
              continue;
            }
            if (m > 0 && x[m - 1] + b[m - 1] === u)
              b[m - 1] += F0;
            else
              g[m] = J.drawCount.ref.value, b[m] = F0, x[m] = u, m += 1;
          }
        }
        Y.count = m, Q.length = 1, Q[0] = Y, Q[0].uniforms.length = 0;
      }
      W = !0;
    },
    uncull: () => {
      W = !1;
    },
    cullSimple: (N, q, U) => {
      var F, E;
      let R = (F = J.lodLevels) === null || F === void 0 ? void 0 : F.ref.value;
      if (!R || R.length === 0)
        return;
      if (((E = J.lodLevels) === null || E === void 0 ? void 0 : E.ref.version) !== K)
        H();
      else
        for (let z = 0, D = R.length;z < D; ++z)
          Q[z].count = 0;
      for (let z = 0, D = R.length;z < D; ++z)
        if (N + q < R[z][1] * U) {
          let A = Q[z], B = A.count;
          A.counts[B] = R[z][3], A.instanceCounts[B] = J.instanceCount.ref.value, A.baseInstances[B] = 0, A.count += 1;
          break;
        }
      W = !0;
    },
    render: (N, q) => {
      if (J.uAlpha && J.alpha)
        C.updateIfChanged(J.uAlpha, x8(J.alpha.ref.value * $.alphaFactor, 0, 1));
      Z.render(N, q, W ? Q : void 0);
    },
    getByteCount: () => Z.getByteCount(),
    getProgram: (N) => Z.getProgram(N),
    setTransparency: (N) => Z.setTransparency(N),
    update: () => {
      Z.update(), H();
    },
    dispose: () => Z.destroy()
  };
}
function e8(Z, J) {
  return {
    id: mE0(),
    values: J,
    render: () => {
      Z.getProgram("compute").finalize(!0), Z.render("compute", 0);
    },
    update: () => Z.update(),
    dispose: () => Z.destroy()
  };
}

// node_modules/molstar/lib/mol-gl/compute/util.js
var RV = new Float32Array([
  1,
  1,
  -1,
  1,
  -1,
  -1,
  -1,
  -1,
  1,
  -1,
  1,
  1
]), A6 = {
  drawCount: zZ("number"),
  instanceCount: zZ("number"),
  aPosition: a6("float32", 2, 0),
  uQuadScale: _0("v2")
}, B6 = {
  drawCount: C.create(6),
  instanceCount: C.create(1),
  aPosition: C.create(RV),
  uQuadScale: C.create(h0.create(1, 1))
}, r71 = {
  ...A6,
  tColor: o1("texture", "rgba", "ubyte", "nearest"),
  uTexSize: _0("v2")
}, t71 = v8("copy", p6, yE0);
function T5(Z, J) {
  let $ = {
    ...B6,
    tColor: C.create(J),
    uTexSize: C.create(h0.create(J.getWidth(), J.getHeight()))
  }, X = { ...r71 }, Y = t8(Z, "triangles", t71, X, $);
  return e8(Y, $);
}

// node_modules/molstar/lib/mol-geo/geometry/image/image.js
var dE0 = new Uint32Array([
  0,
  1,
  2,
  1,
  3,
  2
]), e71 = new Float32Array([
  0,
  1,
  0,
  0,
  1,
  1,
  1,
  0
]), yh = {
  nearest: "Nearest",
  catmulrom: "Catmulrom (Cubic)",
  mitchell: "Mitchell (Cubic)",
  bspline: "B-Spline (Cubic)"
}, VL2 = Object.keys(yh);
var VY;
(function(Z) {
  function J() {
    return { type: 0, center: M(), rotation: k8(), scale: M(), transform: e() };
  }
  Z.createEmptyTrim = J;
  function $(E, R, z, D, A, B, T) {
    return T ? Q(E, R, z, D, A, B, T) : Y(E, R, z, D, A, B);
  }
  Z.create = $;
  function X(E) {
    return l9([
      E.cornerBuffer.ref.version
    ]);
  }
  function Y(E, R, z, D, A, B) {
    let T = C0(), w = -1, V = E.width, P = E.height, I = {
      kind: "image",
      imageTexture: C.create(E),
      imageTextureDim: C.create(h0.create(V, P)),
      cornerBuffer: C.create(R),
      groupTexture: C.create(z),
      valueTexture: C.create(D),
      trimType: C.create(A.type),
      trimCenter: C.create(A.center),
      trimRotation: C.create(A.rotation),
      trimScale: C.create(A.scale),
      trimTransform: C.create(A.transform),
      isoLevel: C.create(B),
      get boundingSphere() {
        let S = X(I);
        if (S !== w) {
          let f = ZJ1(I.cornerBuffer.ref.value);
          C0.copy(T, f), w = S;
        }
        return T;
      },
      setBoundingSphere(S) {
        C0.copy(T, S), w = X(I);
      }
    };
    return I;
  }
  function Q(E, R, z, D, A, B, T) {
    let { width: w, height: V } = E;
    return C.update(T.imageTexture, E), C.update(T.imageTextureDim, h0.set(T.imageTextureDim.ref.value, w, V)), C.update(T.cornerBuffer, R), C.update(T.groupTexture, z), C.update(T.valueTexture, D), C.updateIfChanged(T.trimType, A.type), C.update(T.trimCenter, M.copy(T.trimCenter.ref.value, A.center)), C.update(T.trimRotation, k8.copy(T.trimRotation.ref.value, A.rotation)), C.update(T.trimScale, M.copy(T.trimScale.ref.value, A.scale)), C.update(T.trimTransform, e.copy(T.trimTransform.ref.value, A.transform)), C.updateIfChanged(T.isoLevel, B), T;
  }
  function W(E) {
    let R = Z9(0, 4, Uint8Array), z = E ? E.cornerBuffer.ref.value : new Float32Array(24), D = Z9(0, 4, Uint8Array), A = Z9(0, 1, Float32Array), B = J();
    return $(R, z, D, A, B, -1, E);
  }
  Z.createEmpty = W, Z.Params = {
    ...q1.Params,
    interpolation: j.Select("bspline", j.objectToOptions(yh))
  }, Z.Utils = {
    Params: Z.Params,
    createEmpty: W,
    createValues: G,
    createValuesSimple: H,
    updateValues: N,
    updateBoundingSphere: q,
    createRenderableState: U,
    updateRenderableState: F,
    createPositionIterator: K
  };
  function K(E, R) {
    return X6(1, 1, 1, () => qQ);
  }
  function G(E, R, z, D, A) {
    let { instanceCount: B, groupCount: T } = z, w = K(E, R), V = WJ(z, w, D.color), P = A.instanceGranularity ? rZ(B, "instance") : rZ(B * T, "groupInstance"), I = LY(), S = RY(), f = zY(), v = OY(), h = EY(), x = { drawCount: dE0.length, vertexCount: RV.length / 3, groupCount: T, instanceCount: B }, b = C0.clone(E.boundingSphere), g = j7(b, R.aTransform.ref.value, B, 0);
    return {
      dGeometryType: C.create("image"),
      ...V,
      ...P,
      ...I,
      ...S,
      ...f,
      ...v,
      ...h,
      ...R,
      ...q1.createValues(A, x),
      aPosition: E.cornerBuffer,
      aUv: C.create(e71),
      elements: C.create(dE0),
      aGroup: C.create(uJ(new Float32Array(4))),
      boundingSphere: C.create(g),
      invariantBoundingSphere: C.create(b),
      uInvariantBoundingSphere: C.create(E2.ofSphere(b)),
      dInterpolation: C.create(A.interpolation),
      uImageTexDim: E.imageTextureDim,
      tImageTex: E.imageTexture,
      tGroupTex: E.groupTexture,
      tValueTex: E.valueTexture,
      uTrimType: E.trimType,
      uTrimCenter: E.trimCenter,
      uTrimRotation: E.trimRotation,
      uTrimScale: E.trimScale,
      uTrimTransform: E.trimTransform,
      uIsoLevel: E.isoLevel
    };
  }
  function H(E, R, z, D, A) {
    let B = q1.createSimple(z, D, A), T = { ...j.getDefaultValues(Z.Params), ...R };
    return G(E, B.transform, B.locationIterator, B.theme, T);
  }
  function N(E, R) {
    q1.updateValues(E, R), C.updateIfChanged(E.dInterpolation, R.interpolation);
  }
  function q(E, R) {
    let z = C0.clone(R.boundingSphere), D = j7(z, E.aTransform.ref.value, E.instanceCount.ref.value, 0);
    if (!C0.equals(D, E.boundingSphere.ref.value))
      C.update(E.boundingSphere, D);
    if (!C0.equals(z, E.invariantBoundingSphere.ref.value))
      C.update(E.invariantBoundingSphere, z), C.update(E.uInvariantBoundingSphere, E2.fromSphere(E.uInvariantBoundingSphere.ref.value, z));
  }
  function U(E) {
    let R = q1.createRenderableState(E);
    return R.opaque = !1, R;
  }
  function F(E, R) {
    q1.updateRenderableState(E, R), E.opaque = !1;
  }
})(VY || (VY = {}));
function ZJ1(Z) {
  let J = M(), $ = [];
  for (let Q = 0, W = Z.length;Q < W; Q += 3) {
    let K = M.fromArray(M(), Z, Q);
    $.push(K), M.add(J, J, K);
  }
  M.scale(J, J, 1 / (Z.length / 3));
  let X = 0;
  for (let Q of $) {
    let W = M.distance(J, Q);
    if (W > X)
      X = W;
  }
  let Y = C0.create(J, X);
  return C0.setExtrema(Y, $), Y;
}

// node_modules/molstar/lib/mol-geo/geometry/cylinders/cylinders.js
var T7;
(function(Z) {
  function J(E, R, z, D, A, B, T, w, V, P) {
    return P ? Q(E, R, z, D, A, B, T, w, V, P) : Y(E, R, z, D, A, B, T, w, V);
  }
  Z.create = J;
  function $(E) {
    let R = E ? E.mappingBuffer.ref.value : new Float32Array(0), z = E ? E.indexBuffer.ref.value : new Uint32Array(0), D = E ? E.groupBuffer.ref.value : new Float32Array(0), A = E ? E.startBuffer.ref.value : new Float32Array(0), B = E ? E.endBuffer.ref.value : new Float32Array(0), T = E ? E.scaleBuffer.ref.value : new Float32Array(0), w = E ? E.capBuffer.ref.value : new Float32Array(0), V = E ? E.colorModeBuffer.ref.value : new Float32Array(0);
    return J(R, z, D, A, B, T, w, V, 0, E);
  }
  Z.createEmpty = $;
  function X(E) {
    return l9([
      E.cylinderCount,
      E.mappingBuffer.ref.version,
      E.indexBuffer.ref.version,
      E.groupBuffer.ref.version,
      E.startBuffer.ref.version,
      E.endBuffer.ref.version,
      E.scaleBuffer.ref.version,
      E.capBuffer.ref.version,
      E.colorModeBuffer.ref.version
    ]);
  }
  function Y(E, R, z, D, A, B, T, w, V) {
    let P = C0(), I, S = -1, f = -1, v = {
      kind: "cylinders",
      cylinderCount: V,
      mappingBuffer: C.create(E),
      indexBuffer: C.create(R),
      groupBuffer: C.create(z),
      startBuffer: C.create(D),
      endBuffer: C.create(A),
      scaleBuffer: C.create(B),
      capBuffer: C.create(T),
      colorModeBuffer: C.create(w),
      get boundingSphere() {
        let h = X(v);
        if (h !== S) {
          let x = w5(v.startBuffer.ref.value, v.cylinderCount * 6, 6), b = w5(v.endBuffer.ref.value, v.cylinderCount * 6, 6);
          C0.expandBySphere(P, x, b), S = h;
        }
        return P;
      },
      get groupMapping() {
        if (v.groupBuffer.ref.version !== f)
          I = _3(v.groupBuffer.ref.value, v.cylinderCount, 6), f = v.groupBuffer.ref.version;
        return I;
      },
      setBoundingSphere(h) {
        C0.copy(P, h), S = X(v);
      }
    };
    return v;
  }
  function Q(E, R, z, D, A, B, T, w, V, P) {
    if (V > P.cylinderCount)
      C.update(P.mappingBuffer, E), C.update(P.indexBuffer, R);
    return P.cylinderCount = V, C.update(P.groupBuffer, z), C.update(P.startBuffer, D), C.update(P.endBuffer, A), C.update(P.scaleBuffer, B), C.update(P.capBuffer, T), C.update(P.colorModeBuffer, w), P;
  }
  function W(E, R) {
    let z = E.startBuffer.ref.value;
    SW(R, z, 0, E.cylinderCount * 6), C.update(E.startBuffer, z);
    let D = E.endBuffer.ref.value;
    SW(R, D, 0, E.cylinderCount * 6), C.update(E.endBuffer, D);
  }
  Z.transform = W, Z.Params = {
    ...q1.Params,
    sizeFactor: j.Numeric(1, { min: 0, max: 10, step: 0.1 }),
    sizeAspectRatio: j.Numeric(1, { min: 0, max: 3, step: 0.01 }),
    doubleSided: j.Boolean(!1, q1.CustomQualityParamInfo),
    ignoreLight: j.Boolean(!1, q1.ShadingCategory),
    celShaded: j.Boolean(!1, q1.ShadingCategory),
    xrayShaded: j.Select(!1, [[!1, "Off"], [!0, "On"], ["inverted", "Inverted"]], q1.ShadingCategory),
    transparentBackfaces: j.Select("off", j.arrayToOptions(["off", "on", "opaque"]), q1.ShadingCategory),
    solidInterior: j.Boolean(!0, q1.ShadingCategory),
    bumpFrequency: j.Numeric(0, { min: 0, max: 10, step: 0.1 }, q1.ShadingCategory),
    bumpAmplitude: j.Numeric(1, { min: 0, max: 5, step: 0.1 }, q1.ShadingCategory),
    interior: I3(),
    colorMode: j.Select("default", j.arrayToOptions(["default", "interpolate"]), q1.ShadingCategory)
  }, Z.Utils = {
    Params: Z.Params,
    createEmpty: $,
    createValues: G,
    createValuesSimple: H,
    updateValues: N,
    updateBoundingSphere: q,
    createRenderableState: U,
    updateRenderableState: F,
    createPositionIterator: K
  };
  function K(E, R) {
    let z = E.cylinderCount * 6, D = R.instanceCount.ref.value, A = b$(), B = A.position, T = E.startBuffer.ref.value, w = E.endBuffer.ref.value, V = R.aTransform.ref.value;
    return X6(z, D, 2, (I, S) => {
      let f = I % 6 === 0 ? T : w;
      if (S < 0)
        M.fromArray(B, f, I * 3);
      else
        M.transformMat4Offset(B, f, V, 0, I * 3, S * 16);
      return A;
    });
  }
  function G(E, R, z, D, A) {
    let { instanceCount: B, groupCount: T } = z, w = K(E, R), V = WJ(z, w, D.color), P = DY(z, D.size), I = A.instanceGranularity ? rZ(B, "instance") : rZ(B * T, "groupInstance"), S = LY(), f = RY(), v = zY(), h = OY(), x = EY(), b = { drawCount: E.cylinderCount * 4 * 3, vertexCount: E.cylinderCount * 6, groupCount: T, instanceCount: B }, g = IR(P) * A.sizeFactor, m = C0.clone(E.boundingSphere), i = j7(m, R.aTransform.ref.value, B, 0);
    return {
      dGeometryType: C.create("cylinders"),
      aMapping: E.mappingBuffer,
      aGroup: E.groupBuffer,
      aStart: E.startBuffer,
      aEnd: E.endBuffer,
      aScale: E.scaleBuffer,
      aCap: E.capBuffer,
      aColorMode: E.colorModeBuffer,
      elements: E.indexBuffer,
      boundingSphere: C.create(i),
      invariantBoundingSphere: C.create(m),
      uInvariantBoundingSphere: C.create(E2.ofSphere(m)),
      ...V,
      ...P,
      ...I,
      ...S,
      ...f,
      ...v,
      ...h,
      ...x,
      ...R,
      padding: C.create(g),
      ...q1.createValues(A, b),
      uSizeFactor: C.create(A.sizeFactor * A.sizeAspectRatio),
      uDoubleSided: C.create(A.doubleSided),
      dIgnoreLight: C.create(A.ignoreLight),
      dCelShaded: C.create(A.celShaded),
      dXrayShaded: C.create(A.xrayShaded === "inverted" ? "inverted" : A.xrayShaded === !0 ? "on" : "off"),
      dTransparentBackfaces: C.create(A.transparentBackfaces),
      dSolidInterior: C.create(A.solidInterior),
      uBumpFrequency: C.create(A.bumpFrequency),
      uBumpAmplitude: C.create(A.bumpAmplitude),
      uInteriorColor: C.create(P3(A.interior, E2())),
      uInteriorSubstance: C.create(C3(A.interior, E2())),
      dDualColor: C.create(A.colorMode === "interpolate")
    };
  }
  function H(E, R, z, D, A) {
    let B = q1.createSimple(z, D, A), T = { ...j.getDefaultValues(Z.Params), ...R };
    return G(E, B.transform, B.locationIterator, B.theme, T);
  }
  function N(E, R) {
    q1.updateValues(E, R), C.updateIfChanged(E.uSizeFactor, R.sizeFactor * R.sizeAspectRatio), C.updateIfChanged(E.uDoubleSided, R.doubleSided), C.updateIfChanged(E.dIgnoreLight, R.ignoreLight), C.updateIfChanged(E.dCelShaded, R.celShaded), C.updateIfChanged(E.dXrayShaded, R.xrayShaded === "inverted" ? "inverted" : R.xrayShaded === !0 ? "on" : "off"), C.updateIfChanged(E.dTransparentBackfaces, R.transparentBackfaces), C.updateIfChanged(E.dSolidInterior, R.solidInterior), C.updateIfChanged(E.uBumpFrequency, R.bumpFrequency), C.updateIfChanged(E.uBumpAmplitude, R.bumpAmplitude), C.update(E.uInteriorColor, P3(R.interior, E.uInteriorColor.ref.value)), C.update(E.uInteriorSubstance, C3(R.interior, E.uInteriorSubstance.ref.value)), C.updateIfChanged(E.dDualColor, R.colorMode === "interpolate");
  }
  function q(E, R) {
    let z = C0.clone(R.boundingSphere), D = j7(z, E.aTransform.ref.value, E.instanceCount.ref.value, 0);
    if (!C0.equals(D, E.boundingSphere.ref.value))
      C.update(E.boundingSphere, D);
    if (!C0.equals(z, E.invariantBoundingSphere.ref.value))
      C.update(E.invariantBoundingSphere, z), C.update(E.uInvariantBoundingSphere, E2.fromSphere(E.uInvariantBoundingSphere.ref.value, z));
  }
  function U(E) {
    let R = q1.createRenderableState(E);
    return F(R, E), R;
  }
  function F(E, R) {
    q1.updateRenderableState(E, R), E.opaque = E.opaque && !R.xrayShaded, E.writeDepth = E.opaque;
  }
})(T7 || (T7 = {}));

// node_modules/molstar/lib/mol-geo/geometry/geometry.js
var n7;
(function(Z) {
  function J(W) {
    switch (W.kind) {
      case "mesh":
        return W.triangleCount * 3;
      case "points":
        return W.pointCount;
      case "spheres":
        return W.sphereCount * 2 * 3;
      case "cylinders":
        return W.cylinderCount * 4 * 3;
      case "text":
        return W.charCount * 2 * 3;
      case "lines":
        return W.lineCount * 2 * 3;
      case "direct-volume":
        return 36;
      case "image":
        return 6;
      case "texture-mesh":
        return W.vertexCount;
    }
  }
  Z.getDrawCount = J;
  function $(W) {
    switch (W.kind) {
      case "mesh":
        return W.vertexCount;
      case "points":
        return W.pointCount;
      case "spheres":
        return W.sphereCount * 6;
      case "cylinders":
        return W.cylinderCount * 6;
      case "text":
        return W.charCount * 4;
      case "lines":
        return W.lineCount * 4;
      case "direct-volume":
        let [K, G, H] = W.gridDimension.ref.value;
        return K * G * H;
      case "image":
        return 4;
      case "texture-mesh":
        return W.vertexCount;
    }
  }
  Z.getVertexCount = $;
  function X(W) {
    switch (W.kind) {
      case "mesh":
      case "points":
      case "spheres":
      case "cylinders":
      case "text":
      case "lines":
        return J(W) === 0 ? 0 : yX(W.groupBuffer.ref.value) + 1;
      case "direct-volume":
        return 1;
      case "image":
        return jE0(W.groupTexture.ref.value.array, 4) + 1;
      case "texture-mesh":
        return W.groupCount;
    }
  }
  Z.getGroupCount = X;
  function Y(W) {
    switch (W.kind) {
      case "mesh":
        return n1.Utils;
      case "points":
        return YX.Utils;
      case "spheres":
        return R$.Utils;
      case "cylinders":
        return T7.Utils;
      case "text":
        return IJ.Utils;
      case "lines":
        return f6.Utils;
      case "direct-volume":
        return gX.Utils;
      case "image":
        return VY.Utils;
      case "texture-mesh":
        return iJ.Utils;
    }
  }
  Z.getUtils = Y;
  function Q(W, K) {
    return K === "instance" && W.nonInstanceable ? "group" : K;
  }
  Z.getGranularity = Q;
})(n7 || (n7 = {}));

// node_modules/molstar/lib/mol-theme/size/shape-group.js
var JJ1 = 1, $J1 = "Assigns sizes as defined by the shape object.", pE0 = {};
function XJ1(Z) {
  return pE0;
}
function gh(Z, J) {
  return {
    factory: gh,
    granularity: "groupInstance",
    size: ($) => {
      if (x$.isLocation($))
        return $.shape.getSize($.group, $.instance);
      return JJ1;
    },
    props: J,
    description: $J1
  };
}
var uE0 = {
  name: "shape-group",
  label: "Shape Group",
  category: "",
  factory: gh,
  getParams: XJ1,
  defaultValues: j.getDefaultValues(pE0),
  isApplicable: (Z) => !!Z.shape
};

// node_modules/molstar/lib/mol-theme/color/shape-group.js
var YJ1 = i0(13421772), QJ1 = "Assigns colors as defined by the shape object.", cE0 = {};
function WJ1(Z) {
  return cE0;
}
function mh(Z, J) {
  return {
    factory: mh,
    granularity: "groupInstance",
    color: ($) => {
      if (x$.isLocation($))
        return $.shape.getColor($.group, $.instance);
      return YJ1;
    },
    props: J,
    description: QJ1
  };
}
var lE0 = {
  name: "shape-group",
  label: "Shape Group",
  category: $8.Misc,
  factory: mh,
  getParams: WJ1,
  defaultValues: j.getDefaultValues(cE0),
  isApplicable: (Z) => !!Z.shape
};

// node_modules/molstar/lib/mol-gl/renderable/direct-volume.js
var KJ1 = {
  ...jY,
  aPosition: a6("float32", 3, 0),
  elements: k3("uint32"),
  uBboxMin: _0("v3"),
  uBboxMax: _0("v3"),
  uBboxSize: _0("v3"),
  uMaxSteps: _0("i"),
  uStepScale: _0("f"),
  uJumpLength: _0("f"),
  uTransform: _0("m4"),
  uGridDim: _0("v3"),
  tTransferTex: o1("image-uint8", "alpha", "ubyte", "linear"),
  uTransferScale: _0("f", "material"),
  dGridTexType: p1("string", ["2d", "3d"]),
  uGridTexDim: _0("v3"),
  tGridTex: o1("texture", "rgba", "ubyte", "linear"),
  uGridStats: _0("v4"),
  uCellDim: _0("v3"),
  uCartnToUnit: _0("m4"),
  uUnitToCartn: _0("m4"),
  dPackedGroup: p1("boolean"),
  dAxisOrder: p1("string", ["012", "021", "102", "120", "201", "210"]),
  dIgnoreLight: p1("boolean"),
  dCelShaded: p1("boolean"),
  dXrayShaded: p1("string", ["off", "on", "inverted"]),
  meta: zZ("unknown")
};
function nE0(Z, J, $, X, Y, Q, W) {
  let K = { ...MY, ...AY, ...BY, ...wY, ...KJ1 };
  if (!Z.isWebGL2)
    K.uMaxSteps = p1("number");
  let G = {
    ...$,
    uObjectId: C.create(J),
    dLightCount: C.create(W.dLightCount),
    dColorMarker: C.create(W.dColorMarker)
  }, N = TY(Z, "triangles", YR0, K, G, Y, Q);
  return _Y(N, G, X);
}

// node_modules/molstar/lib/mol-gl/renderable/mesh.js
var GJ1 = {
  ...jY,
  aGroup: a6("float32", 1, 0),
  aPosition: a6("float32", 3, 0),
  aNormal: a6("float32", 3, 0),
  elements: k3("uint32"),
  dVaryingGroup: p1("boolean"),
  dFlatShaded: p1("boolean"),
  uDoubleSided: _0("b", "material"),
  dFlipSided: p1("boolean"),
  dIgnoreLight: p1("boolean"),
  dCelShaded: p1("boolean"),
  dXrayShaded: p1("string", ["off", "on", "inverted"]),
  dTransparentBackfaces: p1("string", ["off", "on", "opaque"]),
  uBumpFrequency: _0("f", "material"),
  uBumpAmplitude: _0("f", "material"),
  uInteriorColor: _0("v4"),
  uInteriorSubstance: _0("v4"),
  meta: zZ("unknown")
};
function iE0(Z, J, $, X, Y, Q, W) {
  let K = { ...MY, ...AY, ...BY, ...wY, ...GJ1 }, G = {
    ...$,
    uObjectId: C.create(J),
    dLightCount: C.create(W.dLightCount),
    dColorMarker: C.create(W.dColorMarker)
  }, N = TY(Z, "triangles", Mh, K, G, Y, Q);
  return _Y(N, G, X);
}

// node_modules/molstar/lib/mol-gl/renderable/points.js
var HJ1 = {
  ...jY,
  ...cN,
  aGroup: a6("float32", 1, 0),
  aPosition: a6("float32", 3, 0),
  dPointSizeAttenuation: p1("boolean"),
  dPointStyle: p1("string", ["square", "circle", "fuzzy"])
};
function oE0(Z, J, $, X, Y, Q, W) {
  let K = { ...MY, ...AY, ...BY, ...wY, ...HJ1 }, G = {
    ...$,
    uObjectId: C.create(J),
    dLightCount: C.create(W.dLightCount),
    dColorMarker: C.create(W.dColorMarker)
  }, N = TY(Z, "points", eL0, K, G, Y, Q);
  return _Y(N, G, X);
}

// node_modules/molstar/lib/mol-gl/renderable/lines.js
var NJ1 = {
  ...jY,
  ...cN,
  aGroup: a6("float32", 1, 0),
  aMapping: a6("float32", 2, 0),
  aStart: a6("float32", 3, 0),
  aEnd: a6("float32", 3, 0),
  elements: k3("uint32"),
  dLineSizeAttenuation: p1("boolean"),
  uDoubleSided: _0("b", "material"),
  dFlipSided: p1("boolean")
};
function sE0(Z, J, $, X, Y, Q, W) {
  let K = { ...MY, ...AY, ...BY, ...wY, ...NJ1 }, G = {
    ...$,
    uObjectId: C.create(J),
    dLightCount: C.create(W.dLightCount),
    dColorMarker: C.create(W.dColorMarker)
  }, N = TY(Z, "triangles", XR0, K, G, Y, Q);
  return _Y(N, G, X);
}

// node_modules/molstar/lib/mol-gl/renderable/spheres.js
var qJ1 = {
  ...jY,
  ...cN,
  uTexDim: _0("v2"),
  tPositionGroup: o1("image-float32", "rgba", "float", "nearest"),
  padding: zZ("number"),
  uDoubleSided: _0("b", "material"),
  dIgnoreLight: p1("boolean"),
  dCelShaded: p1("boolean"),
  dXrayShaded: p1("string", ["off", "on", "inverted"]),
  dTransparentBackfaces: p1("string", ["off", "on", "opaque"]),
  dSolidInterior: p1("boolean"),
  dClipPrimitive: p1("boolean"),
  dApproximate: p1("boolean"),
  uAlphaThickness: _0("f"),
  uBumpFrequency: _0("f", "material"),
  uBumpAmplitude: _0("f", "material"),
  uInteriorColor: _0("v4"),
  uInteriorSubstance: _0("v4"),
  lodLevels: zZ("unknown"),
  centerBuffer: zZ("float32"),
  groupBuffer: zZ("float32")
};
function aE0(Z, J, $, X, Y, Q, W) {
  let K = { ...MY, ...AY, ...BY, ...wY, ...qJ1 }, G = {
    ...$,
    uObjectId: C.create(J),
    dLightCount: C.create(W.dLightCount),
    dColorMarker: C.create(W.dColorMarker)
  }, N = TY(Z, "triangles", ZR0, K, G, Y, Q);
  return _Y(N, G, X);
}

// node_modules/molstar/lib/mol-gl/renderable/text.js
var FJ1 = {
  ...jY,
  ...cN,
  aGroup: a6("float32", 1, 0),
  aPosition: a6("float32", 3, 0),
  aMapping: a6("float32", 2, 0),
  aDepth: a6("float32", 1, 0),
  elements: k3("uint32"),
  aTexCoord: a6("float32", 2, 0),
  tFont: o1("image-uint8", "alpha", "ubyte", "linear"),
  padding: zZ("number"),
  uBorderWidth: _0("f", "material"),
  uBorderColor: _0("v3", "material"),
  uOffsetX: _0("f", "material"),
  uOffsetY: _0("f", "material"),
  uOffsetZ: _0("f", "material"),
  uBackgroundColor: _0("v3", "material"),
  uBackgroundOpacity: _0("f", "material")
};
function rE0(Z, J, $, X, Y, Q, W) {
  let K = { ...MY, ...AY, ...BY, ...wY, ...FJ1 }, G = {
    ...$,
    uObjectId: C.create(J),
    dLightCount: C.create(W.dLightCount),
    dColorMarker: C.create(W.dColorMarker)
  }, N = TY(Z, "triangles", $R0, K, G, Y, Q);
  return _Y(N, G, X);
}

// node_modules/molstar/lib/mol-gl/renderable/texture-mesh.js
var UJ1 = {
  ...jY,
  uGeoTexDim: _0("v2", "buffered"),
  tPosition: o1("texture", "rgb", "float", "nearest"),
  tGroup: o1("texture", "alpha", "float", "nearest"),
  tNormal: o1("texture", "rgb", "float", "nearest"),
  dVaryingGroup: p1("boolean"),
  dFlatShaded: p1("boolean"),
  uDoubleSided: _0("b", "material"),
  dFlipSided: p1("boolean"),
  dIgnoreLight: p1("boolean"),
  dCelShaded: p1("boolean"),
  dXrayShaded: p1("string", ["off", "on", "inverted"]),
  dTransparentBackfaces: p1("string", ["off", "on", "opaque"]),
  uBumpFrequency: _0("f", "material"),
  uBumpAmplitude: _0("f", "material"),
  uInteriorColor: _0("v4"),
  uInteriorSubstance: _0("v4"),
  meta: zZ("unknown")
};
function tE0(Z, J, $, X, Y, Q, W) {
  let K = { ...MY, ...AY, ...BY, ...wY, ...UJ1 }, G = {
    ...$,
    uObjectId: C.create(J),
    dLightCount: C.create(W.dLightCount),
    dColorMarker: C.create(W.dColorMarker)
  }, N = TY(Z, "triangles", Mh, K, G, Y, Q);
  return _Y(N, G, X);
}

// node_modules/molstar/lib/mol-gl/renderable/image.js
var LJ1 = {
  ...jY,
  aGroup: a6("float32", 1, 0),
  aPosition: a6("float32", 3, 0),
  aUv: a6("float32", 2, 0),
  elements: k3("uint32"),
  uImageTexDim: _0("v2"),
  tImageTex: o1("image-uint8", "rgba", "ubyte", "nearest"),
  tGroupTex: o1("image-uint8", "rgba", "ubyte", "nearest"),
  tValueTex: o1("image-float32", "alpha", "float", "linear"),
  uTrimType: _0("i"),
  uTrimCenter: _0("v3"),
  uTrimRotation: _0("q"),
  uTrimScale: _0("v3"),
  uTrimTransform: _0("m4"),
  uIsoLevel: _0("f"),
  dInterpolation: p1("string", ["nearest", "catmulrom", "mitchell", "bspline"])
};
function eE0(Z, J, $, X, Y, Q, W) {
  let K = { ...MY, ...AY, ...BY, ...wY, ...LJ1 }, G = {
    ...$,
    uObjectId: C.create(J),
    dLightCount: C.create(W.dLightCount),
    dColorMarker: C.create(W.dColorMarker)
  }, N = TY(Z, "triangles", QR0, K, G, Y, Q);
  return _Y(N, G, X);
}

// node_modules/molstar/lib/mol-gl/renderable/cylinders.js
var RJ1 = {
  ...jY,
  ...cN,
  aGroup: a6("float32", 1, 0),
  aStart: a6("float32", 3, 0),
  aEnd: a6("float32", 3, 0),
  aMapping: a6("float32", 3, 0),
  aScale: a6("float32", 1, 0),
  aCap: a6("float32", 1, 0),
  aColorMode: a6("float32", 1, 0),
  elements: k3("uint32"),
  padding: zZ("number"),
  uDoubleSided: _0("b", "material"),
  dIgnoreLight: p1("boolean"),
  dCelShaded: p1("boolean"),
  dXrayShaded: p1("string", ["off", "on", "inverted"]),
  dTransparentBackfaces: p1("string", ["off", "on", "opaque"]),
  dSolidInterior: p1("boolean"),
  uBumpFrequency: _0("f", "material"),
  uBumpAmplitude: _0("f", "material"),
  uInteriorColor: _0("v4"),
  uInteriorSubstance: _0("v4"),
  dDualColor: p1("boolean")
};
function ZO0(Z, J, $, X, Y, Q, W) {
  let K = { ...MY, ...AY, ...BY, ...wY, ...RJ1 }, G = {
    ...$,
    uObjectId: C.create(J),
    dLightCount: C.create(W.dLightCount),
    dColorMarker: C.create(W.dColorMarker)
  }, N = TY(Z, "triangles", JR0, K, G, Y, Q);
  return _Y(N, G, X);
}

// node_modules/molstar/lib/mol-gl/render-object.js
var EJ1 = $7(0, 2147483647), bW = $7(0, 2147483647);
function v3(Z, J, $, X) {
  return { id: EJ1(), type: Z, values: J, state: $, materialId: X };
}
function JO0(Z, J, $, X) {
  switch (J.type) {
    case "mesh":
      return iE0(Z, J.id, J.values, J.state, J.materialId, $, X);
    case "points":
      return oE0(Z, J.id, J.values, J.state, J.materialId, $, X);
    case "spheres":
      return aE0(Z, J.id, J.values, J.state, J.materialId, $, X);
    case "cylinders":
      return ZO0(Z, J.id, J.values, J.state, J.materialId, $, X);
    case "text":
      return rE0(Z, J.id, J.values, J.state, J.materialId, $, X);
    case "lines":
      return sE0(Z, J.id, J.values, J.state, J.materialId, $, X);
    case "direct-volume":
      return nE0(Z, J.id, J.values, J.state, J.materialId, $, X);
    case "image":
      return eE0(Z, J.id, J.values, J.state, J.materialId, $, X);
    case "texture-mesh":
      return tE0(Z, J.id, J.values, J.state, J.materialId, $, X);
  }
  T8(J.type);
}

// node_modules/molstar/lib/mol-model/shape/shape.js
var c8;
(function(Z) {
  function J(N, q, U, F, E, R, z, D) {
    return {
      id: R6.create22(),
      name: N,
      sourceData: q,
      geometry: U,
      transforms: z || [e.identity()],
      get groupCount() {
        return D !== null && D !== void 0 ? D : n7.getGroupCount(U);
      },
      getColor: F,
      getSize: E,
      getLabel: R
    };
  }
  Z.create = J;
  function $(N) {
    return {
      color: mh({ shape: N }, {}),
      size: gh({ shape: N }, {})
    };
  }
  Z.getTheme = $;
  function X(N) {
    let q = N.transforms.length, U = x$.Location(N), F = (E, R) => {
      return U.group = E, U.instance = R, U;
    };
    return X6(N.groupCount, q, 1, F);
  }
  Z.groupIterator = X;
  function Y(N, q, U, F, E) {
    let R = E && E.aTransform.ref.value.length >= N.length * 16 ? E.aTransform.ref.value : new Float32Array(N.length * 16);
    for (let z = 0, D = N.length;z < D; ++z)
      e.toArray(N[z], R, z * 16);
    return zz(R, N.length, q, U, F, E);
  }
  Z.createTransform = Y;
  function Q(N, q) {
    let U = $(N), F = n7.getUtils(N.geometry), E = bW(), R = X(N), z = Y(N.transforms, N.geometry.boundingSphere, q.cellSize, q.batchSize), D = F.createValues(N.geometry, z, R, U, q), A = F.createRenderableState(q);
    return v3(N.geometry.kind, D, A, E);
  }
  Z.createRenderObject = Q;
  function W(N) {
    return { kind: "shape-loci", shape: N };
  }
  Z.Loci = W;
  function K(N) {
    return !!N && N.kind === "shape-loci";
  }
  Z.isLoci = K;
  function G(N, q) {
    return N.shape === q.shape;
  }
  Z.areLociEqual = G;
  function H(N) {
    return N.shape.groupCount === 0;
  }
  Z.isLociEmpty = H;
})(c8 || (c8 = {}));
var x$;
(function(Z) {
  function J(F, E = 0, R = 0) {
    return { kind: "group-location", shape: F, group: E, instance: R };
  }
  Z.Location = J;
  function $(F) {
    return !!F && F.kind === "group-location";
  }
  Z.isLocation = $;
  function X(F, E) {
    return { kind: "group-loci", shape: F, groups: E };
  }
  Z.Loci = X;
  function Y(F) {
    return !!F && F.kind === "group-loci";
  }
  Z.isLoci = Y;
  function Q(F, E) {
    if (F.shape !== E.shape)
      return !1;
    if (F.groups.length !== E.groups.length)
      return !1;
    for (let R = 0, z = F.groups.length;R < z; ++R) {
      let { ids: D, instance: A } = F.groups[R], { ids: B, instance: T } = E.groups[R];
      if (A !== T)
        return !1;
      if (!f0.areEqual(D, B))
        return !1;
    }
    return !0;
  }
  Z.areLociEqual = Q;
  function W(F) {
    return K(F) === 0 ? !0 : !1;
  }
  Z.isLociEmpty = W;
  function K(F) {
    let E = 0;
    for (let R of F.groups)
      E += f0.size(R.ids);
    return E;
  }
  Z.size = K;
  let G = new yQ, H = M.zero();
  function N(F, E, R, z) {
    let { indices: D, offsets: A } = E;
    for (let { ids: B, instance: T } of F)
      f0.forEach(B, (w) => {
        for (let V = A[w], P = A[w + 1];V < P; ++V)
          M.fromArray(H, R, D[V] * 3), M.transformMat4(H, H, z[T]), G.includeStep(H);
      });
  }
  function q(F, E, R, z) {
    let { indices: D, offsets: A } = E;
    for (let { ids: B, instance: T } of F)
      f0.forEach(B, (w) => {
        for (let V = A[w], P = A[w + 1];V < P; ++V)
          M.fromArray(H, R, D[V] * 3), M.transformMat4(H, H, z[T]), G.radiusStep(H);
      });
  }
  function U(F, E) {
    if (!E)
      E = C0();
    G.reset();
    let R = 0, { geometry: z, transforms: D } = F.shape;
    if (z.kind === "mesh" || z.kind === "points") {
      let A = z.kind === "mesh" ? z.vertexBuffer.ref.value : z.centerBuffer.ref.value;
      N(F.groups, z.groupMapping, A, D), G.finishedIncludeStep(), q(F.groups, z.groupMapping, A, D);
    } else if (z.kind === "lines") {
      let A = z.startBuffer.ref.value, B = z.endBuffer.ref.value;
      N(F.groups, z.groupMapping, A, D), N(F.groups, z.groupMapping, B, D), G.finishedIncludeStep(), q(F.groups, z.groupMapping, A, D), q(F.groups, z.groupMapping, B, D);
    } else if (z.kind === "spheres" || z.kind === "text") {
      let A = z.centerBuffer.ref.value;
      N(F.groups, z.groupMapping, A, D), G.finishedIncludeStep(), q(F.groups, z.groupMapping, A, D);
      for (let { ids: B, instance: T } of F.groups)
        f0.forEach(B, (w) => {
          let V = F.shape.getSize(w, T);
          if (R < V)
            R = V;
        });
    } else
      return C0.copy(E, z.boundingSphere);
    return M.copy(E.center, G.center), E.radius = Math.sqrt(G.radiusSq), C0.expand(E, E, R), E;
  }
  Z.getBoundingSphere = U;
})(x$ || (x$ = {}));
// node_modules/molstar/lib/mol-model/loci.js
var nN = { kind: "every-loci" };
function KJ(Z) {
  return !!Z && Z.kind === "every-loci";
}
var G8 = { kind: "empty-loci" };
function _7(Z) {
  return !!Z && Z.kind === "empty-loci";
}
function Mz(Z) {
  return !!Z && Z.kind === "data-loci";
}
function OJ1(Z, J) {
  if (!xO(Z.data, J.data) || Z.tag !== J.tag)
    return !1;
  if (Z.elements.length !== J.elements.length)
    return !1;
  for (let $ = 0, X = Z.elements.length;$ < X; ++$)
    if (!xO(Z.elements[$], J.elements[$]))
      return !1;
  return !0;
}
function zJ1(Z) {
  return Z.elements.length === 0 ? !0 : !1;
}
function PR(Z, J, $, X, Y) {
  return { kind: "data-loci", tag: Z, data: J, elements: $, getBoundingSphere: X, getLabel: Y };
}
var d2;
(function(Z) {
  let J = new $J("98");
  function $(R) {
    let z = R.loci.map((D) => K(D)).filter((D) => !!D);
    J.reset();
    for (let D of z)
      J.includePositionRadius(D.center, D.radius);
    J.finishedIncludeStep();
    for (let D of z)
      J.radiusPositionRadius(D.center, D.radius);
    return J.getSphere();
  }
  Z.getBundleBoundingSphere = $;
  function X(R, z) {
    if (KJ(R) && KJ(z))
      return !0;
    if (_7(R) && _7(z))
      return !0;
    if (Mz(R) && Mz(z))
      return OJ1(R, z);
    if (s0.isLoci(R) && s0.isLoci(z))
      return s0.areLociEqual(R, z);
    if (W0.Loci.is(R) && W0.Loci.is(z))
      return W0.Loci.areEqual(R, z);
    if ($2.isLoci(R) && $2.isLoci(z))
      return $2.areLociEqual(R, z);
    if (c8.isLoci(R) && c8.isLoci(z))
      return c8.areLociEqual(R, z);
    if (x$.isLoci(R) && x$.isLoci(z))
      return x$.areLociEqual(R, z);
    if (Q1.isLoci(R) && Q1.isLoci(z))
      return Q1.areLociEqual(R, z);
    if (Q1.Isosurface.isLoci(R) && Q1.Isosurface.isLoci(z))
      return Q1.Isosurface.areLociEqual(R, z);
    if (Q1.Cell.isLoci(R) && Q1.Cell.isLoci(z))
      return Q1.Cell.areLociEqual(R, z);
    if (Q1.Segment.isLoci(R) && Q1.Segment.isLoci(z))
      return Q1.Segment.areLociEqual(R, z);
    return !1;
  }
  Z.areEqual = X;
  function Y(R) {
    return !!R && R.kind === "every-loci";
  }
  Z.isEvery = Y;
  function Q(R) {
    if (KJ(R))
      return !1;
    if (_7(R))
      return !0;
    if (Mz(R))
      return zJ1(R);
    if (s0.isLoci(R))
      return s0.isLociEmpty(R);
    if (W0.Loci.is(R))
      return W0.Loci.isEmpty(R);
    if ($2.isLoci(R))
      return $2.isLociEmpty(R);
    if (c8.isLoci(R))
      return c8.isLociEmpty(R);
    if (x$.isLoci(R))
      return x$.isLociEmpty(R);
    if (Q1.isLoci(R))
      return Q1.isLociEmpty(R);
    if (Q1.Isosurface.isLoci(R))
      return Q1.Isosurface.isLociEmpty(R);
    if (Q1.Cell.isLoci(R))
      return Q1.Cell.isLociEmpty(R);
    if (Q1.Segment.isLoci(R))
      return Q1.Segment.isLociEmpty(R);
    return !1;
  }
  Z.isEmpty = Q;
  function W(R, z) {
    if (z instanceof s0) {
      if (W0.Loci.is(R))
        R = W0.Loci.remap(R, z);
      else if (s0.isLoci(R))
        R = s0.remapLoci(R, z);
      else if ($2.isLoci(R))
        R = $2.remapLoci(R, z);
    }
    return R;
  }
  Z.remap = W;
  function K(R, z) {
    var D;
    if (R.kind === "every-loci" || R.kind === "empty-loci")
      return;
    if (!z)
      z = C0();
    if (R.kind === "structure-loci")
      return C0.copy(z, R.structure.boundary.sphere);
    else if (R.kind === "element-loci")
      return C0.copy(z, W0.Loci.getBoundary(R).sphere);
    else if (R.kind === "bond-loci")
      return $2.getBoundingSphere(R, z);
    else if (R.kind === "shape-loci")
      return C0.copy(z, R.shape.geometry.boundingSphere);
    else if (R.kind === "group-loci")
      return x$.getBoundingSphere(R, z);
    else if (R.kind === "data-loci")
      return (D = R.getBoundingSphere) === null || D === void 0 ? void 0 : D.call(R, z);
    else if (R.kind === "volume-loci")
      return Q1.getBoundingSphere(R.volume, z);
    else if (R.kind === "isosurface-loci")
      return Q1.Isosurface.getBoundingSphere(R.volume, R.isoValue, z);
    else if (R.kind === "cell-loci")
      return Q1.Cell.getBoundingSphere(R.volume, R.elements, z);
    else if (R.kind === "segment-loci")
      return Q1.Segment.getBoundingSphere(R.volume, R.elements, z);
  }
  Z.getBoundingSphere = K;
  let G = C0.zero();
  function H(R, z) {
    let D = K(R, G);
    return D ? M.copy(z || M(), D.center) : void 0;
  }
  Z.getCenter = H;
  function N(R) {
    if (R.kind === "every-loci" || R.kind === "empty-loci")
      return;
    if (R.kind === "structure-loci")
      return W0.Loci.getPrincipalAxes(s0.toStructureElementLoci(R.structure));
    else if (R.kind === "element-loci")
      return W0.Loci.getPrincipalAxes(R);
    else if (R.kind === "bond-loci")
      return;
    else if (R.kind === "shape-loci")
      return;
    else if (R.kind === "group-loci")
      return;
    else if (R.kind === "data-loci")
      return;
    else if (R.kind === "volume-loci")
      return;
    else if (R.kind === "isosurface-loci")
      return;
    else if (R.kind === "cell-loci")
      return;
    else if (R.kind === "segment-loci")
      return;
  }
  Z.getPrincipalAxes = N;
  let q = {
    element: (R) => R,
    residue: (R) => {
      return W0.Loci.is(R) ? W0.Loci.extendToWholeResidues(R, !0) : R;
    },
    chain: (R) => {
      return W0.Loci.is(R) ? W0.Loci.extendToWholeChains(R) : R;
    },
    entity: (R) => {
      return W0.Loci.is(R) ? W0.Loci.extendToWholeEntities(R) : R;
    },
    model: (R) => {
      return W0.Loci.is(R) ? W0.Loci.extendToWholeModels(R) : R;
    },
    operator: (R) => {
      return W0.Loci.is(R) ? W0.Loci.extendToWholeOperators(R) : R;
    },
    structure: (R) => {
      return W0.Loci.is(R) ? s0.toStructureElementLoci(R.structure) : x$.isLoci(R) ? c8.Loci(R.shape) : Q1.Cell.isLoci(R) ? Q1.Loci(R.volume, k0.ofLength(R.volume.instances.length)) : Q1.Isosurface.isLoci(R) ? Q1.Loci(R.volume, k0.ofLength(R.volume.instances.length)) : R;
    },
    elementInstances: (R) => {
      return W0.Loci.is(R) ? W0.Loci.extendToAllInstances(R) : R;
    },
    residueInstances: (R) => {
      return W0.Loci.is(R) ? W0.Loci.extendToAllInstances(W0.Loci.extendToWholeResidues(R, !0)) : R;
    },
    chainInstances: (R) => {
      return W0.Loci.is(R) ? W0.Loci.extendToAllInstances(W0.Loci.extendToWholeChains(R)) : R;
    }
  };
  Z.GranularityOptions = j.objectToOptions(q, (R) => {
    switch (R) {
      case "element":
        return "Atom/Coarse Element";
      case "elementInstances":
        return ["Atom/Coarse Element Instances", "With Symmetry"];
      case "structure":
        return "Structure/Shape";
      default:
        return R.indexOf("Instances") ? [v$(R), "With Symmetry"] : v$(R);
    }
  });
  function U(R) {
    return R.replace("Instances", "");
  }
  Z.simpleGranularity = U;
  function F(R, z) {
    return q[z](R);
  }
  Z.applyGranularity = F;
  function E(R, z, D = !1) {
    if ((z !== "element" || D) && $2.isLoci(R))
      R = $2.toStructureElementLoci(R);
    if (s0.isLoci(R))
      R = s0.toStructureElementLoci(R.structure);
    if (W0.Loci.is(R))
      R = W0.Loci.remap(R, R.structure.root);
    if (z)
      R = F(R, z);
    return R;
  }
  Z.normalize = E;
})(d2 || (d2 = {}));

// node_modules/molstar/lib/mol-util/single-async-queue.js
class Ca {
  constructor(Z = !1) {
    this.isRunning = !1, this.queue = [], this.counter = 0, this.log = Z;
  }
  enqueue(Z) {
    if (this.log)
      console.log("SingleAsyncQueue enqueue", this.counter);
    this.queue[0] = { id: this.counter, func: Z }, this.counter++, this.run();
  }
  async run() {
    if (this.isRunning)
      return;
    let Z = this.queue.pop();
    if (!Z)
      return;
    this.isRunning = !0;
    try {
      if (this.log)
        console.log("SingleAsyncQueue run", Z.id);
      if (await Z.func(), this.log)
        console.log("SingleAsyncQueue complete", Z.id);
    } finally {
      this.isRunning = !1, this.run();
    }
  }
}

// node_modules/molstar/lib/mol-plugin/behavior/dynamic/volume-streaming/behavior.js
class y$ extends D0.CreateBehavior({ name: "Volume Streaming" }) {
}
(function(Z) {
  Z.RootTag = "volume-streaming-info";
  function J(G, H, N, q, U = {}) {
    var F, E, R, z;
    return j.Group({
      isoValue: Q1.createIsoValueParam((F = U.isoValue) !== null && F !== void 0 ? F : N, q),
      color: j.Color((E = U.color) !== null && E !== void 0 ? E : H),
      wireframe: j.Boolean((R = U.wireframe) !== null && R !== void 0 ? R : !1),
      opacity: j.Numeric((z = U.opacity) !== null && z !== void 0 ? z : 0.3, { min: 0, max: 1, step: 0.01 })
    }, { label: G, isExpanded: !0 });
  }
  let $ = {
    byteOffset: 0,
    rate: 1,
    sampleCount: [1, 1, 1],
    valuesInfo: [{ mean: 0, min: -1, max: 1, sigma: 0.1 }, { mean: 0, min: -1, max: 1, sigma: 0.1 }]
  };
  function X(G = {}) {
    let { data: H, defaultView: N, channelParams: q } = G, U = /* @__PURE__ */ new Map;
    if (H)
      H.entries.forEach((R) => U.set(R.dataId, R));
    let F = H ? H.entries.map((R) => [R.dataId, R.dataId]) : [], E = H ? H.entries[0].dataId : "";
    return {
      entry: j.Mapped(E, F, (R) => j.Group(Y({ entryData: U.get(R), defaultView: N, structure: H && H.structure, channelParams: q })))
    };
  }
  Z.createParams = X;
  function Y(G) {
    let { entryData: H, defaultView: N, structure: q, channelParams: U = {} } = G, F = H || { kind: "em", header: { sampling: [$], availablePrecisions: [{ precision: 0, maxVoxels: 0 }] }, emDefaultContourLevel: Q1.IsoValue.relative(0) }, E = q && q.boundary.box || t1();
    return {
      view: j.MappedStatic(N || (F.kind === "em" ? "auto" : "selection-box"), {
        off: j.Group({}),
        box: j.Group({
          bottomLeft: j.Vec3(E.min),
          topRight: j.Vec3(E.max)
        }, { description: "Static box defined by cartesian coords.", isFlat: !0 }),
        "selection-box": j.Group({
          radius: j.Numeric(5, { min: 0, max: 50, step: 0.5 }, { description: "Radius in Å within which the volume is shown." }),
          bottomLeft: j.Vec3(M.create(0, 0, 0), {}, { isHidden: !0 }),
          topRight: j.Vec3(M.create(0, 0, 0), {}, { isHidden: !0 })
        }, { description: "Box around focused element.", isFlat: !0 }),
        "camera-target": j.Group({
          radius: j.Numeric(0.5, { min: 0, max: 1, step: 0.05 }, { description: "Radius within which the volume is shown (relative to the field of view)." }),
          dynamicDetailLevel: Q(F.header.availablePrecisions, 0, { label: "Dynamic Detail" }),
          bottomLeft: j.Vec3(M.create(0, 0, 0), {}, { isHidden: !0 }),
          topRight: j.Vec3(M.create(0, 0, 0), {}, { isHidden: !0 })
        }, { description: "Box around camera target.", isFlat: !0 }),
        cell: j.Group({}),
        auto: j.Group({
          radius: j.Numeric(5, { min: 0, max: 50, step: 0.5 }, { description: "Radius in Å within which the volume is shown." }),
          selectionDetailLevel: Q(F.header.availablePrecisions, 6, { label: "Selection Detail" }),
          isSelection: j.Boolean(!1, { isHidden: !0 }),
          bottomLeft: j.Vec3(E.min, {}, { isHidden: !0 }),
          topRight: j.Vec3(E.max, {}, { isHidden: !0 })
        }, { description: "Box around focused element.", isFlat: !0 })
      }, { options: Z.ViewTypeOptions, description: 'Controls what of the volume is displayed. "Off" hides the volume alltogether. "Bounded box" shows the volume inside the given box. "Around Interaction" shows the volume around the focused element/atom. "Whole Structure" shows the volume for the whole structure.' }),
      detailLevel: Q(F.header.availablePrecisions, 3),
      channels: F.kind === "em" ? j.Group({
        em: J("EM", i0(6524815), F.emDefaultContourLevel || Q1.IsoValue.relative(1), F.header.sampling[0].valuesInfo[0], U.em)
      }, { isFlat: !0 }) : j.Group({
        "2fo-fc": J("2Fo-Fc", i0(3367602), Q1.IsoValue.relative(1.5), F.header.sampling[0].valuesInfo[0], U["2fo-fc"]),
        "fo-fc(+ve)": J("Fo-Fc(+ve)", i0(3390259), Q1.IsoValue.relative(3), F.header.sampling[0].valuesInfo[1], U["fo-fc(+ve)"]),
        "fo-fc(-ve)": J("Fo-Fc(-ve)", i0(12268339), Q1.IsoValue.relative(-3), F.header.sampling[0].valuesInfo[1], U["fo-fc(-ve)"])
      }, { isFlat: !0 })
    };
  }
  Z.createEntryParams = Y;
  function Q(G, H, N) {
    return j.Select(Math.min(H, G.length - 1), G.map((q, U) => [U, `${U + 1} [ ${Math.pow(q.maxVoxels, 0.3333333333333333) | 0}^3 cells ]`]), {
      description: "Determines the maximum number of voxels. Depending on the size of the volume options are in the range from 1 (0.52M voxels) to 7 (25.17M voxels).",
      ...N
    });
  }
  function W(G) {
    return {
      entry: {
        name: G.entry.name,
        params: {
          detailLevel: G.entry.params.detailLevel,
          channels: G.entry.params.channels,
          view: {
            name: G.entry.params.view.name,
            params: { ...G.entry.params.view.params }
          }
        }
      }
    };
  }
  Z.copyParams = W, Z.ViewTypeOptions = [["off", "Off"], ["box", "Bounded Box"], ["selection-box", "Around Focus"], ["camera-target", "Around Camera"], ["cell", "Whole Structure"], ["auto", "Auto"]], Z.ChannelTypeOptions = [["em", "em"], ["2fo-fc", "2fo-fc"], ["fo-fc(+ve)", "fo-fc(+ve)"], ["fo-fc(-ve)", "fo-fc(-ve)"]];

  class K extends i8.WithSubscribers {
    get info() {
      return this.infoMap.get(this.params.entry.name);
    }
    async queryData(G) {
      let H = HR(this.data.serverUrl, `${this.info.kind}/${this.info.dataId.toLowerCase()}`);
      if (G) {
        let { min: z, max: D } = G;
        H += `/box/${z.map((A) => Math.round(1000 * A) / 1000).join(",")}/${D.map((A) => Math.round(1000 * A) / 1000).join(",")}`;
      } else
        H += "/cell";
      let N = this.params.entry.params.detailLevel;
      if (this.params.entry.params.view.name === "auto" && this.params.entry.params.view.params.isSelection)
        N = this.params.entry.params.view.params.selectionDetailLevel;
      if (this.params.entry.params.view.name === "camera-target" && G)
        N = this.decideDetail(G, this.params.entry.params.view.params.dynamicDetailLevel);
      H += `?detail=${N}`;
      let q = NA.get(this.cache, H);
      if (q)
        return q.data;
      let U = E6.getUrlAsset(this.plugin.managers.asset, H), F = await this.plugin.runTask(this.plugin.managers.asset.resolve(U, "binary")), E = await this.parseCif(F.data);
      if (!E)
        return;
      let R = NA.set(this.cache, H, { data: E, asset: F });
      if (R)
        R.asset.dispose();
      return E;
    }
    async parseCif(G) {
      let H = await this.plugin.runTask(kW.parseBinary(G));
      if (H.isError) {
        this.plugin.log.error("VolumeStreaming, parsing CIF: " + H.toString());
        return;
      }
      if (H.result.blocks.length < 2) {
        this.plugin.log.error("VolumeStreaming: Invalid data.");
        return;
      }
      let N = {};
      for (let q = 1;q < H.result.blocks.length; q++) {
        let U = H.result.blocks[q], F = kW.schema.densityServer(U), E = await this.plugin.runTask(jf(F));
        N[U.header] = E;
      }
      return N;
    }
    async updateParams(G, H = !1) {
      let N = W(this.params), q = N.entry.params.view.name;
      if (q !== "off" && q !== "cell")
        N.entry.params.view.params.bottomLeft = (G === null || G === void 0 ? void 0 : G.min) || M.zero(), N.entry.params.view.params.topRight = (G === null || G === void 0 ? void 0 : G.max) || M.zero();
      if (q === "auto")
        N.entry.params.view.params.isSelection = H;
      let U = this.plugin.state.data, F = U.build().to(this.ref).update(N);
      await h1.State.Update(this.plugin, { state: U, tree: F, options: { doNotUpdateCurrent: !0 } });
    }
    getStructureRoot() {
      return this.plugin.state.data.select(f2.Generators.byRef(this.ref).rootOfType(D0.Molecule.Structure))[0];
    }
    register(G) {
      this.ref = G, this.subscribeObservable(this.plugin.state.events.object.removed, (H) => {
        if (!D0.Molecule.Structure.is(H.obj) || !W0.Loci.is(this.lastLoci))
          return;
        if (this.lastLoci.structure === H.obj.data)
          this.lastLoci = G8;
      }), this.subscribeObservable(this.plugin.state.events.object.updated, (H) => {
        if (!D0.Molecule.Structure.is(H.oldObj) || !W0.Loci.is(this.lastLoci))
          return;
        if (this.lastLoci.structure === H.oldObj.data)
          this.lastLoci = G8;
      }), this.subscribeObservable(this.plugin.managers.structure.focus.behaviors.current, (H) => {
        if (!this.plugin.state.data.tree.children.has(this.ref))
          return;
        let N = H ? H.loci : G8;
        switch (this.params.entry.params.view.name) {
          case "auto":
            this.updateAuto(N);
            break;
          case "selection-box":
            this.updateSelectionBox(N);
            break;
          default:
            this.lastLoci = N;
            break;
        }
      });
    }
    unregister() {
      let G = this.cache.entries.first;
      while (G)
        G.value.data.asset.dispose(), G = G.next;
    }
    isCameraTargetSame(G, H) {
      if (!G || !H)
        return !1;
      let N = M.equals(G.target, H.target), q = M.squaredDistance(G.target, G.position), U = M.squaredDistance(H.target, H.position), F = Math.abs(q - U) / q < 0.001;
      return N && F;
    }
    cameraTargetDistance(G) {
      return M.distance(G.target, G.position);
    }
    getBoxFromLoci(G) {
      var H, N, q;
      if (d2.isEmpty(G) || _7(G))
        return t1();
      let U = this.plugin.helpers.substructureParent.get(G.structure, !0);
      if (!U)
        return t1();
      let F = this.getStructureRoot();
      if (!F || ((H = F.obj) === null || H === void 0 ? void 0 : H.data) !== ((N = U.obj) === null || N === void 0 ? void 0 : N.data))
        return t1();
      let E = dN.get((q = F.obj) === null || q === void 0 ? void 0 : q.data.models[0]);
      if (E)
        e.invert(this._invTransform, E);
      let R = W0.Loci.extendToWholeResidues(G), z = W0.Loci.getBoundary(R, E && !Number.isNaN(this._invTransform[0]) ? this._invTransform : void 0).box;
      if (W0.Loci.size(R) === 1)
        t1.expand(z, z, M.create(1, 1, 1));
      return z;
    }
    updateAuto(G) {
      this.updateQueue.enqueue(async () => {
        if (this.lastLoci = G, _7(G))
          await this.updateParams(this.info.kind === "x-ray" ? this.data.structure.boundary.box : void 0, !1);
        else
          await this.updateParams(this.getBoxFromLoci(G), !0);
      });
    }
    updateSelectionBox(G) {
      this.updateQueue.enqueue(async () => {
        if (d2.areEqual(this.lastLoci, G))
          this.lastLoci = G8;
        else
          this.lastLoci = G;
        let H = this.getBoxFromLoci(this.lastLoci);
        await this.updateParams(H);
      });
    }
    updateCameraTarget(G) {
      this.updateQueue.enqueue(async () => {
        var H, N, q;
        let U = (H = this.plugin.canvas3d) === null || H === void 0 ? void 0 : H.props.camera.manualReset;
        try {
          if (!U)
            (N = this.plugin.canvas3d) === null || N === void 0 || N.setProps({ camera: { manualReset: !0 } });
          let F = this.boxFromCameraTarget(G, !0);
          await this.updateParams(F);
        } finally {
          if (!U)
            (q = this.plugin.canvas3d) === null || q === void 0 || q.setProps({ camera: { manualReset: U } });
        }
      });
    }
    boxFromCameraTarget(G, H) {
      var N;
      let q = G.target, U = this.cameraTargetDistance(G), E = Math.tan(0.5 * G.fov) * U, R = (N = this.plugin.canvas3d) === null || N === void 0 ? void 0 : N.camera.viewport;
      if (R && R.width > R.height)
        E *= R.width / R.height;
      let z = this.params.entry.params.view.name === "camera-target" ? this.params.entry.params.view.params.radius : 0.5;
      E *= z;
      let D, A, B;
      if (H) {
        let T = M.zero();
        t1.size(T, this.data.structure.boundary.box), D = Math.min(E, 0.5 * T[0]), A = Math.min(E, 0.5 * T[1]), B = Math.min(E, 0.5 * T[2]);
      } else
        D = A = B = E;
      return t1.create(M.create(q[0] - D, q[1] - A, q[2] - B), M.create(q[0] + D, q[1] + A, q[2] + B));
    }
    decideDetail(G, H) {
      let N = this.info.kind === "x-ray" ? t1.volume(this.data.structure.boundary.box) : this.info.header.spacegroup.size.reduce((R, z) => R * z, 1), U = t1.volume(G) / N, F = this.info.header.availablePrecisions.length - 1, E = H;
      while (U <= 0.5 && E < F)
        U *= 2, E += 1;
      return E;
    }
    async update(G) {
      let H = G.entry.params.view.name === "selection-box" && this.params && this.params.entry && this.params.entry.params && this.params.entry.params.view && this.params.entry.params.view.name !== "selection-box";
      this.params = G;
      let N = void 0, q = !1;
      if (G.entry.params.view.name !== "camera-target" && this.cameraTargetSubscription)
        this.cameraTargetSubscription.unsubscribe(), this.cameraTargetSubscription = void 0;
      switch (G.entry.params.view.name) {
        case "off":
          q = !0;
          break;
        case "box":
          N = t1.create(G.entry.params.view.params.bottomLeft, G.entry.params.view.params.topRight), q = t1.volume(N) < 0.0001;
          break;
        case "selection-box": {
          if (H)
            N = this.getBoxFromLoci(this.lastLoci) || t1();
          else
            N = t1.create(M.clone(G.entry.params.view.params.bottomLeft), M.clone(G.entry.params.view.params.topRight));
          let E = G.entry.params.view.params.radius;
          q = t1.volume(N) < 0.0001, t1.expand(N, N, M.create(E, E, E));
          break;
        }
        case "camera-target":
          if (!this.cameraTargetSubscription)
            this.cameraTargetSubscription = this.subscribeObservable(this.cameraTargetObservable, (E) => this.updateCameraTarget(E));
          N = this.boxFromCameraTarget(this.plugin.canvas3d.camera.getSnapshot(), !0);
          break;
        case "cell":
          N = this.info.kind === "x-ray" ? this.data.structure.boundary.box : void 0;
          break;
        case "auto":
          if (N = G.entry.params.view.params.isSelection || this.info.kind === "x-ray" ? t1.create(M.clone(G.entry.params.view.params.bottomLeft), M.clone(G.entry.params.view.params.topRight)) : void 0, N) {
            if (q = t1.volume(N) < 0.0001, G.entry.params.view.params.isSelection) {
              let E = G.entry.params.view.params.radius;
              t1.expand(N, N, M.create(E, E, E));
            }
          }
          break;
      }
      let U = q ? {} : await this.queryData(N);
      if (!U)
        return !1;
      let F = G.entry.params.channels;
      if (this.info.kind === "x-ray")
        this.channels["2fo-fc"] = this.createChannel(U["2FO-FC"] || Q1.One, F["2fo-fc"], this.info.header.sampling[0].valuesInfo[0]), this.channels["fo-fc(+ve)"] = this.createChannel(U["FO-FC"] || Q1.One, F["fo-fc(+ve)"], this.info.header.sampling[0].valuesInfo[1]), this.channels["fo-fc(-ve)"] = this.createChannel(U["FO-FC"] || Q1.One, F["fo-fc(-ve)"], this.info.header.sampling[0].valuesInfo[1]);
      else
        this.channels.em = this.createChannel(U.EM || Q1.One, F.em, this.info.header.sampling[0].valuesInfo[0]);
      return !0;
    }
    createChannel(G, H, N) {
      let q = H;
      return {
        data: G,
        color: q.color,
        wireframe: q.wireframe,
        opacity: q.opacity,
        isoValue: q.isoValue.kind === "relative" ? q.isoValue : Q1.IsoValue.toRelative(q.isoValue, N)
      };
    }
    getDescription() {
      if (this.params.entry.params.view.name === "selection-box")
        return "Selection";
      if (this.params.entry.params.view.name === "camera-target")
        return "Camera";
      if (this.params.entry.params.view.name === "box")
        return "Static Box";
      if (this.params.entry.params.view.name === "cell")
        return "Cell";
      return "";
    }
    constructor(G, H) {
      super(G, {});
      this.plugin = G, this.data = H, this.cache = NA.create(25), this.params = {}, this.lastLoci = G8, this.ref = "", this.cameraTargetObservable = this.plugin.canvas3d.didDraw.pipe(bQ(500, void 0, { leading: !0, trailing: !0 }), w_(() => {
        var N;
        return (N = this.plugin.canvas3d) === null || N === void 0 ? void 0 : N.camera.getSnapshot();
      }), Ci((N, q) => this.isCameraTargetSame(N, q)), fN((N) => N !== void 0)), this.cameraTargetSubscription = void 0, this.channels = {}, this._invTransform = e(), this.infoMap = /* @__PURE__ */ new Map, this.data.entries.forEach((N) => this.infoMap.set(N.dataId, N)), this.updateQueue = new Ca;
    }
  }
  Z.Behavior = K;
})(y$ || (y$ = {}));

// node_modules/molstar/lib/mol-plugin-state/transforms/representation.js
var wt = {};
y9(wt, {
  VolumeRepresentation3DHelpers: () => l3,
  VolumeRepresentation3D: () => CG1,
  UnwindStructureAssemblyRepresentation3D: () => EG1,
  TransparencyStructureRepresentation3DFromScript: () => AG1,
  TransparencyStructureRepresentation3DFromBundle: () => BG1,
  ThemeStrengthRepresentation3D: () => PG1,
  SubstanceStructureRepresentation3DFromScript: () => TG1,
  SubstanceStructureRepresentation3DFromBundle: () => _G1,
  StructureSelectionsPlane3D: () => gG1,
  StructureSelectionsOrientation3D: () => yG1,
  StructureSelectionsLabel3D: () => xG1,
  StructureSelectionsDistance3D: () => fG1,
  StructureSelectionsDihedral3D: () => bG1,
  StructureSelectionsAngle3D: () => hG1,
  StructureRepresentation3D: () => lA,
  StructureBoundingBox3D: () => SG1,
  SpinStructureRepresentation3D: () => zG1,
  ShapeRepresentation3D: () => kG1,
  OverpaintStructureRepresentation3DFromScript: () => DG1,
  OverpaintStructureRepresentation3DFromBundle: () => MG1,
  ModelUnitcell3D: () => vG1,
  ExplodeStructureRepresentation3D: () => OG1,
  EmissiveStructureRepresentation3DFromScript: () => wG1,
  EmissiveStructureRepresentation3DFromBundle: () => jG1,
  ClippingStructureRepresentation3DFromScript: () => VG1,
  ClippingStructureRepresentation3DFromBundle: () => IG1
});

// node_modules/molstar/lib/mol-theme/color/carbohydrate-symbol.js
var dh = i0(13421772), DJ1 = "Assigns colors according to the Symbol Nomenclature for Glycans (SNFG).", $O0 = {};
function MJ1(Z) {
  return $O0;
}
function XO0(Z, J) {
  let $;
  if (Z.structure) {
    let { elements: X, getElementIndices: Y } = Z.structure.carbohydrates, Q = (W, K) => {
      if (!j0.isAtomic(W))
        return dh;
      let G = Y(W, K);
      return G.length > 0 ? X[G[0]].component.color : dh;
    };
    $ = (W, K) => {
      if (K)
        return u2.Secondary;
      else if (W0.Location.is(W))
        return Q(W.unit, W.element);
      else if ($2.isLocation(W))
        return Q(W.aUnit, W.aUnit.elements[W.aIndex]);
      return dh;
    };
  } else
    $ = () => dh;
  return {
    factory: XO0,
    granularity: "group",
    color: $,
    props: J,
    description: DJ1,
    legend: ZX(bH0)
  };
}
var YO0 = {
  name: "carbohydrate-symbol",
  label: "Carbohydrate Symbol",
  category: $8.Residue,
  factory: XO0,
  getParams: MJ1,
  defaultValues: j.getDefaultValues($O0),
  isApplicable: (Z) => {
    return !!Z.structure && Z.structure.models.some((J) => O2.hasCarbohydrate(J));
  }
};

// node_modules/molstar/lib/mol-util/color/distinct.js
var ka = {
  hue: j.Interval([1, 360], { min: 0, max: 360, step: 1 }),
  chroma: j.Interval([40, 70], { min: 0, max: 100, step: 1 }),
  luminance: j.Interval([15, 85], { min: 0, max: 100, step: 1 }),
  sort: j.Select("contrast", j.arrayToOptions(["none", "contrast"]), { description: "no sorting leaves colors approximately ordered by hue" }),
  clusteringStepCount: j.Numeric(50, { min: 10, max: 200, step: 1 }, { isHidden: !0 }),
  minSampleCount: j.Numeric(800, { min: 100, max: 5000, step: 100 }, { isHidden: !0 }),
  sampleCountFactor: j.Numeric(5, { min: 1, max: 100, step: 1 }, { isHidden: !0 })
}, DA = 2, Az = [0, 0, 0], Bz = [0, 0, 0];
function AJ1(Z, J) {
  return TJ.toHcl(Az, Z), TJ.fromColor(Bz, TJ.toColor(Z)), Az[0] >= J.hue[0] && Az[0] <= J.hue[1] && Az[1] >= J.chroma[0] && Az[1] <= J.chroma[1] && Az[2] >= J.luminance[0] && Az[2] <= J.luminance[1] && Bz[0] >= Z[0] - DA && Bz[0] <= Z[0] + DA && Bz[1] >= Z[1] - DA && Bz[1] <= Z[1] + DA && Bz[2] >= Z[2] - DA && Bz[2] <= Z[2] + DA;
}
function BJ1(Z) {
  let J = Z.slice(0), $ = [J.shift()];
  while (J.length > 0) {
    let X = $[$.length - 1], Y = 0, Q = Number.NEGATIVE_INFINITY;
    for (let W = 0;W < J.length; ++W) {
      let K = TJ.distance(X, J[W]);
      if (K > Q)
        Q = K, Y = W;
    }
    $.push(J.splice(Y, 1)[0]);
  }
  return $;
}
function wJ1(Z, J) {
  let $ = /* @__PURE__ */ new Map, X = Math.ceil(Math.cbrt(Z)), Y = R5(), Q = Math.max((J.hue[1] - J.hue[0]) / X, 1), W = Math.max((J.chroma[1] - J.chroma[0]) / X, 1), K = Math.max((J.luminance[1] - J.luminance[0]) / X, 1);
  for (let G = J.hue[0] + Q / 2;G <= J.hue[1]; G += Q)
    for (let H = J.chroma[0] + W / 2;H <= J.chroma[1]; H += W)
      for (let N = J.luminance[0] + K / 2;N <= J.luminance[1]; N += K) {
        let q = TJ.fromHcl(TJ(), R5.set(Y, G, H, N));
        if (AJ1(q, J))
          $.set(TJ.toColor(q), q);
      }
  return Array.from($.values());
}
function QO0(Z, J) {
  let $ = 1 / 0, X = 0;
  for (let Y = 0;Y < Z.length; Y++) {
    let Q = TJ.distance(J, Z[Y]);
    if (Q < $)
      $ = Q, X = Y;
  }
  return X;
}
function WO0(Z, J = {}) {
  let $ = { ...j.getDefaultValues(ka), ...J };
  if (Z <= 0)
    return [];
  let X = wJ1(Math.max($.minSampleCount, Z * $.sampleCountFactor), $);
  if (X.length < Z)
    return console.warn("Not enough samples to generate distinct colors, increase sample count."), new Array(Z).fill(c2.lightgrey);
  let Y = [], Q = [], W = Math.floor(X.length / Z);
  for (let G = 0;G < X.length; G += W)
    if (Y.push(X[G]), Q.push([]), Y.length >= Z)
      break;
  for (let G = 1;G <= $.clusteringStepCount; ++G) {
    let H = W$(Q), N = W$(X);
    for (let U = 0;U < Y.length; ++U) {
      let F = QO0(N, Y[U]);
      H[U].push(X[F]), N.splice(F, 1);
    }
    for (let U = 0;U < N.length; ++U) {
      let F = QO0(Y, X[U]);
      H[F].push(X[U]);
    }
    let q = W$(Y);
    for (let U = 0;U < H.length; ++U) {
      let F = H[U], E = F.length;
      if (E === 0)
        continue;
      let R = 0, z = 0, D = 0;
      for (let w of F)
        R += w[0], z += w[1], D += w[2];
      let A = R / E, B = z / E, T = D / E;
      Y[U] = [A, B, T];
    }
    if (QY(q, Y))
      break;
  }
  return ($.sort === "contrast" ? BJ1(Y) : Y).map((G) => TJ.toColor(G));
}

// node_modules/molstar/lib/mol-util/color/palette.js
var GO0 = {
  type: "generate",
  colorList: "red-yellow-blue"
};
function p9(Z = {}) {
  let J = { ...GO0, ...Z };
  return {
    palette: j.MappedStatic(J.type, {
      colors: j.Group({
        list: j.ColorList(J.colorList)
      }, { isFlat: !0 }),
      generate: j.Group({
        ...ka,
        maxCount: j.Numeric(75, { min: 1, max: 250, step: 1 })
      }, { isFlat: !0 })
    }, {
      options: [
        ["colors", "Color List"],
        ["generate", "Generate Distinct"]
      ]
    })
  };
}
var gO2 = j.getDefaultValues(p9()), KO0 = {
  valueLabel: (Z) => `${Z + 1}`,
  minLabel: "Start",
  maxLabel: "End"
};
function a9(Z, J, $ = {}) {
  var X;
  let Y, Q;
  if (J.palette.name === "colors" && J.palette.params.list.kind === "interpolate") {
    let { list: W } = J.palette.params, K = [0, Z - 1], { minLabel: G, maxLabel: H } = { ...KO0, ...$ }, N = W.colors;
    if (N.length === 0)
      N = RJ(GO0.colorList).list;
    let q = _J.create({ listOrName: N, domain: K, minLabel: G, maxLabel: H });
    Q = q.legend, Y = q.color;
  } else {
    let W;
    if (J.palette.name === "colors") {
      if (W = J.palette.params.list.colors.map((N) => Array.isArray(N) ? N[0] : N), W.length === 0)
        W = RJ("dark-2").list.map((N) => Array.isArray(N) ? N[0] : N);
    } else
      Z = Math.min(Z, J.palette.params.maxCount), W = WO0(Z, J.palette.params);
    let K = (X = $.valueLabel) !== null && X !== void 0 ? X : KO0.valueLabel, G = W.length, H = [];
    for (let N = 0;N < Z; ++N) {
      let q = N % G;
      if (H[q] === void 0)
        H[q] = [K(N), W[q]];
      else
        H[q][0] += `, ${K(N)}`;
    }
    Q = ZX(H), Y = (N) => W[N % G];
  }
  return { color: Y, legend: Q };
}

// node_modules/molstar/lib/mol-theme/color/chain-id.js
var jJ1 = "many-distinct", HO0 = i0(16448250), TJ1 = "Gives every chain a color based on its `asym_id` value.", iN = {
  asymId: j.Select("auth", j.arrayToOptions(["auth", "label"])),
  ...p9({ type: "colors", colorList: jJ1 })
};
function _J1(Z) {
  var J;
  let $ = j.clone(iN);
  if ((J = Z.structure) === null || J === void 0 ? void 0 : J.models.some((X) => X.coarseHierarchy.isDefined))
    $.asymId.defaultValue = "label";
  return $;
}
function VJ1(Z, J) {
  switch (Z.kind) {
    case j0.Kind.Atomic:
      return J === "auth" ? w1.chain.auth_asym_id : w1.chain.label_asym_id;
    case j0.Kind.Spheres:
    case j0.Kind.Gaussians:
      return w1.coarse.asym_id;
  }
}
function NO0(Z, J) {
  let $ = VJ1(Z.unit, J)(Z);
  return Z.structure.root.models.length > 1 ? qO0(Z.unit.model, $) : $;
}
function qO0(Z, J) {
  return `${J}|${(O2.Index.get(Z).value || 0) + 1}`;
}
function IJ1(Z, J) {
  let $ = /* @__PURE__ */ new Map;
  for (let X of Z.models) {
    let Y = O2.AsymIdOffset.get(X).value, Q = (J === "auth" ? Y === null || Y === void 0 ? void 0 : Y.auth : Y === null || Y === void 0 ? void 0 : Y.label) || 0, W = 0;
    X.properties.structAsymMap.forEach(({ auth_id: K }, G) => {
      let H = J === "auth" ? K : G, N = Z.models.length > 1 ? qO0(X, H) : H;
      if (!$.has(N))
        $.set(N, W + Q), ++W;
    });
  }
  return $;
}
function oN(Z, J) {
  let $, X;
  if (Z.structure) {
    let Y = W0.Location.create(Z.structure.root), Q = IJ1(Z.structure.root, J.asymId), W = Array.from(Q.keys()), K = (H) => W[H], G = a9(Q.size, J, { valueLabel: K });
    X = G.legend, $ = (H) => {
      let N = void 0;
      if (W0.Location.is(H)) {
        let q = NO0(H, J.asymId);
        N = Q.get(q);
      } else if ($2.isLocation(H)) {
        Y.unit = H.aUnit, Y.element = H.aUnit.elements[H.aIndex];
        let q = NO0(Y, J.asymId);
        N = Q.get(q);
      }
      return N === void 0 ? HO0 : G.color(N);
    };
  } else
    $ = () => HO0;
  return {
    factory: oN,
    granularity: "group",
    color: $,
    props: J,
    description: TJ1,
    legend: X
  };
}
var ph = {
  name: "chain-id",
  label: "Chain Id",
  category: $8.Chain,
  factory: oN,
  getParams: _J1,
  defaultValues: j.getDefaultValues(iN),
  isApplicable: (Z) => !!Z.structure
};

// node_modules/molstar/lib/mol-theme/color/element-index.js
var FO0 = i0(13421772), PJ1 = "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.", UO0 = {
  ...p9({ type: "colors", colorList: "red-yellow-blue" })
};
function CJ1(Z) {
  return UO0;
}
function LO0(Z, J) {
  let $, X;
  if (Z.structure) {
    let { units: Y } = Z.structure.root, Q = Y.length, W = /* @__PURE__ */ new Map, K = /* @__PURE__ */ new Map, G = 0;
    for (let N = 0;N < Q; ++N)
      W.set(N, G), G += Y[N].elements.length, K.set(Y[N].id, N);
    let H = a9(G, J);
    X = H.legend, $ = (N) => {
      if (W0.Location.is(N)) {
        let q = K.get(N.unit.id), U = f0.findPredecessorIndex(Y[q].elements, N.element);
        return H.color(W.get(q) + U);
      } else if ($2.isLocation(N)) {
        let q = K.get(N.aUnit.id), U = f0.findPredecessorIndex(Y[q].elements, N.aUnit.elements[N.aIndex]);
        return H.color(W.get(q) + U);
      }
      return FO0;
    };
  } else
    $ = () => FO0;
  return {
    factory: LO0,
    granularity: "groupInstance",
    preferSmoothing: !0,
    color: $,
    props: J,
    description: PJ1,
    legend: X
  };
}
var RO0 = {
  name: "element-index",
  label: "Element Index",
  category: $8.Atom,
  factory: LO0,
  getParams: CJ1,
  defaultValues: j.getDefaultValues(UO0),
  isApplicable: (Z) => !!Z.structure
};

// node_modules/molstar/lib/mol-util/color/params.js
function sN(Z) {
  let J = {};
  return B7(Z, ($, X) => {
    J[X] = j.Color(Z[X]);
  }), J;
}

// node_modules/molstar/lib/mol-theme/color/operator-name.js
var kJ1 = "many-distinct", EO0 = i0(13421772), vJ1 = "Assigns a color based on the operator name of a transformed chain.", uh = {
  ...p9({ type: "colors", colorList: kJ1 })
};
function SJ1(Z) {
  return j.clone(uh);
}
function fJ1(Z) {
  let J = /* @__PURE__ */ new Map;
  for (let $ = 0, X = Z.units.length;$ < X; ++$) {
    let Y = Z.units[$].conformation.operator.name;
    if (!J.has(Y))
      J.set(Y, J.size);
  }
  return J;
}
function ch(Z, J) {
  let $, X;
  if (Z.structure) {
    let Y = fJ1(Z.structure.root), Q = Array.from(Y.keys()), W = (G) => Q[G], K = a9(Y.size, J, { valueLabel: W });
    X = K.legend, $ = (G) => {
      let H = void 0;
      if (W0.Location.is(G)) {
        let N = G.unit.conformation.operator.name;
        H = Y.get(N);
      } else if ($2.isLocation(G)) {
        let N = G.aUnit.conformation.operator.name;
        H = Y.get(N);
      }
      return H === void 0 ? EO0 : K.color(H);
    };
  } else
    $ = () => EO0;
  return {
    factory: ch,
    granularity: "instance",
    color: $,
    props: J,
    description: vJ1,
    legend: X
  };
}
var MA = {
  name: "operator-name",
  label: "Operator Name",
  category: $8.Symmetry,
  factory: ch,
  getParams: SJ1,
  defaultValues: j.getDefaultValues(uh),
  isApplicable: (Z) => !!Z.structure
};

// node_modules/molstar/lib/mol-theme/color/entity-id.js
var hJ1 = "many-distinct", va = i0(16448250), bJ1 = i0(16715021), xJ1 = "Gives every chain a color based on its `label_entity_id` value.", aN = {
  ...p9({ type: "colors", colorList: hJ1 }),
  overrideWater: j.Boolean(!1, { description: "Override the color for water molecules." }),
  waterColor: j.Color(bJ1, { hideIf: (Z) => !Z.overrideWater, description: "Color for water molecules (if overrideWater is true)." })
};
function yJ1(Z) {
  return j.clone(aN);
}
function lh(Z, J) {
  return `${Z}|${J}`;
}
function gJ1(Z) {
  let J = /* @__PURE__ */ new WeakMap, $ = 0;
  for (let X = 0, Y = Z.models.length;X < Y; ++X) {
    let Q = Z.models[X].sourceData;
    if (!J.has(Q))
      J.set(Q, $++);
  }
  return J;
}
function mJ1(Z, J) {
  var $;
  let X = /* @__PURE__ */ new Map;
  for (let Y = 0, Q = Z.models.length;Y < Q; ++Y) {
    let W = ($ = J.get(Z.models[Y].sourceData)) !== null && $ !== void 0 ? $ : -1, { label_entity_id: K } = Z.models[Y].atomicHierarchy.chains;
    for (let H = 0, N = K.rowCount;H < N; ++H) {
      let q = lh(K.value(H), W);
      if (!X.has(q))
        X.set(q, X.size);
    }
    let { coarseHierarchy: G } = Z.models[Y];
    if (G.isDefined) {
      let { entity_id: H } = G.spheres;
      for (let q = 0, U = H.rowCount;q < U; ++q) {
        let F = lh(H.value(q), W);
        if (!X.has(F))
          X.set(F, X.size);
      }
      let { entity_id: N } = G.gaussians;
      for (let q = 0, U = N.rowCount;q < U; ++q) {
        let F = lh(N.value(q), W);
        if (!X.has(F))
          X.set(F, X.size);
      }
    }
  }
  return X;
}
function dJ1(Z) {
  switch (Z.unit.kind) {
    case j0.Kind.Atomic:
      return w1.chain.label_entity_id(Z);
    case j0.Kind.Spheres:
    case j0.Kind.Gaussians:
      return w1.coarse.entity_id(Z);
  }
}
function rN(Z, J) {
  let $, X;
  if (Z.structure) {
    let Y = W0.Location.create(Z.structure.root), Q = gJ1(Z.structure), W = mJ1(Z.structure.root, Q), K = Array.from(W.keys()), G = (N) => K[N], H = a9(W.size, J, { valueLabel: G });
    X = H.legend, $ = (N) => {
      var q;
      let U;
      if (W0.Location.is(N))
        U = N;
      else if ($2.isLocation(N))
        Y.unit = N.aUnit, Y.element = N.aUnit.elements[N.aIndex], U = Y;
      else
        return va;
      let F = dJ1(U), E = (q = Q.get(U.unit.model.sourceData)) !== null && q !== void 0 ? q : -1;
      if (J.overrideWater) {
        let D = U.unit.model.entities;
        if (D.data.type.value(D.getEntityIndex(F)) === "water")
          return J.waterColor;
      }
      let R = lh(F, E), z = W.get(R);
      return z === void 0 ? va : H.color(z);
    };
  } else
    $ = () => va;
  return {
    factory: rN,
    granularity: "group",
    color: $,
    props: J,
    description: xJ1,
    legend: X
  };
}
var OO0 = {
  name: "entity-id",
  label: "Entity Id",
  category: $8.Chain,
  factory: rN,
  getParams: yJ1,
  defaultValues: j.getDefaultValues(aN),
  isApplicable: (Z) => !!Z.structure
};

// node_modules/molstar/lib/mol-theme/color/entity-source.js
var fa = "dark-2", nh = i0(16448250), pJ1 = "Gives ranges of a polymer chain a color based on the entity source it originates from (e.g. gene, plasmid, organism).", tN = {
  ...p9({ type: "colors", colorList: fa })
};
function uJ1(Z) {
  let J = j.clone(tN);
  if (Z.structure) {
    if (DO0(Z.structure.root.models).srcKeySerialMap.size > g7[fa].list.length)
      J.palette.defaultValue.name = "colors", J.palette.defaultValue.params = {
        ...J.palette.defaultValue.params,
        list: { kind: "interpolate", colors: RJ(fa).list }
      };
  }
  return J;
}
function zO0(Z, J) {
  return `${Z}|${J}`;
}
function cJ1(Z, J, $, X, Y, Q) {
  return `${Z}|${J}|${$}|${Q ? Q : Y ? Y : X}`;
}
function Sa(Z, J, $, X, Y, Q, W, K) {
  let { entity_id: G, pdbx_src_id: H, pdbx_beg_seq_num: N, pdbx_end_seq_num: q } = Y;
  for (let U = 0, F = Y._rowCount;U < F; ++U) {
    let E = G.value(U), R = zO0($, E), z;
    if (!Z.has(R)) {
      let P = X.entities.getEntityIndex(E), I = X.sequence.sequences[P].sequence;
      z = new Int16Array(I.length), Z.set(R, z);
    } else
      z = Z.get(R);
    let D = W ? W.value(U) : "", A = K ? K.value(U)[0] : "", B = cJ1($, E, Q.value(U), H.value(U), D, A), T = N.valueKind(U) === s.ValueKinds.Present ? N.value(U) : 1, w = q.valueKind(U) === s.ValueKinds.Present ? q.value(U) : z.length, V;
    if (J.has(B))
      V = J.get(B);
    else
      V = J.size + 1, J.set(B, V);
    for (let P = T, I = w;P <= I; ++P)
      z[P - 1] = V;
  }
}
function DO0(Z) {
  let J = /* @__PURE__ */ new Map, $ = /* @__PURE__ */ new Map;
  for (let X = 0, Y = Z.length;X < Y; ++X) {
    let Q = Z[X];
    if (!S6.is(Q.sourceData))
      continue;
    let { entity_src_gen: W, entity_src_nat: K, pdbx_entity_src_syn: G } = Q.sourceData.data.db;
    Sa(J, $, X, Q, W, W.pdbx_gene_src_scientific_name, W.plasmid_name, W.pdbx_gene_src_gene), Sa(J, $, X, Q, K, K.pdbx_organism_scientific, K.pdbx_plasmid_name), Sa(J, $, X, Q, G, G.organism_scientific);
  }
  return { seqToSrcByModelEntity: J, srcKeySerialMap: $ };
}
function lJ1(Z) {
  let J = 0;
  return Array.from(Z.keys()).map(($) => {
    let X = $.split("|"), Y = X[2];
    return `${OH0(X[3]) ? `Unnamed ${++J}` : X[3]}${Y ? ` (${Y})` : ""}`;
  });
}
function eN(Z, J) {
  let $, X;
  if (Z.structure) {
    let Y = W0.Location.create(Z.structure), { models: Q } = Z.structure.root, { seqToSrcByModelEntity: W, srcKeySerialMap: K } = DO0(Q), G = lJ1(K), H = (U) => G[U], N = a9(K.size, J, { valueLabel: H });
    X = N.legend;
    let q = (U) => {
      let F = Q.indexOf(U.unit.model), E = w1.entity.id(U), R = zO0(F, E), z = W.get(R);
      if (z) {
        let D = z[w1.residue.label_seq_id(U) - 1] - 1;
        return D === -1 ? nh : N.color(D);
      } else
        return nh;
    };
    $ = (U) => {
      if (W0.Location.is(U))
        return q(U);
      else if ($2.isLocation(U))
        return Y.unit = U.aUnit, Y.element = U.aUnit.elements[U.aIndex], q(Y);
      return nh;
    };
  } else
    $ = () => nh;
  return {
    factory: eN,
    granularity: "group",
    color: $,
    props: J,
    description: pJ1,
    legend: X
  };
}
var MO0 = {
  name: "entity-source",
  label: "Entity Source",
  category: $8.Chain,
  factory: eN,
  getParams: uJ1,
  defaultValues: j.getDefaultValues(tN),
  isApplicable: (Z) => !!Z.structure
};

// node_modules/molstar/lib/mol-theme/color/model-index.js
var AO0 = i0(13421772), nJ1 = "Gives every model a unique color based on its index.", Zq = {
  ...p9({ type: "colors", colorList: "many-distinct" })
};
function iJ1(Z) {
  return j.clone(Zq);
}
function Jq(Z, J) {
  var $;
  let X, Y, Q = -1;
  if (Z.structure) {
    let W = (($ = O2.MaxIndex.get(Z.structure.models[0]).value) !== null && $ !== void 0 ? $ : -1) + 1;
    Q = W;
    let K = a9(W, J);
    Y = K.legend, X = (G) => {
      if (W0.Location.is(G))
        return K.color(O2.Index.get(G.unit.model).value || 0);
      else if ($2.isLocation(G))
        return K.color(O2.Index.get(G.aUnit.model).value || 0);
      return AO0;
    };
  } else
    X = () => AO0;
  return {
    factory: Jq,
    granularity: "instance",
    color: X,
    props: J,
    contextHash: Q,
    description: nJ1,
    legend: Y
  };
}
var BO0 = {
  name: "model-index",
  label: "Model Index",
  category: $8.Chain,
  factory: Jq,
  getParams: iJ1,
  defaultValues: j.getDefaultValues(Zq),
  isApplicable: (Z) => !!Z.structure && Z.structure.elementCount > 0
};

// node_modules/molstar/lib/mol-theme/color/structure-index.js
var wO0 = i0(13421772), oJ1 = "Gives every structure a unique color based on its index.", $q = {
  ...p9({ type: "colors", colorList: "many-distinct" })
};
function sJ1(Z) {
  return j.clone($q);
}
function Xq(Z, J) {
  var $;
  let X, Y, Q = -1;
  if (Z.structure) {
    let W = (($ = s0.MaxIndex.get(Z.structure).value) !== null && $ !== void 0 ? $ : -1) + 1;
    Q = W;
    let K = a9(W, J);
    Y = K.legend, X = (G) => {
      if (W0.Location.is(G))
        return K.color(s0.Index.get(G.structure).value || 0);
      else if ($2.isLocation(G))
        return K.color(s0.Index.get(G.aStructure).value || 0);
      return wO0;
    };
  } else
    X = () => wO0;
  return {
    factory: Xq,
    granularity: "instance",
    color: X,
    props: J,
    contextHash: Q,
    description: oJ1,
    legend: Y
  };
}
var jO0 = {
  name: "structure-index",
  label: "Structure Index",
  category: $8.Chain,
  factory: Xq,
  getParams: sJ1,
  defaultValues: j.getDefaultValues($q),
  isApplicable: (Z) => !!Z.structure && Z.structure.elementCount > 0
};

// node_modules/molstar/lib/mol-theme/color/unit-index.js
var ha = "dark-2", TO0 = i0(13421772), aJ1 = "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.", ih = {
  ...p9({ type: "colors", colorList: ha })
};
function rJ1(Z) {
  let J = j.clone(ih);
  if (Z.structure) {
    if (Z.structure.root.units.length > g7[ha].list.length)
      J.palette.defaultValue.name = "colors", J.palette.defaultValue.params = {
        ...J.palette.defaultValue.params,
        list: { kind: "interpolate", colors: RJ(ha).list }
      };
  }
  return J;
}
function oh(Z, J) {
  let $, X;
  if (Z.structure) {
    let { units: Y } = Z.structure.root, Q = a9(Y.length, J);
    X = Q.legend;
    let W = /* @__PURE__ */ new Map;
    for (let K = 0, G = Y.length;K < G; ++K)
      W.set(Y[K].id, Q.color(K));
    $ = (K) => {
      if (W0.Location.is(K))
        return W.get(K.unit.id);
      else if ($2.isLocation(K))
        return W.get(K.aUnit.id);
      return TO0;
    };
  } else
    $ = () => TO0;
  return {
    factory: oh,
    granularity: "instance",
    color: $,
    props: J,
    description: aJ1,
    legend: X
  };
}
var _O0 = {
  name: "unit-index",
  label: "Chain Instance",
  category: $8.Chain,
  factory: oh,
  getParams: rJ1,
  defaultValues: j.getDefaultValues(ih),
  isApplicable: (Z) => !!Z.structure
};

// node_modules/molstar/lib/mol-theme/color/trajectory-index.js
var VO0 = i0(13421772), tJ1 = "Gives every model (frame) a unique color based on the index in its trajectory.", CR = {
  ...p9({ type: "colors", colorList: "purples" })
};
function eJ1(Z) {
  return j.clone(CR);
}
function kR(Z, J) {
  var $, X;
  let Y, Q, W = -1;
  if (Z.structure) {
    let { models: K } = Z.structure.root, G = 0;
    for (let U of K)
      G = Math.max(G, (($ = O2.TrajectoryInfo.get(U)) === null || $ === void 0 ? void 0 : $.size) || 0);
    let H = [G], N = a9(G, J);
    Q = N.legend;
    let q = /* @__PURE__ */ new Map;
    for (let U = 0, F = K.length;U < F; ++U) {
      let E = ((X = O2.TrajectoryInfo.get(K[U])) === null || X === void 0 ? void 0 : X.index) || 0;
      q.set(E, N.color(E)), H.push(E);
    }
    W = l9(H), Y = (U) => {
      if (W0.Location.is(U))
        return q.get(O2.TrajectoryInfo.get(U.unit.model).index);
      else if ($2.isLocation(U))
        return q.get(O2.TrajectoryInfo.get(U.aUnit.model).index);
      return VO0;
    };
  } else
    Y = () => VO0;
  return {
    factory: kR,
    granularity: "instance",
    color: Y,
    props: J,
    contextHash: W,
    description: tJ1,
    legend: Q
  };
}
var IO0 = {
  name: "trajectory-index",
  label: "Trajectory Index",
  category: $8.Chain,
  factory: kR,
  getParams: eJ1,
  defaultValues: j.getDefaultValues(CR),
  isApplicable: (Z) => !!Z.structure && Z.structure.elementCount > 0 && O2.TrajectoryInfo.get(Z.structure.models[0]).size > 1
};

// node_modules/molstar/lib/mol-theme/color/element-symbol.js
var PO0 = QQ({
  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: 15780000,
  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: 32000,
  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
}), CO0 = i0(16777215), Z$1 = "Assigns a color to every atom according to its chemical element.", sh = {
  carbonColor: j.MappedStatic("chain-id", {
    "chain-id": j.Group(iN),
    "unit-index": j.Group(ih, { label: "Chain Instance" }),
    "entity-id": j.Group(aN),
    "entity-source": j.Group(tN),
    "operator-name": j.Group(uh),
    "model-index": j.Group(Zq),
    "structure-index": j.Group($q),
    "trajectory-index": j.Group(CR),
    uniform: j.Group(tF),
    "element-symbol": j.EmptyGroup()
  }, { description: "Use chain-id coloring for carbon atoms." }),
  saturation: j.Numeric(0, { min: -6, max: 6, step: 0.1 }),
  lightness: j.Numeric(0.2, { min: -6, max: 6, step: 0.1 }),
  colors: j.MappedStatic("default", {
    default: j.EmptyGroup(),
    custom: j.Group(sN(PO0))
  })
};
function J$1(Z) {
  return j.clone(sh);
}
function $$1(Z, J) {
  let $ = Z[J];
  return $ === void 0 ? CO0 : $;
}
function X$1(Z, J) {
  switch (J.name) {
    case "chain-id":
      return oN(Z, J.params);
    case "unit-index":
      return oh(Z, J.params);
    case "entity-id":
      return rN(Z, J.params);
    case "entity-source":
      return eN(Z, J.params);
    case "operator-name":
      return ch(Z, J.params);
    case "model-index":
      return Jq(Z, J.params);
    case "structure-index":
      return Xq(Z, J.params);
    case "trajectory-index":
      return kR(Z, J.params);
    case "uniform":
      return qH(Z, J.params);
    case "element-symbol":
      return;
    default:
      T8(J);
  }
}
function ah(Z, J) {
  var $;
  let X = VN(J.colors.name === "default" ? PO0 : J.colors.params, J.saturation, J.lightness), Y = X$1(Z, J.carbonColor), Q = Y === null || Y === void 0 ? void 0 : Y.color, W = ($ = Y === null || Y === void 0 ? void 0 : Y.contextHash) !== null && $ !== void 0 ? $ : -1;
  function K(N, q) {
    return Q && N === "C" ? Q(q, !1) : $$1(X, N);
  }
  function G(N) {
    if (W0.Location.is(N)) {
      if (j0.isAtomic(N.unit)) {
        let { type_symbol: q } = N.unit.model.atomicHierarchy.atoms;
        return K(q.value(N.element), N);
      }
    } else if ($2.isLocation(N)) {
      if (j0.isAtomic(N.aUnit)) {
        let { type_symbol: q } = N.aUnit.model.atomicHierarchy.atoms, U = q.value(N.aUnit.elements[N.aIndex]);
        return K(U, N);
      }
    }
    return CO0;
  }
  let H = J.carbonColor.name === "operator-name" || J.carbonColor.name === "unit-index" ? "groupInstance" : "group";
  return {
    factory: ah,
    granularity: H,
    preferSmoothing: !0,
    color: G,
    props: J,
    contextHash: W,
    description: Z$1,
    legend: ZX(Object.keys(X).map((N) => {
      return [N, X[N]];
    }))
  };
}
var kO0 = {
  name: "element-symbol",
  label: "Element Symbol",
  category: $8.Atom,
  factory: ah,
  getParams: J$1,
  defaultValues: j.getDefaultValues(sh),
  isApplicable: (Z) => !!Z.structure
};

// node_modules/molstar/lib/mol-theme/color/molecule-type.js
var SO0 = QQ({
  water: 3697840,
  ion: 15729279,
  protein: 12496596,
  RNA: 16629894,
  DNA: 12540695,
  PNA: 4367514,
  saccharide: 8374655
}), ba = i0(16777113), Y$1 = "Assigns a color based on the molecule type of a residue.", vR = {
  saturation: j.Numeric(0, { min: -6, max: 6, step: 0.1 }),
  lightness: j.Numeric(0, { min: -6, max: 6, step: 0.1 }),
  colors: j.MappedStatic("default", {
    default: j.EmptyGroup(),
    custom: j.Group(sN(SO0))
  })
};
function Q$1(Z) {
  return vR;
}
function vO0(Z, J, $) {
  switch (rM(J, $)) {
    case e2.Water:
      return Z.water;
    case e2.Ion:
      return Z.ion;
    case e2.Protein:
      return Z.protein;
    case e2.RNA:
      return Z.RNA;
    case e2.DNA:
      return Z.DNA;
    case e2.PNA:
      return Z.PNA;
    case e2.Saccharide:
      return Z.saccharide;
  }
  return ba;
}
function SR(Z, J) {
  let $ = VN(J.colors.name === "default" ? SO0 : J.colors.params, J.saturation, J.lightness);
  function X(Y) {
    if (W0.Location.is(Y))
      return vO0($, Y.unit, Y.element);
    else if ($2.isLocation(Y))
      return vO0($, Y.aUnit, Y.aUnit.elements[Y.aIndex]);
    return ba;
  }
  return {
    factory: SR,
    granularity: "group",
    color: X,
    props: J,
    description: Y$1,
    legend: ZX(Object.keys($).map((Y) => {
      return [Y, $[Y]];
    }).concat([["Other/unknown", ba]]))
  };
}
var fO0 = {
  name: "molecule-type",
  label: "Molecule Type",
  category: $8.Residue,
  factory: SR,
  getParams: Q$1,
  defaultValues: j.getDefaultValues(vR),
  isApplicable: (Z) => !!Z.structure
};

// node_modules/molstar/lib/mol-theme/color/polymer-id.js
var xa = "dark-2", hO0 = i0(16448250), W$1 = "Gives every polymer chain a color based on its `asym_id` value.", xO0 = {
  ...p9({ type: "colors", colorList: xa })
};
function K$1(Z) {
  let J = j.clone(xO0);
  if (Z.structure) {
    if (yO0(Z.structure.root).size > g7[xa].list.length)
      J.palette.defaultValue.name = "colors", J.palette.defaultValue.params = {
        ...J.palette.defaultValue.params,
        list: { kind: "interpolate", colors: RJ(xa).list }
      };
  }
  return J;
}
function bO0(Z) {
  switch (Z.kind) {
    case j0.Kind.Atomic:
      return w1.chain.label_asym_id;
    case j0.Kind.Spheres:
    case j0.Kind.Gaussians:
      return w1.coarse.asym_id;
  }
}
function yO0(Z) {
  let J = /* @__PURE__ */ new Map;
  for (let $ = 0, X = Z.unitSymmetryGroups.length;$ < X; ++$) {
    let Y = Z.unitSymmetryGroups[$].units[0], { model: Q } = Y;
    if (j0.isAtomic(Y)) {
      let { chainAtomSegments: W, chains: K } = Q.atomicHierarchy, G = b2.transientSegments(W, Y.elements);
      while (G.hasNext) {
        let { index: H } = G.move(), N = K.label_entity_id.value(H), q = Q.entities.getEntityIndex(N);
        if (Q.entities.data.type.value(q) === "polymer") {
          let U = K.label_asym_id.value(H);
          if (!J.has(U))
            J.set(U, J.size);
        }
      }
    } else if (j0.isCoarse(Y)) {
      let { chainElementSegments: W, asym_id: K, entity_id: G } = j0.isSpheres(Y) ? Q.coarseHierarchy.spheres : Q.coarseHierarchy.gaussians, H = b2.transientSegments(W, Y.elements);
      while (H.hasNext) {
        let { index: N } = H.move(), q = W.offsets[N], U = G.value(q), F = Q.entities.getEntityIndex(U);
        if (Q.entities.data.type.value(F) === "polymer") {
          let E = K.value(q);
          if (!J.has(E))
            J.set(E, J.size);
        }
      }
    }
  }
  return J;
}
function gO0(Z, J) {
  let $, X;
  if (Z.structure) {
    let Y = W0.Location.create(Z.structure), Q = yO0(Z.structure.root), W = Array.from(Q.keys()), K = (H) => W[H], G = a9(Q.size, J, { valueLabel: K });
    X = G.legend, $ = (H) => {
      let N = void 0;
      if (W0.Location.is(H)) {
        let q = bO0(H.unit);
        N = Q.get(q(H));
      } else if ($2.isLocation(H)) {
        let q = bO0(H.aUnit);
        Y.unit = H.aUnit, Y.element = H.aUnit.elements[H.aIndex], N = Q.get(q(Y));
      }
      return N === void 0 ? hO0 : G.color(N);
    };
  } else
    $ = () => hO0;
  return {
    factory: gO0,
    granularity: "group",
    color: $,
    props: J,
    description: W$1,
    legend: X
  };
}
var mO0 = {
  name: "polymer-id",
  label: "Polymer Chain Id",
  category: $8.Chain,
  factory: gO0,
  getParams: K$1,
  defaultValues: j.getDefaultValues(xO0),
  isApplicable: (Z) => !!Z.structure
};

// node_modules/molstar/lib/mol-theme/color/polymer-index.js
var ya = "dark-2", dO0 = i0(13421772), G$1 = "Gives every polymer chain instance a unique color based on the position (index) of the polymer in the list of polymers in the structure.", pO0 = {
  ...p9({ type: "colors", colorList: ya })
};
function H$1(Z) {
  let J = j.clone(pO0);
  if (Z.structure) {
    if (uO0(Z.structure.root) > g7[ya].list.length)
      J.palette.defaultValue.name = "colors", J.palette.defaultValue.params = {
        ...J.palette.defaultValue.params,
        list: { kind: "interpolate", colors: RJ(ya).list }
      };
  }
  return J;
}
function uO0(Z) {
  let J = 0, { units: $ } = Z;
  for (let X = 0, Y = $.length;X < Y; ++X)
    if ($[X].polymerElements.length > 0)
      ++J;
  return J;
}
function cO0(Z, J) {
  let $, X;
  if (Z.structure) {
    let Y = a9(uO0(Z.structure.root), J);
    X = Y.legend;
    let { units: Q } = Z.structure.root, W = /* @__PURE__ */ new Map;
    for (let K = 0, G = 0, H = Q.length;K < H; ++K)
      if (Q[K].polymerElements.length > 0)
        W.set(Q[K].id, Y.color(G)), ++G;
    $ = (K) => {
      let G;
      if (W0.Location.is(K))
        G = W.get(K.unit.id);
      else if ($2.isLocation(K))
        G = W.get(K.aUnit.id);
      return G !== void 0 ? G : dO0;
    };
  } else
    $ = () => dO0;
  return {
    factory: cO0,
    granularity: "instance",
    color: $,
    props: J,
    description: G$1,
    legend: X
  };
}
var lO0 = {
  name: "polymer-index",
  label: "Polymer Chain Instance",
  category: $8.Chain,
  factory: cO0,
  getParams: H$1,
  defaultValues: j.getDefaultValues(pO0),
  isApplicable: (Z) => !!Z.structure
};

// node_modules/molstar/lib/mol-theme/color/residue-name.js
var oO0 = QQ({
  ALA: 9240460,
  ARG: 124,
  ASN: 16743536,
  ASP: 10485826,
  CYS: 16777072,
  GLN: 16731212,
  GLU: 6684672,
  GLY: 15658734,
  HIS: 7368959,
  ILE: 19456,
  LEU: 4546117,
  LYS: 4671416,
  MET: 12099650,
  PHE: 5459026,
  PRO: 5395026,
  SER: 16740418,
  THR: 12078080,
  TRP: 5195264,
  TYR: 9203788,
  VAL: 16747775,
  A: 14423100,
  G: 3329330,
  I: 10145074,
  C: 16766720,
  T: 4286945,
  U: 4251856,
  DA: 14423100,
  DG: 3329330,
  DI: 10145074,
  DC: 16766720,
  DT: 4286945,
  DU: 4251856,
  APN: 14423100,
  GPN: 3329330,
  CPN: 16766720,
  TPN: 4286945
}), ga = i0(16711935), N$1 = "Assigns a color to every residue according to its name.", th = {
  saturation: j.Numeric(0, { min: -6, max: 6, step: 0.1 }),
  lightness: j.Numeric(1, { min: -6, max: 6, step: 0.1 }),
  colors: j.MappedStatic("default", {
    default: j.EmptyGroup(),
    custom: j.Group(sN(oO0))
  })
};
function q$1(Z) {
  return th;
}
function nO0(Z, J) {
  return Z.model.atomicHierarchy.atoms.label_comp_id.value(J);
}
function iO0(Z, J) {
  let $ = Z.coarseElements.seq_id_begin.value(J), X = Z.coarseElements.seq_id_end.value(J);
  if ($ === X) {
    let Y = Z.coarseElements.entityKey[J];
    return Z.model.sequence.byEntityKey[Y].sequence.compId.value($ - 1);
  }
}
function rh(Z, J) {
  let $ = Z[J];
  return $ === void 0 ? ga : $;
}
function eh(Z, J) {
  let $ = VN(J.colors.name === "default" ? oO0 : J.colors.params, J.saturation, J.lightness);
  function X(Y) {
    if (W0.Location.is(Y))
      if (j0.isAtomic(Y.unit)) {
        let Q = nO0(Y.unit, Y.element);
        return rh($, Q);
      } else {
        let Q = iO0(Y.unit, Y.element);
        if (Q)
          return rh($, Q);
      }
    else if ($2.isLocation(Y))
      if (j0.isAtomic(Y.aUnit)) {
        let Q = nO0(Y.aUnit, Y.aUnit.elements[Y.aIndex]);
        return rh($, Q);
      } else {
        let Q = iO0(Y.aUnit, Y.aUnit.elements[Y.aIndex]);
        if (Q)
          return rh($, Q);
      }
    return ga;
  }
  return {
    factory: eh,
    granularity: "group",
    preferSmoothing: !0,
    color: X,
    props: J,
    description: N$1,
    legend: ZX(Object.keys($).map((Y) => {
      return [Y, $[Y]];
    }).concat([["Unknown", ga]]))
  };
}
var sO0 = {
  name: "residue-name",
  label: "Residue Name",
  category: $8.Residue,
  factory: eh,
  getParams: q$1,
  defaultValues: j.getDefaultValues(th),
  isApplicable: (Z) => !!Z.structure
};

// node_modules/molstar/lib/mol-theme/color/residue-charge.js
var tO0 = QQ({
  ARG: 255,
  ASP: 16711680,
  GLU: 16711680,
  HIS: 3392505,
  LYS: 255,
  ALA: 16777215,
  ASN: 16777215,
  CYS: 16777215,
  GLN: 16777215,
  GLY: 16777215,
  ILE: 16777215,
  LEU: 16777215,
  MET: 16777215,
  PHE: 16777215,
  PRO: 16777215,
  SER: 16777215,
  THR: 16777215,
  TRP: 16777215,
  TYR: 16777215,
  VAL: 16777215,
  MSE: 16777215,
  SEP: 16777215,
  TPO: 16777215,
  PTR: 16777215,
  PCA: 16777215,
  HYP: 16777215,
  HSD: 16777215,
  HSE: 16777215,
  HSP: 255,
  LSN: 16777215,
  ASPP: 16777215,
  GLUP: 16777215,
  HID: 16777215,
  HIE: 16777215,
  HIP: 255,
  LYN: 16777215,
  ASH: 16777215,
  GLH: 16777215,
  A: 16777215,
  G: 16777215,
  I: 16777215,
  C: 16777215,
  T: 16777215,
  U: 16777215,
  DA: 16777215,
  DG: 16777215,
  DI: 16777215,
  DC: 16777215,
  DT: 16777215,
  DU: 16777215,
  APN: 16777215,
  GPN: 16777215,
  CPN: 16777215,
  TPN: 16777215
}), ma = i0(16711935), F$1 = "Assigns a color to every residue based on its charge state.", eO0 = {
  method: j.MappedStatic("by-name", {
    "by-name": j.Group({
      saturation: j.Numeric(0, { min: -6, max: 6, step: 0.1 }),
      lightness: j.Numeric(0, { min: -6, max: 6, step: 0.1 }),
      colors: j.MappedStatic("default", {
        default: j.EmptyGroup(),
        custom: j.Group(sN(tO0))
      })
    }, { isFlat: !0 })
  })
};
function U$1(Z) {
  return j.clone(eO0);
}
function aO0(Z, J) {
  return Z.model.atomicHierarchy.atoms.label_comp_id.value(J);
}
function rO0(Z, J) {
  let $ = Z.coarseElements.seq_id_begin.value(J), X = Z.coarseElements.seq_id_end.value(J);
  if ($ === X) {
    let Y = Z.coarseElements.entityKey[J];
    return Z.model.sequence.byEntityKey[Y].sequence.compId.value($ - 1);
  }
}
function Zb(Z, J) {
  let $ = Z[J];
  return $ === void 0 ? ma : $;
}
function Zz0(Z, J) {
  let { saturation: $, lightness: X, colors: Y } = J.method.params, Q = VN(J.method.params.colors.name === "default" ? tO0 : Y.params, $, X);
  function W(K) {
    if (W0.Location.is(K))
      if (j0.isAtomic(K.unit)) {
        let G = aO0(K.unit, K.element);
        return Zb(Q, G);
      } else {
        let G = rO0(K.unit, K.element);
        if (G)
          return Zb(Q, G);
      }
    else if ($2.isLocation(K))
      if (j0.isAtomic(K.aUnit)) {
        let G = aO0(K.aUnit, K.aUnit.elements[K.aIndex]);
        return Zb(Q, G);
      } else {
        let G = rO0(K.aUnit, K.aUnit.elements[K.aIndex]);
        if (G)
          return Zb(Q, G);
      }
    return ma;
  }
  return {
    factory: Zz0,
    granularity: "group",
    preferSmoothing: !0,
    color: W,
    props: J,
    description: F$1,
    legend: ZX(Object.keys(Q).map((K) => {
      return [K, Q[K]];
    }).concat([["Unknown", ma]]))
  };
}
var Jz0 = {
  name: "residue-charge",
  label: "Residue Charge",
  category: $8.Residue,
  factory: Zz0,
  getParams: U$1,
  defaultValues: j.getDefaultValues(eO0),
  isApplicable: (Z) => !!Z.structure
};

// node_modules/molstar/lib/mol-theme/color/secondary-structure.js
var Xz0 = QQ({
  alphaHelix: 16711808,
  threeTenHelix: 10485888,
  piHelix: 6291584,
  betaTurn: 6324479,
  betaStrand: 16762880,
  coil: 16777215,
  bend: 6740169,
  turn: 45670,
  dna: 11403518,
  rna: 16580962,
  carbohydrate: 10921722
}), da = i0(8421504), L$1 = "Assigns a color based on the type of secondary structure and basic molecule type.", Jb = {
  saturation: j.Numeric(-1, { min: -6, max: 6, step: 0.1 }),
  lightness: j.Numeric(0, { min: -6, max: 6, step: 0.1 }),
  colors: j.MappedStatic("default", {
    default: j.EmptyGroup(),
    custom: j.Group(sN(Xz0))
  })
};
function R$1(Z) {
  return Jb;
}
function $z0(Z, J, $, X) {
  let Y = m2.create(m2.Flag.None);
  if (X && j0.isAtomic(J)) {
    let Q = X.get(J.invariantId);
    if (Q)
      Y = Q.type[Q.getIndex(J.residueIndex[$])];
  }
  if (m2.is(Y, m2.Flag.Helix)) {
    if (m2.is(Y, m2.Flag.Helix3Ten))
      return Z.threeTenHelix;
    else if (m2.is(Y, m2.Flag.HelixPi))
      return Z.piHelix;
    return Z.alphaHelix;
  } else if (m2.is(Y, m2.Flag.Beta))
    return Z.betaStrand;
  else if (m2.is(Y, m2.Flag.Bend))
    return Z.bend;
  else if (m2.is(Y, m2.Flag.Turn))
    return Z.turn;
  else {
    let Q = rM(J, $);
    if (Q === e2.DNA)
      return Z.dna;
    else if (Q === e2.RNA)
      return Z.rna;
    else if (Q === e2.Saccharide)
      return Z.carbohydrate;
    else if (Q === e2.Protein)
      return Z.coil;
  }
  return da;
}
function $b(Z, J) {
  let $ = Z.structure && $X.get(Z.structure), X = $ ? SQ($.id, $.version) : -1, Y = VN(J.colors.name === "default" ? Xz0 : J.colors.params, J.saturation, J.lightness);
  function Q(W) {
    if (W0.Location.is(W))
      return $z0(Y, W.unit, W.element, $ === null || $ === void 0 ? void 0 : $.value);
    else if ($2.isLocation(W))
      return $z0(Y, W.aUnit, W.aUnit.elements[W.aIndex], $ === null || $ === void 0 ? void 0 : $.value);
    return da;
  }
  return {
    factory: $b,
    granularity: "group",
    preferSmoothing: !0,
    color: Q,
    props: J,
    contextHash: X,
    description: L$1,
    legend: ZX(Object.keys(Y).map((W) => {
      return [W, Y[W]];
    }).concat([["Other", da]]))
  };
}
var Yz0 = {
  name: "secondary-structure",
  label: "Secondary Structure",
  category: $8.Residue,
  factory: $b,
  getParams: R$1,
  defaultValues: j.getDefaultValues(Jb),
  isApplicable: (Z) => !!Z.structure,
  ensureCustomProperties: {
    attach: (Z, J) => J.structure ? $X.attach(Z, J.structure, void 0, !0) : Promise.resolve(),
    detach: (Z) => Z.structure && $X.ref(Z.structure, !1)
  }
};

// node_modules/molstar/lib/mol-theme/color/sequence-id.js
var E$1 = i0(13421772), O$1 = "Gives every polymer residue a color based on its `seq_id` value.", Xb = {
  list: j.ColorList("turbo-no-black", { presetKind: "scale" })
};
function z$1(Z) {
  return Xb;
}
function Qz0(Z, J) {
  let { model: $ } = Z;
  switch (Z.kind) {
    case j0.Kind.Atomic:
      let X = $.atomicHierarchy.residueAtomSegments.index[J];
      return $.atomicHierarchy.residues.label_seq_id.value(X);
    case j0.Kind.Spheres:
      return Math.round(($.coarseHierarchy.spheres.seq_id_begin.value(J) + $.coarseHierarchy.spheres.seq_id_end.value(J)) / 2);
    case j0.Kind.Gaussians:
      return Math.round(($.coarseHierarchy.gaussians.seq_id_begin.value(J) + $.coarseHierarchy.gaussians.seq_id_end.value(J)) / 2);
  }
}
function Wz0(Z, J) {
  let { model: $ } = Z, X = "";
  switch (Z.kind) {
    case j0.Kind.Atomic:
      let W = $.atomicHierarchy.chainAtomSegments.index[J];
      X = $.atomicHierarchy.chains.label_entity_id.value(W);
      break;
    case j0.Kind.Spheres:
      X = $.coarseHierarchy.spheres.entity_id.value(J);
      break;
    case j0.Kind.Gaussians:
      X = $.coarseHierarchy.gaussians.entity_id.value(J);
      break;
  }
  if (X === "")
    return 0;
  let Y = $.entities.getEntityIndex(X);
  if (Y === -1)
    return 0;
  let Q = $.sequence.byEntityKey[Y];
  if (Q === void 0)
    return 0;
  return Q.sequence.length;
}
function Yb(Z, J) {
  let $ = _J.create({
    listOrName: J.list.colors,
    minLabel: "Start",
    maxLabel: "End"
  });
  return {
    factory: Yb,
    granularity: "group",
    preferSmoothing: !0,
    color: (Y) => {
      if (W0.Location.is(Y)) {
        let { unit: Q, element: W } = Y, K = Qz0(Q, W);
        if (K > 0) {
          let G = Wz0(Q, W);
          if (G)
            return $.setDomain(0, G - 1), $.color(K);
        }
      } else if ($2.isLocation(Y)) {
        let { aUnit: Q, aIndex: W } = Y, K = Qz0(Q, Q.elements[W]);
        if (K > 0) {
          let G = Wz0(Q, Q.elements[W]);
          if (G)
            return $.setDomain(0, G - 1), $.color(K);
        }
      }
      return E$1;
    },
    props: J,
    description: O$1,
    legend: $ ? $.legend : void 0
  };
}
var Kz0 = {
  name: "sequence-id",
  label: "Sequence Id",
  category: $8.Residue,
  factory: Yb,
  getParams: z$1,
  defaultValues: j.getDefaultValues(Xb),
  isApplicable: (Z) => !!Z.structure
};

// node_modules/molstar/lib/mol-theme/color/uncertainty.js
var D$1 = i0(16777113), M$1 = "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.", Qb = {
  domain: j.Interval([0, 100]),
  list: j.ColorList("red-white-blue", { presetKind: "scale" })
};
function A$1(Z) {
  return Qb;
}
function Gz0(Z, J) {
  if (j0.isAtomic(Z))
    return Z.model.atomicConformation.B_iso_or_equiv.value(J);
  else if (j0.isSpheres(Z))
    return Z.model.coarseConformation.spheres.rmsf[J];
  else
    return 0;
}
function Wb(Z, J) {
  let $;
  if (J.list.kind === "set")
    $ = _J.createDiscrete({
      reverse: !0,
      domain: J.domain,
      listOrName: J.list.colors
    });
  else
    $ = _J.create({
      reverse: !0,
      domain: J.domain,
      listOrName: J.list.colors
    });
  function X(Y) {
    if (W0.Location.is(Y))
      return $.color(Gz0(Y.unit, Y.element));
    else if ($2.isLocation(Y))
      return $.color(Gz0(Y.aUnit, Y.aUnit.elements[Y.aIndex]));
    return D$1;
  }
  return {
    factory: Wb,
    granularity: "group",
    preferSmoothing: !0,
    color: X,
    props: J,
    description: M$1,
    legend: $ ? $.legend : void 0
  };
}
var Hz0 = {
  name: "uncertainty",
  label: "Uncertainty/Disorder",
  category: $8.Atom,
  factory: Wb,
  getParams: A$1,
  defaultValues: j.getDefaultValues(Qb),
  isApplicable: (Z) => !!Z.structure && Z.structure.models.some((J) => J.atomicConformation.B_iso_or_equiv.isDefined || J.coarseHierarchy.isDefined)
};

// node_modules/molstar/lib/mol-theme/color/illustrative.js
var B$1 = i0(15658734), w$1 = "Assigns an illustrative color that gives every chain a color based on the chosen style but with lighter carbons (inspired by David Goodsell's Molecule of the Month style).", Nz0 = {
  style: j.MappedStatic("entity-id", {
    uniform: j.Group(tF),
    "chain-id": j.Group(iN),
    "entity-id": j.Group(aN),
    "entity-source": j.Group(tN),
    "molecule-type": j.Group(vR),
    "model-index": j.Group(Zq),
    "structure-index": j.Group($q),
    "trajectory-index": j.Group(CR)
  }),
  carbonLightness: j.Numeric(0.8, { min: -6, max: 6, step: 0.1 })
};
function j$1(Z) {
  return j.clone(Nz0);
}
function T$1(Z, J) {
  switch (J.name) {
    case "uniform":
      return qH(Z, J.params);
    case "chain-id":
      return oN(Z, J.params);
    case "entity-id":
      return rN(Z, J.params);
    case "entity-source":
      return eN(Z, J.params);
    case "molecule-type":
      return SR(Z, J.params);
    case "model-index":
      return Jq(Z, J.params);
    case "structure-index":
      return Xq(Z, J.params);
    case "trajectory-index":
      return kR(Z, J.params);
    default:
      T8(J);
  }
}
function qz0(Z, J) {
  let { color: $, legend: X, contextHash: Y } = T$1(Z, J.style);
  function Q(K, G) {
    let H = $(K, !1);
    return G === "C" ? i0.lighten(H, J.carbonLightness) : H;
  }
  function W(K) {
    if (W0.Location.is(K) && j0.isAtomic(K.unit)) {
      let G = K.unit.model.atomicHierarchy.atoms.type_symbol.value(K.element);
      return Q(K, G);
    } else if ($2.isLocation(K) && j0.isAtomic(K.aUnit)) {
      let G = K.aUnit.elements[K.aIndex], H = K.aUnit.model.atomicHierarchy.atoms.type_symbol.value(G);
      return Q(K, H);
    }
    return B$1;
  }
  return {
    factory: qz0,
    granularity: "group",
    preferSmoothing: !0,
    color: W,
    props: J,
    contextHash: Y,
    description: w$1,
    legend: X
  };
}
var Fz0 = {
  name: "illustrative",
  label: "Illustrative",
  category: $8.Misc,
  factory: qz0,
  getParams: j$1,
  defaultValues: j.getDefaultValues(Nz0),
  isApplicable: (Z) => !!Z.structure
};

// node_modules/molstar/lib/mol-theme/color/hydrophobicity.js
var _$1 = '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).', Kb = {
  list: j.ColorList("red-yellow-green", { presetKind: "scale" }),
  scale: j.Select("DGwif", [["DGwif", "DG water-membrane"], ["DGwoct", "DG water-octanol"], ["Oct-IF", "DG difference"]])
};
function V$1(Z) {
  return Kb;
}
var I$1 = { DGwif: 0, DGwoct: 1, "Oct-IF": 2 };
function P$1(Z, J) {
  let $ = Sf[Z];
  return $ === void 0 ? 0 : $[J];
}
function Uz0(Z, J) {
  return Z.model.atomicHierarchy.atoms.label_comp_id.value(J);
}
function Lz0(Z, J) {
  let $ = Z.coarseElements.seq_id_begin.value(J), X = Z.coarseElements.seq_id_end.value(J);
  if ($ === X) {
    let Y = Z.coarseElements.entityKey[J];
    return Z.model.sequence.byEntityKey[Y].sequence.compId.value($ - 1);
  }
}
function Gb(Z, J) {
  let $ = I$1[J.scale], X = 1 / 0, Y = -1 / 0;
  for (let K in Sf) {
    let G = Sf[K][$];
    X = Math.min(X, G), Y = Math.max(Y, G);
  }
  let Q = _J.create({
    listOrName: J.list.colors,
    domain: [Y, X],
    minLabel: "Hydrophilic",
    maxLabel: "Hydrophobic"
  });
  function W(K) {
    let G;
    if (W0.Location.is(K))
      if (j0.isAtomic(K.unit))
        G = Uz0(K.unit, K.element);
      else
        G = Lz0(K.unit, K.element);
    else if ($2.isLocation(K))
      if (j0.isAtomic(K.aUnit))
        G = Uz0(K.aUnit, K.aUnit.elements[K.aIndex]);
      else
        G = Lz0(K.aUnit, K.aUnit.elements[K.aIndex]);
    return Q.color(G ? P$1(G, $) : 0);
  }
  return {
    factory: Gb,
    granularity: "group",
    preferSmoothing: !0,
    color: W,
    props: J,
    description: _$1,
    legend: Q ? Q.legend : void 0
  };
}
var Rz0 = {
  name: "hydrophobicity",
  label: "Hydrophobicity",
  category: $8.Residue,
  factory: Gb,
  getParams: V$1,
  defaultValues: j.getDefaultValues(Kb),
  isApplicable: (Z) => !!Z.structure
};

// node_modules/molstar/lib/mol-theme/color/occupancy.js
var C$1 = i0(13421772), k$1 = "Assigns a color based on the occupancy of an atom.", Hb = {
  domain: j.Interval([0, 1]),
  list: j.ColorList("purples", { presetKind: "scale" })
};
function v$1(Z) {
  return Hb;
}
function Ez0(Z, J) {
  if (j0.isAtomic(Z))
    return Z.model.atomicConformation.occupancy.value(J);
  else
    return 0;
}
function Nb(Z, J) {
  let $ = _J.create({
    reverse: !1,
    domain: J.domain,
    listOrName: J.list.colors
  });
  function X(Y) {
    if (W0.Location.is(Y))
      return $.color(Ez0(Y.unit, Y.element));
    else if ($2.isLocation(Y))
      return $.color(Ez0(Y.aUnit, Y.aUnit.elements[Y.aIndex]));
    return C$1;
  }
  return {
    factory: Nb,
    granularity: "group",
    preferSmoothing: !0,
    color: X,
    props: J,
    description: k$1,
    legend: $ ? $.legend : void 0
  };
}
var Oz0 = {
  name: "occupancy",
  label: "Occupancy",
  category: $8.Atom,
  factory: Nb,
  getParams: v$1,
  defaultValues: j.getDefaultValues(Hb),
  isApplicable: (Z) => !!Z.structure && Z.structure.models.some((J) => J.atomicConformation.occupancy.isDefined)
};

// node_modules/molstar/lib/mol-theme/color/operator-hkl.js
var ua = "dark-2", zz0 = i0(13421772), S$1 = "Assigns a color based on the operator HKL value of a transformed chain.", Dz0 = {
  ...p9({ type: "colors", colorList: ua })
};
function f$1(Z) {
  let J = j.clone(Dz0);
  if (Z.structure) {
    if (Mz0(Z.structure.root).map.size > g7[ua].list.length)
      J.palette.defaultValue.name = "colors", J.palette.defaultValue.params = {
        ...J.palette.defaultValue.params,
        list: { kind: "interpolate", colors: RJ(ua).list }
      };
  }
  return J;
}
var EV = 1e4;
function ca(Z) {
  return Z.map((J) => `${J + EV}`.padStart(5, "0")).join("");
}
function la(Z) {
  let J = RH0(EV, 0), $ = parseInt(Z.substr(0, J)), X = parseInt(Z.substr(J, J)), Y = parseInt(Z.substr(J + J, J));
  return M.create($ - EV, X - EV, Y - EV);
}
function pa(Z) {
  return Z.map((J) => J + 5).join("");
}
function Mz0(Z) {
  let J = /* @__PURE__ */ new Map, $ = /* @__PURE__ */ new Set;
  for (let W = 0, K = Z.units.length;W < K; ++W) {
    let G = ca(Z.units[W].conformation.operator.hkl);
    $.add(G);
  }
  let X = Array.from($.values()).sort();
  X.forEach((W) => J.set(W, J.size));
  let Y = la(X[0]), Q = la(X[X.length - 1]);
  return { min: Y, max: Q, map: J };
}
function Az0(Z, J) {
  let $, X;
  if (Z.structure) {
    let { min: Y, max: Q, map: W } = Mz0(Z.structure.root), K = [];
    W.forEach((N, q) => {
      let U = N % W.size, F = pa(la(q));
      if (K[U] === void 0)
        K[U] = F;
      else
        K[U] += `, ${F}`;
    });
    let G = {
      minLabel: pa(Y),
      maxLabel: pa(Q),
      valueLabel: (N) => K[N]
    }, H = a9(W.size, J, G);
    X = H.legend, $ = (N) => {
      let q = void 0;
      if (W0.Location.is(N)) {
        let U = ca(N.unit.conformation.operator.hkl);
        q = W.get(U);
      } else if ($2.isLocation(N)) {
        let U = ca(N.aUnit.conformation.operator.hkl);
        q = W.get(U);
      }
      return q === void 0 ? zz0 : H.color(q);
    };
  } else
    $ = () => zz0;
  return {
    factory: Az0,
    granularity: "instance",
    color: $,
    props: J,
    description: S$1,
    legend: X
  };
}
var Bz0 = {
  name: "operator-hkl",
  label: "Operator HKL",
  category: $8.Symmetry,
  factory: Az0,
  getParams: f$1,
  defaultValues: j.getDefaultValues(Dz0),
  isApplicable: (Z) => !!Z.structure
};

// node_modules/molstar/lib/mol-model-formats/structure/property/partial-charge.js
var EH;
(function(Z) {
  Z.Descriptor = {
    name: "atom_partial_charge"
  }, Z.Provider = e$.create(Z.Descriptor);
})(EH || (EH = {}));

// node_modules/molstar/lib/mol-theme/color/partial-charge.js
var na = i0(16777113), h$1 = "Assigns a color based on the partial charge of an atom.", qb = {
  domain: j.Interval([-1, 1]),
  list: j.ColorList("red-white-blue", { presetKind: "scale" })
};
function b$1(Z) {
  return qb;
}
function wz0(Z, J) {
  var $;
  return ($ = EH.Provider.get(Z.model)) === null || $ === void 0 ? void 0 : $.data.value(J);
}
function Fb(Z, J) {
  let $ = _J.create({
    domain: J.domain,
    listOrName: J.list.colors
  });
  function X(Y) {
    if (W0.Location.is(Y)) {
      let Q = wz0(Y.unit, Y.element);
      return Q !== void 0 ? $.color(Q) : na;
    } else if ($2.isLocation(Y)) {
      let Q = wz0(Y.aUnit, Y.aUnit.elements[Y.aIndex]);
      return Q !== void 0 ? $.color(Q) : na;
    }
    return na;
  }
  return {
    factory: Fb,
    granularity: "group",
    preferSmoothing: !0,
    color: X,
    props: J,
    description: h$1,
    legend: $ ? $.legend : void 0
  };
}
var jz0 = {
  name: "partial-charge",
  label: "Partial Charge",
  category: $8.Atom,
  factory: Fb,
  getParams: b$1,
  defaultValues: j.getDefaultValues(qb),
  isApplicable: (Z) => !!Z.structure && Z.structure.models.some((J) => EH.Provider.get(J) !== void 0)
};

// node_modules/molstar/lib/mol-theme/color/atom-id.js
var x$1 = "many-distinct", Tz0 = i0(16448250), y$1 = "Gives every atom a color based on its `label_atom_id` value.", _z0 = {
  ...p9({ type: "colors", colorList: x$1 })
};
function g$1(Z) {
  return j.clone(_z0);
}
function m$1(Z) {
  let J = /* @__PURE__ */ new Map;
  for (let $ of Z.models) {
    let { label_atom_id: X } = $.atomicHierarchy.atoms;
    for (let Y = 0, Q = X.rowCount;Y < Q; ++Y) {
      let W = X.value(Y);
      if (!J.has(W))
        J.set(W, J.size);
    }
  }
  return J;
}
function Vz0(Z, J) {
  let $, X;
  if (Z.structure) {
    let Y = W0.Location.create(Z.structure.root), Q = m$1(Z.structure.root), W = Array.from(Q.keys()), K = (H) => W[H], G = a9(Q.size, J, { valueLabel: K });
    X = G.legend, $ = (H) => {
      let N = void 0;
      if (W0.Location.is(H)) {
        let q = w1.atom.label_atom_id(H);
        N = Q.get(q);
      } else if ($2.isLocation(H)) {
        Y.unit = H.aUnit, Y.element = H.aUnit.elements[H.aIndex];
        let q = w1.atom.label_atom_id(Y);
        N = Q.get(q);
      }
      return N === void 0 ? Tz0 : G.color(N);
    };
  } else
    $ = () => Tz0;
  return {
    factory: Vz0,
    granularity: "group",
    preferSmoothing: !0,
    color: $,
    props: J,
    description: y$1,
    legend: X
  };
}
var Iz0 = {
  name: "atom-id",
  label: "Atom Id",
  category: $8.Atom,
  factory: Vz0,
  getParams: g$1,
  defaultValues: j.getDefaultValues(_z0),
  isApplicable: (Z) => !!Z.structure
};

// node_modules/molstar/lib/mol-theme/color/volume-value.js
var ia = "Assign color based on the given value of a volume cell.", Pz0 = {
  colorList: j.ColorList({
    kind: "interpolate",
    colors: [
      [c2.white, 0],
      [c2.red, 0.25],
      [c2.white, 0.5],
      [c2.blue, 0.75],
      [c2.white, 1]
    ]
  }, { offsets: !0, isEssential: !0 }),
  domain: j.MappedStatic("auto", {
    custom: j.Interval([-1, 1], { step: 0.001 }),
    auto: j.Group({
      symmetric: j.Boolean(!1, { description: "If true the automatic range is determined as [-|max|, |max|]." })
    })
  }),
  isRelative: j.Boolean(!1, { description: "If true the value is treated as relative to the volume mean and sigma." }),
  defaultColor: j.Color(i0(13421772))
};
function d$1(Z) {
  return Pz0;
}
function Ub(Z, J) {
  var $;
  if (Z.volume) {
    let { min: X, max: Y, mean: Q, sigma: W } = Z.volume.grid.stats, K = J.domain.name === "custom" ? J.domain.params : [X, Y], { colorList: G, defaultColor: H } = J;
    if (J.domain.name === "auto" && J.isRelative)
      K[0] = (K[0] - Q) / W, K[1] = (K[1] - Q) / W;
    if (J.domain.name === "auto" && J.domain.params.symmetric) {
      let N = Math.max(Math.abs(K[0]), Math.abs(K[1]));
      K[0] = -N, K[1] = N;
    }
    if (($ = Z.locationKinds) === null || $ === void 0 ? void 0 : $.includes("direct-location")) {
      let N = [
        aG(K[0], X, Y),
        aG(K[1], X, Y)
      ], q = oJ.Palette(G.colors, G.kind, N, H);
      return {
        factory: Ub,
        granularity: "direct",
        props: J,
        description: ia,
        palette: q
      };
    } else {
      let N = s6.makeGetTrilinearlyInterpolated(Z.volume.grid, "none"), q = (F) => {
        if (!qA(F))
          return J.defaultColor;
        let E = N(F.position);
        if (Number.isNaN(E))
          return J.defaultColor;
        return x8((E - K[0]) / (K[1] - K[0]), 0, 1) * oJ.PaletteScale;
      }, U = oJ.Palette(G.colors, G.kind, void 0, H);
      return {
        factory: Ub,
        granularity: "vertex",
        preferSmoothing: !0,
        color: q,
        palette: U,
        props: J,
        description: ia
      };
    }
  } else
    return {
      factory: Ub,
      granularity: "uniform",
      color: () => J.defaultColor,
      props: J,
      description: ia
    };
}
var Cz0 = {
  name: "volume-value",
  label: "Volume Value",
  category: $8.Misc,
  factory: Ub,
  getParams: d$1,
  defaultValues: j.getDefaultValues(Pz0),
  isApplicable: (Z) => !!Z.volume && !Q1.Segmentation.get(Z.volume)
};

// node_modules/molstar/lib/mol-theme/color/volume-segment.js
var kz0 = i0(13421772), p$1 = "Gives every volume segment a unique color.", vz0 = {
  ...p9({ type: "colors", colorList: "many-distinct" })
};
function u$1(Z) {
  return j.clone(vz0);
}
function Sz0(Z, J) {
  let $, X, Y = Z.volume && Q1.Segmentation.get(Z.volume);
  if (Y) {
    let Q = Y.segments.size, W = Array.from(Y.segments.keys()), K = a9(Q, J);
    X = K.legend, $ = (G) => {
      if (Q1.Segment.isLocation(G))
        return K.color(W.indexOf(G.segment));
      return kz0;
    };
  } else
    $ = () => kz0;
  return {
    factory: Sz0,
    granularity: "instance",
    color: $,
    props: J,
    description: p$1,
    legend: X
  };
}
var fz0 = {
  name: "volume-segment",
  label: "Volume Segment",
  category: $8.Misc,
  factory: Sz0,
  getParams: u$1,
  defaultValues: j.getDefaultValues(vz0),
  isApplicable: (Z) => !!Z.volume && !!Q1.Segmentation.get(Z.volume)
};

// node_modules/molstar/lib/mol-theme/color/external-volume.js
var c$1 = "Assigns a color based on volume value at a given vertex.", hz0 = {
  volume: j.ValueRef((Z) => {
    return Z.state.data.selectQ(($) => $.root.subtree().filter((X) => {
      var Y;
      return Q1.is((Y = X.obj) === null || Y === void 0 ? void 0 : Y.data);
    })).map(($) => {
      var X, Y;
      return [$.transform.ref, (Y = (X = $.obj) === null || X === void 0 ? void 0 : X.label) !== null && Y !== void 0 ? Y : "<unknown>"];
    });
  }, (Z, J) => J(Z)),
  coloring: j.MappedStatic("absolute-value", {
    "absolute-value": j.Group({
      domain: j.MappedStatic("auto", {
        custom: j.Interval([-1, 1], { step: 0.001 }),
        auto: j.Group({
          symmetric: j.Boolean(!1, { description: "If true the automatic range is determined as [-|max|, |max|]." })
        })
      }),
      list: j.ColorList("red-white-blue", { presetKind: "scale" })
    }),
    "relative-value": j.Group({
      domain: j.MappedStatic("auto", {
        custom: j.Interval([-1, 1], { step: 0.001 }),
        auto: j.Group({
          symmetric: j.Boolean(!1, { description: "If true the automatic range is determined as [-|max|, |max|]." })
        })
      }),
      list: j.ColorList("red-white-blue", { presetKind: "scale" })
    })
  }),
  defaultColor: j.Color(i0(13421772)),
  normalOffset: j.Numeric(0, { min: 0, max: 20, step: 0.1 }, { description: "Offset vertex position along its normal by given amount." }),
  usePalette: j.Boolean(!1, { description: "Use a palette to color at the pixel level." })
};
function bz0(Z, J) {
  let $;
  try {
    $ = J.volume.getValue();
  } catch (G) {}
  let X, Y, { normalOffset: Q, defaultColor: W, usePalette: K } = J;
  if ($) {
    let G = J.coloring.params, { stats: H } = $.grid, N = G.domain.name === "custom" ? G.domain.params : [H.min, H.max], q = J.coloring.name === "relative-value";
    if (G.domain.name === "auto" && q)
      N[0] = (N[0] - H.mean) / H.sigma, N[1] = (N[1] - H.mean) / H.sigma;
    if (G.domain.name === "auto" && G.domain.params.symmetric) {
      let R = Math.max(Math.abs(N[0]), Math.abs(N[1]));
      N[0] = -R, N[1] = R;
    }
    let U = _J.create({ domain: N, listOrName: G.list.colors }), F = M(), E = s6.makeGetTrilinearlyInterpolated($.grid, q ? "relative" : "none");
    X = (R) => {
      if (!qA(R))
        return W;
      if (Q > 0)
        M.scaleAndAdd(F, R.position, R.normal, Q);
      else
        M.copy(F, R.position);
      let z = E(F);
      if (Number.isNaN(z))
        return W;
      if (K)
        return x8((z - N[0]) / (N[1] - N[0]), 0, 1) * oJ.PaletteScale;
      else
        return U.color(z);
    }, Y = K ? {
      colors: G.list.colors.map((R) => Array.isArray(R) ? R[0] : R),
      filter: G.list.kind === "set" ? "nearest" : "linear"
    } : void 0;
  } else
    X = () => W;
  return {
    factory: bz0,
    granularity: "vertex",
    preferSmoothing: !0,
    color: X,
    palette: Y,
    props: J,
    description: c$1
  };
}
var xz0 = {
  name: "external-volume",
  label: "External Volume",
  category: $8.Misc,
  factory: bz0,
  getParams: () => hz0,
  defaultValues: j.getDefaultValues(hz0),
  isApplicable: (Z) => !0
};

// node_modules/molstar/lib/mol-theme/color/cartoon.js
var l$1 = "Uses separate themes for coloring mainchain and sidechain visuals.", yz0 = {
  mainchain: j.MappedStatic("molecule-type", {
    uniform: j.Group(tF),
    "chain-id": j.Group(iN),
    "entity-id": j.Group(aN),
    "entity-source": j.Group(tN),
    "molecule-type": j.Group(vR),
    "model-index": j.Group(Zq),
    "structure-index": j.Group($q),
    "secondary-structure": j.Group(Jb),
    "trajectory-index": j.Group(CR)
  }),
  sidechain: j.MappedStatic("residue-name", {
    uniform: j.Group(tF),
    "residue-name": j.Group(th),
    "element-symbol": j.Group(sh),
    hydrophobicity: j.Group(Kb),
    uncertainty: j.Group(Qb),
    occupancy: j.Group(Hb),
    "sequence-id": j.Group(Xb),
    "partial-charge": j.Group(qb)
  })
};
function n$1(Z) {
  return j.clone(yz0);
}
function i$1(Z, J) {
  switch (J.name) {
    case "uniform":
      return qH(Z, J.params);
    case "chain-id":
      return oN(Z, J.params);
    case "entity-id":
      return rN(Z, J.params);
    case "entity-source":
      return eN(Z, J.params);
    case "molecule-type":
      return SR(Z, J.params);
    case "model-index":
      return Jq(Z, J.params);
    case "structure-index":
      return Xq(Z, J.params);
    case "secondary-structure":
      return $b(Z, J.params);
    case "trajectory-index":
      return kR(Z, J.params);
    default:
      T8(J);
  }
}
function o$1(Z, J) {
  switch (J.name) {
    case "uniform":
      return qH(Z, J.params);
    case "residue-name":
      return eh(Z, J.params);
    case "element-symbol":
      return ah(Z, J.params);
    case "hydrophobicity":
      return Gb(Z, J.params);
    case "uncertainty":
      return Wb(Z, J.params);
    case "occupancy":
      return Nb(Z, J.params);
    case "sequence-id":
      return Yb(Z, J.params);
    case "partial-charge":
      return Fb(Z, J.params);
    default:
      T8(J);
  }
}
function gz0(Z, J) {
  var $, X, Y, Q;
  let W = i$1(Z, J.mainchain), K = o$1(Z, J.sidechain), G = SQ(($ = W.contextHash) !== null && $ !== void 0 ? $ : 0, (X = K.contextHash) !== null && X !== void 0 ? X : 0);
  function H(q, U) {
    return U ? W.color(q, !1) : K.color(q, !1);
  }
  let N = W.legend;
  if (((Y = W.legend) === null || Y === void 0 ? void 0 : Y.kind) === "table-legend" && ((Q = K.legend) === null || Q === void 0 ? void 0 : Q.kind) === "table-legend")
    N = {
      kind: "table-legend",
      table: [...W.legend.table, ...K.legend.table]
    };
  return {
    factory: gz0,
    granularity: "group",
    preferSmoothing: !1,
    color: H,
    props: J,
    contextHash: G,
    description: l$1,
    legend: N
  };
}
var mz0 = {
  name: "cartoon",
  label: "Cartoon",
  category: $8.Misc,
  factory: gz0,
  getParams: n$1,
  defaultValues: j.getDefaultValues(yz0),
  isApplicable: (Z) => !!Z.structure
};

// node_modules/molstar/lib/mol-theme/color/formal-charge.js
var oa = i0(16777113), s$1 = "Assigns a color based on the formal charge of an atom.", pz0 = {
  domain: j.Interval([-3, 3]),
  list: j.ColorList({ kind: "set", colors: g7["red-white-blue"].list })
};
function a$1(Z) {
  return pz0;
}
function dz0(Z, J) {
  if (j0.isAtomic(Z))
    return Z.model.atomicHierarchy.atoms.pdbx_formal_charge.value(J);
  else
    return 0;
}
function uz0(Z, J) {
  let $ = _J.create({
    domain: J.domain,
    listOrName: J.list.colors
  });
  function X(Y) {
    if (W0.Location.is(Y)) {
      let Q = dz0(Y.unit, Y.element);
      return Q !== void 0 ? $.color(Q) : oa;
    } else if ($2.isLocation(Y)) {
      let Q = dz0(Y.aUnit, Y.aUnit.elements[Y.aIndex]);
      return Q !== void 0 ? $.color(Q) : oa;
    }
    return oa;
  }
  return {
    factory: uz0,
    granularity: "group",
    preferSmoothing: !0,
    color: X,
    props: J,
    description: s$1,
    legend: $ ? $.legend : void 0
  };
}
var cz0 = {
  name: "formal-charge",
  label: "Formal Charge",
  category: $8.Atom,
  factory: uz0,
  getParams: a$1,
  defaultValues: j.getDefaultValues(pz0),
  isApplicable: (Z) => !!Z.structure && Z.structure.models.some((J) => J.atomicHierarchy.atoms.pdbx_formal_charge.isDefined)
};
// node_modules/molstar/lib/mol-script/runtime/query/table.js
var y8 = NH.Const, Y8 = NH.Dynamic, r$1 = [
  y8(p0.core.type.bool, function Z(J, $) {
    return !!$[0](J);
  }),
  y8(p0.core.type.num, function Z(J, $) {
    return +$[0](J);
  }),
  y8(p0.core.type.str, function Z(J, $) {
    return "" + $[0](J);
  }),
  y8(p0.core.type.list, function Z(J, $) {
    return QA.forEachEval($, J, (X, Y, Q) => Q[Y] = X, []);
  }),
  y8(p0.core.type.set, function Z(J, $) {
    return QA.forEachEval($, J, function X(Y, Q, W) {
      return W.add(Y);
    }, /* @__PURE__ */ new Set);
  }),
  y8(p0.core.type.regex, function Z(J, $) {
    return new RegExp($[0](J), $[1] && $[1](J) || "");
  }),
  y8(p0.core.type.bitflags, function Z(J, $) {
    return +$[0](J);
  }),
  y8(p0.core.type.compositeKey, function Z(J, $) {
    return QA.forEachEval($, J, (X, Y, Q) => Q[Y] = "" + X, []).join("-");
  }),
  y8(p0.core.logic.not, (Z, J) => !J[0](Z)),
  y8(p0.core.logic.and, (Z, J) => {
    if (typeof J.length === "number") {
      for (let $ = 0, X = J.length;$ < X; $++)
        if (!J[$](Z))
          return !1;
    } else
      for (let $ of Object.keys(J))
        if (!J[$](Z))
          return !1;
    return !0;
  }),
  y8(p0.core.logic.or, (Z, J) => {
    if (typeof J.length === "number") {
      for (let $ = 0, X = J.length;$ < X; $++)
        if (J[$](Z))
          return !0;
    } else
      for (let $ of Object.keys(J))
        if (J[$](Z))
          return !0;
    return !1;
  }),
  y8(p0.core.rel.eq, (Z, J) => J[0](Z) === J[1](Z)),
  y8(p0.core.rel.neq, (Z, J) => J[0](Z) !== J[1](Z)),
  y8(p0.core.rel.lt, (Z, J) => J[0](Z) < J[1](Z)),
  y8(p0.core.rel.lte, (Z, J) => J[0](Z) <= J[1](Z)),
  y8(p0.core.rel.gr, (Z, J) => J[0](Z) > J[1](Z)),
  y8(p0.core.rel.gre, (Z, J) => J[0](Z) >= J[1](Z)),
  y8(p0.core.rel.inRange, (Z, J) => {
    let $ = J[0](Z);
    return $ >= J[1](Z) && $ <= J[2](Z);
  }),
  y8(p0.core.math.add, (Z, J) => {
    let $ = 0;
    if (typeof J.length === "number")
      for (let X = 0, Y = J.length;X < Y; X++)
        $ += J[X](Z);
    else
      for (let X of Object.keys(J))
        $ += J[X](Z);
    return $;
  }),
  y8(p0.core.math.sub, (Z, J) => {
    let $ = 0;
    if (typeof J.length === "number") {
      if (J.length === 1)
        return -J[0](Z);
      $ = J[0](Z) || 0;
      for (let X = 1, Y = J.length;X < Y; X++)
        $ -= J[X](Z);
    } else {
      let X = Object.keys(J);
      if (X.length === 1)
        return -J[X[0]](Z);
      $ = J[X[0]](Z) || 0;
      for (let Y = 1, Q = X.length;Y < Q; Y++)
        $ -= J[X[Y]](Z);
    }
    return $;
  }),
  y8(p0.core.math.mult, (Z, J) => {
    let $ = 1;
    if (typeof J.length === "number")
      for (let X = 0, Y = J.length;X < Y; X++)
        $ *= J[X](Z);
    else
      for (let X of Object.keys(J))
        $ *= J[X](Z);
    return $;
  }),
  y8(p0.core.math.div, (Z, J) => J[0](Z) / J[1](Z)),
  y8(p0.core.math.pow, (Z, J) => Math.pow(J[0](Z), J[1](Z))),
  y8(p0.core.math.mod, (Z, J) => J[0](Z) % J[1](Z)),
  y8(p0.core.math.min, (Z, J) => {
    let $ = Number.POSITIVE_INFINITY;
    if (typeof J.length === "number")
      for (let X = 0, Y = J.length;X < Y; X++)
        $ = Math.min(J[X](Z), $);
    else
      for (let X of Object.keys(J))
        $ = Math.min(J[X](Z), $);
    return $;
  }),
  y8(p0.core.math.max, (Z, J) => {
    let $ = Number.NEGATIVE_INFINITY;
    if (typeof J.length === "number")
      for (let X = 0, Y = J.length;X < Y; X++)
        $ = Math.max(J[X](Z), $);
    else
      for (let X of Object.keys(J))
        $ = Math.max(J[X](Z), $);
    return $;
  }),
  y8(p0.core.math.cantorPairing, (Z, J) => ZJ(J[0](Z), J[1](Z))),
  y8(p0.core.math.sortedCantorPairing, (Z, J) => wW(J[0](Z), J[1](Z))),
  y8(p0.core.math.invertCantorPairing, (Z, J) => PM([0, 0], J[0](Z))),
  y8(p0.core.math.floor, (Z, J) => Math.floor(J[0](Z))),
  y8(p0.core.math.ceil, (Z, J) => Math.ceil(J[0](Z))),
  y8(p0.core.math.roundInt, (Z, J) => Math.round(J[0](Z))),
  y8(p0.core.math.trunc, (Z, J) => Math.trunc(J[0](Z))),
  y8(p0.core.math.abs, (Z, J) => Math.abs(J[0](Z))),
  y8(p0.core.math.sign, (Z, J) => Math.sign(J[0](Z))),
  y8(p0.core.math.sqrt, (Z, J) => Math.sqrt(J[0](Z))),
  y8(p0.core.math.cbrt, (Z, J) => Math.cbrt(J[0](Z))),
  y8(p0.core.math.sin, (Z, J) => Math.sin(J[0](Z))),
  y8(p0.core.math.cos, (Z, J) => Math.cos(J[0](Z))),
  y8(p0.core.math.tan, (Z, J) => Math.tan(J[0](Z))),
  y8(p0.core.math.asin, (Z, J) => Math.asin(J[0](Z))),
  y8(p0.core.math.acos, (Z, J) => Math.acos(J[0](Z))),
  y8(p0.core.math.atan, (Z, J) => Math.atan(J[0](Z))),
  y8(p0.core.math.sinh, (Z, J) => Math.sinh(J[0](Z))),
  y8(p0.core.math.cosh, (Z, J) => Math.cosh(J[0](Z))),
  y8(p0.core.math.tanh, (Z, J) => Math.tanh(J[0](Z))),
  y8(p0.core.math.exp, (Z, J) => Math.exp(J[0](Z))),
  y8(p0.core.math.log, (Z, J) => Math.log(J[0](Z))),
  y8(p0.core.math.log10, (Z, J) => Math.log10(J[0](Z))),
  y8(p0.core.math.atan2, (Z, J) => Math.atan2(J[0](Z), J[1](Z))),
  y8(p0.core.str.match, (Z, J) => J[0](Z).test(J[1](Z))),
  y8(p0.core.str.concat, (Z, J) => {
    let $ = [];
    if (typeof J.length === "number")
      for (let X = 0, Y = J.length;X < Y; X++)
        $.push(J[X](Z).toString());
    else
      for (let X of Object.keys(J))
        $.push(J[X](Z).toString());
    return $.join("");
  }),
  y8(p0.core.list.getAt, (Z, J) => J[0](Z)[J[1](Z)]),
  y8(p0.core.list.equal, (Z, J) => oO(J[0](Z), J[1](Z))),
  y8(p0.core.set.has, function Z(J, $) {
    return $[0](J).has($[1](J));
  }),
  y8(p0.core.set.isSubset, function Z(J, $) {
    return uZ.isSuperset($[1](J), $[0](J));
  }),
  y8(p0.core.flags.hasAny, (Z, J) => {
    let $ = J[1](Z), X = J[0](Z);
    if (!$)
      return !!X;
    return (X & $) !== 0;
  }),
  y8(p0.core.flags.hasAll, (Z, J) => {
    let $ = J[1](Z), X = J[0](Z);
    if (!$)
      return !X;
    return (X & $) === $;
  }),
  y8(p0.structureQuery.type.elementSymbol, (Z, J) => WH(J[0](Z))),
  y8(p0.structureQuery.type.atomName, (Z, J) => l50(J[0](Z))),
  y8(p0.structureQuery.type.bondFlags, (Z, J) => {
    let $ = s1.Flag.None;
    if (typeof J.length === "number")
      for (let X = 0, Y = J.length;X < Y; X++)
        $ = lz0($, J[X](Z));
    else
      for (let X of Object.keys(J))
        $ = lz0($, J[X](Z));
    return $;
  }),
  y8(p0.structureQuery.type.ringFingerprint, (Z, J) => A5.elementFingerprint(t$1(Z, J))),
  y8(p0.structureQuery.type.secondaryStructureFlags, (Z, J) => {
    let $ = m2.Flag.None;
    if (typeof J.length === "number")
      for (let X = 0, Y = J.length;X < Y; X++)
        $ = nz0($, J[X](Z));
    else
      for (let X of Object.keys(J))
        $ = nz0($, J[X](Z));
    return $;
  }),
  Y8(p0.structureQuery.filter.pick, (Z, J) => OZ.filters.pick(J[0], J.test)(Z)),
  Y8(p0.structureQuery.filter.first, (Z, J) => OZ.filters.first(J[0])(Z)),
  Y8(p0.structureQuery.filter.withSameAtomProperties, (Z, J) => OZ.filters.withSameAtomProperties(J[0], J.source, J.property)(Z)),
  Y8(p0.structureQuery.filter.intersectedBy, (Z, J) => OZ.filters.areIntersectedBy(J[0], J.by)(Z)),
  Y8(p0.structureQuery.filter.within, (Z, J) => {
    var $, X, Y;
    return OZ.filters.within({
      query: J[0],
      target: J.target,
      minRadius: ($ = J["min-radius"]) === null || $ === void 0 ? void 0 : $.call(J, Z),
      maxRadius: (X = J["max-radius"]) === null || X === void 0 ? void 0 : X.call(J, Z),
      elementRadius: J["atom-radius"],
      invert: (Y = J.invert) === null || Y === void 0 ? void 0 : Y.call(J, Z)
    })(Z);
  }),
  Y8(p0.structureQuery.filter.isConnectedTo, (Z, J) => {
    var $, X;
    return OZ.filters.isConnectedTo({
      query: J[0],
      target: J.target,
      disjunct: ($ = J.disjunct) === null || $ === void 0 ? void 0 : $.call(J, Z),
      invert: (X = J.invert) === null || X === void 0 ? void 0 : X.call(J, Z),
      bondTest: J["bond-test"]
    })(Z);
  }),
  Y8(p0.structureQuery.generator.atomGroups, function Z(J, $) {
    return OZ.generators.atoms({
      entityTest: $["entity-test"],
      chainTest: $["chain-test"],
      residueTest: $["residue-test"],
      atomTest: $["atom-test"],
      groupBy: $["group-by"]
    })(J);
  }),
  Y8(p0.structureQuery.generator.all, function Z(J) {
    return OZ.generators.all(J);
  }),
  Y8(p0.structureQuery.generator.empty, function Z(J) {
    return OZ.generators.none(J);
  }),
  Y8(p0.structureQuery.generator.bondedAtomicPairs, function Z(J, $) {
    return OZ.generators.bondedAtomicPairs($ && $[0])(J);
  }),
  Y8(p0.structureQuery.generator.rings, function Z(J, $) {
    var X, Y;
    return OZ.generators.rings((X = $ === null || $ === void 0 ? void 0 : $.fingerprint) === null || X === void 0 ? void 0 : X.call($, J), (Y = $ === null || $ === void 0 ? void 0 : $["only-aromatic"]) === null || Y === void 0 ? void 0 : Y.call($, J))(J);
  }),
  Y8(p0.structureQuery.generator.queryInSelection, function Z(J, $) {
    var X;
    return OZ.generators.querySelection($[0], $.query, (X = $["in-complement"]) === null || X === void 0 ? void 0 : X.call($, J))(J);
  }),
  Y8(p0.structureQuery.modifier.includeSurroundings, function Z(J, $) {
    return OZ.modifiers.includeSurroundings($[0], {
      radius: $.radius(J),
      wholeResidues: !!($["as-whole-residues"] && $["as-whole-residues"](J)),
      elementRadius: $["atom-radius"]
    })(J);
  }),
  Y8(p0.structureQuery.modifier.surroundingLigands, function Z(J, $) {
    return OZ.modifiers.surroundingLigands({
      query: $[0],
      radius: $.radius(J),
      includeWater: !!($["include-water"] && $["include-water"](J))
    })(J);
  }),
  Y8(p0.structureQuery.modifier.wholeResidues, function Z(J, $) {
    return OZ.modifiers.wholeResidues($[0])(J);
  }),
  Y8(p0.structureQuery.modifier.union, function Z(J, $) {
    return OZ.modifiers.union($[0])(J);
  }),
  Y8(p0.structureQuery.modifier.expandProperty, function Z(J, $) {
    return OZ.modifiers.expandProperty($[0], $.property)(J);
  }),
  Y8(p0.structureQuery.modifier.exceptBy, function Z(J, $) {
    return OZ.modifiers.exceptBy($[0], $.by)(J);
  }),
  Y8(p0.structureQuery.modifier.includeConnected, function Z(J, $) {
    var X, Y;
    return OZ.modifiers.includeConnected({
      query: $[0],
      bondTest: $["bond-test"],
      wholeResidues: !!($["as-whole-residues"] && $["as-whole-residues"](J)),
      layerCount: $["layer-count"] && $["layer-count"](J) || 1,
      fixedPoint: (Y = (X = $["fixed-point"]) === null || X === void 0 ? void 0 : X.call($, J)) !== null && Y !== void 0 ? Y : !1
    })(J);
  }),
  Y8(p0.structureQuery.modifier.intersectBy, function Z(J, $) {
    return OZ.modifiers.intersectBy($[0], $.by)(J);
  }),
  Y8(p0.structureQuery.combinator.merge, (Z, J) => OZ.combinators.merge(J)(Z)),
  Y8(p0.structureQuery.atomProperty.core.elementSymbol, z9(w1.atom.type_symbol)),
  Y8(p0.structureQuery.atomProperty.core.vdw, (Z, J) => D5(w1.atom.type_symbol(J && J[0] && J[0](Z) || Z.element))),
  Y8(p0.structureQuery.atomProperty.core.mass, (Z, J) => _H0(w1.atom.type_symbol(J && J[0] && J[0](Z) || Z.element))),
  Y8(p0.structureQuery.atomProperty.core.atomicNumber, (Z, J) => DR(w1.atom.type_symbol(J && J[0] && J[0](Z) || Z.element))),
  Y8(p0.structureQuery.atomProperty.core.x, z9(w1.atom.x)),
  Y8(p0.structureQuery.atomProperty.core.y, z9(w1.atom.y)),
  Y8(p0.structureQuery.atomProperty.core.z, z9(w1.atom.z)),
  Y8(p0.structureQuery.atomProperty.core.sourceIndex, z9(w1.atom.sourceIndex)),
  Y8(p0.structureQuery.atomProperty.core.operatorName, z9(w1.unit.operator_name)),
  Y8(p0.structureQuery.atomProperty.core.instanceId, z9(w1.unit.instance_id)),
  Y8(p0.structureQuery.atomProperty.core.operatorKey, z9(w1.unit.operator_key)),
  Y8(p0.structureQuery.atomProperty.core.modelIndex, z9(w1.unit.model_index)),
  Y8(p0.structureQuery.atomProperty.core.modelLabel, z9(w1.unit.model_label)),
  Y8(p0.structureQuery.atomProperty.core.modelEntryId, z9(w1.unit.model_entry_id)),
  Y8(p0.structureQuery.atomProperty.core.atomKey, (Z, J) => {
    let $ = J && J[0] && J[0](Z) || Z.element;
    return ZJ($.unit.id, $.element);
  }),
  Y8(p0.structureQuery.atomProperty.macromolecular.residueKey, (Z, J) => W0.residueIndex(J && J[0] && J[0](Z) || Z.element)),
  Y8(p0.structureQuery.atomProperty.macromolecular.chainKey, (Z, J) => W0.chainIndex(J && J[0] && J[0](Z) || Z.element)),
  Y8(p0.structureQuery.atomProperty.macromolecular.entityKey, (Z, J) => W0.entityIndex(J && J[0] && J[0](Z) || Z.element)),
  Y8(p0.structureQuery.atomProperty.macromolecular.id, z9(w1.atom.id)),
  Y8(p0.structureQuery.atomProperty.macromolecular.isHet, (Z, J) => w1.residue.group_PDB(J && J[0] && J[0](Z) || Z.element) !== "ATOM"),
  Y8(p0.structureQuery.atomProperty.macromolecular.label_atom_id, z9(w1.atom.label_atom_id)),
  Y8(p0.structureQuery.atomProperty.macromolecular.label_alt_id, z9(w1.atom.label_alt_id)),
  Y8(p0.structureQuery.atomProperty.macromolecular.label_comp_id, z9(w1.atom.label_comp_id)),
  Y8(p0.structureQuery.atomProperty.macromolecular.label_seq_id, z9(w1.residue.label_seq_id)),
  Y8(p0.structureQuery.atomProperty.macromolecular.label_asym_id, z9(w1.chain.label_asym_id)),
  Y8(p0.structureQuery.atomProperty.macromolecular.label_entity_id, z9(w1.entity.id)),
  Y8(p0.structureQuery.atomProperty.macromolecular.auth_atom_id, z9(w1.atom.auth_atom_id)),
  Y8(p0.structureQuery.atomProperty.macromolecular.auth_comp_id, z9(w1.atom.auth_comp_id)),
  Y8(p0.structureQuery.atomProperty.macromolecular.auth_seq_id, z9(w1.residue.auth_seq_id)),
  Y8(p0.structureQuery.atomProperty.macromolecular.auth_asym_id, z9(w1.chain.auth_asym_id)),
  Y8(p0.structureQuery.atomProperty.macromolecular.pdbx_PDB_ins_code, z9(w1.residue.pdbx_PDB_ins_code)),
  Y8(p0.structureQuery.atomProperty.macromolecular.pdbx_formal_charge, z9(w1.atom.pdbx_formal_charge)),
  Y8(p0.structureQuery.atomProperty.macromolecular.occupancy, z9(w1.atom.occupancy)),
  Y8(p0.structureQuery.atomProperty.macromolecular.B_iso_or_equiv, z9(w1.atom.B_iso_or_equiv)),
  Y8(p0.structureQuery.atomProperty.macromolecular.entityType, z9(w1.entity.type)),
  Y8(p0.structureQuery.atomProperty.macromolecular.entitySubtype, z9(w1.entity.subtype)),
  Y8(p0.structureQuery.atomProperty.macromolecular.entityPrdId, z9(w1.entity.prd_id)),
  Y8(p0.structureQuery.atomProperty.macromolecular.entityDescription, z9(w1.entity.pdbx_description)),
  Y8(p0.structureQuery.atomProperty.macromolecular.objectPrimitive, z9(w1.unit.object_primitive)),
  Y8(p0.structureQuery.atomProperty.macromolecular.isNonStandard, z9(w1.residue.isNonStandard)),
  Y8(p0.structureQuery.atomProperty.macromolecular.secondaryStructureKey, z9(w1.residue.secondary_structure_key)),
  Y8(p0.structureQuery.atomProperty.macromolecular.secondaryStructureFlags, z9(w1.residue.secondary_structure_type)),
  Y8(p0.structureQuery.atomProperty.macromolecular.chemCompType, z9(w1.residue.chem_comp_type)),
  Y8(p0.structureQuery.atomProperty.macromolecular.residueSourceIndex, z9(w1.residue.residueSourceIndex)),
  Y8(p0.structureQuery.atomProperty.ihm.hasSeqId, function Z(J, $) {
    let X = J.element, Y = $ && $[0] && $[0](J);
    if (X.unit.kind === j0.Kind.Atomic)
      return Y === w1.residue.label_seq_id(X);
    return Y >= w1.coarse.seq_id_begin(X) && Y <= w1.coarse.seq_id_end(X);
  }),
  Y8(p0.structureQuery.atomProperty.ihm.overlapsSeqIdRange, function Z(J, $) {
    var X, Y;
    let Q = J.element, W = (X = $ && $.beg && $.beg(J)) !== null && X !== void 0 ? X : -Number.MAX_VALUE, K = (Y = $ && $.end && $.end(J)) !== null && Y !== void 0 ? Y : Number.MAX_VALUE;
    if (Q.unit.kind === j0.Kind.Atomic) {
      let N = w1.residue.label_seq_id(Q);
      return N >= W && N <= K;
    }
    let G = w1.coarse.seq_id_begin(Q), H = w1.coarse.seq_id_end(Q);
    return G >= W && G <= K || H >= W && H <= K || G <= W && H >= K;
  }),
  Y8(p0.structureQuery.atomSet.atomCount, function Z(J, $) {
    return OZ.atomset.atomCount(J);
  }),
  Y8(p0.structureQuery.atomSet.countQuery, function Z(J, $) {
    return OZ.atomset.countQuery($[0])(J);
  }),
  Y8(p0.structureQuery.atomSet.propertySet, function Z(J, $) {
    return OZ.atomset.propertySet($[0])(J);
  }),
  Y8(p0.structureQuery.bondProperty.order, (Z, J) => Z.atomicBond.order),
  Y8(p0.structureQuery.bondProperty.flags, (Z, J) => Z.atomicBond.type),
  Y8(p0.structureQuery.bondProperty.key, (Z, J) => Z.atomicBond.key),
  Y8(p0.structureQuery.bondProperty.atomA, (Z, J) => Z.atomicBond.a),
  Y8(p0.structureQuery.bondProperty.atomB, (Z, J) => Z.atomicBond.b),
  Y8(p0.structureQuery.bondProperty.length, (Z, J) => Z.atomicBond.length),
  Y8(p0.internal.generator.bundleElement, function Z(J, $) {
    return yo($.groupedUnits(J), $.ranges(J), $.set(J));
  }),
  Y8(p0.internal.generator.bundle, function Z(J, $) {
    return go($.elements(J))(J);
  }),
  Y8(p0.internal.generator.current, function Z(J, $) {
    return J.tryGetCurrentSelection();
  })
];
function z9(Z) {
  return (J, $) => Z($ && $[0] && $[0](J) || J.element);
}
function lz0(Z, J) {
  return Z | (s1.isName(J) ? s1.fromName(J) : s1.Flag.None);
}
function nz0(Z, J) {
  switch (J.toLowerCase()) {
    case "helix":
      return Z | m2.Flag.Helix;
    case "alpha":
      return Z | m2.Flag.Helix | m2.Flag.HelixAlpha;
    case "pi":
      return Z | m2.Flag.Helix | m2.Flag.HelixPi;
    case "310":
      return Z | m2.Flag.Helix | m2.Flag.Helix3Ten;
    case "beta":
      return Z | m2.Flag.Beta;
    case "strand":
      return Z | m2.Flag.Beta | m2.Flag.BetaStrand;
    case "sheet":
      return Z | m2.Flag.Beta | m2.Flag.BetaSheet;
    case "turn":
      return Z | m2.Flag.Turn;
    case "bend":
      return Z | m2.Flag.Bend;
    case "coil":
      return Z | m2.Flag.NA;
    default:
      return Z;
  }
}
function t$1(Z, J) {
  let $ = [];
  if (!J)
    return $;
  if (typeof J.length === "number")
    for (let X = 0, Y = J.length;X < Y; X++)
      $.push(J[X](Z));
  else {
    let X = Object.keys(J);
    for (let Y = 1, Q = X.length;Y < Q; Y++)
      $.push(J[X[Y]](Z));
  }
  return $;
}
(function() {
  for (let Z of r$1)
    WA.addSymbol(Z);
})();

// node_modules/molstar/lib/mol-plugin-state/transforms/data.js
var Qr = {};
y9(Qr, {
  ReadFile: () => Yr,
  RawData: () => Xr,
  ParseTop: () => GY1,
  ParsePsf: () => WY1,
  ParsePrmtop: () => KY1,
  ParsePly: () => HY1,
  ParseJson: () => RY1,
  ParseDx: () => FY1,
  ParseDsn6: () => qY1,
  ParseCube: () => QY1,
  ParseCif: () => YY1,
  ParseCcp4: () => NY1,
  ParseBlob: () => XY1,
  LazyVolume: () => EY1,
  ImportString: () => UY1,
  ImportJson: () => LY1,
  DownloadBlob: () => $r,
  Download: () => Jr,
  DeflateData: () => $Y1
});

// node_modules/molstar/lib/mol-io/common/simple-buffer.js
var xW;
(function(Z) {
  function J(K) {
    let G = new DataView(K.buffer);
    return Object.assign(K.subarray(0), {
      readInt8: (H) => G.getInt8(H),
      readUInt8: (H) => G.getUint8(H),
      writeInt8: (H, N) => G.setInt8(N, H),
      writeUInt8: (H, N) => G.setUint8(N, H),
      readInt16LE: (H) => G.getInt16(H, !0),
      readInt32LE: (H) => G.getInt32(H, !0),
      readUInt16LE: (H) => G.getUint16(H, !0),
      readUInt32LE: (H) => G.getUint32(H, !0),
      readFloatLE: (H) => G.getFloat32(H, !0),
      readDoubleLE: (H) => G.getFloat64(H, !0),
      writeInt16LE: (H, N) => G.setInt16(N, H, !0),
      writeInt32LE: (H, N) => G.setInt32(N, H, !0),
      writeUInt16LE: (H, N) => G.setUint16(N, H, !0),
      writeUInt32LE: (H, N) => G.setUint32(N, H, !0),
      writeFloatLE: (H, N) => G.setFloat32(N, H, !0),
      writeDoubleLE: (H, N) => G.setFloat64(N, H, !0),
      readInt16BE: (H) => G.getInt16(H, !1),
      readInt32BE: (H) => G.getInt32(H, !1),
      readUInt16BE: (H) => G.getUint16(H, !1),
      readUInt32BE: (H) => G.getUint32(H, !1),
      readFloatBE: (H) => G.getFloat32(H, !1),
      readDoubleBE: (H) => G.getFloat64(H, !1),
      writeInt16BE: (H, N) => G.setInt16(N, H, !1),
      writeInt32BE: (H, N) => G.setInt32(N, H, !1),
      writeUInt16BE: (H, N) => G.setUint16(N, H, !1),
      writeUInt32BE: (H, N) => G.setUint32(N, H, !1),
      writeFloatBE: (H, N) => G.setFloat32(N, H, !1),
      writeDoubleBE: (H, N) => G.setFloat64(N, H, !1),
      copy: (H, N, q, U) => {
        return N = t7(N, 0), q = t7(q, 0), U = t7(U, K.length), H.set(K.subarray(q, U), N), U - q;
      }
    });
  }
  Z.fromUint8Array = J;
  function $(K) {
    return J(new Uint8Array(K));
  }
  Z.fromArrayBuffer = $;
  function X(K) {
    return K;
  }
  Z.fromBuffer = X, Z.IsNativeEndianLittle = new Uint16Array(new Uint8Array([18, 52]).buffer)[0] === 13330;
  function Y(K, G, H, N, q) {
    for (let U = 0, F = H;U < F; U += N)
      for (let E = 0;E < N; E++)
        G[q + U + N - E - 1] = K[q + U + E];
  }
  Z.flipByteOrder = Y;
  function Q(K, G = 0, H) {
    let N = new Int16Array(K, G, H);
    for (let q = 0, U = N.length;q < U; ++q) {
      let F = N[q];
      N[q] = (F & 255) << 8 | F >> 8 & 255;
    }
  }
  Z.flipByteOrderInPlace2 = Q;
  function W(K, G, H, N, q) {
    if (Z.IsNativeEndianLittle)
      return;
    if (!H || N <= 1)
      return;
    Y(K, G, H, N, q);
  }
  Z.ensureLittleEndian = W;
})(xW || (xW = {}));

// node_modules/molstar/lib/mol-io/common/file-handle.js
var AA;
(function(Z) {
  function J($, X) {
    return {
      name: X,
      readBuffer: (Y, Q, W, K) => {
        let G, H;
        if (typeof Q === "number") {
          W = t7(W, Q);
          let N = Y, q = Math.min($.length, N + W);
          G = q - N, H = xW.fromUint8Array(new Uint8Array($.buffer, N, q - N));
        } else {
          W = t7(W, Q.length);
          let N = Y, q = Math.min($.length, N + W);
          Q.set($.subarray(N, q), K), G = q - N, H = Q;
        }
        if (W !== G)
          console.warn(`byteCount ${W} and bytesRead ${G} differ`);
        return Promise.resolve({ bytesRead: G, buffer: H });
      },
      writeBuffer: (Y, Q, W) => {
        return W = t7(W, Q.length), console.error(".writeBuffer not implemented for FileHandle.fromBuffer"), Promise.resolve(0);
      },
      writeBufferSync: (Y, Q, W) => {
        return W = t7(W, Q.length), console.error(".writeSync not implemented for FileHandle.fromBuffer"), 0;
      },
      close: xX
    };
  }
  Z.fromBuffer = J;
})(AA || (AA = {}));

// node_modules/molstar/lib/mol-io/common/typed-array.js
var mX;
(function(Z) {
  Z.Float32 = "float32", Z.Int8 = "int8", Z.Int16 = "int16", Z.Uint16 = "uint16";
})(mX || (mX = {}));
function sa(Z) {
  if (Z === mX.Float32)
    return 4;
  if (Z === mX.Int16)
    return 2;
  if (Z === mX.Uint16)
    return 2;
  return 1;
}
function e$1(Z, J, $ = 0, X) {
  if (Z === mX.Float32)
    return new Float32Array(J, $, X);
  if (Z === mX.Int16)
    return new Int16Array(J, $, X);
  if (Z === mX.Uint16)
    return new Uint16Array(J, $, X);
  return new Int8Array(J, $, X);
}
function iz0(Z, J) {
  let $ = sa(J), X = new ArrayBuffer($ * Z), Y = xW.fromArrayBuffer(X), Q = xW.IsNativeEndianLittle ? X : new ArrayBuffer($ * Z);
  return {
    type: J,
    elementByteSize: $,
    readBuffer: Y,
    valuesBuffer: new Uint8Array(Q),
    values: e$1(J, Q)
  };
}
async function oz0(Z, J, $, X, Y, Q) {
  if (await J.readBuffer($, Z.readBuffer, X, Y), Z.elementByteSize > 1 && (Q !== void 0 && Q !== xW.IsNativeEndianLittle || !xW.IsNativeEndianLittle))
    xW.flipByteOrder(Z.readBuffer, Z.valuesBuffer, X, Z.elementByteSize, Y);
  return Z.values;
}

// node_modules/molstar/lib/mol-io/reader/ccp4/parser.js
async function ZX1(Z) {
  let { buffer: $ } = await Z.readBuffer(0, 1024), X = String.fromCharCode($.readUInt8(208), $.readUInt8(209), $.readUInt8(210), $.readUInt8(211));
  if (X !== "MAP ")
    throw new Error('ccp4 format error, missing "MAP " string');
  let Y = [$.readUInt8(212), $.readUInt8(213)], Q = !1;
  if (Y[0] === 68 && Y[1] === 65)
    Q = !0;
  else if (Y[0] === 17 && Y[1] === 17)
    Q = !1;
  else if ($.readInt32LE(12) <= 16)
    Q = !0;
  let W = Q ? (H) => $.readInt32LE(H * 4) : (H) => $.readInt32BE(H * 4), K = Q ? (H) => $.readFloatLE(H * 4) : (H) => $.readFloatBE(H * 4);
  return { header: {
    NC: W(0),
    NR: W(1),
    NS: W(2),
    MODE: W(3),
    NCSTART: W(4),
    NRSTART: W(5),
    NSSTART: W(6),
    NX: W(7),
    NY: W(8),
    NZ: W(9),
    xLength: K(10),
    yLength: K(11),
    zLength: K(12),
    alpha: K(13),
    beta: K(14),
    gamma: K(15),
    MAPC: W(16),
    MAPR: W(17),
    MAPS: W(18),
    AMIN: K(19),
    AMAX: K(20),
    AMEAN: K(21),
    ISPG: W(22),
    NSYMBT: W(23),
    LSKFLG: W(24),
    SKWMAT: [],
    SKWTRN: [],
    userFlag1: W(39),
    userFlag2: W(40),
    originX: K(49),
    originY: K(50),
    originZ: K(51),
    MAP: X,
    MACHST: Y,
    ARMS: K(54)
  }, littleEndian: Q };
}
async function JX1(Z, J, $, X, Y, Q) {
  if (az0(Z)) {
    let W = 3 * Y;
    await $.readBuffer(X, J.readBuffer, Y, W);
    let K = new Int8Array(J.valuesBuffer.buffer, W), G = (Z.AMAX - Z.AMIN) / 255, H = 0.5 * (Z.AMIN + Z.AMAX + G);
    for (let N = 0, q = Y;N < q; ++N)
      J.values[N] = G * K[N] + H;
  } else
    await oz0(J, $, X, Y, 0, Q);
}
function sz0(Z) {
  switch (Z) {
    case 0:
      return mX.Int8;
    case 1:
      return mX.Int16;
    case 2:
      return mX.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:
      mX.Uint16;
    case 16:
      throw new Error("mode 16 unsupported, unsigned char * 3 (for rgb data, non-standard)");
  }
  throw new Error(`unknown mode '${Z}'`);
}
function az0(Z) {
  return Z.userFlag1 === -128 && Z.userFlag2 === 127;
}
function aa(Z) {
  return az0(Z) ? mX.Float32 : sz0(Z.MODE);
}
function $X1(Z) {
  return 1024 + Z.NSYMBT;
}
async function XX1(Z, J, $) {
  await $.update({ message: "Parsing CCP4/MRC/MAP file..." });
  let { header: X, littleEndian: Y } = await ZX1(Z), Q = $X1(X), W = sz0(X.MODE), K = aa(X), G = X.NC * X.NR * X.NS, H = sa(W), N = G * H, q = iz0(G, K);
  return JX1(X, q, Z, Q, N, Y), { header: X, values: q.values, name: Z.name };
}
function YX1(Z, J) {
  return n0.create("Parse CCP4/MRC/MAP", async ($) => {
    try {
      return a8.success(await XX1(Z, J, $));
    } catch (X) {
      return a8.error(X);
    }
  });
}
function rz0(Z, J) {
  return YX1(AA.fromBuffer(xW.fromUint8Array(Z), J), Z.length);
}

// node_modules/molstar/lib/mol-io/reader/dsn6/parser.js
var ra = 512;
function WX1(Z) {
  return {
    xStart: parseInt(Z.substr(10, 5)),
    yStart: parseInt(Z.substr(15, 5)),
    zStart: parseInt(Z.substr(20, 5)),
    xExtent: parseInt(Z.substr(32, 5)),
    yExtent: parseInt(Z.substr(38, 5)),
    zExtent: parseInt(Z.substr(42, 5)),
    xRate: parseInt(Z.substr(52, 5)),
    yRate: parseInt(Z.substr(58, 5)),
    zRate: parseInt(Z.substr(62, 5)),
    xlen: parseFloat(Z.substr(73, 10)),
    ylen: parseFloat(Z.substr(83, 10)),
    zlen: parseFloat(Z.substr(93, 10)),
    alpha: parseFloat(Z.substr(103, 10)),
    beta: parseFloat(Z.substr(113, 10)),
    gamma: parseFloat(Z.substr(123, 10)),
    divisor: parseFloat(Z.substr(138, 12)),
    summand: parseInt(Z.substr(155, 8)),
    sigma: parseFloat(Z.substr(170, 12))
  };
}
function KX1(Z, J) {
  let $ = J ? (Y) => Z.readInt16LE(Y * 2) : (Y) => Z.readInt16BE(Y * 2), X = 1 / $(17);
  return {
    xStart: $(0),
    yStart: $(1),
    zStart: $(2),
    xExtent: $(3),
    yExtent: $(4),
    zExtent: $(5),
    xRate: $(6),
    yRate: $(7),
    zRate: $(8),
    xlen: $(9) * X,
    ylen: $(10) * X,
    zlen: $(11) * X,
    alpha: $(12) * X,
    beta: $(13) * X,
    gamma: $(14) * X,
    divisor: $(15) / 100,
    summand: $(16),
    sigma: void 0
  };
}
function tz0(Z) {
  let { xExtent: J, yExtent: $, zExtent: X } = Z, Y = Math.ceil(J / 8), Q = Math.ceil($ / 8), W = Math.ceil(X / 8);
  return { xBlocks: Y, yBlocks: Q, zBlocks: W };
}
async function GX1(Z) {
  let { buffer: J } = await Z.readBuffer(0, ra), $ = String.fromCharCode.apply(null, J), X = $.startsWith(":-)"), Y = X || J.readInt16LE(36) === 100;
  return { header: X ? WX1($) : KX1(J, Y), littleEndian: Y };
}
async function HX1(Z, J, $, X) {
  if (!X)
    xW.flipByteOrderInPlace2(J.buffer);
  let { divisor: Y, summand: Q, xExtent: W, yExtent: K, zExtent: G } = Z, { xBlocks: H, yBlocks: N, zBlocks: q } = tz0(Z), U = 0;
  for (let F = 0;F < q; ++F)
    for (let E = 0;E < N; ++E)
      for (let R = 0;R < H; ++R)
        for (let z = 0;z < 8; ++z) {
          let D = 8 * F + z;
          for (let A = 0;A < 8; ++A) {
            let B = 8 * E + A;
            for (let T = 0;T < 8; ++T) {
              let w = 8 * R + T;
              if (w < W && B < K && D < G) {
                let V = (w * K + B) * G + D;
                $[V] = (J[U] - Q) / Y, ++U;
              } else {
                U += 8 - T;
                break;
              }
            }
          }
        }
}
function NX1(Z) {
  let { xExtent: J, yExtent: $, zExtent: X } = Z, { xBlocks: Y, yBlocks: Q, zBlocks: W } = tz0(Z), K = J * $ * X, G = Y * 8 * Q * 8 * W * 8, H = 1, N = G * 1;
  return { count: G, byteCount: N, valueCount: K };
}
async function qX1(Z, J, $) {
  await $.update({ message: "Parsing DSN6/BRIX file..." });
  let { header: X, littleEndian: Y } = await GX1(Z), { buffer: Q } = await Z.readBuffer(ra, J - ra), { valueCount: W } = NX1(X), K = new Float32Array(W);
  return await HX1(X, Q, K, Y), { header: X, values: K, name: Z.name };
}
function FX1(Z, J) {
  return n0.create("Parse DSN6/BRIX", async ($) => {
    try {
      return a8.success(await qX1(Z, J, $));
    } catch (X) {
      return a8.error(X);
    }
  });
}
function ez0(Z, J) {
  return FX1(AA.fromBuffer(xW.fromUint8Array(Z), J), Z.length);
}

// node_modules/molstar/lib/mol-io/reader/ply/schema.js
var LX1 = {
  char: 1,
  uchar: 1,
  short: 2,
  ushort: 2,
  int: 4,
  uint: 4,
  float: 4,
  double: 8,
  int8: 1,
  uint8: 1,
  int16: 2,
  uint16: 2,
  int32: 4,
  uint32: 4,
  float32: 4,
  float64: 8
}, RX1 = new Set(Object.keys(LX1));
function Lb(Z) {
  if (!RX1.has(Z))
    throw new Error(`unknown ply type '${Z}'`);
  return Z;
}
function Z40(Z, J, $) {
  let X = /* @__PURE__ */ new Map;
  for (let Y = 0, Q = J.length;Y < Q; ++Y)
    X.set(J[Y], Z[Y]);
  return {
    comments: $,
    elementNames: J,
    getElement: (Y) => {
      return X.get(Y);
    }
  };
}

// node_modules/molstar/lib/mol-io/reader/ply/parser.js
function EX1(Z, J) {
  let $ = Z2(Z);
  return {
    data: Z,
    tokenizer: $,
    runtimeCtx: J,
    comments: [],
    elementSpecs: [],
    elements: []
  };
}
function OX1(Z) {
  let J = Z.data.indexOf("end_header", Z.position);
  if (J === -1)
    throw new Error("no 'end_header' record found");
  Z.tokenStart = Z.position, Z.tokenEnd = J, Z.position = J, Z2.eatLine(Z);
}
function zX1(Z) {
  let { tokenizer: J, comments: $, elementSpecs: X } = Z;
  OX1(J);
  let Y = Z2.getTokenString(J).split(/\r?\n/);
  if (Y[0] !== "ply")
    throw new Error("data not starting with 'ply'");
  if (Y[1] !== "format ascii 1.0")
    throw new Error("format not 'ascii 1.0'");
  let Q, W, K;
  function G() {
    if (Q !== void 0 && W !== void 0 && K !== void 0) {
      let H = !1;
      for (let N = 0, q = K.length;N < q; ++N)
        if (K[N].kind === "list") {
          H = !0;
          break;
        }
      if (H && K.length !== 1)
        ;
      if (H)
        X.push({
          kind: "list",
          name: Q,
          count: W,
          property: K[0]
        });
      else
        X.push({
          kind: "table",
          name: Q,
          count: W,
          properties: K
        });
    }
  }
  for (let H = 2, N = Y.length;H < N; ++H) {
    let q = Y[H], U = q.split(" ");
    if (q.startsWith("comment"))
      $.push(q.substr(8));
    else if (q.startsWith("element"))
      G(), K = [], Q = U[1], W = parseInt(U[2]);
    else if (q.startsWith("property")) {
      if (K === void 0)
        throw new Error("properties outside of element");
      if (U[1] === "list")
        K.push({
          kind: "list",
          countType: Lb(U[2]),
          dataType: Lb(U[3]),
          name: U[4]
        });
      else
        K.push({
          kind: "column",
          type: Lb(U[1]),
          name: U[2]
        });
    } else if (q.startsWith("end_header"))
      G();
    else
      console.warn("unknown header line");
  }
}
function DX1(Z) {
  let { elementSpecs: J } = Z;
  for (let $ = 0, X = J.length;$ < X; ++$) {
    let Y = J[$];
    if (Y.kind === "table")
      MX1(Z, Y);
    else if (Y.kind === "list")
      AX1(Z, Y);
  }
}
function J40(Z) {
  switch (Z) {
    case "char":
    case "uchar":
    case "int8":
    case "uint8":
    case "short":
    case "ushort":
    case "int16":
    case "uint16":
    case "int":
    case "uint":
    case "int32":
    case "uint32":
      return s.Schema.int;
    case "float":
    case "double":
    case "float32":
    case "float64":
      return s.Schema.float;
  }
}
function MX1(Z, J) {
  let { elements: $, tokenizer: X } = Z, { count: Y, properties: Q } = J, W = Q.length, K = [], G = [], H = [], N = /* @__PURE__ */ new Map;
  for (let q = 0, U = W;q < U; ++q) {
    let F = G1.create(X.data, Y * 2);
    H.push(F);
  }
  for (let q = 0, U = Y;q < U; ++q)
    for (let F = 0, E = W;F < E; ++F)
      Z2.skipWhitespace(X), Z2.markStart(X), Z2.eatValue(X), G1.addUnchecked(H[F], X.tokenStart, X.tokenEnd);
  for (let q = 0, U = W;q < U; ++q) {
    let { type: F, name: E } = Q[q], R = ff(H[q], J40(F));
    K.push(E), G.push(F), N.set(E, R);
  }
  $.push({
    kind: "table",
    rowCount: Y,
    propertyNames: K,
    propertyTypes: G,
    getProperty: (q) => N.get(q)
  });
}
function AX1(Z, J) {
  let { elements: $, tokenizer: X } = Z, { count: Y, property: Q } = J, W = G1.create(X.data, Y * 2 * 3), K = new Uint32Array(Y + 1), G = 0;
  for (let q = 0, U = Y;q < U; ++q) {
    Z2.skipWhitespace(X), Z2.markStart(X);
    while (Z2.skipWhitespace(X) !== 10)
      ++G, Z2.markStart(X), Z2.eatValue(X), G1.addToken(W, X);
    K[q + 1] = G;
  }
  let H = {
    entries: [],
    count: 0
  }, N = ff(W, J40(Q.dataType));
  $.push({
    kind: "list",
    rowCount: Y,
    name: Q.name,
    type: Q.dataType,
    value: (q) => {
      let U = K[q] + 1, F = N.value(U - 1);
      for (let E = U, R = U + F;E < R; ++E)
        H.entries[E - U] = N.value(E);
      return H.count = F, H;
    }
  });
}
async function BX1(Z, J) {
  let $ = EX1(Z, J);
  J.update({ message: "Parsing...", current: 0, max: Z.length }), zX1($), DX1($);
  let { elements: X, elementSpecs: Y, comments: Q } = $, W = Y.map((G) => G.name), K = Z40(X, W, Q);
  return a8.success(K);
}
function $40(Z) {
  return n0.create("Parse PLY", async (J) => {
    return await BX1(Z, J);
  });
}

// node_modules/molstar/lib/mol-io/reader/psf/parser.js
var { readLine: Eb, skipWhitespace: X40, eatValue: Y40, eatLine: jX1, markStart: ta } = Z2, Rb = /\s+/, TX1 = /(^\*|REMARK)*/;
function _X1(Z, J) {
  return {
    tokenizer: Z,
    runtimeCtx: J
  };
}
async function VX1(Z, J) {
  let { tokenizer: $ } = Z, X = G1.create($.data, J * 2), Y = G1.create($.data, J * 2), Q = G1.create($.data, J * 2), W = G1.create($.data, J * 2), K = G1.create($.data, J * 2), G = G1.create($.data, J * 2), H = G1.create($.data, J * 2), N = G1.create($.data, J * 2), { position: q } = $, U = Eb($).trim();
  $.position = q;
  let F = U.split(Rb).length === 7, E = F ? 6 : 8, { length: R } = $, z = 0;
  return await K$(Z.runtimeCtx, 1e5, void 0, (D) => {
    let A = Math.min(J - z, D);
    for (let B = 0;B < A; ++B) {
      for (let T = 0;T < E; ++T)
        if (X40($), ta($), Y40($), F)
          switch (T) {
            case 0:
              G1.addUnchecked(X, $.tokenStart, $.tokenEnd);
              break;
            case 1:
              G1.addUnchecked(Q, $.tokenStart, $.tokenEnd);
              break;
            case 2:
              G1.addUnchecked(K, $.tokenStart, $.tokenEnd);
              break;
            case 3:
              G1.addUnchecked(G, $.tokenStart, $.tokenEnd);
              break;
            case 4:
              G1.addUnchecked(H, $.tokenStart, $.tokenEnd);
              break;
            case 5:
              G1.addUnchecked(N, $.tokenStart, $.tokenEnd);
              break;
          }
        else
          switch (T) {
            case 0:
              G1.addUnchecked(X, $.tokenStart, $.tokenEnd);
              break;
            case 1:
              G1.addUnchecked(Y, $.tokenStart, $.tokenEnd);
              break;
            case 2:
              G1.addUnchecked(Q, $.tokenStart, $.tokenEnd);
              break;
            case 3:
              G1.addUnchecked(W, $.tokenStart, $.tokenEnd);
              break;
            case 4:
              G1.addUnchecked(K, $.tokenStart, $.tokenEnd);
              break;
            case 5:
              G1.addUnchecked(G, $.tokenStart, $.tokenEnd);
              break;
            case 6:
              G1.addUnchecked(H, $.tokenStart, $.tokenEnd);
              break;
            case 7:
              G1.addUnchecked(N, $.tokenStart, $.tokenEnd);
              break;
          }
      jX1($), ta($);
    }
    return z += A, A;
  }, (D) => D.update({ message: "Parsing...", current: $.position, max: R })), {
    count: J,
    atomId: I2(X)(s.Schema.int),
    segmentName: F ? I2(Q)(s.Schema.str) : I2(Y)(s.Schema.str),
    residueId: I2(Q)(s.Schema.int),
    residueName: F ? I2(Q)(s.Schema.str) : I2(W)(s.Schema.str),
    atomName: I2(K)(s.Schema.str),
    atomType: I2(G)(s.Schema.str),
    charge: I2(H)(s.Schema.float),
    mass: I2(N)(s.Schema.float)
  };
}
async function IX1(Z, J) {
  let { tokenizer: $ } = Z, X = G1.create($.data, J * 2), Y = G1.create($.data, J * 2), { length: Q } = $, W = 0;
  return await K$(Z.runtimeCtx, 10, void 0, (K) => {
    let G = Math.min(J - W, K);
    for (let H = 0;H < G; ++H)
      for (let N = 0;N < 2; ++N)
        switch (X40($), ta($), Y40($), N) {
          case 0:
            G1.addUnchecked(X, $.tokenStart, $.tokenEnd);
            break;
          case 1:
            G1.addUnchecked(Y, $.tokenStart, $.tokenEnd);
            break;
        }
    return W += G, G;
  }, (K) => K.update({ message: "Parsing...", current: $.position, max: Q })), {
    count: J,
    atomIdA: I2(X)(s.Schema.int),
    atomIdB: I2(Y)(s.Schema.int)
  };
}
function PX1(Z, J) {
  let $ = [];
  for (let X = 0;X < J; ++X) {
    let Y = Eb(Z.tokenizer);
    $.push(Y.replace(TX1, "").trim());
  }
  return $;
}
async function CX1(Z, J) {
  let $ = Z2(Z), X = _X1($, J), Y = void 0, Q = void 0, W = void 0, K = Eb(X.tokenizer).trim();
  while ($.tokenEnd < $.length) {
    let H = Eb(X.tokenizer).trim();
    if (H.includes("!NTITLE")) {
      let N = parseInt(H.split(Rb)[0]);
      Y = PX1(X, N);
    } else if (H.includes("!NATOM")) {
      let N = parseInt(H.split(Rb)[0]);
      Q = await VX1(X, N);
    } else if (H.includes("!NBOND")) {
      let N = parseInt(H.split(Rb)[0]);
      W = await IX1(X, N);
      break;
    } else if (H.includes("!NTHETA"))
      ;
    else if (H.includes("!NPHI"))
      ;
    else if (H.includes("!NIMPHI"))
      ;
    else if (H.includes("!NDON"))
      ;
    else if (H.includes("!NACC"))
      ;
    else if (H.includes("!NNB"))
      ;
    else if (H.includes("!NGRP NST2"))
      ;
    else if (H.includes("!MOLNT"))
      ;
    else if (H.includes("!NUMLP NUMLPH"))
      ;
    else if (H.includes("!NCRTERM"))
      ;
  }
  if (Y === void 0)
    Y = [];
  if (Q === void 0)
    return a8.error("no atoms data");
  if (W === void 0)
    return a8.error("no bonds data");
  let G = {
    id: K,
    title: Y,
    atoms: Q,
    bonds: W
  };
  return a8.success(G);
}
function Q40(Z) {
  return n0.create("Parse PSF", async (J) => {
    return await CX1(Z, J);
  });
}

// node_modules/molstar/lib/mol-io/reader/cube/parser.js
var W40 = 0.529177210859;
function kX1(Z) {
  let J = Z2.readLines(Z, 6), $ = (A, B) => {
    let T = +J[A].trim().split(/\s+/g)[B];
    return Number.isNaN(T) ? 0 : T;
  }, X = (A) => {
    let B = $(A + 2, 0), T = W40;
    return [Math.abs(B), M.create($(A + 2, 1) * T, $(A + 2, 2) * T, $(A + 2, 3) * T), B];
  }, Y = J[0].trim(), Q = J[1].trim(), [W, K, G] = X(0), [H, N] = X(1), [q, U] = X(2), [F, E] = X(3), R = vX1(Z, W, W40), z = [];
  if (G >= 0) {
    let A = $(2, 4);
    if (A === 0)
      A = 1;
    for (let B = 0;B < A; B++)
      z.push(B);
  } else {
    let A = Z2.readLine(Z).trim().split(/\s+/g);
    for (let B = 0, T = +A[0];B < T; B++)
      z.push(+A[B + 1]);
  }
  return { header: { orbitals: G < 0, comment1: Y, comment2: Q, atomCount: W, origin: K, dim: M.create(H, q, F), basisX: N, basisY: U, basisZ: E, dataSetIds: z }, atoms: R };
}
function vX1(Z, J, $) {
  let X = new Int32Array(J), Y = new Float64Array(J), Q = new Float32Array(J), W = new Float32Array(J), K = new Float32Array(J);
  for (let G = 0;G < J; G++) {
    let H = Z2.readLine(Z).trim().split(/\s+/g);
    X[G] = +H[0], Y[G] = +H[1], Q[G] = +H[2] * $, W[G] = +H[3] * $, K[G] = +H[4] * $;
  }
  return {
    count: J,
    number: s.ofArray({ array: X, schema: s.Schema.int }),
    nuclearCharge: s.ofArray({ array: Y, schema: s.Schema.float }),
    x: s.ofArray({ array: Q, schema: s.Schema.float }),
    y: s.ofArray({ array: W, schema: s.Schema.float }),
    z: s.ofArray({ array: K, schema: s.Schema.float })
  };
}
function SX1(Z, J, $) {
  let X = $.dim[0] * $.dim[1] * $.dim[2] * $.dataSetIds.length, Y = 1e6, Q = new Float64Array(X), W = 0;
  return K$(Z, 1e6, Q, (K, G) => {
    let H = Math.min(X, W + K);
    for (let N = W;N < H; N++)
      Z2.skipWhitespace(J), J.tokenStart = J.position, Z2.eatValue(J), G[N] = _W(J.data, J.tokenStart, J.tokenEnd);
    return W = H, H === X ? 0 : 1e6;
  }, (K, G, H) => K.update({ current: Math.min(H, X), max: X }));
}
function K40(Z, J) {
  return n0.create("Parse Cube", async ($) => {
    await $.update("Reading header...");
    let X = Z2(Z), { header: Y, atoms: Q } = kX1(X), W = await SX1($, X, Y);
    return a8.success({ header: Y, atoms: Q, values: W, name: J });
  });
}

// node_modules/molstar/lib/mol-io/reader/dx/parser.js
function G40(Z) {
  let J = { h: M() }, $ = 0, X = 0, Y = /\s+/g;
  while (!0) {
    let Q = Z2.readLine(Z), W;
    if (Q.startsWith("object 1"))
      W = Q.split(Y), J.dim = M.create(parseInt(W[5]), parseInt(W[6]), parseInt(W[7]));
    else if (Q.startsWith("origin"))
      W = Q.split(Y), J.min = M.create(parseFloat(W[1]), parseFloat(W[2]), parseFloat(W[3]));
    else if (Q.startsWith("delta")) {
      if (W = Q.split(Y), X === 0)
        J.h[0] = parseFloat(W[1]);
      else if (X === 1)
        J.h[1] = parseFloat(W[2]);
      else if (X === 2)
        J.h[2] = parseFloat(W[3]);
      X += 1;
    } else if (Q.startsWith("object 3")) {
      $ += Q.length + 1;
      break;
    }
    $ += Q.length + 1;
  }
  return { header: J, headerByteCount: $ };
}
function fX1(Z, J, $) {
  let X = $.dim[0] * $.dim[1] * $.dim[2], Y = 1e6, Q = new Float64Array(X), W = 0;
  return K$(Z, 1e6, Q, (K, G) => {
    let H = Math.min(X, W + K);
    for (let N = W;N < H; N++)
      Z2.skipWhitespace(J), J.tokenStart = J.position, Z2.eatValue(J), G[N] = _W(J.data, J.tokenStart, J.tokenEnd);
    return W = H, H === X ? 0 : 1e6;
  }, (K, G, H) => K.update({ current: Math.min(H, X), max: X }));
}
async function hX1(Z, J, $) {
  await Z.update("Reading header...");
  let X = Z2(J), { header: Y } = G40(X);
  await Z.update("Reading values...");
  let Q = await fX1(Z, X, Y);
  return a8.success({ header: Y, values: Q, name: $ });
}
async function bX1(Z, J, $) {
  await Z.update("Reading header...");
  let X = IN(J, 0, 1000), Y = Z2(X), { header: Q, headerByteCount: W } = G40(Y);
  await Z.update("Reading values...");
  let K = Q.dim[0] * Q.dim[1] * Q.dim[2], G = new DataView(J.buffer, J.byteOffset + W), H = new Float64Array(K);
  for (let N = 0;N < K; N++)
    H[N] = G.getFloat64(N * 8, !0);
  return a8.success({ header: Q, values: H, name: $ });
}
function H40(Z, J) {
  return n0.create("Parse DX", ($) => {
    if (oL.is(Z))
      return hX1($, Z, J);
    return bX1($, Z, J);
  });
}

// node_modules/molstar/lib/mol-io/reader/prmtop/parser.js
var xX1 = {
  NATOM: "",
  NTYPES: "",
  NBONH: "",
  MBONA: "",
  NTHETH: "",
  MTHETA: "",
  NPHIH: "",
  MPHIA: "",
  NHPARM: "",
  NPARM: "",
  NNB: "",
  NRES: "",
  NBONA: "",
  NTHETA: "",
  NPHIA: "",
  NUMBND: "",
  NUMANG: "",
  NPTRA: "",
  NATYP: "",
  NPHB: "",
  IFPERT: "",
  NBPER: "",
  NGPER: "",
  NDPER: "",
  MBPER: "",
  MGPER: "",
  MDPER: "",
  IFBOX: "",
  NMXRS: "",
  IFCAP: "",
  NUMEXTRA: "",
  NCOPY: ""
}, N40 = Object.keys(xX1), { readLine: OV, markLine: q40, trim: yX1 } = Z2;
function gX1(Z, J) {
  return {
    tokenizer: Z,
    runtimeCtx: J
  };
}
function mX1(Z) {
  let { tokenizer: J } = Z, $ = [];
  while (J.tokenEnd < J.length) {
    if (J.data.charAt(J.position) === "%")
      break;
    let X = OV(J).trim();
    if (X)
      $.push(X);
  }
  return $;
}
function dX1(Z) {
  let { tokenizer: J } = Z, $ = Object.create(null);
  N40.forEach((Y) => {
    $[Y] = 0;
  });
  let X = 0;
  while (J.tokenEnd < J.length) {
    if (J.data.charAt(J.position) === "%")
      break;
    let Y = OV(J), Q = Math.min(X + 10, 32);
    for (let W = 0;X < Q; ++W, ++X)
      $[N40[X]] = parseInt(Y.substring(W * 8, W * 8 + 8).trim());
  }
  return $;
}
function fR(Z, J, $, X) {
  let { tokenizer: Y } = Z, Q = G1.create(Y.data, J * 2), W = 0;
  while (Y.tokenEnd < Y.length) {
    if (Y.data.charAt(Y.position) === "%")
      break;
    Y.tokenStart = Y.position;
    let K = Math.min(W + $, J);
    for (let G = 0;W < K; ++G, ++W) {
      let H = Y.position;
      yX1(Y, Y.position, Y.position + X), G1.addUnchecked(Q, Y.tokenStart, Y.tokenEnd), Y.position = H + X;
    }
    q40(Y);
  }
  return Q;
}
async function pX1(Z, J) {
  let $ = Z2(Z), X = gX1($, J), Y = Object.create(null), Q = 0;
  while ($.tokenEnd < $.length) {
    if ($.position - Q > 1e5 && J.shouldUpdate)
      Q = $.position, await J.update({ current: $.position, max: $.length });
    let W = OV(X.tokenizer).trim();
    if (W.startsWith("%VERSION"))
      Y.version = W.substring(8).trim();
    else if (W.startsWith("%FLAG")) {
      let K = W.substring(5).trim(), G = OV(X.tokenizer).trim();
      while (G.startsWith("%COMMENT"))
        G = OV(X.tokenizer).trim();
      if (!G.startsWith("%FORMAT"))
        throw new Error(`expected %FORMAT got "${G}"`);
      if (K === "TITLE" || K === "CTITLE")
        Y.title = mX1(X);
      else if (K === "POINTERS")
        Y.pointers = dX1(X);
      else if (K === "ATOM_NAME") {
        let H = fR(X, Y.pointers.NATOM, 20, 4);
        Y.atomName = I2(H)(s.Schema.str);
      } else if (K === "CHARGE") {
        let H = fR(X, Y.pointers.NATOM, 5, 16);
        Y.charge = I2(H)(s.Schema.float);
      } else if (K === "MASS") {
        let H = fR(X, Y.pointers.NATOM, 5, 16);
        Y.mass = I2(H)(s.Schema.float);
      } else if (K === "RESIDUE_LABEL") {
        let H = fR(X, Y.pointers.NRES, 20, 4);
        Y.residueLabel = I2(H)(s.Schema.str);
      } else if (K === "RESIDUE_POINTER") {
        let H = fR(X, Y.pointers.NRES, 10, 8);
        Y.residuePointer = I2(H)(s.Schema.int);
      } else if (K === "BONDS_INC_HYDROGEN") {
        let H = fR(X, Y.pointers.NBONH * 3, 10, 8);
        Y.bondsIncHydrogen = I2(H)(s.Schema.int);
      } else if (K === "BONDS_WITHOUT_HYDROGEN") {
        let H = fR(X, Y.pointers.NBONA * 3, 10, 8);
        Y.bondsWithoutHydrogen = I2(H)(s.Schema.int);
      } else if (K === "RADII") {
        let H = fR(X, Y.pointers.NATOM, 5, 16);
        Y.radii = I2(H)(s.Schema.float);
      } else
        while ($.tokenEnd < $.length) {
          if ($.data.charAt($.position) === "%")
            break;
          q40($);
        }
    }
  }
  return a8.success(Y);
}
function F40(Z) {
  return n0.create("Parse PRMTOP", async (J) => {
    return await pX1(Z, J);
  });
}

// node_modules/molstar/lib/mol-io/reader/top/parser.js
var uX1 = {
  nr: s.Schema.Int(),
  type: s.Schema.Str(),
  resnr: s.Schema.Int(),
  residu: s.Schema.Str(),
  atom: s.Schema.Str(),
  cgnr: s.Schema.Int(),
  charge: s.Schema.Float(),
  mass: s.Schema.Float()
}, cX1 = {
  ai: s.Schema.Int(),
  aj: s.Schema.Int()
}, lX1 = {
  compound: s.Schema.Str(),
  molCount: s.Schema.Int()
}, { readLine: ea, markLine: hR, skipWhitespace: bR, markStart: Ob, eatValue: Zr, eatLine: nX1 } = Z2;
function iX1(Z, J) {
  return {
    tokenizer: Z,
    runtimeCtx: J
  };
}
var oX1 = /\[ (.+) \]/, sX1 = /\s+/;
function aX1(Z) {
  let { tokenizer: J } = Z, $ = void 0;
  while (J.tokenEnd < J.length) {
    bR(J);
    let X = J.data.charAt(J.position);
    if (X === "[")
      break;
    if (X === ";" || X === "*") {
      hR(J);
      continue;
    }
    if ($ !== void 0)
      throw new Error("more than one molName");
    $ = ea(J).split(sX1)[0];
  }
  if ($ === void 0)
    throw new Error("missing molName");
  return $;
}
function rX1(Z) {
  let { tokenizer: J } = Z, $ = G1.create(J.data, 64), X = G1.create(J.data, 64), Y = G1.create(J.data, 64), Q = G1.create(J.data, 64), W = G1.create(J.data, 64), K = G1.create(J.data, 64), G = G1.create(J.data, 64), H = G1.create(J.data, 64);
  while (J.tokenEnd < J.length) {
    bR(J);
    let N = J.data.charAt(J.position);
    if (N === "[")
      break;
    if (N === ";" || N === "*") {
      hR(J);
      continue;
    }
    for (let q = 0;q < 8; ++q)
      switch (bR(J), Ob(J), Zr(J), q) {
        case 0:
          G1.add($, J.tokenStart, J.tokenEnd);
          break;
        case 1:
          G1.add(X, J.tokenStart, J.tokenEnd);
          break;
        case 2:
          G1.add(Y, J.tokenStart, J.tokenEnd);
          break;
        case 3:
          G1.add(Q, J.tokenStart, J.tokenEnd);
          break;
        case 4:
          G1.add(W, J.tokenStart, J.tokenEnd);
          break;
        case 5:
          G1.add(K, J.tokenStart, J.tokenEnd);
          break;
        case 6:
          G1.add(G, J.tokenStart, J.tokenEnd);
          break;
        case 7:
          G1.add(H, J.tokenStart, J.tokenEnd);
          break;
      }
    hR(J);
  }
  return A8.ofColumns(uX1, {
    nr: I2($)(s.Schema.int),
    type: I2(X)(s.Schema.str),
    resnr: I2(Y)(s.Schema.int),
    residu: I2(Q)(s.Schema.str),
    atom: I2(W)(s.Schema.str),
    cgnr: I2(K)(s.Schema.int),
    charge: I2(G)(s.Schema.float),
    mass: I2(H)(s.Schema.float)
  });
}
function tX1(Z) {
  let { tokenizer: J } = Z, $ = G1.create(J.data, 64), X = G1.create(J.data, 64);
  while (J.tokenEnd < J.length) {
    bR(J);
    let Y = J.data.charAt(J.position);
    if (Y === "[")
      break;
    if (Y === ";" || Y === "*") {
      hR(J);
      continue;
    }
    for (let Q = 0;Q < 2; ++Q)
      switch (bR(J), Ob(J), Zr(J), Q) {
        case 0:
          G1.add($, J.tokenStart, J.tokenEnd);
          break;
        case 1:
          G1.add(X, J.tokenStart, J.tokenEnd);
          break;
      }
    hR(J);
  }
  return A8.ofColumns(cX1, {
    ai: I2($)(s.Schema.int),
    aj: I2(X)(s.Schema.int)
  });
}
function eX1(Z) {
  let { tokenizer: J } = Z, $ = void 0;
  while (J.tokenEnd < J.length) {
    bR(J);
    let X = J.data.charAt(J.position);
    if (X === "[")
      break;
    if (X === ";" || X === "*") {
      hR(J);
      continue;
    }
    if ($ !== void 0)
      throw new Error("more than one system");
    $ = ea(J).trim();
  }
  if ($ === void 0)
    throw new Error("missing system");
  return $;
}
function ZY1(Z) {
  let { tokenizer: J } = Z, $ = G1.create(J.data, 64), X = G1.create(J.data, 64);
  while (J.tokenEnd < J.length) {
    if (bR(J), J.position >= J.length)
      break;
    let Y = J.data.charAt(J.position);
    if (Y === "[")
      break;
    if (Y === ";" || Y === "*") {
      hR(J);
      continue;
    }
    for (let Q = 0;Q < 2; ++Q)
      switch (bR(J), Ob(J), Zr(J), Q) {
        case 0:
          G1.add($, J.tokenStart, J.tokenEnd);
          break;
        case 1:
          G1.add(X, J.tokenStart, J.tokenEnd);
          break;
      }
    nX1(J), Ob(J);
  }
  return A8.ofColumns(lX1, {
    compound: I2($)(s.Schema.str),
    molCount: I2(X)(s.Schema.int)
  });
}
async function JY1(Z, J) {
  let $ = Z2(Z), X = iX1($, J), Y = Object.create(null), Q = 0;
  Y.compounds = {};
  let W = {}, K = "";
  function G() {
    if (K && W.atoms)
      Y.compounds[K] = W, W = {}, K = "";
  }
  while ($.tokenEnd < $.length) {
    if ($.position - Q > 1e5 && J.shouldUpdate)
      Q = $.position, await J.update({ current: $.position, max: $.length });
    let H = ea(X.tokenizer).trim();
    if (!H || H[0] === "*" || H[0] === ";")
      continue;
    if (H.startsWith("#include"))
      throw new Error("#include statements not allowed");
    if (H.startsWith("[")) {
      let N = H.match(oX1);
      if (N === null)
        throw new Error("expected field name");
      let q = N[1];
      if (q === "moleculetype")
        G(), K = aX1(X);
      else if (q === "atoms")
        W.atoms = rX1(X);
      else if (q === "bonds")
        W.bonds = tX1(X);
      else if (q === "system")
        Y.system = eX1(X);
      else if (q === "molecules")
        G(), Y.molecules = ZY1(X);
      else
        while ($.tokenEnd < $.length) {
          if ($.data.charAt($.position) === "[")
            break;
          hR($);
        }
    }
  }
  return a8.success(Y);
}
function U40(Z) {
  return n0.create("Parse TOP", async (J) => {
    return await JY1(Z, J);
  });
}

// node_modules/molstar/lib/mol-plugin-state/transforms/data.js
var Jr = B2.BuiltIn({
  name: "download",
  display: { name: "Download", description: "Download string or binary data from the specified URL" },
  from: [D0.Root],
  to: [D0.Data.String, D0.Data.Binary],
  params: {
    url: j.Url("https://www.ebi.ac.uk/pdbe/static/entry/1cbs_updated.cif", { description: "Resource URL. Must be the same domain or support CORS." }),
    label: j.Optional(j.Text("")),
    isBinary: j.Optional(j.Boolean(!1, { description: "If true, download data as binary (string otherwise)" }))
  }
})({
  apply({ params: Z, cache: J }, $) {
    return n0.create("Download", async (X) => {
      let Y = E6.getUrlAsset($.managers.asset, Z.url), Q = await $.managers.asset.resolve(Y, Z.isBinary ? "binary" : "string").runInContext(X);
      return J.asset = Q, Z.isBinary ? new D0.Data.Binary(Q.data, { label: Z.label ? Z.label : Y.url }) : new D0.Data.String(Q.data, { label: Z.label ? Z.label : Y.url });
    });
  },
  dispose({ cache: Z }) {
    var J;
    (J = Z === null || Z === void 0 ? void 0 : Z.asset) === null || J === void 0 || J.dispose();
  },
  update({ oldParams: Z, newParams: J, b: $ }) {
    if (Z.url !== J.url || Z.isBinary !== J.isBinary)
      return T1.UpdateResult.Recreate;
    if (Z.label !== J.label)
      return $.label = J.label || (typeof J.url === "string" ? J.url : J.url.url), T1.UpdateResult.Updated;
    return T1.UpdateResult.Unchanged;
  }
}), $r = B2.BuiltIn({
  name: "download-blob",
  display: { name: "Download Blob", description: "Download multiple string or binary data from the specified URLs." },
  from: D0.Root,
  to: D0.Data.Blob,
  params: {
    sources: j.ObjectList({
      id: j.Text("", { label: "Unique ID" }),
      url: j.Url("https://www.ebi.ac.uk/pdbe/static/entry/1cbs_updated.cif", { description: "Resource URL. Must be the same domain or support CORS." }),
      isBinary: j.Optional(j.Boolean(!1, { description: "If true, download data as binary (string otherwise)" })),
      canFail: j.Optional(j.Boolean(!1, { description: "Indicate whether the download can fail and not be included in the blob as a result." }))
    }, (Z) => `${Z.id}: ${Z.url}`),
    maxConcurrency: j.Optional(j.Numeric(4, { min: 1, max: 12, step: 1 }, { description: "The maximum number of concurrent downloads." }))
  }
})({
  apply({ params: Z, cache: J }, $) {
    return n0.create("Download Blob", async (X) => {
      let Y = [], Q = await vK0(X, $.managers.asset, Z.sources, Z.maxConcurrency || 4), W = [];
      for (let K = 0;K < Q.length; K++) {
        let G = Q[K], H = Z.sources[K];
        if (G.kind === "error")
          $.log.warn(`Download ${G.id} (${H.url}) failed: ${G.error}`);
        else
          W.push(G.result), Y.push(H.isBinary ? { id: G.id, kind: "binary", data: G.result.data } : { id: G.id, kind: "string", data: G.result.data });
      }
      return J.assets = W, new D0.Data.Blob(Y, { label: "Data Blob", description: `${Y.length} ${Y.length === 1 ? "entry" : "entries"}` });
    });
  },
  dispose({ cache: Z }, J) {
    let $ = Z === null || Z === void 0 ? void 0 : Z.assets;
    if (!$)
      return;
    for (let X of $)
      X.dispose();
  }
}), $Y1 = B2.BuiltIn({
  name: "defalate-data",
  display: { name: "Deflate", description: "Deflate compressed data" },
  params: {
    method: j.Select("gzip", [["gzip", "gzip"]]),
    isString: j.Boolean(!1),
    stringEncoding: j.Optional(j.Select("utf-8", [["utf-8", "UTF8"]])),
    label: j.Optional(j.Text(""))
  },
  from: [D0.Data.Binary],
  to: [D0.Data.Binary, D0.Data.String]
})({
  apply({ a: Z, params: J }, $) {
    return n0.create("Gzip", async (X) => {
      let Y = await fS(X, Z.data), Q = J.label ? J.label : Z.label;
      if (J.isString) {
        let W = _S(Y);
        return new D0.Data.String(W, { label: Q });
      }
      return new D0.Data.Binary(Y, { label: Q });
    });
  }
}), Xr = B2.BuiltIn({
  name: "raw-data",
  display: { name: "Raw Data", description: "Raw data supplied by value." },
  from: [D0.Root],
  to: [D0.Data.String, D0.Data.Binary],
  params: {
    data: j.Value("", { isHidden: !0 }),
    label: j.Optional(j.Text(""))
  }
})({
  apply({ params: Z }) {
    return n0.create("Raw Data", async () => {
      if (typeof Z.data === "string")
        return new D0.Data.String(Z.data, { label: Z.label ? Z.label : "String" });
      else if (Array.isArray(Z.data))
        return new D0.Data.Binary(new Uint8Array(Z.data), { label: Z.label ? Z.label : "Binary" });
      else if (Z.data instanceof ArrayBuffer)
        return new D0.Data.Binary(new Uint8Array(Z.data), { label: Z.label ? Z.label : "Binary" });
      else if (Z.data instanceof Uint8Array)
        return new D0.Data.Binary(Z.data, { label: Z.label ? Z.label : "Binary" });
      else
        T8(Z.data);
    });
  },
  update({ oldParams: Z, newParams: J, b: $ }) {
    if (Z.data !== J.data)
      return T1.UpdateResult.Recreate;
    if (Z.label !== J.label)
      return $.label = J.label || $.label, T1.UpdateResult.Updated;
    return T1.UpdateResult.Unchanged;
  },
  customSerialization: {
    toJSON(Z) {
      if (typeof Z.data === "string" || Array.isArray(Z.data))
        return Z;
      else if (Z.data instanceof ArrayBuffer) {
        let J = new Uint8Array(Z.data), $ = new Array(J.length);
        for (let X = 0, Y = J.length;X < Y; X++)
          $[X] = J[X];
        return { data: $, label: Z.label };
      } else if (Z.data instanceof Uint8Array) {
        let J = new Array(Z.data.length);
        for (let $ = 0, X = Z.data.length;$ < X; $++)
          J[$] = Z.data[$];
        return { data: J, label: Z.label };
      }
    },
    fromJSON(Z) {
      return Z;
    }
  }
}), Yr = B2.BuiltIn({
  name: "read-file",
  display: { name: "Read File", description: "Read string or binary data from the specified file" },
  from: D0.Root,
  to: [D0.Data.String, D0.Data.Binary],
  params: {
    file: j.File(),
    label: j.Optional(j.Text("")),
    isBinary: j.Optional(j.Boolean(!1, { description: "If true, open file as as binary (string otherwise)" }))
  }
})({
  apply({ params: Z, cache: J }, $) {
    return n0.create("Open File", async (X) => {
      if (Z.file === null)
        return $.log.error("No file(s) selected"), LZ.Null;
      let Y = await $.managers.asset.resolve(Z.file, Z.isBinary ? "binary" : "string").runInContext(X);
      return J.asset = Y, Z.isBinary ? new D0.Data.Binary(Y.data, { label: Z.label ? Z.label : Z.file.name }) : new D0.Data.String(Y.data, { label: Z.label ? Z.label : Z.file.name });
    });
  },
  dispose({ cache: Z }) {
    var J;
    (J = Z === null || Z === void 0 ? void 0 : Z.asset) === null || J === void 0 || J.dispose();
  },
  update({ oldParams: Z, newParams: J, b: $ }) {
    var X;
    if (Z.label !== J.label)
      return $.label = J.label || ((X = Z.file) === null || X === void 0 ? void 0 : X.name) || "", T1.UpdateResult.Updated;
    return T1.UpdateResult.Unchanged;
  },
  isSerializable: () => ({ isSerializable: !1, reason: "Cannot serialize user loaded files." })
}), XY1 = B2.BuiltIn({
  name: "parse-blob",
  display: { name: "Parse Blob", description: "Parse multiple data enties" },
  from: D0.Data.Blob,
  to: D0.Format.Blob,
  params: {
    formats: j.ObjectList({
      id: j.Text("", { label: "Unique ID" }),
      format: j.Select("cif", [["cif", "cif"]])
    }, (Z) => `${Z.id}: ${Z.format}`)
  }
})({
  apply({ a: Z, params: J }, $) {
    return n0.create("Parse Blob", async (X) => {
      let Y = /* @__PURE__ */ new Map;
      for (let W of J.formats)
        Y.set(W.id, W.format);
      let Q = [];
      for (let W of Z.data) {
        if (!Y.has(W.id))
          continue;
        let K = await (W.kind === "string" ? kW.parse(W.data) : kW.parseBinary(W.data)).runInContext(X);
        if (K.isError)
          throw new Error(`${W.id}: ${K.message}`);
        Q.push({ id: W.id, kind: "cif", data: K.result });
      }
      return new D0.Format.Blob(Q, { label: "Format Blob", description: `${Q.length} ${Q.length === 1 ? "entry" : "entries"}` });
    });
  }
}), YY1 = B2.BuiltIn({
  name: "parse-cif",
  display: { name: "Parse CIF", description: "Parse CIF from String or Binary data" },
  from: [D0.Data.String, D0.Data.Binary],
  to: D0.Format.Cif
})({
  apply({ a: Z }) {
    return n0.create("Parse CIF", async (J) => {
      let $ = await kW.parse(Z.data).runInContext(J);
      if ($.isError)
        throw new Error($.message);
      if ($.result.blocks.length === 0)
        return LZ.Null;
      return new D0.Format.Cif($.result);
    });
  }
}), QY1 = B2.BuiltIn({
  name: "parse-cube",
  display: { name: "Parse Cube", description: "Parse Cube from String data" },
  from: D0.Data.String,
  to: D0.Format.Cube
})({
  apply({ a: Z }) {
    return n0.create("Parse Cube", async (J) => {
      let $ = await K40(Z.data, Z.label).runInContext(J);
      if ($.isError)
        throw new Error($.message);
      return new D0.Format.Cube($.result);
    });
  }
}), WY1 = B2.BuiltIn({
  name: "parse-psf",
  display: { name: "Parse PSF", description: "Parse PSF from String data" },
  from: [D0.Data.String],
  to: D0.Format.Psf
})({
  apply({ a: Z }) {
    return n0.create("Parse PSF", async (J) => {
      let $ = await Q40(Z.data).runInContext(J);
      if ($.isError)
        throw new Error($.message);
      return new D0.Format.Psf($.result);
    });
  }
}), KY1 = B2.BuiltIn({
  name: "parse-prmtop",
  display: { name: "Parse PRMTOP", description: "Parse PRMTOP from String data" },
  from: [D0.Data.String],
  to: D0.Format.Prmtop
})({
  apply({ a: Z }) {
    return n0.create("Parse PRMTOP", async (J) => {
      let $ = await F40(Z.data).runInContext(J);
      if ($.isError)
        throw new Error($.message);
      return new D0.Format.Prmtop($.result);
    });
  }
}), GY1 = B2.BuiltIn({
  name: "parse-top",
  display: { name: "Parse TOP", description: "Parse TOP from String data" },
  from: [D0.Data.String],
  to: D0.Format.Top
})({
  apply({ a: Z }) {
    return n0.create("Parse TOP", async (J) => {
      let $ = await U40(Z.data).runInContext(J);
      if ($.isError)
        throw new Error($.message);
      return new D0.Format.Top($.result);
    });
  }
}), HY1 = B2.BuiltIn({
  name: "parse-ply",
  display: { name: "Parse PLY", description: "Parse PLY from String data" },
  from: [D0.Data.String],
  to: D0.Format.Ply
})({
  apply({ a: Z }) {
    return n0.create("Parse PLY", async (J) => {
      let $ = await $40(Z.data).runInContext(J);
      if ($.isError)
        throw new Error($.message);
      return new D0.Format.Ply($.result, { label: $.result.comments[0] || "PLY Data" });
    });
  }
}), NY1 = B2.BuiltIn({
  name: "parse-ccp4",
  display: { name: "Parse CCP4/MRC/MAP", description: "Parse CCP4/MRC/MAP from Binary data" },
  from: [D0.Data.Binary],
  to: D0.Format.Ccp4
})({
  apply({ a: Z }) {
    return n0.create("Parse CCP4/MRC/MAP", async (J) => {
      let $ = await rz0(Z.data, Z.label).runInContext(J);
      if ($.isError)
        throw new Error($.message);
      return new D0.Format.Ccp4($.result);
    });
  }
}), qY1 = B2.BuiltIn({
  name: "parse-dsn6",
  display: { name: "Parse DSN6/BRIX", description: "Parse CCP4/BRIX from Binary data" },
  from: [D0.Data.Binary],
  to: D0.Format.Dsn6
})({
  apply({ a: Z }) {
    return n0.create("Parse DSN6/BRIX", async (J) => {
      let $ = await ez0(Z.data, Z.label).runInContext(J);
      if ($.isError)
        throw new Error($.message);
      return new D0.Format.Dsn6($.result);
    });
  }
}), FY1 = B2.BuiltIn({
  name: "parse-dx",
  display: { name: "Parse DX", description: "Parse DX from Binary/String data" },
  from: [D0.Data.Binary, D0.Data.String],
  to: D0.Format.Dx
})({
  apply({ a: Z }) {
    return n0.create("Parse DX", async (J) => {
      let $ = await H40(Z.data, Z.label).runInContext(J);
      if ($.isError)
        throw new Error($.message);
      return new D0.Format.Dx($.result);
    });
  }
}), UY1 = B2.BuiltIn({
  name: "import-string",
  display: { name: "Import String", description: "Import given data as a string" },
  from: D0.Root,
  to: D0.Data.String,
  params: {
    data: j.Value(""),
    label: j.Optional(j.Text(""))
  }
})({
  apply({ params: { data: Z, label: J } }) {
    return new D0.Data.String(Z, { label: J || "" });
  },
  update({ oldParams: Z, newParams: J, b: $ }) {
    if (Z.data !== J.data)
      return T1.UpdateResult.Recreate;
    if (Z.label !== J.label)
      return $.label = J.label || "", T1.UpdateResult.Updated;
    return T1.UpdateResult.Unchanged;
  },
  isSerializable: () => ({ isSerializable: !1, reason: "Cannot serialize user imported strings." })
}), LY1 = B2.BuiltIn({
  name: "import-json",
  display: { name: "Import JSON", description: "Import given data as a JSON" },
  from: D0.Root,
  to: D0.Format.Json,
  params: {
    data: j.Value({}),
    label: j.Optional(j.Text(""))
  }
})({
  apply({ params: { data: Z, label: J } }) {
    return new D0.Format.Json(Z, { label: J || "" });
  },
  update({ oldParams: Z, newParams: J, b: $ }) {
    if (Z.data !== J.data)
      return T1.UpdateResult.Recreate;
    if (Z.label !== J.label)
      return $.label = J.label || "", T1.UpdateResult.Updated;
    return T1.UpdateResult.Unchanged;
  },
  isSerializable: () => ({ isSerializable: !1, reason: "Cannot serialize user imported JSON." })
}), RY1 = B2.BuiltIn({
  name: "parse-json",
  display: { name: "Parse JSON", description: "Parse JSON from String data" },
  from: [D0.Data.String],
  to: D0.Format.Json
})({
  apply({ a: Z }) {
    return n0.create("Parse JSON", async (J) => {
      let $ = await new Response(oL.toString(Z.data)).json();
      return new D0.Format.Json($);
    });
  }
}), EY1 = B2.BuiltIn({
  name: "lazy-volume",
  display: { name: "Lazy Volume", description: "A placeholder for lazy loaded volume representation" },
  from: D0.Root,
  to: D0.Volume.Lazy,
  params: {
    url: j.Url(""),
    isBinary: j.Boolean(!1),
    format: j.Text("ccp4"),
    entryId: j.Value("", { isHidden: !0 }),
    isovalues: j.ObjectList({
      type: j.Text("relative"),
      value: j.Numeric(0),
      color: j.Color(c2.black),
      alpha: j.Numeric(1, { min: 0, max: 1, step: 0.01 }),
      volumeIndex: j.Numeric(0)
    }, (Z) => `${Z.type} ${Z.value}`)
  }
})({
  apply({ a: Z, params: J }) {
    return n0.create("Lazy Volume", async ($) => {
      let X = Array.isArray(J.entryId) ? J.entryId.join(", ") : J.entryId;
      return new D0.Volume.Lazy(J, { label: `${X || J.url}`, description: "Lazy Volume" });
    });
  }
});

// node_modules/molstar/lib/mol-plugin-state/transforms/misc.js
var Wr = {};
y9(Wr, {
  CreateGroup: () => OY1
});
var OY1 = B2.BuiltIn({
  name: "create-group",
  display: { name: "Group" },
  from: [],
  to: D0.Group,
  params: {
    label: j.Text("Group"),
    description: j.Optional(j.Text(""))
  }
})({
  apply({ params: Z }) {
    return new D0.Group({}, Z);
  },
  update({ oldParams: Z, newParams: J, b: $ }) {
    if (zN(Z, J))
      return T1.UpdateResult.Unchanged;
    return $.label = J.label, $.description = J.description, T1.UpdateResult.Updated;
  }
});

// node_modules/molstar/lib/mol-plugin-state/transforms/model.js
var Et = {};
y9(Et, {
  getTrajectory: () => _M0,
  TransformStructureConformation: () => $51,
  TrajectoryFromXYZ: () => cW1,
  TrajectoryFromSDF: () => oW1,
  TrajectoryFromPDB: () => pW1,
  TrajectoryFromModelAndCoordinates: () => kb,
  TrajectoryFromMmCif: () => dW1,
  TrajectoryFromMOL2: () => sW1,
  TrajectoryFromMOL: () => iW1,
  TrajectoryFromLammpsTrajData: () => nW1,
  TrajectoryFromLammpsData: () => lW1,
  TrajectoryFromGRO: () => uW1,
  TrajectoryFromCube: () => aW1,
  TrajectoryFromCifCore: () => rW1,
  TrajectoryFromBlob: () => mW1,
  TopologyFromTop: () => gW1,
  TopologyFromPsf: () => xW1,
  TopologyFromPrmtop: () => yW1,
  StructureSelectionFromScript: () => G51,
  StructureSelectionFromExpression: () => Q51,
  StructureSelectionFromBundle: () => H51,
  StructureInstances: () => X51,
  StructureFromTrajectory: () => Z51,
  StructureFromModel: () => J51,
  StructureComponent: () => F51,
  StructureComplexElementTypes: () => VM0,
  StructureComplexElement: () => q51,
  ShapeFromPly: () => U51,
  MultiStructureSelectionFromExpression: () => W51,
  MultiStructureSelectionFromBundle: () => K51,
  ModelWithCoordinates: () => Y51,
  ModelFromTrajectory: () => Ut,
  CustomStructureProperties: () => Rt,
  CustomModelProperties: () => Lt,
  CoordinatesFromXtc: () => SW1,
  CoordinatesFromTrr: () => fW1,
  CoordinatesFromNctraj: () => hW1,
  CoordinatesFromLammpstraj: () => bW1,
  CoordinatesFromDcd: () => vW1
});

// node_modules/molstar/lib/mol-io/reader/dcd/parser.js
function zY1(Z) {
  let J = new DataView(Z.buffer), $ = Object.create(null), X = [], Y = 0, Q = new Int32Array(Z.buffer, 0, 23), W = Q[0] !== J.getInt32(0);
  if (Q[0] !== 84) {
    let R = Z.byteLength;
    for (let z = 0;z < R; z += 4)
      J.setFloat32(z, J.getFloat32(z), !0);
  }
  if (Q[0] !== 84)
    throw new Error("dcd bad format, header block start");
  if (String.fromCharCode(J.getUint8(4), J.getUint8(5), J.getUint8(6), J.getUint8(7)) !== "CORD")
    throw new Error("dcd bad format, format string");
  let G = !1, H = !1, N = !1;
  if (Q[22] !== 0) {
    if (G = !0, Q[12] !== 0)
      H = !0;
    if (Q[13] === 1)
      N = !0;
  }
  if ($.NSET = Q[2], $.ISTART = Q[3], $.NSAVC = Q[4], $.NAMNF = Q[10], G)
    $.DELTA = J.getFloat32(44, W);
  else
    $.DELTA = J.getFloat64(44, W);
  if (Q[22] !== 84)
    throw new Error("dcd bad format, header block end");
  Y = Y + 84 + 8;
  let q = J.getInt32(Y, W), U = Y + 1;
  if ((q - 4) % 80 !== 0)
    throw new Error("dcd bad format, title block start");
  if ($.TITLE = TN0(Z.subarray(U, q)), J.getInt32(U + q + 4 - 1, W) !== q)
    throw new Error("dcd bad format, title block end");
  if (Y = Y + q + 8, J.getInt32(Y, W) !== 4)
    throw new Error("dcd bad format, natom block start");
  if ($.NATOM = J.getInt32(Y + 4, W), J.getInt32(Y + 8, W) !== 4)
    throw new Error("dcd bad format, natom block end");
  if (Y = Y + 4 + 8, $.NAMNF > 0)
    throw new Error("dcd format with fixed atoms unsupported, aborting");
  let F = $.NATOM, E = F * 4;
  for (let R = 0, z = $.NSET;R < z; ++R) {
    let D = Object.create(null);
    if (D.elementCount = F, H)
      Y += 4, D.cell = [
        J.getFloat64(Y, W),
        J.getFloat64(Y + 1, W),
        J.getFloat64(Y + 16, W),
        J.getFloat64(Y + 24, W),
        J.getFloat64(Y + 32, W),
        J.getFloat64(Y + 40, W)
      ], Y += 48, Y += 4;
    for (let A = 0;A < 3; ++A) {
      if (J.getInt32(Y, W) !== E)
        throw new Error(`dcd bad format, coord block start: ${R}, ${A}`);
      Y += 4;
      let B = new Float32Array(Z.buffer, Y, F);
      if (A === 0)
        D.x = B;
      else if (A === 1)
        D.y = B;
      else
        D.z = B;
      if (Y += E, J.getInt32(Y, W) !== E)
        throw new Error(`dcd bad format, coord block end: ${R}, ${A}`);
      Y += 4;
    }
    if (N) {
      let A = J.getInt32(Y, W);
      Y += 4 + A + 4;
    }
    X.push(D);
  }
  return { header: $, frames: X };
}
function L40(Z) {
  return n0.create("Parse DCD", async (J) => {
    try {
      let $ = zY1(Z);
      return a8.success($);
    } catch ($) {
      return a8.error($);
    }
  });
}

// node_modules/molstar/lib/mol-io/reader/common/text/column/fixed.js
function R40(Z) {
  return function(J, $, X) {
    return DY1(Z, J, $, X);
  };
}
function DY1(Z, J, $, X) {
  let { data: Y, indices: Q, count: W } = Z, { valueType: K } = X, G = K === "str" ? (H) => {
    let N = Q[2 * H] + J, q = Q[2 * H + 1];
    if (N >= q)
      return "";
    let U = N + $;
    if (U > q)
      U = q;
    return XF0(Y, N, U);
  } : K === "int" ? (H) => {
    let N = Q[2 * H] + J;
    if (N > Q[2 * H + 1])
      return 0;
    return mF(Y, N, N + $);
  } : (H) => {
    let N = Q[2 * H] + J;
    if (N > Q[2 * H + 1])
      return 0;
    return AH0(Y, N, N + $);
  };
  return {
    schema: X,
    __array: void 0,
    isDefined: !0,
    rowCount: W,
    value: G,
    valueKind: (H) => s.ValueKinds.Present,
    toArray: (H) => w7.createAndFillArray(W, G, H),
    areValuesEqual: (H, N) => G(H) === G(N)
  };
}

// node_modules/molstar/lib/mol-io/reader/gro/parser.js
function MY1() {
  return {
    title: "",
    timeInPs: 0,
    hasVelocities: !1,
    precision: { position: 0, velocity: 0 },
    box: [0, 0, 0]
  };
}
function AY1(Z, J) {
  return {
    tokenizer: Z,
    header: MY1(),
    numberOfAtoms: 0,
    runtimeCtx: J
  };
}
function BY1(Z) {
  let { tokenizer: J, header: $ } = Z, X = Z2.readLine(J);
  if (X.trim().length === 0)
    X = Z2.readLine(J);
  let Y = X.lastIndexOf("t=");
  if (Y >= 0) {
    if ($.timeInPs = parseFloat(X.substring(Y + 2)), $.title = X.substring(0, Y).trim(), $.title && $.title[$.title.length - 1] === ",")
      $.title = $.title.substring(0, $.title.length - 1);
  } else
    $.title = X;
}
function wY1(Z) {
  let { tokenizer: J } = Z;
  Z2.markLine(J);
  let $ = Z2.getTokenString(J);
  Z.numberOfAtoms = parseInt($);
}
async function jY1(Z) {
  let { tokenizer: J, numberOfAtoms: $ } = Z, X = await Z2.readLinesAsync(J, $, Z.runtimeCtx, 1e5), Q = J.data.substring(X.indices[0], X.indices[1]).substring(20).match(/\.\d+/g), W = Q.length === 6;
  Z.header.hasVelocities = W, Z.header.precision.position = Q[0].length - 1, Z.header.precision.velocity = W ? Q[3].length - 1 : 0;
  let K = 20, G = Z.header.precision.position + 5, H = K + 3 * G, N = Z.header.precision.velocity + 4, q = R40(X), U = s.Undefined(Z.numberOfAtoms, s.Schema.float);
  return {
    count: Z.numberOfAtoms,
    residueNumber: q(0, 5, s.Schema.int),
    residueName: q(5, 5, s.Schema.str),
    atomName: q(10, 5, s.Schema.str),
    atomNumber: q(15, 5, s.Schema.int),
    x: q(K, G, s.Schema.float),
    y: q(K + G, G, s.Schema.float),
    z: q(K + 2 * G, G, s.Schema.float),
    vx: W ? q(H, N, s.Schema.float) : U,
    vy: W ? q(H + N, N, s.Schema.float) : U,
    vz: W ? q(H + 2 * N, N, s.Schema.float) : U
  };
}
function TY1(Z) {
  let { tokenizer: J } = Z, $ = Z2.readLine(J).trim().split(/\s+/g);
  Z.header.box = [+$[0], +$[1], +$[2]];
}
async function _Y1(Z, J) {
  let $ = Z2(Z);
  await J.update({ message: "Parsing...", current: 0, max: Z.length });
  let X = [];
  while ($.position < Z.length) {
    let Q = AY1($, J);
    BY1(Q), wY1(Q);
    let W = await jY1(Q);
    TY1(Q), X.push({ header: Q.header, atoms: W });
  }
  let Y = { structures: X };
  return a8.success(Y);
}
function E40(Z) {
  return n0.create("Parse GRO", async (J) => {
    return await _Y1(Z, J);
  });
}

// node_modules/molstar/lib/mol-io/reader/pdb/parser.js
function O40(Z, J, $ = !1) {
  return n0.create("Parse PDB", async (X) => a8.success({
    lines: await Z2.readAllLinesAsync(Z, X),
    id: J,
    isPdbqt: $
  }));
}

// node_modules/molstar/lib/mol-geo/primitive/polyhedron.js
var VY1 = {
  radius: 1,
  detail: 0
};
function z40(Z, J, $) {
  let { radius: X, detail: Y } = { ...VY1, ...$ }, Q = IY1(), { vertices: W, indices: K } = Q;
  H(Y), FU0(W, X);
  let G = new Float32Array(W.length);
  return Eh(W, K, G, W.length / 3, K.length / 3), {
    vertices: new Float32Array(W),
    normals: new Float32Array(G),
    indices: new Uint32Array(K)
  };
  function H(q) {
    let U = M(), F = M(), E = M();
    for (let R = 0;R < J.length; R += 3)
      M.fromArray(U, Z, J[R + 0] * 3), M.fromArray(F, Z, J[R + 1] * 3), M.fromArray(E, Z, J[R + 2] * 3), N(U, F, E, q);
  }
  function N(q, U, F, E) {
    let R = Math.pow(2, E), z = [];
    for (let D = 0;D <= R; ++D) {
      z[D] = [];
      let A = M();
      M.lerp(A, q, F, D / R);
      let B = M();
      M.lerp(B, U, F, D / R);
      let T = R - D;
      for (let w = 0;w <= T; ++w)
        if (w === 0 && D === R)
          z[D][w] = A;
        else {
          let V = M();
          M.lerp(V, A, B, w / T), z[D][w] = V;
        }
    }
    for (let D = 0;D < R; ++D)
      for (let A = 0;A < 2 * (R - D) - 1; ++A) {
        let B = Math.floor(A / 2);
        if (A % 2 === 0)
          Q.add(z[D][B + 1], z[D + 1][B], z[D][B]);
        else
          Q.add(z[D][B + 1], z[D + 1][B + 1], z[D + 1][B]);
      }
  }
}
function IY1() {
  let Z = [], J = [], $ = /* @__PURE__ */ new Map;
  function X(Y) {
    let Q = `${Y[0].toFixed(5)}|${Y[1].toFixed(5)}|${Y[2].toFixed(5)}`, W = $.get(Q);
    if (W === void 0)
      W = Z.length / 3, $.set(Q, W), Z.push(...Y);
    return W;
  }
  return {
    vertices: Z,
    indices: J,
    add: (Y, Q, W) => {
      J.push(X(Y), X(Q), X(W));
    }
  };
}

// node_modules/molstar/lib/mol-geo/primitive/icosahedron.js
var S3 = (1 + Math.sqrt(5)) / 2, D40 = [
  -1,
  S3,
  0,
  1,
  S3,
  0,
  -1,
  -S3,
  0,
  1,
  -S3,
  0,
  0,
  -1,
  S3,
  0,
  1,
  S3,
  0,
  -1,
  -S3,
  0,
  1,
  -S3,
  S3,
  0,
  -1,
  S3,
  0,
  1,
  -S3,
  0,
  -1,
  -S3,
  0,
  1
], PY1 = [
  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
], CY1 = [
  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
], Kr;
function M40() {
  if (!Kr)
    Kr = Dz(D40, PY1);
  return Kr;
}
var Aw2 = uN(D40, CY1);

// node_modules/molstar/lib/mol-geo/primitive/sphere.js
var { vertices: kY1, indices: vY1 } = M40();
function _5(Z) {
  return 10 * Math.pow(Math.pow(2, Z), 2) + 2;
}
function A40(Z) {
  return z40(kY1, vY1, { detail: Z, radius: 1 });
}

// node_modules/molstar/lib/mol-geo/geometry/mesh/builder/sphere.js
var B40 = /* @__PURE__ */ new Map, SY1 = e.identity();
function fY1(Z, J, $) {
  return e.scaleUniformly(Z, e.fromTranslation(Z, J), $);
}
function Gr(Z) {
  let J = B40.get(Z);
  if (J === void 0)
    J = A40(Z), B40.set(Z, J);
  return J;
}
function g8(Z, J, $, X) {
  v1.addPrimitive(Z, fY1(SY1, J, $), Gr(X));
}

// node_modules/molstar/lib/mol-geo/primitive/cylinder.js
var OH = {
  radiusTop: 1,
  radiusBottom: 1,
  height: 1,
  radialSegments: 8,
  heightSegments: 1,
  topCap: !1,
  bottomCap: !1,
  thetaStart: 0,
  thetaLength: Math.PI * 2
};
function w40(Z) {
  let { radiusTop: J, radiusBottom: $, height: X, radialSegments: Y, heightSegments: Q, topCap: W, bottomCap: K, thetaStart: G, thetaLength: H } = { ...OH, ...Z }, N = [], q = [], U = [], F = 0, E = [], R = X / 2;
  if (z(), W && J > 0)
    D(!0);
  if (K && $ > 0)
    D(!1);
  return {
    vertices: new Float32Array(q),
    normals: new Float32Array(U),
    indices: new Uint32Array(N)
  };
  function z() {
    let A = M.zero(), B = ($ - J) / X;
    for (let T = 0;T <= Q; ++T) {
      let w = [], V = T / Q, P = V * ($ - J) + J;
      for (let I = 0;I <= Y; ++I) {
        let f = I / Y * H + G, v = Math.sin(f), h = Math.cos(f);
        q.push(P * v, -V * X + R, P * h), M.normalize(A, M.set(A, v, B, h)), U.push(...A), w.push(F++);
      }
      E.push(w);
    }
    for (let T = 0;T < Y; ++T)
      for (let w = 0;w < Q; ++w) {
        let V = E[w][T], P = E[w + 1][T], I = E[w + 1][T + 1], S = E[w][T + 1];
        N.push(V, P, S), N.push(P, I, S);
      }
  }
  function D(A) {
    let B = A === !0 ? J : $, T = A === !0 ? 1 : -1, w = F;
    for (let P = 1;P <= Y; ++P)
      q.push(0, R * T, 0), U.push(0, T, 0), ++F;
    let V = F;
    for (let P = 0;P <= Y; ++P) {
      let S = P / Y * H + G, f = Math.cos(S), v = Math.sin(S);
      q.push(B * v, R * T, B * f), U.push(0, T, 0), ++F;
    }
    for (let P = 0;P < Y; ++P) {
      let I = w + P, S = V + P;
      if (A === !0)
        N.push(S, S + 1, I);
      else
        N.push(S + 1, S, I);
    }
  }
}

// node_modules/molstar/lib/mol-geo/primitive/prism.js
var j40 = M(), T40 = M(), V5 = M(), I5 = M(), Yq = M(), BA = M(), hY1 = {
  height: 1,
  topCap: !0,
  bottomCap: !0
};
function wz(Z, J) {
  let $ = Z.length / 3;
  if ($ < 3)
    throw new Error("need at least 3 points to build a prism");
  let { height: X, topCap: Y, bottomCap: Q } = { ...hY1, ...J }, W = $ * 2, K = $ * 4, G = (Y ? 1 : 0) + (Q ? 1 : 0);
  if ($ === 3)
    W += G, K += G * 3;
  else if ($ === 4)
    W += G * 2, K += G * 4;
  else
    W += G * $, K += G * $ * 3;
  let H = RH(W, K), N = X * 0.5;
  M.set(j40, 0, 0, -N), M.set(T40, 0, 0, N);
  for (let q = 0;q < $; ++q) {
    let U = (q + 1) % $;
    M.set(V5, Z[q * 3], Z[q * 3 + 1], -N), M.set(I5, Z[U * 3], Z[U * 3 + 1], -N), M.set(Yq, Z[U * 3], Z[U * 3 + 1], N), M.set(BA, Z[q * 3], Z[q * 3 + 1], N), H.addQuad(V5, I5, Yq, BA);
  }
  if ($ === 3) {
    if (Y)
      M.set(V5, Z[0], Z[1], -N), M.set(I5, Z[3], Z[4], -N), M.set(Yq, Z[6], Z[7], -N), H.add(Yq, I5, V5);
    if (Q)
      M.set(V5, Z[0], Z[1], N), M.set(I5, Z[3], Z[4], N), M.set(Yq, Z[6], Z[7], N), H.add(V5, I5, Yq);
  } else if ($ === 4) {
    if (Y)
      M.set(V5, Z[0], Z[1], -N), M.set(I5, Z[3], Z[4], -N), M.set(Yq, Z[6], Z[7], -N), M.set(BA, Z[9], Z[10], -N), H.addQuad(BA, Yq, I5, V5);
    if (Q)
      M.set(V5, Z[0], Z[1], N), M.set(I5, Z[3], Z[4], N), M.set(Yq, Z[6], Z[7], N), M.set(BA, Z[9], Z[10], N), H.addQuad(V5, I5, Yq, BA);
  } else
    for (let q = 0;q < $; ++q) {
      let U = (q + 1) % $;
      if (Y)
        M.set(V5, Z[q * 3], Z[q * 3 + 1], -N), M.set(I5, Z[U * 3], Z[U * 3 + 1], -N), H.add(j40, I5, V5);
      if (Q)
        M.set(V5, Z[q * 3], Z[q * 3 + 1], N), M.set(I5, Z[U * 3], Z[U * 3 + 1], N), H.add(V5, I5, T40);
    }
  return H.getPrimitive();
}
var Hr;
function _40() {
  if (!Hr)
    Hr = wz(hW(4, !1));
  return Hr;
}
var Nr;
function V40() {
  if (!Nr)
    Nr = wz(hW(5, !1));
  return Nr;
}
var qr;
function I40() {
  if (!qr)
    qr = wz(hW(6, !1));
  return qr;
}
var Fr;
function P40() {
  if (!Fr)
    Fr = wz(hW(6, !0));
  return Fr;
}
var Ur;
function C40() {
  if (!Ur)
    Ur = wz(hW(7, !1));
  return Ur;
}

// node_modules/molstar/lib/mol-geo/geometry/mesh/builder/cylinder.js
var k40 = /* @__PURE__ */ new Map, v40 = M.create(0, 1, 0), Kq = M(), zb = M(), S40 = M(), Gq = e(), f40 = e(), h40 = M(), Wq = M(), Lr = M();
function zV(Z, J, $, X, Y) {
  if (M.setMagnitude(zb, $, X / 2), M.add(S40, J, zb), Y)
    M.matchDirection(Lr, v40, zb);
  else
    M.copy(Lr, v40);
  return M.set(h40, 1, X, 1), M.makeRotation(f40, Lr, zb), e.scale(Z, f40, h40), e.setTranslation(Z, S40);
}
var Qq = new Int32Array(9);
function bY1(Z) {
  var J, $, X, Y, Q, W, K, G, H;
  return Qq[0] = Math.round(1000 * ((J = Z.radiusTop) !== null && J !== void 0 ? J : OH.radiusTop)), Qq[1] = Math.round(1000 * (($ = Z.radiusBottom) !== null && $ !== void 0 ? $ : OH.radiusBottom)), Qq[2] = Math.round(1000 * ((X = Z.height) !== null && X !== void 0 ? X : OH.height)), Qq[3] = (Y = Z.radialSegments) !== null && Y !== void 0 ? Y : OH.radialSegments, Qq[4] = (Q = Z.heightSegments) !== null && Q !== void 0 ? Q : OH.heightSegments, Qq[5] = ((W = Z.topCap) !== null && W !== void 0 ? W : OH.topCap) ? 1 : 0, Qq[6] = ((K = Z.bottomCap) !== null && K !== void 0 ? K : OH.bottomCap) ? 1 : 0, Qq[7] = Math.round(1000 * ((G = Z.thetaStart) !== null && G !== void 0 ? G : OH.thetaStart)), Qq[8] = Math.round(1000 * ((H = Z.thetaLength) !== null && H !== void 0 ? H : OH.thetaLength)), l9(Qq);
}
function DV(Z) {
  let J = bY1(Z), $ = k40.get(J);
  if ($ === void 0) {
    if (Z.radialSegments && Z.radialSegments <= 4) {
      let X = Math.max(3, Z.radialSegments), Y = wz(hW(X, !0, Z.radiusTop), Z);
      $ = EA(Y, e.rotX90);
    } else
      $ = w40(Z);
    k40.set(J, $);
  }
  return $;
}
function b40(Z, J, $, X) {
  zV(Gq, J.origin, J.direction, $, !1), v1.addPrimitive(Z, Gq, DV(X));
}
function q6(Z, J, $, X, Y) {
  let Q = M.distance(J, $) * X;
  M.sub(Kq, $, J), zV(Gq, J, Kq, Q, !0), v1.addPrimitive(Z, Gq, DV(Y));
}
function x40(Z, J, $, X, Y, Q) {
  let W = M.distance(J, $) * X, K = DV(Q);
  M.sub(Kq, $, J), M.add(Wq, J, Y), zV(Gq, Wq, Kq, W, !0), v1.addPrimitive(Z, Gq, K), M.sub(Wq, J, Y), zV(Gq, Wq, Kq, W, !0), v1.addPrimitive(Z, Gq, K);
}
function jz(Z, J, $, X, Y, Q, W) {
  let K = M.distance(J, $) * X, G = Y % 2 !== 0, H = Math.floor((Y + 1) / 2), N = K / (Y + 0.5), q = DV(W);
  M.setMagnitude(Kq, M.sub(Kq, $, J), N), M.copy(Wq, J);
  for (let U = 0;U < H; ++U) {
    if (M.add(Wq, Wq, Kq), G && U === H - 1) {
      if (!Q && W.topCap)
        W.topCap = !1, q = DV(W);
      N /= 2;
    }
    zV(Gq, Wq, Kq, N, !1), v1.addPrimitive(Z, Gq, q), M.add(Wq, Wq, Kq);
  }
}

// node_modules/molstar/lib/mol-geo/geometry/mesh/mesh-builder.js
var CJ = M(), y40 = h2(), zH = M(), f3 = M(), $U = M(), Db = M(), uQ = M.fromArray, xY1 = M.triangleNormal, g40 = M.copy, Mb = M.transformMat4, m40 = M.transformMat3, d40 = h2.directionTransform, cQ = B1.add3, Ab = B1.add, v1;
(function(Z) {
  function J(U = 2048, F = 1024, E) {
    return {
      currentGroup: -1,
      vertices: B1.create(Float32Array, 3, F, E ? E.vertexBuffer.ref.value : U),
      normals: B1.create(Float32Array, 3, F, E ? E.normalBuffer.ref.value : U),
      indices: B1.create(Uint32Array, 3, F * 3, E ? E.indexBuffer.ref.value : U * 3),
      groups: B1.create(Float32Array, 1, F, E ? E.groupBuffer.ref.value : U),
      mesh: E
    };
  }
  Z.createState = J;
  function $(U, F, E, R) {
    let { vertices: z, normals: D, indices: A, groups: B, currentGroup: T } = U, w = z.elementCount;
    cQ(z, F[0], F[1], F[2]), cQ(z, E[0], E[1], E[2]), cQ(z, R[0], R[1], R[2]), xY1(CJ, F, E, R);
    for (let V = 0;V < 3; ++V)
      cQ(D, CJ[0], CJ[1], CJ[2]), Ab(B, T);
    cQ(A, w, w + 1, w + 2);
  }
  Z.addTriangle = $;
  function X(U, F, E, R, z) {
    let { vertices: D, normals: A, indices: B, groups: T, currentGroup: w } = U, V = D.elementCount;
    cQ(D, F[0], F[1], F[2]), cQ(D, E[0], E[1], E[2]), cQ(D, R[0], R[1], R[2]);
    for (let P = 0;P < 3; ++P)
      cQ(A, z[0], z[1], z[2]), Ab(T, w);
    cQ(B, V, V + 1, V + 2);
  }
  Z.addTriangleWithNormal = X;
  function Y(U, F, E) {
    uQ($U, F, E[0] * 3), uQ(Db, F, E[1] * 3);
    for (let R = 2, z = E.length;R < z; R += 2)
      g40(zH, $U), g40(f3, Db), uQ($U, F, E[R] * 3), uQ(Db, F, E[R + 1] * 3), $(U, zH, f3, $U), $(U, f3, Db, $U);
  }
  Z.addTriangleStrip = Y;
  function Q(U, F, E) {
    uQ(zH, F, E[0] * 3);
    for (let R = 2, z = E.length;R < z; ++R)
      uQ(f3, F, E[R - 1] * 3), uQ($U, F, E[R] * 3), $(U, zH, $U, f3);
  }
  Z.addTriangleFan = Q;
  function W(U, F, E, R) {
    uQ(zH, F, E[0] * 3);
    for (let z = 2, D = E.length;z < D; ++z)
      uQ(f3, F, E[z - 1] * 3), uQ($U, F, E[z] * 3), X(U, zH, $U, f3, R);
  }
  Z.addTriangleFanWithNormal = W;
  function K(U, F, E) {
    let { vertices: R, normals: z, indices: D } = E, { vertices: A, normals: B, indices: T, groups: w, currentGroup: V } = U, P = A.elementCount, I = d40(y40, F);
    for (let S = 0, f = R.length;S < f; S += 3)
      Mb(CJ, uQ(CJ, R, S), F), cQ(A, CJ[0], CJ[1], CJ[2]), m40(CJ, uQ(CJ, z, S), I), cQ(B, CJ[0], CJ[1], CJ[2]), Ab(w, V);
    for (let S = 0, f = D.length;S < f; S += 3)
      cQ(T, D[S] + P, D[S + 1] + P, D[S + 2] + P);
  }
  Z.addPrimitive = K;
  function G(U, F, E) {
    let { vertices: R, normals: z, indices: D } = E, { vertices: A, normals: B, indices: T, groups: w, currentGroup: V } = U, P = A.elementCount, I = d40(y40, F);
    for (let S = 0, f = R.length;S < f; S += 3)
      Mb(CJ, uQ(CJ, R, S), F), cQ(A, CJ[0], CJ[1], CJ[2]), m40(CJ, uQ(CJ, z, S), I), cQ(B, -CJ[0], -CJ[1], -CJ[2]), Ab(w, V);
    for (let S = 0, f = D.length;S < f; S += 3)
      cQ(T, D[S + 2] + P, D[S + 1] + P, D[S] + P);
  }
  Z.addPrimitiveFlipped = G;
  function H(U, F, E, R, z, D) {
    let { vertices: A, edges: B } = E, T = { radiusTop: R, radiusBottom: R, radialSegments: D };
    for (let w = 0, V = B.length;w < V; w += 2)
      uQ(zH, A, B[w] * 3), uQ(f3, A, B[w + 1] * 3), Mb(zH, zH, F), Mb(f3, f3, F), g8(U, zH, R, z), g8(U, f3, R, z), q6(U, zH, f3, 1, T);
  }
  Z.addCage = H;
  function N(U, F, E) {
    K(U, F, {
      vertices: E.vertexBuffer.ref.value.subarray(0, E.vertexCount * 3),
      normals: E.normalBuffer.ref.value.subarray(0, E.vertexCount * 3),
      indices: E.indexBuffer.ref.value.subarray(0, E.triangleCount * 3)
    });
  }
  Z.addMesh = N;
  function q(U) {
    let { vertices: F, normals: E, indices: R, groups: z, mesh: D } = U, A = B1.compact(F, !0), B = B1.compact(R, !0), T = B1.compact(E, !0), w = B1.compact(z, !0);
    return n1.create(A, B, T, w, U.vertices.elementCount, U.indices.elementCount, D);
  }
  Z.getMesh = q;
})(v1 || (v1 = {}));

// node_modules/molstar/lib/mol-model-formats/shape/ply.js
function l40(Z) {
  let J = Z && Z.getElement("vertex"), $ = Z && Z.getElement("material"), X = { group: "", vRed: "", vGreen: "", vBlue: "", mRed: "", mGreen: "", mBlue: "" }, Y = [["", ""]], Q = [["", ""]];
  if (J) {
    for (let G = 0, H = J.propertyNames.length;G < H; ++G) {
      let N = J.propertyNames[G], q = J.propertyTypes[G];
      if (q === "uchar" || q === "uint8" || q === "ushort" || q === "uint16" || q === "uint" || q === "uint32" || q === "int")
        Y.push([N, N]);
      if (q === "uchar" || q === "uint8")
        Q.push([N, N]);
    }
    if (J.propertyNames.includes("atomid"))
      X.group = "atomid";
    else if (J.propertyNames.includes("material_index"))
      X.group = "material_index";
    if (J.propertyNames.includes("red"))
      X.vRed = "red";
    if (J.propertyNames.includes("green"))
      X.vGreen = "green";
    if (J.propertyNames.includes("blue"))
      X.vBlue = "blue";
  }
  let W = [["", ""]];
  if ($) {
    for (let G = 0, H = $.propertyNames.length;G < H; ++G) {
      let N = $.propertyNames[G], q = $.propertyTypes[G];
      if (q === "uchar" || q === "uint8")
        W.push([N, N]);
    }
    if ($.propertyNames.includes("red"))
      X.mRed = "red";
    if ($.propertyNames.includes("green"))
      X.mGreen = "green";
    if ($.propertyNames.includes("blue"))
      X.mBlue = "blue";
  }
  let K = X.vRed && X.vGreen && X.vBlue ? "vertex" : X.mRed && X.mGreen && X.mBlue ? "material" : "uniform";
  return {
    ...n1.Params,
    coloring: j.MappedStatic(K, {
      vertex: j.Group({
        red: j.Select(X.vRed, Q, { label: "Red Property" }),
        green: j.Select(X.vGreen, Q, { label: "Green Property" }),
        blue: j.Select(X.vBlue, Q, { label: "Blue Property" })
      }, { isFlat: !0 }),
      material: j.Group({
        red: j.Select(X.mRed, W, { label: "Red Property" }),
        green: j.Select(X.mGreen, W, { label: "Green Property" }),
        blue: j.Select(X.mBlue, W, { label: "Blue Property" })
      }, { isFlat: !0 }),
      uniform: j.Group({
        color: j.Color(c2.grey),
        saturation: j.Numeric(0, { min: -6, max: 6, step: 0.1 }),
        lightness: j.Numeric(0, { min: -6, max: 6, step: 0.1 })
      }, { isFlat: !0 })
    }),
    grouping: j.MappedStatic(X.group ? "vertex" : "none", {
      vertex: j.Group({
        group: j.Select(X.group, Y, { label: "Group Property" })
      }, { isFlat: !0 }),
      none: j.Group({})
    })
  };
}
var p40 = l40();
function yY1(Z, J, $, X, Y) {
  let { vertices: Q, normals: W, groups: K } = $, G = X.getProperty("x"), H = X.getProperty("y"), N = X.getProperty("z");
  if (!G || !H || !N)
    throw new Error("missing coordinate properties");
  let q = X.getProperty("nx"), U = X.getProperty("ny"), F = X.getProperty("nz"), E = !!q && !!U && !!F;
  for (let R = Z;R < J; ++R) {
    if (B1.add3(Q, G.value(R), H.value(R), N.value(R)), E)
      B1.add3(W, q.value(R), U.value(R), F.value(R));
    B1.add(K, Y[R]);
  }
}
function gY1(Z, J, $, X) {
  let { indices: Y } = $;
  for (let Q = Z;Q < J; ++Q) {
    let { entries: W, count: K } = X.value(Q);
    if (K === 3)
      B1.add3(Y, W[0], W[1], W[2]);
    else if (K === 4)
      B1.add3(Y, W[2], W[1], W[0]), B1.add3(Y, W[2], W[0], W[3]);
  }
}
async function mY1(Z, J, $, X, Y) {
  let Q = v1.createState(J.rowCount, J.rowCount / 4, Y), W = J.getProperty("x"), K = J.getProperty("y"), G = J.getProperty("z");
  if (!W || !K || !G)
    throw new Error("missing coordinate properties");
  let H = J.getProperty("nx"), N = J.getProperty("ny"), q = J.getProperty("nz"), U = !!H && !!N && !!q, F = 1e5;
  for (let R = 0, z = J.rowCount;R < z; R += F)
    if (yY1(R, Math.min(R + F, z), Q, J, X), Z.shouldUpdate)
      await Z.update({ message: "adding ply mesh vertices", current: R, max: z });
  for (let R = 0, z = $.rowCount;R < z; R += F)
    if (gY1(R, Math.min(R + F, z), Q, $), Z.shouldUpdate)
      await Z.update({ message: "adding ply mesh faces", current: R, max: z });
  let E = v1.getMesh(Q);
  if (!U)
    n1.computeNormals(E);
  return C.updateIfChanged(E.varyingGroup, !0), E;
}
var XU = s.Schema.int;
function dY1(Z, J) {
  let { grouping: $ } = J, { rowCount: X } = Z, Y = $.name === "vertex" ? Z.getProperty($.params.group) : void 0, Q = $.name === "vertex" ? v$($.params.group) : "Vertex", W = Y ? Y.toArray({ array: Uint32Array }) : uJ(new Uint32Array(X)), K = Y ? yX(W) : X - 1, G = new Uint32Array(K + 1);
  for (let H = 0, N = W.length;H < N; ++H)
    G[W[H]] = H;
  return { ids: W, map: G, label: Q };
}
function u40(Z, J, $) {
  let { coloring: X } = $, { rowCount: Y } = Z, Q, W, K;
  if (X.name === "vertex")
    Q = Z.getProperty(X.params.red) || s.ofConst(127, Y, XU), W = Z.getProperty(X.params.green) || s.ofConst(127, Y, XU), K = Z.getProperty(X.params.blue) || s.ofConst(127, Y, XU);
  else if (X.name === "material")
    Q = J && J.getProperty(X.params.red) || s.ofConst(127, Y, XU), W = J && J.getProperty(X.params.green) || s.ofConst(127, Y, XU), K = J && J.getProperty(X.params.blue) || s.ofConst(127, Y, XU);
  else {
    let G = X.params.color;
    G = i0.saturate(G, X.params.saturation), G = i0.lighten(G, X.params.lightness);
    let [H, N, q] = i0.toRgb(G);
    Q = s.ofConst(H, Y, XU), W = s.ofConst(N, Y, XU), K = s.ofConst(q, Y, XU);
  }
  return { kind: X.name, red: Q, green: W, blue: K };
}
function c40(Z, J, $, X) {
  let { kind: Y, red: Q, green: W, blue: K } = $, { ids: G, map: H, label: N } = X, { source: q, transforms: U } = Z;
  return c8.create("ply-mesh", q, J, (F) => {
    let E = Y === "material" ? F : H[F];
    return i0.fromRgb(Q.value(E), W.value(E), K.value(E));
  }, () => 1, (F) => {
    return `${N} ${G[F]}`;
  }, U);
}
function pY1() {
  let Z, J, $, X, Y, Q;
  return async (K, G, H, N) => {
    let q = G.source.getElement("vertex");
    if (!q)
      throw new Error("missing vertex element");
    let U = G.source.getElement("face");
    if (!U)
      throw new Error("missing face element");
    let F = G.source.getElement("material"), E = !1, R = !1;
    if (!Z || Z !== G)
      E = !0;
    if (!J || !j.isParamEqual(p40.grouping, J.grouping, H.grouping))
      E = !0;
    if (!J || !j.isParamEqual(p40.coloring, J.coloring, H.coloring))
      R = !0;
    if (E)
      Y = u40(q, F, H), Q = dY1(q, H), X = await mY1(K, q, U, Q.ids, N && N.geometry), $ = c40(G, X, Y, Q);
    else if (R)
      Y = u40(q, F, H), $ = c40(G, X, Y, Q);
    return Z = G, J = W$(H), $;
  };
}
function n40(Z, J) {
  return n0.create("Shape Provider", async ($) => {
    return {
      label: "Mesh",
      data: { source: Z, transforms: J === null || J === void 0 ? void 0 : J.transforms },
      params: l40(Z),
      getShape: pY1(),
      geometryUtils: n1.Utils
    };
  });
}

// node_modules/molstar/lib/mol-math/geometry/spacegroup/cell.js
function VK() {
  return VK.empty();
}
(function(Z) {
  function J(Y, Q) {
    return { size: Y, anglesInRadians: Q };
  }
  Z.create = J;
  function $() {
    return J(M(), M());
  }
  Z.empty = $;
  function X(Y, Q, W) {
    let K = M.magnitude(Y), G = M.magnitude(Q), H = M.magnitude(W), N = Math.acos(M.dot(Q, W) / (G * H)), q = Math.acos(M.dot(Y, W) / (K * H)), U = Math.acos(M.dot(Y, Q) / (K * G));
    if (K <= 0 || G <= 0 || H <= 0 || N >= Math.PI || q >= Math.PI || U >= Math.PI)
      return $();
    else
      return J(M.create(K, G, H), M.create(N, q, U));
  }
  Z.fromBasis = X;
})(VK || (VK = {}));

// node_modules/molstar/lib/mol-model-formats/structure/dcd.js
var uY1 = 20.45482949774598;
function i40(Z) {
  return n0.create("Parse DCD", async (J) => {
    await J.update("Converting to coordinates");
    let { header: $ } = Z, X = $.DELTA ? N$($.DELTA * uY1, "ps") : N$(1, "step"), Y = $.ISTART >= 1 ? N$(($.ISTART - 1) * X.value, X.unit) : N$(0, X.unit), Q = [];
    for (let W = 0, K = Z.frames.length;W < K; ++W) {
      let G = Z.frames[W], H = {
        elementCount: G.elementCount,
        time: N$(Y.value + X.value * W, X.unit),
        x: G.x,
        y: G.y,
        z: G.z,
        xyzOrdering: { isIdentity: !0 }
      };
      if (G.cell) {
        let N = G.cell;
        if (N[1] >= -1 && N[1] <= 1 && N[3] >= -1 && N[3] <= 1 && N[4] >= -1 && N[4] <= 1)
          H.cell = VK.create(M.create(N[0], N[2], N[5]), M.create(_8(90 - Math.asin(N[1]) * 90 / cO), _8(90 - Math.asin(N[3]) * 90 / cO), _8(90 - Math.asin(N[4]) * 90 / cO)));
        else if (N[0] < 0 || N[1] < 0 || N[2] < 0 || N[3] < 0 || N[4] < 0 || N[5] < 0 || N[3] > 180 || N[4] > 180 || N[5] > 180)
          H.cell = VK.fromBasis(M.create(N[0], N[1], N[3]), M.create(N[1], N[2], N[4]), M.create(N[3], N[4], N[5]));
        else
          H.cell = VK.create(M.create(N[0], N[2], N[5]), M.create(_8(dZ(N[1], 0, u8) ? 90 : N[1]), _8(dZ(N[3], 0, u8) ? 90 : N[3]), _8(dZ(N[4], 0, u8) ? 90 : N[4])));
      }
      Q.push(H);
    }
    return z5.create(Q, X, Y);
  });
}

// node_modules/molstar/lib/mol-model-formats/structure/util.js
function wA(Z, J, $, X) {
  let Y = $, Q = X - 1, W = J.charCodeAt(Y);
  while ((W === 32 || W >= 48 && W <= 57) && Y <= Q)
    W = J.charCodeAt(++Y);
  W = J.charCodeAt(Q);
  while ((W === 32 || W >= 48 && W <= 57) && Q >= Y)
    W = J.charCodeAt(--Q);
  if (++Q, Y === Q)
    return G1.add(Z, Y, Q);
  if (Y + 1 === Q)
    return G1.add(Z, Y, Q);
  if (W = J.charCodeAt(Y), Y + 2 === Q) {
    let K = J.charCodeAt(Y + 1);
    if ((W === 78 || W === 110) && (K === 65 || K === 97) || (W === 67 || W === 99) && (K === 76 || K === 108) || (W === 70 || W === 102) && (K === 69 || K === 101) || (W === 83 || W === 115) && (K === 73 || K === 105) || (W === 66 || W === 98) && (K === 82 || K === 114) || (W === 65 || W === 97) && (K === 83 || K === 115))
      return G1.add(Z, Y, Y + 2);
  }
  if (W === 67 || W === 99 || W === 72 || W === 104 || W === 78 || W === 110 || W === 79 || W === 111 || W === 80 || W === 112 || W === 83 || W === 115)
    return G1.add(Z, Y, Y + 1);
  G1.add(Z, Y, Y);
}
var cY1 = /* @__PURE__ */ new Set(["NA", "CL", "FE", "SI", "BR", "AS", "LI"]), lY1 = /* @__PURE__ */ new Set(["C", "H", "N", "O", "P", "S", "F", "B"]), nY1 = /^[\s\d]+|[\s\d]+$/g;
function h3(Z, J) {
  Z = Z.replace(nY1, "").toUpperCase();
  let $ = Z.length;
  if ($ === 0)
    return Z;
  if ($ === 1)
    return Z;
  if (cY1.has(Z))
    return Z;
  if ($ === 3 && J === Z) {
    if (Z === "SOD")
      return "NA";
    if (Z === "POT")
      return "K";
    if (Z === "CES")
      return "CS";
    if (Z === "CAL")
      return "CA";
    if (Z === "CLA")
      return "CL";
  }
  if (lY1.has(Z[0]))
    return Z[0];
  return "";
}

// node_modules/molstar/lib/mol-model-formats/structure/common/util.js
var Rr = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
function iY1(Z) {
  let J = Rr.length, $ = Z, X = 0, Y = Rr[$ % J];
  while ($ >= J)
    $ = Math.floor($ / J), Y += Rr[$ % J], X += 1;
  if (X >= 5)
    console.warn("getChainId overflow");
  return Y;
}
var DH = QH(iY1);

// node_modules/molstar/lib/mol-model-formats/structure/gro.js
function oY1(Z, J) {
  let { atomName: $, residueName: X } = Z, Y = new Array(Z.count), Q = new Array(Z.count), W = new Uint32Array(Z.count), K = new Uint32Array(Z.count), G = new Array(Z.count), H = new c7, N = new l7(Z.residueNumber, Z.atomName), q = "", U = 0, F = "", E = 0, R = e2.Unknown, z = -1;
  for (let B = 0, T = Z.count;B < T; ++B) {
    let w = Z.residueNumber.value(B);
    if (w !== z) {
      let V = Z.residueName.value(B), P = qY(N.add(V, B).type, V);
      if (P !== R || w !== z + 1 && !(z === 99999 && w === 0))
        F = DH(U), U += 1, E = 0;
      q = H.getEntityId(V, P, F), E += 1, z = w, R = P;
    }
    Y[B] = q, Q[B] = F, W[B] = E, K[B] = B, G[B] = h3(Z.atomName.value(B), Z.residueName.value(B));
  }
  let D = s.ofStringArray(Q), A = A8.ofPartialColumns(E9.atom_site, {
    auth_asym_id: D,
    auth_atom_id: $,
    auth_comp_id: X,
    auth_seq_id: Z.residueNumber,
    Cartn_x: s.ofFloatArray(s.mapToArray(Z.x, (B) => B * 10, Float32Array)),
    Cartn_y: s.ofFloatArray(s.mapToArray(Z.y, (B) => B * 10, Float32Array)),
    Cartn_z: s.ofFloatArray(s.mapToArray(Z.z, (B) => B * 10, Float32Array)),
    id: s.ofIntArray(K),
    label_asym_id: D,
    label_atom_id: $,
    label_comp_id: X,
    label_seq_id: s.ofIntArray(W),
    label_entity_id: s.ofStringArray(Y),
    occupancy: s.ofConst(1, Z.count, s.Schema.float),
    type_symbol: s.ofStringArray(G),
    pdbx_PDB_model_num: s.ofConst(J, Z.count, s.Schema.int)
  }, Z.count);
  return u7({
    entity: H.getEntityTable(),
    chem_comp: N.getChemCompTable(),
    atom_site: A
  });
}
var Er;
(function(Z) {
  function J(X) {
    return (X === null || X === void 0 ? void 0 : X.kind) === "gro";
  }
  Z.is = J;
  function $(X) {
    return { kind: "gro", name: X.structures[0].header.title, data: X };
  }
  Z.fromGro = $;
})(Er || (Er = {}));
function o40(Z) {
  return n0.create("Parse GRO", async (J) => {
    let $ = Er.fromGro(Z), X = [];
    for (let Y = 0, Q = Z.structures.length;Y < Q; ++Y) {
      let W = oY1(Z.structures[Y].atoms, Y + 1), K = await nJ(W, $, J);
      if (K.frameCount === 1)
        X.push(K.representative);
    }
    return new UY(X);
  });
}

// node_modules/molstar/lib/mol-model-formats/structure/pdb/assembly.js
function a40(Z, J) {
  let $ = (Q, W) => (J.substr(Q, W) || "").trim(), X = {
    entry_id: K2.ofString(Z),
    length_a: K2.ofString($(6, 9)),
    length_b: K2.ofString($(15, 9)),
    length_c: K2.ofString($(24, 9)),
    angle_alpha: K2.ofString($(33, 7)),
    angle_beta: K2.ofString($(40, 7)),
    angle_gamma: K2.ofString($(47, 7)),
    Z_PDB: K2.ofString($(66, 4)),
    pdbx_unique_axis: K2.ofString("?")
  }, Y = {
    entry_id: K2.ofString(Z),
    "space_group_name_H-M": K2.ofString($(55, 11)),
    Int_Tables_number: K2.ofString("?"),
    cell_setting: K2.ofString("?"),
    space_group_name_Hall: K2.ofString("?")
  };
  return [YJ.ofFields("cell", X), YJ.ofFields("symmetry", Y)];
}
function s40(Z, J) {
  return { id: Z, details: J, groups: [] };
}
function r40(Z, J, $) {
  let X = [], Y, Q, W, K = 1, G = 1, H = (R) => Z.data.substring(Z.indices[2 * R], Z.indices[2 * R + 1]);
  for (let R = J;R < $; R++) {
    let z = H(R);
    if (z.substr(11, 12) === "BIOMOLECULE:") {
      let D = z.substr(23).trim(), A = `Biomolecule ${D}`;
      if (z = H(R + 1), z.substr(11, 30) !== "APPLY THE FOLLOWING TO CHAINS:")
        R++, A = z.substr(11).trim();
      Y = s40(D, A), X.push(Y);
    } else if (z.substr(13, 5) === "BIOMT") {
      let D = z.split(/\s+/), A = parseInt(z[18]) - 1;
      if (A === 0)
        W = e.identity(), Q.operators.push({ id: K++, matrix: W });
      e.setValue(W, A, 0, parseFloat(D[4])), e.setValue(W, A, 1, parseFloat(D[5])), e.setValue(W, A, 2, parseFloat(D[6])), e.setValue(W, A, 3, parseFloat(D[7]));
    } else if (z.substr(11, 30) === "APPLY THE FOLLOWING TO CHAINS:" || z.substr(11, 30) === "                   AND CHAINS:") {
      if (z.substr(11, 5) === "APPLY")
        Q = { chains: [], operators: [] }, Y.groups.push(Q);
      let D = z.substr(41, 30).split(",");
      for (let A = 0, B = D.length;A < B; ++A) {
        let T = D[A].trim();
        if (T)
          Q.chains.push(T);
      }
    } else if (z.substr(11, 33) === "APPLYING THE FOLLOWING TO CHAINS:") {
      Y = s40(`${G}`, `Biomolecule ${G}`), X.push(Y), G += 1, Q = { chains: [], operators: [] }, Y.groups.push(Q), R++, z = H(R);
      let D = z.substr(11, 69).split(",");
      for (let A = 0, B = D.length;A < B; ++A) {
        let T = D[A].trim();
        if (T)
          Q.chains.push(T);
      }
    }
  }
  if (X.length === 0)
    return [];
  let N = {
    id: K2.ofStrings(X.map((R) => R.id)),
    details: K2.ofStrings(X.map((R) => R.details))
  }, q = [];
  for (let R of X)
    for (let z of R.groups)
      q.push({
        assembly_id: R.id,
        oper_expression: z.operators.map((D) => D.id).join(","),
        asym_id_list: z.chains.join(",")
      });
  let U = {
    assembly_id: K2.ofStrings(q.map((R) => R.assembly_id)),
    oper_expression: K2.ofStrings(q.map((R) => R.oper_expression)),
    asym_id_list: K2.ofStrings(q.map((R) => R.asym_id_list))
  }, F = [];
  for (let R of X)
    for (let z of R.groups)
      for (let D of z.operators) {
        let A = {
          id: "" + D.id,
          type: "?",
          name: "?",
          symmetry_operation: "?"
        };
        for (let B = 0;B < 3; B++) {
          for (let T = 0;T < 3; T++)
            A[`matrix[${B + 1}][${T + 1}]`] = "" + e.getValue(D.matrix, B, T);
          A[`vector[${B + 1}]`] = "" + e.getValue(D.matrix, B, 3);
        }
        F.push(A);
      }
  let E = {
    id: K2.ofStrings(F.map((R) => R.id)),
    type: K2.ofStrings(F.map((R) => R.type)),
    name: K2.ofStrings(F.map((R) => R.name)),
    symmetry_operation: K2.ofStrings(F.map((R) => R.symmetry_operation))
  };
  for (let R = 0;R < 3; R++) {
    for (let D = 0;D < 3; D++) {
      let A = `matrix[${R + 1}][${D + 1}]`;
      E[A] = K2.ofStrings(F.map((B) => B[A]));
    }
    let z = `vector[${R + 1}]`;
    E[z] = K2.ofStrings(F.map((D) => D[z]));
  }
  return [
    YJ.ofFields("pdbx_struct_assembly", N),
    YJ.ofFields("pdbx_struct_assembly_gen", U),
    YJ.ofFields("pdbx_struct_oper_list", E)
  ];
}
function t40(Z, J, $) {
  let X = [], Y, Q = (H) => Z.data.substring(Z.indices[2 * H], Z.indices[2 * H + 1]);
  for (let H = J;H < $; H++) {
    let N = Q(H), q = N.split(/\s+/), U = parseInt(N[5]) - 1;
    if (U === 0)
      Y = e.identity(), X.push(Y);
    e.setValue(Y, U, 0, parseFloat(q[2])), e.setValue(Y, U, 1, parseFloat(q[3])), e.setValue(Y, U, 2, parseFloat(q[4])), e.setValue(Y, U, 3, parseFloat(q[5]));
  }
  if (X.length === 0)
    return [];
  let W = [], K = 1;
  for (let H of X) {
    let N = {
      id: "ncsop" + K++,
      code: ".",
      details: "."
    };
    for (let q = 0;q < 3; q++) {
      for (let U = 0;U < 3; U++)
        N[`matrix[${q + 1}][${U + 1}]`] = "" + e.getValue(H, q, U);
      N[`vector[${q + 1}]`] = "" + e.getValue(H, q, 3);
    }
    W.push(N);
  }
  let G = {
    id: K2.ofStrings(W.map((H) => H.id)),
    code: K2.ofStrings(W.map((H) => H.code)),
    details: K2.ofStrings(W.map((H) => H.details))
  };
  for (let H = 0;H < 3; H++) {
    for (let q = 0;q < 3; q++) {
      let U = `matrix[${H + 1}][${q + 1}]`;
      G[U] = K2.ofStrings(W.map((F) => F[U]));
    }
    let N = `vector[${H + 1}]`;
    G[N] = K2.ofStrings(W.map((q) => q[N]));
  }
  return [YJ.ofFields("struct_ncs_oper", G)];
}

// node_modules/molstar/lib/mol-model-formats/structure/pdb/secondary-structure.js
var sY1 = {
  1: "helx_rh_al_p",
  2: "helx_rh_om_p",
  3: "helx_rh_pi_p",
  4: "helx_rh_ga_p",
  5: "helx_rh_3t_p",
  6: "helx_lh_al_p",
  7: "helx_lh_om_p",
  8: "helx_lh_ga_p",
  9: "helx_rh_27_p",
  10: "helx_rh_pp_p"
};
function aY1(Z) {
  return sY1[Z] || "helx_p";
}
function e40(Z, J, $) {
  let X = [], Y = (N) => Z.data.substring(Z.indices[2 * N], Z.indices[2 * N + 1]);
  for (let N = J;N < $; N++) {
    let q = Y(N);
    X.push({
      serNum: q.substring(7, 10).trim(),
      helixID: q.substring(11, 14).trim(),
      initResName: q.substring(15, 19).trim(),
      initChainID: q.substring(19, 20).trim(),
      initSeqNum: q.substring(21, 25).trim(),
      initICode: q.substring(25, 26).trim(),
      endResName: q.substring(27, 31).trim(),
      endChainID: q.substring(31, 34).trim(),
      endSeqNum: q.substring(33, 37).trim(),
      endICode: q.substring(37, 38).trim(),
      helixClass: q.substring(38, 40).trim(),
      comment: q.substring(40, 70).trim(),
      length: q.substring(71, 76).trim()
    });
  }
  let Q = K2.ofStrings(X.map((N) => N.initChainID)), W = K2.ofStrings(X.map((N) => N.initResName)), K = K2.ofStrings(X.map((N) => N.endChainID)), G = K2.ofStrings(X.map((N) => N.endResName)), H = {
    beg_label_asym_id: Q,
    beg_label_comp_id: W,
    beg_label_seq_id: K2.ofUndefined(X.length, s.Schema.int),
    beg_auth_asym_id: Q,
    beg_auth_comp_id: W,
    beg_auth_seq_id: K2.ofStrings(X.map((N) => N.initSeqNum)),
    conf_type_id: K2.ofStrings(X.map((N) => aY1(N.helixClass))),
    details: K2.ofStrings(X.map((N) => N.comment)),
    end_label_asym_id: K,
    end_label_comp_id: G,
    end_label_seq_id: K2.ofUndefined(X.length, s.Schema.int),
    end_auth_asym_id: K,
    end_auth_comp_id: G,
    end_auth_seq_id: K2.ofStrings(X.map((N) => N.endSeqNum)),
    id: K2.ofStrings(X.map((N) => N.serNum)),
    pdbx_beg_PDB_ins_code: K2.ofStrings(X.map((N) => N.initICode)),
    pdbx_end_PDB_ins_code: K2.ofStrings(X.map((N) => N.endICode)),
    pdbx_PDB_helix_class: K2.ofStrings(X.map((N) => N.helixClass)),
    pdbx_PDB_helix_length: K2.ofStrings(X.map((N) => N.length)),
    pdbx_PDB_helix_id: K2.ofStrings(X.map((N) => N.helixID))
  };
  return YJ.ofFields("struct_conf", H);
}
function ZD0(Z, J, $) {
  let X = [], Y = (U) => Z.data.substring(Z.indices[2 * U], Z.indices[2 * U + 1]);
  for (let U = J;U < $; U++) {
    let F = Y(U);
    X.push({
      strand: F.substring(7, 10).trim(),
      sheetID: F.substring(11, 14).trim(),
      numStrands: F.substring(14, 16).trim(),
      initResName: F.substring(17, 21).trim(),
      initChainID: F.substring(21, 22).trim(),
      initSeqNum: F.substring(22, 26).trim(),
      initICode: F.substring(26, 27).trim(),
      endResName: F.substring(28, 32).trim(),
      endChainID: F.substring(32, 33).trim(),
      endSeqNum: F.substring(33, 37).trim(),
      endICode: F.substring(37, 38).trim(),
      sense: F.substring(38, 40).trim(),
      curAtom: F.substring(41, 45).trim(),
      curResName: F.substring(45, 49).trim(),
      curChainId: F.substring(49, 50).trim(),
      curResSeq: F.substring(50, 54).trim(),
      curICode: F.substring(54, 55).trim(),
      prevAtom: F.substring(56, 60).trim(),
      prevResName: F.substring(60, 64).trim(),
      prevChainId: F.substring(64, 65).trim(),
      prevResSeq: F.substring(65, 69).trim(),
      prevICode: F.substring(69, 70).trim()
    });
  }
  let Q = K2.ofStrings(X.map((U) => U.initChainID)), W = K2.ofStrings(X.map((U) => U.initResName)), K = K2.ofStrings(X.map((U) => U.initSeqNum)), G = K2.ofStrings(X.map((U) => U.endChainID)), H = K2.ofStrings(X.map((U) => U.endResName)), N = K2.ofStrings(X.map((U) => U.endSeqNum)), q = {
    beg_label_asym_id: Q,
    beg_label_comp_id: W,
    beg_label_seq_id: K,
    beg_auth_asym_id: Q,
    beg_auth_comp_id: W,
    beg_auth_seq_id: K,
    end_label_asym_id: G,
    end_label_comp_id: G,
    end_label_seq_id: N,
    end_auth_asym_id: G,
    end_auth_comp_id: H,
    end_auth_seq_id: N,
    id: K2.ofStrings(X.map((U) => U.strand)),
    sheet_id: K2.ofStrings(X.map((U) => U.sheetID)),
    pdbx_beg_PDB_ins_code: K2.ofStrings(X.map((U) => U.initICode)),
    pdbx_end_PDB_ins_code: K2.ofStrings(X.map((U) => U.endICode))
  };
  return YJ.ofFields("struct_sheet_range", q);
}

// node_modules/molstar/lib/mol-model-formats/structure/pdb/entity.js
var rY1 = {
  MOL_ID: "",
  MOLECULE: "",
  CHAIN: "",
  FRAGMENT: "",
  SYNONYM: "",
  EC: "",
  ENGINEERED: "",
  MUTATION: "",
  OTHER_DETAILS: ""
};
function JD0(Z, J, $) {
  let X = (G) => Z.data.substring(Z.indices[2 * G], Z.indices[2 * G + 1]), Y, Q = { chains: [], description: "" }, W = [];
  for (let G = J;G < $; G++) {
    let N = X(G).substr(10, 70).trim(), q = N.indexOf(":"), U = N.substring(0, q), F;
    if (U in rY1)
      Y = U, F = N.substring(q + 2);
    else
      F = N;
    if (F = F.replace(/;$/, ""), Y === "MOL_ID")
      Q = {
        chains: [],
        description: ""
      }, W.push(Q);
    else if (Y === "MOLECULE") {
      if (Q.description)
        Q.description += " ";
      Q.description += F;
    } else if (Y === "CHAIN")
      Array.prototype.push.apply(Q.chains, F.split(/\s*,\s*/));
  }
  let K = [];
  for (let G of W)
    for (let H of G.chains)
      K.push({
        description: G.description,
        chains: [H]
      });
  return K;
}
function $D0(Z, J, $) {
  let X = (Q) => Z.data.substring(Z.indices[2 * Q], Z.indices[2 * Q + 1]), Y = /* @__PURE__ */ new Map;
  for (let Q = J;Q < $; Q++) {
    let W = X(Q), K = W.substr(11, 3).trim(), G = W.substr(15).trim();
    if (Y.has(K))
      Y.set(K, `${Y.get(K)} ${G}`);
    else
      Y.set(K, G);
  }
  return Y;
}

// node_modules/molstar/lib/mol-model-formats/structure/pdb/atom-site.js
function XD0(Z, J) {
  let $ = () => [], X = () => G1.create(Z, 2 * J);
  return {
    index: 0,
    group_PDB: X(),
    id: $(),
    auth_atom_id: X(),
    label_alt_id: X(),
    auth_comp_id: X(),
    auth_asym_id: X(),
    auth_seq_id: X(),
    pdbx_PDB_ins_code: X(),
    Cartn_x: X(),
    Cartn_y: X(),
    Cartn_z: X(),
    occupancy: X(),
    B_iso_or_equiv: X(),
    type_symbol: X(),
    pdbx_PDB_model_num: $(),
    label_entity_id: $(),
    partial_charge: X()
  };
}

class Or {
  constructor(Z, J, $, X) {
    this.asymIds = Z, this.modelNums = J, this.terIndices = $, this.hasAssemblies = X, this.asymIdCounts = /* @__PURE__ */ new Map, this.currModelNum = void 0, this.currAsymId = "", this.currLabelAsymId = "";
  }
  clear() {
    this.asymIdCounts.clear(), this.currModelNum = void 0;
  }
  get(Z) {
    let J = this.asymIds.value(Z);
    if (this.hasAssemblies)
      return J;
    let $ = this.modelNums[Z];
    if ($ !== this.currModelNum)
      this.asymIdCounts.clear(), this.currModelNum = $, this.currLabelAsymId = J;
    else if (this.currAsymId !== J)
      this.currAsymId = J, this.currLabelAsymId = J;
    if (this.asymIdCounts.has(J)) {
      if (this.terIndices.has(Z)) {
        let X = this.asymIdCounts.get(J) + 1;
        this.asymIdCounts.set(J, X), this.currLabelAsymId = `${J}_${X}`;
      }
    } else
      this.asymIdCounts.set(J, 0);
    return this.currLabelAsymId;
  }
}
function YD0(Z, J, $) {
  J.clear();
  let X = K2.ofStrings(Z.pdbx_PDB_model_num), Y = K2.ofTokens(Z.auth_asym_id), Q = K2.ofTokens(Z.auth_seq_id), W = K2.ofTokens(Z.pdbx_PDB_ins_code), K = K2.ofTokens(Z.auth_atom_id), G = K2.ofTokens(Z.auth_comp_id), H = K2.ofStrings(Z.id), N = X.str(0), q = Y.str(0), U = Q.int(0), F = W.str(0), E = U, R = /* @__PURE__ */ new Map, z = /* @__PURE__ */ new Map, D = [], A = [], B = [], T = !1;
  for (let I = 0, S = H.rowCount;I < S; ++I)
    if (W.str(I) !== "") {
      T = !0;
      break;
    }
  for (let I = 0, S = H.rowCount;I < S; ++I) {
    let f = X.str(I), v = Y.str(I), h = Q.int(I), x = W.str(I), b = K.str(I);
    if (f !== N)
      R.clear(), z.clear(), N = f, q = v, U = h, F = x, E = h;
    else if (q !== v)
      z.clear(), q = v, U = h, F = x, E = h;
    else if (U !== h) {
      if (z.clear(), U === E)
        E = h;
      else
        E += 1;
      U = h, F = x;
    } else if (F !== x)
      z.clear(), F = x, E += 1;
    if (D[I] = J.get(I), z.has(b)) {
      let g = z.get(b) + 1;
      z.set(b, g), b = `${b}_${g}`;
    } else
      z.set(b, 0);
    if (A[I] = b, T)
      B[I] = E;
  }
  let w = s.ofStringArray(D), V = s.ofStringArray(A), P = T ? K2.ofColumn(s.ofIntArray(B)) : K2.ofUndefined(Z.index, s.Schema.int);
  return {
    auth_asym_id: Y,
    auth_atom_id: K,
    auth_comp_id: G,
    auth_seq_id: Q,
    B_iso_or_equiv: K2.ofTokens(Z.B_iso_or_equiv),
    Cartn_x: K2.ofTokens(Z.Cartn_x),
    Cartn_y: K2.ofTokens(Z.Cartn_y),
    Cartn_z: K2.ofTokens(Z.Cartn_z),
    group_PDB: K2.ofTokens(Z.group_PDB),
    id: H,
    label_alt_id: K2.ofTokens(Z.label_alt_id),
    label_asym_id: K2.ofColumn(w),
    label_atom_id: K2.ofColumn(V),
    label_comp_id: G,
    label_seq_id: P,
    label_entity_id: K2.ofStrings(Z.label_entity_id),
    occupancy: QN0(Z.occupancy) ? K2.ofUndefined(Z.index, s.Schema.float) : K2.ofTokens(Z.occupancy),
    type_symbol: K2.ofTokens(Z.type_symbol),
    pdbx_PDB_ins_code: K2.ofTokens(Z.pdbx_PDB_ins_code),
    pdbx_PDB_model_num: X,
    partial_charge: K2.ofTokens(Z.partial_charge)
  };
}
function zr(Z, J, $, X, Y, Q) {
  let { data: W } = $, K = Y - X;
  if (G1.addToken(Z.group_PDB, Z2.trim($, X, X + 6)), Z2.trim($, X + 6, X + 11), Z.id[Z.index] = $.data.substring($.tokenStart, $.tokenEnd), G1.addToken(Z.auth_atom_id, Z2.trim($, X + 12, X + 16)), W.charCodeAt(X + 16) === 32)
    G1.add(Z.label_alt_id, 0, 0);
  else
    G1.add(Z.label_alt_id, X + 16, X + 17);
  if (G1.addToken(Z.auth_comp_id, Z2.trim($, X + 17, X + 21)), G1.add(Z.auth_asym_id, X + 21, X + 22), G1.addToken(Z.auth_seq_id, Z2.trim($, X + 22, X + 26)), W.charCodeAt(X + 26) === 32)
    G1.add(Z.pdbx_PDB_ins_code, 0, 0);
  else
    G1.add(Z.pdbx_PDB_ins_code, X + 26, X + 27);
  if (G1.addToken(Z.Cartn_x, Z2.trim($, X + 30, X + 38)), G1.addToken(Z.Cartn_y, Z2.trim($, X + 38, X + 46)), G1.addToken(Z.Cartn_z, Z2.trim($, X + 46, X + 54)), G1.addToken(Z.occupancy, Z2.trim($, X + 54, X + 60)), K >= 66)
    G1.addToken(Z.B_iso_or_equiv, Z2.trim($, X + 60, X + 66));
  else
    G1.add(Z.B_iso_or_equiv, 0, 0);
  if (Q)
    G1.addToken(Z.partial_charge, Z2.trim($, X + 70, X + 76));
  if (K >= 78 && !Q)
    if (Z2.trim($, X + 76, X + 78), $.tokenStart < $.tokenEnd)
      G1.addToken(Z.type_symbol, $);
    else
      wA(Z.type_symbol, W, X + 12, X + 16);
  else
    wA(Z.type_symbol, W, X + 12, X + 16);
  Z.pdbx_PDB_model_num[Z.index] = J, Z.index++;
}

// node_modules/molstar/lib/mol-model-formats/structure/pdb/anisotropic.js
function QD0(Z, J) {
  let $ = () => [], X = () => new Float32Array(J), Y = () => G1.create(Z, 2 * J);
  return {
    index: 0,
    count: J,
    id: $(),
    type_symbol: Y(),
    pdbx_label_atom_id: Y(),
    pdbx_label_alt_id: Y(),
    pdbx_label_comp_id: Y(),
    pdbx_label_asym_id: Y(),
    pdbx_label_seq_id: Y(),
    pdbx_PDB_ins_code: Y(),
    "U[1][1]": X(),
    "U[2][2]": X(),
    "U[3][3]": X(),
    "U[1][2]": X(),
    "U[1][3]": X(),
    "U[2][3]": X(),
    pdbx_auth_seq_id: Y(),
    pdbx_auth_comp_id: Y(),
    pdbx_auth_asym_id: Y(),
    pdbx_auth_atom_id: Y()
  };
}
function WD0(Z) {
  let J = K2.ofTokens(Z.pdbx_auth_seq_id), $ = K2.ofTokens(Z.pdbx_auth_comp_id), X = K2.ofTokens(Z.pdbx_auth_asym_id), Y = K2.ofTokens(Z.pdbx_auth_atom_id), Q = {
    id: K2.ofStrings(Z.id),
    type_symbol: K2.ofTokens(Z.type_symbol),
    pdbx_label_atom_id: Y,
    pdbx_label_alt_id: K2.ofTokens(Z.pdbx_label_alt_id),
    pdbx_label_comp_id: $,
    pdbx_label_asym_id: X,
    pdbx_label_seq_id: J,
    pdbx_PDB_ins_code: K2.ofTokens(Z.pdbx_PDB_ins_code),
    pdbx_auth_seq_id: J,
    pdbx_auth_comp_id: $,
    pdbx_auth_asym_id: X,
    pdbx_auth_atom_id: Y
  };
  return Q["U[1][1]"] = K2.ofNumbers(Z["U[1][1]"]), Q["U[2][2]"] = K2.ofNumbers(Z["U[2][2]"]), Q["U[3][3]"] = K2.ofNumbers(Z["U[3][3]"]), Q["U[1][2]"] = K2.ofNumbers(Z["U[1][2]"]), Q["U[1][3]"] = K2.ofNumbers(Z["U[1][3]"]), Q["U[2][3]"] = K2.ofNumbers(Z["U[2][3]"]), Q;
}
function KD0(Z, J, $, X, Y) {
  let { data: Q } = $, W = Y - X;
  if (Z2.trim($, X + 6, X + 11), Z.id[Z.index] = Q.substring($.tokenStart, $.tokenEnd), G1.addToken(Z.pdbx_auth_atom_id, Z2.trim($, X + 12, X + 16)), Q.charCodeAt(X + 16) === 32)
    G1.add(Z.pdbx_label_alt_id, 0, 0);
  else
    G1.add(Z.pdbx_label_alt_id, X + 16, X + 17);
  if (G1.addToken(Z.pdbx_auth_comp_id, Z2.trim($, X + 17, X + 21)), G1.add(Z.pdbx_auth_asym_id, X + 21, X + 22), G1.addToken(Z.pdbx_auth_seq_id, Z2.trim($, X + 22, X + 26)), Q.charCodeAt(X + 26) === 32)
    G1.add(Z.pdbx_PDB_ins_code, 0, 0);
  else
    G1.add(Z.pdbx_PDB_ins_code, X + 26, X + 27);
  if (Z["U[1][1]"][Z.index] = mF(Q, X + 28, X + 35) / 1e4, Z["U[2][2]"][Z.index] = mF(Q, X + 35, X + 42) / 1e4, Z["U[3][3]"][Z.index] = mF(Q, X + 42, X + 49) / 1e4, Z["U[1][2]"][Z.index] = mF(Q, X + 49, X + 56) / 1e4, Z["U[1][3]"][Z.index] = mF(Q, X + 56, X + 63) / 1e4, Z["U[2][3]"][Z.index] = mF(Q, X + 63, X + 70) / 1e4, W >= 78)
    if (Z2.trim($, X + 76, X + 78), $.tokenStart < $.tokenEnd)
      G1.addToken(Z.type_symbol, $);
    else
      wA(Z.type_symbol, Q, X + 12, X + 16);
  else
    wA(Z.type_symbol, Q, X + 12, X + 16);
  Z.index++;
}

// node_modules/molstar/lib/mol-model-formats/structure/pdb/conect.js
function GD0(Z, J, $, X) {
  let Y = {};
  for (let v = 0, h = X.id.rowCount;v < h; ++v)
    Y[X.id.str(v)] = v;
  let Q = (v) => Z.data.substring(Z.indices[2 * v], Z.indices[2 * v + 1]), W = [], K = [], G = [], H = [], N = [], q = [], U = [], F = [], E = [], R = [], z = [], D = [], A = [], B = [], T = [], w = [11, 16, 21, 26], V = 1, P = -1, I = {}, S = !1;
  for (let v = J;v < $; v++) {
    let h = Q(v), x = Y[parseInt(h.substr(6, 5))];
    if (x === void 0)
      continue;
    if (P !== x)
      P = x, I = {};
    for (let b = 0;b < 4; ++b) {
      let g = parseInt(h.substr(w[b], 5));
      if (Number.isNaN(g))
        continue;
      let m = Y[g];
      if (m === void 0)
        continue;
      if (x > m)
        continue;
      if (I[m] !== void 0) {
        G[I[m]] += 1, S = !0;
        continue;
      }
      I[m] = V - 1, W.push(`covale${V}`), K.push("covale"), G.push(1), H.push(X.label_asym_id.str(x)), N.push(X.label_seq_id.int(x)), q.push(X.auth_seq_id.int(x)), U.push(X.label_atom_id.str(x)), F.push(X.label_alt_id.str(x)), E.push(X.pdbx_PDB_ins_code.str(x)), R.push(X.label_asym_id.str(m)), z.push(X.label_seq_id.int(m)), D.push(X.auth_seq_id.int(m)), A.push(X.label_atom_id.str(m)), B.push(X.label_alt_id.str(m)), T.push(X.pdbx_PDB_ins_code.str(m)), V += 1;
    }
  }
  let f = {
    id: K2.ofStrings(W),
    conn_type_id: K2.ofStrings(K),
    ptnr1_label_asym_id: K2.ofStrings(H),
    ptnr1_label_seq_id: K2.ofNumbers(N),
    ptnr1_auth_seq_id: K2.ofNumbers(q),
    ptnr1_label_atom_id: K2.ofStrings(U),
    pdbx_ptnr1_label_alt_id: K2.ofStrings(F),
    pdbx_ptnr1_PDB_ins_code: K2.ofStrings(E),
    ptnr2_label_asym_id: K2.ofStrings(R),
    ptnr2_label_seq_id: K2.ofNumbers(z),
    ptnr2_auth_seq_id: K2.ofNumbers(D),
    ptnr2_label_atom_id: K2.ofStrings(A),
    pdbx_ptnr2_label_alt_id: K2.ofStrings(B),
    pdbx_ptnr2_PDB_ins_code: K2.ofStrings(T)
  };
  if (S) {
    let v = ["sing", "doub", "trpl", "quad"];
    f.pdbx_value_order = K2.ofStrings(G.map((h) => v[h - 1] || "sing"));
  }
  return YJ.ofFields("struct_conn", f);
}

// node_modules/molstar/lib/mol-model-formats/structure/pdb/header.js
function HD0(Z, J, $, X) {
  let Y = Z.substring(J, $);
  X.id_code = Y.substring(62, 66).trim() || void 0, X.dep_date = Y.substring(50, 59).trim() || void 0, X.classification = Y.substring(10, 50).trim() || void 0;
}

// node_modules/molstar/lib/mol-model-formats/structure/pdb/to-cif.js
function kJ(Z, J, $, X) {
  let Y = X.length;
  if (Y > $ - J)
    return !1;
  for (let Q = 0;Q < Y; Q++)
    if (Z.charCodeAt(J + Q) !== X.charCodeAt(Q))
      return !1;
  return !0;
}
async function ND0(Z) {
  let { lines: J } = Z, { data: $, indices: X } = J, Y = Z2($), Q = !!Z.isPdbqt, W = 0, K = 0;
  for (let v = 0, h = J.count;v < h; v++) {
    let x = X[2 * v], b = X[2 * v + 1];
    switch ($.charAt(x)) {
      case "A":
        if (kJ($, x, b, "ATOM  "))
          W++;
        else if (kJ($, x, b, "ANISOU"))
          K++;
        break;
      case "H":
        if (kJ($, x, b, "HETATM"))
          W++;
        break;
    }
  }
  let G = {}, H = XD0($, W), N = QD0($, K), q = new c7, U = [], F = [], E = 0, R = "", z = void 0, D = !1, A = /* @__PURE__ */ new Set;
  for (let v = 0, h = J.count;v < h; v++) {
    let x = X[2 * v], b = X[2 * v + 1];
    switch ($.charAt(x)) {
      case "A":
        if (kJ($, x, b, "ATOM  ")) {
          if (!E)
            E++, R = "" + E;
          zr(H, R, Y, x, b, Q);
        } else if (kJ($, x, b, "ANISOU"))
          KD0(N, R, Y, x, b);
        break;
      case "C":
        if (kJ($, x, b, "CRYST1"))
          U.push(...a40(Z.id || "?", $.substring(x, b)));
        else if (kJ($, x, b, "CONECT")) {
          let g = v + 1;
          while (!0) {
            if (x = X[2 * g], b = X[2 * g + 1], !kJ($, x, b, "CONECT"))
              break;
            g++;
          }
          if (z) {
            if (y2)
              console.log("only single CONECT block allowed, ignoring others");
          } else
            z = [v, g];
          v = g - 1;
        } else if (kJ($, x, b, "COMPND")) {
          let g = v + 1;
          while (!0) {
            if (x = X[2 * g], b = X[2 * g + 1], !kJ($, x, b, "COMPND"))
              break;
            g++;
          }
          q.setCompounds(JD0(J, v, g)), v = g - 1;
        }
        break;
      case "H":
        if (kJ($, x, b, "HEADER"))
          HD0($, x, b, G);
        else if (kJ($, x, b, "HETATM")) {
          if (!E)
            E++, R = "" + E;
          zr(H, R, Y, x, b, Q);
        } else if (kJ($, x, b, "HELIX")) {
          let g = v + 1;
          while (!0) {
            if (x = X[2 * g], b = X[2 * g + 1], !kJ($, x, b, "HELIX"))
              break;
            g++;
          }
          U.push(e40(J, v, g)), v = g - 1;
        } else if (kJ($, x, b, "HETNAM")) {
          let g = v + 1;
          while (!0) {
            if (x = X[2 * g], b = X[2 * g + 1], !kJ($, x, b, "HETNAM"))
              break;
            g++;
          }
          F.push(...Array.from($D0(J, v, g).entries())), v = g - 1;
        }
        break;
      case "M":
        if (kJ($, x, b, "MODEL "))
          E++, R = "" + E;
        if (kJ($, x, b, "MTRIX")) {
          let g = v + 1;
          while (!0) {
            if (x = X[2 * g], b = X[2 * g + 1], !kJ($, x, b, "MTRIX"))
              break;
            g++;
          }
          U.push(...t40(J, v, g)), v = g - 1;
        }
        break;
      case "O":
        break;
      case "R":
        if (kJ($, x, b, "REMARK 350")) {
          let g = v + 1;
          while (!0) {
            if (x = X[2 * g], b = X[2 * g + 1], !kJ($, x, b, "REMARK 350"))
              break;
            g++;
          }
          U.push(...r40(J, v, g)), v = g - 1, D = !0;
        }
        break;
      case "S":
        if (kJ($, x, b, "SHEET")) {
          let g = v + 1;
          while (!0) {
            if (x = X[2 * g], b = X[2 * g + 1], !kJ($, x, b, "SHEET"))
              break;
            g++;
          }
          U.push(ZD0(J, v, g)), v = g - 1;
        }
        break;
      case "T":
        if (kJ($, x, b, "TER"))
          A.add(H.index);
    }
  }
  if (G.id_code) {
    let v = {
      id: K2.ofString(G.id_code)
    };
    U.push(YJ.ofFields("entry", v));
  }
  if (G.classification) {
    let v = {
      pdbx_keywords: K2.ofString(G.classification)
    };
    U.push(YJ.ofFields("struct_keywords", v));
  }
  if (G.dep_date) {
    let v = {
      recvd_initial_deposition_date: K2.ofString(G.dep_date)
    };
    U.push(YJ.ofFields("pdbx_database_status", v));
  }
  let B = s.ofIntTokens(H.auth_seq_id), T = s.ofStringTokens(H.auth_atom_id), w = s.ofStringTokens(H.auth_comp_id), V = s.ofStringTokens(H.auth_asym_id), P = new Or(V, H.pdbx_PDB_model_num, A, D), I = new l7(B, T);
  I.setNames(F), q.setNames(F);
  for (let v = 0, h = w.rowCount;v < h; ++v) {
    let x = w.value(v), b = qY(I.add(x, v).type, x), g = P.get(v);
    H.label_entity_id[v] = q.getEntityId(x, b, g);
  }
  let S = YD0(H, P, { hasAssemblies: D });
  if (!Q)
    delete S.partial_charge;
  if (z)
    U.push(GD0(J, z[0], z[1], S));
  let f = {
    entity: YJ.ofTable("entity", q.getEntityTable()),
    chem_comp: YJ.ofTable("chem_comp", I.getChemCompTable()),
    atom_site: YJ.ofFields("atom_site", S),
    atom_site_anisotrop: YJ.ofFields("atom_site_anisotrop", WD0(N))
  };
  for (let v of U)
    f[v.name] = v;
  return {
    header: Z.id || "PDB",
    categoryNames: Object.keys(f),
    categories: f
  };
}

// node_modules/molstar/lib/mol-model-formats/structure/pdb.js
var Dr;
(function(Z) {
  function J(X) {
    return (X === null || X === void 0 ? void 0 : X.kind) === "pdb";
  }
  Z.is = J;
  function $(X) {
    return { kind: "pdb", name: X.id || "", data: X };
  }
  Z.create = $;
})(Dr || (Dr = {}));
function qD0(Z) {
  return n0.create("Parse PDB", async (J) => {
    var $;
    await J.update("Converting to mmCIF");
    let X = await ND0(Z), Y = S6.fromFrame(X, void 0, Dr.create(Z)), Q = u7(Y.data.db, !0), W = await nJ(Q, Y, J), K = ($ = X.categories.atom_site) === null || $ === void 0 ? void 0 : $.getField("partial_charge");
    if (K) {
      if (W.frameCount === 1) {
        let G = W.representative, H = G.atomicHierarchy.atomSourceIndex, q = s.isIdentity(H) ? void 0 : H.toArray({ array: Int32Array }), U = K.toFloatArray(), F = q ? s.ofFloatArray(s.mapToArray(H, (E) => U[E], Float32Array)) : s.ofFloatArray(U);
        EH.Provider.set(G, {
          data: F,
          type: "GASTEIGER"
        });
      }
    }
    return W;
  });
}

// node_modules/molstar/lib/mol-model-formats/structure/psf.js
function tY1(Z) {
  let J = new Array(Z.count), $ = new Array(Z.count), X = new Uint32Array(Z.count), Y = new Uint32Array(Z.count), Q = new Array(Z.count), W = new c7, K = new l7(Z.residueId, Z.atomName), G = "", H = 0, N = "", q = 0, U = Z.segmentName.value(0), F = !1, E = e2.Unknown, R = -1;
  for (let D = 0, A = Z.count;D < A; ++D) {
    let B = Z.residueId.value(D), T = Z.segmentName.value(D);
    if (U !== T)
      N = DH(H), H += 1, q = 0, F = !0, U = T;
    else
      F = !1;
    if (F || B !== R) {
      let w = Z.residueName.value(D), V = qY(K.add(w, D).type, w);
      if (!F && (V !== E || B !== R + 1))
        N = DH(H), H += 1, q = 0;
      G = W.getEntityId(w, V, N), q += 1, R = B, E = V;
    }
    J[D] = G, $[D] = N, X[D] = q, Y[D] = D, Q[D] = h3(Z.atomName.value(D), Z.residueName.value(D));
  }
  let z = A8.ofPartialColumns(E9.atom_site, {
    auth_asym_id: Z.segmentName,
    auth_atom_id: Z.atomName,
    auth_comp_id: Z.residueName,
    auth_seq_id: Z.residueId,
    id: s.ofIntArray(Y),
    label_asym_id: s.ofStringArray($),
    label_atom_id: Z.atomName,
    label_comp_id: Z.residueName,
    label_seq_id: s.ofIntArray(X),
    label_entity_id: s.ofStringArray(J),
    occupancy: s.ofConst(1, Z.count, s.Schema.float),
    type_symbol: s.ofStringArray(Q),
    pdbx_PDB_model_num: s.ofConst(1, Z.count, s.Schema.int)
  }, Z.count);
  return u7({
    entity: W.getEntityTable(),
    chem_comp: K.getChemCompTable(),
    atom_site: z
  });
}
var Mr;
(function(Z) {
  function J(X) {
    return (X === null || X === void 0 ? void 0 : X.kind) === "psf";
  }
  Z.is = J;
  function $(X) {
    return { kind: "psf", name: X.id, data: X };
  }
  Z.fromPsf = $;
})(Mr || (Mr = {}));
function FD0(Z) {
  return n0.create("Parse PSF", async (J) => {
    let $ = Mr.fromPsf(Z), X = tY1(Z.atoms), { atomIdA: Y, atomIdB: Q } = Z.bonds, W = {
      indexA: s.ofLambda({
        value: (K) => Y.value(K) - 1,
        rowCount: Y.rowCount,
        schema: Y.schema
      }),
      indexB: s.ofLambda({
        value: (K) => Q.value(K) - 1,
        rowCount: Q.rowCount,
        schema: Q.schema
      }),
      order: s.ofConst(1, Z.bonds.count, s.Schema.int)
    };
    return ER.create(Z.id, X, W, $);
  });
}

// node_modules/molstar/lib/mol-script/script/mol-script/script-macro.js
function UD0(Z) {
  return Object.keys(Z).filter((J) => !isNaN(J)).map((J) => +J).sort((J, $) => J - $).map((J) => Z[J]);
}
function Bb(Z, J, $) {
  return Z && Z[J] !== void 0 ? Z[J] : $;
}

// node_modules/molstar/lib/mol-script/script/mol-script/symbols.js
function m1(Z, ...J) {
  return { kind: "alias", aliases: J, symbol: Z };
}
function wb(Z, J, ...$) {
  return Z.info.namespace = "molscript-macro", Z.id = `molscript-macro.${Z.info.name}`, { kind: "macro", symbol: Z, translate: J, aliases: [Z.info.name, ...$] };
}
function eY1(Z) {
  return Z.kind === "alias" || Z.kind === "macro";
}
var ZQ1 = [
  [
    "Core symbols",
    m1(p0.core.type.bool, "bool"),
    m1(p0.core.type.num, "num"),
    m1(p0.core.type.str, "str"),
    m1(p0.core.type.regex, "regex"),
    m1(p0.core.type.list, "list"),
    m1(p0.core.type.set, "set"),
    m1(p0.core.type.compositeKey, "composite-key"),
    m1(p0.core.logic.not, "not"),
    m1(p0.core.logic.and, "and"),
    m1(p0.core.logic.or, "or"),
    m1(p0.core.ctrl.if, "if"),
    m1(p0.core.ctrl.fn, "fn"),
    m1(p0.core.ctrl.eval, "eval"),
    m1(p0.core.math.add, "add", "+"),
    m1(p0.core.math.sub, "sub", "-"),
    m1(p0.core.math.mult, "mult", "*"),
    m1(p0.core.math.div, "div", "/"),
    m1(p0.core.math.pow, "pow", "**"),
    m1(p0.core.math.mod, "mod"),
    m1(p0.core.math.min, "min"),
    m1(p0.core.math.max, "max"),
    m1(p0.core.math.cantorPairing, "cantor-pairing"),
    m1(p0.core.math.sortedCantorPairing, "sorted-cantor-pairing"),
    m1(p0.core.math.invertCantorPairing, "invert-cantor-pairing"),
    m1(p0.core.math.floor, "floor"),
    m1(p0.core.math.ceil, "ceil"),
    m1(p0.core.math.roundInt, "round"),
    m1(p0.core.math.trunc, "trunc"),
    m1(p0.core.math.abs, "abs"),
    m1(p0.core.math.sign, "sign"),
    m1(p0.core.math.sqrt, "sqrt"),
    m1(p0.core.math.cbrt, "cbrt"),
    m1(p0.core.math.sin, "sin"),
    m1(p0.core.math.cos, "cos"),
    m1(p0.core.math.tan, "tan"),
    m1(p0.core.math.asin, "asin"),
    m1(p0.core.math.acos, "acos"),
    m1(p0.core.math.atan, "atan"),
    m1(p0.core.math.sinh, "sinh"),
    m1(p0.core.math.cosh, "cosh"),
    m1(p0.core.math.tanh, "tanh"),
    m1(p0.core.math.exp, "exp"),
    m1(p0.core.math.log, "log"),
    m1(p0.core.math.log10, "log10"),
    m1(p0.core.math.atan2, "atan2"),
    m1(p0.core.rel.eq, "eq", "="),
    m1(p0.core.rel.neq, "neq", "!="),
    m1(p0.core.rel.lt, "lt", "<"),
    m1(p0.core.rel.lte, "lte", "<="),
    m1(p0.core.rel.gr, "gr", ">"),
    m1(p0.core.rel.gre, "gre", ">="),
    m1(p0.core.rel.inRange, "in-range"),
    m1(p0.core.str.concat, "concat"),
    m1(p0.core.str.match, "regex.match"),
    m1(p0.core.list.getAt, "list.get"),
    m1(p0.core.set.has, "set.has"),
    m1(p0.core.set.isSubset, "set.subset")
  ],
  [
    "Structure",
    [
      "Types",
      m1(p0.structureQuery.type.entityType, "ent-type"),
      m1(p0.structureQuery.type.authResidueId, "auth-resid"),
      m1(p0.structureQuery.type.labelResidueId, "label-resid"),
      m1(p0.structureQuery.type.ringFingerprint, "ringfp"),
      m1(p0.structureQuery.type.bondFlags, "bond-flags")
    ],
    [
      "Slots",
      m1(p0.structureQuery.slot.elementSetReduce, "atom.set.reduce.value")
    ],
    [
      "Generators",
      m1(p0.structureQuery.generator.atomGroups, "sel.atom.atom-groups"),
      m1(p0.structureQuery.generator.queryInSelection, "sel.atom.query-in-selection"),
      m1(p0.structureQuery.generator.rings, "sel.atom.rings"),
      m1(p0.structureQuery.generator.empty, "sel.atom.empty"),
      m1(p0.structureQuery.generator.all, "sel.atom.all"),
      m1(p0.structureQuery.generator.bondedAtomicPairs, "sel.atom.bonded-pairs"),
      wb(Hz("sel.atom.atoms", r2.Dictionary({
        0: Q2(r0.Bool, { isOptional: !0, defaultValue: !0, description: "Test applied to each atom." })
      }), C2.ElementSelection, "A selection of singleton atom sets."), (Z) => L0.struct.generator.atomGroups({ "atom-test": Bb(Z, 0, !0) })),
      wb(Hz("sel.atom.res", r2.Dictionary({
        0: Q2(r0.Bool, { isOptional: !0, defaultValue: !0, description: "Test applied to the 1st atom of each residue." })
      }), C2.ElementSelection, "A selection of atom sets grouped by residue."), (Z) => L0.struct.generator.atomGroups({
        "residue-test": Bb(Z, 0, !0),
        "group-by": L0.ammp("residueKey")
      })),
      wb(Hz("sel.atom.chains", r2.Dictionary({
        0: Q2(r0.Bool, { isOptional: !0, defaultValue: !0, description: "Test applied to the 1st atom of each chain." })
      }), C2.ElementSelection, "A selection of atom sets grouped by chain."), (Z) => L0.struct.generator.atomGroups({
        "chain-test": Bb(Z, 0, !0),
        "group-by": L0.ammp("chainKey")
      }))
    ],
    [
      "Modifiers",
      m1(p0.structureQuery.modifier.queryEach, "sel.atom.query-each"),
      m1(p0.structureQuery.modifier.intersectBy, "sel.atom.intersect-by"),
      m1(p0.structureQuery.modifier.exceptBy, "sel.atom.except-by"),
      m1(p0.structureQuery.modifier.unionBy, "sel.atom.union-by"),
      m1(p0.structureQuery.modifier.union, "sel.atom.union"),
      m1(p0.structureQuery.modifier.cluster, "sel.atom.cluster"),
      m1(p0.structureQuery.modifier.includeSurroundings, "sel.atom.include-surroundings"),
      m1(p0.structureQuery.modifier.surroundingLigands, "sel.atom.surrounding-ligands"),
      m1(p0.structureQuery.modifier.includeConnected, "sel.atom.include-connected"),
      m1(p0.structureQuery.modifier.expandProperty, "sel.atom.expand-property")
    ],
    [
      "Filters",
      m1(p0.structureQuery.filter.pick, "sel.atom.pick"),
      m1(p0.structureQuery.filter.first, "sel.atom.first"),
      m1(p0.structureQuery.filter.withSameAtomProperties, "sel.atom.with-same-atom-properties"),
      m1(p0.structureQuery.filter.intersectedBy, "sel.atom.intersected-by"),
      m1(p0.structureQuery.filter.within, "sel.atom.within"),
      m1(p0.structureQuery.filter.isConnectedTo, "sel.atom.is-connected-to")
    ],
    [
      "Combinators",
      m1(p0.structureQuery.combinator.intersect, "sel.atom.intersect"),
      m1(p0.structureQuery.combinator.merge, "sel.atom.merge"),
      m1(p0.structureQuery.combinator.distanceCluster, "sel.atom.dist-cluster")
    ],
    [
      "Atom Set Properties",
      m1(p0.structureQuery.atomSet.atomCount, "atom.set.atom-count"),
      m1(p0.structureQuery.atomSet.countQuery, "atom.set.count-query"),
      m1(p0.structureQuery.atomSet.reduce, "atom.set.reduce"),
      m1(p0.structureQuery.atomSet.propertySet, "atom.set.property")
    ],
    [
      "Atom Properties",
      m1(p0.structureQuery.atomProperty.core.elementSymbol, "atom.el"),
      m1(p0.structureQuery.atomProperty.core.vdw, "atom.vdw"),
      m1(p0.structureQuery.atomProperty.core.mass, "atom.mass"),
      m1(p0.structureQuery.atomProperty.core.atomicNumber, "atom.atomic-number"),
      m1(p0.structureQuery.atomProperty.core.x, "atom.x"),
      m1(p0.structureQuery.atomProperty.core.y, "atom.y"),
      m1(p0.structureQuery.atomProperty.core.z, "atom.z"),
      m1(p0.structureQuery.atomProperty.core.sourceIndex, "atom.src-index"),
      m1(p0.structureQuery.atomProperty.core.operatorName, "atom.op-name"),
      m1(p0.structureQuery.atomProperty.core.instanceId, "atom.instance-id"),
      m1(p0.structureQuery.atomProperty.core.operatorKey, "atom.op-key"),
      m1(p0.structureQuery.atomProperty.core.modelIndex, "atom.model-index"),
      m1(p0.structureQuery.atomProperty.core.modelLabel, "atom.model-label"),
      m1(p0.structureQuery.atomProperty.core.modelEntryId, "atom.model-entry-id"),
      m1(p0.structureQuery.atomProperty.core.atomKey, "atom.key"),
      m1(p0.structureQuery.atomProperty.core.bondCount, "atom.bond-count"),
      m1(p0.structureQuery.atomProperty.topology.connectedComponentKey, "atom.key.molecule"),
      m1(p0.structureQuery.atomProperty.macromolecular.authResidueId, "atom.auth-resid"),
      m1(p0.structureQuery.atomProperty.macromolecular.labelResidueId, "atom.label-resid"),
      m1(p0.structureQuery.atomProperty.macromolecular.residueKey, "atom.key.res"),
      m1(p0.structureQuery.atomProperty.macromolecular.chainKey, "atom.key.chain"),
      m1(p0.structureQuery.atomProperty.macromolecular.entityKey, "atom.key.entity"),
      m1(p0.structureQuery.atomProperty.macromolecular.isHet, "atom.is-het"),
      m1(p0.structureQuery.atomProperty.macromolecular.id, "atom.id"),
      m1(p0.structureQuery.atomProperty.macromolecular.label_atom_id, "atom.label_atom_id"),
      m1(p0.structureQuery.atomProperty.macromolecular.label_alt_id, "atom.label_alt_id", "atom.altloc"),
      m1(p0.structureQuery.atomProperty.macromolecular.label_comp_id, "atom.label_comp_id"),
      m1(p0.structureQuery.atomProperty.macromolecular.label_asym_id, "atom.label_asym_id"),
      m1(p0.structureQuery.atomProperty.macromolecular.label_entity_id, "atom.label_entity_id"),
      m1(p0.structureQuery.atomProperty.macromolecular.label_seq_id, "atom.label_seq_id"),
      m1(p0.structureQuery.atomProperty.macromolecular.auth_atom_id, "atom.auth_atom_id", "atom.name"),
      m1(p0.structureQuery.atomProperty.macromolecular.auth_comp_id, "atom.auth_comp_id", "atom.resname"),
      m1(p0.structureQuery.atomProperty.macromolecular.auth_asym_id, "atom.auth_asym_id", "atom.chain"),
      m1(p0.structureQuery.atomProperty.macromolecular.auth_seq_id, "atom.auth_seq_id", "atom.resno"),
      m1(p0.structureQuery.atomProperty.macromolecular.pdbx_PDB_ins_code, "atom.pdbx_PDB_ins_code", "atom.inscode"),
      m1(p0.structureQuery.atomProperty.macromolecular.pdbx_formal_charge, "atom.pdbx_formal_charge"),
      m1(p0.structureQuery.atomProperty.macromolecular.occupancy, "atom.occupancy"),
      m1(p0.structureQuery.atomProperty.macromolecular.B_iso_or_equiv, "atom.B_iso_or_equiv", "atom.bfactor"),
      m1(p0.structureQuery.atomProperty.macromolecular.entityType, "atom.entity-type"),
      m1(p0.structureQuery.atomProperty.macromolecular.entitySubtype, "atom.entity-subtype"),
      m1(p0.structureQuery.atomProperty.macromolecular.entityPrdId, "atom.entity-prd-id"),
      m1(p0.structureQuery.atomProperty.macromolecular.entityDescription, "atom.entity-description"),
      m1(p0.structureQuery.atomProperty.macromolecular.objectPrimitive, "atom.object-primitive"),
      m1(p0.structureQuery.atomProperty.macromolecular.chemCompType, "atom.chem-comp-type"),
      m1(p0.structureQuery.atomProperty.macromolecular.secondaryStructureKey, "atom.key.sec-struct"),
      m1(p0.structureQuery.atomProperty.macromolecular.isModified, "atom.is-modified"),
      m1(p0.structureQuery.atomProperty.macromolecular.modifiedParentName, "atom.modified-parent"),
      m1(p0.structureQuery.atomProperty.ihm.hasSeqId, "atom.ihm.has-seq-id"),
      m1(p0.structureQuery.atomProperty.ihm.overlapsSeqIdRange, "atom.ihm.overlaps-seq-id-range")
    ],
    [
      "Bond Properties",
      m1(p0.structureQuery.bondProperty.order, "bond.order"),
      m1(p0.structureQuery.bondProperty.length, "bond.length"),
      m1(p0.structureQuery.bondProperty.key, "bond.key"),
      m1(p0.structureQuery.bondProperty.atomA, "bond.atom-a"),
      m1(p0.structureQuery.bondProperty.atomB, "bond.atom-b"),
      wb(Hz("bond.is", r2.List(C2.BondFlag), r0.Bool, `Test if the current bond has at least one (or all if partial = false) of the specified flags: ${r0.oneOfValues(C2.BondFlag).join(", ")}`), (Z) => L0.core.flags.hasAny([L0.struct.bondProperty.flags(), L0.struct.type.bondFlags(UD0(Z))]))
    ]
  ]
], LD0 = [];
function RD0(Z) {
  for (let J of Z)
    if (eY1(J))
      LD0.push(J);
    else if (J instanceof Array)
      RD0(J);
}
RD0(ZQ1);
var jb = function() {
  let Z = [], J = Object.create(null), $ = o6.create(), X = o6.create();
  for (let Y of LD0) {
    for (let W of Y.aliases) {
      if (Z.push([W, Y]), J[W])
        throw new Error(`Alias '${W}' already in use.`);
      J[W] = Y;
    }
    let Q = Y.symbol.args;
    if (Q.kind !== "dictionary") {
      if (Q.type.kind === "oneof")
        r0.oneOfValues(Q.type).forEach((W) => o6.add(X, W, W));
      continue;
    }
    for (let W of Object.keys(Q.map)) {
      if (isNaN(W))
        o6.add($, W, W);
      let K = Q.map[W];
      if (K.type.kind === "oneof")
        r0.oneOfValues(K.type).forEach((G) => o6.add(X, G, G));
    }
  }
  return { symbolList: Z, symbolMap: J, namedArgs: $.array, constants: X.array };
}();
var { constants: cT2, namedArgs: lT2, symbolMap: jA, symbolList: nT2 } = jb;
function MV(Z) {
  if (VJ.isLiteral(Z))
    return Z;
  if (VJ.isSymbol(Z)) {
    if (!jA[Z.name])
      return Z;
    let W = jA[Z.name];
    if (W.kind === "alias")
      return VJ.Symbol(jA[Z.name].symbol.id);
    throw W.translate([]);
  }
  let J = VJ.isSymbol(Z.head) && !!jA[Z.head.name] && jA[Z.head.name].kind === "macro", $ = J ? Z.head : MV(Z.head), X = $ !== Z.head;
  if (!Z.args) {
    if (J)
      return MV(Z.head);
    return X ? VJ.Apply($) : Z;
  }
  let Y = !1, Q;
  if (VJ.isArgumentsArray(Z.args)) {
    Q = [];
    for (let W = 0, K = Z.args.length;W < K; W++) {
      let G = Z.args[W], H = MV(G);
      if (G !== H)
        Y = !0;
      Q[Q.length] = H;
    }
    if (!Y)
      Q = Z.args;
    if (!J && !X && !Y)
      return Z;
  } else {
    Q = {};
    for (let W of Object.keys(Z.args)) {
      let K = Z.args[W], G = MV(K);
      if (K !== G)
        Y = !0;
      Q[W] = G;
    }
    if (!J && !X && !Y)
      return Z;
    if (!Y)
      Q = Z.args;
  }
  if (J) {
    let W = jA[Z.head.name];
    if (W.kind !== "macro")
      return VJ.Apply($, Q);
    return W.translate(Q);
  }
  return VJ.Apply($, Q);
}
function ED0(Z) {
  return MV(Z);
}

// node_modules/molstar/lib/mol-util/monadic-parser.js
class N1 {
  constructor(Z) {
    this._ = Z;
  }
  parse(Z) {
    let J = this.skip(N1.eof)._(Z, 0);
    if (J.status)
      return { success: !0, value: J.value };
    return { success: !1, index: OD0(Z, J.furthest), expected: J.expected };
  }
  tryParse(Z) {
    let J = this.parse(Z);
    if (J.success)
      return J.value;
    else {
      let $ = XQ1(Z, J);
      throw new Error($);
    }
  }
  or(Z) {
    return N1.alt(this, Z);
  }
  trim(Z) {
    return this.wrap(Z, Z);
  }
  wrap(Z, J) {
    return Ar(1, typeof Z === "string" ? N1.string(Z) : Z, this, typeof J === "string" ? N1.string(J) : J);
  }
  thru(Z) {
    return Z(this);
  }
  then(Z) {
    return Ar(1, this, Z);
  }
  many() {
    return new N1((Z, J) => {
      let $ = [], X = void 0;
      while (!0)
        if (X = b3(this._(Z, J), X), X.status) {
          if (J === X.index)
            throw new Error("infinite loop detected in .many() parser --- calling .many() on a parser which can accept zero characters is usually the cause");
          J = X.index, $.push(X.value);
        } else
          return b3(lQ(J, $), X);
    });
  }
  times(Z, J) {
    let $ = typeof J === "undefined" ? Z : J;
    return new N1((X, Y) => {
      let Q = [], W = void 0, K = void 0, G;
      for (G = 0;G < Z; G++)
        if (W = this._(X, Y), K = b3(W, K), W.status)
          Y = W.index, Q.push(W.value);
        else
          return K;
      for (;G < $; G += 1)
        if (W = this._(X, Y), K = b3(W, K), W.status)
          Y = W.index, Q.push(W.value);
        else
          break;
      return b3(lQ(Y, Q), K);
    });
  }
  result(Z) {
    return this.map(() => Z);
  }
  atMost(Z) {
    return this.times(0, Z);
  }
  atLeast(Z) {
    return N1.seq(this.times(Z), this.many()).map((J) => [...J[0], ...J[1]]);
  }
  map(Z) {
    return new N1((J, $) => {
      let X = this._(J, $);
      if (!X.status)
        return X;
      return b3(lQ(X.index, Z(X.value)), X);
    });
  }
  skip(Z) {
    return Ar(0, this, Z);
  }
  mark() {
    return N1.seq(N1.index, this, N1.index).map((Z) => ({ start: Z[0], value: Z[1], end: Z[2] }));
  }
  node(Z) {
    return N1.seq(N1.index, this, N1.index).map((J) => ({ name: Z, start: J[0], value: J[1], end: J[2] }));
  }
  sepBy(Z) {
    return N1.sepBy(this, Z);
  }
  sepBy1(Z) {
    return N1.sepBy1(this, Z);
  }
  lookahead(Z) {
    return this.skip(N1.lookahead(Z));
  }
  notFollowedBy(Z) {
    return this.skip(N1.notFollowedBy(Z));
  }
  desc(Z) {
    return new N1((J, $) => {
      let X = this._(J, $);
      if (!X.status)
        X.expected = [Z];
      return X;
    });
  }
  fallback(Z) {
    return this.or(N1.succeed(Z));
  }
  ap(Z) {
    return N1.seq(Z, this).map(([J, $]) => J($));
  }
  chain(Z) {
    return new N1((J, $) => {
      let X = this._(J, $);
      if (!X.status)
        return X;
      let Y = Z(X.value);
      return b3(Y._(J, X.index), X);
    });
  }
}
(function(Z) {
  function J(I, S, f) {
    let v = [].slice.call(arguments);
    if (v.length === 0)
      throw new Error("seqMap needs at least one argument");
    let h = v.pop();
    return WQ1(h), X.apply(null, v).map(function(x) {
      return h.apply(null, x);
    });
  }
  Z.seqMap = J;
  function $(I) {
    let S = {};
    for (let f of Object.keys(I))
      (function(v) {
        S[v] = T(() => I[v](S));
      })(f);
    return S;
  }
  Z.createLanguage = $;
  function X(...I) {
    let S = I.length;
    return new Z((f, v) => {
      let h, x = new Array(S), b = v;
      for (let g = 0;g < S; g++) {
        if (h = b3(I[g]._(f, b), h), !h.status)
          return h;
        x[g] = h.value, b = h.index;
      }
      return b3(lQ(b, x), h);
    });
  }
  Z.seq = X;
  function Y(...I) {
    if (I.length === 0)
      return U("zero alternates");
    return new Z((f, v) => {
      let h;
      for (let x = 0;x < I.length; x++)
        if (h = b3(I[x]._(f, v), h), h.status)
          return h;
      return h;
    });
  }
  Z.alt = Y;
  function Q(I, S) {
    return W(I, S).or(q([]));
  }
  Z.sepBy = Q;
  function W(I, S) {
    let f = S.then(I).many();
    return X(I, f).map((v) => [v[0], ...v[1]]);
  }
  Z.sepBy1 = W;
  function K(I) {
    let S = `'${I}'`;
    if (I.length === 1) {
      let f = I.charCodeAt(0);
      return new Z((v, h) => v.charCodeAt(h) === f ? lQ(h + 1, I) : YU(h, S));
    }
    return new Z((f, v) => {
      let h = v + I.length;
      if (f.slice(v, h) === I)
        return lQ(h, I);
      else
        return YU(v, S);
    });
  }
  Z.string = K;
  function G(I) {
    let S = "" + I;
    return S.slice(S.lastIndexOf("/") + 1);
  }
  function H(I) {
    return RegExp("^(?:" + I.source + ")", G(I));
  }
  function N(I, S = 0) {
    let f = H(I), v = "" + I;
    return new Z((h, x) => {
      let b = f.exec(h.slice(x));
      if (b) {
        if (0 <= S && S <= b.length) {
          let m = b[0], i = b[S];
          return lQ(x + m.length, i);
        }
        let g = `invalid match group (0 to ${b.length}) in ${v}`;
        return YU(x, g);
      }
      return YU(x, v);
    });
  }
  Z.regexp = N;
  function q(I) {
    return new Z((S, f) => lQ(f, I));
  }
  Z.succeed = q;
  function U(I) {
    return new Z((S, f) => YU(f, I));
  }
  Z.fail = U;
  function F(I) {
    if (QQ1(I))
      return new Z((S, f) => {
        let v = I._(S, f);
        if (v.status)
          v.index = f, v.value = null;
        return v;
      });
    else if (typeof I === "string")
      return F(K(I));
    else if (I instanceof RegExp)
      return F(N(I));
    throw new Error("not a string, regexp, or parser: " + I);
  }
  Z.lookahead = F;
  function E(I) {
    return new Z((S, f) => {
      let v = I._(S, f);
      return v.status ? YU(f, 'not "' + S.slice(f, v.index) + '"') : lQ(f, null);
    });
  }
  Z.notFollowedBy = E;
  function R(I) {
    return new Z((S, f) => {
      let v = S.charAt(f);
      if (f < S.length && I(v))
        return lQ(f + 1, v);
      else
        return YU(f, "a character " + I);
    });
  }
  Z.test = R;
  function z(I) {
    return R((S) => I.indexOf(S) >= 0);
  }
  Z.oneOf = z;
  function D(I) {
    return R((S) => I.indexOf(S) < 0);
  }
  Z.noneOf = D;
  function A(I, S) {
    return R((f) => I <= f && f <= S).desc(I + "-" + S);
  }
  Z.range = A;
  function B(I) {
    return new Z((S, f) => {
      let v = f;
      while (v < S.length && I(S.charAt(v)))
        v++;
      return lQ(v, S.slice(f, v));
    });
  }
  Z.takeWhile = B;
  function T(I) {
    let S = new Z((f, v) => {
      let h = I()._;
      return S._ = h, h(f, v);
    });
    return S;
  }
  Z.lazy = T;
  function w() {
    return U("empty");
  }
  Z.empty = w, Z.index = new Z(function(I, S) {
    return lQ(S, OD0(I, S));
  }), Z.anyChar = new Z((I, S) => {
    if (S >= I.length)
      return YU(S, "any character");
    return lQ(S + 1, I.charAt(S));
  }), Z.all = new Z(function(I, S) {
    return lQ(I.length, I.slice(S));
  }), Z.eof = new Z(function(I, S) {
    if (S < I.length)
      return YU(S, "EOF");
    return lQ(S, null);
  }), Z.digit = N(/[0-9]/).desc("a digit"), Z.digits = N(/[0-9]*/).desc("optional digits"), Z.letter = N(/[a-z]/i).desc("a letter"), Z.letters = N(/[a-z]*/i).desc("optional letters"), Z.optWhitespace = N(/\s*/).desc("optional whitespace"), Z.whitespace = N(/\s+/).desc("whitespace"), Z.cr = K("\r"), Z.lf = K(`
`), Z.crlf = K(`\r
`), Z.newline = Y(Z.crlf, Z.lf, Z.cr).desc("newline"), Z.end = Y(Z.newline, Z.eof);
  function V(I) {
    return q(I);
  }
  Z.of = V;
  function P(I) {
    return N(I);
  }
  Z.regex = P;
})(N1 || (N1 = {}));
function Ar(Z, ...J) {
  let $ = J.length;
  return new N1((X, Y) => {
    let Q, W, K = Y;
    for (let G = 0;G < $; G++) {
      if (Q = b3(J[G]._(X, K), Q), !Q.status)
        return Q;
      if (Z === G)
        W = Q.value;
      K = Q.index;
    }
    return b3(lQ(K, W), Q);
  });
}
function lQ(Z, J) {
  return { status: !0, index: Z, value: J };
}
function YU(Z, J) {
  return { status: !1, furthest: Z, expected: [J] };
}
function b3(Z, J) {
  if (!J || Z.status || J.status || Z.furthest > J.furthest)
    return Z;
  let $ = Z.furthest === J.furthest ? YQ1(Z.expected, J.expected) : J.expected;
  return { status: Z.status, furthest: J.furthest, expected: $ };
}
function OD0(Z, J) {
  let $ = Z.slice(0, J).split(`
`), X = $.length, Y = $[$.length - 1].length + 1;
  return { offset: J, line: X, column: Y };
}
function JQ1(Z) {
  if (Z.length === 1)
    return Z[0];
  return "one of " + Z.join(", ");
}
function $Q1(Z, J) {
  let $ = J.index, X = $.offset;
  if (X === Z.length)
    return ", got the end of the input";
  let Y = X > 0 ? "'..." : "'", Q = Z.length - X > 12 ? "...'" : "'";
  return ` at line ${$.line} column ${$.column}, got ${Y}${Z.slice(X, X + 12)}${Q}`;
}
function XQ1(Z, J) {
  return `expected ${JQ1(J.expected)}${$Q1(Z, J)}`;
}
function YQ1(Z, J) {
  let $ = Z.length, X = J.length;
  if ($ === 0)
    return J;
  else if (X === 0)
    return Z;
  let Y = /* @__PURE__ */ new Set, Q = [];
  for (let W = 0;W < $; W++)
    if (!Y.has(Z[W]))
      Q[Q.length] = Z[W], Y.add(Z[W]);
  for (let W = 0;W < X; W++)
    if (!Y.has(J[W]))
      Q[Q.length] = J[W], Y.add(J[W]);
  return Q.sort(), Q;
}
function QQ1(Z) {
  return Z instanceof N1;
}
function WQ1(Z) {
  if (typeof Z !== "function")
    throw new Error("not a function: " + Z);
}

// node_modules/molstar/lib/mol-script/language/parser.js
function zD0(Z) {
  return Br.parse(Z);
}
var Br;
(function(Z) {
  let J;
  (function(T) {
    function w(S) {
      return { kind: "string", value: S };
    }
    T.str = w;
    function V(S) {
      return { kind: "symbol", value: S };
    }
    T.symb = V;
    function P(S, f) {
      return { kind: "list", bracket: S, nodes: f };
    }
    T.list = P;
    function I(S) {
      return { kind: "comment", value: S };
    }
    T.comment = I;
  })(J || (J = {}));
  let $ = N1.regexp(/[\n\r\s]*/), X = N1.lazy(() => N1.alt(Y, q, Q, W).trim($)), Y = N1.takeWhile((T) => T !== "`").trim("`").map(J.str), Q = N1.regexp(/[^()\[\]{};`,\n\r\s]+/).map(J.symb), W = N1.regexp(/\s*;+([^\n\r]*)\n/, 1).map(J.comment), K = X.many(), G = K.wrap("(", ")").map((T) => J.list("(", T)), H = K.wrap("[", "]").map((T) => J.list("[", T)), N = K.wrap("{", "}").map((T) => J.list("{", T)), q = N1.alt(G, H, N), U = X.many();
  function F(T) {
    return U.tryParse(T);
  }
  function E(T) {
    switch (T.kind) {
      case "string":
        return T.value;
      case "symbol": {
        let w = T.value;
        if (w.length > 1)
          switch (w.charAt(0)) {
            case ".":
              return L0.atomName(w.substr(1));
            case "_":
              return L0.struct.type.elementSymbol([w.substr(1)]);
          }
        if (w === "true")
          return !0;
        if (w === "false")
          return !1;
        if (A(w))
          return +w;
        return VJ.Symbol(w);
      }
      case "list":
        switch (T.bracket) {
          case "[":
            return L0.core.type.list(D(T.nodes).map(E));
          case "{":
            return L0.core.type.set(D(T.nodes).map(E));
          case "(": {
            if (T.nodes[0].kind === "comment")
              throw new Error("Invalid expression");
            let w = E(T.nodes[0]);
            return VJ.Apply(w, R(T.nodes));
          }
          default:
            T8(T.bracket);
        }
      default:
        T8(T);
    }
  }
  function R(T) {
    if (T.length <= 1)
      return;
    if (!z(T)) {
      let I = [];
      for (let S = 1, f = T.length;S < f; S++) {
        let v = T[S];
        if (v.kind === "comment")
          continue;
        I[I.length] = E(v);
      }
      return I;
    }
    let w = {}, V = !0, P = 0;
    for (let I = 1, S = T.length;I < S; I++) {
      let f = T[I];
      if (f.kind === "comment")
        continue;
      if (f.kind === "symbol" && f.value.length > 1 && f.value.charAt(0) === ":") {
        let v = f.value.substr(1);
        ++I;
        while (I < S && T[I].kind === "comment")
          I++;
        if (I >= S)
          throw new Error(`There must be a value foolowed a named arg ':${v}'.`);
        if (T[I].kind === "comment")
          throw new Error("Invalid expression");
        if (w[v] = E(T[I]), isNaN(+v))
          V = !1;
      } else
        w[P++] = E(f);
    }
    if (V) {
      let I = Object.keys(w).map((f) => +f).sort((f, v) => f - v), S = !0;
      for (let f = 0, v = I.length;f < v; f++)
        if (I[f] !== f) {
          S = !1;
          break;
        }
      if (S) {
        let f = [];
        for (let v = 0, h = I.length;v < h; v++)
          f[v] = w[v];
        return f;
      }
    }
    return w;
  }
  function z(T) {
    for (let w = 1, V = T.length;w < V; w++) {
      let P = T[w];
      if (P.kind === "symbol" && P.value.length > 1 && P.value.charAt(0) === ":")
        return !0;
    }
    return !1;
  }
  function D(T) {
    let w = !1;
    for (let V = 0, P = T.length;V < P; V++)
      if (T[V].kind === "comment") {
        w = !0;
        break;
      }
    if (!w)
      return T;
    return T.filter((V) => V.kind !== "comment");
  }
  function A(T) {
    return /-?(0|[1-9][0-9]*)([.][0-9]+)?([eE][+-]?[0-9]+)?/.test(T) && !isNaN(+T);
  }
  function B(T) {
    let w = F(T), V = [];
    for (let P of w) {
      if (P.kind === "comment")
        continue;
      V[V.length] = E(P);
    }
    return V;
  }
  Z.parse = B;
})(Br || (Br = {}));

// node_modules/molstar/lib/mol-script/transpilers/helper.js
var r9 = L0;
function dX(Z, J, $) {
  let X = N1.lazy(() => {
    return N1.seq(Z, X).map((Y) => $(...Y)).or(J);
  });
  return X;
}
function AV(Z, J, $) {
  return N1.seqMap(J, Z.many(), (X, Y) => Y.reduce((Q, W) => {
    return $(W, Q);
  }, X));
}
function QX(Z, J, $) {
  return N1.seqMap(J, N1.seq(Z, J).many(), (X, Y) => {
    return Y.reduce((Q, W) => {
      let [K, G] = W;
      return $(K, Q, G);
    }, X);
  });
}
function xR(Z, J) {
  return Z.reduce((X, Y) => {
    let Q = Y.isUnsupported ? QU(`operator '${Y.name}' not supported`) : Y.map;
    return Y.type(Y.rule, X, Q);
  }, J);
}
function x3(Z, J = 0) {
  return N1.optWhitespace.then(N1.regexp(Z, J).skip(N1.optWhitespace));
}
function yW(Z, J = 0) {
  return N1.regexp(Z, J).skip(N1.optWhitespace);
}
function BV(Z, J = 0) {
  return N1.optWhitespace.then(N1.regexp(Z, J));
}
function Tb(Z, J) {
  let $ = J ? `${Z}|${IF(J)}` : Z, X = RegExp(`(${$})\\s+([-+]?[0-9]*\\.?[0-9]+)\\s+OF`, "i");
  return x3(X, 2).map(parseFloat);
}
function QU(Z) {
  return function() {
    throw new Error(Z);
  };
}
function wV(Z) {
  if (Z.length === 1)
    return Z[0];
  else if (Z.length > 1)
    return r9.core.logic.and(Z);
  else
    return;
}
function MD0(Z) {
  if (Z.length === 1)
    return Z[0];
  else if (Z.length > 1)
    return r9.core.logic.or(Z);
  else
    return;
}
function wr(Z, J) {
  if (J && J.op !== void 0 && J.val !== void 0) {
    let $ = [Z, J.val];
    switch (J.op) {
      case "=":
        return r9.core.rel.eq($);
      case "!=":
        return r9.core.rel.neq($);
      case ">":
        return r9.core.rel.gr($);
      case "<":
        return r9.core.rel.lt($);
      case ">=":
        return r9.core.rel.gre($);
      case "<=":
        return r9.core.rel.lte($);
      default:
        throw new Error(`operator '${J.op}' not supported`);
    }
  } else if (J && J.flags !== void 0)
    return r9.core.flags.hasAny([Z, J.flags]);
  else if (J && J.min !== void 0 && J.max !== void 0)
    return r9.core.rel.inRange([Z, J.min, J.max]);
  else if (!Array.isArray(J))
    return r9.core.rel.eq([Z, J]);
  else if (J.length > 1)
    return r9.core.set.has([r9.core.type.set(J), Z]);
  else
    return r9.core.rel.eq([Z, J[0]]);
}
function IY(Z) {
  return r9.struct.generator.queryInSelection({
    0: Z,
    query: r9.struct.generator.all(),
    "in-complement": !0
  });
}
function P5(Z, J) {
  return Z.length < J.length ? 1 : -1;
}
function jr(Z, J) {
  let $ = (J ? [Z].concat(J) : [Z]).sort(P5).map(IF).join("|");
  return RegExp(`${$}`, "i");
}
function AD0(Z) {
  let J = {};
  return Object.keys(Z).sort(P5).forEach(($) => {
    let X = Z[$], Y = QU(`property '${$}' not supported`), Q = N1.regexp(X.regex).map((W) => {
      if (X.isUnsupported)
        Y();
      return wr(X.property, X.map(W));
    });
    if (!X.isNumeric)
      J[$] = Q;
  }), J;
}
function _b(Z) {
  let J = [];
  return Object.keys(Z).sort(P5).forEach(($) => {
    let X = Z[$], Y = QU(`property '${$}' not supported`), Q = N1.regexp(X.regex).map((G) => {
      if (X.isUnsupported)
        Y();
      return wr(X.property, X.map(G));
    }), W = N1.regexp(jr($, X.abbr)).trim(N1.optWhitespace), K = (G) => r9.struct.generator.atomGroups({ [X.level]: G });
    if (X.isNumeric)
      J.push(W.then(N1.seq(N1.regexp(/>=|<=|=|!=|>|</).trim(N1.optWhitespace), N1.regexp(X.regex).map(X.map))).map((G) => {
        if (X.isUnsupported)
          Y();
        return wr(X.property, { op: G[0], val: G[1] });
      }).map(K));
    else
      J.push(W.then(Q).map(K));
  }), J;
}
function TA(Z) {
  let J = [];
  return Object.keys(Z).sort(P5).forEach(($) => {
    let X = Z[$], Y = X.map ? X.map : QU(`keyword '${$}' not supported`), Q = N1.regexp(jr($, X.abbr)).map(Y);
    J.push(Q);
  }), J;
}
function BD0(Z, J) {
  let $ = [], X = N1.regexp(/\(\s*/), Y = N1.regexp(/\s*\)/);
  return Object.keys(Z).sort(P5).forEach((Q) => {
    let W = Z[Q], K = W.map ? W.map : QU(`function '${Q}' not supported`), G = N1.regexp(new RegExp(Q, "i")).skip(X).then(J).skip(Y).map(K);
    $.push(G);
  }), $;
}
function jV(Z, J) {
  let $ = [];
  return Object.keys(Z).sort(P5).forEach((X) => {
    let Y = Z[X], Q = QU(`property '${X}' not supported`), W = N1.regexp(jr(X, Y.abbr)).lookahead(J).map(() => {
      if (Y.isUnsupported)
        Q();
      return Y.property;
    });
    $.push(W);
  }), $;
}
function _A(Z, J, $, X) {
  let Y = [];
  for (let Q in Z)
    if (Y.push(Q), Z[Q].abbr)
      Y.push(...Z[Q].abbr);
  for (let Q in J)
    if (Y.push(Q), J[Q].abbr)
      Y.push(...J[Q].abbr);
  return $.forEach((Q) => {
    if (Y.push(Q.name), Q.abbr)
      Y.push(...Q.abbr);
  }), Y;
}
function IK(Z) {
  return r9.core.type.set(Z.map(r9.atomName));
}
function PK(Z) {
  return r9.struct.generator.queryInSelection({
    0: Z,
    query: r9.struct.generator.all()
  });
}
function _z(Z, J, $) {
  switch (Z.head.name) {
    case "structure-query.atom-property.macromolecular.label_atom_id":
      return r9.atomName(J);
    case "structure-query.atom-property.core.element-symbol":
      return r9.es(J);
    case "structure-query.atom-property.macromolecular.secondary-structure-flags":
      if ($)
        J = [$[J.toUpperCase()] || "none"];
      return r9.struct.type.secondaryStructureFlags([J]);
    default:
      return J;
  }
}
var DD0 = "structure-query.atom-property.macromolecular.", KQ1 = ["entityKey", "label_entity_id", "entityType"], GQ1 = ["chainKey", "label_asym_id", "label_entity_id", "auth_asym_id", "entityType"], HQ1 = ["residueKey", "label_comp_id", "label_seq_id", "auth_comp_id", "auth_seq_id", "pdbx_formal_charge", "secondaryStructureKey", "secondaryStructureFlags", "isModified", "modifiedParentName"];
function wD0(Z) {
  if (Z.head.name.startsWith(DD0)) {
    let J = Z.head.name.substr(DD0.length);
    if (KQ1.includes(J))
      return "entity-test";
    if (GQ1.includes(J))
      return "chain-test";
    if (HQ1.includes(J))
      return "residue-test";
  }
  return "atom-test";
}
var NQ1 = [
  "structure-query.atom-property.macromolecular.secondary-structure-flags"
];
function jD0(Z, J) {
  if (NQ1.includes(Z.head.name)) {
    let $ = J[0].head, X = [];
    return J.forEach((Y) => X.push(...Y.args[0])), r9.core.flags.hasAny([Z, { head: $, args: X }]);
  } else if (J.length === 1)
    return r9.core.rel.eq([Z, J[0]]);
  else if (J.length > 1)
    return r9.core.set.has([r9.core.type.set(J), Z]);
}
function DZ(Z) {
  return r9.struct.generator.atomGroups({
    "residue-test": r9.core.set.has([
      r9.core.type.set(Z),
      r9.ammp("label_comp_id")
    ])
  });
}

// node_modules/molstar/lib/mol-script/transpilers/jmol/properties.js
var sJ = L0, y3 = /[-+]?[0-9]*\.?[0-9]+/, TV = /[0-9]+/;
function P8(Z) {
  return Z;
}
var qQ1 = {
  none: "none",
  turn: "turn",
  sheet: "beta",
  helix: "helix",
  dna: "dna",
  rna: "rna",
  carbohydrate: "carbohydrate",
  helix310: "3-10",
  helixalpha: "alpha",
  helixpi: "pi",
  0: "none",
  1: "turn",
  2: "beta",
  3: "helix",
  4: "dna",
  5: "rna",
  6: "carbohydrate",
  7: "3-10",
  8: "alpha",
  9: "pi"
};
function Tr(Z) {
  if (Z.head) {
    if (Z.head.name && Z.head.name === "core.type.regex")
      Z = Z.args[0].replace(/^\^|\$$/g, "");
    if (Z = qQ1[Z.toString().toLowerCase()] || "none", ["dna", "rna", "carbohydrate"].indexOf(Z) !== -1)
      throw new Error("values 'dna', 'rna', 'carbohydrate' not yet supported for 'structure' property");
    else
      return sJ.struct.type.secondaryStructureFlags([Z]);
  }
}
var _r = {
  adpmax: {
    "@desc": "the maximum anisotropic displacement parameter for the selected atom",
    "@examples": [""],
    isUnsupported: !0,
    regex: y3,
    map: (Z) => parseFloat(Z),
    level: "atom-test"
  },
  adpmin: {
    "@desc": "the minimum anisotropic displacement parameter for the selected atom",
    "@examples": [""],
    isUnsupported: !0,
    regex: y3,
    map: (Z) => parseFloat(Z),
    level: "atom-test"
  },
  altloc: {
    "@desc": "PDB alternate location identifier",
    "@examples": ["altloc = A"],
    regex: /[a-zA-Z0-9]/,
    map: P8,
    level: "atom-test",
    property: sJ.ammp("label_alt_id")
  },
  altname: {
    "@desc": "an alternative name given to atoms by some file readers (for example, P2N)",
    "@examples": [""],
    isUnsupported: !0,
    regex: /[a-zA-Z0-9]/,
    map: P8,
    level: "atom-test"
  },
  atomID: {
    "@desc": "special atom IDs for PDB atoms assigned by Jmol",
    "@examples": [""],
    isUnsupported: !0,
    regex: TV,
    map: (Z) => parseInt(Z),
    level: "atom-test"
  },
  atomIndex: {
    "@desc": "atom 0-based index; a unique number for each atom regardless of the number of models loaded",
    "@examples": [""],
    isUnsupported: !0,
    regex: TV,
    map: (Z) => parseInt(Z),
    level: "atom-test"
  },
  atomName: {
    "@desc": "atom name",
    "@examples": ["atomName = CA"],
    regex: /[a-zA-Z0-9]+/,
    map: (Z) => sJ.atomName(Z),
    level: "atom-test",
    property: sJ.ammp("label_atom_id")
  },
  atomno: {
    "@desc": 'sequential number; you can use "@" instead of "atomno=" -- for example, select @33 or Var x = @33 or @35',
    "@examples": [""],
    isUnsupported: !0,
    regex: TV,
    map: (Z) => parseInt(Z),
    level: "atom-test"
  },
  atomType: {
    "@desc": "atom type (mol2, AMBER files) or atom name (other file types)",
    "@examples": ["atomType = OH"],
    regex: /[a-zA-Z0-9]+/,
    map: (Z) => sJ.atomName(Z),
    level: "atom-test",
    property: sJ.ammp("label_atom_id")
  },
  atomX: {
    "@desc": "Cartesian X coordinate (or just X)",
    "@examples": ["x = 4.2"],
    abbr: ["X"],
    isNumeric: !0,
    regex: y3,
    map: (Z) => parseFloat(Z),
    level: "atom-test",
    property: sJ.acp("x")
  },
  atomY: {
    "@desc": "Cartesian Y coordinate (or just Y)",
    "@examples": ["y < 42"],
    abbr: ["Y"],
    isNumeric: !0,
    regex: y3,
    map: (Z) => parseFloat(Z),
    level: "atom-test",
    property: sJ.acp("y")
  },
  atomZ: {
    "@desc": "Cartesian Z coordinate (or just Z)",
    "@examples": ["Z > 10"],
    abbr: ["Z"],
    isNumeric: !0,
    regex: y3,
    map: (Z) => parseFloat(Z),
    level: "atom-test",
    property: sJ.acp("z")
  },
  bondcount: {
    "@desc": "covalent bond count",
    "@examples": ["bondcount = 0"],
    isNumeric: !0,
    regex: TV,
    map: (Z) => parseInt(Z),
    level: "atom-test",
    property: sJ.acp("bondCount")
  },
  bondingRadius: {
    "@desc": "radius used for auto bonding; synonymous with ionic and ionicRadius",
    "@examples": [""],
    abbr: ["ionic", "ionicRadius"],
    isUnsupported: !0,
    regex: y3,
    map: (Z) => parseFloat(Z),
    level: "atom-test"
  },
  cell: {
    "@desc": 'crystallographic unit cell, expressed either in lattice integer notation (111-999) or as a coordinate in ijk space, where {1 1 1} is the same as 555. ANDing two cells, for example select cell=555 and cell=556, selects the atoms on the common face. (Note: in the specifc case of CELL, only "=" is allowed as a comparator.)',
    "@examples": [""],
    isUnsupported: !0,
    regex: /[0-9\s{}-]+/,
    map: P8,
    level: "atom-test"
  },
  configuration: {
    "@desc": 'Only in the context {configuration=n}, this option selects the set of atoms with either no ALTLOC specified or those atoms having this index into the array of altlocs within its model. So, for example, if the model has altloc "A" and "B", select configuration=1 is equivalent to select altloc="" or altloc="A", and print {configuration=2} is equivalent to print {altloc="" or altloc="B"}. Configuration 0 is "all atoms in a model having configurations", and an invalid configuration number gives no atoms. (Note: in the specifc case of CONFIGURATION, only "=" is allowed as a comparator.)',
    "@examples": [""],
    isUnsupported: !0,
    regex: TV,
    map: (Z) => parseInt(Z),
    level: "atom-test"
  },
  chain: {
    "@desc": 'protein chain. For newer CIF files allowing multicharacter chain specifications, use quotations marks: select chain="AA". For these multicharacter desigations, case is not checked unless the CIF file has lower-case chain designations.',
    "@examples": ["chain = A", 'chain = "AA"'],
    regex: /[a-zA-Z0-9]+/,
    map: P8,
    level: "chain-test",
    property: sJ.ammp("auth_asym_id")
  },
  chainNo: {
    "@desc": 'chain number; sequentially counted from 1 for each model; chainNo == 0 means"no chain" or PDB chain identifier indicated as a blank (Jmol 14.0).',
    "@examples": [""],
    isUnsupported: !0,
    regex: /[0-9\s{}-]+/,
    map: P8,
    level: "atom-test"
  },
  color: {
    "@desc": "the atom color",
    "@examples": [""],
    isUnsupported: !0,
    regex: /[0-9\s{}-]+/,
    map: P8,
    level: "atom-test"
  },
  covalentRadius: {
    "@desc": "covalent bonding radius, synonymous with covalent. Not used by Jmol, but could be used, for example, in {*}.spacefill={*}.covalentRadius.all.",
    "@examples": [""],
    abbr: ["covalent"],
    isUnsupported: !0,
    regex: /[0-9\s{}-]+/,
    map: P8,
    level: "atom-test"
  },
  cs: {
    "@desc": "chemical shift calculated using computational results that include magnetic shielding tensors.",
    "@examples": [""],
    isUnsupported: !0,
    regex: /[0-9\s{}-]+/,
    map: P8,
    level: "atom-test"
  },
  element: {
    "@desc": 'element symbol. The value of this parameter depends upon the context. Used with select structure=x, x can be either the quoted element symbol, "H", "He", "Li", etc. or atomic number. In all other contexts, the value is the element symbol. When the atom is a specific isotope, the string will contain the isotope number -- "13C", for example.',
    "@examples": ["element=Fe"],
    regex: /[a-zA-Z]+/,
    map: (Z) => sJ.es(Z),
    level: "atom-test",
    property: sJ.acp("elementSymbol")
  },
  elemno: {
    "@desc": "atomic element number",
    "@examples": ["elemno=8"],
    regex: /[0-9\s{}-]+/,
    map: (Z) => parseInt(Z),
    level: "atom-test",
    property: sJ.acp("atomicNumber")
  },
  eta: {
    "@desc": `Based on Carlos M. Duarte, Leven M. Wadley, and Anna Marie Pyle, RNA structure comparison, motif search and discovery using a reduced representation of RNA conformational space, Nucleic Acids Research, 2003, Vol. 31, No. 16 4755-4761. The parameter eta is the C4'[i-1]-P[i]-C4'[i]-P[i+1] dihedral angle; theta is the P[i]-C4'[i]-P[i+1]-C4'[i+1] dihedral angle. Both are measured on a 0-360 degree scale because they are commonly near 180 degrees. Using the commands plot PROPERTIES eta theta resno; select visible;wireframe only one can create these authors' "RNA worm" graph.`,
    "@examples": [""],
    isUnsupported: !0,
    regex: /[0-9\s{}-]+/,
    map: P8,
    level: "atom-test"
  },
  theta: {
    "@desc": `Based on Carlos M. Duarte, Leven M. Wadley, and Anna Marie Pyle, RNA structure comparison, motif search and discovery using a reduced representation of RNA conformational space, Nucleic Acids Research, 2003, Vol. 31, No. 16 4755-4761. The parameter eta is the C4'[i-1]-P[i]-C4'[i]-P[i+1] dihedral angle; theta is the P[i]-C4'[i]-P[i+1]-C4'[i+1] dihedral angle. Both are measured on a 0-360 degree scale because they are commonly near 180 degrees. Using the commands plot PROPERTIES eta theta resno; select visible;wireframe only one can create these authors' "RNA worm" graph.`,
    "@examples": [""],
    isUnsupported: !0,
    regex: /[0-9\s{}-]+/,
    map: P8,
    level: "atom-test"
  },
  file: {
    "@desc": "file number containing this atom",
    "@examples": [""],
    isUnsupported: !0,
    regex: /[0-9\s{}-]+/,
    map: P8,
    level: "atom-test"
  },
  formalCharge: {
    "@desc": "formal charge",
    "@examples": ["formalCharge=1"],
    regex: y3,
    map: (Z) => parseFloat(Z),
    level: "atom-test",
    property: sJ.ammp("pdbx_formal_charge")
  },
  format: {
    "@desc": "format (label) of the atom.",
    "@examples": [""],
    isUnsupported: !0,
    regex: /[0-9\s{}-]+/,
    map: P8,
    level: "atom-test"
  },
  fXyz: {
    "@desc": "fractional XYZ coordinates",
    "@examples": [""],
    isUnsupported: !0,
    regex: /[0-9\s{}-]+/,
    map: P8,
    level: "atom-test"
  },
  fX: {
    "@desc": "fractional X coordinate",
    "@examples": [""],
    isUnsupported: !0,
    regex: /[0-9\s{}-]+/,
    map: P8,
    level: "atom-test"
  },
  fY: {
    "@desc": "fractional Y coordinate",
    "@examples": [""],
    isUnsupported: !0,
    regex: /[0-9\s{}-]+/,
    map: P8,
    level: "atom-test"
  },
  fZ: {
    "@desc": "fractional Z coordinate",
    "@examples": [""],
    isUnsupported: !0,
    regex: /[0-9\s{}-]+/,
    map: P8,
    level: "atom-test"
  },
  fuxyz: {
    "@desc": "fractional XYZ coordinates in the unitcell coordinate system",
    "@examples": [""],
    isUnsupported: !0,
    regex: /[0-9\s{}-]+/,
    map: P8,
    level: "atom-test"
  },
  fux: {
    "@desc": "fractional X coordinate in the unitcell coordinate system",
    "@examples": [""],
    isUnsupported: !0,
    regex: /[0-9\s{}-]+/,
    map: P8,
    level: "atom-test"
  },
  fuy: {
    "@desc": "fractional Y coordinate in the unitcell coordinate system",
    "@examples": [""],
    isUnsupported: !0,
    regex: /[0-9\s{}-]+/,
    map: P8,
    level: "atom-test"
  },
  fuz: {
    "@desc": "fractional Z coordinate in the unit cell coordinate system",
    "@examples": [""],
    isUnsupported: !0,
    regex: /[0-9\s{}-]+/,
    map: P8,
    level: "atom-test"
  },
  group: {
    "@desc": "3-letter residue code",
    "@examples": ["group = ALA"],
    regex: /[a-zA-Z0-9]{1,3}/,
    map: P8,
    level: "residue-test",
    property: sJ.ammp("label_comp_id")
  },
  group1: {
    "@desc": "single-letter residue code (amino acids only)",
    "@examples": ["group1 = G"],
    regex: /[a-zA-Z]/,
    map: P8,
    level: "residue-test",
    property: sJ.ammp("label_comp_id")
  },
  groupID: {
    "@desc": "group ID number: A unique ID for each amino acid or nucleic acid residue in a PDB file. 0  noGroup 1-5  ALA, ARG, ASN, ASP, CYS 6-10  GLN, GLU, GLY, HIS, ILE 11-15  LEU, LYS, MET, PHE, PRO 16-20  SER, THR, TRP, TYR, VAL 21-23  ASX, GLX, UNK 24-29  A, +A, G, +G, I, +I 30-35  C, +C, T, +T, U, +U Additional unique numbers are assigned arbitrarily by Jmol and cannot be used reproducibly.",
    "@examples": [""],
    isUnsupported: !0,
    regex: /[0-9\s{}-]+/,
    map: P8,
    level: "atom-test"
  },
  groupindex: {
    "@desc": "overall group index",
    "@examples": [""],
    isUnsupported: !0,
    regex: /[0-9\s{}-]+/,
    map: P8,
    level: "atom-test"
  },
  hydrophobicity: {
    "@desc": "Aminoacid residue scale of hydrophobicity based on Rose, G. D., Geselowitz, A. R., Lesser, G. J., Lee, R. H., and Zehfus, M. H. (1985). Hydrophobicity of amino acid residues in globular proteins, Science, 229(4716):834-838.",
    "@examples": [""],
    isUnsupported: !0,
    regex: /[0-9\s{}-]+/,
    map: P8,
    level: "atom-test"
  },
  identify: {
    "@desc": "for a PDB/mmCIF file, a label such as [ILE]7^1:A.CD1%A/3 #47, which includes the group ([ILE]), residue number with optional insertion code (7^1), chain (:A), atom name (CD1), alternate location if present (%A), PDB model number (/3, for NMR models when one file is loaded; /file.model such as /2.3 if more than one file is loaded), and atom number (#47). For non-PDB data, the information is shorter -- for example, H15/2.1 #6, indicating atom name (H15), full file.model number (/2.1), and atom number (#6). If only a single model is loaded, %[identify] does not include the model number.",
    "@examples": [""],
    isUnsupported: !0,
    regex: /[0-9\s{}-]+/,
    map: P8,
    level: "atom-test"
  },
  insertion: {
    "@desc": "protein residue insertion code",
    "@examples": ["insertion=A"],
    regex: /[a-zA-Z0-9]/,
    map: P8,
    level: "atom-test",
    property: sJ.ammp("pdbx_PDB_ins_code")
  },
  label: {
    "@desc": "current atom label (same as format)",
    "@examples": [""],
    isUnsupported: !0,
    regex: /[0-9\s{}-]+/,
    map: P8,
    level: "atom-test"
  },
  mass: {
    "@desc": "atomic mass -- especially useful with appended .max or .sum",
    "@examples": ["mass > 13"],
    regex: y3,
    map: (Z) => parseFloat(Z),
    level: "atom-test",
    property: sJ.acp("mass")
  },
  model: {
    "@desc": "model number",
    "@examples": [""],
    isUnsupported: !0,
    regex: /[0-9\s{}-]+/,
    map: P8,
    level: "atom-test"
  },
  modelindex: {
    "@desc": "a unique number for each model, starting with 0 and spanning all models in all files",
    "@examples": [""],
    isUnsupported: !0,
    regex: /[0-9\s{}-]+/,
    map: P8,
    level: "atom-test"
  },
  modO: {
    "@desc": "currently calculated occupancy from modulation (0 to 100; NaN if atom has no occupancy modulation)",
    "@examples": [""],
    isUnsupported: !0,
    regex: /[0-9\s{}-]+/,
    map: P8,
    level: "atom-test"
  },
  modXYZ: {
    "@desc": "currently calculated displacement modulation (for incommensurately modulated structures). Also modX, modY, modZ for individual components. For atoms without modultion, {xx}.modXYZ is -1 and {xx}.modX is NaN, and in a label %[modXYZ] and %[modX] are blank.",
    "@examples": [""],
    isUnsupported: !0,
    regex: /[0-9\s{}-]+/,
    map: P8,
    level: "atom-test"
  },
  molecule: {
    "@desc": "molecule number",
    "@examples": [""],
    isUnsupported: !0,
    regex: /[0-9\s{}-]+/,
    map: P8,
    level: "atom-test"
  },
  monomer: {
    "@desc": "monomer number (group number) in a polymer (usually a chain), starting with 1, or 0 if not part of a biopolymer -- that is, not a connected carbohydrate, amino acid, or nucleic acid (Jmol 14.3.15)",
    "@examples": [""],
    isUnsupported: !0,
    regex: /[0-9\s{}-]+/,
    map: P8,
    level: "atom-test"
  },
  ms: {
    "@desc": "magnetic shielding calculated from file-loaded tensors.",
    "@examples": [""],
    isUnsupported: !0,
    regex: /[0-9\s{}-]+/,
    map: P8,
    level: "atom-test"
  },
  occupancy: {
    "@desc": 'CIF file site occupancy. In SELECT command comparisons ("select occupancy < 90"), an integer n implies measurement on a 0-100 scale; also, in the context %[occupancy] or %q for a label, the reported number is a percentage. In all other cases, such as when %Q is used in a label or when a decimal number is used in a comparison, the scale is 0.0 - 1.0.',
    "@examples": ["occupancy < 1"],
    regex: y3,
    map: (Z) => parseFloat(Z),
    level: "atom-test",
    property: sJ.ammp("occupancy")
  },
  partialCharge: {
    "@desc": "partial charge",
    "@examples": [""],
    isUnsupported: !0,
    regex: y3,
    map: (Z) => parseFloat(Z),
    level: "atom-test"
  },
  phi: {
    "@desc": "protein group PHI angle for atom's residue",
    "@examples": [""],
    isUnsupported: !0,
    regex: /[0-9\s{}-]+/,
    map: P8,
    level: "atom-test"
  },
  polymer: {
    "@desc": "sequential polymer number in a model, starting with 1.",
    "@examples": [""],
    isUnsupported: !0,
    regex: /[0-9\s{}-]+/,
    map: P8,
    level: "atom-test"
  },
  polymerLength: {
    "@desc": "polymer length",
    "@examples": [""],
    isUnsupported: !0,
    regex: /[0-9\s{}-]+/,
    map: P8,
    level: "atom-test"
  },
  property_xx: {
    "@desc": "a property created using the DATA command",
    "@examples": [""],
    isUnsupported: !0,
    regex: /[0-9\s{}-]+/,
    map: P8,
    level: "atom-test"
  },
  psi: {
    "@desc": "protein group PSI angle for the atom's residue",
    "@examples": [""],
    isUnsupported: !0,
    regex: /[0-9\s{}-]+/,
    map: P8,
    level: "atom-test"
  },
  radius: {
    "@desc": 'currently displayed radius -- In SELECT command comparisons ("select radius=n"), integer n implies Rasmol units 1/250 Angstroms; in all other cases or when a decimal number is used, the units are Angstroms.',
    "@examples": [""],
    isUnsupported: !0,
    regex: /[0-9\s{}-]+/,
    map: P8,
    level: "atom-test"
  },
  resno: {
    "@desc": "PDB residue number, not including insertion code (see also seqcode, below)",
    "@examples": ["resno = 100"],
    regex: /-?[0-9]+/,
    map: (Z) => parseInt(Z),
    level: "residue-test",
    property: sJ.ammp("auth_seq_id")
  },
  selected: {
    "@desc": "1.0 if atom is selected; 0.0 if not",
    "@examples": [""],
    isUnsupported: !0,
    regex: /[0-9\s{}-]+/,
    map: P8,
    level: "atom-test"
  },
  sequence: {
    "@desc": 'PDB one-character sequence code, as a string of characters, with "?" indicated where single-character codes are not available',
    "@examples": [""],
    isUnsupported: !0,
    regex: /[0-9\s{}-]+/,
    map: P8,
    level: "atom-test"
  },
  seqcode: {
    "@desc": 'PDB residue number, including insertion code (for example, 234^2; "seqcode" option added in Jmol 14.3.16)',
    "@examples": [""],
    isUnsupported: !0,
    regex: /[0-9\s{}-]+/,
    map: P8,
    level: "atom-test"
  },
  seqid: {
    "@desc": "(mmCIF only) the value from _atom_site.label_seq_id; a pointer to _entity_poly_seq.num in the ENTITY_POLY_SEQ category specifying 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. (Jmol 14.2.3)",
    "@examples": [""],
    isUnsupported: !0,
    regex: /[0-9\s{}-]+/,
    map: P8,
    level: "atom-test"
  },
  shape: {
    "@desc": 'hybridization geometry such as "tetrahedral"',
    "@examples": [""],
    isUnsupported: !0,
    regex: /[0-9\s{}-]+/,
    map: P8,
    level: "atom-test"
  },
  site: {
    "@desc": "crystallographic site number",
    "@examples": [""],
    isUnsupported: !0,
    regex: /[0-9\s{}-]+/,
    map: P8,
    level: "atom-test"
  },
  spacefill: {
    "@desc": "currently displayed radius",
    "@examples": [""],
    isUnsupported: !0,
    regex: /[0-9\s{}-]+/,
    map: P8,
    level: "atom-test"
  },
  straightness: {
    "@desc": 'quaternion-derived straightness (second derivative of the quaternion describing the orientation of the residue. This quantity will have different values depending upon the setting of quaternionFrame as "A" (alpha-carbon/phosphorus atom only), "C" (alpha-carbon/pyrimidine or purine base based), "P" (carbonyl-carbon peptide plane/phosphorus tetrahedron based), or "N" (amide-nitrogen based). The default is alpha-carbon based, which corresponds closely to the following combination of Ramachandran angles involving three consecutive residues i-1, i, and i+1: -psii-1 - phii + psii + phii+1.',
    "@examples": [""],
    isUnsupported: !0,
    regex: /[0-9\s{}-]+/,
    map: P8,
    level: "atom-test"
  },
  strucno: {
    "@desc": "a unique number for each helix, sheet, or turn in a model, starting with 1.",
    "@examples": [""],
    isUnsupported: !0,
    regex: /[0-9\s{}-]+/,
    map: P8,
    level: "atom-test"
  },
  structure: {
    "@desc": 'The value of this parameter depends upon the context. Used with select structure=x, x can be either the quoted keyword "none", "turn", "sheet", "helix", "dna", "rna", or "carbohydrate" or a respective number 0-6. In the context {*}.structure, the return value is a number; in the context label %[structure], the return is one of the six keywords.',
    "@examples": ['structure="helix"', "structure=3"],
    regex: /none|turn|sheet|helix|dna|rna|carbohydrate|[0-6]/i,
    map: P8,
    level: "residue-test",
    property: "structure"
  },
  substructure: {
    "@desc": 'like structure, the value of this parameter depends upon the context. Used with select substructure=x, x can be either the quoted keyword "none", "turn", "sheet", "helix", "dna", "rna", "carbohydrate", "helix310", "helixalpha", or "helixpi", or the respective number 0-9. In the context {*}.substructure, the return value is a number; in the context label %[substructure], the return is one of the nine keywords.',
    "@examples": ['substructure = "alphahelix"', "substructure =9"],
    regex: /none|turn|sheet|helix|dna|rna|carbohydrate|helix310|helixalpha|helixpi|[0-9]/i,
    map: P8,
    level: "residue-test",
    property: "structure"
  },
  surfacedistance: {
    "@desc": "A value related to the distance of an atom to a nominal molecular surface. 0 indicates at the surface. Positive numbers are minimum distances in Angstroms from the given atom to the surface.",
    "@examples": [""],
    isUnsupported: !0,
    regex: /[0-9\s{}-]+/,
    map: P8,
    level: "atom-test"
  },
  symop: {
    "@desc": 'the first symmetry operation code that generated this atom by Jmol; an integer starting with 1. See also symmetry, below. This operator is only present if the file contains space group information and the file was loaded using the {i, j, k} option so as to generate symmetry-based atoms. To select only the original atoms prior to application of symmetry, you can either use "SYMOP=n", where n is the symmetry operator corresponding to "x,y,z", or you can specify instead simply "NOT symmetry" the way you might specify "NOT hydrogen". Note that atoms in special positions will have multiple operator matches. These atoms can be selected using the keyword SPECIALPOSITION. The special form select SYMOP=nijk selects a specific translation of atoms from the given crystallographic symmetry operation. Comparators <, <=, >, >=, and != can be used and only apply to the ijk part of the designation. The ijk are relative, not absolute. Thus, symop=2555 selects for atoms that have been transformed by symop=2 but not subjected to any further translation. select symop=1555 is identical to select not symmetry. All other ijk are relative to these selections for 555. If the model was loaded using load "filename.cif" {444 666 1}, where the 1 indicates that all symmetry-generated atoms are to be packed within cell 555 and then translated to fill the other 26 specified cells, then select symop=3555 is nearly the same as select symop=3 and cell=555. (The difference being that cell=555 selects for all atoms that are on any edge of the cell, while symop=3555 does not.) However, the situation is different if instead the model was loaded using load "filename.cif" {444 666 0}, where the 0 indicates that symmetry-generated atoms are to be placed exactly where their symmetry operator would put them (x,-y,z being different then from x, 1-y, z). In that case, select symop=3555 is for all atoms that have been generated using symmetry operation 3 but have not had any additional translations applied to the x,y,z expression found in the CIF file. If, for example, symmetry operation 3 is -x,-y,-z, then load "filename.cif" {444 666 0} will place an atom originally at {1/2, 1/2, 1/2} at positions {-1/2, -1/2, -1/2} (symop=3555) and {-3/2, -3/2, -3/2} (symop=3444) and 24 other sites.',
    "@examples": [""],
    isUnsupported: !0,
    regex: /[0-9\s{}-]+/,
    map: P8,
    level: "atom-test"
  },
  symmetry: {
    "@desc": 'as "symmetry" or in a label as lower-case "o" gives list of crystallographic symmetry operators generating this atom with lattice designations,such as 3555; upper-case "%O" in a label gives a list without the lattice designations. See also symop, above.',
    "@examples": [""],
    isUnsupported: !0,
    regex: /[0-9\s{}-]+/,
    map: P8,
    level: "atom-test"
  },
  temperature: {
    "@desc": "yes  yes  temperature factor (B-factor)",
    "@examples": ["temperature >= 20"],
    regex: y3,
    map: (Z) => parseFloat(Z),
    level: "atom-test",
    property: sJ.ammp("B_iso_or_equiv")
  },
  unitXyz: {
    "@desc": "unit cell XYZ coordinates",
    "@examples": [""],
    isUnsupported: !0,
    regex: /[0-9\s{}-]+/,
    map: P8,
    level: "atom-test"
  },
  uX: {
    "@desc": "unit cell X coordinate normalized to [0,1)",
    "@examples": [""],
    isUnsupported: !0,
    regex: /[0-9\s{}-]+/,
    map: P8,
    level: "atom-test"
  },
  uY: {
    "@desc": "unit cell Y coordinate normalized to [0,1)",
    "@examples": [""],
    isUnsupported: !0,
    regex: /[0-9\s{}-]+/,
    map: P8,
    level: "atom-test"
  },
  uZ: {
    "@desc": "unit cell Z coordinate normalized to [0,1)",
    "@examples": [""],
    isUnsupported: !0,
    regex: /[0-9\s{}-]+/,
    map: P8,
    level: "atom-test"
  },
  valence: {
    "@desc": "the valence of an atom (sum of bonds, where double bond counts as 2 and triple bond counts as 3",
    "@examples": [""],
    isUnsupported: !0,
    regex: /[0-9\s{}-]+/,
    map: P8,
    level: "atom-test"
  },
  vanderwaals: {
    "@desc": "van der Waals radius",
    "@examples": ["vanderwaals >2"],
    regex: y3,
    map: (Z) => parseFloat(Z),
    level: "atom-test",
    property: sJ.acp("vdw")
  },
  vectorScale: {
    "@desc": "vibration vector scale",
    "@examples": [""],
    isUnsupported: !0,
    regex: /[0-9\s{}-]+/,
    map: P8,
    level: "atom-test"
  },
  volume: {
    "@desc": "approximate van der Waals volume for this atom. Note, {*}.volume gives an average; use {*}.volume.sum to get total volume.",
    "@examples": [""],
    isUnsupported: !0,
    regex: /[0-9\s{}-]+/,
    map: P8,
    level: "atom-test"
  },
  vXyz: {
    "@desc": "vibration vector, or individual components as %vx %vy %vz. For atoms without vibration vectors, {xx}.vXyz is -1; in a label, %[vxyz] is blank.",
    "@examples": [""],
    isUnsupported: !0,
    regex: /[0-9\s{}-]+/,
    map: P8,
    level: "atom-test"
  },
  vX: {
    "@desc": "vibration vector X coordinate; for atoms without vibration vector, {xx}.vX is NaN (same for vY and vZ)",
    "@examples": [""],
    isUnsupported: !0,
    regex: /[0-9\s{}-]+/,
    map: P8,
    level: "atom-test"
  },
  vY: {
    "@desc": "vibration vector Y coordinate",
    "@examples": [""],
    isUnsupported: !0,
    regex: /[0-9\s{}-]+/,
    map: P8,
    level: "atom-test"
  },
  vZ: {
    "@desc": "vibration vector Z coordinate",
    "@examples": [""],
    isUnsupported: !0,
    regex: /[0-9\s{}-]+/,
    map: P8,
    level: "atom-test"
  },
  xyz: {
    "@desc": "Cartesian XYZ coordinates; select xyz > 1.0 selects atoms more than one Angstrom from the origin.",
    "@examples": [""],
    isUnsupported: !0,
    regex: /[0-9\s{}-]+/,
    map: P8,
    level: "atom-test"
  }
};

// node_modules/molstar/lib/mol-script/transpilers/jmol/operators.js
var TD0 = L0, Vr = [
  {
    "@desc": "Selects atoms that are not included in s1.",
    "@examples": ["not ARG"],
    name: "not",
    type: dX,
    rule: N1.alt(N1.regex(/NOT/i).skip(N1.whitespace), N1.string("!").skip(N1.optWhitespace)),
    map: (Z, J) => IY(J)
  },
  {
    "@desc": "Selects atoms included in both s1 and s2.",
    "@examples": ["ASP and .CA"],
    name: "and",
    type: QX,
    rule: x3(/AND|&/i),
    map: (Z, J, $) => TD0.struct.modifier.intersectBy({ 0: J, by: $ })
  },
  {
    "@desc": "Selects atoms included in either s1 or s2.",
    "@examples": ["ASP or GLU"],
    name: "or",
    type: QX,
    rule: x3(/OR|\||,/i),
    map: (Z, J, $) => TD0.struct.combinator.merge([J, $])
  }
];

// node_modules/molstar/lib/mol-script/transpilers/jmol/keywords.js
var W1 = L0, k7 = {
  acidic: ["ASP", "GLU"],
  aliphatic: ["ALA", "GLY", "ILE", "LEU", "VAL"],
  amino: ["ALA", "ARG", "ASN", "ASP", "CYS", "GLN", "GLU", "GLY", "HIS", "ILE", "LEU", "LYS", "MET", "PHE", "PRO", "SER", "THR", "TRP", "TYR", "VAL", "ASX", "GLX", "UNK"],
  aromatic: ["HIS", "PHE", "TRP", "TYR"],
  basic: ["ARG", "HIS", "LYS"],
  buried: ["ALA", "CYS", "ILE", "LEU", "MET", "PHE", "TRP", "VAL"],
  cg: ["CYT", "C", "GUA", "G"],
  cyclic: ["HIS", "PHE", "PRO", "TRP", "TYR"],
  hydrophobic: ["ALA", "GLY", "ILE", "LEU", "MET", "PHE", "PRO", "TRP", "TYR", "VAL"],
  large: ["ARG", "GLU", "GLN", "HIS", "ILE", "LEU", "LYS", "MET", "PHE", "TRP", "TYR"],
  medium: ["ASN", "ASP", "CYS", "PRO", "THR", "VAL"],
  small: ["ALA", "GLY", "SER"],
  nucleic: ["G", "C", "A", "T", "U", "I", "DG", "DC", "DA", "DT", "DU", "DI", "+G", "+C", "+A", "+T", "+U", "+I"]
}, _D0 = {
  nucleic: [
    "P",
    "O3'",
    "O5'",
    "C5'",
    "C4'",
    "C3'",
    "OP1",
    "OP2",
    "O3*",
    "O5*",
    "C5*",
    "C4*",
    "C3*",
    "C2'",
    "C1'",
    "O4'",
    "O2'"
  ],
  protein: ["C", "N", "CA"]
};
function _V() {
  return W1.struct.combinator.merge([
    W1.struct.generator.atomGroups({
      "residue-test": W1.core.set.has([
        W1.set(...k7.nucleic),
        W1.ammp("label_comp_id")
      ])
    }),
    W1.struct.filter.pick({
      0: W1.struct.generator.atomGroups({
        "group-by": W1.ammp("residueKey")
      }),
      test: W1.core.logic.and([
        W1.core.rel.eq([W1.struct.atomSet.atomCount(), 1]),
        W1.core.rel.eq([W1.ammp("label_atom_id"), W1.atomName("P")])
      ])
    }),
    W1.struct.filter.pick({
      0: W1.struct.generator.atomGroups({
        "group-by": W1.ammp("residueKey")
      }),
      test: W1.core.logic.or([
        W1.core.set.isSubset([
          IK(["C1'", "C2'", "O3'", "C3'", "C4'", "C5'", "O5'"]),
          W1.ammpSet("label_atom_id")
        ]),
        W1.core.set.isSubset([
          IK(["C1*", "C2*", "O3*", "C3*", "C4*", "C5*", "O5*"]),
          W1.ammpSet("label_atom_id")
        ])
      ])
    })
  ]);
}
function FQ1() {
  return W1.struct.generator.atomGroups({
    "residue-test": W1.core.set.has([
      W1.set(...k7.amino),
      W1.ammp("label_comp_id")
    ])
  });
}
function UQ1() {
  return W1.struct.combinator.merge([
    W1.struct.modifier.intersectBy({
      0: W1.struct.generator.atomGroups({
        "residue-test": W1.core.set.has([
          W1.core.type.set(k7.amino),
          W1.ammp("label_comp_id")
        ])
      }),
      by: W1.struct.generator.atomGroups({
        "atom-test": W1.core.set.has([
          W1.core.type.set(_D0.protein),
          W1.ammp("label_atom_id")
        ])
      })
    }),
    W1.struct.modifier.intersectBy({
      0: W1.struct.generator.atomGroups({
        "residue-test": W1.core.set.has([
          W1.core.type.set(k7.nucleic),
          W1.ammp("label_comp_id")
        ])
      }),
      by: W1.struct.generator.atomGroups({
        "atom-test": W1.core.set.has([
          W1.core.type.set(_D0.nucleic),
          W1.ammp("label_atom_id")
        ])
      })
    })
  ]);
}
var Ir = {
  all: {
    "@desc": "all atoms; same as *",
    abbr: ["*"],
    map: () => W1.struct.generator.all()
  },
  bonded: {
    "@desc": "covalently bonded",
    map: () => W1.struct.generator.atomGroups({
      "atom-test": W1.core.rel.gr([W1.struct.atomProperty.core.bondCount({
        flags: W1.struct.type.bondFlags(["covalent", "metallic", "sulfide"])
      }), 0])
    })
  },
  clickable: {
    "@desc": "actually visible -- having some visible aspect such as wireframe, spacefill, or a label showing, or the alpha-carbon or phosphorus atom in a biomolecule that is rendered with only cartoon, rocket, or other biomolecule-specific shape."
  },
  connected: {
    "@desc": "bonded in any way, including hydrogen bonds",
    map: () => W1.struct.generator.atomGroups({
      "atom-test": W1.core.rel.gr([W1.struct.atomProperty.core.bondCount({
        flags: W1.struct.type.bondFlags()
      }), 0])
    })
  },
  displayed: {
    "@desc": "displayed using the display or hide command; not necessarily visible"
  },
  hidden: {
    "@desc": "hidden using the display or hide command"
  },
  none: {
    "@desc": "no atoms",
    map: () => W1.struct.generator.empty()
  },
  selected: {
    "@desc": "atoms that have been selected; defaults to all when a file is first loaded"
  },
  thisModel: {
    "@desc": 'atoms in the current frame set, as defined by frame, model, or animation commands. If more than one model is in this set, "thisModel" refers to all of them, regardless of atom displayed/hidden status.'
  },
  visible: {
    "@desc": "visible in any way, including PDB residue atoms for which a cartoon or other such rendering makes their group visible, even if they themselves are not visible."
  },
  subset: {
    "@desc": "the currently defined subset. Note that if a subset is currently defined, then select/display all is the same as select/display subset, restrict none is the same as restrict not subset. In addition, select not subset selects nothing."
  },
  specialPosition: {
    "@desc": "atoms in crystal structures that are at special positions - that is, for which there is more than one operator that leads to them."
  },
  unitcell: {
    "@desc": "atoms within the current unitcell, which may be offset. This includes atoms on the faces and at the vertices of the unitcell."
  },
  polyhedra: {
    "@desc": "all central atoms for which polyhedra have been created. See also polyhera(n), below. (Jmol 14.4)"
  },
  nonmetal: {
    "@desc": "_H,_He,_B,_C,_N,_O,_F,_Ne,_Si,_P,_S,_Cl,_Ar,_As,_Se,_Br,_Kr,_Te,_I,_Xe,_At,_Rn",
    map: () => W1.struct.generator.atomGroups({
      "atom-test": W1.core.set.has([
        W1.set(...["H", "He", "B", "C", "N", "O", "F", "Ne", "Si", "P", "S", "Cl", "Ar", "As", "Se", "Br", "Kr", "Te", "I", "Xe", "At", "Rn"].map(W1.es)),
        W1.acp("elementSymbol")
      ])
    })
  },
  metal: {
    "@desc": "!nonmetal",
    map: () => W1.struct.generator.atomGroups({
      "atom-test": W1.core.logic.not([
        W1.core.set.has([
          W1.set(...["H", "He", "B", "C", "N", "O", "F", "Ne", "Si", "P", "S", "Cl", "Ar", "As", "Se", "Br", "Kr", "Te", "I", "Xe", "At", "Rn"].map(W1.es)),
          W1.acp("elementSymbol")
        ])
      ])
    })
  },
  alkaliMetal: {
    "@desc": "_Li,_Na,_K,_Rb,_Cs,_Fr",
    map: () => W1.struct.generator.atomGroups({
      "atom-test": W1.core.set.has([
        W1.set(...["Li", "Na", "K", "Rb", "Cs", "Fr"].map(W1.es)),
        W1.acp("elementSymbol")
      ])
    })
  },
  alkalineEarth: {
    "@desc": "_Be,_Mg,_Ca,_Sr,_Ba,_Ra",
    map: () => W1.struct.generator.atomGroups({
      "atom-test": W1.core.set.has([
        W1.set(...["Be", "Mg", "Ca", "Sr", "Ba", "Ra"].map(W1.es)),
        W1.acp("elementSymbol")
      ])
    })
  },
  nobleGas: {
    "@desc": "_He,_Ne,_Ar,_Kr,_Xe,_Rn",
    map: () => W1.struct.generator.atomGroups({
      "atom-test": W1.core.set.has([
        W1.set(...["He", "Ne", "Ar", "Kr", "Xe", "Rn"].map(W1.es)),
        W1.acp("elementSymbol")
      ])
    })
  },
  metalloid: {
    "@desc": "_B,_Si,_Ge,_As,_Sb,_Te",
    map: () => W1.struct.generator.atomGroups({
      "atom-test": W1.core.set.has([
        W1.set(...["B", "Si", "Ge", "As", "Sb", "Te"].map(W1.es)),
        W1.acp("elementSymbol")
      ])
    })
  },
  transitionMetal: {
    "@desc": "(includes La and Ac) elemno>=21 and elemno<=30, elemno=57, elemno=89, elemno>=39 and elemno<=48, elemno>=72 and elemno<=80, elemno>=104 and elemno<=112",
    map: () => W1.struct.generator.atomGroups({
      "atom-test": W1.core.logic.or([
        W1.core.rel.inRange([W1.acp("atomicNumber"), 21, 30]),
        W1.core.rel.inRange([W1.acp("atomicNumber"), 39, 48]),
        W1.core.rel.inRange([W1.acp("atomicNumber"), 72, 80]),
        W1.core.rel.inRange([W1.acp("atomicNumber"), 104, 112]),
        W1.core.set.has([W1.set(57, 89), W1.acp("atomicNumber")])
      ])
    })
  },
  lanthanide: {
    "@desc": "(does not include La) elemno>57 and elemno<=71",
    map: () => W1.struct.generator.atomGroups({
      "atom-test": W1.core.rel.inRange([W1.acp("atomicNumber"), 57, 71])
    })
  },
  actinide: {
    "@desc": "(does not include Ac) elemno>89 and elemno<=103",
    map: () => W1.struct.generator.atomGroups({
      "atom-test": W1.core.rel.inRange([W1.acp("atomicNumber"), 89, 103])
    })
  },
  isaromatic: {
    "@desc": "atoms connected with the AROMATIC, AROMATICSINGLE, or AROMATICDOUBLE bond types",
    map: () => W1.struct.generator.atomGroups({
      "atom-test": W1.core.rel.gr([
        W1.struct.atomProperty.core.bondCount({
          flags: W1.struct.type.bondFlags(["aromatic"])
        }),
        0
      ])
    })
  },
  carbohydrate: {
    "@desc": ""
  },
  ions: {
    "@desc": '(specifically the PDB designations "PO4" and "SO4")'
  },
  ligand: {
    "@desc": '(originally "hetero and not solvent"; changed to "!(protein,nucleic,water,UREA)" for Jmol 12.2)'
  },
  nucleic: {
    "@desc": `any group that (a) has one of the following group names: G, C, A, T, U, I, DG, DC, DA, DT, DU, DI, +G, +C, +A, +T, +U, +I; or (b) can be identified as a group that is only one atom, with name "P"; or (c) has all of the following atoms (prime, ', can replace * here): C1*, C2*, C3*, O3*, C4*, C5*, and O5*.`,
    map: () => _V()
  },
  purine: {
    "@desc": "any nucleic group that (a) has one of the following group names: A, G, I, DA, DG, DI, +A, +G, or +I; or (b) also has atoms N7, C8, and N9.",
    map: () => W1.struct.modifier.intersectBy({
      0: _V(),
      by: W1.struct.combinator.merge([
        W1.struct.generator.atomGroups({
          "residue-test": W1.core.set.has([
            W1.set(...["A", "G", "I", "DA", "DG", "DI", "+A", "+G", "+I"]),
            W1.ammp("label_comp_id")
          ])
        }),
        W1.struct.filter.pick({
          0: W1.struct.generator.atomGroups({
            "group-by": W1.ammp("residueKey")
          }),
          test: W1.core.set.isSubset([
            IK(["N7", "C8", "N9"]),
            W1.ammpSet("label_atom_id")
          ])
        })
      ])
    })
  },
  pyrimidine: {
    "@desc": "any nucleic group that (a) has one of the following group names: C, T, U, DC, DT, DU, +C, +T, +U; or (b) also has atom O2.",
    map: () => W1.struct.modifier.intersectBy({
      0: _V(),
      by: W1.struct.combinator.merge([
        W1.struct.generator.atomGroups({
          "residue-test": W1.core.set.has([
            W1.set(...["C", "T", "U", "DC", "DT", "DU", "+C", "+T", "+U"]),
            W1.ammp("label_comp_id")
          ])
        }),
        W1.struct.filter.pick({
          0: W1.struct.generator.atomGroups({
            "group-by": W1.ammp("residueKey")
          }),
          test: W1.core.logic.or([
            W1.core.set.has([
              W1.ammpSet("label_atom_id"),
              W1.atomName("O2*")
            ]),
            W1.core.set.has([
              W1.ammpSet("label_atom_id"),
              W1.atomName("O2'")
            ])
          ])
        })
      ])
    })
  },
  dna: {
    "@desc": "any nucleic group that (a) has one of the following group names: DG, DC, DA, DT, DU, DI, T, +G, +C, +A, +T; or (b) has neither atom O2* or O2'.",
    map: () => W1.struct.modifier.intersectBy({
      0: _V(),
      by: W1.struct.combinator.merge([
        W1.struct.generator.atomGroups({
          "residue-test": W1.core.set.has([
            W1.set(...["DG", "DC", "DA", "DT", "DU", "DI", "T", "+G", "+C", "+A", "+T"]),
            W1.ammp("label_comp_id")
          ])
        }),
        W1.struct.filter.pick({
          0: W1.struct.generator.atomGroups({
            "group-by": W1.ammp("residueKey")
          }),
          test: W1.core.logic.not([
            W1.core.logic.or([
              W1.core.set.has([
                W1.ammpSet("label_atom_id"),
                W1.atomName("O2*")
              ]),
              W1.core.set.has([
                W1.ammpSet("label_atom_id"),
                W1.atomName("O2'")
              ])
            ])
          ])
        })
      ])
    })
  },
  rna: {
    "@desc": "any nucleic group that (a) has one of the following group names: G, C, A, U, I, +U, +I; or (b) has atom O2* or O2'.",
    map: () => W1.struct.modifier.intersectBy({
      0: _V(),
      by: W1.struct.combinator.merge([
        W1.struct.generator.atomGroups({
          "residue-test": W1.core.set.has([
            W1.set(...["G", "C", "A", "U", "I", "+U", "+I"]),
            W1.ammp("label_comp_id")
          ])
        }),
        W1.struct.filter.pick({
          0: W1.struct.generator.atomGroups({
            "group-by": W1.ammp("residueKey")
          }),
          test: W1.core.logic.or([
            W1.core.set.has([
              W1.ammpSet("label_atom_id"),
              W1.atomName("O2*")
            ]),
            W1.core.set.has([
              W1.ammpSet("label_atom_id"),
              W1.atomName("O2'")
            ])
          ])
        })
      ])
    })
  },
  protein: {
    "@desc": 'defined as a group that (a) has one of the following group names: ALA, ARG, ASN, ASP, CYS, GLN, GLU, GLY, HIS, ILE, LEU, LYS, MET, PHE, PRO, SER, THR, TRP, TYR, VAL, ASX, GLX, or UNK; or (b) contains PDB atom designations [C, O, CA, and N] bonded correctly; or (c) does not contain "O" but contains [C, CA, and N] bonded correctly; or (d) has only one atom, which has name CA and does not have the group name CA (indicating a calcium atom).',
    map: () => FQ1()
  },
  acidic: {
    "@desc": "ASP GLU",
    map: () => DZ(k7.acidic)
  },
  acyclic: {
    "@desc": "amino and not cyclic",
    map: () => W1.struct.modifier.intersectBy({
      0: DZ(k7.amino),
      by: IY(DZ(k7.cyclic))
    })
  },
  aliphatic: {
    "@desc": "ALA GLY ILE LEU VAL",
    map: () => DZ(k7.aliphatic)
  },
  amino: {
    "@desc": "all twenty standard amino acids, plus ASX, GLX, UNK",
    map: () => DZ(k7.amino)
  },
  aromatic: {
    "@desc": 'HIS PHE TRP TYR (see also "isaromatic" for aromatic bonds)',
    map: () => DZ(k7.aromatic)
  },
  basic: {
    "@desc": "ARG HIS LYS",
    map: () => DZ(k7.basic)
  },
  buried: {
    "@desc": "ALA CYS ILE LEU MET PHE TRP VAL",
    map: () => DZ(k7.buried)
  },
  charged: {
    "@desc": "same as acidic or basic -- ASP GLU, ARG HIS LYS",
    map: () => DZ(k7.acidic.concat(k7.basic))
  },
  cyclic: {
    "@desc": "HIS PHE PRO TRP TYR",
    map: () => DZ(k7.cyclic)
  },
  helix: {
    "@desc": "secondary structure-related.",
    map: () => W1.struct.generator.atomGroups({
      "residue-test": W1.core.flags.hasAny([
        W1.struct.type.secondaryStructureFlags(["helix"]),
        W1.ammp("secondaryStructureFlags")
      ])
    })
  },
  helixalpha: {
    "@desc": "secondary structure-related.",
    map: () => W1.struct.generator.atomGroups({
      "residue-test": W1.core.flags.hasAny([
        W1.struct.type.secondaryStructureFlags(["alpha"]),
        W1.ammp("secondaryStructureFlags")
      ])
    })
  },
  helix310: {
    "@desc": "secondary structure-related.",
    map: () => W1.struct.generator.atomGroups({
      "residue-test": W1.core.flags.hasAny([
        W1.struct.type.secondaryStructureFlags(["3-10"]),
        W1.ammp("secondaryStructureFlags")
      ])
    })
  },
  helixpi: {
    "@desc": "secondary structure-related.",
    map: () => W1.struct.generator.atomGroups({
      "residue-test": W1.core.flags.hasAny([
        W1.struct.type.secondaryStructureFlags(["pi"]),
        W1.ammp("secondaryStructureFlags")
      ])
    })
  },
  hetero: {
    "@desc": "PDB atoms designated as HETATM",
    map: () => W1.struct.generator.atomGroups({
      "atom-test": W1.ammp("isHet")
    })
  },
  hydrophobic: {
    "@desc": "ALA GLY ILE LEU MET PHE PRO TRP TYR VAL",
    map: () => DZ(k7.hydrophobic)
  },
  large: {
    "@desc": "ARG GLU GLN HIS ILE LEU LYS MET PHE TRP TYR",
    map: () => DZ(k7.large)
  },
  medium: {
    "@desc": "ASN ASP CYS PRO THR VAL",
    map: () => DZ(k7.medium)
  },
  negative: {
    "@desc": "same as acidic -- ASP GLU",
    map: () => DZ(k7.acidic)
  },
  neutral: {
    "@desc": "amino and not (acidic or basic)",
    map: () => W1.struct.modifier.intersectBy({
      0: DZ(k7.amino),
      by: IY(DZ(k7.acidic.concat(k7.basic)))
    })
  },
  polar: {
    "@desc": "amino and not hydrophobic",
    map: () => W1.struct.modifier.intersectBy({
      0: DZ(k7.amino),
      by: IY(DZ(k7.hydrophobic))
    })
  },
  positive: {
    "@desc": "same as basic -- ARG HIS LYS",
    map: () => DZ(k7.basic)
  },
  sheet: {
    "@desc": "secondary structure-related",
    map: () => W1.struct.generator.atomGroups({
      "residue-test": W1.core.flags.hasAny([
        W1.struct.type.secondaryStructureFlags(["sheet"]),
        W1.ammp("secondaryStructureFlags")
      ])
    })
  },
  small: {
    "@desc": "ALA GLY SER",
    map: () => DZ(k7.small)
  },
  surface: {
    "@desc": "amino and not buried",
    map: () => W1.struct.modifier.intersectBy({
      0: DZ(k7.amino),
      by: IY(DZ(k7.buried))
    })
  },
  turn: {
    "@desc": "secondary structure-related",
    map: () => W1.struct.generator.atomGroups({
      "residue-test": W1.core.flags.hasAny([
        W1.struct.type.secondaryStructureFlags(["turn"]),
        W1.ammp("secondaryStructureFlags")
      ])
    })
  },
  alpha: {
    "@desc": "(*.CA)",
    map: () => W1.struct.generator.atomGroups({
      "atom-test": W1.core.rel.eq([
        W1.atomName("CA"),
        W1.ammp("label_atom_id")
      ])
    })
  },
  base: {
    "@desc": "(nucleic bases)"
  },
  backbone: {
    "@desc": "(*.C, *.CA, *.N, and all nucleic other than the bases themselves)",
    abbr: ["mainchain"],
    map: () => UQ1()
  },
  sidechain: {
    "@desc": "((protein or nucleic) and not backbone)"
  },
  spine: {
    "@desc": "(*.CA, *.N, *.C for proteins; *.P, *.O3', *.O5', *.C3', *.C4', *.C5 for nucleic acids)"
  },
  leadatom: {
    "@desc": "(*.CA, *.P, and terminal *.O5')"
  },
  solvent: {
    "@desc": 'PDB "HOH", water, also the connected set of H-O-H in any model'
  }
};

// node_modules/molstar/lib/mol-script/transpilers/jmol/parser.js
var w6 = L0, LQ1 = [
  {
    "@desc": "value comparisons",
    "@examples": [],
    name: "=",
    abbr: ["=="],
    type: QX,
    rule: N1.regexp(/\s*(LIKE|>=|<=|=|!=|>|<)\s*/i, 1),
    map: (Z, J, $) => {
      let X;
      if (J === "structure")
        X = w6.core.flags.hasAny([w6.ammp("secondaryStructureFlags"), Tr($)]);
      else if ($ === "structure")
        X = w6.core.flags.hasAny([w6.ammp("secondaryStructureFlags"), Tr(J)]);
      else if (J.head !== void 0) {
        if (J.head.name === "core.type.regex")
          X = w6.core.str.match([J, w6.core.type.str([$])]);
      } else if ($.head !== void 0) {
        if ($.head.name === "core.type.regex")
          X = w6.core.str.match([$, w6.core.type.str([J])]);
      } else if (Z.toUpperCase() === "LIKE")
        if (J.head)
          X = w6.core.str.match([
            w6.core.type.regex([`^${$}$`, "i"]),
            w6.core.type.str([J])
          ]);
        else
          X = w6.core.str.match([
            w6.core.type.regex([`^${J}$`, "i"]),
            w6.core.type.str([$])
          ]);
      if (!X) {
        if (J.head)
          $ = _z(J, $);
        if ($.head)
          J = _z($, J);
        switch (Z) {
          case "=":
            X = w6.core.rel.eq([J, $]);
            break;
          case "!=":
            X = w6.core.rel.neq([J, $]);
            break;
          case ">":
            X = w6.core.rel.gr([J, $]);
            break;
          case "<":
            X = w6.core.rel.lt([J, $]);
            break;
          case ">=":
            X = w6.core.rel.gre([J, $]);
            break;
          case "<=":
            X = w6.core.rel.lte([J, $]);
            break;
          default:
            throw new Error(`value operator '${Z}' not supported`);
        }
      }
      return w6.struct.generator.atomGroups({ "atom-test": X });
    }
  }
];
function RQ1(Z) {
  let [J, $, X, Y, Q, W, K] = Z[1], G = {};
  if (Q)
    G["chain-test"] = w6.core.rel.eq([w6.ammp("auth_asym_id"), Q]);
  let H = [];
  if (J)
    H.push(w6.core.rel.eq([w6.ammp("label_comp_id"), J]));
  if ($)
    H.push(w6.core.logic.and([
      w6.core.rel.gre([w6.ammp("auth_seq_id"), $[0]]),
      w6.core.rel.lte([w6.ammp("auth_seq_id"), $[1]])
    ]));
  if (X)
    H.push(w6.core.rel.eq([w6.ammp("auth_seq_id"), X]));
  if (Y)
    H.push(w6.core.rel.eq([w6.ammp("pdbx_PDB_ins_code"), Y]));
  if (H.length)
    G["residue-test"] = wV(H);
  let N = [];
  if (W)
    N.push(w6.core.rel.eq([w6.ammp("auth_atom_id"), W]));
  if (K)
    N.push(w6.core.rel.eq([w6.ammp("label_alt_id"), K]));
  if (N.length)
    G["atom-test"] = wV(N);
  return w6.struct.generator.atomGroups(G);
}
var EQ1 = N1.createLanguage({
  Integer: () => N1.regexp(/-?[0-9]+/).map(Number).desc("integer"),
  Parens: function(Z) {
    return N1.alt(Z.Parens, Z.Operator, Z.Expression).wrap(N1.regexp(/\(\s*/), N1.regexp(/\s*\)/));
  },
  Expression: function(Z) {
    return N1.alt(Z.Keywords, Z.AtomExpression.map(RQ1), Z.Within.map((J) => w6.struct.modifier.includeSurroundings({ 0: J[1], radius: J[0] })), Z.ValueQuery, Z.Element.map((J) => w6.struct.generator.atomGroups({
      "atom-test": w6.core.rel.eq([w6.acp("elementSymbol"), w6.struct.type.elementSymbol(J)])
    })), Z.Resname.map((J) => w6.struct.generator.atomGroups({
      "residue-test": w6.core.rel.eq([w6.ammp("label_comp_id"), J])
    })));
  },
  Operator: function(Z) {
    return xR(Vr, N1.alt(Z.Parens, Z.Expression));
  },
  AtomExpression: function(Z) {
    return N1.seq(N1.lookahead(Z.AtomPrefix), N1.seq(Z.BracketedResname.or(N1.of(null)), Z.ResnoRange.or(N1.of(null)), Z.Resno.or(N1.of(null)), Z.Inscode.or(N1.of(null)), Z.Chainname.or(N1.of(null)), Z.Atomname.or(N1.of(null)), Z.Altloc.or(N1.of(null)), Z.Model.or(N1.of(null)))).desc("expression");
  },
  AtomPrefix: () => N1.regexp(/[\[0-9:^%/.-]/).desc("atom-prefix"),
  Chainname: () => N1.regexp(/:([A-Za-z]{1,3})/, 1).desc("chainname"),
  Model: () => N1.regexp(/\/([0-9]+)/, 1).map(Number).desc("model"),
  Element: () => N1.regexp(/_([A-Za-z]{1,3})/, 1).desc("element"),
  Atomname: () => N1.regexp(/\.([a-zA-Z0-9]{1,4})/, 1).map(w6.atomName).desc("atomname"),
  Resname: () => N1.regexp(/[a-zA-Z0-9]{1,4}/).desc("resname"),
  Resno: (Z) => Z.Integer.desc("resno"),
  Altloc: () => N1.regexp(/%([a-zA-Z0-9])/, 1).desc("altloc"),
  Inscode: () => N1.regexp(/\^([a-zA-Z0-9])/, 1).desc("inscode"),
  BracketedResname: () => N1.regexp(/\[([a-zA-Z0-9]{1,4})\]/, 1).desc("bracketed-resname"),
  ResnoRange: (Z) => {
    return N1.seq(Z.Integer.skip(N1.seq(N1.optWhitespace, N1.string("-"), N1.optWhitespace)), Z.Integer).desc("resno-range");
  },
  Within: (Z) => {
    return N1.regexp(/within/i).skip(N1.regexp(/\s*\(\s*/)).then(N1.seq(Z.Integer.skip(N1.regexp(/\s*,\s*/)), Z.Query)).skip(N1.regexp(/\)/));
  },
  Keywords: () => N1.alt(...TA(Ir)).desc("keyword"),
  Query: function(Z) {
    return N1.alt(Z.Operator, Z.Parens, Z.Expression).trim(N1.optWhitespace);
  },
  Number: function() {
    return N1.regexp(/-?(0|[1-9][0-9]*)([.][0-9]+)?([eE][+-]?[0-9]+)?/).map(Number).desc("number");
  },
  String: function() {
    let Z = _A(_r, Ir, Vr).sort(P5).map(IF).join("|");
    return N1.alt(N1.regexp(new RegExp(`(?!(${Z}))[A-Z0-9_]+`, "i")), N1.regexp(/'((?:[^"\\]|\\.)*)'/, 1), N1.regexp(/"((?:[^"\\]|\\.)*)"/, 1).map((J) => w6.core.type.regex([`^${J}$`, "i"]))).desc("string");
  },
  Value: function(Z) {
    return N1.alt(Z.Number, Z.String);
  },
  ValueParens: function(Z) {
    return N1.alt(Z.ValueParens, Z.ValueOperator, Z.ValueExpressions).wrap(N1.string("("), N1.string(")"));
  },
  ValuePropertyNames: function() {
    return N1.alt(...jV(_r, /LIKE|>=|<=|=|!=|>|<|\)|\s/i));
  },
  ValueOperator: function(Z) {
    return xR(LQ1, N1.alt(Z.ValueParens, Z.ValueExpressions));
  },
  ValueExpressions: function(Z) {
    return N1.alt(Z.Value, Z.ValuePropertyNames);
  },
  ValueQuery: function(Z) {
    return N1.alt(Z.ValueOperator.map((J) => {
      if (J.head) {
        if (J.head.name.startsWith("structure-query.generator"))
          return J;
      } else if (typeof J === "string" && J.length <= 4)
        return w6.struct.generator.atomGroups({
          "residue-test": w6.core.rel.eq([w6.ammp("label_comp_id"), J])
        });
      throw new Error(`values must be part of an comparison, value '${J}'`);
    }));
  }
}), VD0 = (Z) => EQ1.Query.tryParse(Z);

// node_modules/molstar/lib/mol-script/transpilers/pymol/properties.js
var PY = L0, Vb = /[-+]?[0-9]*\.?[0-9]+/;
function OQ1(Z) {
  return Z.split("+").map(PY.atomName);
}
function VA(Z) {
  return Z.split("+").map((J) => J.replace(/^["']|["']$/g, ""));
}
function Pr(Z) {
  if (Z.includes("-") && Z.includes("+")) {
    let J = Z.split("+").map((X) => X.replace(/^["']|["']$/g, "")), $ = [];
    return J.forEach((X) => {
      if (X.includes("-") && !X.startsWith("-")) {
        let [Y, Q] = X.split("-").map((W) => parseInt(W));
        for (let W = Y;W <= Q; W++)
          $.push(W);
      } else if (X.includes("-") && X.startsWith("-") && X.match(/[0-9]+-[-0-9]+/)) {
        let Y = -parseInt(X.split("-")[1]), Q;
        if (X.includes("--"))
          Q = -parseInt(X.split("-")[3]);
        else
          Q = parseInt(X.split("-")[2]);
        for (let W = Y;W <= Q; W++)
          $.push(W);
      } else if (X.includes("-") && X.startsWith("-") && !X.match(/[0-9]+-[-0-9]+/))
        $.push(parseInt(X));
      else
        $.push(parseInt(X));
    }), $;
  } else if (Z.includes("-") && !Z.includes("+")) {
    let J = [];
    if (!Z.startsWith("-")) {
      let [$, X] = Z.split("-").map((Y) => parseInt(Y));
      for (let Y = $;Y <= X; Y++)
        J.push(Y);
    } else if (Z.startsWith("-") && Z.match(/[0-9]+-[-0-9]+/)) {
      let $ = -parseInt(Z.split("-")[1]), X;
      if (Z.includes("--"))
        X = -parseInt(Z.split("-")[3]);
      else
        X = parseInt(Z.split("-")[2]);
      for (let Y = $;Y <= X; Y++)
        J.push(Y);
    } else if (Z.startsWith("-") && !Z.match(/[0-9]+-[-0-9]+/))
      J.push(parseInt(Z));
    else
      J.push(parseInt(Z));
    return J;
  } else if (!Z.includes("-") && Z.includes("+"))
    return VA(Z).map((J) => parseInt(J));
  else
    return [parseInt(Z)];
}
function zQ1(Z) {
  return Z.split("+").map(PY.struct.type.elementSymbol);
}
var DQ1 = {
  H: "helix",
  S: "beta",
  L: "none"
};
function MQ1(Z) {
  return {
    flags: PY.struct.type.secondaryStructureFlags(Z.toUpperCase().split("+").map((J) => DQ1[J] || "none"))
  };
}
var VV = {
  symbol: {
    "@desc": "chemical-symbol-list: list of 1- or 2-letter chemical symbols from the periodic table",
    "@examples": ["symbol O+N"],
    abbr: ["e."],
    regex: /[a-zA-Z'"+]+/,
    map: zQ1,
    level: "atom-test",
    property: PY.acp("elementSymbol")
  },
  name: {
    "@desc": "atom-name-list: list of up to 4-letter codes for atoms in proteins or nucleic acids",
    "@examples": ["name CA+CB+CG+CD"],
    abbr: ["n."],
    regex: /[a-zA-Z0-9'"+]+/,
    map: OQ1,
    level: "atom-test",
    property: PY.ammp("label_atom_id")
  },
  resn: {
    "@desc": "residue-name-list: list of 3-letter codes for amino acids or list of up to 2-letter codes for nucleic acids",
    "@examples": ["resn ASP+GLU+ASN+GLN", "resn A+G"],
    abbr: ["resname", "r."],
    regex: /[a-zA-Z0-9'"+]+/,
    map: VA,
    level: "residue-test",
    property: PY.ammp("label_comp_id")
  },
  resi: {
    "@desc": "residue-identifier-list list of up to 4-digit residue numbers or residue-identifier-range",
    "@examples": ["resi 1+10+100+1000", "resi 1-10"],
    abbr: ["resident", "residue", "resid", "i."],
    regex: /[0-9+-]+/,
    map: Pr,
    level: "residue-test",
    property: PY.ammp("auth_seq_id")
  },
  alt: {
    "@desc": "alternate-conformation-identifier-list list of single letters",
    "@examples": ["alt A+B", 'alt ""', 'alt ""+A'],
    abbr: [],
    regex: /[a-zA-Z0-9'"+]+/,
    map: VA,
    level: "atom-test",
    property: PY.ammp("label_alt_id")
  },
  chain: {
    "@desc": "chain-identifier-list list of single letters or sometimes numbers",
    "@examples": ["chain A"],
    abbr: ["c."],
    regex: /[a-zA-Z0-9'"+]+/,
    map: VA,
    level: "chain-test",
    property: PY.ammp("auth_asym_id")
  },
  segi: {
    "@desc": "segment-identifier-list list of up to 4 letter identifiers",
    "@examples": ["segi lig"],
    abbr: ["segid", "s."],
    regex: /[a-zA-Z0-9'"+]+/,
    map: VA,
    level: "chain-test",
    property: PY.ammp("label_asym_id")
  },
  flag: {
    "@desc": "flag-number a single integer from 0 to 31",
    "@examples": ["flag 0"],
    isUnsupported: !0,
    abbr: ["f."],
    regex: /[0-9]+/,
    map: (Z) => parseInt(Z),
    level: "atom-test"
  },
  numeric_type: {
    "@desc": "type-number a single integer",
    "@examples": ["nt. 5"],
    isUnsupported: !0,
    abbr: ["nt."],
    regex: /[0-9]+/,
    map: (Z) => parseInt(Z),
    level: "atom-test"
  },
  text_type: {
    "@desc": "type-string a list of up to 4 letter codes",
    "@examples": ["text_type HA+HC"],
    isUnsupported: !0,
    abbr: ["tt."],
    regex: /[a-zA-Z0-9'"+]+/,
    map: VA,
    level: "atom-test"
  },
  id: {
    "@desc": "external-index-number a single integer",
    "@examples": ["id 23"],
    regex: /[0-9+-]+/,
    map: Pr,
    level: "atom-test",
    property: PY.ammp("id")
  },
  index: {
    "@desc": "internal-index-number a single integer",
    "@examples": ["index 11"],
    regex: /[0-9+-]+/,
    map: Pr,
    level: "atom-test",
    property: PY.ammp("id")
  },
  ss: {
    "@desc": "secondary-structure-type list of single letters. Helical regions should be assigned H and sheet regions S. Loop regions can either be assigned L or be blank.",
    "@examples": ["ss H+S+L", 'ss S+""'],
    abbr: [],
    regex: /[a-zA-Z'"+]+/,
    map: MQ1,
    level: "residue-test",
    property: PY.ammp("secondaryStructureFlags")
  },
  b: {
    "@desc": "comparison-operator b-factor-value a real number",
    "@examples": ["b > 10"],
    isNumeric: !0,
    abbr: [],
    regex: Vb,
    map: (Z) => parseFloat(Z),
    level: "atom-test",
    property: PY.ammp("B_iso_or_equiv")
  },
  q: {
    "@desc": "comparison-operator occupancy-value a real number",
    "@examples": ["q <0.50"],
    isNumeric: !0,
    abbr: [],
    regex: Vb,
    map: (Z) => parseFloat(Z),
    level: "atom-test",
    property: PY.ammp("occupancy")
  },
  formal_charge: {
    "@desc": "comparison-operator formal charge-value an integer",
    "@examples": ["fc. = -1"],
    isNumeric: !0,
    abbr: ["fc."],
    regex: Vb,
    map: (Z) => parseFloat(Z),
    level: "atom-test",
    property: PY.ammp("pdbx_formal_charge")
  },
  partial_charge: {
    "@desc": "comparison-operator partial charge-value a real number",
    "@examples": ["pc. > 1"],
    isUnsupported: !0,
    isNumeric: !0,
    abbr: ["pc."],
    regex: Vb,
    map: (Z) => parseFloat(Z),
    level: "atom-test"
  },
  elem: {
    "@desc": 'str  atomic element symbol string ("X" if undefined)',
    "@examples": ["elem N"],
    regex: /[a-zA-Z0-9]{1,3}/,
    map: (Z) => PY.es(Z),
    level: "atom-test",
    property: PY.acp("elementSymbol")
  }
};

// node_modules/molstar/lib/mol-script/transpilers/pymol/operators.js
var Y6 = L0, Cr = [
  {
    "@desc": "Selects atoms that are not included in s1.",
    "@examples": [
      "NOT resn ALA",
      "not (resi 42 or chain A)",
      "!resi 42 or chain A"
    ],
    name: "not",
    type: dX,
    rule: N1.alt(N1.regexp(/NOT/i).skip(N1.whitespace), N1.string("!").skip(N1.optWhitespace)),
    map: (Z, J) => IY(J)
  },
  {
    "@desc": "Selects atoms included in both s1 and s2.",
    "@examples": ["chain A AND name CA"],
    name: "and",
    type: QX,
    rule: x3(/AND|&/i),
    map: (Z, J, $) => Y6.struct.modifier.intersectBy({ 0: J, by: $ })
  },
  {
    "@desc": "Selects atoms included in either s1 or s2.",
    "@examples": ["chain A OR chain B"],
    name: "or",
    type: QX,
    rule: x3(/OR|\|/i),
    map: (Z, J, $) => Y6.struct.combinator.merge([J, $])
  },
  {
    "@desc": "Selects atoms in s1 whose identifiers name, resi, resn, chain and segi all match atoms in s2.",
    "@examples": ["chain A IN chain B"],
    name: "in",
    type: QX,
    rule: x3(/IN/i),
    map: (Z, J, $) => {
      return Y6.struct.filter.withSameAtomProperties({
        0: J,
        source: $,
        property: Y6.core.type.compositeKey([
          Y6.ammp("label_atom_id"),
          Y6.ammp("label_seq_id"),
          Y6.ammp("label_comp_id"),
          Y6.ammp("auth_asym_id"),
          Y6.ammp("label_asym_id")
        ])
      });
    }
  },
  {
    "@desc": "Selects atoms in s1 whose identifiers name and resi match atoms in s2.",
    "@examples": ["chain A LIKE chain B"],
    name: "like",
    type: QX,
    rule: x3(/LIKE|l\./i),
    map: (Z, J, $) => {
      return Y6.struct.filter.withSameAtomProperties({
        0: J,
        source: $,
        property: Y6.core.type.compositeKey([
          Y6.ammp("label_atom_id"),
          Y6.ammp("label_seq_id")
        ])
      });
    }
  },
  {
    "@desc": "Selects all atoms whose van der Waals radii are separated from the van der Waals radii of s1 by a minimum of X Angstroms.",
    "@examples": ["solvent GAP 2"],
    name: "gap",
    type: AV,
    rule: BV(/GAP\s+([-+]?[0-9]*\.?[0-9]+)/i, 1).map((Z) => parseFloat(Z)),
    map: (Z, J) => {
      return Y6.struct.filter.within({
        "0": Y6.struct.generator.all(),
        target: J,
        "atom-radius": Y6.acp("vdw"),
        "max-radius": Z,
        invert: !0
      });
    }
  },
  {
    "@desc": "Selects atoms with centers within X Angstroms of the center of any atom in s1.",
    "@examples": ["resname LIG AROUND 1"],
    name: "around",
    abbr: ["a."],
    type: AV,
    rule: BV(/(AROUND|a\.)\s+([-+]?[0-9]*\.?[0-9]+)/i, 2).map((Z) => parseFloat(Z)),
    map: (Z, J) => {
      return Y6.struct.modifier.exceptBy({
        "0": Y6.struct.filter.within({
          "0": Y6.struct.generator.all(),
          target: J,
          "max-radius": Z
        }),
        by: J
      });
    }
  },
  {
    "@desc": "Expands s1 by all atoms within X Angstroms of the center of any atom in s1.",
    "@examples": ["chain A EXPAND 3"],
    name: "expand",
    abbr: ["x."],
    type: AV,
    rule: BV(/(EXPAND|x\.)\s+([-+]?[0-9]*\.?[0-9]+)/i, 2).map((Z) => parseFloat(Z)),
    map: (Z, J) => {
      return Y6.struct.modifier.includeSurroundings({ 0: J, radius: Z });
    }
  },
  {
    "@desc": "Selects atoms in s1 that are within X Angstroms of any atom in s2.",
    "@examples": ["chain A WITHIN 3 OF chain B"],
    name: "within",
    abbr: ["w."],
    type: QX,
    rule: Tb("WITHIN", "w."),
    map: (Z, J, $) => {
      return Y6.struct.filter.within({
        0: J,
        target: $,
        "max-radius": Z
      });
    }
  },
  {
    "@desc": "Same as within, but excludes s2 from the selection (and thus is identical to s1 and s2 around X).",
    "@examples": ["chain A NEAR_TO 3 OF chain B"],
    name: "near_to",
    abbr: ["nto."],
    type: QX,
    rule: Tb("NEAR_TO", "nto."),
    map: (Z, J, $) => {
      return Y6.struct.modifier.exceptBy({
        "0": Y6.struct.filter.within({
          "0": J,
          target: $,
          "max-radius": Z
        }),
        by: $
      });
    }
  },
  {
    "@desc": "Selects atoms in s1 that are at least X Anstroms away from s2.",
    "@examples": ["solvent BEYOND 2 OF chain A"],
    name: "beyond",
    abbr: ["be."],
    type: QX,
    rule: Tb("BEYOND", "be."),
    map: (Z, J, $) => {
      return Y6.struct.modifier.exceptBy({
        "0": Y6.struct.filter.within({
          "0": J,
          target: $,
          "max-radius": Z,
          invert: !0
        }),
        by: $
      });
    }
  },
  {
    "@desc": "Expands selection to complete residues.",
    "@examples": ["BYRESIDUE name N"],
    name: "byresidue",
    abbr: ["byresi", "byres", "br."],
    type: dX,
    rule: yW(/BYRESIDUE|byresi|byres|br\./i),
    map: (Z, J) => {
      return PK(Y6.struct.modifier.expandProperty({
        "0": Y6.struct.modifier.union({ 0: J }),
        property: Y6.ammp("residueKey")
      }));
    }
  },
  {
    "@desc": "Completely selects all alpha carbons in all residues covered by a selection.",
    "@examples": ["BYCALPHA chain A"],
    name: "bycalpha",
    abbr: ["bca."],
    type: dX,
    rule: yW(/BYCALPHA|bca\./i),
    map: (Z, J) => {
      return Y6.struct.generator.queryInSelection({
        "0": Y6.struct.modifier.expandProperty({
          "0": Y6.struct.modifier.union({ 0: J }),
          property: Y6.ammp("residueKey")
        }),
        query: Y6.struct.generator.atomGroups({
          "atom-test": Y6.core.rel.eq([
            Y6.atomName("CA"),
            Y6.ammp("label_atom_id")
          ])
        })
      });
    }
  },
  {
    "@desc": "Expands selection to complete molecules.",
    "@examples": ["BYMOLECULE resi 20-30"],
    name: "bymolecule",
    isUnsupported: !0,
    abbr: ["bymol", "bm."],
    type: dX,
    rule: yW(/BYMOLECULE|bymol|bm\./i),
    map: (Z, J) => {
      return PK(Y6.struct.modifier.expandProperty({
        "0": Y6.struct.modifier.union({ 0: J }),
        property: Y6.atp("connectedComponentKey")
      }));
    }
  },
  {
    "@desc": "Expands selection to complete fragments.",
    "@examples": ["BYFRAGMENT resi 10"],
    name: "byfragment",
    abbr: ["byfrag", "bf."],
    isUnsupported: !0,
    type: dX,
    rule: yW(/BYFRAGMENT|byfrag|bf\./i),
    map: (Z, J) => [Z, J]
  },
  {
    "@desc": "Expands selection to complete segments.",
    "@examples": ["BYSEGMENT resn CYS"],
    name: "bysegment",
    abbr: ["bysegi", "byseg", "bs."],
    type: dX,
    rule: yW(/BYSEGMENT|bysegi|byseg|bs\./i),
    map: (Z, J) => {
      return PK(Y6.struct.modifier.expandProperty({
        "0": Y6.struct.modifier.union({ 0: J }),
        property: Y6.ammp("chainKey")
      }));
    }
  },
  {
    "@desc": "Expands selection to complete objects.",
    "@examples": ["BYOBJECT chain A"],
    name: "byobject",
    abbr: ["byobj", "bo."],
    isUnsupported: !0,
    type: dX,
    rule: yW(/BYOBJECT|byobj|bo\./i),
    map: (Z, J) => [Z, J]
  },
  {
    "@desc": "Expands selection to unit cell.",
    "@examples": ["BYCELL chain A"],
    name: "bycell",
    isUnsupported: !0,
    type: dX,
    rule: yW(/BYCELL/i),
    map: (Z, J) => [Z, J]
  },
  {
    "@desc": "All rings of size ≤ 7 which have at least one atom in s1.",
    "@examples": ["BYRING resn HEM"],
    name: "byring",
    type: dX,
    rule: yW(/BYRING/i),
    map: (Z, J) => {
      return PK(Y6.struct.modifier.intersectBy({
        "0": Y6.struct.filter.pick({
          "0": Y6.struct.generator.rings(),
          test: Y6.core.logic.and([
            Y6.core.rel.lte([Y6.struct.atomSet.atomCount(), 7]),
            Y6.core.rel.gr([Y6.struct.atomSet.countQuery([J]), 1])
          ])
        }),
        by: J
      }));
    }
  },
  {
    "@desc": "Selects atoms directly bonded to s1, excludes s1.",
    "@examples": ["NEIGHBOR resn CYS"],
    name: "neighbor",
    type: dX,
    abbr: ["nbr."],
    rule: yW(/NEIGHBOR|nbr\./i),
    map: (Z, J) => {
      return Y6.struct.modifier.exceptBy({
        "0": PK(Y6.struct.modifier.includeConnected({
          "0": Y6.struct.modifier.union({ 0: J }),
          "bond-test": !0
        })),
        by: J
      });
    }
  },
  {
    "@desc": "Selects atoms directly bonded to s1, may include s1.",
    "@examples": ["BOUND_TO name CA"],
    name: "bound_to",
    abbr: ["bto."],
    type: dX,
    rule: yW(/BOUND_TO|bto\./i),
    map: (Z, J) => {
      return PK(Y6.struct.modifier.includeConnected({
        "0": Y6.struct.modifier.union({ 0: J })
      }));
    }
  },
  {
    "@desc": "Extends s1 by X bonds connected to atoms in s1.",
    "@examples": ["resname LIG EXTEND 3"],
    name: "extend",
    abbr: ["xt."],
    type: AV,
    rule: BV(/(EXTEND|xt\.)\s+([0-9]+)/i, 2).map((Z) => parseInt(Z)),
    map: (Z, J) => {
      return PK(Y6.struct.modifier.includeConnected({
        "0": Y6.struct.modifier.union({ 0: J }),
        "bond-test": !0,
        "layer-count": Z
      }));
    }
  }
];

// node_modules/molstar/lib/mol-script/transpilers/pymol/keywords.js
var g2 = L0, nQ = {
  nucleic: ["A", "C", "T", "G", "U", "DA", "DC", "DT", "DG", "DU"],
  protein: ["ALA", "ARG", "ASN", "ASP", "CYS", "CYX", "GLN", "GLU", "GLY", "HIS", "HID", "HIE", "HIP", "ILE", "LEU", "LYS", "MET", "MSE", "PHE", "PRO", "SER", "THR", "TRP", "TYR", "VAL"],
  solvent: ["HOH", "WAT", "H20", "TIP", "SOL"]
}, ID0 = {
  nucleic: [
    "P",
    "O3'",
    "O5'",
    "C5'",
    "C4'",
    "C3'",
    "OP1",
    "OP2",
    "O3*",
    "O5*",
    "C5*",
    "C4*",
    "C3*",
    "C2'",
    "C1'",
    "O4'",
    "O2'"
  ],
  protein: ["C", "N", "CA", "O"]
};
function PD0() {
  return g2.struct.combinator.merge([
    g2.struct.modifier.intersectBy({
      0: g2.struct.generator.atomGroups({
        "residue-test": g2.core.set.has([
          g2.core.type.set(nQ.protein),
          g2.ammp("label_comp_id")
        ])
      }),
      by: g2.struct.generator.atomGroups({
        "atom-test": g2.core.set.has([
          g2.core.type.set(ID0.protein),
          g2.ammp("label_atom_id")
        ])
      })
    }),
    g2.struct.modifier.intersectBy({
      0: g2.struct.generator.atomGroups({
        "residue-test": g2.core.set.has([
          g2.core.type.set(nQ.nucleic),
          g2.ammp("label_comp_id")
        ])
      }),
      by: g2.struct.generator.atomGroups({
        "atom-test": g2.core.set.has([
          g2.core.type.set(ID0.nucleic),
          g2.ammp("label_atom_id")
        ])
      })
    })
  ]);
}
var kr = {
  all: {
    "@desc": "All atoms currently loaded into PyMOL",
    abbr: ["*"],
    map: () => g2.struct.generator.all()
  },
  none: {
    "@desc": "No atoms (empty selection)",
    map: () => g2.struct.generator.empty()
  },
  hydrogens: {
    "@desc": "All hydrogen atoms currently loaded into PyMOL",
    abbr: ["hydro", "h."],
    map: () => g2.struct.generator.atomGroups({
      "atom-test": g2.core.rel.eq([
        g2.acp("elementSymbol"),
        g2.es("H")
      ])
    })
  },
  hetatm: {
    "@desc": "All atoms loaded from Protein Data Bank HETATM records",
    abbr: ["het"],
    map: () => g2.struct.generator.atomGroups({
      "atom-test": g2.core.rel.eq([g2.ammp("isHet"), !0])
    })
  },
  visible: {
    "@desc": "All atoms in enabled objects with at least one visible representation",
    abbr: ["v."]
  },
  polymer: {
    "@desc": "All atoms on the polymer (not het). Finds atoms with residue identifiers matching a known polymer, such a peptide and DNA.",
    abbr: ["pol."],
    map: () => g2.struct.generator.atomGroups({
      "residue-test": g2.core.set.has([
        g2.core.type.set(nQ.nucleic.concat(nQ.protein)),
        g2.ammp("label_comp_id")
      ])
    })
  },
  sidechain: {
    "@desc": "Polymer non-backbone atoms (new in PyMOL 1.6.1)",
    abbr: ["sc."],
    map: () => {
      return g2.struct.modifier.exceptBy({
        "0": g2.struct.generator.atomGroups({
          "residue-test": g2.core.set.has([
            g2.core.type.set(nQ.nucleic.concat(nQ.protein)),
            g2.ammp("label_comp_id")
          ])
        }),
        by: PD0()
      });
    }
  },
  present: {
    "@desc": "All atoms with defined coordinates in the current state (used in creating movies)",
    abbr: ["pr."]
  },
  center: {
    "@desc": "Pseudo-atom at the center of the scene"
  },
  origin: {
    "@desc": "Pseudo-atom at the origin of rotation"
  },
  enabled: {
    "@desc": "All enabled objects or selections from the object list."
  },
  masked: {
    "@desc": "All masked atoms.",
    abbr: ["msk."]
  },
  protected: {
    "@desc": "All protected atoms.",
    abbr: ["pr."]
  },
  bonded: {
    "@desc": "All bonded atoms",
    map: () => g2.struct.generator.atomGroups({
      "atom-test": g2.core.rel.gr([g2.struct.atomProperty.core.bondCount({
        flags: g2.struct.type.bondFlags(["covalent", "metallic", "sulfide"])
      }), 0])
    })
  },
  donors: {
    "@desc": "All hydrogen bond donor atoms.",
    abbr: ["don."]
  },
  acceptors: {
    "@desc": "All hydrogen bond acceptor atoms.",
    abbr: ["acc."]
  },
  fixed: {
    "@desc": "All fixed atoms.",
    abbr: ["fxd."]
  },
  restrained: {
    "@desc": "All restrained atoms.",
    abbr: ["rst."]
  },
  organic: {
    "@desc": "All atoms in non-polymer organic compounds (e.g. ligands, buffers). Finds carbon-containing molecules that do not match known polymers.",
    abbr: ["org."],
    map: () => PK(g2.struct.modifier.expandProperty({
      "0": g2.struct.modifier.union([
        g2.struct.generator.queryInSelection({
          "0": g2.struct.generator.atomGroups({
            "residue-test": g2.core.logic.not([
              g2.core.set.has([
                g2.core.type.set(nQ.nucleic.concat(nQ.protein)),
                g2.ammp("label_comp_id")
              ])
            ])
          }),
          query: g2.struct.generator.atomGroups({
            "atom-test": g2.core.rel.eq([
              g2.es("C"),
              g2.acp("elementSymbol")
            ])
          })
        })
      ]),
      property: g2.ammp("residueKey")
    }))
  },
  inorganic: {
    "@desc": "All non-polymer inorganic atoms/ions. Finds atoms in molecules that do not contain carbon and do not match any known solvent residues.",
    abbr: ["ino."],
    map: () => PK(g2.struct.modifier.expandProperty({
      "0": g2.struct.modifier.union([
        g2.struct.filter.pick({
          "0": g2.struct.generator.atomGroups({
            "residue-test": g2.core.logic.not([
              g2.core.set.has([
                g2.core.type.set(nQ.nucleic.concat(nQ.protein).concat(nQ.solvent)),
                g2.ammp("label_comp_id")
              ])
            ]),
            "group-by": g2.ammp("residueKey")
          }),
          test: g2.core.logic.not([
            g2.core.set.has([
              g2.struct.atomSet.propertySet([g2.acp("elementSymbol")]),
              g2.es("C")
            ])
          ])
        })
      ]),
      property: g2.ammp("residueKey")
    }))
  },
  solvent: {
    "@desc": "All water molecules. The hardcoded solvent residue identifiers are currently: HOH, WAT, H20, TIP, SOL.",
    abbr: ["sol."],
    map: () => g2.struct.generator.atomGroups({
      "residue-test": g2.core.set.has([
        g2.core.type.set(nQ.solvent),
        g2.ammp("label_comp_id")
      ])
    })
  },
  guide: {
    "@desc": "All protein CA and nucleic acid C4*/C4",
    map: () => g2.struct.combinator.merge([
      g2.struct.generator.atomGroups({
        "atom-test": g2.core.rel.eq([
          g2.atomName("CA"),
          g2.ammp("label_atom_id")
        ]),
        "residue-test": g2.core.set.has([
          g2.core.type.set(nQ.protein),
          g2.ammp("label_comp_id")
        ])
      }),
      g2.struct.generator.atomGroups({
        "atom-test": g2.core.set.has([
          IK(["C4*", "C4'"]),
          g2.ammp("label_atom_id")
        ]),
        "residue-test": g2.core.set.has([
          g2.core.type.set(nQ.nucleic),
          g2.ammp("label_comp_id")
        ])
      })
    ])
  },
  metals: {
    "@desc": "All metal atoms (new in PyMOL 1.6.1)"
  },
  backbone: {
    "@desc": "Polymer backbone atoms (new in PyMOL 1.6.1)",
    abbr: ["bb."],
    map: () => PD0()
  },
  "polymer.protein": {
    "@desc": "Protein (New in PyMOL 2.1)",
    abbr: ["polymer.protein"],
    map: () => g2.struct.generator.atomGroups({
      "residue-test": g2.core.set.has([
        g2.core.type.set(nQ.protein),
        g2.ammp("label_comp_id")
      ])
    })
  },
  "polymer.nucleic": {
    "@desc": "Nucleic Acid (New in PyMOL 2.1)",
    abbr: ["polymer.nucleic"],
    map: () => g2.struct.generator.atomGroups({
      "residue-test": g2.core.set.has([
        g2.core.type.set(nQ.nucleic),
        g2.ammp("label_comp_id")
      ])
    })
  }
};

// node_modules/molstar/lib/mol-script/transpilers/pymol/parser.js
var AQ1 = L0, aJ = AD0(VV), E$ = N1.string("/");
function V7(Z) {
  return Z.or(N1.of(null));
}
function BQ1(Z) {
  let J = {}, $ = {};
  for (let X in Z) {
    let Y = VV[X];
    if (!Y)
      throw new Error(`property '${X}' not supported, value '${Z[X]}'`);
    if (Z[X] === null)
      continue;
    if (!$[Y.level])
      $[Y.level] = [];
    $[Y.level].push(Z[X]);
  }
  for (let X in $)
    J[X] = wV($[X]);
  return AQ1.struct.generator.atomGroups(J);
}
var wQ1 = N1.createLanguage({
  Parens: function(Z) {
    return N1.alt(Z.Parens, Z.Operator, Z.Expression).wrap(N1.string("("), N1.string(")"));
  },
  Expression: function(Z) {
    return N1.alt(Z.Keywords, Z.AtomSelectionMacro.map(BQ1), Z.NamedAtomProperties, Z.Pepseq, Z.Rep, Z.Object);
  },
  AtomSelectionMacro: function(Z) {
    return N1.alt(E$.then(N1.alt(N1.seq(V7(Z.ObjectProperty).skip(E$), V7(aJ.segi).skip(E$), V7(aJ.chain).skip(E$), V7(aJ.resi).skip(E$), V7(aJ.name)).map((J) => {
      return { object: J[0], segi: J[1], chain: J[2], resi: J[3], name: J[4] };
    }), N1.seq(V7(Z.ObjectProperty).skip(E$), V7(aJ.segi).skip(E$), V7(aJ.chain).skip(E$), V7(aJ.resi)).map((J) => {
      return { object: J[0], segi: J[1], chain: J[2], resi: J[3] };
    }), N1.seq(V7(Z.ObjectProperty).skip(E$), V7(aJ.segi).skip(E$), V7(aJ.chain)).map((J) => {
      return { object: J[0], segi: J[1], chain: J[2] };
    }), N1.seq(V7(Z.ObjectProperty).skip(E$), V7(aJ.segi)).map((J) => {
      return { object: J[0], segi: J[1] };
    }), N1.seq(V7(Z.ObjectProperty)).map((J) => {
      return { object: J[0] };
    }))), N1.alt(N1.seq(V7(Z.ObjectProperty).skip(E$), V7(aJ.segi).skip(E$), V7(aJ.chain).skip(E$), V7(aJ.resi).skip(E$), V7(aJ.name)).map((J) => {
      return { object: J[0], segi: J[1], chain: J[2], resi: J[3], name: J[4] };
    }), N1.seq(V7(aJ.segi).skip(E$), V7(aJ.chain).skip(E$), V7(aJ.resi).skip(E$), V7(aJ.name)).map((J) => {
      return { segi: J[0], chain: J[1], resi: J[2], name: J[3] };
    }), N1.seq(V7(aJ.chain).skip(E$), V7(aJ.resi).skip(E$), V7(aJ.name)).map((J) => {
      return { chain: J[0], resi: J[1], name: J[2] };
    }), N1.seq(V7(aJ.resi).skip(E$), V7(aJ.name)).map((J) => {
      return { resi: J[0], name: J[1] };
    })));
  },
  NamedAtomProperties: function() {
    return N1.alt(..._b(VV));
  },
  Keywords: () => N1.alt(...TA(kr)),
  ObjectProperty: () => {
    let Z = _A(VV, kr, Cr).sort(P5).map(IF).join("|");
    return N1.regexp(new RegExp(`(?!(${Z}))[A-Z0-9_]+`, "i"));
  },
  Object: (Z) => {
    return Z.ObjectProperty.notFollowedBy(E$).map((J) => {
      throw new Error(`property 'object' not supported, value '${J}'`);
    });
  },
  Pepseq: () => {
    return N1.regexp(/(PEPSEQ|ps\.)\s+([a-z]+)/i, 2).map(QU("operator 'pepseq' not supported"));
  },
  Rep: () => {
    return N1.regexp(/REP\s+(lines|spheres|mesh|ribbon|cartoon|sticks|dots|surface|labels|extent|nonbonded|nb_spheres|slice|extent|slice|dashes|angles|dihedrals|cgo|cell|callback|everything)/i, 1).map(QU("operator 'rep' not supported"));
  },
  Operator: function(Z) {
    return xR(Cr, N1.alt(Z.Parens, Z.Expression, Z.Operator));
  },
  Query: function(Z) {
    return N1.alt(Z.Operator, Z.Parens, Z.Expression).trim(N1.optWhitespace);
  }
}), CD0 = (Z) => wQ1.Query.tryParse(Z);

// node_modules/molstar/lib/mol-script/transpilers/vmd/properties.js
var vJ = L0, C5 = /[-+]?[0-9]*\.?[0-9]+/, Ib = /[+]?[0-9]+/, IV = /[-+]?[0-9]+/;
function Vz(Z) {
  return Z;
}
var vr = {
  T: "turn",
  E: "sheet",
  B: "strand",
  H: "alpha",
  G: "3-10",
  I: "pi",
  C: "none"
};
function Pb(Z) {
  return vJ.struct.type.secondaryStructureFlags([vr[Z.toUpperCase()] || "none"]);
}
var KU = {
  name: {
    "@desc": "str    atom name",
    "@examples": ["name CA"],
    regex: /[a-zA-Z0-9]+/,
    map: vJ.atomName,
    level: "atom-test",
    property: vJ.ammp("label_atom_id")
  },
  type: {
    "@desc": "str    atom type",
    "@examples": ["type C3"],
    isUnsupported: !0,
    regex: /[a-zA-Z0-9]+/,
    map: Vz,
    level: "atom-test"
  },
  index: {
    "@desc": "num    the atom number, starting at 0",
    "@examples": ["index 10"],
    isNumeric: !0,
    regex: Ib,
    map: (Z) => parseInt(Z) - 1,
    level: "atom-test",
    property: vJ.ammp("id")
  },
  serial: {
    "@desc": "num    the atom number, starting at 1",
    "@examples": ["serial 11"],
    isNumeric: !0,
    regex: Ib,
    map: (Z) => parseInt(Z),
    level: "atom-test",
    property: vJ.ammp("id")
  },
  atomicnumber: {
    "@desc": "num    atomic number (0 if undefined)",
    "@examples": ["atomicnumber 13"],
    isNumeric: !0,
    regex: Ib,
    map: (Z) => parseInt(Z),
    level: "atom-test",
    property: vJ.acp("atomicNumber")
  },
  element: {
    "@desc": 'str  atomic element symbol string ("X" if undefined)',
    "@examples": ["element N"],
    regex: /[a-zA-Z0-9]{1,3}/,
    map: (Z) => vJ.es(Z),
    level: "atom-test",
    property: vJ.acp("elementSymbol")
  },
  altloc: {
    "@desc": "str  alternate location/conformation identifier",
    "@examples": ["altloc C"],
    regex: /[a-zA-Z0-9]+/,
    map: Vz,
    level: "atom-test",
    property: vJ.ammp("label_alt_id")
  },
  chain: {
    "@desc": "str  the one-character chain identifier",
    "@examples": ["chain A"],
    regex: /[a-zA-Z0-9]+/,
    map: Vz,
    level: "residue-test",
    property: vJ.ammp("auth_asym_id")
  },
  residue: {
    "@desc": "num  a set of connected atoms with the same residue number",
    "@examples": ["residue < 11", "residue 11"],
    isNumeric: !0,
    regex: IV,
    map: (Z) => parseInt(Z),
    level: "residue-test",
    property: vJ.ammp("auth_seq_id")
  },
  fragment: {
    "@desc": "num  a set of connected residues",
    "@examples": ["fragment 42"],
    isUnsupported: !0,
    isNumeric: !0,
    regex: IV,
    map: (Z) => parseInt(Z),
    level: "residue-test"
  },
  pfrag: {
    "@desc": "num  a set of connected protein residues",
    "@examples": ["pfrag 42"],
    isUnsupported: !0,
    isNumeric: !0,
    regex: IV,
    map: (Z) => parseInt(Z),
    level: "residue-test"
  },
  nfrag: {
    "@desc": "num  a set of connected nucleic residues",
    "@examples": ["nfrag 42"],
    isUnsupported: !0,
    isNumeric: !0,
    regex: IV,
    map: (Z) => parseInt(Z),
    level: "residue-test"
  },
  sequence: {
    "@desc": "str  a sequence given by one letter names",
    "@examples": ["sequence PGATTACA"],
    isUnsupported: !0,
    regex: /[a-zA-Z0-9]+/,
    map: Vz,
    level: "residue-test"
  },
  numbonds: {
    "@desc": "num  number of bonds",
    "@examples": ["numbonds = 2", "numbonds >= 3"],
    isNumeric: !0,
    regex: Ib,
    map: (Z) => parseInt(Z),
    level: "atom-test",
    property: vJ.acp("bondCount")
  },
  resname: {
    "@desc": "str  residue name",
    "@examples": ["resname ALA"],
    regex: /[a-zA-Z0-9]+/,
    map: Vz,
    level: "residue-test",
    property: vJ.ammp("auth_comp_id")
  },
  resid: {
    "@desc": "num  residue id",
    "@examples": ["resid 42"],
    isNumeric: !0,
    regex: IV,
    map: (Z) => parseInt(Z),
    level: "residue-test",
    property: vJ.ammp("auth_seq_id")
  },
  segname: {
    "@desc": "str  segment name",
    "@examples": ["segname B"],
    regex: /[a-zA-Z0-9]+/,
    map: Vz,
    level: "residue-test",
    property: vJ.ammp("label_asym_id")
  },
  x: {
    "@desc": "float  x coordinate",
    "@examples": ["x 42"],
    isNumeric: !0,
    regex: C5,
    map: (Z) => parseFloat(Z),
    level: "atom-test",
    property: vJ.acp("x")
  },
  y: {
    "@desc": "float  y coordinate",
    "@examples": ["y > 1.7"],
    isNumeric: !0,
    regex: C5,
    map: (Z) => parseFloat(Z),
    level: "atom-test",
    property: vJ.acp("y")
  },
  z: {
    "@desc": "float  z coordinate",
    "@examples": ["z < 11", "z > -21"],
    isNumeric: !0,
    regex: C5,
    map: (Z) => parseFloat(Z),
    level: "atom-test",
    property: vJ.acp("z")
  },
  radius: {
    "@desc": "float  atomic radius",
    "@examples": ["radius > 1.3"],
    isNumeric: !0,
    regex: C5,
    map: (Z) => parseFloat(Z),
    level: "atom-test",
    property: vJ.acp("vdw")
  },
  mass: {
    "@desc": "float  atomic mass",
    "@examples": ["mass > 2"],
    isNumeric: !0,
    regex: C5,
    map: (Z) => parseFloat(Z),
    level: "atom-test",
    property: vJ.acp("mass")
  },
  charge: {
    "@desc": "float  atomic charge",
    "@examples": ["charge > 0", "charge 1"],
    isNumeric: !0,
    regex: C5,
    map: (Z) => parseFloat(Z),
    level: "atom-test",
    property: vJ.ammp("pdbx_formal_charge")
  },
  beta: {
    "@desc": "float  temperature factor",
    "@examples": ["beta < 20", "beta > 35"],
    isNumeric: !0,
    regex: C5,
    map: (Z) => parseFloat(Z),
    level: "atom-test",
    property: vJ.ammp("B_iso_or_equiv")
  },
  occupancy: {
    "@desc": "float  occupancy",
    "@examples": ["occupancy 1", "occupancy < 1"],
    isNumeric: !0,
    regex: C5,
    map: (Z) => parseFloat(Z),
    level: "atom-test",
    property: vJ.ammp("occupancy")
  },
  user: {
    "@desc": "float  time-varying user-specified value",
    "@examples": ["user < 0.1"],
    isUnsupported: !0,
    isNumeric: !0,
    regex: C5,
    map: (Z) => parseFloat(Z),
    level: "atom-test"
  },
  rasmol: {
    "@desc": "str  translates Rasmol selection string to VMD",
    "@examples": ["rasmol 'all'"],
    isUnsupported: !0,
    regex: /[^']*/,
    map: Vz,
    level: "atom-test"
  },
  structure: {
    "@desc": "str  single letter name for the secondary structure",
    "@examples": ["structure H", "structure H E"],
    regex: /T|E|B|H|G|I|C/i,
    map: Pb,
    level: "atom-test",
    property: vJ.ammp("secondaryStructureFlags")
  },
  phi: {
    "@desc": "float  phi backbone conformational angles",
    "@examples": ["phi < 160"],
    isUnsupported: !0,
    isNumeric: !0,
    regex: C5,
    map: (Z) => parseFloat(Z),
    level: "residue-test"
  },
  psi: {
    "@desc": "float  psi backbone conformational angles",
    "@examples": ["psi < 160"],
    isUnsupported: !0,
    isNumeric: !0,
    regex: C5,
    map: (Z) => parseFloat(Z),
    level: "residue-test"
  },
  ufx: {
    "@desc": "num  force to apply in the x coordinate",
    "@examples": ["ufx 1"],
    isUnsupported: !0,
    isNumeric: !0,
    regex: C5,
    map: (Z) => parseInt(Z),
    level: "atom-test"
  },
  ufy: {
    "@desc": "num  force to apply in the y coordinate",
    "@examples": ["ufy 1"],
    isUnsupported: !0,
    isNumeric: !0,
    regex: C5,
    map: (Z) => parseInt(Z),
    level: "atom-test"
  },
  ufz: {
    "@desc": "num  force to apply in the z coordinate",
    "@examples": ["ufz 1"],
    isUnsupported: !0,
    isNumeric: !0,
    regex: C5,
    map: (Z) => parseInt(Z),
    level: "atom-test"
  }
};

// node_modules/molstar/lib/mol-script/transpilers/vmd/operators.js
var Iz = L0, jQ1 = Object.keys(KU).sort(P5).filter((Z) => !KU[Z].isUnsupported).join("|"), Sr = [
  {
    "@desc": "Selects atoms that are not included in s1.",
    "@examples": ["not protein"],
    name: "not",
    type: dX,
    rule: N1.regexp(/NOT/i).skip(N1.whitespace),
    map: (Z, J) => IY(J)
  },
  {
    "@desc": "Selects atoms within a specified distance of a selection",
    "@examples": ["within 5 of name FE"],
    name: "within",
    type: dX,
    rule: yW(/WITHIN\s+([-+]?[0-9]*\.?[0-9]+)\s+OF/i, 1).map((Z) => parseFloat(Z)),
    map: (Z, J) => {
      return Iz.struct.modifier.includeSurroundings({ 0: J, radius: Z });
    }
  },
  {
    "@desc": "Exclusive within, equivalent to (within 3 of X) and not X",
    "@examples": ["exwithin 10 of resname HEM"],
    name: "exwithin",
    type: dX,
    rule: yW(/EXWITHIN\s+([-+]?[0-9]*\.?[0-9]+)\s+OF/i, 1).map((Z) => parseFloat(Z)),
    map: (Z, J) => {
      return Iz.struct.modifier.exceptBy({
        "0": Iz.struct.modifier.includeSurroundings({ 0: J, radius: Z }),
        by: J
      });
    }
  },
  {
    "@desc": "Selects atoms which have the same keyword as the atoms in a given selection",
    "@examples": ["same resid as name FE"],
    name: "same",
    type: dX,
    rule: yW(new RegExp(`SAME\\s+(${jQ1})\\s+AS`, "i"), 1).map((Z) => KU[Z].property),
    map: (Z, J) => {
      return Iz.struct.filter.withSameAtomProperties({
        "0": Iz.struct.generator.all(),
        source: J,
        property: Z
      });
    }
  },
  {
    "@desc": "Selects atoms included in both s1 and s2.",
    "@examples": ["backbone and protein"],
    name: "and",
    type: QX,
    rule: N1.alt(x3(/AND/i), N1.whitespace),
    map: (Z, J, $) => Iz.struct.modifier.intersectBy({ 0: J, by: $ })
  },
  {
    "@desc": "Selects atoms included in either s1 or s2.",
    "@examples": ["water or protein"],
    name: "or",
    type: QX,
    rule: x3(/OR/i),
    map: (Z, J, $) => Iz.struct.combinator.merge([J, $])
  }
];

// node_modules/molstar/lib/mol-script/transpilers/vmd/keywords.js
var h6 = L0;
function GU() {
  return h6.struct.filter.pick({
    0: h6.struct.generator.atomGroups({
      "group-by": h6.ammp("residueKey")
    }),
    test: h6.core.set.isSubset([
      IK(["C", "N", "CA", "O"]),
      h6.ammpSet("label_atom_id")
    ])
  });
}
function fr() {
  return h6.struct.filter.pick({
    0: h6.struct.generator.atomGroups({
      "group-by": h6.ammp("residueKey")
    }),
    test: h6.core.logic.and([
      h6.core.set.isSubset([
        IK(["P"]),
        h6.ammpSet("label_atom_id")
      ]),
      h6.core.logic.or([
        h6.core.set.isSubset([
          IK(["O3'", "C3'", "C4'", "C5'", "O5'"]),
          h6.ammpSet("label_atom_id")
        ]),
        h6.core.set.isSubset([
          IK(["O3*", "C3*", "C4*", "C5*", "O5*"]),
          h6.ammpSet("label_atom_id")
        ])
      ])
    ])
  });
}
function kD0() {
  return h6.struct.combinator.merge([
    h6.struct.generator.queryInSelection({
      0: GU(),
      query: h6.struct.generator.atomGroups({
        "atom-test": h6.core.set.has([
          IK(vD0.protein),
          h6.ammp("label_atom_id")
        ])
      })
    }),
    h6.struct.generator.queryInSelection({
      0: fr(),
      query: h6.struct.generator.atomGroups({
        "atom-test": h6.core.set.has([
          IK(vD0.nucleic),
          h6.ammp("label_atom_id")
        ])
      })
    })
  ]);
}
function Hq(Z) {
  return h6.struct.generator.atomGroups({
    "residue-test": h6.core.flags.hasAll([
      h6.ammp("secondaryStructureFlags"),
      h6.struct.type.secondaryStructureFlags(Z)
    ])
  });
}
var vD0 = {
  nucleic: ["P", "O3'", "O5'", "C5'", "C4'", "C3'", "OP1", "OP2", "O3*", "O5*", "C5*", "C4*", "C3*"],
  protein: ["C", "N", "CA", "O"]
}, O$ = {
  acidic: ["ASP", "GLU"],
  aliphatic: ["ALA", "GLY", "ILE", "LEU", "VAL"],
  aromatic: ["HIS", "PHE", "TRP", "TYR"],
  at: ["ADA", "A", "THY", "T"],
  basic: ["ARG", "HIS", "LYS"],
  buried: ["ALA", "LEU", "VAL", "ILE", "PHE", "CYS", "MET", "TRP"],
  cg: ["CYT", "C", "GUA", "G"],
  cyclic: ["HIS", "PHE", "PRO", "TRP", "TYR"],
  hydrophobic: ["ALA", "LEU", "VAL", "ILE", "PRO", "PHE", "MET", "TRP"],
  medium: ["VAL", "THR", "ASP", "ASN", "PRO", "CYS", "ASX", "PCA", "HYP"],
  neutral: ["VAL", "PHE", "GLN", "TYR", "HIS", "CYS", "MET", "TRP", "ASX", "GLX", "PCA", "HYP"],
  purine: ["ADE", "A", "GUA", "G"],
  pyrimidine: ["CYT", "C", "THY", "T", "URI", "U"],
  small: ["ALA", "GLY", "SER"],
  water: ["H2O", "HH0", "OHH", "HOH", "OH2", "SOL", "WAT", "TIP", "TIP2", "TIP3", "TIP4"]
}, hr = {
  all: {
    "@desc": "everything",
    map: () => h6.struct.generator.all()
  },
  none: {
    "@desc": "nothing",
    map: () => h6.struct.generator.empty()
  },
  protein: {
    "@desc": "a residue with atoms named C, N, CA, and O",
    map: () => GU()
  },
  nucleic: {
    "@desc": "a residue with atoms named P, O1P, O2P and either O3', C3', C4', C5', O5' or O3*, C3*, C4*, C5*, O5*. This definition assumes that the base is phosphorylated, an assumption which will be corrected in the future.",
    map: () => fr()
  },
  backbone: {
    "@desc": "the C, N, CA, and O atoms of a protein and the equivalent atoms in a nucleic acid.",
    map: () => kD0()
  },
  sidechain: {
    "@desc": "non-backbone atoms and bonds",
    map: () => IY(kD0())
  },
  water: {
    "@desc": "all atoms with the resname H2O, HH0, OHH, HOH, OH2, SOL, WAT, TIP, TIP2, TIP3 or TIP4",
    abbr: ["waters"],
    map: () => DZ(O$.water)
  },
  at: {
    "@desc": "residues named ADA A THY T",
    map: () => DZ(O$.at)
  },
  acidic: {
    "@desc": "residues named ASP GLU",
    map: () => DZ(O$.acidic)
  },
  acyclic: {
    "@desc": '"protein and not cyclic"',
    map: () => h6.struct.modifier.intersectBy({
      0: GU(),
      by: IY(DZ(O$.cyclic))
    })
  },
  aliphatic: {
    "@desc": "residues named ALA GLY ILE LEU VAL",
    map: () => DZ(O$.aliphatic)
  },
  alpha: {
    "@desc": "atom's residue is an alpha helix",
    map: () => Hq(["alpha"])
  },
  amino: {
    "@desc": "a residue with atoms named C, N, CA, and O",
    map: () => GU()
  },
  aromatic: {
    "@desc": "residues named HIS PHE TRP TYR",
    map: () => DZ(O$.aromatic)
  },
  basic: {
    "@desc": "residues named ARG HIS LYS",
    map: () => DZ(O$.basic)
  },
  bonded: {
    "@desc": "atoms for which numbonds > 0",
    map: () => PK(h6.struct.filter.pick({
      "0": h6.struct.modifier.includeConnected({
        "0": h6.struct.generator.all(),
        "bond-test": h6.core.flags.hasAny([
          h6.struct.bondProperty.flags(),
          h6.struct.type.bondFlags(["covalent", "metallic", "sulfide"])
        ])
      }),
      test: h6.core.rel.gr([
        h6.struct.atomSet.atomCount(),
        1
      ])
    }))
  },
  buried: {
    "@desc": "residues named ALA LEU VAL ILE PHE CYS MET TRP",
    map: () => DZ(O$.buried)
  },
  cg: {
    "@desc": "residues named CYT C GUA G",
    map: () => DZ(O$.cg)
  },
  charged: {
    "@desc": '"basic or acidic"',
    map: () => DZ(O$.basic.concat(O$.acidic))
  },
  cyclic: {
    "@desc": "residues named HIS PHE PRO TRP TYR",
    map: () => DZ(O$.cyclic)
  },
  hetero: {
    "@desc": '"not (protein or nucleic)"',
    map: () => IY(h6.struct.combinator.merge([GU(), fr()]))
  },
  hydrogen: {
    "@desc": 'name "[0-9]?H.*"',
    map: () => h6.struct.generator.atomGroups({
      "atom-test": h6.core.str.match([
        h6.core.type.regex(["^[0-9]?[H].*$", "i"]),
        h6.core.type.str([h6.ammp("label_atom_id")])
      ])
    })
  },
  large: {
    "@desc": '"protein and not (small or medium)"',
    map: () => h6.struct.modifier.intersectBy({
      0: GU(),
      by: IY(DZ(O$.small.concat(O$.medium)))
    })
  },
  medium: {
    "@desc": "residues named VAL THR ASP ASN PRO CYS ASX PCA HYP",
    map: () => DZ(O$.medium)
  },
  neutral: {
    "@desc": "residues named VAL PHE GLN TYR HIS CYS MET TRP ASX GLX PCA HYP",
    map: () => DZ(O$.neutral)
  },
  hydrophobic: {
    "@desc": "hydrophobic resname ALA LEU VAL ILE PRO PHE MET TRP",
    map: () => DZ(O$.hydrophobic)
  },
  polar: {
    "@desc": '"protein and not hydrophobic"',
    map: () => h6.struct.modifier.intersectBy({
      0: GU(),
      by: IY(DZ(O$.hydrophobic))
    })
  },
  purine: {
    "@desc": "residues named ADE A GUA G",
    map: () => DZ(O$.purine)
  },
  pyrimidine: {
    "@desc": "residues named CYT C THY T URI U",
    map: () => DZ(O$.pyrimidine)
  },
  small: {
    "@desc": "residues named ALA GLY SER",
    map: () => DZ(O$.small)
  },
  surface: {
    "@desc": '"protein and not buried"',
    map: () => h6.struct.modifier.intersectBy({
      0: GU(),
      by: IY(DZ(O$.buried))
    })
  },
  alpha_helix: {
    "@desc": "atom's residue is in an alpha helix",
    map: () => Hq(["alpha"])
  },
  pi_helix: {
    "@desc": "atom's residue is in a pi helix",
    map: () => Hq(["pi"])
  },
  helix_3_10: {
    "@desc": "atom's residue is in a 3-10 helix",
    map: () => Hq(["3-10"])
  },
  helix: {
    "@desc": "atom's residue is in an alpha or pi or 3-10 helix",
    map: () => Hq(["helix"])
  },
  extended_beta: {
    "@desc": "atom's residue is a beta sheet",
    map: () => Hq(["sheet"])
  },
  bridge_beta: {
    "@desc": "atom's residue is a beta sheet",
    map: () => Hq(["strand"])
  },
  sheet: {
    "@desc": "atom's residue is a beta sheet",
    map: () => Hq(["beta"])
  },
  turn: {
    "@desc": "atom's residue is in a turn conformation",
    map: () => Hq(["turn"])
  },
  coil: {
    "@desc": "atom's residue is in a coil conformation",
    map: () => h6.struct.modifier.intersectBy({
      0: GU(),
      by: Hq(["none"])
    })
  }
};

// node_modules/molstar/lib/mol-script/transpilers/vmd/functions.js
var UQ = L0, SD0 = {
  sqr: {
    "@desc": "square of x",
    "@examples": ["sqr(2)"],
    map: (Z) => UQ.core.math.pow([Z, 2])
  },
  sqrt: {
    "@desc": "square root of x",
    "@examples": ["sqrt(2)"],
    map: (Z) => UQ.core.math.sqrt([Z])
  },
  abs: {
    "@desc": "absolute value of x",
    "@examples": ["abs(2)"],
    map: (Z) => UQ.core.math.abs([Z])
  },
  floor: {
    "@desc": "largest integer not greater than x",
    "@examples": ["floor(2)"],
    map: (Z) => UQ.core.math.floor([Z])
  },
  ceil: {
    "@desc": "smallest integer not less than x",
    "@examples": ["ceil(2)"],
    map: (Z) => UQ.core.math.ceil([Z])
  },
  sin: {
    "@desc": "sine of x",
    "@examples": ["sin(2)"],
    map: (Z) => UQ.core.math.sin([Z])
  },
  cos: {
    "@desc": "cosine of x",
    "@examples": ["cos(2)"],
    map: (Z) => UQ.core.math.cos([Z])
  },
  tan: {
    "@desc": "tangent of x",
    "@examples": ["tan(2)"],
    map: (Z) => UQ.core.math.tan([Z])
  },
  atan: {
    "@desc": "arctangent of x",
    "@examples": ["atan(2)"],
    map: (Z) => UQ.core.math.atan([Z])
  },
  asin: {
    "@desc": "arcsin of x",
    "@examples": ["asin(2)"],
    map: (Z) => UQ.core.math.asin([Z])
  },
  acos: {
    "@desc": "arccos of x",
    "@examples": ["acos(2)"],
    map: (Z) => UQ.core.math.acos([Z])
  },
  sinh: {
    "@desc": "hyperbolic sine of x",
    "@examples": ["sinh(2)"],
    map: (Z) => UQ.core.math.sinh([Z])
  },
  cosh: {
    "@desc": "hyperbolic cosine of x",
    "@examples": ["cosh(2)"],
    map: (Z) => UQ.core.math.cosh([Z])
  },
  tanh: {
    "@desc": "hyperbolic tangent of x",
    "@examples": ["tanh(2)"],
    map: (Z) => UQ.core.math.tanh([Z])
  },
  exp: {
    "@desc": "e to the power x",
    "@examples": ["exp(2)"],
    map: (Z) => UQ.core.math.exp([Z])
  },
  log: {
    "@desc": "natural log of x",
    "@examples": ["log(2)"],
    map: (Z) => UQ.core.math.log([Z])
  },
  log10: {
    "@desc": "log base 10 of x",
    "@examples": ["log10(2)"],
    map: (Z) => UQ.core.math.log10([Z])
  }
};

// node_modules/molstar/lib/mol-script/transpilers/vmd/parser.js
var i7 = L0, TQ1 = [
  {
    "@desc": "multiplication, division",
    "@examples": [],
    name: "mul-div",
    type: QX,
    rule: N1.regexp(/\s*(\*|\/)\s*/, 1),
    map: (Z, J, $) => {
      switch (Z) {
        case "*":
          return i7.core.math.mult([J, $]);
        case "/":
          return i7.core.math.div([J, $]);
        default:
          throw new Error(`value operator '${Z}' not supported`);
      }
    }
  },
  {
    "@desc": "addition, substraction",
    "@examples": [],
    name: "add-sub",
    type: QX,
    rule: N1.regexp(/\s*(-|\+)\s*/, 1),
    map: (Z, J, $) => {
      switch (Z) {
        case "-":
          return i7.core.math.sub([J, $]);
        case "+":
          return i7.core.math.add([J, $]);
        default:
          throw new Error(`value operator '${Z}' not supported`);
      }
    }
  },
  {
    "@desc": "value comparisons",
    "@examples": [],
    name: "comparison",
    type: QX,
    rule: N1.alt(N1.regexp(/\s*(=~|==|>=|<=|=|!=|>|<)\s*/, 1), N1.whitespace.result("=")),
    map: (Z, J, $) => {
      let X;
      if (J.head !== void 0) {
        if (J.head.name === "structure-query.atom-property.macromolecular.secondary-structure-flags")
          X = i7.core.flags.hasAny([J, Pb($)]);
        if (J.head.name === "core.type.regex")
          X = i7.core.str.match([J, i7.core.type.str([$])]);
      } else if ($.head !== void 0) {
        if ($.head.name === "structure-query.atom-property.macromolecular.secondary-structure-flags")
          X = i7.core.flags.hasAny([$, Pb(J)]);
        if ($.head.name === "core.type.regex")
          X = i7.core.str.match([$, i7.core.type.str([J])]);
      } else if (Z === "=~")
        if (J.head)
          X = i7.core.str.match([
            i7.core.type.regex([`^${$}$`, "i"]),
            i7.core.type.str([J])
          ]);
        else
          X = i7.core.str.match([
            i7.core.type.regex([`^${J}$`, "i"]),
            i7.core.type.str([$])
          ]);
      if (!X) {
        if (J.head)
          $ = _z(J, $);
        if ($.head)
          J = _z($, J);
        switch (Z) {
          case "=":
          case "==":
            X = i7.core.rel.eq([J, $]);
            break;
          case "!=":
            X = i7.core.rel.neq([J, $]);
            break;
          case ">":
            X = i7.core.rel.gr([J, $]);
            break;
          case "<":
            X = i7.core.rel.lt([J, $]);
            break;
          case ">=":
            X = i7.core.rel.gre([J, $]);
            break;
          case "<=":
            X = i7.core.rel.lte([J, $]);
            break;
          default:
            throw new Error(`value operator '${Z}' not supported`);
        }
      }
      return i7.struct.generator.atomGroups({ "atom-test": X });
    }
  }
], _Q1 = N1.createLanguage({
  Parens: function(Z) {
    return N1.alt(Z.Parens, Z.Operator, Z.Expression).wrap(N1.string("("), N1.string(")"));
  },
  Expression: function(Z) {
    return N1.alt(Z.RangeListProperty, Z.ValueQuery, Z.Keywords);
  },
  NamedAtomProperties: function() {
    return N1.alt(..._b(KU));
  },
  Keywords: () => N1.alt(...TA(hr)),
  ValueRange: function(Z) {
    return N1.seq(Z.Value.skip(N1.regexp(/\s+TO\s+/i)), Z.Value).map((J) => ({ range: J }));
  },
  RangeListProperty: function(Z) {
    return N1.seq(N1.alt(...jV(KU, /\s/)).skip(N1.whitespace), N1.alt(Z.ValueRange, Z.Value).sepBy1(N1.whitespace)).map((J) => {
      let [$, X] = J, Y = [], Q = [];
      X.forEach((H) => {
        if (H.range)
          Q.push(i7.core.rel.inRange([$, H.range[0], H.range[1]]));
        else
          Y.push(_z($, H, vr));
      });
      let W = MD0(Q), K = jD0($, Y), G;
      if (W && K)
        G = i7.core.logic.or([W, K]);
      else
        G = W ? W : K;
      return i7.struct.generator.atomGroups({ [wD0($)]: G });
    });
  },
  Operator: function(Z) {
    return xR(Sr, N1.alt(Z.Parens, Z.Expression, Z.ValueQuery));
  },
  Query: function(Z) {
    return N1.alt(Z.Operator, Z.Parens, Z.Expression).trim(N1.optWhitespace);
  },
  Number: function() {
    return N1.regexp(/-?(0|[1-9][0-9]*)([.][0-9]+)?([eE][+-]?[0-9]+)?/).map(Number).desc("number");
  },
  String: function() {
    let Z = _A(KU, hr, Sr).sort(P5).map(IF).join("|");
    return N1.alt(N1.regexp(new RegExp(`(?!(${Z}))[A-Z0-9_]+`, "i")), N1.regexp(/'((?:[^"\\]|\\.)*)'/, 1), N1.regexp(/"((?:[^"\\]|\\.)*)"/, 1).map((J) => i7.core.type.regex([`^${J}$`, "i"]))).desc("string");
  },
  Value: function(Z) {
    return N1.alt(Z.Number, Z.String);
  },
  ValueParens: function(Z) {
    return N1.alt(Z.ValueParens, Z.ValueOperator, Z.ValueExpressions).wrap(N1.string("("), N1.string(")"));
  },
  ValuePropertyNames: function() {
    return N1.alt(...jV(KU, /=~|==|>=|<=|=|!=|>|<|\)|\s|\+|-|\*|\//i));
  },
  ValueOperator: function(Z) {
    return xR(TQ1, N1.alt(Z.ValueParens, Z.ValueExpressions));
  },
  ValueExpressions: function(Z) {
    return N1.alt(Z.ValueFunctions, Z.Value, Z.ValuePropertyNames);
  },
  ValueFunctions: function(Z) {
    return N1.alt(...BD0(SD0, Z.ValueOperator));
  },
  ValueQuery: function(Z) {
    return N1.alt(Z.ValueOperator.map((J) => {
      if (!J.head.name || !J.head.name.startsWith("structure-query.generator"))
        throw new Error(`values must be part of an comparison, value '${J}'`);
      else
        return J;
    }));
  }
}), fD0 = (Z) => _Q1.Query.tryParse(Z);

// node_modules/molstar/lib/mol-script/transpilers/all.js
var hD0 = {
  pymol: CD0,
  vmd: fD0,
  jmol: VD0
};

// node_modules/molstar/lib/mol-script/transpile.js
var VQ1 = hD0;
function bD0(Z, J) {
  try {
    return VQ1[Z](J);
  } catch ($) {
    throw console.error($.message), $;
  }
}

// node_modules/molstar/lib/mol-script/script.js
function cZ(Z, J) {
  return { expression: Z, language: J };
}
(function(Z) {
  Z.Info = {
    "mol-script": "Mol-Script",
    pymol: "PyMOL",
    vmd: "VMD",
    jmol: "Jmol"
  };
  function J(K) {
    return !!K && typeof K.expression === "string" && !!K.language;
  }
  Z.is = J;
  function $(K, G) {
    return K.language === G.language && K.expression === G.expression;
  }
  Z.areEqual = $;
  function X(K) {
    switch (K.language) {
      case "mol-script":
        let G = zD0(K.expression);
        if (G.length === 0)
          throw new Error("No query");
        return ED0(G[0]);
      case "pymol":
      case "jmol":
      case "vmd":
        return bD0(K.language, K.expression);
      default:
        T8(K.language);
    }
  }
  Z.toExpression = X;
  function Y(K) {
    let G = X(K);
    return PW(G);
  }
  Z.toQuery = Y;
  function Q(K, G) {
    let N = Y(K)(new C9(G));
    return f1.toLociWithSourceUnits(N);
  }
  Z.toLoci = Q;
  function W(K, G, H) {
    let N = typeof K === "function" ? K(L0) : K;
    return PW(N)(new C9(G, H));
  }
  Z.getStructureSelection = W;
})(cZ || (cZ = {}));

// node_modules/molstar/lib/mol-plugin-state/helpers/root-structure.js
var IA = {
  dynamicBonds: j.Optional(j.Boolean(!1, { description: "Ensure bonds are recalculated upon model changes. Also enables calculation of inter-unit bonds in water molecules and ions." }))
}, Nq;
(function(Z) {
  function J(G, H) {
    let N = G && T9.Provider.get(G), q = N ? N.assemblies.map((D) => [D.id, `${D.id}: ${v$(D.details)}`]) : [], U = !N ? !0 : !d7.isZero(N.spacegroup.cell), F = [];
    if (N) {
      let { operators: D } = N.spacegroup;
      for (let A = 0, B = D.length;A < B; A++)
        F.push([A, `${A + 1}: ${f$.getOperatorXyz(D[A])}`]);
    }
    let E = [];
    if (G)
      G.properties.structAsymMap.forEach((D) => {
        let A = D.id === D.auth_id ? D.id : `${D.id} [auth ${D.auth_id}]`;
        E.push([D.id, A]);
      });
    let R = {
      auto: j.Group(IA),
      model: j.Group(IA),
      assembly: j.Group({
        id: j.Optional(G ? j.Select(q.length ? q[0][0] : "", q, { label: "Asm Id", description: "Assembly Id" }) : j.Text("", { label: "Asm Id", description: "Assembly Id (use empty for the 1st assembly)" })),
        ...IA
      }, { isFlat: !0 }),
      "symmetry-mates": j.Group({
        radius: j.Numeric(5, { min: 0, max: 50, step: 1 }),
        ...IA
      }, { isFlat: !0 }),
      symmetry: j.Group({
        ijkMin: j.Vec3(M.create(-1, -1, -1), { step: 1 }, { label: "Min IJK", fieldLabels: { x: "I", y: "J", z: "K" } }),
        ijkMax: j.Vec3(M.create(1, 1, 1), { step: 1 }, { label: "Max IJK", fieldLabels: { x: "I", y: "J", z: "K" } }),
        ...IA
      }, { isFlat: !0 }),
      "symmetry-assembly": j.Group({
        generators: j.ObjectList({
          operators: j.ObjectList({
            index: j.Select(0, F),
            shift: j.Vec3(M(), { step: 1 }, { label: "IJK", fieldLabels: { x: "I", y: "J", z: "K" } })
          }, (D) => `${D.index + 1}_${D.shift.map((A) => A + 5).join("")}`, {
            defaultValue: []
          }),
          asymIds: j.MultiSelect([], E)
        }, (D) => `${D.asymIds.length} asym ids, ${D.operators.length} operators`, {
          defaultValue: []
        }),
        ...IA
      }, { isFlat: !0 })
    }, z = [];
    if (H === "auto")
      z.push(["auto", "Auto"]);
    if (z.push(["model", "Model"]), q.length > 0)
      z.push(["assembly", "Assembly"]);
    if (U)
      z.push(["symmetry-mates", "Symmetry Mates"]), z.push(["symmetry", "Symmetry (indices)"]), z.push(["symmetry-assembly", "Symmetry (assembly)"]);
    return {
      type: j.MappedStatic(H || "model", R, { options: z })
    };
  }
  Z.getParams = J;
  function $(G, H) {
    if (H.name === "symmetry-assembly" || H.name === "symmetry" && G.name === "symmetry")
      return !1;
    return !0;
  }
  Z.canAutoUpdate = $;
  async function X(G, H, N, q, U) {
    let F = void 0, E = T9.Provider.get(N);
    if (!q && E && E.assemblies.length !== 0)
      q = E.assemblies[0].id;
    if (!E || E.assemblies.length === 0)
      G.log.warn(`Model '${N.entryId}' has no assembly, returning model structure.`);
    else if (F = nF.findAssembly(N, q || ""), !F)
      G.log.warn(`Model '${N.entryId}' has no assembly called '${q}', returning model structure.`);
    let R = s0.ofModel(N, U);
    if (!F) {
      let A = { label: "Model", description: s0.elementDescription(R) };
      return new D0.Molecule.Structure(R, A);
    }
    q = F.id;
    let z = await VW.buildAssembly(R, q).runInContext(H), D = { label: `Assembly ${q}`, description: s0.elementDescription(z) };
    return new D0.Molecule.Structure(z, D);
  }
  async function Y(G, H, N, q, U) {
    let F = s0.ofModel(H, U), E = await VW.buildSymmetryRange(F, N, q).runInContext(G), R = { label: `Symmetry [${N}] to [${q}]`, description: s0.elementDescription(E) };
    return new D0.Molecule.Structure(E, R);
  }
  async function Q(G, H, N, q) {
    let U = s0.ofModel(H, q), F = await VW.builderSymmetryMates(U, N).runInContext(G), E = { label: "Symmetry Mates", description: s0.elementDescription(F) };
    return new D0.Molecule.Structure(F, E);
  }
  async function W(G, H, N, q, U) {
    let F = s0.ofModel(H, U), E = await VW.buildSymmetryAssembly(F, N, q).runInContext(G), R = { label: "Symmetry Assembly", description: s0.elementDescription(E) };
    return new D0.Molecule.Structure(E, R);
  }
  async function K(G, H, N, q) {
    let U = q === null || q === void 0 ? void 0 : q.params, F = T9.Provider.get(N);
    if (!F || !q || q.name === "model") {
      let E = s0.ofModel(N, U);
      return new D0.Molecule.Structure(E, { label: "Model", description: s0.elementDescription(E) });
    }
    if (q.name === "auto")
      if (F.assemblies.length === 0) {
        let E = s0.ofModel(N, U);
        return new D0.Molecule.Structure(E, { label: "Model", description: s0.elementDescription(E) });
      } else
        return X(G, H, N, void 0, U);
    if (q.name === "assembly")
      return X(G, H, N, q.params.id, U);
    if (q.name === "symmetry")
      return Y(H, N, q.params.ijkMin, q.params.ijkMax, U);
    if (q.name === "symmetry-mates")
      return Q(H, N, q.params.radius, U);
    if (q.name === "symmetry-assembly")
      return W(H, N, q.params.generators, F, U);
    T8(q);
  }
  Z.create = K;
})(Nq || (Nq = {}));

// node_modules/molstar/lib/mol-plugin-state/helpers/structure-query.js
var CY;
(function(Z) {
  function J(K, G, H) {
    if (K.currentStructure !== H)
      return !1;
    if (cZ.is(G))
      return !!K.script && cZ.areEqual(K.script, G);
    return K.expression === G;
  }
  Z.isUnchanged = J;
  function $(K, G) {
    let H = cZ.is(G) ? G : void 0, N = cZ.is(G) ? cZ.toExpression(G) : G, q = PW(N);
    return { script: H, expression: N, compiled: q, originalStructure: K, currentStructure: K };
  }
  Z.create = $;
  function X(K, G) {
    return K.compiled(new C9(G));
  }
  Z.run = X;
  function Y(K, G) {
    let H = $(K, G);
    return { entry: H, selection: X(H, K) };
  }
  Z.createAndRun = Y;
  function Q(K, G) {
    return K.currentStructure = G, K.compiled(new C9(G));
  }
  Z.updateStructure = Q;
  function W(K, G, H) {
    let N = f1.unionStructure(G);
    K.label = `${H || "Selection"}`, K.description = s0.elementDescription(N), K.data = N;
  }
  Z.updateStructureObject = W;
})(CY || (CY = {}));

// node_modules/molstar/lib/mol-plugin-state/helpers/structure-component.js
var xD0 = () => ({
  type: j.MappedStatic("static", {
    static: j.Text("polymer"),
    expression: j.Value(L0.struct.generator.all),
    bundle: j.Value(W0.Bundle.Empty),
    script: j.Script({ language: "mol-script", expression: "(sel.atom.all)" })
  }, { isHidden: !0 }),
  nullIfEmpty: j.Optional(j.Boolean(!0, { isHidden: !0 })),
  label: j.Text("", { isHidden: !0 })
});
function yD0(Z, J, $) {
  $.source = Z;
  let X = s0.Empty, Y = void 0;
  switch (J.type.name) {
    case "static": {
      let W;
      switch (J.type.params) {
        case "all":
          W = u9.all.query, Y = "All";
          break;
        case "polymer":
          W = u9.polymer.query, Y = "Polymer";
          break;
        case "protein":
          W = u9.protein.query, Y = "Protein";
          break;
        case "nucleic":
          W = u9.nucleic.query, Y = "Nucleic";
          break;
        case "water":
          W = OZ.internal.water(), Y = "Water";
          break;
        case "ion":
          W = u9.ion.query, Y = "Ion";
          break;
        case "lipid":
          W = u9.lipid.query, Y = "Lipid";
          break;
        case "branched":
          W = u9.branchedPlusConnected.query, Y = "Branched";
          break;
        case "ligand":
          W = u9.ligandPlusConnected.query, Y = "Ligand";
          break;
        case "non-standard":
          W = u9.nonStandardPolymer.query, Y = "Non-standard";
          break;
        case "coarse":
          W = u9.coarse.query, Y = "Coarse";
          break;
        default:
          T8(J.type);
      }
      let K = W(new C9(Z));
      X = f1.unionStructure(K);
      break;
    }
    case "script":
    case "expression": {
      let { selection: W, entry: K } = CY.createAndRun(Z, J.type.params);
      $.entry = K, X = f1.unionStructure(W);
      break;
    }
    case "bundle": {
      if (J.type.params.hash !== Z.hashCode)
        break;
      X = W0.Bundle.toStructure(J.type.params, Z);
      break;
    }
  }
  if (J.nullIfEmpty && X.elementCount === 0)
    return LZ.Null;
  let Q = { label: `${J.label || Y || "Component"}`, description: s0.elementDescription(X) };
  return new D0.Molecule.Structure(X, Q);
}
function gD0(Z, J, $, X, Y) {
  if ($.type.name !== X.type.name)
    return T1.UpdateResult.Recreate;
  let Q = !1;
  switch (X.type.name) {
    case "static": {
      if ($.type.params !== X.type.params)
        return T1.UpdateResult.Recreate;
      if (!s0.areEquivalent(Z, Y.source))
        return T1.UpdateResult.Recreate;
      if (J.data.model === Z.model)
        return T1.UpdateResult.Unchanged;
      if (!O2.areHierarchiesEqual(Z.model, J.data.model))
        return T1.UpdateResult.Recreate;
      return J.data = J.data.remapModel(Z.model), T1.UpdateResult.Updated;
    }
    case "script":
      if (!cZ.areEqual($.type.params, X.type.params))
        return T1.UpdateResult.Recreate;
    case "expression": {
      if ($.type.params !== X.type.params)
        return T1.UpdateResult.Recreate;
      if (Z === Y.source)
        break;
      let W = Y.entry, K = CY.updateStructure(W, Z);
      Y.source = Z, J.data = f1.unionStructure(K), CY.updateStructureObject(J, K, X.label), Q = !0;
      break;
    }
    case "bundle": {
      if (Z === Y.source && W0.Bundle.areEqual($.type.params, X.type.params))
        break;
      if (Y.source = Z, X.type.params.hash !== Z.hashCode)
        Q = J.data.elementCount !== 0, J.data = J.data.elementCount === 0 ? J.data : s0.Empty;
      else
        Q = !0, J.data = W0.Bundle.toStructure(X.type.params, Z);
      break;
    }
  }
  if (Q) {
    if (X.nullIfEmpty && J.data.elementCount === 0)
      return T1.UpdateResult.Null;
    J.description = s0.elementDescription(J.data);
  }
  if ($.label !== X.label)
    Q = !0, J.label = `${X.label || J.label}`;
  return Q ? T1.UpdateResult.Updated : T1.UpdateResult.Unchanged;
}

// node_modules/molstar/lib/mol-io/reader/mol/parser.js
function mD0(Z) {
  switch (Z) {
    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 ${Z} is outside the 0-7 range, defaulting to 0.`), 0;
  }
}
function br(Z, J) {
  let $ = G1.create(Z.data, J * 2), X = G1.create(Z.data, J * 2), Y = G1.create(Z.data, J * 2), Q = G1.create(Z.data, J * 2), W = G1.create(Z.data, J * 2);
  for (let K = 0;K < J; ++K) {
    Z2.markLine(Z);
    let { tokenStart: G, position: H } = Z;
    Z2.trim(Z, G, G + 10), G1.addUnchecked($, Z.tokenStart, Z.tokenEnd), Z2.trim(Z, G + 10, G + 20), G1.addUnchecked(X, Z.tokenStart, Z.tokenEnd), Z2.trim(Z, G + 20, G + 30), G1.addUnchecked(Y, Z.tokenStart, Z.tokenEnd), Z2.trim(Z, G + 31, G + 34), G1.addUnchecked(Q, Z.tokenStart, Z.tokenEnd), Z2.trim(Z, G + 36, G + 39), G1.addUnchecked(W, Z.tokenStart, Z.tokenEnd), Z.position = H;
  }
  return {
    count: J,
    x: I2($)(s.Schema.float),
    y: I2(X)(s.Schema.float),
    z: I2(Y)(s.Schema.float),
    type_symbol: I2(Q)(s.Schema.str),
    formal_charge: I2(W)(s.Schema.int)
  };
}
function xr(Z, J) {
  let $ = G1.create(Z.data, J * 2), X = G1.create(Z.data, J * 2), Y = G1.create(Z.data, J * 2);
  for (let Q = 0;Q < J; ++Q) {
    Z2.markLine(Z);
    let { tokenStart: W, position: K } = Z;
    Z2.trim(Z, W, W + 3), G1.addUnchecked($, Z.tokenStart, Z.tokenEnd), Z2.trim(Z, W + 3, W + 6), G1.addUnchecked(X, Z.tokenStart, Z.tokenEnd), Z2.trim(Z, W + 6, W + 9), G1.addUnchecked(Y, Z.tokenStart, Z.tokenEnd), Z.position = K;
  }
  return {
    count: J,
    atomIdxA: I2($)(s.Schema.int),
    atomIdxB: I2(X)(s.Schema.int),
    order: I2(Y)(s.Schema.int)
  };
}
function IQ1(Z, J, $) {
  Z2.trim(Z, J + 6, J + 9);
  let X = parseInt(Z2.getTokenString(Z));
  for (let Y = 0;Y < X; ++Y) {
    let Q = 9 + Y * 8;
    Z2.trim(Z, J + Q, J + Q + 4);
    let W = Z2.getTokenString(Z);
    $.atomIdx.push(+W), Z2.trim(Z, J + Q + 4, J + Q + 8);
    let K = Z2.getTokenString(Z);
    $.charge.push(+K);
  }
  Z2.eatLine(Z);
}
function PQ1(Z) {
  let J = Z.trim().split(/\s+/g), $ = [];
  for (let X = 1;X < J.length; X += 2) {
    let Y = +J[X], Q = +J[X + 1] || 0;
    $.push({ atomIdx: Y, kind: Q });
  }
  return $;
}
function yr(Z) {
  let X = { atomIdx: [], charge: [] }, Y = void 0;
  while (Z.position < Z.length) {
    let { position: W } = Z;
    Z2.trim(Z, W + 3, W + 6);
    let K = Z2.getTokenString(Z);
    if (K === "END")
      break;
    switch (Z2.eatLine(Z), K) {
      case "CHG":
        IQ1(Z, W, X);
        break;
      case "APO":
        Y = PQ1(Z2.getTokenString(Z).substring(3));
        break;
      default:
        break;
    }
  }
  return { formalCharges: {
    atomIdx: s.ofIntArray(X.atomIdx),
    charge: s.ofIntArray(X.charge)
  }, attachmentPoints: Y };
}
function CQ1(Z) {
  let J = Z2(Z), $ = Z2.readLine(J).trim(), X = Z2.readLine(J).trim(), Y = Z2.readLine(J).trim(), Q = Z2.readLine(J), W = +Q.substr(0, 3), K = +Q.substr(3, 3), G = br(J, W), H = xr(J, K), N = {
    title: $,
    program: X,
    comment: Y,
    atoms: G,
    bonds: H,
    ...yr(J)
  };
  return a8.success(N);
}
function dD0(Z) {
  return n0.create("Parse Mol", async () => {
    return CQ1(Z);
  });
}

// node_modules/molstar/lib/mol-model-formats/structure/mol.js
async function mr(Z, J, $) {
  let { atoms: X, bonds: Y, formalCharges: Q } = Z, W = s.ofConst("MOL", Z.atoms.count, s.Schema.str), K = s.ofConst("A", Z.atoms.count, s.Schema.str), G = s.asArrayColumn(X.type_symbol), H = s.ofConst(1, X.count, s.Schema.int), N = new Int32Array(Z.atoms.count);
  if (Q.atomIdx.rowCount > 0)
    for (let z = 0;z < Q.atomIdx.rowCount; z++)
      N[Q.atomIdx.value(z) - 1] = Q.charge.value(z);
  else
    for (let z = 0;z < Z.atoms.count; z++)
      N[z] = mD0(X.formal_charge.value(z));
  let q = A8.ofPartialColumns(E9.atom_site, {
    auth_asym_id: K,
    auth_atom_id: G,
    auth_comp_id: W,
    auth_seq_id: H,
    Cartn_x: s.asArrayColumn(X.x, Float32Array),
    Cartn_y: s.asArrayColumn(X.y, Float32Array),
    Cartn_z: s.asArrayColumn(X.z, Float32Array),
    id: s.range(1, X.count),
    label_asym_id: K,
    label_atom_id: G,
    label_comp_id: W,
    label_seq_id: H,
    label_entity_id: s.ofConst("1", X.count, s.Schema.str),
    occupancy: s.ofConst(1, X.count, s.Schema.float),
    type_symbol: G,
    pdbx_PDB_model_num: s.ofConst(1, X.count, s.Schema.int),
    pdbx_formal_charge: s.ofIntArray(N)
  }, X.count), U = new c7;
  U.setNames([["MOL", "Unknown Entity"]]), U.getEntityId("MOL", e2.Unknown, "A");
  let F = new l7(H, G);
  F.setNames([["MOL", "Unknown Molecule"]]), F.add("MOL", 0);
  let E = u7({
    entity: U.getEntityTable(),
    chem_comp: F.getChemCompTable(),
    atom_site: q
  }), R = await nJ(E, J !== null && J !== void 0 ? J : gr.create(Z), $);
  if (R.frameCount > 0) {
    let z = s.ofIntArray(s.mapToArray(Y.atomIdxA, (T) => T - 1, Int32Array)), D = s.ofIntArray(s.mapToArray(Y.atomIdxB, (T) => T - 1, Int32Array)), A = s.asArrayColumn(Y.order, Int32Array), B = j9.fromData({ pairs: { indexA: z, indexB: D, order: A }, count: X.count }, { maxDistance: 1 / 0 });
    j9.Provider.set(R.representative, B);
  }
  return R;
}
var gr;
(function(Z) {
  function J(X) {
    return (X === null || X === void 0 ? void 0 : X.kind) === "mol";
  }
  Z.is = J;
  function $(X) {
    return { kind: "mol", name: X.title, data: X };
  }
  Z.create = $;
})(gr || (gr = {}));
function pD0(Z) {
  return n0.create("Parse MOL", (J) => mr(Z, void 0, J));
}

// node_modules/molstar/lib/mol-model-formats/structure/cif-core.js
function kQ1(Z) {
  let J = Z.it_number.value(0), $ = Z["name_h-m_full"].value(0).replace("-", " ");
  if (!Z.it_number.isDefined)
    return $;
  if (!Z["name_h-m_full"].isDefined)
    return J;
  return J;
}
function vQ1(Z) {
  let { cell: J, space_group: $ } = Z, X = kQ1($), Y = d7.create(X, M.create(J.length_a.value(0), J.length_b.value(0), J.length_c.value(0)), M.scale(M(), M.create(J.angle_alpha.value(0), J.angle_beta.value(0), J.angle_gamma.value(0)), Math.PI / 180));
  return {
    spacegroup: f$.create(Y),
    assemblies: [],
    isNonStandardCrystalFrame: !1,
    ncsOperators: []
  };
}
async function SQ1(Z, J, $) {
  var X;
  let Y = Z.atom_site._rowCount, Q = s.ofConst("MOL", Y, s.Schema.str), W = s.ofConst("A", Y, s.Schema.str), K = s.ofConst(1, Y, s.Schema.int), G = vQ1(Z), H = G.spacegroup.cell.fromFractional, { fract_x: N, fract_y: q, fract_z: U } = Z.atom_site, F = new Float32Array(Y), E = new Float32Array(Y), R = new Float32Array(Y), z = M();
  for (let v = 0;v < Y; ++v)
    M.set(z, N.value(v), q.value(v), U.value(v)), M.transformMat4(z, z, H), F[v] = z[0], E[v] = z[1], R[v] = z[2];
  let { type_symbol: D, label: A } = Z.atom_site, B, T;
  if (D.isDefined) {
    let v = new Array(Y), h = new Int8Array(Y);
    for (let x = 0;x < Y; ++x) {
      let b = D.value(x), g = b.length;
      if (b[g - 1] === "+")
        v[x] = b.substring(0, g - 2), h[x] = parseInt(b[g - 2]);
      else if (b[g - 2] === "+")
        v[x] = b.substring(0, g - 2), h[x] = parseInt(b[g - 1]);
      else if (b[g - 1] === "-")
        v[x] = b.substring(0, g - 2), h[x] = -parseInt(b[g - 2]);
      else if (b[g - 2] === "-")
        v[x] = b.substring(0, g - 2), h[x] = -parseInt(b[g - 1]);
      else
        v[x] = b, h[x] = 0;
    }
    B = s.ofStringArray(v), T = s.ofIntArray(h);
  } else {
    let v = new Array(Y);
    for (let h = 0;h < Y; ++h)
      v[h] = h3(A.value(h), "");
    B = s.ofStringArray(v), T = s.Undefined(Y, s.Schema.int);
  }
  let w = A8.ofPartialColumns(E9.atom_site, {
    auth_asym_id: W,
    auth_atom_id: A,
    auth_comp_id: Q,
    auth_seq_id: K,
    Cartn_x: s.ofFloatArray(F),
    Cartn_y: s.ofFloatArray(E),
    Cartn_z: s.ofFloatArray(R),
    id: s.range(0, Y - 1),
    label_asym_id: W,
    label_atom_id: A,
    label_comp_id: Q,
    label_seq_id: K,
    label_entity_id: s.ofConst("1", Y, s.Schema.str),
    occupancy: Z.atom_site.occupancy.isDefined ? Z.atom_site.occupancy : s.ofConst(1, Y, s.Schema.float),
    type_symbol: B,
    pdbx_formal_charge: T,
    pdbx_PDB_model_num: s.ofConst(1, Y, s.Schema.int),
    B_iso_or_equiv: Z.atom_site.u_iso_or_equiv
  }, Y), V = Z.chemical.name_common.value(0) || Z.chemical.name_systematic.value(0) || Z.chemical_formula.sum.value(0), P = new c7;
  P.setNames([["MOL", V || "Unknown Entity"]]), P.getEntityId("MOL", e2.Unknown, "A");
  let I = new l7(K, Z.atom_site.type_symbol);
  I.setNames([["MOL", V || "Unknown Molecule"]]), I.add("MOL", 0);
  let S = u7({
    entity: P.getEntityTable(),
    chem_comp: I.getChemCompTable(),
    atom_site: w
  }), f = await nJ(S, J, $);
  if (f.frameCount > 0) {
    let v = f.representative;
    T9.Provider.set(v, G);
    let h = Z.geom_bond._rowCount;
    if (h > 0) {
      let x = {}, { label: b } = Z.atom_site;
      for (let Z0 = 0, U0 = b.rowCount;Z0 < U0; ++Z0)
        x[b.value(Z0)] = Z0;
      let g = (X = J.data.frame.categories.ccdc_geom_bond_type) === null || X === void 0 ? void 0 : X.getField(""), m = [], i = [], r = [], Y0 = [], c = [], n = /* @__PURE__ */ new Set, l = 0, { atom_site_label_1: u, atom_site_label_2: G0, valence: F0, distance: t } = Z.geom_bond;
      for (let Z0 = 0;Z0 < h; ++Z0) {
        let U0 = x[u.value(Z0)], a = x[G0.value(Z0)], Q0 = U0 < a ? ZJ(U0, a) : ZJ(a, U0);
        if (n.has(Q0))
          continue;
        if (n.add(Q0), m[l] = U0, i[l] = a, Y0[l] = t.value(Z0) || -1, g) {
          let $0 = g.str(Z0);
          if ($0 === "D")
            r[l] = 2, c[l] = s1.Flag.Covalent;
          else if ($0 === "A")
            r[l] = 1, c[l] = s1.Flag.Covalent | s1.Flag.Aromatic;
          else if ($0 === "S")
            r[l] = 1, c[l] = s1.Flag.Covalent;
          else
            r[l] = 1, c[l] = s1.Flag.Covalent;
        } else
          c[l] = s1.Flag.Covalent, r[l] = F0.isDefined ? F0.value(Z0) : 1;
        l += 1;
      }
      j9.Provider.set(v, j9.fromData({ pairs: {
        indexA: s.ofIntArray(m),
        indexB: s.ofIntArray(i),
        order: s.ofIntArray(r),
        distance: s.ofFloatArray(Y0),
        flag: s.ofIntArray(c)
      }, count: Y }));
    }
  }
  return f;
}
function fQ1(Z) {
  if (!PV.is(Z.sourceData))
    return;
  let { atom_site: J, atom_site_aniso: $ } = Z.sourceData.data.db, X = A8.ofPartialColumns(vW.Schema, {
    U: $.u
  }, $._rowCount), Y = vW.getElementToAnsiotropFromLabel(J.label, $.label);
  return { data: X, elementToAnsiotrop: Y };
}
function hQ1(Z) {
  if (!PV.is(Z.sourceData))
    return !1;
  return Z.sourceData.data.db.atom_site_aniso.u.isDefined;
}
vW.Provider.formatRegistry.add("cifCore", fQ1, hQ1);
var PV;
(function(Z) {
  function J(X) {
    return (X === null || X === void 0 ? void 0 : X.kind) === "cifCore";
  }
  Z.is = J;
  function $(X, Y) {
    if (!Y)
      Y = kW.schema.cifCore(X);
    return { kind: "cifCore", name: Y.database_code.depnum_ccdc_archive.value(0) || Y.database_code.depnum_ccdc_fiz.value(0) || Y.database_code.icsd.value(0) || Y.database_code.mdf.value(0) || Y.database_code.nbs.value(0) || Y.database_code.csd.value(0) || Y.database_code.cod.value(0) || Y._name, data: { db: Y, frame: X } };
  }
  Z.fromFrame = $;
})(PV || (PV = {}));
function uD0(Z) {
  let J = PV.fromFrame(Z);
  return n0.create("Parse CIF Core", ($) => SQ1(J.data.db, J, $));
}

// node_modules/molstar/lib/mol-model-formats/structure/cube.js
async function bQ1(Z, J) {
  let { atoms: $ } = Z, X = s.ofConst("MOL", Z.atoms.count, s.Schema.str), Y = s.ofConst("A", Z.atoms.count, s.Schema.str), Q = s.ofArray({ array: s.mapToArray($.number, (q) => uH0(q)), schema: s.Schema.Aliased(s.Schema.str) }), W = s.ofConst(1, $.count, s.Schema.int), K = A8.ofPartialColumns(E9.atom_site, {
    auth_asym_id: Y,
    auth_atom_id: Q,
    auth_comp_id: X,
    auth_seq_id: W,
    Cartn_x: s.asArrayColumn($.x, Float32Array),
    Cartn_y: s.asArrayColumn($.y, Float32Array),
    Cartn_z: s.asArrayColumn($.z, Float32Array),
    id: s.range(0, $.count - 1),
    label_asym_id: Y,
    label_atom_id: Q,
    label_comp_id: X,
    label_seq_id: W,
    label_entity_id: s.ofConst("1", $.count, s.Schema.str),
    occupancy: s.ofConst(1, $.count, s.Schema.float),
    type_symbol: Q,
    pdbx_PDB_model_num: s.ofConst(1, $.count, s.Schema.int)
  }, $.count), G = new c7;
  G.setNames([["MOL", "Unknown Entity"]]), G.getEntityId("MOL", e2.Unknown, "A");
  let H = new l7(W, Q);
  H.setNames([["MOL", "Unknown Molecule"]]), H.add("MOL", 0);
  let N = u7({
    entity: G.getEntityTable(),
    chem_comp: H.getChemCompTable(),
    atom_site: K
  });
  return await nJ(N, dr.create(Z), J);
}
var dr;
(function(Z) {
  function J(X) {
    return (X === null || X === void 0 ? void 0 : X.kind) === "cube";
  }
  Z.is = J;
  function $(X) {
    return { kind: "cube", name: X.header.comment1, data: X };
  }
  Z.create = $;
})(dr || (dr = {}));
function cD0(Z) {
  return n0.create("Parse Cube", (J) => bQ1(Z, J));
}

// node_modules/molstar/lib/mol-io/reader/mol2/parser.js
var { skipWhitespace: lD0, eatValue: xQ1, markLine: CK, getTokenString: kK, skipStrictWhitespace: yQ1 } = Z2;
function gQ1() {
  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 mQ1(Z, J) {
  return {
    tokenizer: Z,
    molecule: gQ1(),
    runtimeCtx: J
  };
}
var nD0 = /\s+/g;
function dQ1(Z) {
  let { tokenizer: J, molecule: $ } = Z;
  while (kK(J) !== "@<TRIPOS>MOLECULE" && J.position < J.data.length)
    CK(J);
  CK(J), $.mol_name = kK(J), CK(J);
  let X = kK(J).trim().split(nD0);
  $.num_atoms = parseInt(X[0]), $.num_bonds = parseInt(X[1]), $.num_subst = parseInt(X[2]), $.num_feat = parseInt(X[3]), $.num_sets = parseInt(X[4]), CK(J);
  let Y = kK(J);
  if (Y.startsWith("@<TRIPOS>"))
    return;
  $.mol_type = Y, CK(J);
  let Q = kK(J);
  if (Q.startsWith("@<TRIPOS>"))
    return;
  $.charge_type = Q, CK(J);
  let W = kK(J);
  if (W.startsWith("@<TRIPOS>"))
    return;
  $.status_bits = W, CK(J);
  let K = kK(J);
  if (K.startsWith("@<TRIPOS>"))
    return;
  $.mol_comment = K;
}
function pr(Z, J, $) {
  let X = 0;
  for (let Y = 0;Y < Z; Y++) {
    let Q = 0;
    lD0($);
    while (!0) {
      if (yQ1($), $.tokenStart = $.position, xQ1($), $.tokenStart === $.tokenEnd)
        break;
      let W = J[Q++];
      if (!W)
        continue;
      G1.addUnchecked(W, $.tokenStart, $.tokenEnd);
    }
    if (Q > X)
      X = Q;
    for (let W = Q;W < J.length; W++)
      G1.addUnchecked(J[W], 0, 0);
  }
  return X + 1;
}
async function pQ1(Z) {
  let { tokenizer: J, molecule: $ } = Z;
  while (kK(J) !== "@<TRIPOS>ATOM" && J.position < J.data.length)
    CK(J);
  let { position: X, lineNumber: Y } = J, Q = G1.create(J.data, $.num_atoms * 2), W = G1.create(J.data, $.num_atoms * 2), K = G1.create(J.data, $.num_atoms * 2), G = G1.create(J.data, $.num_atoms * 2), H = G1.create(J.data, $.num_atoms * 2), N = G1.create(J.data, $.num_atoms * 2), q = G1.create(J.data, $.num_atoms * 2), U = G1.create(J.data, $.num_atoms * 2), F = G1.create(J.data, $.num_atoms * 2), E = G1.create(J.data, $.num_atoms * 2), R = s.Undefined($.num_atoms, s.Schema.float), z = s.Undefined($.num_atoms, s.Schema.int), D = s.Undefined($.num_atoms, s.Schema.str);
  J.position = X, J.lineNumber = Y;
  let A = 0, B = [
    Q,
    W,
    K,
    G,
    H,
    N,
    q,
    U,
    F,
    E
  ], { length: T } = J, w = 0;
  return await K$(Z.runtimeCtx, 1e5, void 0, (P) => {
    let I = Math.min($.num_atoms - w, P);
    return A = Math.max(A, pr(I, B, J)), w += I, I;
  }, (P) => P.update({ message: "Parsing...", current: J.position, max: T })), {
    count: $.num_atoms,
    atom_id: I2(Q)(s.Schema.int),
    atom_name: I2(W)(s.Schema.str),
    x: I2(K)(s.Schema.float),
    y: I2(G)(s.Schema.float),
    z: I2(H)(s.Schema.float),
    atom_type: A > 5 ? I2(N)(s.Schema.str) : D,
    subst_id: A > 6 ? I2(q)(s.Schema.int) : z,
    subst_name: A > 7 ? I2(U)(s.Schema.str) : D,
    charge: A > 8 ? I2(F)(s.Schema.float) : R,
    status_bits: A > 9 ? I2(E)(s.Schema.str) : D
  };
}
async function uQ1(Z) {
  let { tokenizer: J, molecule: $ } = Z;
  while (kK(J) !== "@<TRIPOS>BOND" && J.position < J.data.length)
    CK(J);
  let { position: X, lineNumber: Y } = J, Q = G1.create(J.data, $.num_bonds * 2), W = G1.create(J.data, $.num_bonds * 2), K = G1.create(J.data, $.num_bonds * 2), G = G1.create(J.data, $.num_bonds * 2), H = G1.create(J.data, $.num_bonds * 2), N = s.Undefined($.num_bonds, s.Schema.str);
  J.position = X, J.lineNumber = Y;
  let q = 0, U = [
    Q,
    W,
    K,
    G,
    H
  ], { length: F } = J, E = 0;
  return await K$(Z.runtimeCtx, 1e5, void 0, (z) => {
    let D = Math.min($.num_bonds - E, z);
    return q = Math.max(q, pr(D, U, J)), E += D, D;
  }, (z) => z.update({ message: "Parsing...", current: J.position, max: F })), {
    count: $.num_bonds,
    bond_id: I2(Q)(s.Schema.int),
    origin_atom_id: I2(W)(s.Schema.int),
    target_atom_id: I2(K)(s.Schema.int),
    bond_type: I2(G)(s.Schema.str),
    status_bits: q > 4 ? I2(H)(s.Schema.str) : N
  };
}
async function cQ1(Z) {
  let { tokenizer: J, molecule: $ } = Z;
  if ($.num_subst === 0)
    return;
  while (kK(J) !== "@<TRIPOS>SUBSTRUCTURE" && J.position < J.data.length)
    CK(J);
  let { position: X, lineNumber: Y } = J, Q = G1.create(J.data, $.num_subst * 2), W = G1.create(J.data, $.num_subst * 2), K = G1.create(J.data, $.num_subst * 2), G = G1.create(J.data, $.num_subst * 2), H = G1.create(J.data, $.num_subst * 2), N = G1.create(J.data, $.num_subst * 2), q = G1.create(J.data, $.num_subst * 2), U = G1.create(J.data, $.num_subst * 2), F = G1.create(J.data, $.num_subst * 2), E = s.Undefined($.num_subst, s.Schema.int), R = s.Undefined($.num_subst, s.Schema.str);
  J.position = X, J.lineNumber = Y;
  let z = 0, D = [
    Q,
    W,
    K,
    G,
    H,
    N,
    q,
    U,
    F
  ], { length: A } = J, B = 0;
  return await K$(Z.runtimeCtx, 1e5, void 0, (w) => {
    let V = Math.min($.num_subst - B, w);
    return z = Math.max(z, pr(V, D, J)), B += V, V;
  }, (w) => w.update({ message: "Parsing...", current: J.position, max: A })), {
    count: $.num_subst,
    subst_id: I2(Q)(s.Schema.int),
    subst_name: I2(W)(s.Schema.str),
    root_atom: I2(K)(s.Schema.int),
    subst_type: z > 3 ? I2(G)(s.Schema.str) : R,
    dict_type: z > 4 ? I2(H)(s.Schema.str) : R,
    chain: z > 5 ? I2(N)(s.Schema.str) : R,
    sub_type: z > 6 ? I2(q)(s.Schema.str) : R,
    inter_bonds: z > 7 ? I2(U)(s.Schema.int) : E,
    status_bits: z > 8 ? I2(F)(s.Schema.str) : R
  };
}
function lQ1(Z) {
  let { tokenizer: J } = Z;
  while (J.position < J.data.length) {
    let X = kK(J);
    if (X === "@<TRIPOS>MOLECULE")
      return;
    else if (X === "@<TRIPOS>CRYSIN")
      break;
    else
      CK(J);
  }
  if (J.position >= J.data.length)
    return;
  CK(J);
  let $ = kK(J).trim().split(nD0);
  return {
    a: parseFloat($[0]),
    b: parseFloat($[1]),
    c: parseFloat($[2]),
    alpha: parseFloat($[3]),
    beta: parseFloat($[4]),
    gamma: parseFloat($[5]),
    spaceGroup: parseInt($[6], 10),
    setting: parseInt($[7], 10)
  };
}
async function nQ1(Z, J, $) {
  let X = Z2(J);
  Z.update({ message: "Parsing...", current: 0, max: J.length });
  let Y = [];
  while (X.position < J.length) {
    let W = mQ1(X, Z);
    dQ1(W);
    let K = await pQ1(W), G = await uQ1(W), H = await cQ1(W), N = lQ1(W);
    Y.push({ molecule: W.molecule, atoms: K, bonds: G, substructures: H, crysin: N }), lD0(X);
    while (kK(X) !== "@<TRIPOS>MOLECULE" && X.position < X.data.length)
      CK(X);
  }
  let Q = { name: $, structures: Y };
  return a8.success(Q);
}
function iD0(Z, J) {
  return n0.create("Parse MOL2", async ($) => {
    return await nQ1($, Z, J);
  });
}

// node_modules/molstar/lib/mol-model-formats/structure/mol2.js
async function iQ1(Z, J) {
  let $ = [];
  for (let X = 0, Y = Z.structures.length;X < Y; ++X) {
    let { molecule: Q, atoms: W, bonds: K, substructures: G, crysin: H } = Z.structures[X], N = new Array(W.count), q = new Array(W.count), U = new Array(W.count), F = new Array(W.count), E = new Array(W.count), R = !1;
    for (let r = 0;r < W.count; ++r)
      if (W.atom_type.value(r).includes(".")) {
        R = !0;
        break;
      }
    let z = /* @__PURE__ */ new Map;
    if (G)
      for (let r = 0;r < G.count; ++r) {
        let Y0 = G.root_atom.value(r), c = G.chain.value(r), n = G.sub_type.value(r);
        z.set(Y0, { chain: c, subType: n });
      }
    let D = new c7, A = new l7(W.subst_id, W.atom_name), B = void 0, T = "", w = 0, V = "", P = e2.Unknown, I = -1;
    for (let r = 0;r < W.count; ++r) {
      let Y0 = W.subst_name.value(r), c = W.subst_id.value(r), n = Y0.replace(/\d+$/, "") || "MOL", l = Y0.match(/(\d+)$/);
      E[r] = l ? parseInt(l[1]) : c;
      let u = z.get(W.atom_id.value(r));
      if (u)
        B = u;
      if (B) {
        if (B.subType && B.subType !== "UNK")
          n = B.subType;
      }
      if (U[r] = R ? W.atom_type.value(r).split(".")[0].toUpperCase() : h3(W.atom_name.value(r), n), F[r] = n, c !== I) {
        let G0 = qY(A.add(n, r).type, n);
        if (B === null || B === void 0 ? void 0 : B.chain)
          V = B.chain;
        else if (G0 !== P || c !== I + 1)
          V = DH(w), w += 1;
        T = D.getEntityId(n, G0, V), I = c, P = G0;
      }
      N[r] = T, q[r] = V;
    }
    let S = s.ofStringArray(U), f = s.ofStringArray(F), v = s.ofStringArray(N), h = s.ofStringArray(q), x = s.asArrayColumn(W.atom_name), b = s.ofIntArray(E), g = A8.ofPartialColumns(E9.atom_site, {
      auth_asym_id: h,
      auth_atom_id: x,
      auth_comp_id: f,
      auth_seq_id: b,
      Cartn_x: s.asArrayColumn(W.x, Float32Array),
      Cartn_y: s.asArrayColumn(W.y, Float32Array),
      Cartn_z: s.asArrayColumn(W.z, Float32Array),
      id: s.asArrayColumn(W.atom_id),
      label_asym_id: h,
      label_atom_id: x,
      label_comp_id: f,
      label_seq_id: W.subst_id,
      label_entity_id: v,
      occupancy: s.ofConst(1, W.count, s.Schema.float),
      type_symbol: S,
      pdbx_PDB_model_num: s.ofConst(X, W.count, s.Schema.int)
    }, W.count), m = u7({
      entity: D.getEntityTable(),
      chem_comp: A.getChemCompTable(),
      atom_site: g
    }), i = await nJ(m, ur.create(Z), J);
    if (i.frameCount > 0) {
      let r = s.ofIntArray(s.mapToArray(K.origin_atom_id, (F0) => F0 - 1, Int32Array)), Y0 = s.ofIntArray(s.mapToArray(K.target_atom_id, (F0) => F0 - 1, Int32Array)), c = K.bond_id, n = s.ofIntArray(s.mapToArray(K.bond_type, (F0) => {
        switch (F0) {
          case "ar":
          case "am":
          case "un":
            return 1;
          case "du":
          case "nc":
            return 0;
          default:
            return parseInt(F0);
        }
      }, Int8Array)), l = s.ofIntArray(s.mapToArray(K.bond_type, (F0) => {
        switch (F0) {
          case "ar":
          case "am":
            return s1.Flag.Aromatic | s1.Flag.Covalent;
          case "du":
          case "nc":
            return s1.Flag.None;
          case "un":
          default:
            return s1.Flag.Covalent;
        }
      }, Int8Array)), u = j9.fromData({ pairs: { key: c, indexA: r, indexB: Y0, order: n, flag: l }, count: W.count }, { maxDistance: H ? -1 : 1 / 0 }), G0 = i.representative;
      if (j9.Provider.set(G0, u), EH.Provider.set(G0, {
        data: W.charge,
        type: Q.charge_type
      }), H) {
        let F0 = oQ1(H);
        if (F0)
          T9.Provider.set(G0, F0);
      }
      $.push(G0);
    }
  }
  return new UY($);
}
function oQ1(Z) {
  if (Z.setting !== 1)
    return;
  let J = d7.create(Z.spaceGroup, M.create(Z.a, Z.b, Z.c), M.scale(M(), M.create(Z.alpha, Z.beta, Z.gamma), Math.PI / 180));
  return {
    spacegroup: f$.create(J),
    assemblies: [],
    isNonStandardCrystalFrame: !1,
    ncsOperators: []
  };
}
var ur;
(function(Z) {
  function J(X) {
    return (X === null || X === void 0 ? void 0 : X.kind) === "mol2";
  }
  Z.is = J;
  function $(X) {
    return { kind: "mol2", name: X.name, data: X };
  }
  Z.create = $;
})(ur || (ur = {}));
function oD0(Z) {
  return n0.create("Parse MOL2", (J) => iQ1(Z, J));
}

// node_modules/molstar/lib/mol-io/reader/xtc/parser.js
var PA = 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
]), cr = 9, k5;
(function(Z) {
  function J(N) {
    let q = 1, U = 0;
    while (N >= q && U < 32)
      U++, q <<= 1;
    return U;
  }
  Z.sizeOfInt = J;
  let $ = new Uint8Array(32);
  function X(N, q) {
    let U = 1, F = 0;
    $[0] = 1;
    for (let R = 0;R < N; R++) {
      let z, D = 0;
      for (z = 0;z < U; z++)
        D += $[z] * q[R], $[z] = D & 255, D >>= 8;
      while (D !== 0)
        $[z++] = D & 255, D >>= 8;
      U = z;
    }
    let E = 1;
    U--;
    while ($[U] >= E)
      F++, E *= 2;
    return F + U * 8;
  }
  Z.sizeOfInts = X;
  let Y = new ArrayBuffer(24);
  Z.buf = new Int32Array(Y);
  let Q = new Uint32Array(Y);
  function W(N, q, U) {
    let F = U, E = (1 << F) - 1, R = Q[1], z = Q[2], D = Z.buf[0], A = 0;
    while (F >= 8)
      z = z << 8 | N[q + D++], A |= z >> R << F - 8, F -= 8;
    if (F > 0) {
      if (R < F)
        R += 8, z = z << 8 | N[q + D++];
      R -= F, A |= z >> R & (1 << F) - 1;
    }
    return A &= E, Z.buf[0] = D, Z.buf[1] = R, Z.buf[2] = z, A;
  }
  Z.decodeBits = W;
  function K(N, q) {
    let U = Q[2], F = Z.buf[0];
    return U = U << 8 | N[q + F], Z.buf[0] = F + 1, Z.buf[2] = U, U >> Q[1] & 255;
  }
  let G = [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 H(N, q, U, F, E) {
    let R = U, z = 0;
    G[0] = 0, G[1] = 0, G[2] = 0, G[3] = 0;
    while (R > 8)
      G[z++] = K(N, q), R -= 8;
    if (R > 0)
      G[z++] = W(N, q, R);
    for (let D = 2;D > 0; D--) {
      let A = 0, B = F[D];
      for (let T = z - 1;T >= 0; T--) {
        A = A << 8 | G[T];
        let w = A / B | 0;
        G[T] = w, A = A - w * B;
      }
      E[D] = A;
    }
    E[0] = G[0] | G[1] << 8 | G[2] << 16 | G[3] << 24;
  }
  Z.decodeInts = H;
})(k5 || (k5 = {}));
function sQ1() {
  throw new Error("(xdrfile error) Undefined error.");
}
async function aQ1(Z, J) {
  let $ = new DataView(J.buffer, J.byteOffset), X = {
    frames: [],
    boxes: [],
    times: [],
    timeOffset: 0,
    deltaTime: 0
  }, Y = X.frames, Q = X.boxes, W = X.times, K = [0, 0, 0, 0, 0, 0], G = [0, 0, 0], H = [0, 0, 0], N = [0, 0, 0], q = [0.1, 0.1, 0.1], U = [0.1, 0.1, 0.1], F = 0, E = k5.buf;
  while (!0) {
    let R, z = $.getInt32(F + 4);
    F += 12, W.push($.getFloat32(F)), F += 4;
    let D = new Float32Array(9);
    for (let A = 0;A < 9; ++A)
      D[A] = $.getFloat32(F) * 10, F += 4;
    if (Q.push(D), z <= 9) {
      R = { count: z, x: new Float32Array(z), y: new Float32Array(z), z: new Float32Array(z) }, F += 4;
      for (let A = 0;A < z; ++A)
        R.x[A] = $.getFloat32(F), R.y[A] = $.getFloat32(F + 4), R.z[A] = $.getFloat32(F + 8), F += 12;
    } else {
      E[0] = E[1] = E[2] = 0, G[0] = G[1] = G[2] = 0, N[0] = N[1] = N[2] = 0, H[0] = H[1] = H[2] = 0, q[0] = q[1] = q[2] = 0, U[0] = U[1] = U[2] = 0, R = { count: z, x: new Float32Array(z), y: new Float32Array(z), z: new Float32Array(z) };
      let A = 0, B = $.getInt32(F);
      F += 4;
      let T = $.getFloat32(F);
      F += 4, K[0] = $.getInt32(F), K[1] = $.getInt32(F + 4), K[2] = $.getInt32(F + 8), K[3] = $.getInt32(F + 12), K[4] = $.getInt32(F + 16), K[5] = $.getInt32(F + 20), G[0] = K[3] - K[0] + 1, G[1] = K[4] - K[1] + 1, G[2] = K[5] - K[2] + 1, F += 24;
      let w;
      if ((G[0] | G[1] | G[2]) > 16777215)
        H[0] = k5.sizeOfInt(G[0]), H[1] = k5.sizeOfInt(G[1]), H[2] = k5.sizeOfInt(G[2]), w = 0;
      else
        w = k5.sizeOfInts(3, G);
      let V = $.getInt32(F);
      F += 4;
      let P = V - 1;
      P = cr > P ? cr : P;
      let I = PA[P] / 2 | 0, S = PA[V] / 2 | 0;
      N[0] = N[1] = N[2] = PA[V];
      let f = Math.ceil($.getInt32(F) / 4) * 4;
      F += 4;
      let v = 1 / T, h = 0, x = 0;
      q[0] = q[1] = q[2] = 0;
      while (x < B) {
        if (w === 0)
          q[0] = k5.decodeBits(J, F, H[0]), q[1] = k5.decodeBits(J, F, H[1]), q[2] = k5.decodeBits(J, F, H[2]);
        else
          k5.decodeInts(J, F, w, G, q);
        x++, q[0] += K[0], q[1] += K[1], q[2] += K[2], U[0] = q[0], U[1] = q[1], U[2] = q[2];
        let b = k5.decodeBits(J, F, 1), g = 0;
        if (b === 1)
          h = k5.decodeBits(J, F, 5), g = h % 3, h -= g, g--;
        if (h > 0) {
          q[0] = q[1] = q[2] = 0;
          for (let m = 0;m < h; m += 3) {
            if (k5.decodeInts(J, F, V, N, q), x++, q[0] += U[0] - S, q[1] += U[1] - S, q[2] += U[2] - S, m === 0) {
              let i = q[0];
              q[0] = U[0], U[0] = i, i = q[1], q[1] = U[1], U[1] = i, i = q[2], q[2] = U[2], U[2] = i, R.x[A] = U[0] * v, R.y[A] = U[1] * v, R.z[A] = U[2] * v, A++;
            } else
              U[0] = q[0], U[1] = q[1], U[2] = q[2];
            R.x[A] = q[0] * v, R.y[A] = q[1] * v, R.z[A] = q[2] * v, A++;
          }
        } else
          R.x[A] = q[0] * v, R.y[A] = q[1] * v, R.z[A] = q[2] * v, A++;
        if (V += g, g < 0)
          if (S = I, V > cr)
            I = PA[V - 1] / 2 | 0;
          else
            I = 0;
        else if (g > 0)
          I = S, S = PA[V] / 2 | 0;
        if (N[0] = N[1] = N[2] = PA[V], N[0] === 0 || N[1] === 0 || N[2] === 0)
          sQ1();
      }
      F += f;
    }
    for (let A = 0;A < z; A++)
      R.x[A] *= 10, R.y[A] *= 10, R.z[A] *= 10;
    if (Y.push(R), Z.shouldUpdate)
      await Z.update({ current: F, max: J.length });
    if (F >= J.length)
      break;
  }
  if (W.length >= 1)
    X.timeOffset = W[0];
  if (W.length >= 2)
    X.deltaTime = W[1] - W[0];
  return X;
}
function sD0(Z) {
  return n0.create("Parse XTC", async (J) => {
    try {
      J.update({ canAbort: !0, message: "Parsing trajectory..." });
      let $ = await aQ1(J, Z);
      return a8.success($);
    } catch ($) {
      return a8.error("" + $);
    }
  });
}

// node_modules/molstar/lib/mol-model-formats/structure/xtc.js
function aD0(Z) {
  return n0.create("Parse XTC", async (J) => {
    await J.update("Converting to coordinates");
    let $ = N$(Z.deltaTime, "step"), X = N$(Z.timeOffset, $.unit), Y = [];
    for (let Q = 0, W = Z.frames.length;Q < W; ++Q) {
      let K = Z.boxes[Q], G = M.fromArray(M(), K, 0), H = M.fromArray(M(), K, 3), N = M.fromArray(M(), K, 6);
      Y.push({
        elementCount: Z.frames[Q].count,
        cell: VK.fromBasis(G, H, N),
        x: Z.frames[Q].x,
        y: Z.frames[Q].y,
        z: Z.frames[Q].z,
        xyzOrdering: { isIdentity: !0 },
        time: N$(X.value + $.value * Q, $.unit)
      });
    }
    return z5.create(Y, $, X);
  });
}

// node_modules/molstar/lib/mol-io/reader/xyz/parser.js
function rQ1(Z) {
  let J = Z.position >= Z.data.length - 1 ? 0 : +Z2.readLine(Z);
  if (isNaN(J))
    J = 0;
  let $ = Z2.readLine(Z), X = new Float64Array(J), Y = new Float64Array(J), Q = new Float64Array(J), W = new Array(J);
  for (let K = 0;K < J; ++K) {
    let H = Z2.readLineTrim(Z).split(/\s+/g);
    W[K] = H[0], X[K] = +H[1], Y[K] = +H[2], Q[K] = +H[3];
  }
  return {
    count: J,
    comment: $,
    x: s.ofFloatArray(X),
    y: s.ofFloatArray(Y),
    z: s.ofFloatArray(Q),
    type_symbol: s.ofStringArray(W)
  };
}
function tQ1(Z) {
  let J = Z2(Z), $ = [];
  while (!0) {
    let Y = rQ1(J);
    if (Y.count === 0)
      break;
    $.push(Y);
  }
  let X = { molecules: $ };
  return a8.success(X);
}
function rD0(Z) {
  return n0.create("Parse Mol", async () => {
    return tQ1(Z);
  });
}

// node_modules/molstar/lib/mol-model-formats/structure/xyz.js
function eQ1(Z, J) {
  let { molecules: $ } = Z, X = 0;
  for (let B of $)
    X += B.count;
  let Y = new Array(X), Q = new Int32Array(X), W = new Float32Array(X), K = new Float32Array(X), G = new Float32Array(X), H = new Int32Array(X), N = 0;
  for (let B = 0;B < $.length; B++) {
    let T = $[B];
    for (let w = 0;w < T.count; w++)
      Y[N] = T.type_symbol.value(w), W[N] = T.x.value(w), K[N] = T.y.value(w), G[N] = T.z.value(w), Q[N] = w, H[N] = B, N++;
  }
  let q = s.ofConst("MOL", X, s.Schema.str), U = s.ofConst("A", X, s.Schema.str), F = s.ofConst(1, X, s.Schema.int), E = s.ofStringArray(Y), R = A8.ofPartialColumns(E9.atom_site, {
    auth_asym_id: U,
    auth_atom_id: E,
    auth_comp_id: q,
    auth_seq_id: F,
    Cartn_x: s.ofFloatArray(W),
    Cartn_y: s.ofFloatArray(K),
    Cartn_z: s.ofFloatArray(G),
    id: s.ofIntArray(Q),
    label_asym_id: U,
    label_atom_id: E,
    label_comp_id: q,
    label_seq_id: F,
    label_entity_id: s.ofConst("1", X, s.Schema.str),
    occupancy: s.ofConst(1, X, s.Schema.float),
    type_symbol: E,
    pdbx_PDB_model_num: s.ofIntArray(H)
  }, X), z = new c7;
  z.setNames([["MOL", "Unknown Entity"]]), z.getEntityId("MOL", e2.Unknown, "A");
  let D = new l7(F, E);
  D.setNames([["MOL", "Unknown Molecule"]]), D.add("MOL", 0);
  let A = u7({
    entity: z.getEntityTable(),
    chem_comp: D.getChemCompTable(),
    atom_site: R
  });
  return nJ(A, lr.create(Z), J);
}
var lr;
(function(Z) {
  function J(X) {
    return (X === null || X === void 0 ? void 0 : X.kind) === "xyz";
  }
  Z.is = J;
  function $(X) {
    return { kind: "xyz", name: "xyz", data: X };
  }
  Z.create = $;
})(lr || (lr = {}));
function tD0(Z) {
  return n0.create("Parse XYZ", (J) => eQ1(Z, J));
}

// node_modules/molstar/lib/mol-io/reader/lammps/schema.js
var CV = {
  lj: {
    mass: "unitless",
    distance: "unitless",
    time: "unitless",
    energy: "unitless",
    velocity: "unitless",
    force: "unitless",
    torque: "unitless",
    temperature: "unitless",
    pressure: "unitless",
    viscosity: "unitless",
    charge: "unitless",
    density: "unitless",
    scale: 1
  },
  real: {
    mass: "grams/mole",
    distance: "Angstroms",
    time: "femtoseconds",
    energy: "Kcal/mol",
    velocity: "Angstroms/femtosecond",
    force: "Kcal/mol-Angstrom",
    torque: "Kcal/mol",
    temperature: "Kelvin",
    pressure: "atmospheres",
    viscosity: "Poise",
    charge: "multiple of electron charge",
    dipole: "charge*Angstroms",
    electricField: "volts/Angstrom",
    density: "g/cm^3",
    scale: 1
  },
  metal: {
    mass: "grams/mole",
    distance: "Angstroms",
    time: "picoseconds",
    energy: "eV",
    velocity: "Angstroms/picosecond",
    force: "eV/Angstrom",
    torque: "eV",
    temperature: "Kelvin",
    pressure: "bars",
    viscosity: "Poise",
    charge: "multiple of electron charge",
    dipole: "charge*Angstroms",
    electricField: "volts/Angstrom",
    density: "g/cm^3",
    scale: 1
  },
  si: {
    mass: "kilograms",
    distance: "meters",
    time: "seconds",
    energy: "Joules",
    velocity: "meters/second",
    force: "Newtons",
    torque: "Newton-meters",
    temperature: "Kelvin",
    pressure: "Pascals",
    viscosity: "Pascal*second",
    charge: "Coulombs",
    dipole: "Coulombs*meters",
    electricField: "volts/meter",
    density: "kg/m^3",
    scale: 1
  },
  cgs: {
    mass: "grams",
    distance: "centimeters",
    time: "seconds",
    energy: "ergs",
    velocity: "centimeters/second",
    force: "dynes",
    torque: "dyne-centimeters",
    temperature: "Kelvin",
    pressure: "dyne/cm^2",
    viscosity: "Poise",
    charge: "statcoulombs",
    dipole: "statcoul-cm",
    electricField: "statvolt/cm",
    density: "g/cm^3",
    scale: 1
  },
  electron: {
    mass: "atomic mass units",
    distance: "Bohr",
    time: "femtoseconds",
    energy: "Hartrees",
    velocity: "Bohr/atomic time units",
    force: "Hartrees/Bohr",
    temperature: "Kelvin",
    pressure: "Pascals",
    charge: "multiple of electron charge",
    dipole: "Debye",
    electricField: "volts/cm",
    density: "unitless",
    torque: "",
    viscosity: "",
    scale: 0.529177
  },
  micro: {
    mass: "picograms",
    distance: "micrometers",
    time: "microseconds",
    energy: "picogram-micrometer^2/microsecond^2",
    velocity: "micrometers/microsecond",
    force: "picogram-micrometer/microsecond^2",
    torque: "picogram-micrometer^2/microsecond^2",
    temperature: "Kelvin",
    pressure: "picogram/(micrometer-microsecond^2)",
    viscosity: "picogram/(micrometer-microsecond)",
    charge: "picocoulombs",
    dipole: "picocoulomb-micrometer",
    electricField: "volt/micrometer",
    density: "pg/μm^3",
    scale: 1
  },
  nano: {
    mass: "attograms",
    distance: "nanometers",
    time: "nanoseconds",
    energy: "attogram-nanometer^2/nanosecond^2",
    velocity: "nanometers/nanosecond",
    force: "attogram-nanometer/nanosecond^2",
    torque: "attogram-nanometer^2/nanosecond^2",
    temperature: "Kelvin",
    pressure: "attogram/(nanometer-nanosecond^2)",
    viscosity: "attogram/(nanometer-nanosecond)",
    charge: "multiple of electron charge",
    dipole: "charge-nanometer",
    electricField: "volt/nanometer",
    density: "ag/nm^3",
    scale: 10
  }
}, nr = ["real", "metal", "si", "cgs", "electron", "micro", "nano", "lj"];

// node_modules/molstar/lib/mol-io/reader/lammps/data/parser.js
var { readLine: ZM0, skipWhitespace: JM0, eatValue: $M0, eatLine: ZW1, markStart: ir } = Z2, eD0 = /\s+/;
function JW1(Z, J) {
  return {
    tokenizer: Z,
    runtimeCtx: J
  };
}
async function $W1(Z, J, $) {
  let { tokenizer: X } = Z, Y = G1.create(X.data, J * 2), Q = G1.create(X.data, J * 2), W = G1.create(X.data, J * 2), K = G1.create(X.data, J * 2), G = G1.create(X.data, J * 2), H = G1.create(X.data, J * 2), N = G1.create(X.data, J * 2), q = {
    full: [Y, Q, W, K, G, H, N],
    atomic: [Y, W, G, H, N],
    bond: [Y, Q, W, G, H, N]
  }, U = q[$].length, { position: F } = X;
  ZM0(X).trim(), X.position = F;
  let { length: E } = X, R = 0;
  return await K$(Z.runtimeCtx, 1e5, void 0, (z) => {
    let D = Math.min(J - R, z);
    for (let A = 0;A < D; ++A) {
      for (let B = 0;B < U; ++B) {
        JM0(X), ir(X), $M0(X);
        let T = q[$][B];
        if (T)
          G1.addUnchecked(T, X.tokenStart, X.tokenEnd);
      }
      ZW1(X), ir(X);
    }
    return R += D, D;
  }, (z) => z.update({ message: "Parsing...", current: X.position, max: E })), {
    count: J,
    atomId: I2(Y)(s.Schema.int),
    moleculeId: I2(Q)(s.Schema.int),
    atomType: I2(W)(s.Schema.int),
    charge: I2(K)(s.Schema.float),
    x: I2(G)(s.Schema.float),
    y: I2(H)(s.Schema.float),
    z: I2(N)(s.Schema.float)
  };
}
async function XW1(Z, J) {
  let { tokenizer: $ } = Z, X = G1.create($.data, J * 2), Y = G1.create($.data, J * 2), Q = G1.create($.data, J * 2), W = G1.create($.data, J * 2), { length: K } = $, G = 0;
  return await K$(Z.runtimeCtx, 10, void 0, (H) => {
    let N = Math.min(J - G, H);
    for (let q = 0;q < N; ++q)
      for (let U = 0;U < 4; ++U)
        switch (JM0($), ir($), $M0($), U) {
          case 0:
            G1.addUnchecked(X, $.tokenStart, $.tokenEnd);
            break;
          case 1:
            G1.addUnchecked(Y, $.tokenStart, $.tokenEnd);
            break;
          case 2:
            G1.addUnchecked(Q, $.tokenStart, $.tokenEnd);
            break;
          case 3:
            G1.addUnchecked(W, $.tokenStart, $.tokenEnd);
            break;
        }
    return G += N, N;
  }, (H) => H.update({ message: "Parsing...", current: $.position, max: K })), {
    count: J,
    bondId: I2(X)(s.Schema.int),
    bondType: I2(Y)(s.Schema.int),
    atomIdA: I2(Q)(s.Schema.int),
    atomIdB: I2(W)(s.Schema.int)
  };
}
var YW1 = ["full", "atomic", "bond"];
async function QW1(Z, J) {
  let $ = Z2(Z), X = JW1($, J), Y = void 0, Q = void 0, W = 0, K = 0, G = "full";
  while ($.tokenEnd < $.length) {
    let N = ZM0(X.tokenizer).trim();
    if (N.includes("atoms"))
      W = parseInt(N.split(eD0)[0]);
    else if (N.includes("bonds"))
      K = parseInt(N.split(eD0)[0]);
    else if (N.includes("Masses"))
      ;
    else if (N.includes("Atoms")) {
      let q = N.split("#");
      if (q.length > 1) {
        let U = q[1].trim();
        if (YW1.includes(U))
          G = U;
        else
          console.warn(`Unknown atom style: ${U}`);
      }
      Y = await $W1(X, W, G);
    } else if (N.includes("Bonds"))
      Q = await XW1(X, K);
  }
  if (Y === void 0)
    return a8.error("no atoms data");
  if (Q === void 0)
    Q = {
      count: 0,
      bondId: s.ofIntArray([]),
      bondType: s.ofIntArray([]),
      atomIdA: s.ofIntArray([]),
      atomIdB: s.ofIntArray([])
    };
  let H = {
    atoms: Y,
    bonds: Q
  };
  return a8.success(H);
}
function XM0(Z) {
  return n0.create("Parse LammpsData", async (J) => {
    return await QW1(Z, J);
  });
}

// node_modules/molstar/lib/mol-model-formats/structure/lammps-data.js
async function WW1(Z, J, $ = "real") {
  let { atoms: X, bonds: Y } = Z, Q = [], W = X.count, K = CV[$].scale, G = new Array(W), H = new Int32Array(W), N = new Float32Array(W), q = new Float32Array(W), U = new Float32Array(W), F = new Int32Array(W), E = 0;
  for (let I = 0;I < W; I++)
    G[E] = X.atomType.value(I).toString(), N[E] = X.x.value(I) * K, q[E] = X.y.value(I) * K, U[E] = X.z.value(I) * K, H[E] = X.atomId.value(I) - 1, F[E] = 0, E++;
  let R = s.ofConst("MOL", W, s.Schema.str), z = s.ofLambda({
    value: (I) => X.moleculeId.value(I).toString(),
    rowCount: W,
    schema: s.Schema.str
  }), D = s.ofConst(1, W, s.Schema.int), A = s.ofStringArray(G), B = A8.ofPartialColumns(E9.atom_site, {
    auth_asym_id: z,
    auth_atom_id: A,
    auth_comp_id: R,
    auth_seq_id: D,
    Cartn_x: s.ofFloatArray(N),
    Cartn_y: s.ofFloatArray(q),
    Cartn_z: s.ofFloatArray(U),
    id: s.ofIntArray(H),
    label_asym_id: z,
    label_atom_id: A,
    label_comp_id: R,
    label_seq_id: D,
    label_entity_id: s.ofConst("1", W, s.Schema.str),
    occupancy: s.ofConst(1, W, s.Schema.float),
    type_symbol: A,
    pdbx_PDB_model_num: s.ofIntArray(F)
  }, W), T = new c7;
  T.setNames([["MOL", "Unknown Entity"]]), T.getEntityId("MOL", e2.Unknown, "A");
  let w = new l7(D, A);
  w.setNames([["MOL", "Unknown Molecule"]]), w.add("MOL", 0);
  let V = u7({
    entity: T.getEntityTable(),
    chem_comp: w.getChemCompTable(),
    atom_site: B
  }), P = await nJ(V, or.create(Z), J);
  if (P.frameCount > 0) {
    let I = P.representative;
    if (Y.count !== 0) {
      let S = s.ofIntArray(s.mapToArray(Y.atomIdA, (g) => g - 1, Int32Array)), f = s.ofIntArray(s.mapToArray(Y.atomIdB, (g) => g - 1, Int32Array)), v = Y.bondId, h = s.ofConst(1, Y.count, s.Schema.int), x = s.ofConst(s1.Flag.Covalent, Y.count, s.Schema.int), b = j9.fromData({ pairs: { key: v, indexA: S, indexB: f, order: h, flag: x }, count: X.count }, { maxDistance: 1 / 0 });
      j9.Provider.set(I, b);
    }
    EH.Provider.set(I, {
      data: X.charge,
      type: "NO_CHARGES"
    }), Q.push(I);
  }
  return new UY(Q);
}
var or;
(function(Z) {
  function J(X) {
    return (X === null || X === void 0 ? void 0 : X.kind) === "data";
  }
  Z.is = J;
  function $(X) {
    return { kind: "data", name: "data", data: X };
  }
  Z.create = $;
})(or || (or = {}));
function YM0(Z, J) {
  if (J === void 0)
    J = "real";
  return n0.create("Parse Lammps Data", ($) => WW1(Z, $, J));
}

// node_modules/molstar/lib/mol-io/reader/lammps/traj/parser.js
var { readLine: CA, skipWhitespace: KW1, eatValue: GW1, eatLine: HW1, markStart: QM0 } = Z2;
function NW1(Z, J) {
  return {
    tokenizer: Z,
    runtimeCtx: J
  };
}
async function qW1(Z, J, $) {
  let { tokenizer: X } = Z, Y = Object.fromEntries($.map((B, T) => [B, T])), Q = $.findIndex((B) => B[0] === "x"), W = $.findIndex((B) => B[0] === "y"), K = $.findIndex((B) => B[0] === "z"), G = $[Q], H = G1.create(X.data, J * 2), N = G1.create(X.data, J * 2), q = G1.create(X.data, J * 2), U = G1.create(X.data, J * 2), F = G1.create(X.data, J * 2), E = G1.create(X.data, J * 2), { position: R } = X;
  X.position = R;
  let z = $.length, { length: D } = X, A = 0;
  return await K$(Z.runtimeCtx, 1e5, void 0, (B) => {
    let T = Math.min(J - A, B);
    for (let w = 0;w < T; ++w) {
      for (let V = 0;V < z; ++V)
        switch (KW1(X), QM0(X), GW1(X), V) {
          case Y.id:
            G1.addUnchecked(H, X.tokenStart, X.tokenEnd);
            break;
          case Y.mol:
            G1.addUnchecked(N, X.tokenStart, X.tokenEnd);
            break;
          case Y.type:
            G1.addUnchecked(q, X.tokenStart, X.tokenEnd);
            break;
          case Q:
            G1.addUnchecked(U, X.tokenStart, X.tokenEnd);
            break;
          case W:
            G1.addUnchecked(F, X.tokenStart, X.tokenEnd);
            break;
          case K:
            G1.addUnchecked(E, X.tokenStart, X.tokenEnd);
            break;
        }
      HW1(X), QM0(X);
    }
    return A += T, T;
  }, (B) => B.update({ message: "Parsing...", current: X.position, max: D })), {
    count: J,
    atomMode: G,
    atomId: I2(H)(s.Schema.int),
    moleculeId: I2(N)(s.Schema.int),
    atomType: I2(q)(s.Schema.int),
    x: I2(U)(s.Schema.float),
    y: I2(F)(s.Schema.float),
    z: I2(E)(s.Schema.float)
  };
}
async function FW1(Z, J) {
  let $ = Z2(Z), X = NW1($, J), Y = {
    frames: [],
    times: [],
    bounds: [],
    timeOffset: 0,
    deltaTime: 0
  }, Q = Y.frames, W = 0, K = 0;
  while ($.tokenEnd < $.length) {
    let G = CA(X.tokenizer).trim();
    if (G.includes("ITEM: TIMESTEP"))
      K = parseInt(CA(X.tokenizer).trim()), Y.times.push(K);
    else if (G.includes("ITEM: NUMBER OF ATOMS"))
      W = parseInt(CA(X.tokenizer).trim());
    else if (G.includes("ITEM: ATOMS")) {
      let H = G.split(" ").slice(2), N = await qW1(X, W, H);
      Q.push(N);
    } else if (G.includes("ITEM: BOX BOUNDS")) {
      let H = G.split("ITEM: BOX BOUNDS ")[1].split(" "), N = H[0], q = H[1], U = H[2], F = CA(X.tokenizer).trim().split(" "), E = CA(X.tokenizer).trim().split(" "), R = CA(X.tokenizer).trim().split(" "), z = parseFloat(F[0]), D = parseFloat(F[1]), A = parseFloat(E[0]), B = parseFloat(E[1]), T = parseFloat(R[0]), w = parseFloat(R[1]);
      Y.bounds.push({
        lower: [z, A, T],
        length: [D - z, B - A, w - T],
        periodicity: [N, q, U]
      });
    }
  }
  if (Y.times.length >= 1)
    Y.timeOffset = Y.times[0];
  if (Y.times.length >= 2)
    Y.deltaTime = Y.times[1] - Y.times[0];
  return a8.success(Y);
}
function sr(Z) {
  return n0.create("Parse Lammp Trajectory", async (J) => {
    return await FW1(Z, J);
  });
}

// node_modules/molstar/lib/mol-model-formats/structure/lammps-trajectory.js
function rr(Z, J = "real") {
  return n0.create("Parse Lammps Trajectory", async ($) => {
    await $.update("Converting to coordinates");
    let X = CV[J].scale, Y = N$(Z.deltaTime, "step"), Q = N$(Z.timeOffset, Y.unit), W = { x: 0, y: 0, z: 0 }, K = { x: 1, y: 1, z: 1 }, H = Z.frames[0].atomMode.includes("s"), N = [];
    for (let q = 0, U = Z.frames.length;q < U; ++q) {
      let F = Z.bounds[q];
      if (H)
        K.x = F.length[0], K.y = F.length[1], K.z = F.length[2], W.x = F.lower[0], W.y = F.lower[1], W.z = F.lower[2];
      let E = Z.frames[q].count, R = new Float32Array(E), z = new Float32Array(E), D = new Float32Array(E), A = 0;
      for (let B = 0;B < E; B++)
        R[A] = (Z.frames[q].x.value(B) * K.x + W.x) * X, z[A] = (Z.frames[q].y.value(B) * K.y + W.y) * X, D[A] = (Z.frames[q].z.value(B) * K.z + W.z) * X, A++;
      N.push({
        elementCount: Z.frames[q].count,
        x: R,
        y: z,
        z: D,
        xyzOrdering: { isIdentity: !0 },
        time: N$(Q.value + Y.value * q, Y.unit)
      });
    }
    return z5.create(N, Y, Q);
  });
}
async function UW1(Z, J, $ = "real") {
  let X = Z.frames[0], Y = X.count, Q = X.atomMode, W = Z.bounds[0], K = { x: 0, y: 0, z: 0 }, G = { x: 1, y: 1, z: 1 }, H = CV[$].scale;
  if (Q.includes("s"))
    G.x = W.length[0], G.y = W.length[1], G.z = W.length[2], K.x = W.lower[0], K.y = W.lower[1], K.z = W.lower[2];
  let N = new Array(Y), q = new Int32Array(Y), U = new Float32Array(Y), F = new Float32Array(Y), E = new Float32Array(Y), R = new Int32Array(Y), z = 0;
  for (let h = 0;h < Y; h++)
    N[z] = X.atomType.value(h).toString(), U[z] = (X.x.value(h) * G.x + K.x) * H, F[z] = (X.y.value(h) * G.y + K.y) * H, E[z] = (X.z.value(h) * G.z + K.z) * H, q[z] = X.atomId.value(h), R[z] = 0, z++;
  let D = s.ofConst("MOL", Y, s.Schema.str), A = s.ofLambda({
    value: (h) => X.moleculeId.value(h).toString(),
    rowCount: Y,
    schema: s.Schema.str
  }), B = s.ofConst(1, Y, s.Schema.int), T = s.ofStringArray(N), w = A8.ofPartialColumns(E9.atom_site, {
    auth_asym_id: A,
    auth_atom_id: T,
    auth_comp_id: D,
    auth_seq_id: B,
    Cartn_x: s.ofFloatArray(U),
    Cartn_y: s.ofFloatArray(F),
    Cartn_z: s.ofFloatArray(E),
    id: s.ofIntArray(q),
    label_asym_id: A,
    label_atom_id: T,
    label_comp_id: D,
    label_seq_id: B,
    label_entity_id: s.ofConst("1", Y, s.Schema.str),
    occupancy: s.ofConst(1, Y, s.Schema.float),
    type_symbol: T,
    pdbx_PDB_model_num: s.ofIntArray(R)
  }, Y), V = new c7;
  V.setNames([["MOL", "Unknown Entity"]]), V.getEntityId("MOL", e2.Unknown, "A");
  let P = new l7(B, T);
  P.setNames([["MOL", "Unknown Molecule"]]), P.add("MOL", 0);
  let I = u7({
    entity: V.getEntityTable(),
    chem_comp: P.getChemCompTable(),
    atom_site: w
  }), f = (await nJ(I, ar.create(Z), J)).representative, v = await rr(Z, $).runInContext(J);
  return O2.trajectoryFromModelAndCoordinates(f, v);
}
var ar;
(function(Z) {
  function J(X) {
    return (X === null || X === void 0 ? void 0 : X.kind) === "lammpstrj";
  }
  Z.is = J;
  function $(X) {
    return { kind: "lammpstrj", name: "lammpstrj", data: X };
  }
  Z.create = $;
})(ar || (ar = {}));
function WM0(Z, J) {
  if (J === void 0)
    J = "real";
  return n0.create("Parse Lammps Traj Data", ($) => UW1(Z, $, J));
}

// node_modules/molstar/lib/mol-io/reader/sdf/parser-v3-util.js
function KM0(Z) {
  return Z.trim().endsWith("V3000");
}
function GM0(Z) {
  let J = G1.create(Z.data, 1), $ = G1.create(Z.data, 1);
  return Z2.eatLine(Z), NU(Z), NU(Z), NU(Z), HU(Z, J), HU(Z, $), Z2.eatLine(Z), {
    atomCount: I2(J)(s.Schema.int).value(0),
    bondCount: I2($)(s.Schema.int).value(0)
  };
}
function HM0(Z, J) {
  let $ = G1.create(Z.data, J * 2), X = G1.create(Z.data, J * 2), Y = G1.create(Z.data, J * 2), Q = G1.create(Z.data, J * 2);
  for (let W = 0;W < J; ++W) {
    Z2.markLine(Z), NU(Z), NU(Z), NU(Z);
    let { position: K } = Z;
    HU(Z, Q), HU(Z, $), HU(Z, X), HU(Z, Y), Z.position = K;
  }
  return Z2.eatLine(Z), Z2.eatLine(Z), {
    count: J,
    x: I2($)(s.Schema.float),
    y: I2(X)(s.Schema.float),
    z: I2(Y)(s.Schema.float),
    type_symbol: I2(Q)(s.Schema.str),
    formal_charge: s.ofConst(0, J, s.Schema.int)
  };
}
function NM0(Z, J) {
  let $ = G1.create(Z.data, J * 2), X = G1.create(Z.data, J * 2), Y = G1.create(Z.data, J * 2);
  for (let Q = 0;Q < J; ++Q) {
    Z2.markLine(Z), NU(Z), NU(Z), NU(Z);
    let { position: W } = Z;
    HU(Z, Y), HU(Z, $), HU(Z, X), Z.position = W;
  }
  return Z2.eatLine(Z), Z2.eatLine(Z), {
    count: J,
    atomIdxA: I2($)(s.Schema.float),
    atomIdxB: I2(X)(s.Schema.float),
    order: I2(Y)(s.Schema.float)
  };
}
function NU(Z) {
  Z2.skipWhitespace(Z), Z2.eatValue(Z);
}
function HU(Z, J) {
  let { position: $ } = Z;
  Z2.skipWhitespace(Z), Z2.eatValue(Z), Z2.trim(Z, $, Z.position), G1.addUnchecked(J, Z.tokenStart, Z.tokenEnd);
}

// node_modules/molstar/lib/mol-io/reader/sdf/parser.js
var tr = "$$$$";
function LW1(Z) {
  let J = G1.create(Z.data, 32), $ = G1.create(Z.data, 32);
  while (Z.position < Z.length) {
    let X = Z2.readLine(Z);
    if (X.startsWith(tr))
      break;
    if (!X)
      continue;
    if (X.startsWith("> ")) {
      G1.add(J, Z.tokenStart + 2, Z.tokenEnd), Z2.markLine(Z);
      let { tokenStart: Y, tokenEnd: Q } = Z, W = !1;
      while (Z.position < Z.length) {
        let K = Z2.readLine(Z);
        if (!K || K.startsWith(tr) || K.startsWith("> ")) {
          G1.add($, Y, Q), W = !0;
          break;
        }
        Q = Z.tokenEnd;
      }
      if (!W)
        G1.add($, Y, Q);
    }
  }
  return {
    dataHeader: I2(J)(s.Schema.str),
    data: I2($)(s.Schema.str)
  };
}
function RW1(Z) {
  return {
    atomCount: +Z.substr(0, 3),
    bondCount: +Z.substr(3, 3)
  };
}
function EW1(Z) {
  let J = Z2.readLine(Z).trim(), $ = Z2.readLine(Z).trim(), X = Z2.readLine(Z).trim(), Y = Z2.readLine(Z), Q = KM0(Y), { atomCount: W, bondCount: K } = Q ? GM0(Z) : RW1(Y);
  if (Number.isNaN(W) || Number.isNaN(K)) {
    while (Z.position < Z.length)
      if (Z2.readLine(Z).startsWith(tr))
        break;
    return;
  }
  let G = {
    atomIdx: s.ofConst(0, W, s.Schema.int),
    charge: s.ofConst(0, W, s.Schema.int)
  }, H = Q ? HM0(Z, W) : br(Z, W), N = Q ? NM0(Z, K) : xr(Z, K), q = Q ? { formalCharges: G } : yr(Z), U = LW1(Z);
  return {
    molFile: { title: J, program: $, comment: X, atoms: H, bonds: N, ...q },
    dataItems: U
  };
}
function OW1(Z) {
  let J = Z2(Z), $ = [];
  while (J.position < J.length) {
    let X = EW1(J);
    if (X)
      $.push(X);
  }
  return a8.success({ compounds: $ });
}
function qM0(Z) {
  return n0.create("Parse Sdf", async () => {
    return OW1(Z);
  });
}

// node_modules/molstar/lib/mol-model-formats/structure/sdf.js
var er;
(function(Z) {
  function J(X) {
    return (X === null || X === void 0 ? void 0 : X.kind) === "sdf";
  }
  Z.is = J;
  function $(X) {
    return { kind: "sdf", name: X.molFile.title, data: X };
  }
  Z.create = $;
})(er || (er = {}));
function FM0(Z) {
  return n0.create("Parse SDF", (J) => mr(Z.molFile, er.create(Z), J));
}

// node_modules/molstar/lib/mol-io/reader/trr/parser.js
async function zW1(Z) {
  let J = new DataView(Z.buffer), $ = {
    frames: [],
    boxes: [],
    times: [],
    timeOffset: 0,
    deltaTime: 0
  }, X = $.frames, Y = $.boxes, Q = $.times, W = 0;
  while (!0) {
    W += 8;
    let K = J.getInt32(W);
    W += 4, W += K;
    let G = J.getInt32(W + 8), H = J.getInt32(W + 12), N = J.getInt32(W + 16), q = J.getInt32(W + 28), U = J.getInt32(W + 32), F = J.getInt32(W + 36), E = J.getInt32(W + 40);
    W += 52;
    let R = G / 9, z = E * 3;
    if (R === 8)
      Q.push(J.getFloat64(W));
    else
      Q.push(J.getFloat32(W));
    if (W += 2 * R, G) {
      let D = new Float32Array(9);
      if (R === 8)
        for (let A = 0;A < 9; ++A)
          D[A] = J.getFloat64(W) * 10, W += 8;
      else
        for (let A = 0;A < 9; ++A)
          D[A] = J.getFloat32(W) * 10, W += 4;
      Y.push(D);
    }
    if (W += H, W += N, q) {
      let D = new Float32Array(E), A = new Float32Array(E), B = new Float32Array(E);
      if (R === 8)
        for (let T = 0;T < E; ++T)
          D[T] = J.getFloat64(W) * 10, A[T] = J.getFloat64(W + 8) * 10, B[T] = J.getFloat64(W + 16) * 10, W += 24;
      else {
        let T = new Uint32Array(Z.buffer, W, z);
        for (let V = 0;V < z; ++V) {
          let P = T[V];
          T[V] = (P & 255) << 24 | (P & 65280) << 8 | P >> 8 & 65280 | P >> 24 & 255;
        }
        let w = new Float32Array(Z.buffer, W, z);
        for (let V = 0;V < E; ++V)
          D[V] = w[V * 3] * 10, A[V] = w[V * 3 + 1] * 10, B[V] = w[V * 3 + 2] * 10, W += 12;
      }
      X.push({ count: E, x: D, y: A, z: B });
    }
    if (W += U, W += F, W >= Z.byteLength)
      break;
  }
  if (Q.length >= 1)
    $.timeOffset = Q[0];
  if (Q.length >= 2)
    $.deltaTime = Q[1] - Q[0];
  return $;
}
function UM0(Z) {
  return n0.create("Parse TRR", async (J) => {
    try {
      J.update({ canAbort: !0, message: "Parsing trajectory..." });
      let $ = await zW1(Z);
      return a8.success($);
    } catch ($) {
      return a8.error("" + $);
    }
  });
}

// node_modules/molstar/lib/mol-model-formats/structure/trr.js
function LM0(Z) {
  return n0.create("Parse TRR", async (J) => {
    await J.update("Converting to coordinates");
    let $ = N$(Z.deltaTime, "step"), X = N$(Z.timeOffset, $.unit), Y = [];
    for (let Q = 0, W = Z.frames.length;Q < W; ++Q) {
      let K = Z.boxes[Q], G = M.fromArray(M(), K, 0), H = M.fromArray(M(), K, 3), N = M.fromArray(M(), K, 6);
      Y.push({
        elementCount: Z.frames[Q].count,
        cell: VK.fromBasis(G, H, N),
        x: Z.frames[Q].x,
        y: Z.frames[Q].y,
        z: Z.frames[Q].z,
        xyzOrdering: { isIdentity: !0 },
        time: N$(X.value + $.value * Q, $.unit)
      });
    }
    return z5.create(Y, $, X);
  });
}

// node_modules/molstar/lib/mol-io/common/io-buffer.js
var Zt = [];

class Jt {
  constructor(Z, J = {}) {
    this._mark = 0, this._marks = [], this.offset = 0, this.littleEndian = !0;
    let $ = !1;
    if (Z === void 0)
      Z = 8192;
    if (typeof Z === "number")
      Z = new ArrayBuffer(Z);
    else
      $ = !0;
    let X = J.offset ? J.offset >>> 0 : 0, Y = Z.byteLength - X, Q = X;
    if (!(Z instanceof ArrayBuffer) && !(Z instanceof SharedArrayBuffer)) {
      if (Z.byteLength !== Z.buffer.byteLength)
        Q = Z.byteOffset + X;
      Z = Z.buffer;
    }
    if ($)
      this._lastWrittenByte = Y;
    else
      this._lastWrittenByte = 0;
    this.buffer = Z, this.length = Y, this.byteLength = Y, this.byteOffset = Q, this._data = new DataView(this.buffer, Q, Y);
  }
  available(Z = 1) {
    return this.offset + Z <= this.length;
  }
  isLittleEndian() {
    return this.littleEndian;
  }
  setLittleEndian() {
    return this.littleEndian = !0, this;
  }
  isBigEndian() {
    return !this.littleEndian;
  }
  setBigEndian() {
    return this.littleEndian = !1, this;
  }
  skip(Z) {
    if (Z === void 0)
      Z = 1;
    return this.offset += Z, this;
  }
  seek(Z) {
    return this.offset = Z, this;
  }
  mark() {
    return this._mark = this.offset, this;
  }
  reset() {
    return this.offset = this._mark, this;
  }
  pushMark() {
    return this._marks.push(this.offset), this;
  }
  popMark() {
    let Z = this._marks.pop();
    if (Z === void 0)
      throw new Error("Mark stack empty");
    return this.seek(Z), this;
  }
  rewind() {
    return this.offset = 0, this;
  }
  ensureAvailable(Z) {
    if (Z === void 0)
      Z = 1;
    if (!this.available(Z)) {
      let $ = (this.offset + Z) * 2, X = new Uint8Array($);
      X.set(new Uint8Array(this.buffer)), this.buffer = X.buffer, this.length = this.byteLength = $, this._data = new DataView(this.buffer);
    }
    return this;
  }
  readBoolean() {
    return this.readUint8() !== 0;
  }
  readInt8() {
    return this._data.getInt8(this.offset++);
  }
  readUint8() {
    return this._data.getUint8(this.offset++);
  }
  readByte() {
    return this.readUint8();
  }
  readBytes(Z) {
    if (Z === void 0)
      Z = 1;
    let J = new Uint8Array(Z);
    for (let $ = 0;$ < Z; $++)
      J[$] = this.readByte();
    return J;
  }
  readInt16() {
    let Z = this._data.getInt16(this.offset, this.littleEndian);
    return this.offset += 2, Z;
  }
  readUint16() {
    let Z = this._data.getUint16(this.offset, this.littleEndian);
    return this.offset += 2, Z;
  }
  readInt32() {
    let Z = this._data.getInt32(this.offset, this.littleEndian);
    return this.offset += 4, Z;
  }
  readUint32() {
    let Z = this._data.getUint32(this.offset, this.littleEndian);
    return this.offset += 4, Z;
  }
  readFloat32() {
    let Z = this._data.getFloat32(this.offset, this.littleEndian);
    return this.offset += 4, Z;
  }
  readFloat64() {
    let Z = this._data.getFloat64(this.offset, this.littleEndian);
    return this.offset += 8, Z;
  }
  readChar() {
    return String.fromCharCode(this.readInt8());
  }
  readChars(Z = 1) {
    Zt.length = Z;
    for (let J = 0;J < Z; J++)
      Zt[J] = this.readChar();
    return Zt.join("");
  }
  writeBoolean(Z = !1) {
    return this.writeUint8(Z ? 255 : 0), this;
  }
  writeInt8(Z) {
    return this.ensureAvailable(1), this._data.setInt8(this.offset++, Z), this._updateLastWrittenByte(), this;
  }
  writeUint8(Z) {
    return this.ensureAvailable(1), this._data.setUint8(this.offset++, Z), this._updateLastWrittenByte(), this;
  }
  writeByte(Z) {
    return this.writeUint8(Z);
  }
  writeBytes(Z) {
    this.ensureAvailable(Z.length);
    for (let J = 0;J < Z.length; J++)
      this._data.setUint8(this.offset++, Z[J]);
    return this._updateLastWrittenByte(), this;
  }
  writeInt16(Z) {
    return this.ensureAvailable(2), this._data.setInt16(this.offset, Z, this.littleEndian), this.offset += 2, this._updateLastWrittenByte(), this;
  }
  writeUint16(Z) {
    return this.ensureAvailable(2), this._data.setUint16(this.offset, Z, this.littleEndian), this.offset += 2, this._updateLastWrittenByte(), this;
  }
  writeInt32(Z) {
    return this.ensureAvailable(4), this._data.setInt32(this.offset, Z, this.littleEndian), this.offset += 4, this._updateLastWrittenByte(), this;
  }
  writeUint32(Z) {
    return this.ensureAvailable(4), this._data.setUint32(this.offset, Z, this.littleEndian), this.offset += 4, this._updateLastWrittenByte(), this;
  }
  writeFloat32(Z) {
    return this.ensureAvailable(4), this._data.setFloat32(this.offset, Z, this.littleEndian), this.offset += 4, this._updateLastWrittenByte(), this;
  }
  writeFloat64(Z) {
    return this.ensureAvailable(8), this._data.setFloat64(this.offset, Z, this.littleEndian), this.offset += 8, this._updateLastWrittenByte(), this;
  }
  writeChar(Z) {
    return this.writeUint8(Z.charCodeAt(0));
  }
  writeChars(Z) {
    for (let J = 0;J < Z.length; J++)
      this.writeUint8(Z.charCodeAt(J));
    return this;
  }
  toArray() {
    return new Uint8Array(this.buffer, this.byteOffset, this._lastWrittenByte);
  }
  _updateLastWrittenByte() {
    if (this.offset > this._lastWrittenByte)
      this._lastWrittenByte = this.offset;
  }
}

// node_modules/molstar/lib/mol-io/common/netcdf/reader.js
function g3(Z, J) {
  if (Z)
    throw new TypeError("Not a valid NetCDF v3.x file: " + J);
}
function RM0(Z) {
  if (Z.offset % 4 !== 0)
    Z.skip(4 - Z.offset % 4);
}
function $t(Z) {
  let J = Z.readUint32(), $ = Z.readChars(J);
  return RM0(Z), $;
}
var SJ = {
  BYTE: 1,
  CHAR: 2,
  SHORT: 3,
  INT: 4,
  FLOAT: 5,
  DOUBLE: 6
};
function EM0(Z) {
  switch (Number(Z)) {
    case SJ.BYTE:
      return "byte";
    case SJ.CHAR:
      return "char";
    case SJ.SHORT:
      return "short";
    case SJ.INT:
      return "int";
    case SJ.FLOAT:
      return "float";
    case SJ.DOUBLE:
      return "double";
    default:
      return "undefined";
  }
}
function OM0(Z) {
  switch (Number(Z)) {
    case SJ.BYTE:
      return 1;
    case SJ.CHAR:
      return 1;
    case SJ.SHORT:
      return 2;
    case SJ.INT:
      return 4;
    case SJ.FLOAT:
      return 4;
    case SJ.DOUBLE:
      return 8;
    default:
      return -1;
  }
}
function zM0(Z) {
  switch (String(Z)) {
    case "byte":
      return SJ.BYTE;
    case "char":
      return SJ.CHAR;
    case "short":
      return SJ.SHORT;
    case "int":
      return SJ.INT;
    case "float":
      return SJ.FLOAT;
    case "double":
      return SJ.DOUBLE;
    default:
      return -1;
  }
}
function Cb(Z, J) {
  if (Z !== 1) {
    let $ = new Array(Z);
    for (let X = 0;X < Z; X++)
      $[X] = J();
    return $;
  } else
    return J();
}
function Xt(Z, J, $) {
  switch (J) {
    case SJ.BYTE:
      return Z.readBytes($);
    case SJ.CHAR:
      return DW1(Z.readChars($));
    case SJ.SHORT:
      return Cb($, Z.readInt16.bind(Z));
    case SJ.INT:
      return Cb($, Z.readInt32.bind(Z));
    case SJ.FLOAT:
      return Cb($, Z.readFloat32.bind(Z));
    case SJ.DOUBLE:
      return Cb($, Z.readFloat64.bind(Z));
    default:
      g3(!0, "non valid type " + J);
      return;
  }
}
function DW1(Z) {
  if (Z.charCodeAt(Z.length - 1) === 0)
    return Z.substring(0, Z.length - 1);
  return Z;
}
function MW1(Z, J) {
  let $ = zM0(J.type), X = J.size / OM0($), Y = new Array(X);
  for (let Q = 0;Q < X; Q++)
    Y[Q] = Xt(Z, $, 1);
  return Y;
}
function AW1(Z, J, $) {
  let X = zM0(J.type), Y = J.size ? J.size / OM0(X) : 1, Q = $.length, W = new Array(Q), K = $.recordStep;
  for (let G = 0;G < Q; G++) {
    let H = Z.offset;
    W[G] = Xt(Z, X, Y), Z.seek(H + K);
  }
  return W;
}
var kA = 0, BW1 = 10, wW1 = 11, jW1 = 12;
function TW1(Z, J) {
  let $ = { recordDimension: { length: Z.readUint32() } };
  $.version = J;
  let X = _W1(Z);
  $.recordDimension.id = X.recordId, $.recordDimension.name = X.recordName, $.dimensions = X.dimensions, $.globalAttributes = DM0(Z);
  let Y = VW1(Z, X.recordId, J);
  return $.variables = Y.variables, $.recordDimension.recordStep = Y.recordStep, $;
}
function _W1(Z) {
  let J, $, X, Y = Z.readUint32();
  if (Y === kA)
    return g3(Z.readUint32() !== kA, "wrong empty tag for list of dimensions"), [];
  else {
    g3(Y !== BW1, "wrong tag for list of dimensions");
    let Q = Z.readUint32();
    J = new Array(Q);
    for (let W = 0;W < Q; W++) {
      let K = $t(Z), G = Z.readUint32();
      if (G === 0)
        $ = W, X = K;
      J[W] = {
        name: K,
        size: G
      };
    }
    return {
      dimensions: J,
      recordId: $,
      recordName: X
    };
  }
}
function DM0(Z) {
  let J, $ = Z.readUint32();
  if ($ === kA)
    return g3(Z.readUint32() !== kA, "wrong empty tag for list of attributes"), [];
  else {
    g3($ !== jW1, "wrong tag for list of attributes");
    let X = Z.readUint32();
    J = new Array(X);
    for (let Y = 0;Y < X; Y++) {
      let Q = $t(Z), W = Z.readUint32();
      g3(W < 1 || W > 6, "non valid type " + W);
      let K = Z.readUint32(), G = Xt(Z, W, K);
      RM0(Z), J[Y] = {
        name: Q,
        type: EM0(W),
        value: G
      };
    }
  }
  return J;
}
function VW1(Z, J, $) {
  let X = Z.readUint32(), Y = 0, Q;
  if (X === kA)
    return g3(Z.readUint32() !== kA, "wrong empty tag for list of variables"), [];
  else {
    g3(X !== wW1, "wrong tag for list of variables");
    let W = Z.readUint32();
    Q = new Array(W);
    for (let K = 0;K < W; K++) {
      let G = $t(Z), H = Z.readUint32(), N = new Array(H);
      for (let R = 0;R < H; R++)
        N[R] = Z.readUint32();
      let q = DM0(Z), U = Z.readUint32();
      g3(U < 1 && U > 6, "non valid type " + U);
      let F = Z.readUint32(), E = Z.readUint32();
      if ($ === 2)
        g3(E > 0, "offsets larger than 4GB not supported"), E = Z.readUint32();
      if (N[0] === J)
        Y += F;
      Q[K] = {
        name: G,
        dimensions: N,
        attributes: q,
        type: EM0(U),
        size: F,
        offset: E,
        record: N[0] === J
      };
    }
  }
  return {
    variables: Q,
    recordStep: Y
  };
}

class Yt {
  constructor(Z) {
    let J = new Jt(Z);
    J.setBigEndian(), g3(J.readChars(3) !== "CDF", "should start with CDF");
    let $ = J.readByte();
    g3($ > 2, "unknown version"), this.header = TW1(J, $), this.buffer = J;
  }
  get version() {
    if (this.header.version === 1)
      return "classic format";
    else
      return "64-bit offset format";
  }
  get recordDimension() {
    return this.header.recordDimension;
  }
  get dimensions() {
    return this.header.dimensions;
  }
  get globalAttributes() {
    return this.header.globalAttributes;
  }
  get variables() {
    return this.header.variables;
  }
  hasDataVariable(Z) {
    return this.header.variables && this.header.variables.findIndex((J) => J.name === Z) !== -1;
  }
  getDataVariable(Z) {
    var J;
    let $;
    if (typeof Z === "string")
      $ = (J = this.header.variables) === null || J === void 0 ? void 0 : J.find((X) => X.name === Z);
    else
      $ = Z;
    if ($ === void 0)
      throw new Error("variable not found");
    if (this.buffer.seek($.offset), $.record)
      return AW1(this.buffer, $, this.header.recordDimension);
    else
      return MW1(this.buffer, $);
  }
}

// node_modules/molstar/lib/mol-io/reader/nctraj/parser.js
async function IW1(Z) {
  let J = new Yt(Z.buffer), $ = {
    coordinates: [],
    time: [],
    timeOffset: 0,
    deltaTime: 1
  };
  for (let X of J.getDataVariable("coordinates"))
    $.coordinates.push(X);
  if (J.hasDataVariable("velocities")) {
    let X = [];
    for (let Y of J.getDataVariable("velocities"))
      X.push(Y);
    $.velocities = X;
  }
  if (J.hasDataVariable("forces")) {
    let X = [];
    for (let Y of J.getDataVariable("forces"))
      X.push(Y);
    $.forces = X;
  }
  if (J.hasDataVariable("cell_lengths")) {
    let X = [];
    for (let Y of J.getDataVariable("cell_lengths"))
      X.push(Y);
    $.cell_lengths = X;
  }
  if (J.hasDataVariable("cell_angles")) {
    let X = [];
    for (let Y of J.getDataVariable("cell_angles"))
      X.push(Y);
    $.cell_angles = X;
  }
  if (J.hasDataVariable("time")) {
    let X = [];
    for (let Y of J.getDataVariable("time"))
      X.push(Y);
    $.time = X;
  }
  if ($.time) {
    if ($.time.length >= 1)
      $.timeOffset = $.time[0];
    if ($.time.length >= 2)
      $.deltaTime = $.time[1] - $.time[0];
  }
  return $;
}
function MM0(Z) {
  return n0.create("Parse NCTRAJ", async (J) => {
    try {
      J.update({ canAbort: !0, message: "Parsing trajectory..." });
      let $ = await IW1(Z);
      return a8.success($);
    } catch ($) {
      return a8.error("" + $);
    }
  });
}

// node_modules/molstar/lib/mol-model-formats/structure/nctraj.js
function AM0(Z) {
  return n0.create("Parse NCTRAJ", async (J) => {
    await J.update("Converting to coordinates");
    let $ = N$(Z.deltaTime, "step"), X = N$(Z.timeOffset, $.unit), Y = [];
    for (let Q = 0, W = Z.coordinates.length;Q < W; ++Q) {
      let K = Z.coordinates[Q], G = K.length / 3, H = new Float32Array(G), N = new Float32Array(G), q = new Float32Array(G);
      for (let F = 0, E = K.length;F < E; F += 3)
        H[F / 3] = K[F], N[F / 3] = K[F + 1], q[F / 3] = K[F + 2];
      let U = {
        elementCount: G,
        x: H,
        y: N,
        z: q,
        xyzOrdering: { isIdentity: !0 },
        time: N$(X.value + $.value * Q, $.unit)
      };
      if (Z.cell_lengths) {
        let F = Z.cell_lengths[Q], E = M.scale(M(), M.unitX, F[0]), R = M.scale(M(), M.unitY, F[1]), z = M.scale(M(), M.unitZ, F[2]);
        U.cell = VK.fromBasis(E, R, z);
      }
      Y.push(U);
    }
    return z5.create(Y, $, X);
  });
}

// node_modules/molstar/lib/mol-model-formats/structure/prmtop.js
function PW1(Z) {
  let { pointers: J, residuePointer: $, residueLabel: X, atomName: Y } = Z, Q = J.NATOM, W = J.NRES, K = new Uint32Array(Q), G = [], H = (x, b, g) => {
    let m = X.value(x);
    for (let i = b, r = g;i < r; ++i)
      K[i] = x + 1, G[i] = m;
  };
  for (let x = 0, b = W - 1;x < b; ++x)
    H(x, $.value(x) - 1, $.value(x + 1) - 1);
  H(W - 1, $.value(W - 1) - 1, Q);
  let N = s.ofIntArray(K), q = s.ofStringArray(G), U = new Array(Q), F = new Array(Q), E = new Uint32Array(Q), R = new Uint32Array(Q), z = new c7, D = new l7(N, Y), A = "", B = 0, T = "", w = 0, V = e2.Unknown, P = -1;
  for (let x = 0, b = Q;x < b; ++x) {
    let g = N.value(x);
    if (g !== P) {
      let m = q.value(x), i = qY(D.add(m, x).type, m);
      if (i !== V)
        T = DH(B), B += 1, w = 0;
      A = z.getEntityId(m, i, T), w += 1, P = g, V = i;
    }
    U[x] = A, F[x] = T, E[x] = w, R[x] = x;
  }
  let I = s.ofIntArray(R), S = s.ofStringArray(F), f = new Array(Q);
  for (let x = 0;x < Q; ++x)
    f[x] = h3(Y.value(x), q.value(x));
  let v = A8.ofPartialColumns(E9.atom_site, {
    auth_asym_id: S,
    auth_atom_id: s.asArrayColumn(Y),
    auth_comp_id: q,
    auth_seq_id: N,
    id: s.asArrayColumn(I),
    label_asym_id: S,
    label_atom_id: s.asArrayColumn(Y),
    label_comp_id: q,
    label_seq_id: s.ofIntArray(E),
    label_entity_id: s.ofStringArray(U),
    occupancy: s.ofConst(1, Q, s.Schema.float),
    type_symbol: s.ofStringArray(f),
    pdbx_PDB_model_num: s.ofConst(1, Q, s.Schema.int)
  }, Q);
  return u7({
    entity: z.getEntityTable(),
    chem_comp: D.getChemCompTable(),
    atom_site: v
  });
}
var Qt;
(function(Z) {
  function J(X) {
    return (X === null || X === void 0 ? void 0 : X.kind) === "prmtop";
  }
  Z.is = J;
  function $(X) {
    return { kind: "prmtop", name: X.title.join(" ") || "PRMTOP", data: X };
  }
  Z.fromPrmtop = $;
})(Qt || (Qt = {}));
function BM0(Z) {
  return n0.create("Parse PRMTOP", async (J) => {
    let $ = Qt.fromPrmtop(Z), X = PW1(Z), { pointers: { NBONH: Y, NBONA: Q }, bondsIncHydrogen: W, bondsWithoutHydrogen: K } = Z, G = Y + Q, H = {
      indexA: s.ofLambda({
        value: (N) => {
          return N < Y ? W.value(N * 3) / 3 : K.value((N - Y) * 3) / 3;
        },
        rowCount: G,
        schema: s.Schema.int
      }),
      indexB: s.ofLambda({
        value: (N) => {
          return N < Y ? W.value(N * 3 + 1) / 3 : K.value((N - Y) * 3 + 1) / 3;
        },
        rowCount: G,
        schema: s.Schema.int
      }),
      order: s.ofConst(1, G, s.Schema.int)
    };
    return ER.create(Z.title.join(" ") || "PRMTOP", X, H, $);
  });
}

// node_modules/molstar/lib/mol-model-formats/structure/top.js
function CW1(Z) {
  let { molecules: J, compounds: $ } = Z, X = {}, Y = 0;
  for (let x = 0, b = J._rowCount;x < b; ++x) {
    let g = J.compound.value(x), m = J.molCount.value(x), { atoms: i } = $[g];
    s.asArrayColumn(i.atom), s.asArrayColumn(i.resnr), s.asArrayColumn(i.residu), Y += m * i._rowCount;
    let r = i.resnr.value(0);
    X[g] = !0;
    for (let Y0 = 1, c = i._rowCount;Y0 < c; ++Y0) {
      let n = i.resnr.value(Y0);
      if (n !== r) {
        X[g] = !1;
        break;
      }
      r = n;
    }
  }
  let Q = new Array(Y), W = new Uint32Array(Y), K = new Array(Y), G = 0;
  for (let x = 0, b = J._rowCount;x < b; ++x) {
    let g = J.compound.value(x), m = J.molCount.value(x), { atoms: i } = $[g], r = X[g];
    for (let Y0 = 0;Y0 < m; ++Y0)
      for (let c = 0, n = i._rowCount;c < n; ++c) {
        if (Q[G] = i.atom.value(c), W[G] = i.resnr.value(c), K[G] = i.residu.value(c), r)
          W[G] += Y0;
        G += 1;
      }
  }
  let H = s.ofStringArray(Q), N = s.ofIntArray(W), q = s.ofStringArray(K), U = new Array(Y), F = new Array(Y), E = new Uint32Array(Y), R = new Uint32Array(Y), z = new c7, D = new l7(N, H), A = "", B = 0, T = "", w = 0, V = e2.Unknown, P = -1;
  for (let x = 0, b = Y;x < b; ++x) {
    let g = N.value(x);
    if (g !== P) {
      let m = q.value(x), i = qY(D.add(m, x).type, m);
      if (i !== V)
        T = DH(B), B += 1, w = 0;
      A = z.getEntityId(m, i, T), w += 1, P = g, V = i;
    }
    U[x] = A, F[x] = T, E[x] = w, R[x] = x;
  }
  let I = s.ofIntArray(R), S = s.ofStringArray(F), f = new Array(Y);
  for (let x = 0;x < Y; ++x)
    f[x] = h3(H.value(x), q.value(x));
  let v = A8.ofPartialColumns(E9.atom_site, {
    auth_asym_id: S,
    auth_atom_id: s.asArrayColumn(H),
    auth_comp_id: q,
    auth_seq_id: N,
    id: s.asArrayColumn(I),
    label_asym_id: S,
    label_atom_id: s.asArrayColumn(H),
    label_comp_id: q,
    label_seq_id: s.ofIntArray(E),
    label_entity_id: s.ofStringArray(U),
    occupancy: s.ofConst(1, Y, s.Schema.float),
    type_symbol: s.ofStringArray(f),
    pdbx_PDB_model_num: s.ofConst(1, Y, s.Schema.int)
  }, Y);
  return u7({
    entity: z.getEntityTable(),
    chem_comp: D.getChemCompTable(),
    atom_site: v
  });
}
function kW1(Z) {
  let { molecules: J, compounds: $ } = Z, X = [], Y = [], Q = 0;
  for (let W = 0, K = J._rowCount;W < K; ++W) {
    let G = J.compound.value(W), H = J.molCount.value(W), { atoms: N, bonds: q } = $[G];
    if (q)
      for (let U = 0;U < H; ++U) {
        for (let F = 0, E = q._rowCount;F < E; ++F)
          X.push(q.ai.value(F) - 1 + Q), Y.push(q.aj.value(F) - 1 + Q);
        Q += N._rowCount;
      }
    else if (G === "TIP3")
      for (let U = 0;U < H; ++U)
        X.push(0 + Q), Y.push(1 + Q), X.push(0 + Q), Y.push(2 + Q), Q += N._rowCount;
    else
      Q += H * N._rowCount;
  }
  return {
    indexA: s.ofIntArray(X),
    indexB: s.ofIntArray(Y),
    order: s.ofConst(1, X.length, s.Schema.int)
  };
}
var Wt;
(function(Z) {
  function J(X) {
    return (X === null || X === void 0 ? void 0 : X.kind) === "top";
  }
  Z.is = J;
  function $(X) {
    return { kind: "top", name: X.system || "TOP", data: X };
  }
  Z.fromTop = $;
})(Wt || (Wt = {}));
function wM0(Z) {
  return n0.create("Parse TOP", async (J) => {
    let $ = Wt.fromTop(Z), X = CW1(Z), Y = kW1(Z);
    return ER.create(Z.system || "TOP", X, Y, $);
  });
}

// node_modules/molstar/lib/mol-plugin-state/transforms/helpers.js
function Kt(Z) {
  let J = Z[0].loci, $ = Z[1].loci;
  return { pairs: [{ loci: [J, $] }] };
}
function Gt(Z) {
  let J = Z[0].loci, $ = Z[1].loci, X = Z[2].loci;
  return { triples: [{ loci: [J, $, X] }] };
}
function Ht(Z) {
  let J = Z[0].loci, $ = Z[1].loci, X = Z[2].loci, Y = Z[3].loci;
  return { quads: [{ loci: [J, $, X, Y] }] };
}
function Nt(Z) {
  return { infos: [{ loci: Z[0].loci }] };
}
function qt(Z) {
  return { locis: Z.map((J) => J.loci) };
}
function Ft(Z) {
  return { locis: Z.map((J) => J.loci) };
}
var v5 = {
  center: M(),
  rotation: e(),
  translationToCenter: e(),
  translationFromCenter: e(),
  translation: e(),
  local: e()
};
function vA(Z) {
  var J;
  if (Z.name === "components" && ((J = Z.params.rotationCenter) === null || J === void 0 ? void 0 : J.name) === "centroid")
    return !0;
  return !1;
}
function SA(Z, J) {
  var $, X;
  if (Z.name === "matrix") {
    let Y = e();
    if (e.copy(Y, Z.params.data), Z.params.transpose)
      e.transpose(Y, Y);
    return Y;
  } else {
    if ((($ = Z.params.rotationCenter) === null || $ === void 0 ? void 0 : $.name) === "centroid")
      M.copy(v5.center, J);
    else if (((X = Z.params.rotationCenter) === null || X === void 0 ? void 0 : X.name) === "point")
      M.copy(v5.center, Z.params.rotationCenter.params.point);
    else
      M.set(v5.center, 0, 0, 0);
    e.fromTranslation(v5.translationToCenter, v5.center), e.fromRotation(v5.rotation, Z.params.angle * Math.PI / 180, Z.params.axis), e.fromTranslation(v5.translationFromCenter, M.negate(v5.center, v5.center));
    let Y = e.mul3(e(), v5.translationToCenter, v5.rotation, v5.translationFromCenter);
    return e.fromTranslation(v5.translation, Z.params.translation), e.mul(Y, v5.translation, Y), Y;
  }
}
var fA = j.MappedStatic("matrix", {
  matrix: j.Group({
    data: j.Mat4(e.identity()),
    transpose: j.Boolean(!1)
  }, { isFlat: !0 }),
  components: j.Group({
    translation: j.Vec3(M.create(0, 0, 0)),
    axis: j.Vec3(M.create(1, 0, 0)),
    angle: j.Numeric(0, { min: -360, max: 360, step: 1 }, { description: "Angle in Degrees" }),
    rotationCenter: j.MappedStatic("point", {
      point: j.Group({ point: j.Vec3(M.create(0, 0, 0)) }, { isFlat: !0 }),
      centroid: j.Group({})
    })
  }, { isFlat: !0 })
}, { label: "Kind" });

// node_modules/molstar/lib/mol-plugin-state/transforms/model.js
var vW1 = B2.BuiltIn({
  name: "coordinates-from-dcd",
  display: { name: "Parse DCD", description: "Parse DCD binary data." },
  from: [D0.Data.Binary],
  to: D0.Molecule.Coordinates
})({
  apply({ a: Z }) {
    return n0.create("Parse DCD", async (J) => {
      let $ = await L40(Z.data).runInContext(J);
      if ($.isError)
        throw new Error($.message);
      let X = await i40($.result).runInContext(J);
      return new D0.Molecule.Coordinates(X, { label: Z.label, description: "Coordinates" });
    });
  }
}), SW1 = B2.BuiltIn({
  name: "coordinates-from-xtc",
  display: { name: "Parse XTC", description: "Parse XTC binary data." },
  from: [D0.Data.Binary],
  to: D0.Molecule.Coordinates
})({
  apply({ a: Z }) {
    return n0.create("Parse XTC", async (J) => {
      let $ = await sD0(Z.data).runInContext(J);
      if ($.isError)
        throw new Error($.message);
      let X = await aD0($.result).runInContext(J);
      return new D0.Molecule.Coordinates(X, { label: Z.label, description: "Coordinates" });
    });
  }
}), fW1 = B2.BuiltIn({
  name: "coordinates-from-trr",
  display: { name: "Parse TRR", description: "Parse TRR binary data." },
  from: [D0.Data.Binary],
  to: D0.Molecule.Coordinates
})({
  apply({ a: Z }) {
    return n0.create("Parse TRR", async (J) => {
      let $ = await UM0(Z.data).runInContext(J);
      if ($.isError)
        throw new Error($.message);
      let X = await LM0($.result).runInContext(J);
      return new D0.Molecule.Coordinates(X, { label: Z.label, description: "Coordinates" });
    });
  }
}), hW1 = B2.BuiltIn({
  name: "coordinates-from-nctraj",
  display: { name: "Parse NCTRAJ", description: "Parse NCTRAJ binary data." },
  from: [D0.Data.Binary],
  to: D0.Molecule.Coordinates
})({
  apply({ a: Z }) {
    return n0.create("Parse NCTRAJ", async (J) => {
      let $ = await MM0(Z.data).runInContext(J);
      if ($.isError)
        throw new Error($.message);
      let X = await AM0($.result).runInContext(J);
      return new D0.Molecule.Coordinates(X, { label: Z.label, description: "Coordinates" });
    });
  }
}), bW1 = B2.BuiltIn({
  name: "coordinates-from-lammpstraj",
  display: { name: "Parse LAMMPSTRAJ", description: "Parse LAMMPSTRAJ data." },
  from: [D0.Data.String],
  to: D0.Molecule.Coordinates
})({
  apply({ a: Z }) {
    return n0.create("Parse LAMMPSTRAJ", async (J) => {
      let $ = await sr(Z.data).runInContext(J);
      if ($.isError)
        throw new Error($.message);
      let X = await rr($.result).runInContext(J);
      return new D0.Molecule.Coordinates(X, { label: Z.label, description: "Coordinates" });
    });
  }
}), xW1 = B2.BuiltIn({
  name: "topology-from-psf",
  display: { name: "PSF Topology", description: "Create topology from PSF." },
  from: [D0.Format.Psf],
  to: D0.Molecule.Topology
})({
  apply({ a: Z }) {
    return n0.create("Create Topology", async (J) => {
      let $ = await FD0(Z.data).runInContext(J);
      return new D0.Molecule.Topology($, { label: $.label || Z.label, description: "Topology" });
    });
  }
}), yW1 = B2.BuiltIn({
  name: "topology-from-prmtop",
  display: { name: "PRMTOP Topology", description: "Create topology from PRMTOP." },
  from: [D0.Format.Prmtop],
  to: D0.Molecule.Topology
})({
  apply({ a: Z }) {
    return n0.create("Create Topology", async (J) => {
      let $ = await BM0(Z.data).runInContext(J);
      return new D0.Molecule.Topology($, { label: $.label || Z.label, description: "Topology" });
    });
  }
}), gW1 = B2.BuiltIn({
  name: "topology-from-top",
  display: { name: "TOP Topology", description: "Create topology from TOP." },
  from: [D0.Format.Top],
  to: D0.Molecule.Topology
})({
  apply({ a: Z }) {
    return n0.create("Create Topology", async (J) => {
      let $ = await wM0(Z.data).runInContext(J);
      return new D0.Molecule.Topology($, { label: $.label || Z.label, description: "Topology" });
    });
  }
});
async function _M0(Z, J, $) {
  if (J.type === D0.Molecule.Topology.type) {
    let X = J.data;
    return await O2.trajectoryFromTopologyAndCoordinates(X, $).runInContext(Z);
  } else if (J.type === D0.Molecule.Model.type) {
    let X = J.data;
    return O2.trajectoryFromModelAndCoordinates(X, $);
  }
  throw new Error("no model/topology found");
}
var kb = B2.BuiltIn({
  name: "trajectory-from-model-and-coordinates",
  display: { name: "Trajectory from Topology & Coordinates", description: "Create a trajectory from existing model/topology and coordinates." },
  from: D0.Root,
  to: D0.Molecule.Trajectory,
  params: {
    modelRef: j.Text("", { isHidden: !0 }),
    coordinatesRef: j.Text("", { isHidden: !0 })
  }
})({
  apply({ params: Z, dependencies: J }) {
    return n0.create("Create trajectory from model/topology and coordinates", async ($) => {
      let X = J[Z.coordinatesRef].data, Y = await _M0($, J[Z.modelRef], X), Q = { label: "Trajectory", description: `${Y.frameCount} model${Y.frameCount === 1 ? "" : "s"}` };
      return new D0.Molecule.Trajectory(Y, Q);
    });
  }
}), mW1 = B2.BuiltIn({
  name: "trajectory-from-blob",
  display: { name: "Parse Blob", description: "Parse format blob into a single trajectory." },
  from: D0.Format.Blob,
  to: D0.Molecule.Trajectory
})({
  apply({ a: Z }) {
    return n0.create("Parse Format Blob", async (J) => {
      let $ = [];
      for (let Y of Z.data) {
        if (Y.kind !== "cif")
          continue;
        let Q = Y.data.blocks[0], W = await Lh(Q).runInContext(J);
        if (W.frameCount === 0)
          throw new Error("No models found.");
        for (let K = 0;K < W.frameCount; K++) {
          let G = await n0.resolveInContext(W.getFrameAtIndex(K), J);
          $.push(G);
        }
      }
      for (let Y = 0;Y < $.length; Y++)
        O2.TrajectoryInfo.set($[Y], { index: Y, size: $.length });
      let X = { label: "Trajectory", description: `${$.length} model${$.length === 1 ? "" : "s"}` };
      return new D0.Molecule.Trajectory(new UY($), X);
    });
  }
});
function MH(Z) {
  return { label: `${Z.representative.entry}`, description: `${Z.frameCount} model${Z.frameCount === 1 ? "" : "s"}` };
}
var dW1 = B2.BuiltIn({
  name: "trajectory-from-mmcif",
  display: { name: "Trajectory from mmCIF", description: "Identify and create all separate models in the specified CIF data block" },
  from: D0.Format.Cif,
  to: D0.Molecule.Trajectory,
  params(Z) {
    if (!Z)
      return {
        loadAllBlocks: j.Optional(j.Boolean(!1, { description: "If True, ignore Block Header and Block Index parameters and parse all datablocks into a single trajectory." })),
        blockHeader: j.Optional(j.Text(void 0, { description: "Header of the block to parse. If not specifed, Block Index parameter applies.", hideIf: (X) => X.loadAllBlocks === !0 })),
        blockIndex: j.Optional(j.Numeric(0, { min: 0, step: 1 }, { description: "Zero-based index of the block to parse. Only applies when Block Header parameter is not specified.", hideIf: (X) => X.loadAllBlocks === !0 || X.blockHeader }))
      };
    let { blocks: J } = Z.data, $ = J.map((X) => [X.header, X.header]);
    return $.push(["", "[Use Block Index]"]), {
      loadAllBlocks: j.Optional(j.Boolean(!1, { description: "If True, ignore Block Header and Block Index parameters and parse all data blocks into a single trajectory." })),
      blockHeader: j.Optional(j.Select(J[0] && J[0].header, $, { description: "Header of the block to parse. If not specifed, Block Index parameter applies.", hideIf: (X) => X.loadAllBlocks === !0 })),
      blockIndex: j.Optional(j.Numeric(0, { min: 0, step: 1, max: J.length - 1 }, { description: "Zero-based index of the block to parse. Only applies when Block Header parameter is not specified.", hideIf: (X) => X.loadAllBlocks === !0 || X.blockHeader }))
    };
  }
})({
  isApplicable: (Z) => Z.data.blocks.length > 0,
  apply({ a: Z, params: J }) {
    return n0.create("Parse mmCIF", async ($) => {
      var X;
      let Y;
      if (J.loadAllBlocks) {
        let W = [];
        for (let K of Z.data.blocks) {
          if ($.shouldUpdate)
            await $.update(`Parsing ${K.header}...`);
          let G = await Lh(K).runInContext($);
          for (let H = 0;H < G.frameCount; H++)
            W.push(await n0.resolveInContext(G.getFrameAtIndex(H), $));
        }
        Y = new UY(W);
      } else {
        let W = J.blockHeader || Z.data.blocks[(X = J.blockIndex) !== null && X !== void 0 ? X : 0].header, K = Z.data.blocks.find((H) => H.header === W);
        if (!K)
          throw new Error(`Data block '${[W]}' not found.`);
        Y = K.categoryNames.includes("chem_comp_atom") && !K.categoryNames.includes("atom_site") && !K.categoryNames.includes("ihm_sphere_obj_site") && !K.categoryNames.includes("ihm_gaussian_obj_site") ? await IF0(K).runInContext($) : await Lh(K, Z.data).runInContext($);
      }
      if (Y.frameCount === 0)
        throw new Error("No models found.");
      let Q = MH(Y);
      return new D0.Molecule.Trajectory(Y, Q);
    });
  }
}), pW1 = B2.BuiltIn({
  name: "trajectory-from-pdb",
  display: { name: "Parse PDB", description: "Parse PDB string and create trajectory." },
  from: [D0.Data.String],
  to: D0.Molecule.Trajectory,
  params: {
    isPdbqt: j.Boolean(!1)
  }
})({
  apply({ a: Z, params: J }) {
    return n0.create("Parse PDB", async ($) => {
      let X = await O40(Z.data, Z.label, J.isPdbqt).runInContext($);
      if (X.isError)
        throw new Error(X.message);
      let Y = await qD0(X.result).runInContext($), Q = MH(Y);
      return new D0.Molecule.Trajectory(Y, Q);
    });
  }
}), uW1 = B2.BuiltIn({
  name: "trajectory-from-gro",
  display: { name: "Parse GRO", description: "Parse GRO string and create trajectory." },
  from: [D0.Data.String],
  to: D0.Molecule.Trajectory
})({
  apply({ a: Z }) {
    return n0.create("Parse GRO", async (J) => {
      let $ = await E40(Z.data).runInContext(J);
      if ($.isError)
        throw new Error($.message);
      let X = await o40($.result).runInContext(J), Y = MH(X);
      return new D0.Molecule.Trajectory(X, Y);
    });
  }
}), cW1 = B2.BuiltIn({
  name: "trajectory-from-xyz",
  display: { name: "Parse XYZ", description: "Parse XYZ string and create trajectory." },
  from: [D0.Data.String],
  to: D0.Molecule.Trajectory
})({
  apply({ a: Z }) {
    return n0.create("Parse XYZ", async (J) => {
      let $ = await rD0(Z.data).runInContext(J);
      if ($.isError)
        throw new Error($.message);
      let X = await tD0($.result).runInContext(J), Y = MH(X);
      return new D0.Molecule.Trajectory(X, Y);
    });
  }
}), lW1 = B2.BuiltIn({
  name: "trajectory-from-lammps-data",
  display: { name: "Parse Lammps Data", description: "Parse Lammps Data from string and create trajectory." },
  from: [D0.Data.String],
  to: D0.Molecule.Trajectory,
  params: {
    unitsStyle: j.Select("real", j.arrayToOptions(nr))
  }
})({
  apply({ a: Z, params: J }) {
    return n0.create("Parse Lammps Data", async ($) => {
      let X = await XM0(Z.data).runInContext($);
      if (X.isError)
        throw new Error(X.message);
      let Y = await YM0(X.result, J.unitsStyle).runInContext($), Q = MH(Y);
      return new D0.Molecule.Trajectory(Y, Q);
    });
  }
}), nW1 = B2.BuiltIn({
  name: "trajectory-from-lammps-traj-data",
  display: { name: "Parse Lammps traj Data", description: "Parse Lammps Traj Data string and create trajectory." },
  from: [D0.Data.String],
  to: D0.Molecule.Trajectory,
  params: {
    unitsStyle: j.Select("real", j.arrayToOptions(nr))
  }
})({
  apply({ a: Z, params: J }) {
    return n0.create("Parse Lammps Data", async ($) => {
      let X = await sr(Z.data).runInContext($);
      if (X.isError)
        throw new Error(X.message);
      let Y = await WM0(X.result, J.unitsStyle).runInContext($), Q = MH(Y);
      return new D0.Molecule.Trajectory(Y, Q);
    });
  }
}), iW1 = B2.BuiltIn({
  name: "trajectory-from-mol",
  display: { name: "Parse MOL", description: "Parse MOL string and create trajectory." },
  from: [D0.Data.String],
  to: D0.Molecule.Trajectory
})({
  apply({ a: Z }) {
    return n0.create("Parse MOL", async (J) => {
      let $ = await dD0(Z.data).runInContext(J);
      if ($.isError)
        throw new Error($.message);
      let X = await pD0($.result).runInContext(J), Y = MH(X);
      return new D0.Molecule.Trajectory(X, Y);
    });
  }
}), oW1 = B2.BuiltIn({
  name: "trajectory-from-sdf",
  display: { name: "Parse SDF", description: "Parse SDF string and create trajectory." },
  from: [D0.Data.String],
  to: D0.Molecule.Trajectory
})({
  apply({ a: Z }) {
    return n0.create("Parse SDF", async (J) => {
      let $ = await qM0(Z.data).runInContext(J);
      if ($.isError)
        throw new Error($.message);
      let X = [];
      for (let W of $.result.compounds) {
        let K = await FM0(W).runInContext(J);
        for (let G = 0;G < K.frameCount; G++)
          X.push(await n0.resolveInContext(K.getFrameAtIndex(G), J));
      }
      let Y = new UY(X), Q = MH(Y);
      return new D0.Molecule.Trajectory(Y, Q);
    });
  }
}), sW1 = B2.BuiltIn({
  name: "trajectory-from-mol2",
  display: { name: "Parse MOL2", description: "Parse MOL2 string and create trajectory." },
  from: [D0.Data.String],
  to: D0.Molecule.Trajectory
})({
  apply({ a: Z }) {
    return n0.create("Parse MOL2", async (J) => {
      let $ = await iD0(Z.data, Z.label).runInContext(J);
      if ($.isError)
        throw new Error($.message);
      let X = await oD0($.result).runInContext(J), Y = MH(X);
      return new D0.Molecule.Trajectory(X, Y);
    });
  }
}), aW1 = B2.BuiltIn({
  name: "trajectory-from-cube",
  display: { name: "Parse Cube", description: "Parse Cube file to create a trajectory." },
  from: D0.Format.Cube,
  to: D0.Molecule.Trajectory
})({
  apply({ a: Z }) {
    return n0.create("Parse MOL", async (J) => {
      let $ = await cD0(Z.data).runInContext(J), X = MH($);
      return new D0.Molecule.Trajectory($, X);
    });
  }
}), rW1 = B2.BuiltIn({
  name: "trajectory-from-cif-core",
  display: { name: "Parse CIF Core", description: "Identify and create all separate models in the specified CIF data block" },
  from: D0.Format.Cif,
  to: D0.Molecule.Trajectory,
  params(Z) {
    if (!Z)
      return {
        blockHeader: j.Optional(j.Text(void 0, { description: "Header of the block to parse. If none is specifed, the 1st data block in the file is used." }))
      };
    let { blocks: J } = Z.data;
    return {
      blockHeader: j.Optional(j.Select(J[0] && J[0].header, J.map(($) => [$.header, $.header]), { description: "Header of the block to parse" }))
    };
  }
})({
  apply({ a: Z, params: J }) {
    return n0.create("Parse CIF Core", async ($) => {
      let X = J.blockHeader || Z.data.blocks[0].header, Y = Z.data.blocks.find((K) => K.header === X);
      if (!Y)
        throw new Error(`Data block '${[X]}' not found.`);
      let Q = await uD0(Y).runInContext($);
      if (Q.frameCount === 0)
        throw new Error("No models found.");
      let W = MH(Q);
      return new D0.Molecule.Trajectory(Q, W);
    });
  }
}), tW1 = (Z) => Z + 1, eW1 = (Z) => Z - 1, Ut = B2.BuiltIn({
  name: "model-from-trajectory",
  display: { name: "Molecular Model", description: "Create a molecular model from specified index in a trajectory." },
  from: D0.Molecule.Trajectory,
  to: D0.Molecule.Model,
  params: (Z) => {
    if (!Z)
      return { modelIndex: j.Numeric(0, {}, { description: "Zero-based index of the model", immediateUpdate: !0 }) };
    return { modelIndex: j.Converted(tW1, eW1, j.Numeric(1, { min: 1, max: Z.data.frameCount, step: 1 }, { description: "Model Index", immediateUpdate: !0 })) };
  }
})({
  isApplicable: (Z) => Z.data.frameCount > 0,
  apply({ a: Z, params: J }) {
    return n0.create("Model from Trajectory", async ($) => {
      let X = Math.round(J.modelIndex) % Z.data.frameCount;
      if (X < 0)
        X += Z.data.frameCount;
      let Y = await n0.resolveInContext(Z.data.getFrameAtIndex(X), $), Q = `Model ${X + 1}`, W = Z.data.frameCount === 1 ? void 0 : `of ${Z.data.frameCount}`;
      return new D0.Molecule.Model(Y, { label: Q, description: W });
    });
  },
  interpolate(Z, J, $) {
    return { modelIndex: $ >= 1 ? J.modelIndex : Z.modelIndex + Math.floor((J.modelIndex - Z.modelIndex + 1) * $) };
  },
  dispose({ b: Z }) {
    Z === null || Z === void 0 || Z.data.customProperties.dispose();
  }
}), Z51 = B2.BuiltIn({
  name: "structure-from-trajectory",
  display: { name: "Structure from Trajectory", description: "Create a molecular structure from a trajectory." },
  from: D0.Molecule.Trajectory,
  to: D0.Molecule.Structure
})({
  apply({ a: Z }) {
    return n0.create("Build Structure", async (J) => {
      let $ = await s0.ofTrajectory(Z.data, J), X = { label: "Ensemble", description: s0.elementDescription($) };
      return new D0.Molecule.Structure($, X);
    });
  },
  dispose({ b: Z }) {
    Z === null || Z === void 0 || Z.data.customPropertyDescriptors.dispose();
  }
}), J51 = B2.BuiltIn({
  name: "structure-from-model",
  display: { name: "Structure", description: "Create a molecular structure (model, assembly, or symmetry) from the specified model." },
  from: D0.Molecule.Model,
  to: D0.Molecule.Structure,
  params(Z) {
    return Nq.getParams(Z && Z.data);
  }
})({
  canAutoUpdate({ oldParams: Z, newParams: J }) {
    return Nq.canAutoUpdate(Z.type, J.type);
  },
  apply({ a: Z, params: J }, $) {
    return n0.create("Build Structure", async (X) => {
      return Nq.create($, X, Z.data, J && J.type);
    });
  },
  update: ({ a: Z, b: J, oldParams: $, newParams: X }) => {
    if (!QY($, X))
      return T1.UpdateResult.Recreate;
    if (J.data.model === Z.data)
      return T1.UpdateResult.Unchanged;
    if (!O2.areHierarchiesEqual(Z.data, J.data.model))
      return T1.UpdateResult.Recreate;
    return J.data = J.data.remapModel(Z.data), T1.UpdateResult.Updated;
  },
  dispose({ b: Z }) {
    Z === null || Z === void 0 || Z.data.customPropertyDescriptors.dispose();
  }
}), $51 = B2.BuiltIn({
  name: "transform-structure-conformation",
  display: { name: "Transform Conformation" },
  isDecorator: !0,
  from: D0.Molecule.Structure,
  to: D0.Molecule.Structure,
  params: {
    transform: fA
  }
})({
  canAutoUpdate({ newParams: Z }) {
    return Z.transform.name !== "matrix";
  },
  apply({ a: Z, params: J }) {
    let $ = vA(J.transform) ? Z.data.boundary.sphere.center : M.unit, X = SA(J.transform, $), Y = s0.transform(Z.data, X);
    return new D0.Molecule.Structure(Y, { label: Z.label, description: `${Z.description} [Transformed]` });
  },
  dispose({ b: Z }) {
    Z === null || Z === void 0 || Z.data.customPropertyDescriptors.dispose();
  }
}), X51 = B2.BuiltIn({
  name: "structure-instances",
  display: { name: "Structure Instances" },
  isDecorator: !0,
  from: D0.Molecule.Structure,
  to: D0.Molecule.Structure,
  params: {
    transforms: j.ObjectList({ transform: fA }, () => "Transform")
  }
})({
  canAutoUpdate() {
    return !0;
  },
  apply({ a: Z, params: J }) {
    let $ = J.transforms.some((Q) => vA(Q.transform)) ? Z.data.boundary.sphere.center : M.unit, X = J.transforms.map((Q) => SA(Q.transform, $));
    if (!X.length)
      return Z;
    let Y = s0.instances(Z.data, X);
    return new D0.Molecule.Structure(Y, { label: Z.label, description: `${Z.description} [Instanced]` });
  },
  dispose({ b: Z }) {
    Z === null || Z === void 0 || Z.data.customPropertyDescriptors.dispose();
  }
}), Y51 = B2.BuiltIn({
  name: "model-with-coordinates",
  display: { name: "Model With Coordinates", description: "Updates the current model with provided coordinate frame" },
  from: D0.Molecule.Model,
  to: D0.Molecule.Model,
  params: {
    frameIndex: j.Optional(j.Numeric(0, void 0, { isHidden: !0 })),
    frameCount: j.Optional(j.Numeric(1, void 0, { isHidden: !0 })),
    atomicCoordinateFrame: j.Optional(j.Value(void 0, { isHidden: !0 }))
  },
  isDecorator: !0
})({
  apply({ a: Z, params: J }) {
    var $, X;
    if (!J.atomicCoordinateFrame)
      return Z;
    let Y = { ...Z.data, atomicConformation: O2.getAtomicConformationFromFrame(Z.data, J.atomicCoordinateFrame) };
    return O2.TrajectoryInfo.set(Y, { index: ($ = J.frameIndex) !== null && $ !== void 0 ? $ : 0, size: (X = J.frameCount) !== null && X !== void 0 ? X : 1 }), new D0.Molecule.Model(Y, { label: Z.label, description: Z.description });
  },
  update: ({ a: Z, b: J, oldParams: $, newParams: X }) => {
    var Y, Q;
    if ($.atomicCoordinateFrame === X.atomicCoordinateFrame)
      return T1.UpdateResult.Unchanged;
    if (!X.atomicCoordinateFrame)
      J.data = Z.data;
    else
      J.data = { ...J.data, atomicConformation: O2.getAtomicConformationFromFrame(J.data, X.atomicCoordinateFrame) };
    return O2.TrajectoryInfo.set(J.data, { index: (Y = X.frameIndex) !== null && Y !== void 0 ? Y : 0, size: (Q = X.frameCount) !== null && Q !== void 0 ? Q : 1 }), T1.UpdateResult.Updated;
  }
}), Q51 = B2.BuiltIn({
  name: "structure-selection-from-expression",
  display: { name: "Selection", description: "Create a molecular structure from the specified expression." },
  from: D0.Molecule.Structure,
  to: D0.Molecule.Structure,
  params: () => ({
    expression: j.Value(L0.struct.generator.all, { isHidden: !0 }),
    label: j.Optional(j.Text("", { isHidden: !0 }))
  })
})({
  apply({ a: Z, params: J, cache: $ }) {
    let { selection: X, entry: Y } = CY.createAndRun(Z.data, J.expression);
    if ($.entry = Y, f1.isEmpty(X))
      return LZ.Null;
    let Q = f1.unionStructure(X), W = { label: `${J.label || "Selection"}`, description: s0.elementDescription(Q) };
    return new D0.Molecule.Structure(Q, W);
  },
  update: ({ a: Z, b: J, oldParams: $, newParams: X, cache: Y }) => {
    if ($.expression !== X.expression)
      return T1.UpdateResult.Recreate;
    let Q = Y.entry;
    if (Q.currentStructure === Z.data)
      return T1.UpdateResult.Unchanged;
    let W = CY.updateStructure(Q, Z.data);
    if (f1.isEmpty(W))
      return T1.UpdateResult.Null;
    return CY.updateStructureObject(J, W, X.label), T1.UpdateResult.Updated;
  },
  dispose({ b: Z }) {
    Z === null || Z === void 0 || Z.data.customPropertyDescriptors.dispose();
  }
}), W51 = B2.BuiltIn({
  name: "structure-multi-selection-from-expression",
  display: { name: "Multi-structure Measurement Selection", description: "Create selection object from multiple structures." },
  from: D0.Root,
  to: D0.Molecule.Structure.Selections,
  params: () => ({
    selections: j.ObjectList({
      key: j.Text(void 0, { description: "A unique key." }),
      ref: j.Text(),
      groupId: j.Optional(j.Text()),
      expression: j.Value(L0.struct.generator.empty)
    }, (Z) => Z.ref, { isHidden: !0 }),
    isTransitive: j.Optional(j.Boolean(!1, { isHidden: !0, description: "Remap the selections from the original structure if structurally equivalent." })),
    label: j.Optional(j.Text("", { isHidden: !0 }))
  })
})({
  apply({ params: Z, cache: J, dependencies: $ }) {
    let X = /* @__PURE__ */ new Map, Y = [], Q = 0;
    for (let K of Z.selections) {
      let { selection: G, entry: H } = CY.createAndRun($[K.ref].data, K.expression);
      X.set(K.key, H);
      let N = f1.toLociWithSourceUnits(G);
      Y.push({ key: K.key, structureRef: K.ref, loci: N, groupId: K.groupId }), Q += W0.Loci.size(N);
    }
    J.entries = X;
    let W = { label: `${Z.label || "Multi-selection"}`, description: `${Z.selections.length} source(s), ${Q} element(s) total` };
    return new D0.Molecule.Structure.Selections(Y, W);
  },
  update: ({ b: Z, oldParams: J, newParams: $, cache: X, dependencies: Y }) => {
    if (!!J.isTransitive !== !!$.isTransitive)
      return T1.UpdateResult.Recreate;
    let Q = X.entries, W = /* @__PURE__ */ new Map, K = /* @__PURE__ */ new Map;
    for (let q of Z.data)
      K.set(q.key, q);
    let G = !1, H = 0, N = [];
    for (let q of $.selections) {
      let U = Y[q.ref].data, F = !1;
      if (Q.has(q.key)) {
        let E = Q.get(q.key);
        if (CY.isUnchanged(E, q.expression, U) && K.has(q.key)) {
          let R = K.get(q.key);
          if (R.groupId !== q.groupId)
            R.groupId = q.groupId, G = !0;
          W.set(q.key, E), N.push(R), H += W0.Loci.size(R.loci);
          continue;
        }
        if (E.expression !== q.expression)
          F = !0;
        else {
          let R = !1;
          if ($.isTransitive)
            if (s0.areUnitIdsAndIndicesEqual(E.originalStructure, U)) {
              let z = CY.run(E, E.originalStructure);
              E.currentStructure = U, W.set(q.key, E);
              let D = W0.Loci.remap(f1.toLociWithSourceUnits(z), U);
              N.push({ key: q.key, structureRef: q.ref, loci: D, groupId: q.groupId }), H += W0.Loci.size(D), G = !0;
            } else
              R = !0;
          else
            R = !0;
          if (R) {
            G = !0;
            let z = CY.updateStructure(E, U);
            W.set(q.key, E);
            let D = f1.toLociWithSourceUnits(z);
            N.push({ key: q.key, structureRef: q.ref, loci: D, groupId: q.groupId }), H += W0.Loci.size(D);
          }
        }
      } else
        F = !0;
      if (F) {
        G = !0;
        let { selection: E, entry: R } = CY.createAndRun(U, q.expression);
        W.set(q.key, R);
        let z = f1.toLociWithSourceUnits(E);
        N.push({ key: q.key, structureRef: q.ref, loci: z, groupId: q.groupId }), H += W0.Loci.size(z);
      }
    }
    if (!G)
      return T1.UpdateResult.Unchanged;
    return X.entries = W, Z.data = N, Z.label = `${$.label || "Multi-selection"}`, Z.description = `${N.length} source(s), ${H} element(s) total`, T1.UpdateResult.Updated;
  }
}), K51 = B2.BuiltIn({
  name: "structure-multi-selection-from-bundle",
  display: { name: "Multi-structure Measurement Selection", description: "Create selection object from multiple structures." },
  from: D0.Root,
  to: D0.Molecule.Structure.Selections,
  params: () => ({
    selections: j.ObjectList({
      key: j.Text(void 0, { description: "A unique key." }),
      ref: j.Text(),
      groupId: j.Optional(j.Text()),
      bundle: j.Value(W0.Bundle.Empty)
    }, (Z) => Z.ref, { isHidden: !0 }),
    isTransitive: j.Optional(j.Boolean(!1, { isHidden: !0, description: "Remap the selections from the original structure if structurally equivalent." })),
    label: j.Optional(j.Text("", { isHidden: !0 }))
  })
})({
  apply({ params: Z, cache: J, dependencies: $ }) {
    let X = /* @__PURE__ */ new Map, Y = [], Q = 0;
    for (let K of Z.selections) {
      let G = $[K.ref].data, H = W0.Bundle.toLoci(K.bundle, G);
      Y.push({ key: K.key, structureRef: K.ref, loci: H, groupId: K.groupId }), Q += W0.Loci.size(H), X.set(K.key, { source: G });
    }
    J.entries = X;
    let W = { label: `${Z.label || "Multi-selection"}`, description: `${Z.selections.length} source(s), ${Q} element(s) total` };
    return new D0.Molecule.Structure.Selections(Y, W);
  },
  update: ({ b: Z, oldParams: J, newParams: $, cache: X, dependencies: Y }) => {
    if (!!J.isTransitive !== !!$.isTransitive)
      return T1.UpdateResult.Recreate;
    let Q = X.entries, W = /* @__PURE__ */ new Map, K = /* @__PURE__ */ new Map;
    for (let U of J.selections)
      K.set(U.key, U.bundle);
    let G = /* @__PURE__ */ new Map;
    for (let U of Z.data)
      G.set(U.key, U);
    let H = !1, N = 0, q = [];
    for (let U of $.selections) {
      let F = !1;
      if (Q.has(U.key)) {
        let E = Y[U.ref].data, R = Q.get(U.key), z = K.get(U.key);
        if (z && E === R.source && U.bundle.hash === R.source.hashCode && W0.Bundle.areEqual(U.bundle, z)) {
          let D = G.get(U.key);
          if (D.groupId !== U.groupId)
            D.groupId = U.groupId, H = !0;
          W.set(U.key, R), q.push(D), N += W0.Loci.size(D.loci);
          continue;
        }
        F = !0;
      } else
        F = !0;
      if (F) {
        H = !0;
        let E = Y[U.ref].data, R = W0.Bundle.toLoci(U.bundle, E);
        q.push({ key: U.key, structureRef: U.ref, loci: R, groupId: U.groupId }), N += W0.Loci.size(R), W.set(U.key, { source: E });
      }
    }
    if (!H)
      return T1.UpdateResult.Unchanged;
    return X.entries = W, Z.data = q, Z.label = `${$.label || "Multi-selection"}`, Z.description = `${q.length} source(s), ${N} element(s) total`, T1.UpdateResult.Updated;
  }
}), G51 = B2.BuiltIn({
  name: "structure-selection-from-script",
  display: { name: "Selection", description: "Create a molecular structure from the specified script." },
  from: D0.Molecule.Structure,
  to: D0.Molecule.Structure,
  params: () => ({
    script: j.Script({ language: "mol-script", expression: "(sel.atom.atom-groups :residue-test (= atom.resname ALA))" }),
    label: j.Optional(j.Text(""))
  })
})({
  apply({ a: Z, params: J, cache: $ }) {
    let { selection: X, entry: Y } = CY.createAndRun(Z.data, J.script);
    $.entry = Y;
    let Q = f1.unionStructure(X), W = { label: `${J.label || "Selection"}`, description: s0.elementDescription(Q) };
    return new D0.Molecule.Structure(Q, W);
  },
  update: ({ a: Z, b: J, oldParams: $, newParams: X, cache: Y }) => {
    if (!cZ.areEqual($.script, X.script))
      return T1.UpdateResult.Recreate;
    let Q = Y.entry;
    if (Q.currentStructure === Z.data)
      return T1.UpdateResult.Unchanged;
    let W = CY.updateStructure(Q, Z.data);
    return CY.updateStructureObject(J, W, X.label), T1.UpdateResult.Updated;
  },
  dispose({ b: Z }) {
    Z === null || Z === void 0 || Z.data.customPropertyDescriptors.dispose();
  }
}), H51 = B2.BuiltIn({
  name: "structure-selection-from-bundle",
  display: { name: "Selection", description: "Create a molecular structure from the specified structure-element bundle." },
  from: D0.Molecule.Structure,
  to: D0.Molecule.Structure,
  params: () => ({
    bundle: j.Value(W0.Bundle.Empty, { isHidden: !0 }),
    label: j.Optional(j.Text("", { isHidden: !0 }))
  })
})({
  apply({ a: Z, params: J, cache: $ }) {
    if (J.bundle.hash !== Z.data.hashCode)
      return LZ.Null;
    $.source = Z.data;
    let X = W0.Bundle.toStructure(J.bundle, Z.data);
    if (X.elementCount === 0)
      return LZ.Null;
    let Y = { label: `${J.label || "Selection"}`, description: s0.elementDescription(X) };
    return new D0.Molecule.Structure(X, Y);
  },
  update: ({ a: Z, b: J, oldParams: $, newParams: X, cache: Y }) => {
    if (!W0.Bundle.areEqual($.bundle, X.bundle))
      return T1.UpdateResult.Recreate;
    if (X.bundle.hash !== Z.data.hashCode)
      return T1.UpdateResult.Null;
    if (Y.source === Z.data)
      return T1.UpdateResult.Unchanged;
    Y.source = Z.data;
    let Q = W0.Bundle.toStructure(X.bundle, Z.data);
    if (Q.elementCount === 0)
      return T1.UpdateResult.Null;
    return J.label = `${X.label || "Selection"}`, J.description = s0.elementDescription(Q), J.data = Q, T1.UpdateResult.Updated;
  },
  dispose({ b: Z }) {
    Z === null || Z === void 0 || Z.data.customPropertyDescriptors.dispose();
  }
}), VM0 = {
  polymer: "polymer",
  protein: "protein",
  nucleic: "nucleic",
  water: "water",
  branched: "branched",
  ligand: "ligand",
  "non-standard": "non-standard",
  coarse: "coarse",
  "atomic-sequence": "atomic-sequence",
  "atomic-het": "atomic-het",
  spheres: "spheres"
}, N51 = j.objectToOptions(VM0), q51 = B2.BuiltIn({
  name: "structure-complex-element",
  display: { name: "Complex Element", description: "Create a molecular structure from the specified model." },
  from: D0.Molecule.Structure,
  to: D0.Molecule.Structure,
  params: { type: j.Select("atomic-sequence", N51, { isHidden: !0 }) }
})({
  apply({ a: Z, params: J }) {
    let $, X;
    switch (J.type) {
      case "polymer":
        $ = u9.polymer.query, X = "Polymer";
        break;
      case "protein":
        $ = u9.protein.query, X = "Protein";
        break;
      case "nucleic":
        $ = u9.nucleic.query, X = "Nucleic";
        break;
      case "water":
        $ = OZ.internal.water(), X = "Water";
        break;
      case "branched":
        $ = u9.branchedPlusConnected.query, X = "Branched";
        break;
      case "ligand":
        $ = u9.ligandPlusConnected.query, X = "Ligand";
        break;
      case "non-standard":
        $ = u9.nonStandardPolymer.query, X = "Non-standard";
        break;
      case "coarse":
        $ = u9.coarse.query, X = "Coarse";
        break;
      case "atomic-sequence":
        $ = OZ.internal.atomicSequence(), X = "Sequence";
        break;
      case "atomic-het":
        $ = OZ.internal.atomicHet(), X = "HET Groups/Ligands";
        break;
      case "spheres":
        $ = OZ.internal.spheres(), X = "Coarse Spheres";
        break;
      default:
        T8(J.type);
    }
    let Y = $(new C9(Z.data)), Q = f1.unionStructure(Y);
    if (Q.elementCount === 0)
      return LZ.Null;
    return new D0.Molecule.Structure(Q, { label: X, description: s0.elementDescription(Q) });
  },
  dispose({ b: Z }) {
    Z === null || Z === void 0 || Z.data.customPropertyDescriptors.dispose();
  }
}), F51 = B2.BuiltIn({
  name: "structure-component",
  display: { name: "Component", description: "A molecular structure component." },
  from: D0.Molecule.Structure,
  to: D0.Molecule.Structure,
  params: xD0
})({
  apply({ a: Z, params: J, cache: $ }) {
    return yD0(Z.data, J, $);
  },
  update: ({ a: Z, b: J, oldParams: $, newParams: X, cache: Y }) => {
    return gD0(Z.data, J, $, X, Y);
  },
  dispose({ b: Z }) {
    Z === null || Z === void 0 || Z.data.customPropertyDescriptors.dispose();
  }
}), Lt = B2.BuiltIn({
  name: "custom-model-properties",
  display: { name: "Custom Model Properties" },
  isDecorator: !0,
  from: D0.Molecule.Model,
  to: D0.Molecule.Model,
  params: (Z, J) => {
    return J.customModelProperties.getParams(Z === null || Z === void 0 ? void 0 : Z.data);
  }
})({
  apply({ a: Z, params: J }, $) {
    return n0.create("Custom Props", async (X) => {
      return await jM0(Z.data, $, X, J), new D0.Molecule.Model(Z.data, { label: Z.label, description: Z.description });
    });
  },
  update({ a: Z, b: J, oldParams: $, newParams: X }, Y) {
    return n0.create("Custom Props", async (Q) => {
      J.data = Z.data, J.label = Z.label, J.description = Z.description;
      for (let W of $.autoAttach) {
        let K = Y.customModelProperties.get(W);
        if (!K)
          continue;
        Z.data.customProperties.reference(K.descriptor, !1);
      }
      return await jM0(Z.data, Y, Q, X), T1.UpdateResult.Updated;
    });
  },
  dispose({ b: Z }) {
    Z === null || Z === void 0 || Z.data.customProperties.dispose();
  }
});
async function jM0(Z, J, $, X) {
  let Y = { runtime: $, assetManager: J.managers.asset, errorContext: J.errorContext }, { autoAttach: Q, properties: W } = X;
  for (let K of Object.keys(W)) {
    let G = J.customModelProperties.get(K), H = W[K];
    if (Q.includes(K) || G.isHidden)
      try {
        await G.attach(Y, Z, H, !0);
      } catch (N) {
        J.log.warn(`Error attaching model prop '${K}': ${N}`);
      }
    else
      G.set(Z, H);
  }
}
var Rt = B2.BuiltIn({
  name: "custom-structure-properties",
  display: { name: "Custom Structure Properties" },
  isDecorator: !0,
  from: D0.Molecule.Structure,
  to: D0.Molecule.Structure,
  params: (Z, J) => {
    return J.customStructureProperties.getParams(Z === null || Z === void 0 ? void 0 : Z.data.root);
  }
})({
  apply({ a: Z, params: J }, $) {
    return n0.create("Custom Props", async (X) => {
      return await TM0(Z.data.root, $, X, J), new D0.Molecule.Structure(Z.data, { label: Z.label, description: Z.description });
    });
  },
  update({ a: Z, b: J, oldParams: $, newParams: X }, Y) {
    if (Z.data !== J.data)
      return T1.UpdateResult.Recreate;
    return n0.create("Custom Props", async (Q) => {
      J.data = Z.data, J.label = Z.label, J.description = Z.description;
      for (let W of $.autoAttach) {
        let K = Y.customStructureProperties.get(W);
        if (!K)
          continue;
        Z.data.customPropertyDescriptors.reference(K.descriptor, !1);
      }
      return await TM0(Z.data.root, Y, Q, X), T1.UpdateResult.Updated;
    });
  },
  dispose({ b: Z }) {
    Z === null || Z === void 0 || Z.data.customPropertyDescriptors.dispose();
  }
});
async function TM0(Z, J, $, X) {
  let Y = { runtime: $, assetManager: J.managers.asset, errorContext: J.errorContext }, { autoAttach: Q, properties: W } = X;
  for (let K of Object.keys(W)) {
    let G = J.customStructureProperties.get(K), H = W[K];
    if (Q.includes(K) || G.isHidden)
      try {
        await G.attach(Y, Z, H, !0);
      } catch (N) {
        J.log.warn(`Error attaching structure prop '${K}': ${N}`);
      }
    else
      G.set(Z, H);
  }
}
var U51 = B2.BuiltIn({
  name: "shape-from-ply",
  display: { name: "Shape from PLY", description: "Create Shape from PLY data" },
  from: D0.Format.Ply,
  to: D0.Shape.Provider,
  params(Z) {
    return {
      transforms: j.Optional(j.Value([], { isHidden: !0 })),
      label: j.Optional(j.Text("", { isHidden: !0 }))
    };
  }
})({
  apply({ a: Z, params: J }) {
    return n0.create("Create shape from PLY", async ($) => {
      let X = await n40(Z.data, J).runInContext($), Y = { label: J.label || "Shape" };
      return new D0.Shape.Provider(X, Y);
    });
  }
});

// node_modules/molstar/lib/mol-plugin-state/transforms/volume.js
var At = {};
y9(At, {
  VolumeTransform: () => w51,
  VolumeInstances: () => j51,
  VolumeFromSegmentationCif: () => A51,
  VolumeFromDx: () => D51,
  VolumeFromDsn6: () => O51,
  VolumeFromDensityServerCif: () => M51,
  VolumeFromCube: () => z51,
  VolumeFromCcp4: () => E51,
  AssignColorVolume: () => B51
});

// node_modules/molstar/lib/mol-model-formats/volume/ccp4.js
function L51(Z) {
  if (Z.originX === 0 && Z.originY === 0 && Z.originZ === 0)
    return M.create(Z.NCSTART, Z.NRSTART, Z.NSSTART);
  else
    return M.create(Z.originX / (Z.xLength / Z.NX), Z.originY / (Z.yLength / Z.NY), Z.originZ / (Z.zLength / Z.NZ));
}
function R51(Z) {
  let J = aa(Z);
  switch (J) {
    case mX.Float32:
      return Float32Array;
    case mX.Int8:
      return Int8Array;
    case mX.Int16:
      return Int16Array;
    case mX.Uint16:
      return Uint16Array;
  }
  throw Error(`${J} is not a supported value format.`);
}
function IM0(Z, J) {
  return n0.create("Create Volume", async ($) => {
    let { header: X, values: Y } = Z, Q = M.create(X.xLength, X.yLength, X.zLength);
    if (J && J.voxelSize)
      M.mul(Q, Q, J.voxelSize);
    let W = M.create(_8(X.alpha), _8(X.beta), _8(X.gamma)), K = X.ISPG > 65536 ? 0 : X.ISPG, G = d7.create(K || "P 1", Q, W), H = M.create(X.MAPC - 1, X.MAPR - 1, X.MAPS - 1), N = M8.convertToCanonicalAxisIndicesFastToSlow(H), q = [X.NX, X.NY, X.NZ], U = N([X.NC, X.NR, X.NS]), F = L51(X);
    if (J === null || J === void 0 ? void 0 : J.offset)
      M.add(F, F, J.offset);
    let E = N(F), R = M.create(E[0] / q[0], E[1] / q[1], E[2] / q[2]), z = M.create(U[0] / q[0], U[1] / q[1], U[2] / q[2]), D = M8.Space(U, M8.invertAxisOrder(H), R51(X)), A = M8.create(D, M8.Data1(Y)), B = X.AMIN === 0 && X.AMAX === 0 && X.AMEAN === 0 && X.ARMS === 0, T = {
      transform: { kind: "spacegroup", cell: G, fractionalBox: t1.create(R, M.add(M(), R, z)) },
      cells: A,
      stats: {
        min: Number.isNaN(X.AMIN) || B ? ZR(Y) : X.AMIN,
        max: Number.isNaN(X.AMAX) || B ? yX(Y) : X.AMAX,
        mean: Number.isNaN(X.AMEAN) || B ? JR(Y) : X.AMEAN,
        sigma: Number.isNaN(X.ARMS) || X.ARMS === 0 ? $R(Y) : X.ARMS
      }
    };
    return {
      label: J === null || J === void 0 ? void 0 : J.label,
      entryId: J === null || J === void 0 ? void 0 : J.entryId,
      periodicity: M.isInteger(z) ? "xyz" : "none",
      grid: T,
      instances: [{ transform: e.identity() }],
      sourceData: Ot.create(Z),
      customProperties: new H$,
      _propertyData: Object.create(null)
    };
  });
}
var Ot;
(function(Z) {
  function J(X) {
    return (X === null || X === void 0 ? void 0 : X.kind) === "ccp4";
  }
  Z.is = J;
  function $(X) {
    return { kind: "ccp4", name: X.name, data: X };
  }
  Z.create = $;
})(Ot || (Ot = {}));

// node_modules/molstar/lib/mol-model-formats/volume/dsn6.js
function PM0(Z, J) {
  return n0.create("Create Volume", async ($) => {
    let { header: X, values: Y } = Z, Q = M.create(X.xlen, X.ylen, X.zlen);
    if (J && J.voxelSize)
      M.mul(Q, Q, J.voxelSize);
    let W = M.create(_8(X.alpha), _8(X.beta), _8(X.gamma)), K = d7.create("P 1", Q, W), G = [X.xRate, X.yRate, X.zRate], H = [X.xExtent, X.yExtent, X.zExtent], N = [X.xStart, X.yStart, X.zStart], q = M.create(N[0] / G[0], N[1] / G[1], N[2] / G[2]), U = M.create(H[0] / G[0], H[1] / G[1], H[2] / G[2]), F = M8.Space(H, [0, 1, 2], Float32Array), E = M8.create(F, M8.Data1(Y));
    return {
      label: J === null || J === void 0 ? void 0 : J.label,
      entryId: J === null || J === void 0 ? void 0 : J.entryId,
      periodicity: M.isInteger(U) ? "xyz" : "none",
      grid: {
        transform: { kind: "spacegroup", cell: K, fractionalBox: t1.create(q, M.add(M.zero(), q, U)) },
        cells: E,
        stats: {
          min: ZR(Y),
          max: yX(Y),
          mean: JR(Y),
          sigma: X.sigma !== void 0 ? X.sigma : $R(Y)
        }
      },
      instances: [{ transform: e.identity() }],
      sourceData: zt.create(Z),
      customProperties: new H$,
      _propertyData: Object.create(null)
    };
  });
}
var zt;
(function(Z) {
  function J(X) {
    return (X === null || X === void 0 ? void 0 : X.kind) === "dsn6";
  }
  Z.is = J;
  function $(X) {
    return { kind: "dsn6", name: X.name, data: X };
  }
  Z.create = $;
})(zt || (zt = {}));

// node_modules/molstar/lib/mol-model-formats/volume/dx.js
function CM0(Z, J) {
  return n0.create("Create Volume", async () => {
    let { header: $, values: X } = Z, Y = M8.Space($.dim, [0, 1, 2], Float64Array), Q = M8.create(Y, M8.Data1(X)), W = e.fromTranslation(e(), $.min), K = e.fromScaling(e(), $.h);
    return e.mul(W, W, K), {
      label: J === null || J === void 0 ? void 0 : J.label,
      entryId: J === null || J === void 0 ? void 0 : J.entryId,
      grid: {
        transform: { kind: "matrix", matrix: W },
        cells: Q,
        stats: {
          min: ZR(X),
          max: yX(X),
          mean: JR(X),
          sigma: $R(X)
        }
      },
      instances: [{ transform: e.identity() }],
      sourceData: Dt.create(Z),
      customProperties: new H$,
      _propertyData: Object.create(null)
    };
  });
}
var Dt;
(function(Z) {
  function J(X) {
    return (X === null || X === void 0 ? void 0 : X.kind) === "dx";
  }
  Z.is = J;
  function $(X) {
    return { kind: "dx", name: X.name, data: X };
  }
  Z.create = $;
})(Dt || (Dt = {}));

// node_modules/molstar/lib/mol-model-formats/volume/segmentation.js
function kM0(Z, J) {
  return n0.create("Create Segmentation Volume", async ($) => {
    var X;
    let { volume_data_3d_info: Y, segmentation_data_3d: Q } = Z, W = d7.create(Y.spacegroup_number.value(0) || "P 1", M.ofArray(Y.spacegroup_cell_size.value(0)), M.scale(M(), M.ofArray(Y.spacegroup_cell_angles.value(0)), Math.PI / 180)), K = Y.axis_order.value(0), G = M8.convertToCanonicalAxisIndicesFastToSlow(K), H = G(Y.sample_count.value(0)), N = M8.Space(H, M8.invertAxisOrder(K), Float32Array), q = M8.create(N, M8.Data1(Q.values.toArray({ array: Float32Array }))), U = M.ofArray(G(Y.origin.value(0))), F = M.ofArray(G(Y.dimensions.value(0))), E = {
      label: J === null || J === void 0 ? void 0 : J.label,
      entryId: void 0,
      grid: {
        transform: {
          kind: "spacegroup",
          cell: W,
          fractionalBox: t1.create(U, M.add(M(), U, F))
        },
        cells: q,
        stats: {
          min: 0,
          max: 1,
          mean: 0,
          sigma: 1
        }
      },
      instances: [{ transform: e.identity() }],
      sourceData: Mt.create(Z),
      customProperties: new H$,
      _propertyData: { ownerId: J === null || J === void 0 ? void 0 : J.ownerId }
    };
    Q1.PickingGranularity.set(E, "object");
    let R = /* @__PURE__ */ new Map, z = /* @__PURE__ */ new Map, { segment_id: D, set_id: A } = Z.segmentation_data_table;
    for (let b = 0, g = D.rowCount;b < g; ++b) {
      let m = D.value(b), i = A.value(b);
      if (i === 0 || m === 0)
        continue;
      if (!z.has(i))
        z.set(i, /* @__PURE__ */ new Set);
      z.get(i).add(m);
    }
    z.forEach((b, g) => {
      b.forEach((m) => {
        if (!R.has(m))
          R.set(m, /* @__PURE__ */ new Set);
        R.get(m).add(g);
      });
    });
    let B = [0, 0, 0], T = q.space.getCoords, w = q.data, [V, P, I] = E.grid.cells.space.dimensions, S = V - 1, f = P - 1, v = I - 1, h = {};
    z.forEach((b, g) => {
      h[g] = [S, f, v, -1, -1, -1];
    });
    for (let b = 0, g = w.length;b < g; ++b) {
      let m = w[b];
      if (m === 0)
        continue;
      T(b, B);
      let i = h[m];
      if (B[0] < i[0])
        i[0] = B[0];
      if (B[1] < i[1])
        i[1] = B[1];
      if (B[2] < i[2])
        i[2] = B[2];
      if (B[0] > i[3])
        i[3] = B[0];
      if (B[1] > i[4])
        i[4] = B[1];
      if (B[2] > i[5])
        i[5] = B[2];
    }
    let x = {};
    return R.forEach((b, g) => {
      x[g] = t1.create(M.create(S, f, v), M.create(-1, -1, -1));
    }), B7(h, (b, g) => {
      z.get(parseInt(g)).forEach((m) => {
        let i = x[m];
        if (b[0] < i.min[0])
          i.min[0] = b[0];
        if (b[1] < i.min[1])
          i.min[1] = b[1];
        if (b[2] < i.min[2])
          i.min[2] = b[2];
        if (b[3] > i.max[0])
          i.max[0] = b[3];
        if (b[4] > i.max[1])
          i.max[1] = b[4];
        if (b[5] > i.max[2])
          i.max[2] = b[5];
      });
    }), Q1.Segmentation.set(E, { segments: R, sets: z, bounds: x, labels: (X = J === null || J === void 0 ? void 0 : J.segmentLabels) !== null && X !== void 0 ? X : {} }), E;
  });
}
var Mt;
(function(Z) {
  function J(X) {
    return (X === null || X === void 0 ? void 0 : X.kind) === "segcif";
  }
  Z.is = J;
  function $(X) {
    return { kind: "segcif", name: X._name, data: X };
  }
  Z.create = $;
})(Mt || (Mt = {}));

// node_modules/molstar/lib/mol-plugin-state/transforms/volume.js
var E51 = B2.BuiltIn({
  name: "volume-from-ccp4",
  display: { name: "Volume from CCP4/MRC/MAP", description: "Create Volume from CCP4/MRC/MAP data" },
  from: D0.Format.Ccp4,
  to: D0.Volume.Data,
  params(Z) {
    return {
      voxelSize: j.Vec3(M.create(1, 1, 1)),
      offset: j.Vec3(M.create(0, 0, 0)),
      entryId: j.Text("")
    };
  }
})({
  apply({ a: Z, params: J }) {
    return n0.create("Create volume from CCP4/MRC/MAP", async ($) => {
      let X = await IM0(Z.data, { ...J, label: Z.data.name || Z.label }).runInContext($), Y = { label: X.label || "Volume", description: `Volume ${Z.data.header.NX}×${Z.data.header.NX}×${Z.data.header.NX}` };
      return new D0.Volume.Data(X, Y);
    });
  },
  dispose({ b: Z }) {
    Z === null || Z === void 0 || Z.data.customProperties.dispose();
  }
}), O51 = B2.BuiltIn({
  name: "volume-from-dsn6",
  display: { name: "Volume from DSN6/BRIX", description: "Create Volume from DSN6/BRIX data" },
  from: D0.Format.Dsn6,
  to: D0.Volume.Data,
  params(Z) {
    return {
      voxelSize: j.Vec3(M.create(1, 1, 1)),
      entryId: j.Text("")
    };
  }
})({
  apply({ a: Z, params: J }) {
    return n0.create("Create volume from DSN6/BRIX", async ($) => {
      let X = await PM0(Z.data, { ...J, label: Z.data.name || Z.label }).runInContext($), Y = { label: X.label || "Volume", description: `Volume ${Z.data.header.xExtent}×${Z.data.header.yExtent}×${Z.data.header.zExtent}` };
      return new D0.Volume.Data(X, Y);
    });
  },
  dispose({ b: Z }) {
    Z === null || Z === void 0 || Z.data.customProperties.dispose();
  }
}), z51 = B2.BuiltIn({
  name: "volume-from-cube",
  display: { name: "Volume from Cube", description: "Create Volume from Cube data" },
  from: D0.Format.Cube,
  to: D0.Volume.Data,
  params(Z) {
    return {
      dataIndex: Z ? j.Select(0, Z.data.header.dataSetIds.map(($, X) => [X, `${$}`])) : j.Numeric(0),
      entryId: j.Text("")
    };
  }
})({
  apply({ a: Z, params: J }) {
    return n0.create("Create volume from Cube", async ($) => {
      let X = await LH0(Z.data, { ...J, label: Z.data.name || Z.label }).runInContext($), Y = { label: X.label || "Volume", description: `Volume ${Z.data.header.dim[0]}×${Z.data.header.dim[1]}×${Z.data.header.dim[2]}` };
      return new D0.Volume.Data(X, Y);
    });
  },
  dispose({ b: Z }) {
    Z === null || Z === void 0 || Z.data.customProperties.dispose();
  }
}), D51 = B2.BuiltIn({
  name: "volume-from-dx",
  display: { name: "Parse DX", description: "Create volume from DX data." },
  from: D0.Format.Dx,
  to: D0.Volume.Data
})({
  apply({ a: Z }) {
    return n0.create("Parse DX", async (J) => {
      let $ = await CM0(Z.data, { label: Z.data.name || Z.label }).runInContext(J), X = { label: $.label || "Volume", description: `Volume ${Z.data.header.dim[0]}×${Z.data.header.dim[1]}×${Z.data.header.dim[2]}` };
      return new D0.Volume.Data($, X);
    });
  },
  dispose({ b: Z }) {
    Z === null || Z === void 0 || Z.data.customProperties.dispose();
  }
}), M51 = B2.BuiltIn({
  name: "volume-from-density-server-cif",
  display: { name: "Volume from density-server CIF", description: "Identify and create all separate models in the specified CIF data block" },
  from: D0.Format.Cif,
  to: D0.Volume.Data,
  params(Z) {
    if (!Z)
      return {
        blockHeader: j.Optional(j.Text(void 0, { description: "Header of the block to parse. If none is specifed, the 1st data block in the file is used." })),
        entryId: j.Text("")
      };
    let J = Z.data.blocks.slice(1);
    return {
      blockHeader: j.Optional(j.Select(J[0] && J[0].header, J.map(($) => [$.header, $.header]), { description: "Header of the block to parse" })),
      entryId: j.Text("")
    };
  }
})({
  isApplicable: (Z) => Z.data.blocks.length > 0,
  apply({ a: Z, params: J }) {
    return n0.create("Parse density-server CIF", async ($) => {
      var X;
      let Y = J.blockHeader || Z.data.blocks[1].header, Q = Z.data.blocks.find((U) => U.header === Y);
      if (!Q)
        throw new Error(`Data block '${[Y]}' not found.`);
      let W = kW.schema.densityServer(Q), K = await jf(W, { entryId: J.entryId }).runInContext($), [G, H, N] = K.grid.cells.space.dimensions, q = { label: (X = J.entryId) !== null && X !== void 0 ? X : W.volume_data_3d_info.name.value(0), description: `Volume ${G}×${H}×${N}` };
      return new D0.Volume.Data(K, q);
    });
  },
  dispose({ b: Z }) {
    Z === null || Z === void 0 || Z.data.customProperties.dispose();
  }
}), A51 = B2.BuiltIn({
  name: "volume-from-segmentation-cif",
  display: { name: "Volume from Segmentation CIF" },
  from: D0.Format.Cif,
  to: D0.Volume.Data,
  params(Z) {
    let J = Z === null || Z === void 0 ? void 0 : Z.data.blocks.slice(1);
    return {
      blockHeader: J ? j.Optional(j.Select(J[0] && J[0].header, J.map((X) => [X.header, X.header]), { description: "Header of the block to parse" })) : j.Optional(j.Text(void 0, { description: "Header of the block to parse. If none is specifed, the 1st data block in the file is used." })),
      segmentLabels: j.ObjectList({ id: j.Numeric(-1), label: j.Text("") }, (X) => `${X.id} = ${X.label}`, { description: "Mapping of segment IDs to segment labels" }),
      ownerId: j.Text("", { isHidden: !0, description: "Reference to the object which manages this volume" })
    };
  }
})({
  isApplicable: (Z) => Z.data.blocks.length > 0,
  apply({ a: Z, params: J }) {
    return n0.create("Parse segmentation CIF", async ($) => {
      let X = J.blockHeader || Z.data.blocks[1].header, Y = Z.data.blocks.find((U) => U.header === X);
      if (!Y)
        throw new Error(`Data block '${[X]}' not found.`);
      let Q = kW.schema.segmentation(Y), W = {};
      for (let U of J.segmentLabels)
        W[U.id] = U.label;
      let K = await kM0(Q, { segmentLabels: W, ownerId: J.ownerId }).runInContext($), [G, H, N] = K.grid.cells.space.dimensions, q = { label: Q.volume_data_3d_info.name.value(0), description: `Segmentation ${G}×${H}×${N}` };
      return new D0.Volume.Data(K, q);
    });
  },
  dispose({ b: Z }) {
    Z === null || Z === void 0 || Z.data.customProperties.dispose();
  }
}), B51 = B2.BuiltIn({
  name: "assign-color-volume",
  display: { name: "Assign Color Volume", description: "Assigns another volume to be available for coloring." },
  from: D0.Volume.Data,
  to: D0.Volume.Data,
  isDecorator: !0,
  params(Z, J) {
    if (!Z)
      return { ref: j.Text() };
    let $ = J.state.data.select(f2.Generators.root.subtree().ofType(D0.Volume.Data).filter((X) => {
      var Y;
      return !!X.obj && !((Y = X.obj) === null || Y === void 0 ? void 0 : Y.data.colorVolume) && X.obj !== Z;
    }));
    if ($.length === 0)
      return { ref: j.Text("", { isHidden: !0 }) };
    return { ref: j.Select($[0].transform.ref, $.map((X) => [X.transform.ref, X.obj.label])) };
  }
})({
  apply({ a: Z, params: J, dependencies: $ }) {
    return n0.create("Assign Color Volume", async (X) => {
      if (!$ || !$[J.ref])
        throw new Error("Dependency not available.");
      let Y = $[J.ref].data, Q = {
        ...Z.data,
        colorVolume: Y
      }, W = { label: Z.label, description: "Volume + Colors" };
      return new D0.Volume.Data(Q, W);
    });
  }
}), w51 = B2.BuiltIn({
  name: "volume-transform",
  display: { name: "Transform Volume" },
  isDecorator: !0,
  from: D0.Volume.Data,
  to: D0.Volume.Data,
  params: {
    transform: fA
  }
})({
  canAutoUpdate() {
    return !1;
  },
  apply({ a: Z, params: J }) {
    let $ = vA(J.transform) ? s6.getBoundingSphere(Z.data.grid).center : M.unit, X = SA(J.transform, $), Y = {
      kind: "matrix",
      matrix: e.mul(e(), X, s6.getGridToCartesianTransform(Z.data.grid))
    };
    return new D0.Volume.Data({
      ...Z.data,
      grid: {
        ...Z.data.grid,
        transform: Y
      }
    }, {
      label: Z.label,
      description: `${Z.description} [Transformed]`
    });
  }
}), j51 = B2.BuiltIn({
  name: "volume-instances",
  display: { name: "Volume Instances" },
  isDecorator: !0,
  from: D0.Volume.Data,
  to: D0.Volume.Data,
  params: {
    transforms: j.ObjectList({ transform: fA }, () => "Transform")
  }
})({
  canAutoUpdate() {
    return !0;
  },
  apply({ a: Z, params: J }) {
    let $ = J.transforms.some((Y) => vA(Y.transform)) ? s6.getBoundingSphere(Z.data.grid).center : M.unit, X = J.transforms.map((Y) => ({ transform: SA(Y.transform, $) }));
    if (!X.length)
      return Z;
    return new D0.Volume.Data({
      ...Z.data,
      instances: X
    }, {
      label: Z.label,
      description: `${Z.description} [Instanced]`
    });
  }
});

// node_modules/molstar/lib/mol-plugin-state/transforms/shape.js
var Bt = {};
y9(Bt, {
  getBoxMesh: () => vb,
  BoxShape3D: () => T51
});
var T51 = B2.BuiltIn({
  name: "box-shape-3d",
  display: "Box Shape",
  from: D0.Root,
  to: D0.Shape.Provider,
  params: {
    bottomLeft: j.Vec3(M()),
    topRight: j.Vec3(M.create(1, 1, 1)),
    radius: j.Numeric(0.15, { min: 0.01, max: 4, step: 0.01 }),
    color: j.Color(c2.red)
  }
})({
  canAutoUpdate() {
    return !0;
  },
  apply({ params: Z }) {
    return n0.create("Shape Representation", async (J) => {
      return new D0.Shape.Provider({
        label: "Box",
        data: Z,
        params: n1.Params,
        getShape: ($, X) => {
          let Y = vb(t1.create(Z.bottomLeft, Z.topRight), Z.radius);
          return c8.create("Box", X, Y, () => X.color, () => 1, () => "Box");
        },
        geometryUtils: n1.Utils
      }, { label: "Box" });
    });
  }
});
function vb(Z, J, $) {
  let X = M.sub(M(), Z.max, Z.min), Y = e.fromTranslation(e(), M.create(0.5, 0.5, 0.5)), Q = e.fromScaling(e(), X), W = e.fromTranslation(e(), Z.min), K = e.mul3(e(), W, Q, Y), G = v1.createState(256, 128, $);
  G.currentGroup = 1, v1.addCage(G, K, fh(), J, 2, 20);
  let H = v1.getMesh(G), N = M.scaleAndAdd(M(), Z.min, X, 0.5), q = M.distance(Z.min, N);
  return H.setBoundingSphere(C0.create(N, q)), H;
}

// node_modules/molstar/lib/mol-plugin-state/transforms.js
var H1 = {
  Data: Qr,
  Misc: Wr,
  Model: Et,
  Volume: At,
  Representation: wt,
  Shape: Bt
};

// node_modules/molstar/lib/mol-plugin-state/helpers/structure-selection-query.js
var fZ;
(function(Z) {
  Z.Type = "Type", Z.Structure = "Structure Property", Z.Atom = "Atom Property", Z.Bond = "Bond Property", Z.Residue = "Residue Property", Z.AminoAcid = "Amino Acid", Z.NucleicBase = "Nucleic Base", Z.Manipulate = "Manipulate Selection", Z.Validation = "Validation", Z.Misc = "Miscellaneous", Z.Internal = "Internal";
})(fZ || (fZ = {}));
function hZ(Z, J, $ = {}) {
  var X;
  let Y;
  return {
    label: Z,
    expression: J,
    description: $.description || "",
    category: (X = $.category) !== null && X !== void 0 ? X : fZ.Misc,
    isHidden: !!$.isHidden,
    priority: $.priority || 0,
    referencesCurrent: !!$.referencesCurrent,
    get query() {
      if (!Y)
        Y = PW(J);
      return Y;
    },
    ensureCustomProperties: $.ensureCustomProperties,
    async getSelection(Q, W, K) {
      let G = Q.managers.structure.selection.getStructure(K), H = G ? f1.Sequence(K, [G]) : f1.Empty(K);
      if ($.ensureCustomProperties)
        await $.ensureCustomProperties({ runtime: W, assetManager: Q.managers.asset }, K);
      if (!Y)
        Y = PW(J);
      return Y(new C9(K, { currentSelection: H }));
    }
  };
}
var _51 = hZ("All", L0.struct.generator.all(), { category: "", priority: 1000 }), V51 = hZ("Current Selection", L0.internal.generator.current(), { category: "", referencesCurrent: !0 }), I51 = hZ("Polymer", L0.struct.modifier.union([
  L0.struct.generator.atomGroups({
    "entity-test": L0.core.logic.and([
      L0.core.rel.eq([L0.ammp("entityType"), "polymer"]),
      L0.core.str.match([
        L0.re("(polypeptide|cyclic-pseudo-peptide|peptide-like|nucleotide|peptide nucleic acid)", "i"),
        L0.ammp("entitySubtype")
      ])
    ])
  })
]), { category: fZ.Type }), P51 = hZ("Trace", L0.struct.modifier.union([
  L0.struct.combinator.merge([
    L0.struct.modifier.union([
      L0.struct.generator.atomGroups({
        "entity-test": L0.core.rel.eq([L0.ammp("entityType"), "polymer"]),
        "chain-test": L0.core.set.has([
          L0.set("sphere", "gaussian"),
          L0.ammp("objectPrimitive")
        ])
      })
    ]),
    L0.struct.modifier.union([
      L0.struct.generator.atomGroups({
        "entity-test": L0.core.rel.eq([L0.ammp("entityType"), "polymer"]),
        "chain-test": L0.core.rel.eq([L0.ammp("objectPrimitive"), "atomistic"]),
        "atom-test": L0.core.set.has([L0.set("CA", "P"), L0.ammp("label_atom_id")])
      })
    ])
  ])
]), { category: fZ.Structure }), hA = L0.core.logic.and([
  L0.core.rel.eq([L0.ammp("entityType"), "polymer"]),
  L0.core.str.match([
    L0.re("(polypeptide|cyclic-pseudo-peptide|peptide-like)", "i"),
    L0.ammp("entitySubtype")
  ])
]), Sb = L0.core.logic.and([
  L0.core.rel.eq([L0.ammp("entityType"), "polymer"]),
  L0.core.str.match([
    L0.re("(nucleotide|peptide nucleic acid)", "i"),
    L0.ammp("entitySubtype")
  ])
]), Pz = L0.core.str.match([
  L0.re("non-polymer|(amino|carboxy) terminus|peptide-like", "i"),
  L0.ammp("chemCompType")
]), C51 = hZ("Backbone", L0.struct.modifier.union([
  L0.struct.combinator.merge([
    L0.struct.modifier.union([
      L0.struct.generator.atomGroups({
        "entity-test": hA,
        "chain-test": L0.core.rel.eq([L0.ammp("objectPrimitive"), "atomistic"]),
        "residue-test": L0.core.logic.not([Pz]),
        "atom-test": L0.core.set.has([L0.set(...uZ.toArray(jK)), L0.ammp("label_atom_id")])
      })
    ]),
    L0.struct.modifier.union([
      L0.struct.generator.atomGroups({
        "entity-test": Sb,
        "chain-test": L0.core.rel.eq([L0.ammp("objectPrimitive"), "atomistic"]),
        "residue-test": L0.core.logic.not([Pz]),
        "atom-test": L0.core.set.has([L0.set(...uZ.toArray(gM)), L0.ammp("label_atom_id")])
      })
    ])
  ])
]), { category: fZ.Structure }), k51 = hZ("Sidechain", L0.struct.modifier.union([
  L0.struct.combinator.merge([
    L0.struct.modifier.union([
      L0.struct.generator.atomGroups({
        "entity-test": hA,
        "chain-test": L0.core.rel.eq([L0.ammp("objectPrimitive"), "atomistic"]),
        "residue-test": L0.core.logic.not([Pz]),
        "atom-test": L0.core.logic.or([
          L0.core.logic.not([
            L0.core.set.has([L0.set(...uZ.toArray(jK)), L0.ammp("label_atom_id")])
          ])
        ])
      })
    ]),
    L0.struct.modifier.union([
      L0.struct.generator.atomGroups({
        "entity-test": Sb,
        "chain-test": L0.core.rel.eq([L0.ammp("objectPrimitive"), "atomistic"]),
        "residue-test": L0.core.logic.not([Pz]),
        "atom-test": L0.core.logic.or([
          L0.core.logic.not([
            L0.core.set.has([L0.set(...uZ.toArray(gM)), L0.ammp("label_atom_id")])
          ])
        ])
      })
    ])
  ])
]), { category: fZ.Structure }), v51 = hZ("Sidechain with Trace", L0.struct.modifier.union([
  L0.struct.combinator.merge([
    L0.struct.modifier.union([
      L0.struct.generator.atomGroups({
        "entity-test": hA,
        "chain-test": L0.core.rel.eq([L0.ammp("objectPrimitive"), "atomistic"]),
        "residue-test": L0.core.logic.not([Pz]),
        "atom-test": L0.core.logic.or([
          L0.core.logic.not([
            L0.core.set.has([L0.set(...uZ.toArray(jK)), L0.ammp("label_atom_id")])
          ]),
          L0.core.rel.eq([L0.ammp("label_atom_id"), "CA"]),
          L0.core.logic.and([
            L0.core.rel.eq([L0.ammp("auth_comp_id"), "PRO"]),
            L0.core.rel.eq([L0.ammp("label_atom_id"), "N"])
          ])
        ])
      })
    ]),
    L0.struct.modifier.union([
      L0.struct.generator.atomGroups({
        "entity-test": Sb,
        "chain-test": L0.core.rel.eq([L0.ammp("objectPrimitive"), "atomistic"]),
        "residue-test": L0.core.logic.not([Pz]),
        "atom-test": L0.core.logic.or([
          L0.core.logic.not([
            L0.core.set.has([L0.set(...uZ.toArray(gM)), L0.ammp("label_atom_id")])
          ]),
          L0.core.rel.eq([L0.ammp("label_atom_id"), "P"])
        ])
      })
    ])
  ])
]), { category: fZ.Structure }), S51 = hZ("Protein", L0.struct.modifier.union([
  L0.struct.generator.atomGroups({ "entity-test": hA })
]), { category: fZ.Type }), f51 = hZ("Nucleic", L0.struct.modifier.union([
  L0.struct.generator.atomGroups({ "entity-test": Sb })
]), { category: fZ.Type }), h51 = hZ("Helix", L0.struct.modifier.union([
  L0.struct.generator.atomGroups({
    "entity-test": hA,
    "residue-test": L0.core.flags.hasAny([
      L0.ammp("secondaryStructureFlags"),
      L0.core.type.bitflags([m2.Flag.Helix])
    ])
  })
]), {
  category: fZ.Structure,
  ensureCustomProperties: (Z, J) => {
    return $X.attach(Z, J);
  }
}), b51 = hZ("Beta Strand/Sheet", L0.struct.modifier.union([
  L0.struct.generator.atomGroups({
    "entity-test": hA,
    "residue-test": L0.core.flags.hasAny([
      L0.ammp("secondaryStructureFlags"),
      L0.core.type.bitflags([m2.Flag.Beta])
    ])
  })
]), {
  category: fZ.Structure,
  ensureCustomProperties: (Z, J) => {
    return $X.attach(Z, J);
  }
}), x51 = hZ("Water", L0.struct.modifier.union([
  L0.struct.generator.atomGroups({
    "entity-test": L0.core.rel.eq([L0.ammp("entityType"), "water"])
  })
]), { category: fZ.Type }), y51 = hZ("Ion", L0.struct.modifier.union([
  L0.struct.generator.atomGroups({
    "entity-test": L0.core.rel.eq([L0.ammp("entitySubtype"), "ion"])
  })
]), { category: fZ.Type }), g51 = hZ("Lipid", L0.struct.modifier.union([
  L0.struct.generator.atomGroups({
    "entity-test": L0.core.rel.eq([L0.ammp("entitySubtype"), "lipid"])
  })
]), { category: fZ.Type }), fb = hZ("Carbohydrate", L0.struct.modifier.union([
  L0.struct.generator.atomGroups({
    "entity-test": L0.core.logic.or([
      L0.core.rel.eq([L0.ammp("entityType"), "branched"]),
      L0.core.logic.and([
        L0.core.rel.eq([L0.ammp("entityType"), "non-polymer"]),
        L0.core.str.match([
          L0.re("oligosaccharide", "i"),
          L0.ammp("entitySubtype")
        ])
      ])
    ])
  })
]), { category: fZ.Type }), vM0 = hZ("Carbohydrate with Connected", L0.struct.modifier.union([
  L0.struct.modifier.includeConnected({
    0: fb.expression,
    "layer-count": 1,
    "as-whole-residues": !0
  })
]), { category: fZ.Internal, isHidden: !0 }), SM0 = hZ("Connected to Carbohydrate", L0.struct.modifier.union([
  L0.struct.modifier.exceptBy({
    0: vM0.expression,
    by: fb.expression
  })
]), { category: fZ.Internal, isHidden: !0 }), Tt = hZ("Ligand", L0.struct.modifier.union([
  L0.struct.modifier.exceptBy({
    0: L0.struct.modifier.union([
      L0.struct.combinator.merge([
        L0.struct.modifier.union([
          L0.struct.generator.atomGroups({
            "entity-test": L0.core.logic.and([
              L0.core.logic.or([
                L0.core.rel.eq([L0.ammp("entityType"), "non-polymer"]),
                L0.core.rel.neq([L0.ammp("entityPrdId"), ""])
              ]),
              L0.core.logic.not([L0.core.str.match([
                L0.re("(oligosaccharide|lipid|ion)", "i"),
                L0.ammp("entitySubtype")
              ])])
            ]),
            "chain-test": L0.core.rel.eq([L0.ammp("objectPrimitive"), "atomistic"]),
            "residue-test": L0.core.logic.not([
              L0.core.str.match([L0.re("saccharide", "i"), L0.ammp("chemCompType")])
            ])
          })
        ]),
        L0.struct.modifier.union([
          L0.struct.generator.atomGroups({
            "entity-test": L0.core.rel.eq([L0.ammp("entityType"), "polymer"]),
            "chain-test": L0.core.rel.eq([L0.ammp("objectPrimitive"), "atomistic"]),
            "residue-test": Pz
          })
        ])
      ])
    ]),
    by: L0.struct.combinator.merge([
      L0.struct.modifier.union([
        L0.struct.generator.atomGroups({
          "entity-test": L0.core.rel.eq([L0.ammp("entityType"), "polymer"]),
          "chain-test": L0.core.rel.eq([L0.ammp("objectPrimitive"), "atomistic"]),
          "residue-test": L0.core.set.has([
            L0.set(...uZ.toArray(uF)),
            L0.ammp("label_comp_id")
          ])
        })
      ]),
      L0.struct.generator.atomGroups({
        "chain-test": L0.core.rel.eq([L0.ammp("objectPrimitive"), "atomistic"]),
        "residue-test": L0.core.set.has([
          L0.set(...uZ.toArray(tH0)),
          L0.ammp("label_comp_id")
        ])
      })
    ])
  })
]), { category: fZ.Type }), fM0 = hZ("Ligand with Connected", L0.struct.modifier.union([
  L0.struct.modifier.exceptBy({
    0: L0.struct.modifier.union([
      L0.struct.modifier.includeConnected({
        0: Tt.expression,
        "layer-count": 1,
        "as-whole-residues": !0,
        "bond-test": L0.core.flags.hasAny([
          L0.struct.bondProperty.flags(),
          L0.core.type.bitflags([
            s1.Flag.Covalent | s1.Flag.MetallicCoordination
          ])
        ])
      })
    ]),
    by: fb.expression
  })
]), { category: fZ.Internal, isHidden: !0 }), hM0 = hZ("Connected to Ligand", L0.struct.modifier.union([
  L0.struct.modifier.exceptBy({
    0: fM0.expression,
    by: Tt.expression
  })
]), { category: fZ.Internal, isHidden: !0 }), m51 = hZ("Connected to Ligand or Carbohydrate", L0.struct.modifier.union([
  L0.struct.combinator.merge([
    SM0.expression,
    hM0.expression
  ])
]), { category: fZ.Internal, isHidden: !0 }), d51 = hZ("Disulfide Bridges", L0.struct.modifier.union([
  L0.struct.combinator.merge([
    L0.struct.modifier.union([
      L0.struct.modifier.wholeResidues([
        L0.struct.filter.isConnectedTo({
          0: L0.struct.generator.atomGroups({
            "residue-test": L0.core.set.has([L0.set("CYS"), L0.ammp("auth_comp_id")]),
            "atom-test": L0.core.set.has([L0.set("SG"), L0.ammp("label_atom_id")])
          }),
          target: L0.struct.generator.atomGroups({
            "residue-test": L0.core.set.has([L0.set("CYS"), L0.ammp("auth_comp_id")]),
            "atom-test": L0.core.set.has([L0.set("SG"), L0.ammp("label_atom_id")])
          }),
          "bond-test": !0
        })
      ])
    ]),
    L0.struct.modifier.union([
      L0.struct.modifier.wholeResidues([
        L0.struct.modifier.union([
          L0.struct.generator.bondedAtomicPairs({
            0: L0.core.flags.hasAny([
              L0.struct.bondProperty.flags(),
              L0.core.type.bitflags([s1.Flag.Disulfide])
            ])
          })
        ])
      ])
    ])
  ])
]), { category: fZ.Bond }), p51 = hZ("NOS Bridges", L0.struct.modifier.union([
  L0.struct.modifier.wholeResidues([
    L0.struct.filter.isConnectedTo({
      0: L0.struct.generator.atomGroups({
        "residue-test": L0.core.set.has([L0.set("CSO", "LYS"), L0.ammp("auth_comp_id")]),
        "atom-test": L0.core.set.has([L0.set("OD", "NZ"), L0.ammp("label_atom_id")])
      }),
      target: L0.struct.generator.atomGroups({
        "residue-test": L0.core.set.has([L0.set("CSO", "LYS"), L0.ammp("auth_comp_id")]),
        "atom-test": L0.core.set.has([L0.set("OD", "NZ"), L0.ammp("label_atom_id")])
      }),
      "bond-test": !0
    })
  ])
]), { category: fZ.Bond }), u51 = hZ("Non-standard Residues in Polymers", L0.struct.modifier.union([
  L0.struct.generator.atomGroups({
    "entity-test": L0.core.rel.eq([L0.ammp("entityType"), "polymer"]),
    "chain-test": L0.core.rel.eq([L0.ammp("objectPrimitive"), "atomistic"]),
    "residue-test": L0.ammp("isNonStandard")
  })
]), { category: fZ.Residue }), c51 = hZ("Coarse Elements", L0.struct.modifier.union([
  L0.struct.generator.atomGroups({
    "chain-test": L0.core.set.has([
      L0.set("sphere", "gaussian"),
      L0.ammp("objectPrimitive")
    ])
  })
]), { category: fZ.Type }), l51 = hZ("Rings in Residues", L0.struct.modifier.union([
  L0.struct.generator.rings()
]), { category: fZ.Residue }), n51 = hZ("Aromatic Rings in Residues", L0.struct.modifier.union([
  L0.struct.generator.rings({ "only-aromatic": !0 })
]), { category: fZ.Residue }), i51 = hZ("Surrounding Residues (5 Å) of Selection", L0.struct.modifier.union([
  L0.struct.modifier.exceptBy({
    0: L0.struct.modifier.includeSurroundings({
      0: L0.internal.generator.current(),
      radius: 5,
      "as-whole-residues": !0
    }),
    by: L0.internal.generator.current()
  })
]), {
  description: "Select residues within 5 Å of the current selection.",
  category: fZ.Manipulate,
  referencesCurrent: !0
}), o51 = hZ("Surrounding Ligands (5 Å) of Selection", L0.struct.modifier.union([
  L0.struct.modifier.surroundingLigands({
    0: L0.internal.generator.current(),
    radius: 5,
    "include-water": !0
  })
]), {
  description: "Select ligand components within 5 Å of the current selection.",
  category: fZ.Manipulate,
  referencesCurrent: !0
}), s51 = hZ("Surrounding Atoms (5 Å) of Selection", L0.struct.modifier.union([
  L0.struct.modifier.exceptBy({
    0: L0.struct.modifier.includeSurroundings({
      0: L0.internal.generator.current(),
      radius: 5,
      "as-whole-residues": !1
    }),
    by: L0.internal.generator.current()
  })
]), {
  description: "Select atoms within 5 Å of the current selection.",
  category: fZ.Manipulate,
  referencesCurrent: !0
}), a51 = hZ("Inverse / Complement of Selection", L0.struct.modifier.union([
  L0.struct.modifier.exceptBy({
    0: L0.struct.generator.all(),
    by: L0.internal.generator.current()
  })
]), {
  description: "Select everything not in the current selection.",
  category: fZ.Manipulate,
  referencesCurrent: !0
}), r51 = hZ("Residues Covalently Bonded to Selection", L0.struct.modifier.union([
  L0.struct.modifier.includeConnected({
    0: L0.internal.generator.current(),
    "layer-count": 1,
    "as-whole-residues": !0
  })
]), {
  description: "Select residues covalently bonded to current selection.",
  category: fZ.Manipulate,
  referencesCurrent: !0
}), t51 = hZ("Covalently Bonded Component", L0.struct.modifier.union([
  L0.struct.modifier.includeConnected({
    0: L0.internal.generator.current(),
    "fixed-point": !0
  })
]), {
  description: "Select covalently bonded component based on current selection.",
  category: fZ.Manipulate,
  referencesCurrent: !0
}), e51 = hZ("Residues with Cov. or Metallic Bond to Selection", L0.struct.modifier.union([
  L0.struct.modifier.includeConnected({
    0: L0.internal.generator.current(),
    "layer-count": 1,
    "as-whole-residues": !0,
    "bond-test": L0.core.flags.hasAny([
      L0.struct.bondProperty.flags(),
      L0.core.type.bitflags([
        s1.Flag.Covalent | s1.Flag.MetallicCoordination
      ])
    ])
  })
]), {
  description: "Select residues with covalent or metallic bond to current selection.",
  category: fZ.Manipulate,
  referencesCurrent: !0
}), ZK1 = hZ("Whole Residues of Selection", L0.struct.modifier.union([
  L0.struct.modifier.wholeResidues({
    0: L0.internal.generator.current()
  })
]), {
  description: "Expand current selection to whole residues.",
  category: fZ.Manipulate,
  referencesCurrent: !0
}), JK1 = [
  [["HIS"], "Histidine"],
  [["ARG"], "Arginine"],
  [["LYS"], "Lysine"],
  [["ILE"], "Isoleucine"],
  [["PHE"], "Phenylalanine"],
  [["LEU"], "Leucine"],
  [["TRP"], "Tryptophan"],
  [["ALA"], "Alanine"],
  [["MET"], "Methionine"],
  [["PRO"], "Proline"],
  [["CYS"], "Cysteine"],
  [["ASN"], "Asparagine"],
  [["VAL"], "Valine"],
  [["GLY"], "Glycine"],
  [["SER"], "Serine"],
  [["GLN"], "Glutamine"],
  [["TYR"], "Tyrosine"],
  [["ASP"], "Aspartic Acid"],
  [["GLU"], "Glutamic Acid"],
  [["THR"], "Threonine"],
  [["SEC"], "Selenocysteine"],
  [["PYL"], "Pyrrolysine"],
  [["UNK"], "Unknown"]
].sort((Z, J) => Z[1] < J[1] ? -1 : Z[1] > J[1] ? 1 : 0), $K1 = [
  [["A", "DA"], "Adenosine"],
  [["C", "DC"], "Cytidine"],
  [["T", "DT"], "Thymidine"],
  [["G", "DG"], "Guanosine"],
  [["I", "DI"], "Inosine"],
  [["U", "DU"], "Uridine"],
  [["N", "DN"], "Unknown"]
].sort((Z, J) => Z[1] < J[1] ? -1 : Z[1] > J[1] ? 1 : 0);
function jt([Z, J], $, X = 0) {
  let Y = Z.length === 1 && !bM0.has(Z[0]) ? `[${Z[0]}] ${J}` : `${J} (${Z.join(", ")})`;
  return hZ(Y, L0.struct.modifier.union([
    L0.struct.generator.atomGroups({
      "residue-test": L0.core.set.has([L0.set(...Z), L0.ammp("auth_comp_id")])
    })
  ]), { category: $, priority: X, description: Y });
}
function XK1([Z, J], $, X) {
  let Y = `${J} (${Z.join(", ")})`;
  return hZ(Y, L0.struct.modifier.union([
    L0.struct.generator.atomGroups({
      "atom-test": L0.core.set.has([L0.set(...Z), L0.acp("elementSymbol")])
    })
  ]), { category: $, priority: X, description: Y });
}
function YK1([Z, J], $, X) {
  let Y = `${J}`;
  return hZ(`${J}`, L0.struct.modifier.union([
    L0.struct.generator.atomGroups({
      "entity-test": L0.core.list.equal([L0.list(...Z), L0.ammp("entityDescription")])
    })
  ]), { category: $, priority: X, description: Y });
}
var bM0 = uZ.unionMany(vf, dM, pM, mM);
function xM0(Z) {
  let J = /* @__PURE__ */ new Set;
  for (let X of Z)
    X.uniqueElementSymbols.forEach((Y) => J.add(Y));
  let $ = [];
  return J.forEach((X) => {
    let Y = rN0[X] || X;
    $.push(XK1([[X], Y], "Element Symbol", 0));
  }), $;
}
function yM0(Z) {
  let J = /* @__PURE__ */ new Map, $ = /* @__PURE__ */ new Set;
  for (let Y of Z) {
    Y.uniqueResidueNames.forEach((Q) => $.add(Q));
    for (let Q of Y.models)
      Y.uniqueResidueNames.forEach((W) => {
        let K = Q.properties.chemicalComponentMap.get(W);
        if (K)
          J.set(W, K.name);
      });
  }
  let X = [];
  return uZ.difference($, bM0).forEach((Y) => {
    let Q = J.get(Y) || Y;
    X.push(jt([[Y], Q], "Ligand/Non-standard Residue", 200));
  }), X;
}
function gM0(Z) {
  let J = /* @__PURE__ */ new Map, $ = W0.Location.create();
  for (let Y of Z) {
    $.structure = Y;
    for (let Q of Y.unitSymmetryGroups) {
      $.unit = Q.units[0], $.element = Q.elements[0];
      let W = w1.entity.type($);
      if (W === "polymer" || W === "branched") {
        let K = w1.entity.pdbx_description($);
        J.set(K.join(", "), K);
      }
    }
  }
  let X = [];
  return J.forEach((Y, Q) => {
    X.push(YK1([Y, Q], "Polymer/Carbohydrate Entities", 300));
  }), X;
}
var u9 = {
  all: _51,
  current: V51,
  polymer: I51,
  trace: P51,
  backbone: C51,
  sidechain: k51,
  sidechainWithTrace: v51,
  protein: S51,
  nucleic: f51,
  helix: h51,
  beta: b51,
  water: x51,
  ion: y51,
  lipid: g51,
  branched: fb,
  branchedPlusConnected: vM0,
  branchedConnectedOnly: SM0,
  ligand: Tt,
  ligandPlusConnected: fM0,
  ligandConnectedOnly: hM0,
  connectedOnly: m51,
  disulfideBridges: d51,
  nosBridges: p51,
  nonStandardPolymer: u51,
  coarse: c51,
  ring: l51,
  aromaticRing: n51,
  surroundings: i51,
  surroundingLigands: o51,
  surroundingAtoms: s51,
  complement: a51,
  covalentlyBonded: r51,
  covalentlyOrMetallicBonded: e51,
  covalentlyBondedComponent: t51,
  wholeResidues: ZK1
};

class _t {
  add(Z) {
    this.list.push(Z), this.options.push([Z, Z.label, Z.category]), this.version += 1;
  }
  remove(Z) {
    let J = this.list.indexOf(Z);
    if (J !== -1)
      this.list.splice(J, 1), this.options.splice(J, 1), this.version += 1;
  }
  constructor() {
    this.list = [], this.options = [], this.version = 1, this.list.push(...Object.values(u9), ...JK1.map((Z) => jt(Z, fZ.AminoAcid)), ...$K1.map((Z) => jt(Z, fZ.NucleicBase))), this.options.push(...this.list.map((Z) => [Z, Z.label, Z.category]));
  }
}

// node_modules/molstar/lib/mol-theme/color/external-structure.js
var QK1 = "Assigns a color based on structure property at a given vertex.", mM0 = {
  structure: j.ValueRef((Z) => {
    return Z.state.data.select(f2.Generators.rootsOfType(D0.Molecule.Structure)).filter(($) => {
      var X;
      return (X = $.obj) === null || X === void 0 ? void 0 : X.data;
    }).map(($) => {
      var X, Y;
      return [$.transform.ref, (Y = (X = $.obj) === null || X === void 0 ? void 0 : X.label) !== null && Y !== void 0 ? Y : "<unknown>"];
    });
  }, (Z, J) => J(Z)),
  style: j.MappedStatic("chain-id", {
    "chain-id": j.Group(iN),
    "entity-id": j.Group(aN),
    "entity-source": j.Group(tN),
    "molecule-type": j.Group(vR),
    "model-index": j.Group(Zq),
    "structure-index": j.Group($q)
  }),
  defaultColor: j.Color(i0(13421772)),
  maxDistance: j.Numeric(8, { min: 0.1, max: 24, step: 0.1 }, { description: "Maximum distance to search for the nearest structure element. This is done only if the approximate search fails." }),
  approxMaxDistance: j.Numeric(4, { min: 0, max: 12, step: 0.1 }, { description: "Maximum distance to search for an approximately nearest structure element. This is done before the extact search." }),
  normalOffset: j.Numeric(0, { min: -10, max: 20, step: 0.1 }, { description: "Offset vertex position along its normal by given amount." }),
  backboneOnly: j.Boolean(!1)
};
function WK1(Z, J) {
  switch (J.name) {
    case "chain-id":
      return oN(Z, J.params);
    case "entity-id":
      return rN(Z, J.params);
    case "entity-source":
      return eN(Z, J.params);
    case "molecule-type":
      return SR(Z, J.params);
    case "model-index":
      return Jq(Z, J.params);
    case "structure-index":
      return Xq(Z, J.params);
    default:
      T8(J);
  }
}
function dM0(Z, J) {
  let $;
  try {
    $ = J.structure.getValue();
  } catch (q) {}
  let X, Y = void 0, Q = void 0, { maxDistance: W, approxMaxDistance: K, normalOffset: G, defaultColor: H, backboneOnly: N } = J;
  if ($) {
    let q = WK1({ ...Z, structure: $ }, J.style), U = tM(), F = tM(), E = $;
    if (N)
      E = f1.unionStructure(u9.backbone.query(new C9($)));
    let R = M(), z = W0.Location.create(E);
    X = (D, A) => {
      if (!qA(D))
        return H;
      if (G !== 0)
        M.scaleAndAdd(R, D.position, D.normal, G);
      else
        M.copy(R, D.position);
      let [B, T, w] = R;
      if (K > 0) {
        let P = E.lookup3d.approxNearest(B, T, w, K, U);
        if (P.count > 0)
          return z.unit = P.units[0], z.element = z.unit.elements[P.indices[0]], q.color(z, A);
      }
      let V = E.lookup3d.find(B, T, w, W, F);
      if (V.count > 0) {
        let P = 0, I = V.squaredDistances[0];
        for (let S = 1;S < V.count; ++S)
          if (V.squaredDistances[S] < I)
            I = V.squaredDistances[S], P = S;
        return z.unit = V.units[P], z.element = z.unit.elements[V.indices[P]], q.color(z, A);
      }
      return H;
    }, Y = q.contextHash, Q = q.legend;
  } else
    X = () => H;
  return {
    factory: dM0,
    granularity: "vertex",
    preferSmoothing: !0,
    color: X,
    props: J,
    contextHash: Y,
    description: QK1,
    legend: Q
  };
}
var pM0 = {
  name: "external-structure",
  label: "External Structure",
  category: $8.Misc,
  factory: dM0,
  getParams: () => mM0,
  defaultValues: j.getDefaultValues(mM0),
  isApplicable: (Z) => !0
};

// node_modules/molstar/lib/mol-theme/color/volume-instance.js
var Vt = "dark-2", uM0 = i0(13421772), KK1 = "Gives every volume instance a unique color based on the position (index) of the instance in the list of instances of the volume.", cM0 = {
  ...p9({ type: "colors", colorList: Vt })
};
function GK1(Z) {
  let J = j.clone(cM0);
  if (Z.volume) {
    if (Z.volume.instances.length > g7[Vt].list.length)
      J.palette.defaultValue.name = "colors", J.palette.defaultValue.params = {
        ...J.palette.defaultValue.params,
        list: { kind: "interpolate", colors: RJ(Vt).list }
      };
  }
  return J;
}
function lM0(Z, J) {
  let $, X;
  if (Z.volume) {
    let Y = a9(Z.volume.instances.length, J);
    X = Y.legend;
    let Q = Q1.Cell.isLocation;
    $ = (W) => {
      if (Q(W))
        return Y.color(W.instance);
      return uM0;
    };
  } else
    $ = () => uM0;
  return {
    factory: lM0,
    granularity: "instance",
    color: $,
    props: J,
    description: KK1,
    legend: X
  };
}
var nM0 = {
  name: "volume-instance",
  label: "Volume Instance",
  category: $8.Misc,
  factory: lM0,
  getParams: GK1,
  defaultValues: j.getDefaultValues(cM0),
  isApplicable: (Z) => !!Z.volume
};

// node_modules/molstar/lib/mol-theme/color.js
var oJ;
(function(Z) {
  Z.Category = $8;
  function J(Q, W, K, G) {
    let H = [];
    if (Q.every((q) => Array.isArray(q))) {
      let q = 0;
      for (let A of Q)
        if (Array.isArray(A)) {
          let B = Xz(A[1]);
          if (B > q)
            q = B;
        }
      let U = Math.pow(10, q), F = [...Q];
      F.sort((A, B) => A[1] - B[1]);
      let E = F.map((A) => A[0]), R = X1.ofSortedArray(F.map((A) => A[1])), z = [];
      for (let A = 0, B = R.length - 1;A < B; ++A)
        z.push(R[A] + (R[A + 1] - R[A]) / 2);
      z.push(R[R.length - 1]);
      let D = X1.ofSortedArray(z);
      for (let A = 0, B = Math.max(U, Q.length);A < B; ++A) {
        let T = aG(A, 0, U - 1), w = X1.findPredecessorIndex(D, T);
        H[A] = E[w];
      }
    } else
      for (let q of Q)
        if (Array.isArray(q))
          H.push(q[0]);
        else
          H.push(q);
    return {
      colors: H,
      filter: W === "set" ? "nearest" : "linear",
      domain: K,
      defaultColor: G
    };
  }
  Z.Palette = J, Z.PaletteScale = 16777214, Z.EmptyFactory = () => Z.Empty;
  let $ = i0(13421772);
  Z.Empty = {
    factory: Z.EmptyFactory,
    granularity: "uniform",
    color: () => $,
    props: {}
  };
  function X(Q, W) {
    return Q.contextHash === W.contextHash && Q.factory === W.factory && QY(Q.props, W.props);
  }
  Z.areEqual = X, Z.EmptyProvider = { name: "", label: "", category: "", factory: Z.EmptyFactory, getParams: () => ({}), defaultValues: {}, isApplicable: () => !0 };
  function Y() {
    return new kV(Z.BuiltIn, Z.EmptyProvider);
  }
  Z.createRegistry = Y, Z.BuiltIn = {
    "atom-id": Iz0,
    "carbohydrate-symbol": YO0,
    cartoon: mz0,
    "chain-id": ph,
    "element-index": RO0,
    "element-symbol": kO0,
    "entity-id": OO0,
    "entity-source": MO0,
    "external-structure": pM0,
    "external-volume": xz0,
    "formal-charge": cz0,
    hydrophobicity: Rz0,
    illustrative: Fz0,
    "model-index": BO0,
    "molecule-type": fO0,
    occupancy: Oz0,
    "operator-hkl": Bz0,
    "operator-name": MA,
    "partial-charge": jz0,
    "polymer-id": mO0,
    "polymer-index": lO0,
    "residue-charge": Jz0,
    "residue-name": sO0,
    "secondary-structure": Yz0,
    "sequence-id": Kz0,
    "shape-group": lE0,
    "structure-index": jO0,
    "trajectory-index": IO0,
    uncertainty: Hz0,
    "unit-index": _O0,
    uniform: ZE0,
    "volume-instance": nM0,
    "volume-segment": fz0,
    "volume-value": Cz0
  };
})(oJ || (oJ = {}));

// node_modules/molstar/lib/mol-theme/size/physical.js
var HK1 = 1, NK1 = "Assigns a physical size, i.e. vdW radius for atoms or given radius for coarse spheres.", iM0 = {
  scale: j.Numeric(1, { min: 0.1, max: 5, step: 0.1 })
};
function qK1(Z) {
  return iM0;
}
function It(Z, J) {
  if (j0.isAtomic(Z))
    return D5(Z.model.atomicHierarchy.atoms.type_symbol.value(J));
  else if (j0.isSpheres(Z))
    return Z.model.coarseConformation.spheres.radius[J];
  else
    return 0;
}
function oM0(Z, J) {
  let $ = J.scale === void 0 ? 1 : J.scale;
  function X(Y) {
    let Q;
    if (W0.Location.is(Y))
      Q = $ * It(Y.unit, Y.element);
    else if ($2.isLocation(Y))
      Q = $ * Math.min(It(Y.aUnit, Y.aUnit.elements[Y.aIndex]), It(Y.bUnit, Y.bUnit.elements[Y.bIndex]));
    else
      Q = $ * HK1;
    return Q;
  }
  return {
    factory: oM0,
    granularity: "group",
    size: X,
    props: J,
    description: NK1
  };
}
var sM0 = {
  name: "physical",
  label: "Physical",
  category: "",
  factory: oM0,
  getParams: qK1,
  defaultValues: j.getDefaultValues(iM0),
  isApplicable: (Z) => !!Z.structure
};

// node_modules/molstar/lib/mol-theme/size/uncertainty.js
var FK1 = "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.", rM0 = {
  bfactorFactor: j.Numeric(0.1, { min: 0, max: 1, step: 0.01 }),
  rmsfFactor: j.Numeric(0.05, { min: 0, max: 1, step: 0.01 }),
  baseSize: j.Numeric(0.2, { min: 0, max: 2, step: 0.1 })
};
function UK1(Z) {
  return rM0;
}
function aM0(Z, J, $) {
  if (j0.isAtomic(Z))
    return Z.model.atomicConformation.B_iso_or_equiv.value(J) * $.bfactorFactor;
  else if (j0.isSpheres(Z))
    return Z.model.coarseConformation.spheres.rmsf[J] * $.rmsfFactor;
  else
    return 0;
}
function tM0(Z, J) {
  function $(X) {
    let Y = J.baseSize;
    if (W0.Location.is(X))
      Y += aM0(X.unit, X.element, J);
    else if ($2.isLocation(X))
      Y += aM0(X.aUnit, X.aUnit.elements[X.aIndex], J);
    return Y;
  }
  return {
    factory: tM0,
    granularity: "group",
    size: $,
    props: J,
    description: FK1
  };
}
var eM0 = {
  name: "uncertainty",
  label: "Uncertainty/Disorder",
  category: "",
  factory: tM0,
  getParams: UK1,
  defaultValues: j.getDefaultValues(rM0),
  isApplicable: (Z) => !!Z.structure && Z.structure.models.some((J) => J.atomicConformation.B_iso_or_equiv.isDefined || J.coarseHierarchy.isDefined)
};

// node_modules/molstar/lib/mol-theme/size/volume-value.js
var ZA0 = "Assign size based on the given value of a volume cell. Negative values are made positive.", JA0 = {
  scale: j.Numeric(1, { min: 0.1, max: 5, step: 0.1 })
};
function LK1(Z) {
  return JA0;
}
function Pt(Z, J) {
  if (Z.volume) {
    let { data: $ } = Z.volume.grid.cells, X = Q1.Cell.isLocation;
    return {
      factory: Pt,
      granularity: "group",
      size: (Q) => {
        if (X(Q))
          return Math.abs($[Q.cell]) * J.scale;
        else
          return 0;
      },
      props: J,
      description: ZA0
    };
  } else
    return {
      factory: Pt,
      granularity: "uniform",
      size: () => J.scale,
      props: J,
      description: ZA0
    };
}
var $A0 = {
  name: "volume-value",
  label: "Volume Value",
  category: "",
  factory: Pt,
  getParams: LK1,
  defaultValues: j.getDefaultValues(JA0),
  isApplicable: (Z) => !!Z.volume && !Q1.Segmentation.get(Z.volume)
};

// node_modules/molstar/lib/mol-theme/size.js
var J9;
(function(Z) {
  Z.EmptyFactory = () => Z.Empty, Z.Empty = { factory: Z.EmptyFactory, granularity: "uniform", size: () => 1, props: {} };
  function J(X, Y) {
    return X.contextHash === Y.contextHash && X.factory === Y.factory && QY(X.props, Y.props);
  }
  Z.areEqual = J, Z.EmptyProvider = { name: "", label: "", category: "", factory: Z.EmptyFactory, getParams: () => ({}), defaultValues: {}, isApplicable: () => !0 };
  function $() {
    return new kV(Z.BuiltIn, Z.EmptyProvider);
  }
  Z.createRegistry = $, Z.BuiltIn = {
    physical: sM0,
    "shape-group": uE0,
    uncertainty: eM0,
    uniform: $E0,
    "volume-value": $A0
  };
})(J9 || (J9 = {}));

// node_modules/molstar/lib/mol-theme/theme.js
var Q7;
(function(Z) {
  function J(Q, W, K, G) {
    G = G || $();
    let { colorTheme: H, sizeTheme: N } = K;
    return G.color = Q.colorThemeRegistry.create(H.name, W, H.params), G.size = Q.sizeThemeRegistry.create(N.name, W, N.params), G;
  }
  Z.create = J;
  function $() {
    return { color: oJ.Empty, size: J9.Empty };
  }
  Z.createEmpty = $;
  async function X(Q, W, K, G) {
    var H, N;
    await ((H = W.colorThemeRegistry.get(G.colorTheme.name).ensureCustomProperties) === null || H === void 0 ? void 0 : H.attach(Q, K)), await ((N = W.sizeThemeRegistry.get(G.sizeTheme.name).ensureCustomProperties) === null || N === void 0 ? void 0 : N.attach(Q, K));
  }
  Z.ensureDependencies = X;
  function Y(Q, W, K) {
    var G, H;
    (G = Q.colorThemeRegistry.get(K.colorTheme.name).ensureCustomProperties) === null || G === void 0 || G.detach(W), (H = Q.sizeThemeRegistry.get(K.sizeTheme.name).ensureCustomProperties) === null || H === void 0 || H.detach(W);
  }
  Z.releaseDependencies = Y;
})(Q7 || (Q7 = {}));
function XA0(Z) {
  return Z.map((J) => [J.name, J.provider.label, J.provider.category]);
}

class kV {
  get default() {
    return this._list[0];
  }
  get list() {
    return this._list;
  }
  get types() {
    return XA0(this._list);
  }
  constructor(Z, J) {
    this.emptyProvider = J, this._list = [], this._map = /* @__PURE__ */ new Map, this._name = /* @__PURE__ */ new Map, B7(Z, ($, X) => {
      if ($.name !== X)
        throw new Error(`Fix build in themes to have matching names. ${$.name} ${X}`);
      this.add($);
    });
  }
  sort() {
    this._list.sort((Z, J) => {
      if (Z.provider.category === J.provider.category)
        return Z.provider.label < J.provider.label ? -1 : Z.provider.label > J.provider.label ? 1 : 0;
      return Z.provider.category < J.provider.category ? -1 : 1;
    });
  }
  add(Z) {
    if (this._map.has(Z.name))
      throw new Error(`${Z.name} already registered.`);
    let J = Z.name;
    this._list.push({ name: J, provider: Z }), this._map.set(J, Z), this._name.set(Z, J), this.sort();
  }
  remove(Z) {
    this._list.splice(this._list.findIndex(($) => $.name === Z.name), 1);
    let J = this._map.get(Z.name);
    if (J)
      this._map.delete(Z.name), this._name.delete(J);
  }
  has(Z) {
    return this._map.has(Z.name);
  }
  get(Z) {
    return this._map.get(Z) || this.emptyProvider;
  }
  getName(Z) {
    if (!this._name.has(Z))
      throw new Error(`'${Z.label}' is not a registered theme provider.`);
    return this._name.get(Z);
  }
  create(Z, J, $ = {}) {
    let X = this.get(Z);
    return X.factory(J, { ...j.getDefaultValues(X.getParams(J)), ...$ });
  }
  getApplicableList(Z) {
    return this._list.filter((J) => J.provider.isApplicable(Z));
  }
  getApplicableTypes(Z) {
    return XA0(this.getApplicableList(Z));
  }
  clear() {
    this._list.length = 0, this._map.clear(), this._name.clear();
  }
}

// node_modules/molstar/lib/mol-util/marker-action.js
var x2;
(function(Z) {
  Z[Z.None = 0] = "None", Z[Z.Highlight = 1] = "Highlight", Z[Z.RemoveHighlight = 2] = "RemoveHighlight", Z[Z.Select = 4] = "Select", Z[Z.Deselect = 8] = "Deselect", Z[Z.Toggle = 16] = "Toggle", Z[Z.Clear = 32] = "Clear";
})(x2 || (x2 = {}));
var W7;
(function(Z) {
  Z.is = r7.has, Z.All = x2.Highlight | x2.RemoveHighlight | x2.Select | x2.Deselect | x2.Toggle | x2.Clear, Z.Highlighting = x2.Highlight | x2.RemoveHighlight | x2.Clear, Z.Selecting = x2.Select | x2.Deselect | x2.Toggle | x2.Clear;
  function J($, X) {
    return $ === x2.Highlight && X === x2.RemoveHighlight || $ === x2.RemoveHighlight && X === x2.Highlight || $ === x2.Select && X === x2.Deselect || $ === x2.Deselect && X === x2.Select || $ === x2.Toggle && X === x2.Toggle;
  }
  Z.isReverse = J;
})(W7 || (W7 = {}));
function YA0(Z, J, $) {
  Z.fill(J, 0, $);
}
function Ct(Z, J, $) {
  switch ($) {
    case x2.Highlight:
      Z[J] |= 1;
      break;
    case x2.RemoveHighlight:
      Z[J] &= -2;
      break;
    case x2.Select:
      Z[J] |= 2;
      break;
    case x2.Deselect:
      Z[J] &= -3;
      break;
    case x2.Toggle:
      Z[J] ^= 2;
      break;
    case x2.Clear:
      Z[J] = 0;
      break;
  }
}
function yR(Z, J, $) {
  if ($ === x2.None)
    return !1;
  if (k0.is(J)) {
    let X = k0.start(J), Y = k0.end(J), Q = X + 3 >> 2, W = Q + (Y - 4 * Q >> 2);
    if (W <= Q) {
      for (let U = X;U < Y; ++U)
        Ct(Z, U, $);
      return !0;
    }
    let K = new Uint32Array(Z.buffer, 0, Z.buffer.byteLength >> 2), G = X, H = Math.min(4 * Q, Y), N = Math.max(X, 4 * W), q = Y;
    switch ($) {
      case x2.Highlight:
        for (let U = Q;U < W; ++U)
          K[U] |= 16843009;
        break;
      case x2.RemoveHighlight:
        for (let U = Q;U < W; ++U)
          K[U] &= -16843010;
        break;
      case x2.Select:
        for (let U = Q;U < W; ++U)
          K[U] |= 33686018;
        break;
      case x2.Deselect:
        for (let U = Q;U < W; ++U)
          K[U] &= -33686019;
        break;
      case x2.Toggle:
        for (let U = Q;U < W; ++U)
          K[U] ^= 33686018;
        break;
      case x2.Clear:
        for (let U = Q;U < W; ++U)
          K[U] = 0;
        break;
      default:
        T8($);
    }
    for (let U = G;U < H; ++U)
      Ct(Z, U, $);
    for (let U = N;U < q; ++U)
      Ct(Z, U, $);
  } else
    switch ($) {
      case x2.Highlight:
        for (let X = 0, Y = J.length;X < Y; ++X)
          Z[J[X]] |= 1;
        break;
      case x2.RemoveHighlight:
        for (let X = 0, Y = J.length;X < Y; ++X)
          Z[J[X]] &= -2;
        break;
      case x2.Select:
        for (let X = 0, Y = J.length;X < Y; ++X)
          Z[J[X]] |= 2;
        break;
      case x2.Deselect:
        for (let X = 0, Y = J.length;X < Y; ++X)
          Z[J[X]] &= -3;
        break;
      case x2.Toggle:
        for (let X = 0, Y = J.length;X < Y; ++X)
          Z[J[X]] ^= 2;
        break;
      case x2.Clear:
        for (let X = 0, Y = J.length;X < Y; ++X)
          Z[J[X]] = 0;
        break;
      default:
        T8($);
    }
  return !0;
}
function QA0(Z, J) {
  let $ = -1, X = -1;
  switch (Z) {
    case x2.Highlight:
      if (J === 0 || J === 1)
        $ = 1, X = 1;
      else if (J === 2 || J === 3)
        $ = 1, X = 3;
      else
        $ = 1;
      break;
    case x2.RemoveHighlight:
      if (J === 0 || J === 1)
        $ = 0, X = 0;
      else if (J === 2 || J === 3)
        $ = 1, X = 2;
      break;
    case x2.Select:
      if (J === 1 || J === 3)
        $ = 1, X = 3;
      else if (J === 0 || J === 2)
        $ = 1, X = 2;
      else
        $ = 1;
      break;
    case x2.Deselect:
      if (J === 1 || J === 3)
        $ = 1, X = 1;
      else if (J === 0 || J === 2)
        $ = 0, X = 0;
      break;
    case x2.Toggle:
      if (J === 1)
        $ = 1, X = 3;
      else if (J === 2)
        $ = 0, X = 0;
      else if (J === 3)
        $ = 1, X = 1;
      else if (J === 0)
        $ = 1, X = 2;
      break;
    case x2.Clear:
      $ = 0, X = 0;
      break;
  }
  return { average: $, status: X };
}
function WA0(Z, J) {
  switch (Z) {
    case x2.Highlight:
      return 0.5;
    case x2.RemoveHighlight:
      if (J === 0)
        return 0;
      else if (J === 2 || J === 3)
        return 0.5;
      else
        return -1;
    case x2.Select:
      return 0.5;
    case x2.Deselect:
      if (J === 1 || J === 3)
        return 0.5;
      else if (J === 0)
        return 0;
      else
        return -1;
    case x2.Toggle:
      if (J === -1)
        return -1;
      else
        return 0.5;
    case x2.Clear:
      if (J === -1)
        return -1;
      else if (J === 0)
        return 0;
      else
        return 0.5;
    case x2.None:
      return -1;
    default:
      T8(Z);
  }
}

// node_modules/molstar/lib/mol-theme/overpaint.js
function rJ(Z, J) {
  return { kind: Z, layers: J };
}
(function(Z) {
  Z.Empty = { kind: "empty-loci", layers: [] };
  function J(H, N) {
    if (H.layers.length === 0 && N.layers.length === 0)
      return !0;
    if (H.layers.length !== N.layers.length)
      return !1;
    for (let q = 0, U = H.layers.length;q < U; ++q) {
      if (H.layers[q].clear !== N.layers[q].clear)
        return !1;
      if (H.layers[q].color !== N.layers[q].color)
        return !1;
      if (!d2.areEqual(H.layers[q].loci, N.layers[q].loci))
        return !1;
    }
    return !0;
  }
  Z.areEqual = J;
  function $(H) {
    return H.layers.length === 0;
  }
  Z.isEmpty = $;
  function X(H, N) {
    if (H.kind === "element-loci") {
      let q = [];
      for (let U of H.layers) {
        let { loci: F, color: E, clear: R } = U;
        if (F = W0.Loci.remap(F, N), !W0.Loci.isEmpty(F))
          q.push({ loci: F, color: E, clear: R });
      }
      return { kind: "element-loci", layers: q };
    } else
      return H;
  }
  Z.remap = X;
  function Y(H) {
    if ($(H))
      return H;
    if (H.kind === "element-loci") {
      let { structure: N } = H.layers[0].loci, q = /* @__PURE__ */ new Map, U = W0.Loci.none(N);
      for (let E = 0, R = H.layers.length;E < R; ++E) {
        let { loci: z, color: D, clear: A } = H.layers[R - E - 1];
        if (z = W0.Loci.subtract(z, U), U = W0.Loci.union(z, U), !W0.Loci.isEmpty(z)) {
          let B = A ? -1 : D;
          if (q.has(B))
            z = W0.Loci.union(z, q.get(B));
          q.set(B, z);
        }
      }
      let F = [];
      return q.forEach((E, R) => {
        let z = R === -1, D = z ? i0(0) : R;
        F.push({ loci: E, color: D, clear: z });
      }), { kind: "element-loci", layers: F };
    } else
      return H;
  }
  Z.merge = Y;
  function Q(H, N) {
    if ($(H))
      return H;
    if (H.kind === "element-loci") {
      let { structure: q } = H.layers[0].loci, U = [];
      for (let F of H.layers) {
        let { loci: E, color: R, clear: z } = F, D = W0.Loci.remap(E, N);
        if (E = W0.Loci.remap(D, q), !W0.Loci.isEmpty(E))
          U.push({ loci: E, color: R, clear: z });
      }
      return { kind: "element-loci", layers: U };
    } else
      return H;
  }
  Z.filter = Q;
  function W(H, N) {
    let q = [];
    for (let U = 0, F = H.length;U < F; ++U) {
      let { script: E, color: R, clear: z } = H[U], D = cZ.toLoci(E, N);
      if (!W0.Loci.isEmpty(D))
        q.push({ loci: D, color: R, clear: z });
    }
    return { kind: "element-loci", layers: q };
  }
  Z.ofScript = W;
  function K(H, N) {
    let q = [];
    for (let U = 0, F = H.length;U < F; ++U) {
      let { bundle: E, color: R, clear: z } = H[U], D = W0.Bundle.toLoci(E, N.root);
      q.push({ loci: D, color: R, clear: z });
    }
    return { kind: "element-loci", layers: q };
  }
  Z.ofBundle = K;
  function G(H) {
    let N = [];
    for (let q = 0, U = H.layers.length;q < U; ++q) {
      let { loci: F, color: E, clear: R } = H.layers[q], z = W0.Bundle.fromLoci(F);
      N.push({ bundle: z, color: E, clear: R });
    }
    return { kind: "element-loci", layers: N };
  }
  Z.toBundle = G;
})(rJ || (rJ = {}));

// node_modules/molstar/lib/mol-theme/transparency.js
function tJ(Z, J) {
  return { kind: Z, layers: J };
}
(function(Z) {
  Z.Empty = { kind: "empty-loci", layers: [] };
  function J(H, N) {
    if (H.layers.length === 0 && N.layers.length === 0)
      return !0;
    if (H.layers.length !== N.layers.length)
      return !1;
    for (let q = 0, U = H.layers.length;q < U; ++q) {
      if (H.layers[q].value !== N.layers[q].value)
        return !1;
      if (!d2.areEqual(H.layers[q].loci, N.layers[q].loci))
        return !1;
    }
    return !0;
  }
  Z.areEqual = J;
  function $(H) {
    return H.layers.length === 0;
  }
  Z.isEmpty = $;
  function X(H, N) {
    if (H.kind === "element-loci") {
      let q = [];
      for (let U of H.layers) {
        let F = W0.Loci.remap(U.loci, N);
        if (!W0.Loci.isEmpty(F))
          q.push({ loci: F, value: U.value });
      }
      return { kind: "element-loci", layers: q };
    } else
      return H;
  }
  Z.remap = X;
  function Y(H) {
    if ($(H))
      return H;
    if (H.kind === "element-loci") {
      let { structure: N } = H.layers[0].loci, q = /* @__PURE__ */ new Map, U = W0.Loci.none(N);
      for (let E = 0, R = H.layers.length;E < R; ++E) {
        let { loci: z, value: D } = H.layers[R - E - 1];
        if (z = W0.Loci.subtract(z, U), U = W0.Loci.union(z, U), !W0.Loci.isEmpty(z)) {
          if (q.has(D))
            z = W0.Loci.union(z, q.get(D));
          q.set(D, z);
        }
      }
      let F = [];
      return q.forEach((E, R) => {
        F.push({ loci: E, value: R });
      }), { kind: "element-loci", layers: F };
    } else
      return H;
  }
  Z.merge = Y;
  function Q(H, N) {
    if ($(H))
      return H;
    if (H.kind === "element-loci") {
      let { structure: q } = H.layers[0].loci, U = [];
      for (let F of H.layers) {
        let { loci: E, value: R } = F, z = W0.Loci.remap(E, N);
        if (E = W0.Loci.remap(z, q), !W0.Loci.isEmpty(E))
          U.push({ loci: E, value: R });
      }
      return { kind: "element-loci", layers: U };
    } else
      return H;
  }
  Z.filter = Q;
  function W(H, N) {
    let q = [];
    for (let U = 0, F = H.length;U < F; ++U) {
      let { script: E, value: R } = H[U], z = cZ.toLoci(E, N);
      if (!W0.Loci.isEmpty(z))
        q.push({ loci: z, value: R });
    }
    return { kind: "element-loci", layers: q };
  }
  Z.ofScript = W;
  function K(H, N) {
    let q = [];
    for (let U = 0, F = H.length;U < F; ++U) {
      let { bundle: E, value: R } = H[U], z = W0.Bundle.toLoci(E, N.root);
      q.push({ loci: z, value: R });
    }
    return { kind: "element-loci", layers: q };
  }
  Z.ofBundle = K;
  function G(H) {
    let N = [];
    for (let q = 0, U = H.layers.length;q < U; ++q) {
      let { loci: F, value: E } = H.layers[q], R = W0.Bundle.fromLoci(F);
      N.push({ bundle: R, value: E });
    }
    return { kind: "element-loci", layers: N };
  }
  Z.toBundle = G;
})(tJ || (tJ = {}));

// node_modules/molstar/lib/mol-repr/util.js
var S5;
(function(Z) {
  function J() {
    return {
      updateTransform: !1,
      updateMatrix: !1,
      updateColor: !1,
      updateSize: !1,
      createGeometry: !1,
      createNew: !1,
      info: {}
    };
  }
  Z.create = J;
  function $(X) {
    X.updateTransform = !1, X.updateMatrix = !1, X.updateColor = !1, X.updateSize = !1, X.createGeometry = !1, X.createNew = !1;
  }
  Z.reset = $;
})(S5 || (S5 = {}));
var RK1 = {
  lowestElementCount: 1e6,
  lowerElementCount: 500000,
  lowElementCount: 1e5,
  mediumElementCount: 20000,
  highElementCount: 2000,
  coarseGrainedFactor: 10,
  elementCountFactor: 1
}, LQ;
(function(Z) {
  Z[Z.Lowest = 0] = "Lowest", Z[Z.Lower = 1] = "Lower", Z[Z.Low = 2] = "Low", Z[Z.Medium = 3] = "Medium", Z[Z.High = 4] = "High", Z[Z.Higher = 5] = "Higher", Z[Z.Highest = 6] = "Highest";
})(LQ || (LQ = {}));
function EK1(Z) {
  switch (Z) {
    case "lowest":
      return LQ.Lowest;
    case "lower":
      return LQ.Lower;
    case "low":
      return LQ.Low;
    case "medium":
      return LQ.Medium;
    case "high":
      return LQ.High;
    case "higher":
      return LQ.Higher;
    case "highest":
      return LQ.Highest;
  }
}
function kt(Z, J = {}) {
  let $ = { ...RK1, ...J }, X = Z.elementCount * $.elementCountFactor;
  if (Z.isCoarseGrained || Z.isCoarse)
    X *= $.coarseGrainedFactor;
  if (X > $.lowestElementCount)
    return "lowest";
  else if (X > $.lowerElementCount)
    return "lower";
  else if (X > $.lowElementCount)
    return "low";
  else if (X > $.mediumElementCount)
    return "medium";
  else if (X > $.highElementCount)
    return "high";
  else
    return "higher";
}
function OK1(Z) {
  if (Z.root.models.length === 1) {
    let J = T9.Provider.get(Z.root.model);
    if (J && J.spacegroup.name === "P 1" && !d7.isZero(J.spacegroup.cell))
      return J.spacegroup.cell.volume;
  }
  return t1.volume(Z.root.boundary.box);
}
function vV(Z, J) {
  let $ = t7(Z.quality, "auto"), X = t7(Z.detail, 1), Y = t7(Z.radialSegments, 12), Q = t7(Z.linearSegments, 8), W = t7(Z.resolution, 2), K = t7(Z.imageResolution, 1), G = t7(Z.probePositions, 12), H = t7(Z.doubleSided, !0), N = 0;
  if ($ === "auto") {
    if (J instanceof s0)
      $ = kt(J.root), N = OK1(J);
    else if (Q1.is(J)) {
      let [q, U, F] = J.grid.cells.space.dimensions;
      N = q * U * F, $ = N < 1e7 ? "medium" : "low";
    }
  }
  if ($ !== "custom" && $ !== "auto") {
    let q = EK1($);
    if (XU0())
      q = Math.max(q - 1, LQ.Lowest);
    switch (q) {
      case LQ.Highest:
        X = 3, Y = 36, Q = 18, W = 0.1, K = 0.01, G = 72, H = !0;
        break;
      case LQ.Higher:
        X = 3, Y = 28, Q = 14, W = 0.3, K = 0.05, G = 48, H = !0;
        break;
      case LQ.High:
        X = 2, Y = 20, Q = 10, W = 0.5, K = 0.1, G = 36, H = !0;
        break;
      case LQ.Medium:
        X = 1, Y = 12, Q = 8, W = 0.8, K = 0.2, G = 24, H = !0;
        break;
      case LQ.Low:
        X = 0, Y = 8, Q = 3, W = 1.3, K = 0.4, G = 24, H = !1;
        break;
      case LQ.Lower:
        X = 0, Y = 4, Q = 2, W = 3, K = 0.7, G = 12, H = !1;
        break;
      case LQ.Lowest:
        X = 0, Y = 2, Q = 1, W = 8, K = 1, G = 12, H = !1;
        break;
    }
  }
  if (N > 0)
    W = Math.max(W, N / 300000000), W = Math.min(W, 20);
  if (Z.transparentBackfaces === "off" && (Z.alpha !== void 0 && Z.alpha < 1 || !!Z.xrayShaded))
    H = !1;
  return {
    detail: X,
    radialSegments: Y,
    linearSegments: Q,
    resolution: W,
    imageResolution: K,
    probePositions: G,
    doubleSided: H
  };
}

// node_modules/molstar/lib/mol-util/number-conversion.js
var hb = zK1();
function zK1() {
  let Z = new ArrayBuffer(4), J = new Float32Array(Z), $ = new Uint32Array(Z), X = new Uint32Array(512), Y = new Uint32Array(512);
  for (let G = 0;G < 256; ++G) {
    let H = G - 127;
    if (H < -27)
      X[G] = 0, X[G | 256] = 32768, Y[G] = 24, Y[G | 256] = 24;
    else if (H < -14)
      X[G] = 1024 >> -H - 14, X[G | 256] = 1024 >> -H - 14 | 32768, Y[G] = -H - 1, Y[G | 256] = -H - 1;
    else if (H <= 15)
      X[G] = H + 15 << 10, X[G | 256] = H + 15 << 10 | 32768, Y[G] = 13, Y[G | 256] = 13;
    else if (H < 128)
      X[G] = 31744, X[G | 256] = 64512, Y[G] = 24, Y[G | 256] = 24;
    else
      X[G] = 31744, X[G | 256] = 64512, Y[G] = 13, Y[G | 256] = 13;
  }
  let Q = new Uint32Array(2048), W = new Uint32Array(64), K = new Uint32Array(64);
  for (let G = 1;G < 1024; ++G) {
    let H = G << 13, N = 0;
    while ((H & 8388608) === 0)
      H <<= 1, N -= 8388608;
    H &= -8388609, N += 947912704, Q[G] = H | N;
  }
  for (let G = 1024;G < 2048; ++G)
    Q[G] = 939524096 + (G - 1024 << 13);
  for (let G = 1;G < 31; ++G)
    W[G] = G << 23;
  W[31] = 1199570944, W[32] = 2147483648;
  for (let G = 33;G < 63; ++G)
    W[G] = 2147483648 + (G - 32 << 23);
  W[63] = 3347054592;
  for (let G = 1;G < 64; ++G)
    if (G !== 32)
      K[G] = 1024;
  return {
    floatView: J,
    uint32View: $,
    baseTable: X,
    shiftTable: Y,
    mantissaTable: Q,
    exponentTable: W,
    offsetTable: K
  };
}
function m3(Z) {
  Z = x8(Z, -65504, 65504), hb.floatView[0] = Z;
  let J = hb.uint32View[0], $ = J >> 23 & 511;
  return hb.baseTable[$] + ((J & 8388607) >> hb.shiftTable[$]);
}

// node_modules/molstar/lib/mol-repr/volume/util.js
var bb = M.set, KA0 = M.normalize, GA0 = M.sub, HA0 = M.addScalar, xb = M.scale, yb = M.toArray;
function qq(Z, J, $, X) {
  let Y = !1, Q = J.grid.cells.data.length;
  if (Q1.isLoci(Z)) {
    if (!Q1.areEquivalent(Z.volume, J))
      return !1;
    if (k0.is(Z.instances)) {
      let W = k0.start(Z.instances) * Q, K = k0.end(Z.instances) * Q;
      if (X(k0.ofBounds(W, K)))
        Y = !0;
    } else
      for (let W = 0, K = Z.instances.length;W < K; ++W) {
        let G = Z.instances[W] * Q;
        if (X(k0.ofBounds(G, G + Q)))
          Y = !0;
      }
  } else if (Q1.Isosurface.isLoci(Z)) {
    if (!Q1.areEquivalent(Z.volume, J))
      return !1;
    if ($ === null || $ === void 0 ? void 0 : $.isoValue) {
      if (!Q1.IsoValue.areSame(Z.isoValue, $.isoValue, J.grid.stats))
        return !1;
      if (k0.is(Z.instances)) {
        let W = k0.start(Z.instances) * Q, K = k0.end(Z.instances) * Q;
        if (X(k0.ofBounds(W, K)))
          Y = !0;
      } else
        for (let W = 0, K = Z.instances.length;W < K; ++W) {
          let G = Z.instances[W] * Q;
          if (X(k0.ofBounds(G, G + Q)))
            Y = !0;
        }
    } else {
      let { stats: W, cells: { data: K } } = J.grid, G = W.sigma, H = Q1.IsoValue.toAbsolute(Z.isoValue, W).absoluteValue;
      for (let N = 0, q = K.length;N < q; ++N)
        if (dZ(H, K[N], G))
          f0.forEach(Z.instances, (U) => {
            let F = U * Q;
            if (X(k0.ofSingleton(F + N)))
              Y = !0;
          });
    }
  } else if (Q1.Cell.isLoci(Z)) {
    if (!Q1.areEquivalent(Z.volume, J))
      return !1;
    for (let { indices: W, instances: K } of Z.elements)
      if (k0.is(W))
        f0.forEach(K, (G) => {
          let H = G * Q;
          if (X(k0.offset(W, H)))
            Y = !0;
        });
      else
        f0.forEach(W, (G) => {
          f0.forEach(K, (H) => {
            let N = H * Q;
            if (X(k0.ofSingleton(N + G)))
              Y = !0;
          });
        });
  } else if (Q1.Segment.isLoci(Z)) {
    if (!Q1.areEquivalent(Z.volume, J))
      return !1;
    if ($ === null || $ === void 0 ? void 0 : $.segments) {
      for (let { segments: W, instances: K } of Z.elements)
        if (f0.areIntersecting(W, $.segments))
          f0.forEach(K, (G) => {
            let H = G * Q;
            if (X(k0.ofBounds(H, H + Q)))
              Y = !0;
          });
    } else {
      let W = Q1.Segmentation.get(J);
      if (W) {
        let K = /* @__PURE__ */ new Set;
        for (let { segments: G, instances: H } of Z.elements) {
          for (let U = 0, F = f0.size(G);U < F; U++) {
            let E = f0.getAt(G, U);
            uZ.add(K, W.segments.get(E));
          }
          let N = Array.from(K.values()), q = J.grid.cells.data;
          for (let U = 0, F = q.length;U < F; ++U)
            if (N.includes(q[U]))
              for (let E = 0, R = f0.size(H);E < R; E++) {
                let z = E * Q;
                if (X(k0.ofSingleton(U + z)))
                  Y = !0;
              }
        }
      }
    }
  }
  return Y;
}
function d3(Z) {
  let [J, $, X] = Z.grid.cells.space.dimensions, Y = J * $ * X, Q = Z.instances.length, W = Q1.Cell.Location(Z);
  return X6(Y, Q, 1, (G, H) => {
    return W.cell = G, W.instance = H, W;
  });
}
function p3(Z, J = 0) {
  let $ = Z[0] * Z[1] * Z[2], X = Math.sqrt($), Y = Math.pow(2, Math.ceil(Math.log(X) / Math.log(2))), Q = Z[0] + J, W = Z[1] + J, K = 1, G = Q;
  if (Y < Q * Z[2])
    G = Math.floor(Y / Q), K = Math.ceil(Z[2] / G), Q *= G, W *= K;
  else
    Q *= Z[2];
  return { width: Q, height: W, columns: G, rows: K, powerOfTwoSize: W < Y ? Y : Y * 2 };
}
function gb(Z, J, $ = 0, X = "byte") {
  let { cells: { space: Y, data: Q }, stats: { max: W, min: K } } = Z.grid, G = Y.dimensions, { dataOffset: H } = Y, { width: N, height: q } = p3(G, $), U = J === "data" ? 1 : 4, F = X === "byte" ? new Uint8Array(N * q * U) : X === "halfFloat" ? new Uint16Array(N * q * U) : new Float32Array(N * q * U), E = { array: F, width: N, height: q }, R = W - K, [z, D, A] = G, B = z + $, T = D + $, w = M(), V = M(), P = z - 1, I = D - 1, S = A - 1;
  for (let f = 0;f < A; ++f)
    for (let v = 0;v < D; ++v)
      for (let h = 0;h < z; ++h) {
        let x = Math.floor(f * B % N / B), b = Math.floor(f * B / N), g = x * B + h, m = U * (b * T * N + v * N + g), i = H(h, v, f), r;
        if (X === "byte")
          r = Math.round((Q[i] - K) / R * 255);
        else if (X === "halfFloat")
          r = m3((Q[i] - K) / R);
        else
          r = (Q[i] - K) / R;
        if (J === "data")
          F[m] = r;
        else {
          if (J === "groups")
            if (X === "halfFloat") {
              let Y0 = x8(Math.round(i), 0, 16777215) + 1;
              F[m + 2] = m3(Y0 % 256), Y0 = Math.floor(Y0 / 256), F[m + 1] = m3(Y0 % 256), Y0 = Math.floor(Y0 / 256), F[m] = m3(Y0 % 256);
            } else
              UH(i, F, m);
          else if (bb(w, Q[H(Math.max(0, h - 1), v, f)], Q[H(h, Math.max(0, v - 1), f)], Q[H(h, v, Math.max(0, f - 1))]), bb(V, Q[H(Math.min(P, h + 1), v, f)], Q[H(h, Math.min(I, v + 1), f)], Q[H(h, v, Math.min(S, f + 1))]), KA0(w, GA0(w, w, V)), HA0(w, xb(w, w, 0.5), 0.5), X === "byte")
            yb(xb(w, w, 255), F, m);
          else if (X === "halfFloat")
            F[m] = m3(w[0]), F[m + 1] = m3(w[1]), F[m + 2] = m3(w[2]);
          else
            yb(w, F, m);
          F[m + 3] = r;
        }
      }
  return E;
}
function NA0(Z, J = "byte") {
  let { cells: { space: $, data: X }, stats: { max: Y, min: Q } } = Z.grid, [W, K, G] = $.dimensions, { dataOffset: H } = $, N = J === "byte" ? new Uint8Array(W * K * G * 4) : J === "halfFloat" ? new Uint16Array(W * K * G * 4) : new Float32Array(W * K * G * 4), q = { array: N, width: W, height: K, depth: G }, U = Y - Q, F = M(), E = M(), R = W - 1, z = K - 1, D = G - 1, A = 0;
  for (let B = 0;B < G; ++B)
    for (let T = 0;T < K; ++T)
      for (let w = 0;w < W; ++w) {
        let V = H(w, T, B);
        if (bb(F, X[H(Math.max(0, w - 1), T, B)], X[H(w, Math.max(0, T - 1), B)], X[H(w, T, Math.max(0, B - 1))]), bb(E, X[H(Math.min(R, w + 1), T, B)], X[H(w, Math.min(z, T + 1), B)], X[H(w, T, Math.min(D, B + 1))]), KA0(F, GA0(F, F, E)), HA0(F, xb(F, F, 0.5), 0.5), J === "byte")
          yb(xb(F, F, 255), N, A), N[A + 3] = Math.round((X[V] - Q) / U * 255);
        else if (J === "halfFloat")
          N[A] = m3(F[0]), N[A + 1] = m3(F[1]), N[A + 2] = m3(F[2]), N[A + 3] = m3((X[V] - Q) / U);
        else
          yb(F, N, A), N[A + 3] = (X[V] - Q) / U;
        A += 4;
      }
  return q;
}
function qA0(Z, J, $, X = 0) {
  let Y = Z.grid.cells.data, Q = t1.size(M(), $), W = Z.grid.cells.space.dataOffset, { width: K, height: G } = p3(Q, X), H = 1, N = new Uint8Array(K * G * 1), q = { array: N, width: K, height: G }, [U, F, E] = Q, R = U - 1, z = F - 1, D = E - 1, A = U + X, B = F + X, [T, w, V] = $.min, [P, I, S] = $.max;
  for (let f = 0;f < E; ++f)
    for (let v = 0;v < F; ++v)
      for (let h = 0;h < U; ++h) {
        let x = Math.floor(f * A % K / A), b = Math.floor(f * A / K), g = x * A + h, m = 1 * (b * B * K + v * K + g), i = J.includes(Y[W(h + T, v + w, f + V)]) ? 255 : 0, r = J.includes(Y[W(Math.min(R + P, h + 1 + T), v + w, f + V)]) ? 255 : 0, Y0 = J.includes(Y[W(Math.max(0, h - 1 + T), v + w, f + V)]) ? 255 : 0, c = J.includes(Y[W(h + T, Math.min(z + I, v + 1 + w), f + V)]) ? 255 : 0, n = J.includes(Y[W(h + T, Math.max(0, v - 1 + w), f + V)]) ? 255 : 0, l = J.includes(Y[W(h + T, v + w, Math.min(D + S, f + 1 + V))]) ? 255 : 0, u = J.includes(Y[W(h + T, v + w, Math.max(0, f - 1 + V))]) ? 255 : 0;
        N[m] = Math.round((i + i + r + Y0 + c + n + l + u) / 8);
      }
  return q;
}
function mb(Z) {
  let { grid: J } = Z, { space: $ } = J.cells, { get: X, set: Y, add: Q, dataOffset: W } = $, [K, G, H] = $.dimensions, N = M.create(K + 1, G + 1, H + 1), R = {
    ...$,
    dimensions: N,
    get: (B, T, w, V) => X(B, T % K, w % G, V % H),
    set: (B, T, w, V, P) => Y(B, T % K, w % G, V % H, P),
    add: (B, T, w, V, P) => Q(B, T % K, w % G, V % H, P),
    dataOffset: (B, T, w) => W(B % K, T % G, w % H)
  }, D = { kind: "matrix", matrix: s6.getGridToCartesianTransform(Z.grid) }, A = {
    ...J,
    transform: D,
    cells: {
      ...J.cells,
      space: R
    }
  };
  return {
    ...Z,
    grid: A
  };
}

// node_modules/molstar/lib/mol-geo/geometry/mesh/color-smoothing.js
function SV(Z, J, $, X, Y) {
  let { colorType: Q, vertexCount: W, groupCount: K, positionBuffer: G, instanceBuffer: H, transformBuffer: N, groupBuffer: q, itemSize: U } = Z, F = Q.endsWith("Instance"), E = t1.fromSphere3D(t1(), F ? Z.boundingSphere : Z.invariantBoundingSphere), R = 1 + J, z = t1.expand(t1(), E, M.create(R, R, R)), D = 1 / J, A = t1.scale(t1(), z, D), B = t1.size(M(), A);
  M.ceil(B, B), M.add(B, B, M.create(2, 2, 2));
  let { min: T } = z, [w, V] = B, { width: P, height: I } = p3(B), S = new Float32Array(P * I * U), f = new Float32Array(P * I), v = new Uint8Array(P * I * U), h = { array: v, width: P, height: I, filter: "linear" }, x = F ? Z.instanceCount : 1, b = Z.colorData.array;
  function g(G0, F0, t) {
    let Z0 = Math.floor(t * w % P / w), U0 = Math.floor(t * w / P), a = Z0 * w + G0;
    return U * (U0 * V * P + F0 * P + a);
  }
  let m = 2, [i, r, Y0] = B, c = M();
  for (let G0 = 0;G0 < x; ++G0) {
    let F0 = X ? H[G0] : G0;
    for (let t = 0;t < W; t += $) {
      if (M.fromArray(c, G, t * 3), F)
        M.transformMat4Offset(c, c, N, 0, 0, G0 * 16);
      M.sub(c, c, T), M.scale(c, c, D);
      let [Z0, U0, a] = c, Q0 = Math.floor(Z0), $0 = Math.floor(U0), R0 = Math.floor(a), X0 = (F0 * K + q[t]) * U, E0 = Math.max(0, Q0 - m), V0 = Math.max(0, $0 - m), u0 = Math.max(0, R0 - m), N0 = Math.min(i, Q0 + m + 2), q0 = Math.min(r, $0 + m + 2), A0 = Math.min(Y0, R0 + m + 2);
      for (let S0 = E0;S0 < N0; ++S0) {
        let a0 = S0 - Z0;
        for (let D1 = V0;D1 < q0; ++D1) {
          let Y1 = D1 - U0;
          for (let u1 = u0;u1 < A0; ++u1) {
            let b0 = u1 - a, x0 = Math.sqrt(a0 * a0 + Y1 * Y1 + b0 * b0);
            if (x0 > m)
              continue;
            let m0 = m - x0, e0 = g(S0, D1, u1);
            for (let p = 0;p < U; ++p)
              S[e0 + p] += b[X0 + p] * m0;
            f[e0 / U] += m0;
          }
        }
      }
    }
  }
  for (let G0 = 0, F0 = f.length;G0 < F0; ++G0) {
    let t = G0 * U, Z0 = f[G0];
    for (let U0 = 0;U0 < U; ++U0)
      v[t + U0] = Math.round(S[t + U0] / Z0);
  }
  let n = h0.create(P, I), l = E2.create(T[0], T[1], T[2], D), u = F ? "volumeInstance" : "volume";
  if (X) {
    if (!Y) {
      let G0 = U === 4 ? "rgba" : U === 3 ? "rgb" : "alpha";
      Y = X.resources.texture("image-uint8", G0, "ubyte", "linear");
    }
    return Y.load(h), { kind: "volume", texture: Y, gridTexDim: n, gridDim: B, gridTransform: l, type: u };
  } else {
    let G0 = DK1({ vertexCount: W, instanceCount: x, transformBuffer: N, positionBuffer: G, colorType: u, grid: v, gridDim: B, gridTexDim: n, gridTransform: l, vertexStride: 3, colorStride: U, outputStride: U });
    return {
      kind: "vertex",
      texture: G0,
      texDim: h0.create(G0.width, G0.height),
      type: F ? "vertexInstance" : "vertex"
    };
  }
}
function DK1(Z) {
  let { vertexCount: J, positionBuffer: $, transformBuffer: X, grid: Y, gridDim: Q, gridTexDim: W, gridTransform: K, vertexStride: G, colorStride: H } = Z, N = Z.itemOffset || 0, q = Z.outputStride;
  if (q + N > H)
    throw new Error("outputStride + itemOffset must NOT be larger than colorStride");
  let U = Z.colorType.endsWith("Instance"), F = U ? Z.instanceCount : 1, E = Z9(Math.max(1, F * J), q, Uint8Array), { array: R } = E, [z, D] = Q, A = W[0], B = M.fromArray(M(), K, 0), T = K[3];
  function w(f, v, h) {
    let x = Math.floor(h * z % A / z), b = Math.floor(h * z / A), g = x * z + f;
    return H * (b * D * A + v * A + g);
  }
  let V = M(), P = M(), I = M(), S = M();
  for (let f = 0;f < F; ++f)
    for (let v = 0;v < J; ++v) {
      if (M.fromArray(V, $, v * G), U)
        M.transformMat4Offset(V, V, X, 0, 0, f * 16);
      M.sub(V, V, B), M.scale(V, V, T), M.floor(P, V), M.ceil(I, V), M.sub(S, V, P), M.sub(V, I, P), M.div(S, S, V);
      let [h, x, b] = P, [g, m, i] = I, [r, Y0, c] = S, n = w(h, x, b) + N, l = w(g, x, b) + N, u = w(h, x, i) + N, G0 = w(g, x, i) + N, F0 = w(h, m, b) + N, t = w(g, m, b) + N, Z0 = w(h, m, i) + N, U0 = w(g, m, i) + N, a = (f * J + v) * q;
      for (let Q0 = 0;Q0 < q; ++Q0) {
        let $0 = Y[n + Q0], R0 = Y[l + Q0], X0 = Y[u + Q0], E0 = Y[G0 + Q0], V0 = Y[F0 + Q0], u0 = Y[t + Q0], N0 = Y[Z0 + Q0], q0 = Y[U0 + Q0], A0 = pZ($0, R0, r), S0 = pZ(X0, E0, r), a0 = pZ(V0, u0, r), D1 = pZ(N0, q0, r), Y1 = pZ(A0, a0, Y0), u1 = pZ(S0, D1, Y0);
        R[a + Q0] = pZ(Y1, u1, c);
      }
    }
  return E;
}
function MK1(Z) {
  return Z === "group" || Z === "groupInstance";
}
function bA(Z, J, $, X, Y) {
  if (!MK1(Z.dColorType.ref.value))
    return;
  let Q = SV({
    vertexCount: Z.uVertexCount.ref.value,
    instanceCount: Z.uInstanceCount.ref.value,
    groupCount: Z.uGroupCount.ref.value,
    transformBuffer: Z.aTransform.ref.value,
    instanceBuffer: Z.aInstance.ref.value,
    positionBuffer: Z.aPosition.ref.value,
    groupBuffer: Z.aGroup.ref.value,
    colorData: Z.tColor.ref.value,
    colorType: Z.dColorType.ref.value,
    boundingSphere: Z.boundingSphere.ref.value,
    invariantBoundingSphere: Z.invariantBoundingSphere.ref.value,
    itemSize: 3
  }, J, $, X, Y);
  if (Q.kind === "volume")
    C.updateIfChanged(Z.dColorType, Q.type), C.update(Z.tColorGrid, Q.texture), C.update(Z.uColorTexDim, Q.gridTexDim), C.update(Z.uColorGridDim, Q.gridDim), C.update(Z.uColorGridTransform, Q.gridTransform);
  else if (Q.kind === "vertex")
    C.updateIfChanged(Z.dColorType, Q.type), C.update(Z.tColor, Q.texture), C.update(Z.uColorTexDim, Q.texDim);
}
function AK1(Z) {
  return Z === "groupInstance";
}
function FA0(Z, J, $, X, Y) {
  if (!AK1(Z.dOverpaintType.ref.value))
    return;
  let Q = SV({
    vertexCount: Z.uVertexCount.ref.value,
    instanceCount: Z.uInstanceCount.ref.value,
    groupCount: Z.uGroupCount.ref.value,
    transformBuffer: Z.aTransform.ref.value,
    instanceBuffer: Z.aInstance.ref.value,
    positionBuffer: Z.aPosition.ref.value,
    groupBuffer: Z.aGroup.ref.value,
    colorData: Z.tOverpaint.ref.value,
    colorType: Z.dOverpaintType.ref.value,
    boundingSphere: Z.boundingSphere.ref.value,
    invariantBoundingSphere: Z.invariantBoundingSphere.ref.value,
    itemSize: 4
  }, J, $, X, Y);
  if (Q.kind === "volume")
    C.updateIfChanged(Z.dOverpaintType, Q.type), C.update(Z.tOverpaintGrid, Q.texture), C.update(Z.uOverpaintTexDim, Q.gridTexDim), C.update(Z.uOverpaintGridDim, Q.gridDim), C.update(Z.uOverpaintGridTransform, Q.gridTransform);
  else if (Q.kind === "vertex")
    C.updateIfChanged(Z.dOverpaintType, Q.type), C.update(Z.tOverpaint, Q.texture), C.update(Z.uOverpaintTexDim, Q.texDim);
}
function BK1(Z) {
  return Z === "groupInstance";
}
function UA0(Z, J, $, X, Y) {
  if (!BK1(Z.dTransparencyType.ref.value))
    return;
  let Q = SV({
    vertexCount: Z.uVertexCount.ref.value,
    instanceCount: Z.uInstanceCount.ref.value,
    groupCount: Z.uGroupCount.ref.value,
    transformBuffer: Z.aTransform.ref.value,
    instanceBuffer: Z.aInstance.ref.value,
    positionBuffer: Z.aPosition.ref.value,
    groupBuffer: Z.aGroup.ref.value,
    colorData: Z.tTransparency.ref.value,
    colorType: Z.dTransparencyType.ref.value,
    boundingSphere: Z.boundingSphere.ref.value,
    invariantBoundingSphere: Z.invariantBoundingSphere.ref.value,
    itemSize: 1
  }, J, $, X, Y);
  if (Q.kind === "volume")
    C.updateIfChanged(Z.dTransparencyType, Q.type), C.update(Z.tTransparencyGrid, Q.texture), C.update(Z.uTransparencyTexDim, Q.gridTexDim), C.update(Z.uTransparencyGridDim, Q.gridDim), C.update(Z.uTransparencyGridTransform, Q.gridTransform);
  else if (Q.kind === "vertex")
    C.updateIfChanged(Z.dTransparencyType, Q.type), C.update(Z.tTransparency, Q.texture), C.update(Z.uTransparencyTexDim, Q.texDim);
}
function wK1(Z) {
  return Z === "groupInstance";
}
function LA0(Z, J, $, X, Y) {
  if (!wK1(Z.dEmissiveType.ref.value))
    return;
  let Q = SV({
    vertexCount: Z.uVertexCount.ref.value,
    instanceCount: Z.uInstanceCount.ref.value,
    groupCount: Z.uGroupCount.ref.value,
    transformBuffer: Z.aTransform.ref.value,
    instanceBuffer: Z.aInstance.ref.value,
    positionBuffer: Z.aPosition.ref.value,
    groupBuffer: Z.aGroup.ref.value,
    colorData: Z.tEmissive.ref.value,
    colorType: Z.dEmissiveType.ref.value,
    boundingSphere: Z.boundingSphere.ref.value,
    invariantBoundingSphere: Z.invariantBoundingSphere.ref.value,
    itemSize: 1
  }, J, $, X, Y);
  if (Q.kind === "volume")
    C.updateIfChanged(Z.dEmissiveType, Q.type), C.update(Z.tEmissiveGrid, Q.texture), C.update(Z.uEmissiveTexDim, Q.gridTexDim), C.update(Z.uEmissiveGridDim, Q.gridDim), C.update(Z.uEmissiveGridTransform, Q.gridTransform);
  else if (Q.kind === "vertex")
    C.updateIfChanged(Z.dEmissiveType, Q.type), C.update(Z.tEmissive, Q.texture), C.update(Z.uEmissiveTexDim, Q.texDim);
}
function jK1(Z) {
  return Z === "groupInstance";
}
function RA0(Z, J, $, X, Y) {
  if (!jK1(Z.dSubstanceType.ref.value))
    return;
  let Q = SV({
    vertexCount: Z.uVertexCount.ref.value,
    instanceCount: Z.uInstanceCount.ref.value,
    groupCount: Z.uGroupCount.ref.value,
    transformBuffer: Z.aTransform.ref.value,
    instanceBuffer: Z.aInstance.ref.value,
    positionBuffer: Z.aPosition.ref.value,
    groupBuffer: Z.aGroup.ref.value,
    colorData: Z.tSubstance.ref.value,
    colorType: Z.dSubstanceType.ref.value,
    boundingSphere: Z.boundingSphere.ref.value,
    invariantBoundingSphere: Z.invariantBoundingSphere.ref.value,
    itemSize: 4
  }, J, $, X, Y);
  if (Q.kind === "volume")
    C.updateIfChanged(Z.dSubstanceType, Q.type), C.update(Z.tSubstanceGrid, Q.texture), C.update(Z.uSubstanceTexDim, Q.gridTexDim), C.update(Z.uSubstanceGridDim, Q.gridDim), C.update(Z.uSubstanceGridTransform, Q.gridTransform);
  else if (Q.kind === "vertex")
    C.updateIfChanged(Z.dSubstanceType, Q.type), C.update(Z.tSubstance, Q.texture), C.update(Z.uSubstanceTexDim, Q.texDim);
}

// node_modules/molstar/lib/mol-gl/shader/compute/color-smoothing/normalize.frag.js
var EA0 = `
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;
}
`;

// node_modules/molstar/lib/mol-gl/shader/compute/color-smoothing/accumulate.frag.js
var OA0 = `
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);
}
`;

// node_modules/molstar/lib/mol-gl/shader/compute/color-smoothing/accumulate.vert.js
var zA0 = `
precision highp float;

#include common
#include read_from_texture

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
}
`;

// node_modules/molstar/lib/mol-geo/geometry/texture-mesh/color-smoothing.js
var TK1 = {
  drawCount: zZ("number"),
  instanceCount: zZ("number"),
  stride: zZ("number"),
  uGroupCount: _0("i", "material"),
  aTransform: a6("float32", 16, 1),
  aInstance: a6("float32", 1, 1),
  aSample: a6("float32", 1, 0),
  uGeoTexDim: _0("v2", "material"),
  tPosition: o1("texture", "rgba", "float", "nearest", "material"),
  tGroup: o1("texture", "rgba", "float", "nearest", "material"),
  uColorTexDim: _0("v2", "material"),
  tColor: o1("texture", "rgba", "ubyte", "nearest", "material"),
  dColorType: p1("string", ["group", "groupInstance", "vertex", "vertexInstance"]),
  uCurrentSlice: _0("f"),
  uCurrentX: _0("f"),
  uCurrentY: _0("f"),
  uBboxMin: _0("v3", "material"),
  uBboxSize: _0("v3", "material"),
  uResolution: _0("f", "material")
}, vK = "color-accumulate", fV = "color-count";
function DA0(Z, J) {
  let $ = new Float32Array(Z);
  for (let X = 0;X < Z; ++X)
    $[X] = X * J;
  return $;
}
function _K1(Z, J, $, X, Y) {
  if (Z.namedComputeRenderables[vK]) {
    let Q = M.sub(M(), $.max, $.min), W = Z.namedComputeRenderables[vK].values, K = Math.round(J.vertexCount / Y);
    if (K > W.drawCount.ref.value || Y !== W.stride.ref.value)
      C.update(W.aSample, DA0(K, Y));
    C.updateIfChanged(W.drawCount, K), C.updateIfChanged(W.instanceCount, J.instanceCount), C.updateIfChanged(W.stride, Y), C.updateIfChanged(W.uGroupCount, J.groupCount), C.update(W.aTransform, J.transformBuffer), C.update(W.aInstance, J.instanceBuffer), C.update(W.uGeoTexDim, h0.set(W.uGeoTexDim.ref.value, J.positionTexture.getWidth(), J.positionTexture.getHeight())), C.update(W.tPosition, J.positionTexture), C.update(W.tGroup, J.groupTexture), C.update(W.uColorTexDim, h0.set(W.uColorTexDim.ref.value, J.colorData.getWidth(), J.colorData.getHeight())), C.update(W.tColor, J.colorData), C.updateIfChanged(W.dColorType, J.colorType), C.updateIfChanged(W.uCurrentSlice, 0), C.updateIfChanged(W.uCurrentX, 0), C.updateIfChanged(W.uCurrentY, 0), C.update(W.uBboxMin, $.min), C.update(W.uBboxSize, Q), C.updateIfChanged(W.uResolution, X), Z.namedComputeRenderables[vK].update();
  } else
    Z.namedComputeRenderables[vK] = VK1(Z, J, $, X, Y);
  return Z.namedComputeRenderables[vK];
}
function VK1(Z, J, $, X, Y) {
  let Q = M.sub(M(), $.max, $.min), W = Math.round(J.vertexCount / Y), K = {
    drawCount: C.create(W),
    instanceCount: C.create(J.instanceCount),
    stride: C.create(Y),
    uGroupCount: C.create(J.groupCount),
    aTransform: C.create(J.transformBuffer),
    aInstance: C.create(J.instanceBuffer),
    aSample: C.create(DA0(W, Y)),
    uGeoTexDim: C.create(h0.create(J.positionTexture.getWidth(), J.positionTexture.getHeight())),
    tPosition: C.create(J.positionTexture),
    tGroup: C.create(J.groupTexture),
    uColorTexDim: C.create(h0.create(J.colorData.getWidth(), J.colorData.getHeight())),
    tColor: C.create(J.colorData),
    dColorType: C.create(J.colorType),
    uCurrentSlice: C.create(0),
    uCurrentX: C.create(0),
    uCurrentY: C.create(0),
    uBboxMin: C.create($.min),
    uBboxSize: C.create(Q),
    uResolution: C.create(X)
  }, G = { ...TK1 }, H = v8("accumulate", zA0, OA0, { drawBuffers: "required" }), N = t8(Z, "points", H, G, K);
  return e8(N, K);
}
function IK1(Z) {
  let { gl: J, state: $ } = Z;
  $.disable(J.CULL_FACE), $.enable(J.BLEND), $.disable(J.DEPTH_TEST), $.enable(J.SCISSOR_TEST), $.depthMask(!1), $.clearColor(0, 0, 0, 0), $.blendFunc(J.ONE, J.ONE), $.blendEquation(J.FUNC_ADD);
}
var PK1 = {
  ...A6,
  tColor: o1("texture", "rgba", "float", "nearest"),
  tCount: o1("texture", "alpha", "float", "nearest"),
  uTexSize: _0("v2")
}, hV = "color-normalize";
function CK1(Z, J, $) {
  if (Z.namedComputeRenderables[hV]) {
    let X = Z.namedComputeRenderables[hV].values;
    C.update(X.tColor, J), C.update(X.tCount, $), C.update(X.uTexSize, h0.set(X.uTexSize.ref.value, J.getWidth(), J.getHeight())), Z.namedComputeRenderables[hV].update();
  } else
    Z.namedComputeRenderables[hV] = kK1(Z, J, $);
  return Z.namedComputeRenderables[hV];
}
function kK1(Z, J, $) {
  let X = {
    ...B6,
    tColor: C.create(J),
    tCount: C.create($),
    uTexSize: C.create(h0.create(J.getWidth(), J.getHeight()))
  }, Y = { ...PK1 }, Q = v8("normalize", p6, EA0), W = t8(Z, "triangles", Q, Y, X);
  return e8(W, X);
}
function vK1(Z) {
  let { gl: J, state: $ } = Z;
  $.disable(J.CULL_FACE), $.enable(J.BLEND), $.disable(J.DEPTH_TEST), $.enable(J.SCISSOR_TEST), $.depthMask(!1), $.clearColor(0, 0, 0, 0), $.blendFunc(J.ONE, J.ONE), $.blendEquation(J.FUNC_ADD);
}
function SK1(Z) {
  let J = Z[0] * Z[1] * Z[2], $ = Math.sqrt(J), X = Math.pow(2, Math.ceil(Math.log($) / Math.log(2))), Y = 0, Q = Z[1], W = 1, K = Z[2];
  if (X < Z[0] * Z[2])
    K = Math.floor(X / Z[0]), W = Math.ceil(Z[2] / K), Y = K * Z[0], Q *= W;
  else
    Y = Z[0] * Z[2];
  return { texDimX: Y, texDimY: Q, texRows: W, texCols: K, powerOfTwoSize: Q < X ? X : X * 2 };
}
function bV(Z, J, $, X, Y) {
  let { drawBuffers: Q } = X.extensions;
  if (!Q)
    throw new Error("need WebGL draw buffers");
  if (K1)
    X.timer.mark("calcTextureMeshColorSmoothing");
  let { gl: W, resources: K, state: G, extensions: { colorBufferHalfFloat: H, textureHalfFloat: N } } = X, q = Z.colorType.endsWith("Instance"), U = t1.fromSphere3D(t1(), q ? Z.boundingSphere : Z.invariantBoundingSphere), F = 1 + J, E = t1.expand(t1(), U, M.create(F, F, F)), R = 1 / J, z = t1.scale(t1(), E, R), D = t1.size(M(), z);
  M.ceil(D, D), M.add(D, D, M.create(2, 2, 2));
  let { min: A } = E, [B, T, w] = D, { texDimX: V, texDimY: P, texCols: I } = SK1(D);
  if (!X.namedFramebuffers[vK])
    X.namedFramebuffers[vK] = X.resources.framebuffer();
  let S = X.namedFramebuffers[vK];
  if (_2(W)) {
    if (!X.namedTextures[vK])
      X.namedTextures[vK] = H && N ? K.texture("image-float16", "rgba", "fp16", "nearest") : K.texture("image-float32", "rgba", "float", "nearest");
    if (!X.namedTextures[fV])
      X.namedTextures[fV] = K.texture("image-float32", "alpha", "float", "nearest");
  } else {
    if (!X.namedTextures[vK])
      X.namedTextures[vK] = K.texture("image-float32", "rgba", "float", "nearest");
    if (!X.namedTextures[fV])
      X.namedTextures[fV] = K.texture("image-float32", "rgba", "float", "nearest");
  }
  let f = X.namedTextures[vK], v = X.namedTextures[fV];
  f.define(V, P), v.define(V, P), f.attachFramebuffer(S, 0), v.attachFramebuffer(S, 1);
  let h = _K1(X, Z, E, J, $);
  G.currentRenderItemId = -1, S.bind(), Q.drawBuffers([
    Q.COLOR_ATTACHMENT0,
    Q.COLOR_ATTACHMENT1
  ]);
  let { uCurrentSlice: x, uCurrentX: b, uCurrentY: g } = h.values;
  if (K1)
    X.timer.mark("ColorAccumulate.render");
  IK1(X), G.viewport(0, 0, V, P), G.scissor(0, 0, V, P), W.clear(W.COLOR_BUFFER_BIT), C.update(g, 0);
  let m = 0, i = 0, r = 0;
  for (let l = 0;l < w; ++l) {
    if (m >= I)
      m -= I, i += T, r = 0, C.update(g, i);
    C.update(b, r), C.update(x, l), G.viewport(r, i, B, T), G.scissor(r, i, B, T), h.render(), ++m, r += B;
  }
  if (f.detachFramebuffer(S, 0), v.detachFramebuffer(S, 1), Q.drawBuffers([W.COLOR_ATTACHMENT0, W.NONE]), K1)
    X.timer.markEnd("ColorAccumulate.render");
  if (K1)
    X.timer.mark("ColorNormalize.render");
  if (!Y || iR0(Y))
    Y = K.texture("image-uint8", "rgba", "ubyte", "linear");
  Y.define(V, P);
  let Y0 = CK1(X, f, v);
  if (G.currentRenderItemId = -1, vK1(X), Y.attachFramebuffer(S, 0), G.viewport(0, 0, V, P), G.scissor(0, 0, V, P), W.clear(W.COLOR_BUFFER_BIT), Y0.render(), K1)
    X.timer.markEnd("ColorNormalize.render");
  let c = E2.create(A[0], A[1], A[2], R), n = q ? "volumeInstance" : "volume";
  if (K1)
    X.timer.markEnd("calcTextureMeshColorSmoothing");
  return { texture: Y, gridDim: D, gridTexDim: h0.create(V, P), gridTransform: c, type: n };
}
var vt = "color-smoothing-rgb", xA = "color-smoothing-rgba", yA = "color-smoothing-alpha";
function fK1(Z) {
  return Z === "group" || Z === "groupInstance";
}
function St(Z, J, $, X, Y) {
  if (!fK1(Z.dColorType.ref.value))
    return;
  if ($ *= 3, !X.namedTextures[vt])
    X.namedTextures[vt] = X.resources.texture("image-uint8", "rgb", "ubyte", "nearest");
  let Q = X.namedTextures[vt];
  Q.load(Z.tColor.ref.value);
  let W = bV({
    vertexCount: Z.uVertexCount.ref.value,
    instanceCount: Z.uInstanceCount.ref.value,
    groupCount: Z.uGroupCount.ref.value,
    transformBuffer: Z.aTransform.ref.value,
    instanceBuffer: Z.aInstance.ref.value,
    positionTexture: Z.tPosition.ref.value,
    groupTexture: Z.tGroup.ref.value,
    colorData: Q,
    colorType: Z.dColorType.ref.value,
    boundingSphere: Z.boundingSphere.ref.value,
    invariantBoundingSphere: Z.invariantBoundingSphere.ref.value
  }, J, $, X, Y);
  C.updateIfChanged(Z.dColorType, W.type), C.update(Z.tColorGrid, W.texture), C.update(Z.uColorTexDim, W.gridTexDim), C.update(Z.uColorGridDim, W.gridDim), C.update(Z.uColorGridTransform, W.gridTransform);
}
function hK1(Z) {
  return Z === "groupInstance";
}
function MA0(Z, J, $, X, Y) {
  if (!hK1(Z.dOverpaintType.ref.value))
    return;
  if ($ *= 3, !X.namedTextures[xA])
    X.namedTextures[xA] = X.resources.texture("image-uint8", "rgba", "ubyte", "nearest");
  let Q = X.namedTextures[xA];
  Q.load(Z.tOverpaint.ref.value);
  let W = bV({
    vertexCount: Z.uVertexCount.ref.value,
    instanceCount: Z.uInstanceCount.ref.value,
    groupCount: Z.uGroupCount.ref.value,
    transformBuffer: Z.aTransform.ref.value,
    instanceBuffer: Z.aInstance.ref.value,
    positionTexture: Z.tPosition.ref.value,
    groupTexture: Z.tGroup.ref.value,
    colorData: Q,
    colorType: Z.dOverpaintType.ref.value,
    boundingSphere: Z.boundingSphere.ref.value,
    invariantBoundingSphere: Z.invariantBoundingSphere.ref.value
  }, J, $, X, Y);
  C.updateIfChanged(Z.dOverpaintType, W.type), C.update(Z.tOverpaintGrid, W.texture), C.update(Z.uOverpaintTexDim, W.gridTexDim), C.update(Z.uOverpaintGridDim, W.gridDim), C.update(Z.uOverpaintGridTransform, W.gridTransform);
}
function bK1(Z) {
  return Z === "groupInstance";
}
function AA0(Z, J, $, X, Y) {
  if (!bK1(Z.dTransparencyType.ref.value))
    return;
  if ($ *= 3, !X.namedTextures[yA])
    X.namedTextures[yA] = X.resources.texture("image-uint8", "alpha", "ubyte", "nearest");
  let Q = X.namedTextures[yA];
  Q.load(Z.tTransparency.ref.value);
  let W = bV({
    vertexCount: Z.uVertexCount.ref.value,
    instanceCount: Z.uInstanceCount.ref.value,
    groupCount: Z.uGroupCount.ref.value,
    transformBuffer: Z.aTransform.ref.value,
    instanceBuffer: Z.aInstance.ref.value,
    positionTexture: Z.tPosition.ref.value,
    groupTexture: Z.tGroup.ref.value,
    colorData: Q,
    colorType: Z.dTransparencyType.ref.value,
    boundingSphere: Z.boundingSphere.ref.value,
    invariantBoundingSphere: Z.invariantBoundingSphere.ref.value
  }, J, $, X, Y);
  C.updateIfChanged(Z.dTransparencyType, W.type), C.update(Z.tTransparencyGrid, W.texture), C.update(Z.uTransparencyTexDim, W.gridTexDim), C.update(Z.uTransparencyGridDim, W.gridDim), C.update(Z.uTransparencyGridTransform, W.gridTransform);
}
function xK1(Z) {
  return Z === "groupInstance";
}
function BA0(Z, J, $, X, Y) {
  if (!xK1(Z.dEmissiveType.ref.value))
    return;
  if ($ *= 3, !X.namedTextures[yA])
    X.namedTextures[yA] = X.resources.texture("image-uint8", "alpha", "ubyte", "nearest");
  let Q = X.namedTextures[yA];
  Q.load(Z.tEmissive.ref.value);
  let W = bV({
    vertexCount: Z.uVertexCount.ref.value,
    instanceCount: Z.uInstanceCount.ref.value,
    groupCount: Z.uGroupCount.ref.value,
    transformBuffer: Z.aTransform.ref.value,
    instanceBuffer: Z.aInstance.ref.value,
    positionTexture: Z.tPosition.ref.value,
    groupTexture: Z.tGroup.ref.value,
    colorData: Q,
    colorType: Z.dEmissiveType.ref.value,
    boundingSphere: Z.boundingSphere.ref.value,
    invariantBoundingSphere: Z.invariantBoundingSphere.ref.value
  }, J, $, X, Y);
  C.updateIfChanged(Z.dEmissiveType, W.type), C.update(Z.tEmissiveGrid, W.texture), C.update(Z.uEmissiveTexDim, W.gridTexDim), C.update(Z.uEmissiveGridDim, W.gridDim), C.update(Z.uEmissiveGridTransform, W.gridTransform);
}
function yK1(Z) {
  return Z === "groupInstance";
}
function wA0(Z, J, $, X, Y) {
  if (!yK1(Z.dSubstanceType.ref.value))
    return;
  if ($ *= 3, !X.namedTextures[xA])
    X.namedTextures[xA] = X.resources.texture("image-uint8", "rgba", "ubyte", "nearest");
  let Q = X.namedTextures[xA];
  Q.load(Z.tSubstance.ref.value);
  let W = bV({
    vertexCount: Z.uVertexCount.ref.value,
    instanceCount: Z.uInstanceCount.ref.value,
    groupCount: Z.uGroupCount.ref.value,
    transformBuffer: Z.aTransform.ref.value,
    instanceBuffer: Z.aInstance.ref.value,
    positionTexture: Z.tPosition.ref.value,
    groupTexture: Z.tGroup.ref.value,
    colorData: Q,
    colorType: Z.dSubstanceType.ref.value,
    boundingSphere: Z.boundingSphere.ref.value,
    invariantBoundingSphere: Z.invariantBoundingSphere.ref.value
  }, J, $, X, Y);
  C.updateIfChanged(Z.dSubstanceType, W.type), C.update(Z.tSubstanceGrid, W.texture), C.update(Z.uSubstanceTexDim, W.gridTexDim), C.update(Z.uSubstanceGridDim, W.gridDim), C.update(Z.uSubstanceGridTransform, W.gridTransform);
}

// node_modules/molstar/lib/mol-repr/visual.js
var m8;
(function(Z) {
  function J(F, E) {
    if (F)
      F.state.visible = E;
  }
  Z.setVisibility = J;
  function $(F, E) {
    if (F)
      F.state.alphaFactor = E;
  }
  Z.setAlphaFactor = $;
  function X(F, E) {
    if (F)
      F.state.pickable = E;
  }
  Z.setPickable = X;
  function Y(F, E) {
    if (F)
      F.state.colorOnly = E;
  }
  Z.setColorOnly = Y;
  function Q(F, E, R, z, D) {
    if (!F || _7(E))
      return !1;
    let { tMarker: A, uMarker: B, markerAverage: T, markerStatus: w, uGroupCount: V, instanceCount: P, instanceGranularity: I } = F.values, S = I.ref.value ? P.ref.value : V.ref.value * P.ref.value, { array: f } = A.ref.value, v = w.ref.value;
    if (!KJ(E)) {
      let g = 0;
      if (z(E, (m) => {
        return g += k0.size(m), !0;
      }, !0), g === 0)
        return !1;
      if (g === S)
        E = nN;
    }
    let h = !1, x = -1, b = -1;
    if (KJ(E)) {
      let g = QA0(R, v);
      if (g.status !== -1) {
        if (h = v !== g.status, h)
          YA0(f, g.status, S);
      } else
        h = yR(f, k0.ofLength(S), R);
      x = g.average, b = g.status;
    } else if (h = z(E, (g) => yR(f, g, R), !0), h) {
      if (x = WA0(R, v), D && D.status !== -1 && x === -1 && W7.isReverse(D.action, R) && d2.areEqual(E, D.loci))
        b = D.status, x = b === 0 ? 0 : 0.5;
    }
    if (h) {
      if (x === -1) {
        if (x = is(f, S), x === 0)
          b = 0;
      }
      if (D)
        D.action = R, D.loci = E, D.status = v;
      if (C.updateIfChanged(B, b), b === -1)
        C.update(A, A.ref.value);
      C.updateIfChanged(T, x), C.updateIfChanged(w, b);
    }
    return h;
  }
  Z.mark = Q;
  function W(F, E, R, z, D) {
    if (!F)
      return;
    let { tOverpaint: A, dOverpaintType: B, dOverpaint: T, uGroupCount: w, instanceCount: V, instanceGranularity: P } = F.values, I = P.ref.value ? V.ref.value : w.ref.value * V.ref.value, S = P.ref.value ? "instance" : "groupInstance";
    QE0(E.layers.length ? I : 0, S, F.values);
    let { array: f } = A.ref.value;
    if (z)
      Ga(f, 0, I);
    for (let v = 0, h = E.layers.length;v < h; ++v) {
      let { loci: x, color: b, clear: g } = E.layers[v];
      R(x, (i) => {
        let r = k0.start(i), Y0 = k0.end(i);
        return g ? Ga(f, r, Y0) : YE0(f, r, Y0, b);
      }, !1);
    }
    if (C.update(A, A.ref.value), C.updateIfChanged(B, S), C.updateIfChanged(T, E.layers.length > 0), E.layers.length === 0)
      return;
    if (S === "instance")
      return;
    if (D && j5(D.props)) {
      let { geometry: v, props: h, webgl: x } = D;
      if (v.kind === "mesh") {
        let { resolution: b, overpaintTexture: g } = v.meta, m = FQ(h.smoothColors, !0, b);
        if (m)
          FA0(F.values, m.resolution, m.stride, x, g), v.meta.overpaintTexture = F.values.tOverpaintGrid.ref.value;
      } else if (x && v.kind === "texture-mesh") {
        let { resolution: b, overpaintTexture: g } = v.meta, m = FQ(h.smoothColors, !0, b);
        if (m)
          MA0(F.values, m.resolution, m.stride, x, g), v.meta.overpaintTexture = F.values.tOverpaintGrid.ref.value;
      }
    }
  }
  Z.setOverpaint = W;
  function K(F, E, R, z, D) {
    if (!F)
      return;
    let { tTransparency: A, dTransparencyType: B, transparencyAverage: T, transparencyMin: w, dTransparency: V, uGroupCount: P, instanceCount: I, instanceGranularity: S } = F.values, f = S.ref.value ? I.ref.value : P.ref.value * I.ref.value, v = S.ref.value ? "instance" : "groupInstance";
    HE0(E.layers.length ? f : 0, v, F.values);
    let { array: h } = A.ref.value;
    if (z)
      GE0(h, 0, f);
    for (let x = 0, b = E.layers.length;x < b; ++x) {
      let { loci: g, value: m } = E.layers[x];
      R(g, (r) => {
        let Y0 = k0.start(r), c = k0.end(r);
        return KE0(h, Y0, c, m);
      }, !1);
    }
    if (C.update(A, A.ref.value), C.updateIfChanged(T, Ha(h, f)), C.updateIfChanged(w, Na(h, f)), C.updateIfChanged(B, v), C.updateIfChanged(V, E.layers.length > 0), E.layers.length === 0)
      return;
    if (v === "instance")
      return;
    if (D && j5(D.props)) {
      let { geometry: x, props: b, webgl: g } = D;
      if (x.kind === "mesh") {
        let { resolution: m, transparencyTexture: i } = x.meta, r = FQ(b.smoothColors, !0, m);
        if (r)
          UA0(F.values, r.resolution, r.stride, g, i), x.meta.transparencyTexture = F.values.tTransparencyGrid.ref.value;
      } else if (g && x.kind === "texture-mesh") {
        let { resolution: m, transparencyTexture: i } = x.meta, r = FQ(b.smoothColors, !0, m);
        if (r)
          AA0(F.values, r.resolution, r.stride, g, i), x.meta.transparencyTexture = F.values.tTransparencyGrid.ref.value;
      }
    }
  }
  Z.setTransparency = K;
  function G(F, E, R, z, D) {
    if (!F)
      return;
    let { tEmissive: A, dEmissiveType: B, emissiveAverage: T, dEmissive: w, uGroupCount: V, instanceCount: P, instanceGranularity: I } = F.values, S = I.ref.value ? P.ref.value : V.ref.value * P.ref.value, f = I.ref.value ? "instance" : "groupInstance";
    ME0(E.layers.length ? S : 0, f, F.values);
    let { array: v } = A.ref.value;
    if (z)
      DE0(v, 0, S);
    for (let h = 0, x = E.layers.length;h < x; ++h) {
      let { loci: b, value: g } = E.layers[h];
      R(b, (i) => {
        let r = k0.start(i), Y0 = k0.end(i);
        return zE0(v, r, Y0, g);
      }, !1);
    }
    if (C.update(A, A.ref.value), C.updateIfChanged(T, Fa(v, S)), C.updateIfChanged(B, f), C.updateIfChanged(w, E.layers.length > 0), E.layers.length === 0)
      return;
    if (f === "instance")
      return;
    if (D && j5(D.props)) {
      let { geometry: h, props: x, webgl: b } = D;
      if (h.kind === "mesh") {
        let { resolution: g, emissiveTexture: m } = h.meta, i = FQ(x.smoothColors, !0, g);
        if (i)
          LA0(F.values, i.resolution, i.stride, b, m), h.meta.emissiveTexture = F.values.tEmissiveGrid.ref.value;
      } else if (b && h.kind === "texture-mesh") {
        let { resolution: g, emissiveTexture: m } = h.meta, i = FQ(x.smoothColors, !0, g);
        if (i)
          BA0(F.values, i.resolution, i.stride, b, m), h.meta.emissiveTexture = F.values.tEmissiveGrid.ref.value;
      }
    }
  }
  Z.setEmissive = G;
  function H(F, E, R, z, D) {
    if (!F)
      return;
    let { tSubstance: A, dSubstanceType: B, dSubstance: T, uGroupCount: w, instanceCount: V, instanceGranularity: P } = F.values, I = P.ref.value ? V.ref.value : w.ref.value * V.ref.value, S = P.ref.value ? "instance" : "groupInstance";
    EE0(E.layers.length ? I : 0, S, F.values);
    let { array: f } = A.ref.value;
    if (z)
      qa(f, 0, I);
    for (let v = 0, h = E.layers.length;v < h; ++v) {
      let { loci: x, material: b, clear: g } = E.layers[v];
      R(x, (i) => {
        let r = k0.start(i), Y0 = k0.end(i);
        return g ? qa(f, r, Y0) : RE0(f, r, Y0, b);
      }, !1);
    }
    if (C.update(A, A.ref.value), C.updateIfChanged(B, S), C.updateIfChanged(T, E.layers.length > 0), E.layers.length === 0)
      return;
    if (S === "instance")
      return;
    if (D && j5(D.props)) {
      let { geometry: v, props: h, webgl: x } = D;
      if (v.kind === "mesh") {
        let { resolution: b, substanceTexture: g } = v.meta, m = FQ(h.smoothColors, !0, b);
        if (m)
          RA0(F.values, m.resolution, m.stride, x, g), v.meta.substanceTexture = F.values.tSubstanceGrid.ref.value;
      } else if (x && v.kind === "texture-mesh") {
        let { resolution: b, substanceTexture: g } = v.meta, m = FQ(h.smoothColors, !0, b);
        if (m)
          wA0(F.values, m.resolution, m.stride, x, g), v.meta.substanceTexture = F.values.tSubstanceGrid.ref.value;
      }
    }
  }
  Z.setSubstance = H;
  function N(F, E, R, z) {
    if (!F)
      return;
    let { tClipping: D, dClippingType: A, dClipping: B, uGroupCount: T, instanceCount: w, instanceGranularity: V } = F.values, P = V.ref.value ? w.ref.value : T.ref.value * w.ref.value, { layers: I } = E, S = V.ref.value ? "instance" : "groupInstance";
    UE0(I.length ? P : 0, S, F.values);
    let { array: f } = D.ref.value;
    if (z)
      FE0(f, 0, P);
    for (let v = 0, h = E.layers.length;v < h; ++v) {
      let { loci: x, groups: b } = E.layers[v];
      R(x, (m) => {
        let i = k0.start(m), r = k0.end(m);
        return qE0(f, i, r, b);
      }, !1);
    }
    C.update(D, D.ref.value), C.updateIfChanged(A, S), C.updateIfChanged(B, E.layers.length > 0);
  }
  Z.setClipping = N;
  function q(F, E) {
    if (F)
      C.updateIfChanged(F.values.uOverpaintStrength, E.overpaint), C.updateIfChanged(F.values.uTransparencyStrength, E.transparency), C.updateIfChanged(F.values.uEmissiveStrength, E.emissive), C.updateIfChanged(F.values.uSubstanceStrength, E.substance);
  }
  Z.setThemeStrength = q;
  function U(F, E, R) {
    if (!F || !E && !R)
      return;
    let { values: z } = F;
    if (E)
      e.copy(z.matrix.ref.value, E), C.update(z.matrix, z.matrix.ref.value);
    if (R)
      z.extraTransform.ref.value.set(R), C.update(z.extraTransform, z.extraTransform.ref.value);
    else if (R === null)
      LA(z.extraTransform.ref.value, z.instanceCount.ref.value), C.update(z.extraTransform, z.extraTransform.ref.value);
    Ka(z, z.invariantBoundingSphere.ref.value, z.instanceGrid.ref.value.cellSize, z.instanceGrid.ref.value.batchSize);
    let D = j7(z.invariantBoundingSphere.ref.value, z.transform.ref.value, z.instanceCount.ref.value, 0);
    C.update(z.boundingSphere, D);
  }
  Z.setTransform = U;
})(m8 || (m8 = {}));

// node_modules/molstar/lib/mol-theme/clipping.js
function $9(Z, J) {
  return { kind: Z, layers: J };
}
(function(Z) {
  Z.Empty = { kind: "empty-loci", layers: [] };
  let J;
  (function(N) {
    N.is = r7.has;
    let q;
    (function(D) {
      D[D.None = 0] = "None", D[D.One = 1] = "One", D[D.Two = 2] = "Two", D[D.Three = 4] = "Three", D[D.Four = 8] = "Four", D[D.Five = 16] = "Five", D[D.Six = 32] = "Six";
    })(q = N.Flag || (N.Flag = {}));
    function U(D) {
      return r7.create(D);
    }
    N.create = U, N.Names = {
      one: q.One,
      two: q.Two,
      three: q.Three,
      four: q.Four,
      five: q.Five,
      six: q.Six
    };
    function F(D) {
      return D in N.Names;
    }
    N.isName = F;
    function E(D) {
      switch (D) {
        case "one":
          return q.One;
        case "two":
          return q.Two;
        case "three":
          return q.Three;
        case "four":
          return q.Four;
        case "five":
          return q.Five;
        case "six":
          return q.Six;
      }
    }
    N.fromName = E;
    function R(D) {
      let A = q.None;
      for (let B = 0, T = D.length;B < T; ++B)
        A |= E(D[B]);
      return A;
    }
    N.fromNames = R;
    function z(D) {
      let A = [];
      if (N.is(D, q.One))
        A.push("one");
      if (N.is(D, q.Two))
        A.push("two");
      if (N.is(D, q.Three))
        A.push("three");
      if (N.is(D, q.Four))
        A.push("four");
      if (N.is(D, q.Five))
        A.push("five");
      if (N.is(D, q.Six))
        A.push("six");
      return A;
    }
    N.toNames = z;
  })(J = Z.Groups || (Z.Groups = {}));
  function $(N, q) {
    if (N.layers.length !== q.layers.length)
      return !1;
    for (let U = 0, F = N.layers.length;U < F; ++U) {
      if (N.layers[U].groups !== q.layers[U].groups)
        return !1;
      if (!d2.areEqual(N.layers[U].loci, q.layers[U].loci))
        return !1;
    }
    return !0;
  }
  Z.areEqual = $;
  function X(N) {
    return N.layers.length === 0;
  }
  Z.isEmpty = X;
  function Y(N, q) {
    if (N.kind === "element-loci") {
      let U = [];
      for (let F of N.layers) {
        let { loci: E, groups: R } = F;
        if (E = W0.Loci.remap(E, q), !W0.Loci.isEmpty(E))
          U.push({ loci: E, groups: R });
      }
      return { kind: "element-loci", layers: U };
    } else
      return N;
  }
  Z.remap = Y;
  function Q(N) {
    if (X(N))
      return N;
    if (N.kind === "element-loci") {
      let { structure: q } = N.layers[0].loci, U = /* @__PURE__ */ new Map, F = W0.Loci.none(q);
      for (let R = 0, z = N.layers.length;R < z; ++R) {
        let { loci: D, groups: A } = N.layers[z - R - 1];
        if (D = W0.Loci.subtract(D, F), F = W0.Loci.union(D, F), !W0.Loci.isEmpty(D)) {
          if (U.has(A))
            D = W0.Loci.union(D, U.get(A));
          U.set(A, D);
        }
      }
      let E = [];
      return U.forEach((R, z) => {
        E.push({ loci: R, groups: z });
      }), { kind: "element-loci", layers: E };
    } else
      return N;
  }
  Z.merge = Q;
  function W(N, q) {
    if (X(N))
      return N;
    if (N.kind === "element-loci") {
      let { structure: U } = N.layers[0].loci, F = [];
      for (let E of N.layers) {
        let { loci: R, groups: z } = E, D = W0.Loci.remap(R, q);
        if (R = W0.Loci.remap(D, U), !W0.Loci.isEmpty(R))
          F.push({ loci: R, groups: z });
      }
      return { kind: "element-loci", layers: F };
    } else
      return N;
  }
  Z.filter = W;
  function K(N, q) {
    let U = [];
    for (let F = 0, E = N.length;F < E; ++F) {
      let { script: R, groups: z } = N[F], D = cZ.toLoci(R, q);
      if (!W0.Loci.isEmpty(D))
        U.push({ loci: D, groups: z });
    }
    return { kind: "element-loci", layers: U };
  }
  Z.ofScript = K;
  function G(N, q) {
    let U = [];
    for (let F = 0, E = N.length;F < E; ++F) {
      let { bundle: R, groups: z } = N[F], D = W0.Bundle.toLoci(R, q.root);
      U.push({ loci: D, groups: z });
    }
    return { kind: "element-loci", layers: U };
  }
  Z.ofBundle = G;
  function H(N) {
    let q = [];
    for (let U = 0, F = N.layers.length;U < F; ++U) {
      let { loci: E, groups: R } = N.layers[U], z = W0.Bundle.fromLoci(E);
      q.push({ bundle: z, groups: R });
    }
    return { kind: "element-loci", layers: q };
  }
  Z.toBundle = H;
})($9 || ($9 = {}));

// node_modules/molstar/lib/mol-theme/substance.js
function eJ(Z, J) {
  return { kind: Z, layers: J };
}
(function(Z) {
  Z.Empty = { kind: "empty-loci", layers: [] };
  function J(H, N) {
    if (H.layers.length === 0 && N.layers.length === 0)
      return !0;
    if (H.layers.length !== N.layers.length)
      return !1;
    for (let q = 0, U = H.layers.length;q < U; ++q) {
      if (H.layers[q].clear !== N.layers[q].clear)
        return !1;
      if (!iL(H.layers[q].material, N.layers[q].material))
        return !1;
      if (!d2.areEqual(H.layers[q].loci, N.layers[q].loci))
        return !1;
    }
    return !0;
  }
  Z.areEqual = J;
  function $(H) {
    return H.layers.length === 0;
  }
  Z.isEmpty = $;
  function X(H, N) {
    if (H.kind === "element-loci") {
      let q = [];
      for (let U of H.layers) {
        let { loci: F, material: E, clear: R } = U;
        if (F = W0.Loci.remap(F, N), !W0.Loci.isEmpty(F))
          q.push({ loci: F, material: E, clear: R });
      }
      return { kind: "element-loci", layers: q };
    } else
      return H;
  }
  Z.remap = X;
  function Y(H) {
    if ($(H))
      return H;
    if (H.kind === "element-loci") {
      let { structure: N } = H.layers[0].loci, q = void 0, U = /* @__PURE__ */ new Map, F = W0.Loci.none(N);
      for (let R = 0, z = H.layers.length;R < z; ++R) {
        let { loci: D, material: A, clear: B } = H.layers[z - R - 1];
        if (D = W0.Loci.subtract(D, F), F = W0.Loci.union(D, F), !W0.Loci.isEmpty(D))
          if (B)
            q = q ? W0.Loci.union(D, q) : D;
          else {
            if (U.has(A))
              D = W0.Loci.union(D, U.get(A));
            U.set(A, D);
          }
      }
      let E = [];
      if (q)
        E.push({ loci: q, material: C7(), clear: !0 });
      return U.forEach((R, z) => {
        E.push({ loci: R, material: z, clear: !1 });
      }), { kind: "element-loci", layers: E };
    } else
      return H;
  }
  Z.merge = Y;
  function Q(H, N) {
    if ($(H))
      return H;
    if (H.kind === "element-loci") {
      let { structure: q } = H.layers[0].loci, U = [];
      for (let F of H.layers) {
        let { loci: E, material: R, clear: z } = F, D = W0.Loci.remap(E, N);
        if (E = W0.Loci.remap(D, q), !W0.Loci.isEmpty(E))
          U.push({ loci: E, material: R, clear: z });
      }
      return { kind: "element-loci", layers: U };
    } else
      return H;
  }
  Z.filter = Q;
  function W(H, N) {
    let q = [];
    for (let U = 0, F = H.length;U < F; ++U) {
      let { script: E, material: R, clear: z } = H[U], D = cZ.toLoci(E, N);
      if (!W0.Loci.isEmpty(D))
        q.push({ loci: D, material: R, clear: z });
    }
    return { kind: "element-loci", layers: q };
  }
  Z.ofScript = W;
  function K(H, N) {
    let q = [];
    for (let U = 0, F = H.length;U < F; ++U) {
      let { bundle: E, material: R, clear: z } = H[U], D = W0.Bundle.toLoci(E, N.root);
      q.push({ loci: D, material: R, clear: z });
    }
    return { kind: "element-loci", layers: q };
  }
  Z.ofBundle = K;
  function G(H) {
    let N = [];
    for (let q = 0, U = H.layers.length;q < U; ++q) {
      let { loci: F, material: E, clear: R } = H.layers[q], z = W0.Bundle.fromLoci(F);
      N.push({ bundle: z, material: E, clear: R });
    }
    return { kind: "element-loci", layers: N };
  }
  Z.toBundle = G;
})(eJ || (eJ = {}));

// node_modules/molstar/lib/mol-theme/emissive.js
function Z$(Z, J) {
  return { kind: Z, layers: J };
}
(function(Z) {
  Z.Empty = { kind: "empty-loci", layers: [] };
  function J(H, N) {
    if (H.layers.length === 0 && N.layers.length === 0)
      return !0;
    if (H.layers.length !== N.layers.length)
      return !1;
    for (let q = 0, U = H.layers.length;q < U; ++q) {
      if (H.layers[q].value !== N.layers[q].value)
        return !1;
      if (!d2.areEqual(H.layers[q].loci, N.layers[q].loci))
        return !1;
    }
    return !0;
  }
  Z.areEqual = J;
  function $(H) {
    return H.layers.length === 0;
  }
  Z.isEmpty = $;
  function X(H, N) {
    if (H.kind === "element-loci") {
      let q = [];
      for (let U of H.layers) {
        let { loci: F, value: E } = U;
        if (F = W0.Loci.remap(F, N), !W0.Loci.isEmpty(F))
          q.push({ loci: F, value: E });
      }
      return { kind: "element-loci", layers: q };
    } else
      return H;
  }
  Z.remap = X;
  function Y(H) {
    if ($(H))
      return H;
    if (H.kind === "element-loci") {
      let { structure: N } = H.layers[0].loci, q = /* @__PURE__ */ new Map, U = W0.Loci.none(N);
      for (let E = 0, R = H.layers.length;E < R; ++E) {
        let { loci: z, value: D } = H.layers[R - E - 1];
        if (z = W0.Loci.subtract(z, U), U = W0.Loci.union(z, U), !W0.Loci.isEmpty(z)) {
          if (q.has(D))
            z = W0.Loci.union(z, q.get(D));
          q.set(D, z);
        }
      }
      let F = [];
      return q.forEach((E, R) => {
        F.push({ loci: E, value: R });
      }), { kind: "element-loci", layers: F };
    } else
      return H;
  }
  Z.merge = Y;
  function Q(H, N) {
    if ($(H))
      return H;
    if (H.kind === "element-loci") {
      let { structure: q } = H.layers[0].loci, U = [];
      for (let F of H.layers) {
        let { loci: E, value: R } = F, z = W0.Loci.remap(E, N);
        if (E = W0.Loci.remap(z, q), !W0.Loci.isEmpty(E))
          U.push({ loci: E, value: R });
      }
      return { kind: "element-loci", layers: U };
    } else
      return H;
  }
  Z.filter = Q;
  function W(H, N) {
    let q = [];
    for (let U = 0, F = H.length;U < F; ++U) {
      let { script: E, value: R } = H[U], z = cZ.toLoci(E, N);
      if (!W0.Loci.isEmpty(z))
        q.push({ loci: z, value: R });
    }
    return { kind: "element-loci", layers: q };
  }
  Z.ofScript = W;
  function K(H, N) {
    let q = [];
    for (let U = 0, F = H.length;U < F; ++U) {
      let { bundle: E, value: R } = H[U], z = W0.Bundle.toLoci(E, N.root);
      q.push({ loci: z, value: R });
    }
    return { kind: "element-loci", layers: q };
  }
  Z.ofBundle = K;
  function G(H) {
    let N = [];
    for (let q = 0, U = H.layers.length;q < U; ++q) {
      let { loci: F, value: E } = H.layers[q], R = W0.Bundle.fromLoci(F);
      N.push({ bundle: R, value: E });
    }
    return { kind: "element-loci", layers: N };
  }
  Z.toBundle = G;
})(Z$ || (Z$ = {}));

// node_modules/molstar/lib/mol-repr/representation.js
var jA0;
(function(Z) {
  function J($, X, Y) {
    return j.getDefaultValues($.getParams(X, Y));
  }
  Z.getDefaultParams = J;
})(jA0 || (jA0 = {}));
var gK1 = {
  name: "",
  label: "",
  description: "",
  factory: () => V2.Empty,
  getParams: () => ({}),
  defaultValues: {},
  defaultColorTheme: { name: "" },
  defaultSizeTheme: { name: "" },
  isApplicable: () => !0
};
function TA0(Z) {
  return Z.map((J) => [J.name, J.provider.label]);
}

class xV {
  get default() {
    return this._list[0];
  }
  get types() {
    return TA0(this._list);
  }
  constructor() {
    this._list = [], this._map = /* @__PURE__ */ new Map, this._name = /* @__PURE__ */ new Map;
  }
  add(Z) {
    if (this._map.has(Z.name))
      throw new Error(`${Z.name} already registered.`);
    this._list.push({ name: Z.name, provider: Z }), this._map.set(Z.name, Z), this._name.set(Z, Z.name);
  }
  getName(Z) {
    if (!this._name.has(Z))
      throw new Error(`'${Z.label}' is not a registered represenatation provider.`);
    return this._name.get(Z);
  }
  remove(Z) {
    let J = Z.name;
    this._list.splice(this._list.findIndex((X) => X.name === J), 1);
    let $ = this._map.get(J);
    if ($)
      this._map.delete(J), this._name.delete($);
  }
  get(Z) {
    return this._map.get(Z) || gK1;
  }
  get list() {
    return this._list;
  }
  getApplicableList(Z) {
    return this._list.filter((J) => J.provider.isApplicable(Z));
  }
  getApplicableTypes(Z) {
    return TA0(this.getApplicableList(Z));
  }
  clear() {
    this._list.length = 0, this._map.clear(), this._name.clear();
  }
}
var V2;
(function(Z) {
  let J;
  (function(G) {
    function H(q, U) {
      return q.repr === U.repr && d2.areEqual(q.loci, U.loci);
    }
    G.areEqual = H;
    function N(q) {
      return d2.isEmpty(q.loci);
    }
    G.isEmpty = N, G.Empty = { loci: G8 };
  })(J = Z.Loci || (Z.Loci = {}));
  function $() {
    return {
      visible: !0,
      alphaFactor: 1,
      pickable: !0,
      colorOnly: !1,
      syncManually: !1,
      transform: e.identity(),
      overpaint: rJ.Empty,
      transparency: tJ.Empty,
      emissive: Z$.Empty,
      substance: eJ.Empty,
      clipping: $9.Empty,
      themeStrength: { overpaint: 1, transparency: 1, emissive: 1, substance: 1 },
      markerActions: W7.All
    };
  }
  Z.createState = $;
  function X(G, H) {
    if (H.visible !== void 0)
      G.visible = H.visible;
    if (H.alphaFactor !== void 0)
      G.alphaFactor = H.alphaFactor;
    if (H.pickable !== void 0)
      G.pickable = H.pickable;
    if (H.colorOnly !== void 0)
      G.colorOnly = H.colorOnly;
    if (H.overpaint !== void 0)
      G.overpaint = H.overpaint;
    if (H.transparency !== void 0)
      G.transparency = H.transparency;
    if (H.emissive !== void 0)
      G.emissive = H.emissive;
    if (H.substance !== void 0)
      G.substance = H.substance;
    if (H.clipping !== void 0)
      G.clipping = H.clipping;
    if (H.themeStrength !== void 0)
      G.themeStrength = H.themeStrength;
    if (H.syncManually !== void 0)
      G.syncManually = H.syncManually;
    if (H.transform !== void 0)
      e.copy(G.transform, H.transform);
    if (H.markerActions !== void 0)
      G.markerActions = H.markerActions;
  }
  Z.updateState = X, Z.StateBuilder = { create: $, update: X };
  function Y() {
    return {
      label: "",
      groupCount: 0,
      renderObjects: [],
      geometryVersion: -1,
      props: {},
      params: {},
      updated: new P6,
      state: $(),
      theme: Q7.createEmpty(),
      createOrUpdate: () => n0.constant("", void 0),
      setState: () => {},
      setTheme: () => {},
      getLoci: () => G8,
      getAllLoci: () => [],
      eachLocation: () => {},
      mark: () => !1,
      destroy: () => {}
    };
  }
  Z.createEmpty = Y;

  class Q {
    constructor() {
      this.curr = /* @__PURE__ */ new Set, this.next = /* @__PURE__ */ new Set, this._version = -1;
    }
    get version() {
      return this._version;
    }
    add(G, H) {
      this.next.add(ZJ(G, H));
    }
    snapshot() {
      if (!uZ.areEqual(this.curr, this.next))
        this._version += 1;
      [this.curr, this.next] = [this.next, this.curr], this.next.clear();
    }
  }
  Z.GeometryState = Q;
  function W(G, H, N, q, U) {
    let F = 0, E = new P6, R = new Q, z = q.create(), D = Q7.createEmpty(), A, B, T, w = {}, V = Object.keys(U).map((P, I) => {
      w[I] = P;
      let S = U[P](H, N);
      return S.setState(z), S;
    });
    return {
      label: G,
      updated: E,
      get groupCount() {
        let P = 0;
        if (B) {
          let { visuals: I } = B;
          for (let S = 0, f = V.length;S < f; ++S)
            if (!I || I.includes(w[S]))
              P += V[S].groupCount;
        }
        return P;
      },
      get renderObjects() {
        let P = [];
        if (B) {
          let { visuals: I } = B;
          for (let S = 0, f = V.length;S < f; ++S)
            if (!I || I.includes(w[S]))
              P.push(...V[S].renderObjects);
        }
        return P;
      },
      get geometryVersion() {
        return R.version;
      },
      get props() {
        return B;
      },
      get params() {
        return A;
      },
      createOrUpdate: (P = {}, I) => {
        if (I && I !== T) {
          if (A = N(H, I), T = I, !B)
            B = j.getDefaultValues(A);
        }
        let S = vV(Object.assign({}, B, P), T);
        Object.assign(B, P, S);
        let { visuals: f } = B;
        return n0.create(`Creating or updating '${G}' representation`, async (v) => {
          for (let h = 0, x = V.length;h < x; ++h) {
            if (!f || f.includes(w[h]))
              await V[h].createOrUpdate(B, T).runInContext(v);
            R.add(h, V[h].geometryVersion);
          }
          R.snapshot(), E.next(F++);
        });
      },
      get state() {
        return z;
      },
      get theme() {
        return D;
      },
      getLoci: (P) => {
        let { visuals: I } = B;
        for (let S = 0, f = V.length;S < f; ++S)
          if (!I || I.includes(w[S])) {
            let v = V[S].getLoci(P);
            if (!_7(v))
              return v;
          }
        return G8;
      },
      getAllLoci: () => {
        let P = [], { visuals: I } = B;
        for (let S = 0, f = V.length;S < f; ++S)
          if (!I || I.includes(w[S]))
            P.push(...V[S].getAllLoci());
        return P;
      },
      eachLocation: (P) => {
        let { visuals: I } = B;
        for (let S = 0, f = V.length;S < f; ++S)
          if (!I || I.includes(w[S]))
            V[S].eachLocation(P);
      },
      mark: (P, I) => {
        let S = !1;
        for (let f = 0, v = V.length;f < v; ++f)
          S = V[f].mark(P, I) || S;
        return S;
      },
      setState: (P) => {
        q.update(z, P);
        for (let I = 0, S = V.length;I < S; ++I)
          V[I].setState(P);
      },
      setTheme: (P) => {
        D = P;
        for (let I = 0, S = V.length;I < S; ++I)
          V[I].setTheme(P);
      },
      destroy() {
        for (let P = 0, I = V.length;P < I; ++P)
          V[P].destroy();
      }
    };
  }
  Z.createMulti = W;
  function K(G, H) {
    let N = 0, q = new P6, U = new Q, F = Z.createState(), E = Q7.createEmpty(), R = j.clone(q1.Params), z = j.getDefaultValues(q1.Params);
    return {
      label: G,
      updated: q,
      get groupCount() {
        return H.values.uGroupCount.ref.value;
      },
      get renderObjects() {
        return [H];
      },
      get geometryVersion() {
        return U.version;
      },
      get props() {
        return z;
      },
      get params() {
        return R;
      },
      createOrUpdate: (D = {}) => {
        let A = vV(Object.assign({}, z, D));
        return Object.assign(z, D, A), n0.create(`Updating '${G}' representation`, async (B) => {
          U.add(0, H.id), U.snapshot(), q.next(N++);
        });
      },
      get state() {
        return F;
      },
      get theme() {
        return E;
      },
      getLoci: () => {
        return G8;
      },
      getAllLoci: () => {
        return [];
      },
      eachLocation: () => {},
      mark: (D, A) => {
        return !1;
      },
      setState: (D) => {
        if (D.visible !== void 0)
          m8.setVisibility(H, D.visible);
        if (D.alphaFactor !== void 0)
          m8.setAlphaFactor(H, D.alphaFactor);
        if (D.pickable !== void 0)
          m8.setPickable(H, D.pickable);
        if (D.colorOnly !== void 0)
          m8.setColorOnly(H, D.colorOnly);
        if (D.overpaint !== void 0)
          ;
        if (D.transparency !== void 0)
          ;
        if (D.emissive !== void 0)
          ;
        if (D.substance !== void 0)
          ;
        if (D.clipping !== void 0)
          ;
        if (D.themeStrength !== void 0)
          m8.setThemeStrength(H, D.themeStrength);
        if (D.transform !== void 0)
          m8.setTransform(H, D.transform);
        Z.updateState(F, D);
      },
      setTheme: () => {},
      destroy() {}
    };
  }
  Z.fromRenderObject = K;
})(V2 || (V2 = {}));
var db = void 0;
Object.defineProperty(V2, "Empty", {
  get: () => {
    return db !== null && db !== void 0 ? db : db = V2.createEmpty();
  }
});

// node_modules/molstar/lib/mol-geo/geometry/picking.js
var K7;
(function(Z) {
  Z.Null = 16777214;
  function J($, X) {
    return $.objectId === X.objectId && $.instanceId === X.instanceId && $.groupId === X.groupId;
  }
  Z.areSame = J;
})(K7 || (K7 = {}));

// node_modules/molstar/lib/mol-repr/shape/representation.js
function I7(Z, J, $ = {}) {
  let X = 0, Y = new P6, Q = V2.createState(), W = bW(), K = [], G, H, N = -1, q = Q7.createEmpty(), U = J.Params, F = j.getDefaultValues(U), E, R;
  if ($.modifyState)
    V2.updateState(Q, $.modifyState(Q));
  let z = S5.create();
  function D(w = {}, V) {
    if (S5.reset(z), !V && !H)
      return;
    else if (V && !H)
      z.createNew = !0;
    else if (V && H && V.id === H.id)
      ;
    else if (V && H && V.id !== H.id)
      z.updateTransform = !0, z.createGeometry = !0;
    else if (!V)
      ;
    else
      console.warn("unexpected state");
    if (w.instanceGranularity !== F.instanceGranularity)
      z.updateTransform = !0;
    if (z.updateTransform)
      z.updateColor = !0, z.updateSize = !0, z.updateMatrix = !0;
    if (z.createGeometry)
      z.updateColor = !0, z.updateSize = !0;
  }
  function A(w = {}, V) {
    if ($.modifyProps)
      w = $.modifyProps(w);
    return n0.create("ShapeRepresentation.create", async (P) => {
      let I = Object.assign(F, w), S = V ? await Z(P, V, I, H) : void 0;
      if (D(w, S), S)
        H = S, Object.assign(q, c8.getTheme(H));
      if (z.createNew) {
        K.length = 0, E = c8.groupIterator(H);
        let f = c8.createTransform(H.transforms, H.geometry.boundingSphere, I.cellSize, I.batchSize), v = J.createValues(H.geometry, f, E, q, I), h = J.createRenderableState(I);
        if ($.modifyState)
          Object.assign(h, $.modifyState(h));
        if (V2.updateState(Q, h), G = v3(H.geometry.kind, v, h, W), G)
          K.push(G);
        R = J.createPositionIterator(H.geometry, G.values);
      } else {
        if (!G)
          throw new Error("expected renderObject to be available");
        if (z.updateTransform) {
          E = c8.groupIterator(H);
          let { instanceCount: f, groupCount: v } = E;
          if (w.instanceGranularity)
            rZ(f, "instance", G.values);
          else
            rZ(f * v, "groupInstance", G.values);
        }
        if (z.updateMatrix) {
          if (c8.createTransform(H.transforms, H.geometry.boundingSphere, I.cellSize, I.batchSize, G.values), "lodLevels" in G.values)
            C.update(G.values.lodLevels, G.values.lodLevels.ref.value);
        }
        if (z.createGeometry)
          C.updateIfChanged(G.values.drawCount, n7.getDrawCount(H.geometry)), C.updateIfChanged(G.values.uVertexCount, n7.getVertexCount(H.geometry)), C.updateIfChanged(G.values.uGroupCount, E.groupCount);
        if (z.updateColor)
          WJ(E, R, q.color, G.values);
        if (z.updateSize) {
          if ("uSize" in G.values)
            DY(E, q.size, G.values);
        }
        if (J.updateValues(G.values, I), J.updateRenderableState(G.state, I), z.updateTransform || z.createGeometry)
          J.updateBoundingSphere(G.values, H.geometry), R = J.createPositionIterator(H.geometry, G.values);
      }
      if (F = I, z.createGeometry || z.createNew)
        N += 1;
      Y.next(X++);
    });
  }
  function B(w, V, P) {
    let I = !1;
    if (!x$.isLoci(w))
      return !1;
    if (x$.isLociEmpty(w))
      return !1;
    if (w.shape !== V)
      return !1;
    for (let S of w.groups)
      if (P(k0.ofSingleton(S.instance)))
        I = !0;
    return I;
  }
  function T(w, V) {
    if (KJ(w) || c8.isLoci(w) && w.shape === H)
      if (F.instanceGranularity)
        return V(k0.ofBounds(0, H.transforms.length));
      else
        return V(k0.ofBounds(0, H.groupCount * H.transforms.length));
    else if (F.instanceGranularity)
      return B(w, H, V);
    else
      return mK1(w, H, V);
  }
  return {
    label: "Shape geometry",
    get groupCount() {
      return E ? E.count : 0;
    },
    get props() {
      return F;
    },
    get params() {
      return U;
    },
    get state() {
      return Q;
    },
    get theme() {
      return q;
    },
    renderObjects: K,
    get geometryVersion() {
      return N;
    },
    updated: Y,
    createOrUpdate: A,
    getLoci(w) {
      let { objectId: V, groupId: P, instanceId: I } = w;
      if (G && G.id === V)
        if (P === K7.Null)
          return c8.Loci(H);
        else
          return x$.Loci(H, [{ ids: f0.ofSingleton(P), instance: I }]);
      return G8;
    },
    getAllLoci() {
      return [c8.Loci(H)];
    },
    eachLocation: (w) => {
      E.reset();
      while (E.hasNext) {
        let { location: V, isSecondary: P } = E.move();
        w(V, P);
      }
    },
    mark(w, V) {
      if (!W7.is(Q.markerActions, V))
        return !1;
      if (x$.isLoci(w) || c8.isLoci(w)) {
        if (w.shape !== H)
          return !1;
      } else if (!KJ(w))
        return !1;
      return m8.mark(G, w, V, T);
    },
    setState(w) {
      if ($.modifyState)
        w = $.modifyState(w);
      if (G) {
        if (w.visible !== void 0)
          m8.setVisibility(G, w.visible);
        if (w.alphaFactor !== void 0)
          m8.setAlphaFactor(G, w.alphaFactor);
        if (w.pickable !== void 0)
          m8.setPickable(G, w.pickable);
        if (w.colorOnly !== void 0)
          m8.setColorOnly(G, w.colorOnly);
        if (w.overpaint !== void 0)
          m8.setOverpaint(G, w.overpaint, T, !0);
        if (w.transparency !== void 0)
          m8.setTransparency(G, w.transparency, T, !0);
        if (w.substance !== void 0)
          m8.setSubstance(G, w.substance, T, !0);
        if (w.transform !== void 0)
          m8.setTransform(G, w.transform);
      }
      V2.updateState(Q, w);
    },
    setTheme(w) {
      if (y2)
        console.warn("The `ShapeRepresentation` theme is fixed to `ShapeGroupColorTheme` and `ShapeGroupSizeTheme`. Colors are taken from `Shape.getColor` and sizes from `Shape.getSize`");
    },
    destroy() {
      if (K.length = 0, G)
        G.state.disposed = !0, G = void 0;
    }
  };
}
function mK1(Z, J, $) {
  if (!x$.isLoci(Z))
    return !1;
  if (Z.shape !== J)
    return !1;
  let X = !1, { groupCount: Y } = J, { groups: Q } = Z;
  for (let { ids: W, instance: K } of Q)
    if (k0.is(W)) {
      let G = K * Y + k0.start(W), H = K * Y + k0.end(W);
      if ($(k0.ofBounds(G, H)))
        X = !0;
    } else
      for (let G = 0, H = W.length;G < H; G++) {
        let N = K * Y + W[G];
        if ($(k0.ofSingleton(N)))
          X = !0;
      }
  return X;
}

// node_modules/molstar/lib/mol-model/structure/structure/util/unit-transforms.js
var _A0 = e();

class gR {
  constructor(Z) {
    this.structure = Z, this.groupUnitTransforms = [], this.unitOffsetMap = NY.Mutable(), this.groupIndexMap = /* @__PURE__ */ new Map, this._isIdentity = void 0, this.version = 0, this.unitTransforms = new Float32Array(Z.units.length * 16), this.size = Z.units.length, this.reset();
    let J = 0;
    for (let $ = 0, X = Z.unitSymmetryGroups.length;$ < X; ++$) {
      let Y = Z.unitSymmetryGroups[$];
      this.groupIndexMap.set(Y, $);
      let Q = this.unitTransforms.subarray(J, J + Y.units.length * 16);
      this.groupUnitTransforms.push(Q);
      for (let W = 0, K = Y.units.length;W < K; ++W)
        this.unitOffsetMap.set(Y.units[W].id, J + W * 16);
      J += Y.units.length * 16;
    }
  }
  reset() {
    this.version = 0, LA(this.unitTransforms, this.size), this._isIdentity = !0;
  }
  get isIdentity() {
    if (this._isIdentity === void 0) {
      this._isIdentity = !0;
      for (let Z = 0, J = this.size * 16;Z < J; Z += 16)
        if (e.fromArray(_A0, this.unitTransforms, Z), !e.isIdentity(_A0)) {
          this._isIdentity = !1;
          break;
        }
    }
    return this._isIdentity;
  }
  setTransform(Z, J) {
    this.version = (this.version + 1) % 2147483647, e.toArray(Z, this.unitTransforms, this.unitOffsetMap.get(J.id)), this._isIdentity = void 0;
  }
  getTransform(Z, J) {
    return e.fromArray(Z, this.unitTransforms, this.unitOffsetMap.get(J.id));
  }
  getSymmetryGroupTransforms(Z) {
    return this.groupUnitTransforms[this.groupIndexMap.get(Z)];
  }
}

// node_modules/molstar/lib/mol-plugin-state/animation/helpers.js
var VA0 = e();
function ft(Z, J, $) {
  for (let X = 0, Y = Z.units.length;X < Y; X++) {
    let Q = Z.units[X];
    RZ.lerpFromIdentity(VA0, Q.conformation.operator, $), J.setTransform(VA0, Q);
  }
}
var IA0 = M(), gA = M(), ub = e();
function ht(Z, J, $, X) {
  let Y = X.radius * $;
  for (let Q = 0, W = Z.units.length;Q < W; Q++) {
    let K = Z.units[Q];
    M.transformMat4(IA0, K.lookup3d.boundary.sphere.center, K.conformation.operator.matrix), M.sub(gA, IA0, X.center), M.setMagnitude(gA, gA, Y), e.fromTranslation(ub, gA), J.setTransform(ub, K);
  }
}
var kA0 = {
  axis: j.MappedStatic("custom", {
    structure: j.Group({
      principalAxis: j.Select("dirA", [["dirA", "A"], ["dirB", "B"], ["dirC", "C"]])
    }),
    custom: j.Group({
      vector: j.Vec3(M.create(0, 0, 1))
    })
  }),
  origin: j.MappedStatic("structure", {
    structure: j.Group({}),
    custom: j.Group({
      vector: j.Vec3(M.create(0, 0, 0))
    })
  })
};
function bt(Z, J) {
  let $, X;
  if (J.axis.name === "custom")
    $ = J.axis.params.vector;
  else
    $ = s0.getPrincipalAxes(Z).momentsAxes[J.axis.params.principalAxis];
  if (J.origin.name === "custom")
    X = J.origin.params.vector;
  else
    X = s0.getPrincipalAxes(Z).momentsAxes.origin;
  return { axis: $, origin: X };
}
var PA0 = e(), CA0 = e(), pb = e();
function xt(Z, J, $, X, Y) {
  for (let Q = 0, W = Z.units.length;Q < W; Q++) {
    let K = Z.units[Q];
    M.negate(gA, Y), e.fromTranslation(ub, gA), e.fromRotation(PA0, Math.PI * $ * 2, X), e.fromTranslation(CA0, Y), e.mul(pb, PA0, ub), e.mul(pb, CA0, pb), J.setTransform(pb, K);
  }
}

// node_modules/molstar/lib/mol-repr/shape/model/unitcell.js
var dK1 = e.fromTranslation(e(), M.create(0.5, 0.5, 0.5)), pK1 = Ma(Da(fh()), dK1), AH = M(), vA0 = e(), uK1 = {
  origin: "Origin",
  model: "Model"
}, cK1 = {
  corner: "Corner",
  center: "Center"
}, lK1 = {
  ...n1.Params,
  cellColor: j.Color(c2.orange),
  cellScale: j.Numeric(2, { min: 0.1, max: 5, step: 0.1 }),
  ref: j.Select("model", j.objectToOptions(uK1), { isEssential: !0 }),
  attachment: j.Select("corner", j.objectToOptions(cK1), { isEssential: !0 })
}, nK1 = {
  mesh: (Z, J) => I7(oK1, n1.Utils)
}, yt = {
  ...lK1
};
function iK1(Z, J, $) {
  let X = v1.createState(256, 128, $), { fromFractional: Y } = Z.symmetry.spacegroup.cell;
  if (M.copy(AH, Z.ref), J.attachment === "center")
    M.trunc(AH, AH), M.subScalar(AH, AH, 0.5);
  else
    M.floor(AH, AH);
  e.fromTranslation(vA0, AH);
  let Q = Ma(Da(pK1), vA0), W = Math.cbrt(Z.symmetry.spacegroup.cell.volume) / 300 * J.cellScale;
  X.currentGroup = 1, v1.addCage(X, Y, Q, W, 2, 20);
  let K = C0.fromDimensionsAndTransform(C0(), M.unit, Y);
  M.transformMat4(AH, AH, Y), C0.translate(K, K, AH), C0.expand(K, K, W);
  let G = v1.getMesh(X);
  return G.setBoundingSphere(K), G;
}
function oK1(Z, J, $, X) {
  let Y = iK1(J, $, X && X.geometry), Q = nF.getUnitcellLabel(J.symmetry);
  return c8.create(Q, J, Y, () => $.cellColor, () => 1, () => Q);
}
function gt(Z, J, $) {
  let X = M();
  if ($.ref === "model")
    M.transformMat4(X, O2.getCenter(Z), J.spacegroup.cell.toFractional);
  return { symmetry: J, ref: X };
}
function SA0(Z, J) {
  return V2.createMulti("Unit Cell", Z, J, V2.StateBuilder, nK1);
}

// node_modules/molstar/lib/mol-geo/geometry/text/text-builder.js
var u3 = new Uint16Array([
  0,
  1,
  2,
  1,
  3,
  2
]), Cz = B1.add3, kY = B1.add2, fA0 = B1.add, iQ;
(function(Z) {
  function J($ = {}, X = 2048, Y = 1024, Q) {
    X *= 2, Y *= 2;
    let W = B1.create(Float32Array, 3, Y, Q ? Q.centerBuffer.ref.value : X), K = B1.create(Float32Array, 2, Y, Q ? Q.mappingBuffer.ref.value : X), G = B1.create(Float32Array, 1, Y, Q ? Q.depthBuffer.ref.value : X), H = B1.create(Uint32Array, 3, Y, Q ? Q.indexBuffer.ref.value : X), N = B1.create(Float32Array, 1, Y, Q ? Q.groupBuffer.ref.value : X), q = B1.create(Float32Array, 2, Y, Q ? Q.tcoordBuffer.ref.value : X), U = { ...j.getDefaultValues(IJ.Params), ...$ }, { attachment: F, background: E, backgroundMargin: R, tether: z, tetherLength: D, tetherBaseWidth: A } = U, B = VE0(U), T = 0.4 * R, w = B.buffer / B.lineHeight, V = (P, I, S, f, v) => {
      Cz(W, P, I, S), fA0(G, f), fA0(N, v);
    };
    return {
      add: (P, I, S, f, v, h, x) => {
        let b = 0, g = P.length;
        for (let G0 = 0;G0 < g; ++G0) {
          let F0 = B.get(P[G0]);
          b += F0.nw - 2 * w;
        }
        let m = 0.8, i, r;
        if (F.startsWith("top"))
          i = m;
        else if (F.startsWith("middle"))
          i = m / 2;
        else
          i = 0;
        if (F.endsWith("right"))
          r = b;
        else if (F.endsWith("center"))
          r = b / 2;
        else
          r = 0;
        if (z)
          switch (F) {
            case "bottom-left":
              r -= D / 2 + T + 0.1, i -= D / 2 + T;
              break;
            case "bottom-center":
              i -= D + T;
              break;
            case "bottom-right":
              r += D / 2 + T + 0.1, i -= D / 2 + T;
              break;
            case "middle-left":
              r -= D + T + 0.1;
              break;
            case "middle-center":
              break;
            case "middle-right":
              r += D + T + 0.1;
              break;
            case "top-left":
              r -= D / 2 + T + 0.1, i += D / 2 + T;
              break;
            case "top-center":
              i += D + T;
              break;
            case "top-right":
              r += D / 2 + T + 0.1, i += D / 2 + T;
              break;
          }
        let Y0 = (-r - T - 0.1) * h, c = (b - r + T + 0.1) * h, n = (m - i + T) * h, l = (-i - T) * h;
        if (E) {
          kY(K, Y0, n), kY(K, Y0, l), kY(K, c, n), kY(K, c, l);
          let G0 = W.elementCount;
          for (let F0 = 0;F0 < 4; ++F0)
            kY(q, 10, 10), V(I, S, f, v, x);
          Cz(H, G0 + u3[0], G0 + u3[1], G0 + u3[2]), Cz(H, G0 + u3[3], G0 + u3[4], G0 + u3[5]);
        }
        if (z) {
          let G0, F0, t, Z0, U0, a, Q0, $0, R0 = D * h, X0 = A * h;
          switch (F) {
            case "bottom-left":
              G0 = Y0 - R0 / 2, t = Y0 + X0 / 2, U0 = Y0, Q0 = Y0, F0 = l - R0 / 2, Z0 = l, a = l + X0 / 2, $0 = l;
              break;
            case "bottom-center":
              G0 = 0, t = X0 / 2, U0 = -X0 / 2, Q0 = 0, F0 = l - R0, Z0 = l, a = l, $0 = l;
              break;
            case "bottom-right":
              G0 = c + R0 / 2, t = c, U0 = c - X0 / 2, Q0 = c, F0 = l - R0 / 2, Z0 = l + X0 / 2, a = l, $0 = l;
              break;
            case "middle-left":
              G0 = Y0 - R0, t = Y0, U0 = Y0, Q0 = Y0, F0 = 0, Z0 = -X0 / 2, a = X0 / 2, $0 = 0;
              break;
            case "middle-center":
              G0 = 0, t = 0, U0 = 0, Q0 = 0, F0 = 0, Z0 = 0, a = 0, $0 = 0;
              break;
            case "middle-right":
              G0 = c + R0, t = c, U0 = c, Q0 = c, F0 = 0, Z0 = X0 / 2, a = -X0 / 2, $0 = 0;
              break;
            case "top-left":
              G0 = Y0 - R0 / 2, t = Y0 + X0 / 2, U0 = Y0, Q0 = Y0, F0 = n + R0 / 2, Z0 = n, a = n - X0 / 2, $0 = n;
              break;
            case "top-center":
              G0 = 0, t = X0 / 2, U0 = -X0 / 2, Q0 = 0, F0 = n + R0, Z0 = n, a = n, $0 = n;
              break;
            case "top-right":
              G0 = c + R0 / 2, t = c, U0 = c - X0 / 2, Q0 = c, F0 = n + R0 / 2, Z0 = n - X0 / 2, a = n, $0 = n;
              break;
            default:
              T8(F);
          }
          kY(K, G0, F0), kY(K, t, Z0), kY(K, U0, a), kY(K, Q0, $0);
          let E0 = W.elementCount;
          for (let V0 = 0;V0 < 4; ++V0)
            kY(q, 10, 10), V(I, S, f, v, x);
          Cz(H, E0, E0 + 1, E0 + 3), Cz(H, E0, E0 + 3, E0 + 2);
        }
        r += w, i += w;
        let u = 0;
        for (let G0 = 0;G0 < g; ++G0) {
          let F0 = B.get(P[G0]), t = (u - r) * h, Z0 = (u + F0.nw - r) * h, U0 = (F0.nh - i) * h, a = -i * h;
          kY(K, t, U0), kY(K, t, a), kY(K, Z0, U0), kY(K, Z0, a);
          let Q0 = B.texture.width, $0 = B.texture.height;
          kY(q, F0.x / Q0, F0.y / $0), kY(q, F0.x / Q0, (F0.y + F0.h) / $0), kY(q, (F0.x + F0.w) / Q0, F0.y / $0), kY(q, (F0.x + F0.w) / Q0, (F0.y + F0.h) / $0), u += F0.nw - 2 * w;
          let R0 = W.elementCount;
          for (let X0 = 0;X0 < 4; ++X0)
            V(I, S, f, v, x);
          Cz(H, R0 + u3[0], R0 + u3[1], R0 + u3[2]), Cz(H, R0 + u3[3], R0 + u3[4], R0 + u3[5]);
        }
      },
      getText: () => {
        let P = B.texture, I = B1.compact(W, !0), S = B1.compact(K, !0), f = B1.compact(G, !0), v = B1.compact(H, !0), h = B1.compact(N, !0), x = B1.compact(q, !0);
        return IJ.create(P, I, S, f, v, h, x, H.elementCount / 2, Q);
      }
    };
  }
  Z.create = J;
})(iQ || (iQ = {}));

// node_modules/molstar/lib/mol-theme/label.js
var dA = {
  granularity: "element",
  condensed: !1,
  reverse: !1,
  countsOnly: !1,
  hidePrefix: !1,
  htmlStyling: !0
};
function c3(Z, J = {}) {
  var $;
  switch (Z.kind) {
    case "structure-loci":
      return Z.structure.models.map((F) => F.entry).filter((F) => !!F).join(", ");
    case "element-loci":
      return kz(W0.Stats.ofLoci(Z), J);
    case "bond-loci":
      let X = Z.bonds[0];
      return X ? gV(X, J) : "";
    case "shape-loci":
      return Z.shape.name;
    case "group-loci":
      let Y = Z.groups[0];
      return Y ? Z.shape.getLabel(f0.start(Y.ids), Y.instance) : "";
    case "every-loci":
      return "Everything";
    case "empty-loci":
      return "Nothing";
    case "data-loci":
      return Z.getLabel();
    case "volume-loci":
      return Z.volume.label || "Volume";
    case "isosurface-loci":
      return [
        `${Z.volume.label || "Volume"}`,
        `Isosurface at ${Q1.IsoValue.toString(Z.isoValue)}`
      ].join(" | ");
    case "cell-loci":
      let Q = Q1.Cell.getLociSize(Z), W = f0.start(Z.elements[0].indices), K = Q1.IsoValue.absolute(Z.volume.grid.cells.data[W]), G = Q1.IsoValue.toRelative(K, Z.volume.grid.stats), H = [
        `${Z.volume.label || "Volume"}`,
        `${Q === 1 ? `Cell #${W}` : `${Q} Cells`}`
      ];
      if (Q === 1) {
        if (Z.volume.instances.length > 1)
          H.push(`Instance #${f0.start(Z.elements[0].instances) + 1}`);
        H.push(`${Q1.IsoValue.toString(K)} (${Q1.IsoValue.toString(G)})`);
      }
      return H.join(" | ");
    case "segment-loci":
      let N = Q1.Segment.getLociSize(Z), q = ($ = Q1.Segmentation.get(Z.volume)) === null || $ === void 0 ? void 0 : $.labels, U = f0.start(Z.elements[0].segments);
      if (q && N === 1) {
        let F = q[U];
        if (F)
          return F;
      }
      return [
        `${Z.volume.label || "Volume"}`,
        `${N === 1 ? `Segment ${U}` : `${N} Segments`}`
      ].join(" | ");
  }
}
function mA(Z, J) {
  return Z === 1 ? `1 ${J}` : `${Z} ${J}s`;
}
function yV(Z, J, $, X, Y, Q) {
  return `${SK(J, { granularity: $, hidePrefix: X, reverse: Y, condensed: Q })} <small>[+ ${mA(Z - 1, `other ${TN($)}`)}]</small>`;
}
function sK1(Z) {
  let { elements: J, model: $ } = Z, { chainAtomSegments: X, residueAtomSegments: Y } = $.atomicHierarchy, Q = X.offsets[X.index[J[0]]], W = X.offsets[X.index[J[J.length - 1]] + 1] - 1;
  return Y.index[W] - Y.index[Q] + 1;
}
function kz(Z, J = {}) {
  let $ = { ...dA, ...J }, X = aK1(Z, $.countsOnly, $.hidePrefix, $.condensed, $.reverse);
  return $.htmlStyling ? X : MK(X);
}
function mR(Z, J = {}) {
  let $ = W0.Stats.create();
  for (let X of Z)
    W0.Stats.add($, $, W0.Stats.ofLoci(X));
  return kz($, J);
}
function aK1(Z, J = !1, $ = !1, X = !1, Y = !1) {
  let { structureCount: Q, chainCount: W, residueCount: K, conformationCount: G, elementCount: H } = Z;
  if (!J && H === 1 && K === 0 && W === 0)
    return SK(Z.firstElementLoc, { hidePrefix: $, condensed: X, granularity: "element", reverse: Y });
  else if (!J && H === 0 && K === 1 && W === 0)
    return SK(Z.firstResidueLoc, { hidePrefix: $, condensed: X, granularity: "residue", reverse: Y });
  else if (!J && H === 0 && K === 0 && W === 1) {
    let { unit: N } = Z.firstChainLoc, q = j0.isAtomic(N) && sK1(N) === 1 ? "residue" : j0.Traits.is(N.traits, j0.Trait.MultiChain) ? "residue" : "chain";
    return SK(Z.firstChainLoc, { hidePrefix: $, condensed: X, granularity: q, reverse: Y });
  } else if (!J) {
    let N = [];
    if (Q > 0)
      N.push(Q === 1 ? SK(Z.firstStructureLoc, { hidePrefix: $, condensed: X, granularity: "structure", reverse: Y }) : yV(Q, Z.firstStructureLoc, "structure", $, Y, X));
    if (W > 0)
      N.push(W === 1 ? SK(Z.firstChainLoc, { condensed: X, granularity: "chain", hidePrefix: $, reverse: Y }) : yV(W, Z.firstChainLoc, "chain", $, Y, X)), $ = !0;
    if (K > 0)
      N.push(K === 1 ? SK(Z.firstResidueLoc, { condensed: X, granularity: "residue", hidePrefix: $, reverse: Y }) : yV(K, Z.firstResidueLoc, "residue", $, Y, X)), $ = !0;
    if (G > 0)
      N.push(G === 1 ? SK(Z.firstConformationLoc, { condensed: X, granularity: "conformation", hidePrefix: $, reverse: Y }) : yV(G, Z.firstConformationLoc, "conformation", $, Y, X)), $ = !0;
    if (H > 0)
      N.push(H === 1 ? SK(Z.firstElementLoc, { condensed: X, granularity: "element", hidePrefix: $, reverse: Y }) : yV(H, Z.firstElementLoc, "element", $, Y, X));
    return N.join("<small> + </small>");
  } else {
    let N = [];
    if (Q > 0)
      N.push(mA(Q, "Structure"));
    if (W > 0)
      N.push(mA(W, "Chain"));
    if (K > 0)
      N.push(mA(K, "Residue"));
    if (G > 0)
      N.push(mA(G, "Conformation"));
    if (H > 0)
      N.push(mA(H, "Element"));
    return N.join("<small> + </small>");
  }
}
function gV(Z, J = {}) {
  return cb({ loci: [
    W0.Loci(Z.aStructure, [{ unit: Z.aUnit, indices: f0.ofSingleton(Z.aIndex) }]),
    W0.Loci(Z.bStructure, [{ unit: Z.bUnit, indices: f0.ofSingleton(Z.bIndex) }])
  ] }, J);
}
function cb(Z, J = {}) {
  let $ = { ...dA, ...J }, X = rK1(Z, $);
  return $.htmlStyling ? X : MK(X);
}
function rK1(Z, J) {
  let { granularity: $, hidePrefix: X, reverse: Y, condensed: Q } = J, W = !0;
  for (let K of Z.loci)
    if (!W0.Loci.is(K) || W0.Loci.size(K) !== 1) {
      W = !1;
      break;
    }
  if (W) {
    let G = Z.loci.map((N) => {
      let { unit: q, indices: U } = N.elements[0];
      return W0.Location.create(N.structure, q, q.elements[f0.start(U)]);
    }).map((N) => hA0(N, $, X, Y || Q));
    if (Q)
      return G.map((N) => N[0].replace(/\[.*\]/g, "").trim()).filter((N) => !!N).join(" — ");
    let H = 0;
    for (let N = 0, q = Math.min(...G.map((U) => U.length)) - 1;N < q; ++N) {
      let U = !0;
      for (let F = 1, E = G.length;F < E; ++F)
        if (G[0][N] !== G[F][N]) {
          U = !1;
          break;
        }
      if (U)
        H += 1;
      else
        break;
    }
    if (H > 0) {
      let N = [G[0].join(" | ")];
      for (let q = 1, U = G.length;q < U; ++q)
        N.push(G[q].slice(H).filter((F) => !!F).join(" | "));
      return N.join(" — ");
    } else
      return G.map((N) => N.filter((q) => !!q).join(" | ")).filter((N) => !!N).join("</br>");
  } else
    return Z.loci.map((G) => c3(G, J)).filter((G) => !!G).join(Q ? " — " : "</br>");
}
function SK(Z, J = {}) {
  var $, X;
  let Y = { ...dA, ...J }, Q = hA0(Z, Y.granularity, Y.hidePrefix, Y.reverse || Y.condensed), W = Y.condensed ? (X = ($ = Q[0]) === null || $ === void 0 ? void 0 : $.replace(/\[.*\]/g, "").trim()) !== null && X !== void 0 ? X : "" : Q.filter((K) => !!K).join(" | ");
  return Y.htmlStyling ? W : MK(W);
}
function hA0(Z, J = "element", $ = !1, X = !1) {
  let Y = [];
  if (!$) {
    let Q = Z.unit.model.entry;
    if (Q.length > 30)
      Q = Q.substr(0, 27) + "…";
    if (Y.push(`<small>${Q}</small>`), J !== "structure")
      Y.push(`<small>Model ${Z.unit.model.modelNum}</small>`), Y.push(`<small>Instance ${Z.unit.conformation.operator.instanceId}</small>`);
  }
  if (j0.isAtomic(Z.unit))
    Y.push(...tK1(Z, J, X));
  else if (j0.isCoarse(Z.unit))
    Y.push(...eK1(Z, J));
  else
    Y.push("Unknown");
  return X ? Y.reverse() : Y;
}
function tK1(Z, J, $ = !1) {
  let X = W0.Location.residueIndex(Z), Y = w1.chain.label_asym_id(Z), Q = w1.chain.auth_asym_id(Z), W = Z.unit.model.atomicHierarchy.residues.label_seq_id.valueKind(X) === s.ValueKinds.Present, K = w1.residue.label_seq_id(Z), G = w1.residue.auth_seq_id(Z), H = w1.residue.pdbx_PDB_ins_code(Z), N = w1.atom.label_comp_id(Z), q = w1.atom.label_atom_id(Z), U = w1.atom.label_alt_id(Z), F = w1.atom.occupancy(Z), E = w1.atom.sourceIndex(Z), R = w1.residue.microheterogeneityCompIds(Z), z = J === "residue" && R.length > 1 ? `(${R.join("|")})` : N, D = [];
  switch (J) {
    case "element": {
      let B = `<b>${q}</b>${U ? `%${U}` : ""}`, T = `<small style='margin-left: 4px'>[idx <b>${E + 1}</b>]</small>`;
      D.push(`${B}${T}`);
    }
    case "conformation":
      if (J === "conformation" && U)
        D.push(`<small>Conformation</small> <b>${U}</b>`);
    case "residue":
      let A = K === G || !W ? G : K;
      D.push(`<b>${z} ${A}</b>${A !== G ? ` <small>[auth</small> <b>${G}</b><small>]</small>` : ""}<b>${H ? H : ""}</b>`);
    case "chain":
      if (Y === Q)
        D.push(`<b>${Y}</b>`);
      else if (J === "chain" && j0.Traits.is(Z.unit.traits, j0.Trait.MultiChain))
        D.push(`<small>[auth</small> <b>${Q}</b><small>]</small>`);
      else
        D.push(`<b>${Y}</b> <small>[auth</small> <b>${Q}</b><small>]</small>`);
  }
  if (D.length > 0 && F !== 1 && !$)
    D[0] = `${D[0]} <small>[occupancy</small> <b>${Math.round(100 * F) / 100}</b><small>]</small>`;
  return D.reverse();
}
function eK1(Z, J) {
  let $ = w1.coarse.asym_id(Z), X = w1.coarse.seq_id_begin(Z), Y = w1.coarse.seq_id_end(Z), Q = [];
  switch (J) {
    case "element":
    case "conformation":
    case "residue":
      if (X === Y) {
        let W = w1.coarse.entityKey(Z), G = Z.unit.model.sequence.byEntityKey[W].sequence.compId.value(X - 1);
        Q.push(`<b>${G} ${X}</b>`);
      } else
        Q.push(`<b>${X}-${Y}</b>`);
    case "chain":
      Q.push(`<b>${$}</b>`);
  }
  return Q.reverse();
}
function pA(Z, J = {}) {
  let $ = { ...dA, measureOnly: !1, unitLabel: "Å", ...J }, [X, Y] = Z.loci.map((K) => d2.getCenter(K)), Q = `${M.distance(X, Y).toFixed(2)} ${$.unitLabel}`;
  if ($.measureOnly)
    return Q;
  let W = cb(Z, $);
  return $.condensed ? `${Q} | ${W}` : `Distance ${Q}</br>${W}`;
}
function uA(Z, J = {}) {
  let $ = { ...dA, measureOnly: !1, ...J }, [X, Y, Q] = Z.loci.map((N) => d2.getCenter(N)), W = M.sub(M(), X, Y), K = M.sub(M(), Q, Y), G = `${k$(M.angle(W, K)).toFixed(2)}°`;
  if ($.measureOnly)
    return G;
  let H = cb(Z, $);
  return $.condensed ? `${G} | ${H}` : `Angle ${G}</br>${H}`;
}
function cA(Z, J = {}) {
  let $ = { ...dA, measureOnly: !1, ...J }, [X, Y, Q, W] = Z.loci.map((H) => d2.getCenter(H)), K = `${k$(M.dihedralAngle(X, Y, Q, W)).toFixed(2)}°`;
  if ($.measureOnly)
    return K;
  let G = cb(Z, $);
  return $.condensed ? `${K} | ${G}` : `Dihedral ${K}</br>${G}`;
}

// node_modules/molstar/lib/mol-repr/shape/loci/common.js
var mt = {
  customText: j.Text("", { label: "Text", description: "Override the label with custom value.", isEssential: !0 }),
  textColor: j.Color(c2.black, { isEssential: !0 }),
  textSize: j.Numeric(0.5, { min: 0.1, max: 10, step: 0.1 }, { isEssential: !0 })
}, dR = {
  ...IJ.Params,
  ...mt,
  borderWidth: j.Numeric(0.2, { min: 0, max: 0.5, step: 0.01 })
};

// node_modules/molstar/lib/mol-repr/shape/loci/distance.js
var bA0 = {
  unitLabel: j.Text("Å", { isEssential: !0 })
}, Z31 = {
  ...f6.Params,
  ...bA0,
  lineSizeAttenuation: j.Boolean(!0),
  linesColor: j.Color(c2.lightgreen, { isEssential: !0 }),
  linesSize: j.Numeric(0.075, { min: 0.01, max: 5, step: 0.01 }),
  dashLength: j.Numeric(0.2, { min: 0.01, max: 0.2, step: 0.01 })
}, J31 = {
  ...dR,
  ...bA0
}, xA0 = {
  lines: (Z, J) => I7(Y31, f6.Utils, { modifyState: ($) => ({ ...$, markerActions: W7.Highlighting }) }),
  text: (Z, J) => I7(W31, IJ.Utils, { modifyState: ($) => ({ ...$, markerActions: x2.None }) })
}, dt = {
  ...Z31,
  ...J31,
  visuals: j.MultiSelect(["lines", "text"], j.objectToOptions(xA0))
};
function $31() {
  return {
    sphereA: C0(),
    sphereB: C0(),
    center: M(),
    distance: 0
  };
}
function yA0(Z, J) {
  let { sphereA: $, sphereB: X, center: Y } = J, [Q, W] = Z.loci;
  return d2.getBoundingSphere(Q, $), d2.getBoundingSphere(W, X), M.add(Y, $.center, X.center), M.scale(Y, Y, 0.5), J.distance = M.distance($.center, X.center), J;
}
var mV = $31();
function gA0(Z, J) {
  return Z.pairs.length === 1 ? `Distance ${pA(Z.pairs[0], { unitLabel: J, measureOnly: !0 })}` : `${Z.pairs.length} Distances`;
}
function X31(Z, J, $) {
  let X = L$.create(128, 64, $);
  for (let Y = 0, Q = Z.pairs.length;Y < Q; ++Y)
    yA0(Z.pairs[Y], mV), X.addFixedLengthDashes(mV.sphereA.center, mV.sphereB.center, J.dashLength, Y);
  return X.getLines();
}
function Y31(Z, J, $, X) {
  let Y = X31(J, $, X && X.geometry), Q = gA0(J, $.unitLabel), W = (K) => pA(J.pairs[K], $);
  return c8.create(Q, J, Y, () => $.linesColor, () => $.linesSize, W);
}
function Q31(Z, J, $) {
  let X = iQ.create(J, 128, 64, $);
  for (let Y = 0, Q = Z.pairs.length;Y < Q; ++Y) {
    yA0(Z.pairs[Y], mV);
    let { center: W, distance: K, sphereA: G, sphereB: H } = mV, N = J.customText || `${K.toFixed(2)} ${J.unitLabel}`, U = Math.max(2, G.radius, H.radius) / 2;
    X.add(N, W[0], W[1], W[2], 1, U, Y);
  }
  return X.getText();
}
function W31(Z, J, $, X) {
  let Y = Q31(J, $, X && X.geometry), Q = gA0(J, $.unitLabel), W = (K) => pA(J.pairs[K], $);
  return c8.create(Q, J, Y, () => $.textColor, () => $.textSize, W);
}
function mA0(Z, J) {
  return V2.createMulti("Distance", Z, J, V2.StateBuilder, xA0);
}

// node_modules/molstar/lib/mol-repr/shape/loci/label.js
var K31 = {
  ...dR
}, dA0 = {
  text: (Z, J) => I7(q31, IJ.Utils)
}, pt = {
  ...K31,
  scaleByRadius: j.Boolean(!0),
  visuals: j.MultiSelect(["text"], j.objectToOptions(dA0)),
  snapshotKey: j.Text("", { isEssential: !0, disableInteractiveUpdates: !0, description: "Activate the snapshot with the provided key when clicking on the label" }),
  tooltip: j.Text("", { isEssential: !0, multiline: !0, disableInteractiveUpdates: !0, placeholder: "Tooltip", description: "Tooltip text to be displayed when hovering over the label" })
}, G31 = C0();
function ut(Z, J = !1) {
  return Z.label || c3(Z.loci, { hidePrefix: !0, htmlStyling: !1, condensed: J });
}
function H31(Z) {
  return Z.infos.length === 1 ? ut(Z.infos[0]) : `${Z.infos.length} Labels`;
}
function N31(Z, J, $) {
  let X = iQ.create(J, 128, 64, $), Y = J.customText.trim();
  for (let Q = 0, W = Z.infos.length;Q < W; ++Q) {
    let K = Z.infos[Q], G = d2.getBoundingSphere(K.loci, G31);
    if (!G)
      continue;
    let { center: H, radius: N } = G, q = Y || ut(K, !0);
    X.add(q, H[0], H[1], H[2], J.scaleByRadius ? N / 0.9 : 0, J.scaleByRadius ? Math.max(1, N) : 1, Q);
  }
  return X.getText();
}
function q31(Z, J, $, X) {
  var Y, Q;
  let W = N31(J, $, X && X.geometry), K = H31(J), G = (Q = (Y = $.tooltip) === null || Y === void 0 ? void 0 : Y.trim()) !== null && Q !== void 0 ? Q : "", H = $.customText.trim(), N;
  if (G)
    N = (q) => G;
  else if (H)
    N = (q) => H;
  else
    N = (q) => ut(J.infos[q]);
  return c8.create(K, J, W, () => $.textColor, () => $.textSize, N);
}
function pA0(Z, J) {
  return V2.createMulti("Label", Z, J, V2.StateBuilder, dA0);
}

// node_modules/molstar/lib/mol-geo/geometry/mesh/builder/axes.js
var vz = M(), F31 = e.identity(), Sz = new Float32Array(18), U31 = new Uint8Array([0, 1, 2, 3, 4, 5]);
function uA0(Z, J, $, X, Y) {
  let { origin: Q, dirA: W, dirB: K, dirC: G } = J;
  M.add(vz, Q, W), M.toArray(M.add(vz, Q, W), Sz, 0), M.toArray(M.sub(vz, Q, W), Sz, 3), M.toArray(M.add(vz, Q, K), Sz, 6), M.toArray(M.sub(vz, Q, K), Sz, 9), M.toArray(M.add(vz, Q, G), Sz, 12), M.toArray(M.sub(vz, Q, G), Sz, 15);
  let H = uN(Sz, U31), N = m7.volume(J), q = Math.cbrt(N) / 300 * $;
  v1.addCage(Z, F31, H, q, X, Y);
}

// node_modules/molstar/lib/mol-geo/geometry/mesh/builder/box.js
var Ly2 = M.zero(), Ry2 = M.zero();
var pR = M(), L31 = M(), R31 = M(), E31 = M(), O31 = e.identity(), cA0 = new Float32Array(24), z31 = new Uint8Array([
  0,
  1,
  0,
  3,
  0,
  6,
  1,
  2,
  1,
  7,
  2,
  3,
  2,
  4,
  3,
  5,
  4,
  5,
  4,
  7,
  5,
  6,
  6,
  7
]);
function lA0(Z, J, $, X, Y) {
  let { origin: Q, dirA: W, dirB: K, dirC: G } = J, H = M.negate(L31, W), N = M.negate(R31, K), q = M.negate(E31, G), U = 0, F = function(D, A, B) {
    M.copy(pR, Q), M.add(pR, pR, D), M.add(pR, pR, A), M.add(pR, pR, B), M.toArray(pR, cA0, U), U += 3;
  };
  F(W, K, G), F(W, K, q), F(W, N, q), F(W, N, G), F(H, N, q), F(H, N, G), F(H, K, G), F(H, K, q);
  let E = uN(cA0, z31), R = m7.volume(J), z = Math.cbrt(R) / 300 * $;
  v1.addCage(Z, O31, E, z, X, Y);
}

// node_modules/molstar/lib/mol-geo/geometry/mesh/builder/ellipsoid.js
var D31 = e.identity(), nA0 = M();
function M31(Z, J, $, X, Y) {
  return M.add(nA0, J, $), e.targetTo(Z, J, nA0, X), e.setTranslation(Z, J), e.scale(Z, Z, Y);
}
function fz(Z, J, $, X, Y, Q) {
  v1.addPrimitive(Z, M31(D31, J, $, X, Y), Gr(Q));
}

// node_modules/molstar/lib/mol-repr/shape/loci/orientation.js
var ct = {
  color: j.Color(c2.orange),
  scaleFactor: j.Numeric(1, { min: 0.1, max: 10, step: 0.1 }),
  radiusScale: j.Numeric(2, { min: 0.1, max: 10, step: 0.1 })
}, A31 = {
  ...n1.Params,
  ...ct
}, B31 = {
  ...n1.Params,
  ...ct
}, w31 = {
  ...n1.Params,
  ...ct
}, iA0 = {
  axes: (Z, J) => I7(_31, n1.Utils),
  box: (Z, J) => I7(P31, n1.Utils),
  ellipsoid: (Z, J) => I7(v31, n1.Utils)
}, lt = {
  ...A31,
  ...B31,
  ...w31,
  visuals: j.MultiSelect(["box"], j.objectToOptions(iA0))
};
function j31(Z) {
  return `Principal Axes of ${mR(Z, { countsOnly: !0 })}`;
}
function T31(Z, J, $) {
  let X = v1.createState(256, 128, $), Y = W0.Loci.getPrincipalAxesMany(Z.locis);
  return m7.scale(Y.momentsAxes, Y.momentsAxes, J.scaleFactor), X.currentGroup = 0, uA0(X, Y.momentsAxes, J.radiusScale, 2, 20), v1.getMesh(X);
}
function _31(Z, J, $, X) {
  let Y = T31(J, $, X && X.geometry), Q = j31(J.locis);
  return c8.create(Q, J, Y, () => $.color, () => 1, () => Q);
}
function V31(Z) {
  return `Oriented Box of ${mR(Z, { countsOnly: !0 })}`;
}
function I31(Z, J, $) {
  let X = v1.createState(256, 128, $), Y = W0.Loci.getPrincipalAxesMany(Z.locis);
  return m7.scale(Y.boxAxes, Y.boxAxes, J.scaleFactor), X.currentGroup = 0, lA0(X, Y.boxAxes, J.radiusScale, 2, 20), v1.getMesh(X);
}
function P31(Z, J, $, X) {
  let Y = I31(J, $, X && X.geometry), Q = V31(J.locis);
  return c8.create(Q, J, Y, () => $.color, () => 1, () => Q);
}
function C31(Z) {
  return `Oriented Ellipsoid of ${mR(Z, { countsOnly: !0 })}`;
}
function k31(Z, J, $) {
  let X = v1.createState(256, 128, $), Q = W0.Loci.getPrincipalAxesMany(Z.locis).boxAxes, { origin: W, dirA: K, dirB: G } = Q, H = m7.size(M(), Q);
  M.scale(H, H, 0.5 * J.scaleFactor);
  let N = M.create(H[2], H[1], H[0]);
  return X.currentGroup = 0, fz(X, W, K, G, N, 2), v1.getMesh(X);
}
function v31(Z, J, $, X) {
  let Y = k31(J, $, X && X.geometry), Q = C31(J.locis);
  return c8.create(Q, J, Y, () => $.color, () => 1, () => Q);
}
function oA0(Z, J) {
  let $ = V2.createMulti("Orientation", Z, J, V2.StateBuilder, iA0);
  return $.setState({ markerActions: W7.Highlighting }), $;
}

// node_modules/molstar/lib/mol-geo/primitive/circle.js
var S31 = {
  radius: 1,
  segments: 36,
  thetaStart: 0,
  thetaLength: Math.PI * 2
};
function lb(Z) {
  let { radius: J, segments: $, thetaStart: X, thetaLength: Y } = { ...S31, ...Z }, Q = Y === Math.PI * 2, W = Q ? $ + 1 : $ + 2, K = new Float32Array(W * 3), G = new Float32Array(W * 3), H = new Uint32Array($ * 3);
  K[0] = 0, K[1] = 0, K[2] = 0, G[0] = 0, G[1] = 1, G[2] = 0;
  for (let N = 0, q = 3;N < $; ++N, q += 3) {
    let U = X + N / $ * Y;
    K[q] = J * Math.sin(U), K[q + 1] = 0, K[q + 2] = J * Math.cos(U), G[q] = 0, G[q + 1] = 1, G[q + 2] = 0;
  }
  for (let N = 1, q = 0;N < $; ++N, q += 3)
    H[q] = N, H[q + 1] = N + 1, H[q + 2] = 0;
  if (Q) {
    let N = ($ - 1) * 3;
    H[N] = $, H[N + 1] = 1, H[N + 2] = 0;
  } else {
    let N = X + Y, q = ($ + 1) * 3;
    K[q] = J * Math.sin(N), K[q + 1] = 0, K[q + 2] = J * Math.cos(N), G[q] = 0, G[q + 1] = 1, G[q + 2] = 0;
    let U = ($ - 1) * 3;
    H[U] = $, H[U + 1] = $ + 1, H[U + 2] = 0;
  }
  return { vertices: K, normals: G, indices: H };
}

// node_modules/molstar/lib/mol-repr/shape/loci/angle.js
var sA0 = {
  color: j.Color(c2.lightgreen),
  arcScale: j.Numeric(0.7, { min: 0.01, max: 1, step: 0.01 })
}, aA0 = {
  ...f6.Params,
  ...sA0,
  lineSizeAttenuation: j.Boolean(!0),
  linesSize: j.Numeric(0.04, { min: 0.01, max: 5, step: 0.01 }),
  dashLength: j.Numeric(0.04, { min: 0.01, max: 0.2, step: 0.01 })
}, f31 = {
  ...aA0
}, h31 = {
  ...aA0
}, b31 = {
  ...n1.Params,
  ...sA0,
  ignoreLight: j.Boolean(!0),
  sectorOpacity: j.Numeric(0.75, { min: 0, max: 1, step: 0.01 })
}, rA0 = {
  vectors: (Z, J) => I7(g31, f6.Utils, { modifyState: ($) => ({ ...$, pickable: !1 }) }),
  arc: (Z, J) => I7(d31, f6.Utils, { modifyState: ($) => ({ ...$, pickable: !1 }) }),
  sector: (Z, J) => I7(u31, n1.Utils, { modifyProps: ($) => ({ ...$, alpha: $.sectorOpacity }), modifyState: ($) => ({ ...$, markerActions: W7.Highlighting }) }),
  text: (Z, J) => I7(l31, IJ.Utils, { modifyState: ($) => ({ ...$, markerActions: x2.None }) })
}, nt = {
  ...f31,
  ...h31,
  ...b31,
  ...dR,
  visuals: j.MultiSelect(["vectors", "sector", "text"], j.objectToOptions(rA0))
};
function x31() {
  return {
    sphereA: C0(),
    sphereB: C0(),
    sphereC: C0(),
    arcDirA: M(),
    arcDirC: M(),
    arcNormal: M(),
    radius: 0,
    angle: 0
  };
}
var uR = M(), dV = e();
function nb(Z, J, $) {
  let { sphereA: X, sphereB: Y, sphereC: Q } = J, { arcDirA: W, arcDirC: K, arcNormal: G } = J, [H, N, q] = Z.loci;
  d2.getBoundingSphere(H, X), d2.getBoundingSphere(N, Y), d2.getBoundingSphere(q, Q), M.sub(W, X.center, Y.center), M.sub(K, Q.center, Y.center), M.cross(G, W, K);
  let F = Math.min(M.magnitude(W), M.magnitude(K)) * $;
  return J.radius = F, J.angle = M.angle(W, K), J;
}
function tA0(Z, J) {
  let { radius: $, angle: X } = Z, Y = J ? AS(X, $) / J : 32;
  e.targetTo(dV, Z.sphereB.center, Z.sphereA.center, Z.arcNormal), e.setTranslation(dV, Z.sphereB.center), e.mul(dV, dV, e.rotY180);
  let Q = lb({ radius: $, thetaLength: X, segments: Y });
  return EA(Q, dV);
}
var vY = x31();
function ib(Z) {
  return Z.triples.length === 1 ? `Angle ${uA(Z.triples[0], { measureOnly: !0 })}` : `${Z.triples.length} Angles`;
}
function y31(Z, J, $) {
  let X = L$.create(128, 64, $);
  for (let Y = 0, Q = Z.triples.length;Y < Q; ++Y)
    nb(Z.triples[Y], vY, J.arcScale), X.addFixedLengthDashes(vY.sphereB.center, vY.sphereA.center, J.dashLength, Y), X.addFixedLengthDashes(vY.sphereB.center, vY.sphereC.center, J.dashLength, Y);
  return X.getLines();
}
function g31(Z, J, $, X) {
  let Y = y31(J, $, X && X.geometry), Q = ib(J);
  return c8.create(Q, J, Y, () => $.color, () => $.linesSize, () => "");
}
function m31(Z, J, $) {
  let X = L$.create(128, 64, $);
  for (let Y = 0, Q = Z.triples.length;Y < Q; ++Y) {
    nb(Z.triples[Y], vY, J.arcScale);
    let W = tA0(vY, J.dashLength), { indices: K, vertices: G } = W;
    for (let H = 0, N = K.length;H < N; H += 3) {
      if (H % 2 === 1)
        continue;
      let q = K[H] * 3, U = K[H + 1] * 3, F = G[q], E = G[q + 1], R = G[q + 2], z = G[U], D = G[U + 1], A = G[U + 2];
      X.add(F, E, R, z, D, A, Y);
    }
  }
  return X.getLines();
}
function d31(Z, J, $, X) {
  let Y = m31(J, $, X && X.geometry), Q = ib(J);
  return c8.create(Q, J, Y, () => $.color, () => $.linesSize, () => "");
}
function p31(Z, J, $) {
  let X = v1.createState(128, 64, $);
  for (let Y = 0, Q = Z.triples.length;Y < Q; ++Y) {
    nb(Z.triples[Y], vY, J.arcScale);
    let W = tA0(vY);
    X.currentGroup = Y, v1.addPrimitive(X, e.id, W), v1.addPrimitiveFlipped(X, e.id, W);
  }
  return v1.getMesh(X);
}
function u31(Z, J, $, X) {
  let Y = p31(J, $, X && X.geometry), Q = ib(J), W = (K) => uA(J.triples[K]);
  return c8.create(Q, J, Y, () => $.color, () => 1, W);
}
function c31(Z, J, $) {
  let X = iQ.create(J, 128, 64, $);
  for (let Y = 0, Q = Z.triples.length;Y < Q; ++Y) {
    nb(Z.triples[Y], vY, J.arcScale), M.add(uR, vY.arcDirA, vY.arcDirC), M.setMagnitude(uR, uR, vY.radius), M.add(uR, vY.sphereB.center, uR);
    let W = k$(vY.angle).toFixed(2), K = J.customText || `${W}°`, H = Math.max(2, vY.sphereA.radius, vY.sphereB.radius, vY.sphereC.radius) / 2;
    X.add(K, uR[0], uR[1], uR[2], 0.1, H, Y);
  }
  return X.getText();
}
function l31(Z, J, $, X) {
  let Y = c31(J, $, X && X.geometry), Q = ib(J), W = (K) => uA(J.triples[K]);
  return c8.create(Q, J, Y, () => $.textColor, () => $.textSize, W);
}
function eA0(Z, J) {
  return V2.createMulti("Angle", Z, J, V2.StateBuilder, rA0);
}

// node_modules/molstar/lib/mol-repr/shape/loci/dihedral.js
var ZB0 = {
  color: j.Color(c2.lightgreen),
  arcScale: j.Numeric(0.7, { min: 0.01, max: 1, step: 0.01 })
}, ob = {
  ...f6.Params,
  ...ZB0,
  lineSizeAttenuation: j.Boolean(!0),
  linesSize: j.Numeric(0.04, { min: 0.01, max: 5, step: 0.01 }),
  dashLength: j.Numeric(0.04, { min: 0.01, max: 0.2, step: 0.01 })
}, n31 = {
  ...ob
}, i31 = {
  ...ob
}, o31 = {
  ...ob
}, s31 = {
  ...ob
}, a31 = {
  ...n1.Params,
  ...ZB0,
  ignoreLight: j.Boolean(!0),
  sectorOpacity: j.Numeric(0.75, { min: 0, max: 1, step: 0.01 })
}, JB0 = {
  vectors: (Z, J) => I7(e31, f6.Utils, { modifyState: ($) => ({ ...$, pickable: !1 }) }),
  extenders: (Z, J) => I7(QG1, f6.Utils, { modifyState: ($) => ({ ...$, pickable: !1 }) }),
  connector: (Z, J) => I7(JG1, f6.Utils, { modifyState: ($) => ({ ...$, pickable: !1 }) }),
  arms: (Z, J) => I7(XG1, f6.Utils, { modifyState: ($) => ({ ...$, pickable: !1 }) }),
  arc: (Z, J) => I7(KG1, f6.Utils, { modifyState: ($) => ({ ...$, pickable: !1 }) }),
  sector: (Z, J) => I7(HG1, n1.Utils, { modifyProps: ($) => ({ ...$, alpha: $.sectorOpacity }), modifyState: ($) => ({ ...$, markerActions: W7.Highlighting }) }),
  text: (Z, J) => I7(qG1, IJ.Utils, { modifyState: ($) => ({ ...$, markerActions: x2.None }) })
}, it = {
  ...n31,
  ...i31,
  ...o31,
  ...s31,
  ...a31,
  ...dR,
  visuals: j.MultiSelect(["extenders", "arms", "sector", "text"], j.objectToOptions(JB0))
};
function r31() {
  return {
    sphereA: C0(),
    sphereB: C0(),
    sphereC: C0(),
    sphereD: C0(),
    dirBA: M(),
    dirCD: M(),
    projA: M(),
    projD: M(),
    arcPointA: M(),
    arcPointD: M(),
    arcDirA: M(),
    arcDirD: M(),
    arcCenter: M(),
    arcNormal: M(),
    radius: 0,
    angle: 0
  };
}
var oQ = M(), pV = e();
function hz(Z, J, $) {
  let { sphereA: X, sphereB: Y, sphereC: Q, sphereD: W, dirBA: K, dirCD: G, projA: H, projD: N } = J, { arcPointA: q, arcPointD: U, arcDirA: F, arcDirD: E, arcCenter: R, arcNormal: z } = J, [D, A, B, T] = Z.loci;
  d2.getBoundingSphere(D, X), d2.getBoundingSphere(A, Y), d2.getBoundingSphere(B, Q), d2.getBoundingSphere(T, W), M.add(R, Y.center, Q.center), M.scale(R, R, 0.5), M.sub(K, X.center, Y.center), M.sub(G, W.center, Q.center), M.add(q, R, K), M.add(U, R, G), M.sub(z, Q.center, Y.center), M.orthogonalize(F, z, K), M.orthogonalize(E, z, G), M.projectPointOnVector(H, q, F, R), M.projectPointOnVector(N, U, E, R);
  let V = Math.min(M.distance(H, R), M.distance(N, R)) * $;
  M.setMagnitude(F, F, V), M.setMagnitude(E, E, V), M.add(q, R, F), M.add(U, R, E), J.radius = V, J.angle = M.dihedralAngle(X.center, Y.center, Q.center, W.center), M.matchDirection(oQ, z, M.sub(oQ, q, X.center));
  let P = M.angle(K, oQ), I = V / Math.cos(P - cO);
  M.add(H, Y.center, M.setMagnitude(oQ, K, I)), M.matchDirection(oQ, z, M.sub(oQ, U, W.center));
  let S = M.angle(G, oQ), f = V / Math.cos(S - cO);
  return M.add(N, Q.center, M.setMagnitude(oQ, G, f)), J;
}
function $B0(Z, J) {
  let { radius: $, angle: X } = Z, Y = J ? AS(X, $) / J : 32;
  e.targetTo(pV, Z.arcCenter, X < 0 ? Z.arcPointD : Z.arcPointA, Z.arcNormal), e.setTranslation(pV, Z.arcCenter), e.mul(pV, pV, e.rotY180);
  let Q = lb({ radius: $, thetaLength: Math.abs(X), segments: Y });
  return EA(Q, pV);
}
var t9 = r31();
function bz(Z) {
  return Z.quads.length === 1 ? `Dihedral ${cA(Z.quads[0], { measureOnly: !0 })}` : `${Z.quads.length} Dihedrals`;
}
function t31(Z, J, $) {
  let X = L$.create(128, 64, $);
  for (let Y = 0, Q = Z.quads.length;Y < Q; ++Y)
    hz(Z.quads[Y], t9, J.arcScale), X.addFixedLengthDashes(t9.arcCenter, t9.arcPointA, J.dashLength, Y), X.addFixedLengthDashes(t9.arcCenter, t9.arcPointD, J.dashLength, Y);
  return X.getLines();
}
function e31(Z, J, $, X) {
  let Y = t31(J, $, X && X.geometry), Q = bz(J);
  return c8.create(Q, J, Y, () => $.color, () => $.linesSize, () => "");
}
function ZG1(Z, J, $) {
  let X = L$.create(128, 64, $);
  for (let Y = 0, Q = Z.quads.length;Y < Q; ++Y)
    hz(Z.quads[Y], t9, J.arcScale), X.addFixedLengthDashes(t9.sphereB.center, t9.sphereC.center, J.dashLength, Y);
  return X.getLines();
}
function JG1(Z, J, $, X) {
  let Y = ZG1(J, $, X && X.geometry), Q = bz(J);
  return c8.create(Q, J, Y, () => $.color, () => $.linesSize, () => "");
}
function $G1(Z, J, $) {
  let X = L$.create(128, 64, $);
  for (let Y = 0, Q = Z.quads.length;Y < Q; ++Y)
    hz(Z.quads[Y], t9, J.arcScale), X.addFixedLengthDashes(t9.sphereB.center, t9.sphereA.center, J.dashLength, Y), X.addFixedLengthDashes(t9.sphereC.center, t9.sphereD.center, J.dashLength, Y);
  return X.getLines();
}
function XG1(Z, J, $, X) {
  let Y = $G1(J, $, X && X.geometry), Q = bz(J);
  return c8.create(Q, J, Y, () => $.color, () => $.linesSize, () => "");
}
function YG1(Z, J, $) {
  let X = L$.create(128, 64, $);
  for (let Y = 0, Q = Z.quads.length;Y < Q; ++Y)
    hz(Z.quads[Y], t9, J.arcScale), X.addFixedLengthDashes(t9.arcPointA, t9.projA, J.dashLength, Y), X.addFixedLengthDashes(t9.arcPointD, t9.projD, J.dashLength, Y);
  return X.getLines();
}
function QG1(Z, J, $, X) {
  let Y = YG1(J, $, X && X.geometry), Q = bz(J);
  return c8.create(Q, J, Y, () => $.color, () => $.linesSize, () => "");
}
function WG1(Z, J, $) {
  let X = L$.create(128, 64, $);
  for (let Y = 0, Q = Z.quads.length;Y < Q; ++Y) {
    hz(Z.quads[Y], t9, J.arcScale);
    let W = $B0(t9, J.dashLength), { indices: K, vertices: G } = W;
    for (let H = 0, N = K.length;H < N; H += 3) {
      if (H % 2 === 1)
        continue;
      let q = K[H] * 3, U = K[H + 1] * 3, F = G[q], E = G[q + 1], R = G[q + 2], z = G[U], D = G[U + 1], A = G[U + 2];
      X.add(F, E, R, z, D, A, Y);
    }
  }
  return X.getLines();
}
function KG1(Z, J, $, X) {
  let Y = WG1(J, $, X && X.geometry), Q = bz(J);
  return c8.create(Q, J, Y, () => $.color, () => $.linesSize, () => "");
}
function GG1(Z, J, $) {
  let X = v1.createState(128, 64, $);
  for (let Y = 0, Q = Z.quads.length;Y < Q; ++Y) {
    hz(Z.quads[Y], t9, J.arcScale);
    let W = $B0(t9);
    X.currentGroup = Y, v1.addPrimitive(X, e.id, W), v1.addPrimitiveFlipped(X, e.id, W);
  }
  return v1.getMesh(X);
}
function HG1(Z, J, $, X) {
  let Y = GG1(J, $, X && X.geometry), Q = bz(J), W = (K) => cA(J.quads[K]);
  return c8.create(Q, J, Y, () => $.color, () => 1, W);
}
function NG1(Z, J, $) {
  let X = iQ.create(J, 128, 64, $);
  for (let Y = 0, Q = Z.quads.length;Y < Q; ++Y) {
    hz(Z.quads[Y], t9, J.arcScale), M.add(oQ, t9.arcDirA, t9.arcDirD), M.setMagnitude(oQ, oQ, t9.radius), M.add(oQ, t9.arcCenter, oQ);
    let W = k$(t9.angle).toFixed(2);
    if (W === "-0.00")
      W = "0.00";
    let K = J.customText || `${W}°`, H = Math.max(2, t9.sphereA.radius, t9.sphereB.radius, t9.sphereC.radius, t9.sphereD.radius) / 2;
    X.add(K, oQ[0], oQ[1], oQ[2], 0.1, H, Y);
  }
  return X.getText();
}
function qG1(Z, J, $, X) {
  let Y = NG1(J, $, X && X.geometry), Q = bz(J), W = (K) => cA(J.quads[K]);
  return c8.create(Q, J, Y, () => $.textColor, () => $.textSize, W);
}
function XB0(Z, J) {
  return V2.createMulti("Dihedral", Z, J, V2.StateBuilder, JB0);
}

// node_modules/molstar/lib/mol-geo/primitive/plane.js
var YB0 = {
  vertices: new Float32Array([
    -0.5,
    0.5,
    0,
    0.5,
    0.5,
    0,
    -0.5,
    -0.5,
    0,
    0.5,
    -0.5,
    0
  ]),
  normals: new Float32Array([
    0,
    0,
    1,
    0,
    0,
    1,
    0,
    0,
    1,
    0,
    0,
    1
  ]),
  indices: new Uint32Array([
    0,
    2,
    1,
    1,
    2,
    3
  ])
}, _g2 = {
  vertices: YB0.vertices,
  edges: new Uint32Array([0, 1, 2, 3, 3, 1, 2, 0])
};
function QB0() {
  return YB0;
}

// node_modules/molstar/lib/mol-repr/shape/loci/plane.js
var FG1 = {
  ...n1.Params,
  color: j.Color(c2.orange),
  scaleFactor: j.Numeric(1, { min: 0.1, max: 10, step: 0.1 })
}, WB0 = {
  plane: (Z, J) => I7(RG1, n1.Utils)
}, st = {
  ...FG1,
  visuals: j.MultiSelect(["plane"], j.objectToOptions(WB0))
};
function UG1(Z) {
  return `Best Fit Plane of ${mR(Z, { countsOnly: !0 })}`;
}
var cR = e(), ot = M();
function LG1(Z, J, $) {
  let X = v1.createState(256, 128, $), Q = W0.Loci.getPrincipalAxesMany(Z.locis).boxAxes, W = QB0();
  return M.add(ot, Q.origin, Q.dirC), e.targetTo(cR, ot, Q.origin, Q.dirB), e.scale(cR, cR, m7.size(ot, Q)), e.scaleUniformly(cR, cR, J.scaleFactor), e.setTranslation(cR, Q.origin), X.currentGroup = 0, v1.addPrimitive(X, cR, W), v1.addPrimitiveFlipped(X, cR, W), v1.getMesh(X);
}
function RG1(Z, J, $, X) {
  let Y = LG1(J, $, X && X.geometry), Q = UG1(J.locis);
  return c8.create(Q, J, Y, () => $.color, () => 1, () => Q);
}
function KB0(Z, J) {
  let $ = V2.createMulti("Plane", Z, J, V2.StateBuilder, WB0);
  return $.setState({ markerActions: W7.Highlighting }), $;
}

// node_modules/molstar/lib/mol-plugin-state/transforms/representation.js
var lA = B2.BuiltIn({
  name: "structure-representation-3d",
  display: "3D Representation",
  from: D0.Molecule.Structure,
  to: D0.Molecule.Structure.Representation3D,
  params: (Z, J) => {
    let { registry: $, themes: X } = J.representation.structure, Y = $.get($.default.name);
    if (!Z) {
      let K = {
        help: (G) => {
          let { name: H, params: N } = G, U = X.colorThemeRegistry.get(H).factory({}, N);
          return { description: U.description, legend: U.legend };
        }
      };
      return {
        type: j.Mapped($.default.name, $.types, (G) => j.Group($.get(G).getParams(X, s0.Empty))),
        colorTheme: j.Mapped(Y.defaultColorTheme.name, X.colorThemeRegistry.types, (G) => j.Group(X.colorThemeRegistry.get(G).getParams({ structure: s0.Empty })), K),
        sizeTheme: j.Mapped(Y.defaultSizeTheme.name, X.sizeThemeRegistry.types, (G) => j.Group(X.sizeThemeRegistry.get(G).getParams({ structure: s0.Empty })))
      };
    }
    let Q = { structure: Z.data }, W = {
      help: (K) => {
        let { name: G, params: H } = K, q = X.colorThemeRegistry.get(G).factory(Q, H);
        return { description: q.description, legend: q.legend };
      }
    };
    return {
      type: j.Mapped($.default.name, $.getApplicableTypes(Z.data), (K) => j.Group($.get(K).getParams(X, Z.data))),
      colorTheme: j.Mapped(Y.defaultColorTheme.name, X.colorThemeRegistry.getApplicableTypes(Q), (K) => j.Group(X.colorThemeRegistry.get(K).getParams(Q)), W),
      sizeTheme: j.Mapped(Y.defaultSizeTheme.name, X.sizeThemeRegistry.getApplicableTypes(Q), (K) => j.Group(X.sizeThemeRegistry.get(K).getParams(Q)))
    };
  }
})({
  canAutoUpdate({ a: Z, oldParams: J, newParams: $ }) {
    return Z.data.elementCount < 1e4 || J.type.name === $.type.name && $.type.params.quality !== "custom";
  },
  apply({ a: Z, params: J, cache: $ }, X) {
    return n0.create("Structure Representation", async (Y) => {
      var Q, W;
      let K = { runtime: Y, assetManager: X.managers.asset, errorContext: X.errorContext }, G = X.representation.structure.registry.get(J.type.name), H = ((Q = G.getData) === null || Q === void 0 ? void 0 : Q.call(G, Z.data, J.type.params)) || Z.data;
      if (G.ensureCustomProperties)
        await G.ensureCustomProperties.attach(K, H);
      let N = G.factory({ webgl: (W = X.canvas3d) === null || W === void 0 ? void 0 : W.webgl, ...X.representation.structure.themes }, G.getParams);
      await Q7.ensureDependencies(K, X.representation.structure.themes, { structure: H }, J), N.setTheme(Q7.create(X.representation.structure.themes, { structure: H }, J));
      let q = J.type.params || {};
      return await N.createOrUpdate(q, H).runInContext(Y), new D0.Molecule.Structure.Representation3D({ repr: N, sourceData: Z.data }, { label: G.label });
    });
  },
  update({ a: Z, b: J, oldParams: $, newParams: X, cache: Y }, Q) {
    return n0.create("Structure Representation", async (W) => {
      var K, G;
      if (X.type.name !== $.type.name)
        return T1.UpdateResult.Recreate;
      let H = Q.representation.structure.registry.get(X.type.name);
      if ((K = H.mustRecreate) === null || K === void 0 ? void 0 : K.call(H, $.type.params, X.type.params))
        return T1.UpdateResult.Recreate;
      let N = ((G = H.getData) === null || G === void 0 ? void 0 : G.call(H, Z.data, X.type.params)) || Z.data, q = { runtime: W, assetManager: Q.managers.asset, errorContext: Q.errorContext };
      if (H.ensureCustomProperties)
        await H.ensureCustomProperties.attach(q, N);
      Q7.releaseDependencies(Q.representation.structure.themes, { structure: J.data.sourceData }, $), await Q7.ensureDependencies(q, Q.representation.structure.themes, { structure: N }, X), J.data.repr.setTheme(Q7.create(Q.representation.structure.themes, { structure: N }, X));
      let U = { ...J.data.repr.props, ...X.type.params };
      return await J.data.repr.createOrUpdate(U, N).runInContext(W), J.data.sourceData = Z.data, T1.UpdateResult.Updated;
    });
  },
  dispose({ b: Z, params: J }, $) {
    if (!Z || !J)
      return;
    let X = Z.data.sourceData, Y = $.representation.structure.registry.get(J.type.name);
    if (Y.ensureCustomProperties)
      Y.ensureCustomProperties.detach(X);
    Q7.releaseDependencies($.representation.structure.themes, { structure: X }, J);
  },
  interpolate(Z, J, $) {
    if (Z.colorTheme.name !== "uniform" || J.colorTheme.name !== "uniform")
      return $ <= 0.5 ? Z : J;
    let X = Z.colorTheme.params.value, Y = J.colorTheme.params.value, Q = i0.interpolate(X, Y, $);
    return {
      type: $ <= 0.5 ? Z.type : J.type,
      colorTheme: { name: "uniform", params: { value: Q } },
      sizeTheme: $ <= 0.5 ? Z.sizeTheme : J.sizeTheme
    };
  }
}), EG1 = B2.BuiltIn({
  name: "unwind-structure-assembly-representation-3d",
  display: "Unwind Assembly 3D Representation",
  from: D0.Molecule.Structure.Representation3D,
  to: D0.Molecule.Structure.Representation3DState,
  params: { t: j.Numeric(0, { min: 0, max: 1, step: 0.01 }) }
})({
  canAutoUpdate() {
    return !0;
  },
  apply({ a: Z, params: J }) {
    let $ = Z.data.sourceData, X = new gR($);
    return ft($, X, J.t), new D0.Molecule.Structure.Representation3DState({
      state: { unitTransforms: X },
      initialState: { unitTransforms: new gR($) },
      info: $,
      repr: Z.data.repr
    }, { label: `Unwind T = ${J.t.toFixed(2)}` });
  },
  update({ a: Z, b: J, newParams: $, oldParams: X }) {
    let Y = J.data.info;
    if (Z.data.sourceData !== Y)
      return T1.UpdateResult.Recreate;
    if (Z.data.repr !== J.data.repr)
      return T1.UpdateResult.Recreate;
    if (X.t === $.t)
      return T1.UpdateResult.Unchanged;
    let Q = J.data.state.unitTransforms;
    return ft(Y, Q, $.t), J.label = `Unwind T = ${$.t.toFixed(2)}`, J.data.repr = Z.data.repr, T1.UpdateResult.Updated;
  }
}), OG1 = B2.BuiltIn({
  name: "explode-structure-representation-3d",
  display: "Explode 3D Representation",
  from: D0.Molecule.Structure.Representation3D,
  to: D0.Molecule.Structure.Representation3DState,
  params: { t: j.Numeric(0, { min: 0, max: 1, step: 0.01 }) }
})({
  canAutoUpdate() {
    return !0;
  },
  apply({ a: Z, params: J }) {
    let $ = Z.data.sourceData, X = new gR($);
    return ht($, X, J.t, $.root.boundary.sphere), new D0.Molecule.Structure.Representation3DState({
      state: { unitTransforms: X },
      initialState: { unitTransforms: new gR($) },
      info: $,
      repr: Z.data.repr
    }, { label: `Explode T = ${J.t.toFixed(2)}` });
  },
  update({ a: Z, b: J, newParams: $, oldParams: X }) {
    let Y = Z.data.sourceData;
    if (J.data.info !== Y)
      return T1.UpdateResult.Recreate;
    if (Z.data.repr !== J.data.repr)
      return T1.UpdateResult.Recreate;
    if (X.t === $.t)
      return T1.UpdateResult.Unchanged;
    let Q = J.data.state.unitTransforms;
    return ht(Y, Q, $.t, Y.root.boundary.sphere), J.label = `Explode T = ${$.t.toFixed(2)}`, J.data.repr = Z.data.repr, T1.UpdateResult.Updated;
  }
}), zG1 = B2.BuiltIn({
  name: "spin-structure-representation-3d",
  display: "Spin 3D Representation",
  from: D0.Molecule.Structure.Representation3D,
  to: D0.Molecule.Structure.Representation3DState,
  params: {
    t: j.Numeric(0, { min: 0, max: 1, step: 0.01 }),
    ...kA0
  }
})({
  canAutoUpdate() {
    return !0;
  },
  apply({ a: Z, params: J }) {
    let $ = Z.data.sourceData, X = new gR($), { axis: Y, origin: Q } = bt($.root, J);
    return xt($, X, J.t, Y, Q), new D0.Molecule.Structure.Representation3DState({
      state: { unitTransforms: X },
      initialState: { unitTransforms: new gR($) },
      info: $,
      repr: Z.data.repr
    }, { label: `Spin T = ${J.t.toFixed(2)}` });
  },
  update({ a: Z, b: J, newParams: $, oldParams: X }) {
    let Y = Z.data.sourceData;
    if (J.data.info !== Y)
      return T1.UpdateResult.Recreate;
    if (Z.data.repr !== J.data.repr)
      return T1.UpdateResult.Recreate;
    if (X.t === $.t && X.axis === $.axis && X.origin === $.origin)
      return T1.UpdateResult.Unchanged;
    let Q = J.data.state.unitTransforms, { axis: W, origin: K } = bt(Y.root, $);
    return xt(Y, Q, $.t, W, K), J.label = `Spin T = ${$.t.toFixed(2)}`, J.data.repr = Z.data.repr, T1.UpdateResult.Updated;
  }
}), DG1 = B2.BuiltIn({
  name: "overpaint-structure-representation-3d-from-script",
  display: "Overpaint 3D Representation",
  from: D0.Molecule.Structure.Representation3D,
  to: D0.Molecule.Structure.Representation3DState,
  params: () => ({
    layers: j.ObjectList({
      script: j.Script(cZ("(sel.atom.all)", "mol-script")),
      color: j.Color(c2.blueviolet),
      clear: j.Boolean(!1)
    }, (Z) => `${Z.clear ? "Clear" : i0.toRgbString(Z.color)}`, {
      defaultValue: [{
        script: cZ("(sel.atom.all)", "mol-script"),
        color: c2.blueviolet,
        clear: !1
      }]
    })
  })
})({
  canAutoUpdate() {
    return !0;
  },
  apply({ a: Z, params: J }) {
    let $ = Z.data.sourceData, X = Z.data.repr.geometryVersion, Y = rJ.ofScript(J.layers, $);
    return new D0.Molecule.Structure.Representation3DState({
      state: { overpaint: Y },
      initialState: { overpaint: rJ.Empty },
      info: { structure: $, geometryVersion: X },
      repr: Z.data.repr
    }, { label: `Overpaint (${Y.layers.length} Layers)` });
  },
  update({ a: Z, b: J, newParams: $, oldParams: X }) {
    let Y = J.data.info, Q = Z.data.sourceData;
    if (Q !== Y.structure)
      return T1.UpdateResult.Recreate;
    if (Z.data.repr !== J.data.repr)
      return T1.UpdateResult.Recreate;
    let W = Z.data.repr.geometryVersion;
    if (W !== Y.geometryVersion && j5(Z.data.repr.props))
      return T1.UpdateResult.Recreate;
    let K = J.data.state.overpaint, G = rJ.ofScript($.layers, Q);
    if (rJ.areEqual(K, G))
      return T1.UpdateResult.Unchanged;
    return Y.geometryVersion = W, J.data.state.overpaint = G, J.data.repr = Z.data.repr, J.label = `Overpaint (${G.layers.length} Layers)`, T1.UpdateResult.Updated;
  }
}), MG1 = B2.BuiltIn({
  name: "overpaint-structure-representation-3d-from-bundle",
  display: "Overpaint 3D Representation",
  from: D0.Molecule.Structure.Representation3D,
  to: D0.Molecule.Structure.Representation3DState,
  params: () => ({
    layers: j.ObjectList({
      bundle: j.Value(W0.Bundle.Empty),
      color: j.Color(c2.blueviolet),
      clear: j.Boolean(!1)
    }, (Z) => `${Z.clear ? "Clear" : i0.toRgbString(Z.color)}`, {
      defaultValue: [{
        bundle: W0.Bundle.Empty,
        color: c2.blueviolet,
        clear: !1
      }],
      isHidden: !0
    })
  })
})({
  canAutoUpdate() {
    return !0;
  },
  apply({ a: Z, params: J }) {
    let $ = Z.data.sourceData, X = Z.data.repr.geometryVersion, Y = rJ.ofBundle(J.layers, $);
    return new D0.Molecule.Structure.Representation3DState({
      state: { overpaint: Y },
      initialState: { overpaint: rJ.Empty },
      info: { structure: $, geometryVersion: X },
      repr: Z.data.repr
    }, { label: `Overpaint (${Y.layers.length} Layers)` });
  },
  update({ a: Z, b: J, newParams: $, oldParams: X }) {
    let Y = J.data.info, Q = Z.data.sourceData;
    if (Q !== Y.structure)
      return T1.UpdateResult.Recreate;
    if (Z.data.repr !== J.data.repr)
      return T1.UpdateResult.Recreate;
    let W = Z.data.repr.geometryVersion;
    if (W !== Y.geometryVersion && j5(Z.data.repr.props))
      return T1.UpdateResult.Recreate;
    let K = J.data.state.overpaint, G = rJ.ofBundle($.layers, Q);
    if (rJ.areEqual(K, G))
      return T1.UpdateResult.Unchanged;
    return Y.geometryVersion = W, J.data.state.overpaint = G, J.data.repr = Z.data.repr, J.label = `Overpaint (${G.layers.length} Layers)`, T1.UpdateResult.Updated;
  }
}), AG1 = B2.BuiltIn({
  name: "transparency-structure-representation-3d-from-script",
  display: "Transparency 3D Representation",
  from: D0.Molecule.Structure.Representation3D,
  to: D0.Molecule.Structure.Representation3DState,
  params: () => ({
    layers: j.ObjectList({
      script: j.Script(cZ("(sel.atom.all)", "mol-script")),
      value: j.Numeric(0.5, { min: 0, max: 1, step: 0.01 }, { label: "Transparency" })
    }, (Z) => `Transparency (${Z.value})`, {
      defaultValue: [{
        script: cZ("(sel.atom.all)", "mol-script"),
        value: 0.5
      }]
    })
  })
})({
  canAutoUpdate() {
    return !0;
  },
  apply({ a: Z, params: J }) {
    let $ = Z.data.sourceData, X = Z.data.repr.geometryVersion, Y = tJ.ofScript(J.layers, $);
    return new D0.Molecule.Structure.Representation3DState({
      state: { transparency: Y },
      initialState: { transparency: tJ.Empty },
      info: { structure: $, geometryVersion: X },
      repr: Z.data.repr
    }, { label: `Transparency (${Y.layers.length} Layers)` });
  },
  update({ a: Z, b: J, newParams: $, oldParams: X }) {
    let Y = J.data.info, Q = Z.data.sourceData;
    if (Q !== Y.structure)
      return T1.UpdateResult.Recreate;
    if (Z.data.repr !== J.data.repr)
      return T1.UpdateResult.Recreate;
    let W = Z.data.repr.geometryVersion;
    if (W !== Y.geometryVersion && j5(Z.data.repr.props))
      return T1.UpdateResult.Recreate;
    let K = J.data.state.transparency, G = tJ.ofScript($.layers, Q);
    if (tJ.areEqual(K, G))
      return T1.UpdateResult.Unchanged;
    return Y.geometryVersion = W, J.data.state.transparency = G, J.data.repr = Z.data.repr, J.label = `Transparency (${G.layers.length} Layers)`, T1.UpdateResult.Updated;
  }
}), BG1 = B2.BuiltIn({
  name: "transparency-structure-representation-3d-from-bundle",
  display: "Transparency 3D Representation",
  from: D0.Molecule.Structure.Representation3D,
  to: D0.Molecule.Structure.Representation3DState,
  params: () => ({
    layers: j.ObjectList({
      bundle: j.Value(W0.Bundle.Empty),
      value: j.Numeric(0.5, { min: 0, max: 1, step: 0.01 }, { label: "Transparency" })
    }, (Z) => `Transparency (${Z.value})`, {
      defaultValue: [{
        bundle: W0.Bundle.Empty,
        value: 0.5
      }],
      isHidden: !0
    })
  })
})({
  canAutoUpdate() {
    return !0;
  },
  apply({ a: Z, params: J }) {
    let $ = Z.data.sourceData, X = Z.data.repr.geometryVersion, Y = tJ.ofBundle(J.layers, $);
    return new D0.Molecule.Structure.Representation3DState({
      state: { transparency: Y },
      initialState: { transparency: tJ.Empty },
      info: { structure: $, geometryVersion: X },
      repr: Z.data.repr
    }, { label: `Transparency (${Y.layers.length} Layers)` });
  },
  update({ a: Z, b: J, newParams: $, oldParams: X }) {
    let Y = J.data.info, Q = Z.data.sourceData;
    if (Q !== Y.structure)
      return T1.UpdateResult.Recreate;
    if (Z.data.repr !== J.data.repr)
      return T1.UpdateResult.Recreate;
    let W = Z.data.repr.geometryVersion;
    if (W !== Y.geometryVersion && j5(Z.data.repr.props))
      return T1.UpdateResult.Recreate;
    let K = J.data.state.transparency, G = tJ.ofBundle($.layers, Q);
    if (tJ.areEqual(K, G))
      return T1.UpdateResult.Unchanged;
    return Y.geometryVersion = W, J.data.state.transparency = G, J.data.repr = Z.data.repr, J.label = `Transparency (${G.layers.length} Layers)`, T1.UpdateResult.Updated;
  }
}), wG1 = B2.BuiltIn({
  name: "emissive-structure-representation-3d-from-script",
  display: "Emissive 3D Representation",
  from: D0.Molecule.Structure.Representation3D,
  to: D0.Molecule.Structure.Representation3DState,
  params: () => ({
    layers: j.ObjectList({
      script: j.Script(cZ("(sel.atom.all)", "mol-script")),
      value: j.Numeric(0.5, { min: 0, max: 1, step: 0.01 }, { label: "Emissive" })
    }, (Z) => `Emissive (${Z.value})`, {
      defaultValue: [{
        script: cZ("(sel.atom.all)", "mol-script"),
        value: 0.5
      }]
    })
  })
})({
  canAutoUpdate() {
    return !0;
  },
  apply({ a: Z, params: J }) {
    let $ = Z.data.sourceData, X = Z.data.repr.geometryVersion, Y = Z$.ofScript(J.layers, $);
    return new D0.Molecule.Structure.Representation3DState({
      state: { emissive: Y },
      initialState: { emissive: Z$.Empty },
      info: { structure: $, geometryVersion: X },
      repr: Z.data.repr
    }, { label: `Emissive (${Y.layers.length} Layers)` });
  },
  update({ a: Z, b: J, newParams: $, oldParams: X }) {
    let Y = J.data.info, Q = Z.data.sourceData;
    if (Q !== Y.structure)
      return T1.UpdateResult.Recreate;
    if (Z.data.repr !== J.data.repr)
      return T1.UpdateResult.Recreate;
    let W = Z.data.repr.geometryVersion;
    if (W !== Y.geometryVersion && j5(Z.data.repr.props))
      return T1.UpdateResult.Recreate;
    let K = J.data.state.emissive, G = Z$.ofScript($.layers, Q);
    if (Z$.areEqual(K, G))
      return T1.UpdateResult.Unchanged;
    return Y.geometryVersion = W, J.data.state.emissive = G, J.data.repr = Z.data.repr, J.label = `Emissive (${G.layers.length} Layers)`, T1.UpdateResult.Updated;
  }
}), jG1 = B2.BuiltIn({
  name: "emissive-structure-representation-3d-from-bundle",
  display: "Emissive 3D Representation",
  from: D0.Molecule.Structure.Representation3D,
  to: D0.Molecule.Structure.Representation3DState,
  params: () => ({
    layers: j.ObjectList({
      bundle: j.Value(W0.Bundle.Empty),
      value: j.Numeric(0.5, { min: 0, max: 1, step: 0.01 }, { label: "Emissive" })
    }, (Z) => `Emissive (${Z.value})`, {
      defaultValue: [{
        bundle: W0.Bundle.Empty,
        value: 0.5
      }],
      isHidden: !0
    })
  })
})({
  canAutoUpdate() {
    return !0;
  },
  apply({ a: Z, params: J }) {
    let $ = Z.data.sourceData, X = Z.data.repr.geometryVersion, Y = Z$.ofBundle(J.layers, $);
    return new D0.Molecule.Structure.Representation3DState({
      state: { emissive: Y },
      initialState: { emissive: Z$.Empty },
      info: { structure: $, geometryVersion: X },
      repr: Z.data.repr
    }, { label: `Emissive (${Y.layers.length} Layers)` });
  },
  update({ a: Z, b: J, newParams: $, oldParams: X }) {
    let Y = J.data.info, Q = Z.data.sourceData;
    if (Q !== Y.structure)
      return T1.UpdateResult.Recreate;
    if (Z.data.repr !== J.data.repr)
      return T1.UpdateResult.Recreate;
    let W = Z.data.repr.geometryVersion;
    if (W !== Y.geometryVersion && j5(Z.data.repr.props))
      return T1.UpdateResult.Recreate;
    let K = J.data.state.emissive, G = Z$.ofBundle($.layers, Q);
    if (Z$.areEqual(K, G))
      return T1.UpdateResult.Unchanged;
    return Y.geometryVersion = W, J.data.state.emissive = G, J.data.repr = Z.data.repr, J.label = `Emissive (${G.layers.length} Layers)`, T1.UpdateResult.Updated;
  }
}), TG1 = B2.BuiltIn({
  name: "substance-structure-representation-3d-from-script",
  display: "Substance 3D Representation",
  from: D0.Molecule.Structure.Representation3D,
  to: D0.Molecule.Structure.Representation3DState,
  params: () => ({
    layers: j.ObjectList({
      script: j.Script(cZ("(sel.atom.all)", "mol-script")),
      material: C7.getParam(),
      clear: j.Boolean(!1)
    }, (Z) => `${Z.clear ? "Clear" : C7.toString(Z.material)}`, {
      defaultValue: [{
        script: cZ("(sel.atom.all)", "mol-script"),
        material: C7({ roughness: 1 }),
        clear: !1
      }]
    })
  })
})({
  canAutoUpdate() {
    return !0;
  },
  apply({ a: Z, params: J }) {
    let $ = Z.data.sourceData, X = Z.data.repr.geometryVersion, Y = eJ.ofScript(J.layers, $);
    return new D0.Molecule.Structure.Representation3DState({
      state: { substance: Y },
      initialState: { substance: eJ.Empty },
      info: { structure: $, geometryVersion: X },
      repr: Z.data.repr
    }, { label: `Substance (${Y.layers.length} Layers)` });
  },
  update({ a: Z, b: J, newParams: $, oldParams: X }) {
    let Y = J.data.info, Q = Z.data.sourceData;
    if (Q !== Y.structure)
      return T1.UpdateResult.Recreate;
    if (Z.data.repr !== J.data.repr)
      return T1.UpdateResult.Recreate;
    let W = Z.data.repr.geometryVersion;
    if (W !== Y.geometryVersion && j5(Z.data.repr.props))
      return T1.UpdateResult.Recreate;
    let K = J.data.state.substance, G = eJ.ofScript($.layers, Q);
    if (eJ.areEqual(K, G))
      return T1.UpdateResult.Unchanged;
    return Y.geometryVersion = W, J.data.state.substance = G, J.data.repr = Z.data.repr, J.label = `Substance (${G.layers.length} Layers)`, T1.UpdateResult.Updated;
  }
}), _G1 = B2.BuiltIn({
  name: "substance-structure-representation-3d-from-bundle",
  display: "Substance 3D Representation",
  from: D0.Molecule.Structure.Representation3D,
  to: D0.Molecule.Structure.Representation3DState,
  params: () => ({
    layers: j.ObjectList({
      bundle: j.Value(W0.Bundle.Empty),
      material: C7.getParam(),
      clear: j.Boolean(!1)
    }, (Z) => `${Z.clear ? "Clear" : C7.toString(Z.material)}`, {
      defaultValue: [{
        bundle: W0.Bundle.Empty,
        material: C7({ roughness: 1 }),
        clear: !1
      }],
      isHidden: !0
    })
  })
})({
  canAutoUpdate() {
    return !0;
  },
  apply({ a: Z, params: J }) {
    let $ = Z.data.sourceData, X = Z.data.repr.geometryVersion, Y = eJ.ofBundle(J.layers, $);
    return new D0.Molecule.Structure.Representation3DState({
      state: { substance: Y },
      initialState: { substance: eJ.Empty },
      info: { structure: $, geometryVersion: X },
      repr: Z.data.repr
    }, { label: `Substance (${Y.layers.length} Layers)` });
  },
  update({ a: Z, b: J, newParams: $, oldParams: X }) {
    let Y = J.data.info, Q = Z.data.sourceData;
    if (Q !== Y.structure)
      return T1.UpdateResult.Recreate;
    if (Z.data.repr !== J.data.repr)
      return T1.UpdateResult.Recreate;
    let W = Z.data.repr.geometryVersion;
    if (W !== Y.geometryVersion && j5(Z.data.repr.props))
      return T1.UpdateResult.Recreate;
    let K = J.data.state.substance, G = eJ.ofBundle($.layers, Q);
    if (eJ.areEqual(K, G))
      return T1.UpdateResult.Unchanged;
    return Y.geometryVersion = W, J.data.state.substance = G, J.data.repr = Z.data.repr, J.label = `Substance (${G.layers.length} Layers)`, T1.UpdateResult.Updated;
  }
}), VG1 = B2.BuiltIn({
  name: "clipping-structure-representation-3d-from-script",
  display: "Clipping 3D Representation",
  from: D0.Molecule.Structure.Representation3D,
  to: D0.Molecule.Structure.Representation3DState,
  params: () => ({
    layers: j.ObjectList({
      script: j.Script(cZ("(sel.atom.all)", "mol-script")),
      groups: j.Converted((Z) => $9.Groups.toNames(Z), (Z) => $9.Groups.fromNames(Z), j.MultiSelect(uO($9.Groups.Names), j.objectToOptions($9.Groups.Names)))
    }, (Z) => `${$9.Groups.toNames(Z.groups).length} group(s)`, {
      defaultValue: [{
        script: cZ("(sel.atom.all)", "mol-script"),
        groups: $9.Groups.Flag.None
      }]
    })
  })
})({
  canAutoUpdate() {
    return !0;
  },
  apply({ a: Z, params: J }) {
    let $ = Z.data.sourceData, X = $9.ofScript(J.layers, $);
    return new D0.Molecule.Structure.Representation3DState({
      state: { clipping: X },
      initialState: { clipping: $9.Empty },
      info: $,
      repr: Z.data.repr
    }, { label: `Clipping (${X.layers.length} Layers)` });
  },
  update({ a: Z, b: J, newParams: $, oldParams: X }) {
    let Y = J.data.info;
    if (Z.data.sourceData !== Y)
      return T1.UpdateResult.Recreate;
    if (Z.data.repr !== J.data.repr)
      return T1.UpdateResult.Recreate;
    let Q = J.data.state.clipping, W = $9.ofScript($.layers, Y);
    if ($9.areEqual(Q, W))
      return T1.UpdateResult.Unchanged;
    return J.data.state.clipping = W, J.data.repr = Z.data.repr, J.label = `Clipping (${W.layers.length} Layers)`, T1.UpdateResult.Updated;
  }
}), IG1 = B2.BuiltIn({
  name: "clipping-structure-representation-3d-from-bundle",
  display: "Clipping 3D Representation",
  from: D0.Molecule.Structure.Representation3D,
  to: D0.Molecule.Structure.Representation3DState,
  params: () => ({
    layers: j.ObjectList({
      bundle: j.Value(W0.Bundle.Empty),
      groups: j.Converted((Z) => $9.Groups.toNames(Z), (Z) => $9.Groups.fromNames(Z), j.MultiSelect(uO($9.Groups.Names), j.objectToOptions($9.Groups.Names)))
    }, (Z) => `${$9.Groups.toNames(Z.groups).length} group(s)`, {
      defaultValue: [{
        bundle: W0.Bundle.Empty,
        groups: $9.Groups.Flag.None
      }],
      isHidden: !0
    })
  })
})({
  canAutoUpdate() {
    return !0;
  },
  apply({ a: Z, params: J }) {
    let $ = Z.data.sourceData, X = $9.ofBundle(J.layers, $);
    return new D0.Molecule.Structure.Representation3DState({
      state: { clipping: X },
      initialState: { clipping: $9.Empty },
      info: $,
      repr: Z.data.repr
    }, { label: `Clipping (${X.layers.length} Layers)` });
  },
  update({ a: Z, b: J, newParams: $, oldParams: X }) {
    let Y = J.data.info;
    if (Z.data.sourceData !== Y)
      return T1.UpdateResult.Recreate;
    if (Z.data.repr !== J.data.repr)
      return T1.UpdateResult.Recreate;
    let Q = J.data.state.clipping, W = $9.ofBundle($.layers, Y);
    if ($9.areEqual(Q, W))
      return T1.UpdateResult.Unchanged;
    return J.data.state.clipping = W, J.data.repr = Z.data.repr, J.label = `Clipping (${W.layers.length} Layers)`, T1.UpdateResult.Updated;
  }
}), PG1 = B2.BuiltIn({
  name: "theme-strength-representation-3d",
  display: "Theme Strength 3D Representation",
  from: D0.Molecule.Structure.Representation3D,
  to: D0.Molecule.Structure.Representation3DState,
  params: () => ({
    overpaintStrength: j.Numeric(1, { min: 0, max: 1, step: 0.01 }),
    transparencyStrength: j.Numeric(1, { min: 0, max: 1, step: 0.01 }),
    emissiveStrength: j.Numeric(1, { min: 0, max: 1, step: 0.01 }),
    substanceStrength: j.Numeric(1, { min: 0, max: 1, step: 0.01 })
  })
})({
  canAutoUpdate() {
    return !0;
  },
  apply({ a: Z, params: J }) {
    return new D0.Molecule.Structure.Representation3DState({
      state: {
        themeStrength: {
          overpaint: J.overpaintStrength,
          transparency: J.transparencyStrength,
          emissive: J.emissiveStrength,
          substance: J.substanceStrength
        }
      },
      initialState: {
        themeStrength: { overpaint: 1, transparency: 1, emissive: 1, substance: 1 }
      },
      info: {},
      repr: Z.data.repr
    }, { label: "Theme Strength", description: `${J.overpaintStrength.toFixed(2)}, ${J.transparencyStrength.toFixed(2)}, ${J.emissiveStrength.toFixed(2)}, ${J.substanceStrength.toFixed(2)}` });
  },
  update({ a: Z, b: J, newParams: $, oldParams: X }) {
    var Y, Q, W, K;
    if ($.overpaintStrength === ((Y = J.data.state.themeStrength) === null || Y === void 0 ? void 0 : Y.overpaint) && $.transparencyStrength === ((Q = J.data.state.themeStrength) === null || Q === void 0 ? void 0 : Q.transparency) && $.emissiveStrength === ((W = J.data.state.themeStrength) === null || W === void 0 ? void 0 : W.emissive) && $.substanceStrength === ((K = J.data.state.themeStrength) === null || K === void 0 ? void 0 : K.substance))
      return T1.UpdateResult.Unchanged;
    return J.data.state.themeStrength = {
      overpaint: $.overpaintStrength,
      transparency: $.transparencyStrength,
      emissive: $.emissiveStrength,
      substance: $.substanceStrength
    }, J.data.repr = Z.data.repr, J.label = "Theme Strength", J.description = `${$.overpaintStrength.toFixed(2)}, ${$.transparencyStrength.toFixed(2)}, ${$.emissiveStrength.toFixed(2)}, ${$.substanceStrength.toFixed(2)}`, T1.UpdateResult.Updated;
  },
  interpolate(Z, J, $) {
    return {
      overpaintStrength: pZ(Z.overpaintStrength, J.overpaintStrength, $),
      transparencyStrength: pZ(Z.transparencyStrength, J.transparencyStrength, $),
      emissiveStrength: pZ(Z.emissiveStrength, J.emissiveStrength, $),
      substanceStrength: pZ(Z.substanceStrength, J.substanceStrength, $)
    };
  }
}), l3;
(function(Z) {
  function J(Y, Q, W, K, G, H, N, q) {
    let U = Y.representation.volume.registry.get(Q), F = Y.representation.volume.themes.colorThemeRegistry.get(G || U.defaultColorTheme.name), E = Y.representation.volume.themes.sizeThemeRegistry.get(N || U.defaultSizeTheme.name), R = j.getDefaultValues(U.getParams(Y.representation.volume.themes, W));
    return {
      type: { name: Q, params: K ? { ...R, ...K } : R },
      colorTheme: { name: F.name, params: H ? { ...F.defaultValues, ...H } : F.defaultValues },
      sizeTheme: { name: E.name, params: q ? { ...E.defaultValues, ...q } : E.defaultValues }
    };
  }
  Z.getDefaultParams = J;
  function $(Y, Q, W, K, G, H, N) {
    let q = Y.representation.volume.registry.get(Q), U = Y.representation.volume.themes.colorThemeRegistry.get(K || q.defaultColorTheme.name), F = Y.representation.volume.themes.sizeThemeRegistry.get(H || q.defaultSizeTheme.name);
    return {
      type: { name: Q, params: W ? { ...q.defaultValues, ...W } : q.defaultValues },
      colorTheme: { name: q.defaultColorTheme.name, params: G ? { ...U.defaultValues, ...G } : U.defaultValues },
      sizeTheme: { name: q.defaultSizeTheme.name, params: N ? { ...F.defaultValues, ...N } : F.defaultValues }
    };
  }
  Z.getDefaultParamsStatic = $;
  function X(Y) {
    var Q, W, K, G;
    if (Y.isoValue)
      return Q1.IsoValue.toString(Y.isoValue);
    else if ((W = (Q = Y.renderMode) === null || Q === void 0 ? void 0 : Q.params) === null || W === void 0 ? void 0 : W.isoValue)
      return Q1.IsoValue.toString((G = (K = Y.renderMode) === null || K === void 0 ? void 0 : K.params) === null || G === void 0 ? void 0 : G.isoValue);
  }
  Z.getDescription = X;
})(l3 || (l3 = {}));
var CG1 = B2.BuiltIn({
  name: "volume-representation-3d",
  display: "3D Representation",
  from: D0.Volume.Data,
  to: D0.Volume.Representation3D,
  params: (Z, J) => {
    let { registry: $, themes: X } = J.representation.volume, Y = $.get($.default.name);
    if (!Z)
      return {
        type: j.Mapped($.default.name, $.types, (W) => j.Group($.get(W).getParams(X, Q1.One))),
        colorTheme: j.Mapped(Y.defaultColorTheme.name, X.colorThemeRegistry.types, (W) => j.Group(X.colorThemeRegistry.get(W).getParams({ volume: Q1.One }))),
        sizeTheme: j.Mapped(Y.defaultSizeTheme.name, X.sizeThemeRegistry.types, (W) => j.Group(X.sizeThemeRegistry.get(W).getParams({ volume: Q1.One })))
      };
    let Q = { volume: Z.data };
    return {
      type: j.Mapped($.default.name, $.types, (W) => j.Group($.get(W).getParams(X, Z.data))),
      colorTheme: j.Mapped(Y.defaultColorTheme.name, X.colorThemeRegistry.getApplicableTypes(Q), (W) => j.Group(X.colorThemeRegistry.get(W).getParams(Q))),
      sizeTheme: j.Mapped(Y.defaultSizeTheme.name, X.sizeThemeRegistry.getApplicableTypes(Q), (W) => j.Group(X.sizeThemeRegistry.get(W).getParams(Q)))
    };
  }
})({
  canAutoUpdate({ oldParams: Z, newParams: J }) {
    return Z.type.name === J.type.name;
  },
  apply({ a: Z, params: J }, $) {
    return n0.create("Volume Representation", async (X) => {
      var Y;
      let Q = { runtime: X, assetManager: $.managers.asset, errorContext: $.errorContext }, W = $.representation.volume.registry.get(J.type.name);
      if (W.ensureCustomProperties)
        await W.ensureCustomProperties.attach(Q, Z.data);
      let K = W.factory({ webgl: (Y = $.canvas3d) === null || Y === void 0 ? void 0 : Y.webgl, ...$.representation.volume.themes }, W.getParams);
      K.setTheme(Q7.create($.representation.volume.themes, { volume: Z.data, locationKinds: W.locationKinds }, J));
      let G = J.type.params || {};
      return await K.createOrUpdate(G, Z.data).runInContext(X), new D0.Volume.Representation3D({ repr: K, sourceData: Z.data }, { label: W.label, description: l3.getDescription(G) });
    });
  },
  update({ a: Z, b: J, oldParams: $, newParams: X }, Y) {
    return n0.create("Volume Representation", async (Q) => {
      var W;
      let K = Y.representation.volume.registry.get($.type.name);
      if (X.type.name !== $.type.name)
        return (W = K.ensureCustomProperties) === null || W === void 0 || W.detach(Z.data), T1.UpdateResult.Recreate;
      let G = { ...J.data.repr.props, ...X.type.params };
      return J.data.repr.setTheme(Q7.create(Y.representation.volume.themes, { volume: Z.data, locationKinds: K.locationKinds }, X)), await J.data.repr.createOrUpdate(G, Z.data).runInContext(Q), J.data.sourceData = Z.data, J.description = l3.getDescription(G), T1.UpdateResult.Updated;
    });
  }
});
var kG1 = B2.BuiltIn({
  name: "shape-representation-3d",
  display: "3D Representation",
  from: D0.Shape.Provider,
  to: D0.Shape.Representation3D,
  params: (Z, J) => {
    return Z ? Z.data.params : q1.Params;
  }
})({
  canAutoUpdate() {
    return !0;
  },
  apply({ a: Z, params: J }) {
    return n0.create("Shape Representation", async ($) => {
      let X = { ...j.getDefaultValues(Z.data.params), ...J }, Y = I7(Z.data.getShape, Z.data.geometryUtils);
      return await Y.createOrUpdate(X, Z.data.data).runInContext($), new D0.Shape.Representation3D({ repr: Y, sourceData: Z.data }, { label: Z.data.label });
    });
  },
  update({ a: Z, b: J, newParams: $ }) {
    return n0.create("Shape Representation", async (X) => {
      let Y = { ...J.data.repr.props, ...$ };
      return await J.data.repr.createOrUpdate(Y, Z.data.data).runInContext(X), J.data.sourceData = Z.data, T1.UpdateResult.Updated;
    });
  }
});
var vG1 = B2.BuiltIn({
  name: "model-unitcell-3d",
  display: "Model Unit Cell",
  from: D0.Molecule.Model,
  to: D0.Shape.Representation3D,
  params: () => ({
    ...yt
  })
})({
  isApplicable: (Z) => !!T9.Provider.get(Z.data),
  canAutoUpdate({ oldParams: Z, newParams: J }) {
    return !0;
  },
  apply({ a: Z, params: J }, $) {
    return n0.create("Model Unit Cell", async (X) => {
      var Y;
      let Q = T9.Provider.get(Z.data);
      if (!Q)
        return LZ.Null;
      let W = gt(Z.data, Q, J), K = SA0({ webgl: (Y = $.canvas3d) === null || Y === void 0 ? void 0 : Y.webgl, ...$.representation.structure.themes }, () => yt);
      return await K.createOrUpdate(J, W).runInContext(X), new D0.Shape.Representation3D({ repr: K, sourceData: W }, { label: "Unit Cell", description: Q.spacegroup.name });
    });
  },
  update({ a: Z, b: J, newParams: $ }) {
    return n0.create("Model Unit Cell", async (X) => {
      let Y = T9.Provider.get(Z.data);
      if (!Y)
        return T1.UpdateResult.Null;
      let Q = { ...J.data.repr.props, ...$ }, W = gt(Z.data, Y, Q);
      return await J.data.repr.createOrUpdate(Q, W).runInContext(X), J.data.sourceData = W, T1.UpdateResult.Updated;
    });
  }
});
var SG1 = B2.BuiltIn({
  name: "structure-bounding-box-3d",
  display: "Bounding Box",
  from: D0.Molecule.Structure,
  to: D0.Shape.Representation3D,
  params: {
    radius: j.Numeric(0.05, { min: 0.01, max: 4, step: 0.01 }, { isEssential: !0 }),
    color: j.Color(c2.red, { isEssential: !0 }),
    ...n1.Params
  }
})({
  canAutoUpdate() {
    return !0;
  },
  apply({ a: Z, params: J }, $) {
    return n0.create("Bounding Box", async (X) => {
      let Y = I7((Q, W, K, G) => {
        let H = vb(W.box, W.radius, G === null || G === void 0 ? void 0 : G.geometry);
        return c8.create("Bouding Box", W, H, () => W.color, () => 1, () => "Bounding Box");
      }, n1.Utils);
      return await Y.createOrUpdate(J, { box: Z.data.boundary.box, radius: J.radius, color: J.color }).runInContext(X), new D0.Shape.Representation3D({ repr: Y, sourceData: Z.data }, { label: "Bounding Box" });
    });
  },
  update({ a: Z, b: J, oldParams: $, newParams: X }, Y) {
    return n0.create("Bounding Box", async (Q) => {
      return await J.data.repr.createOrUpdate(X, { box: Z.data.boundary.box, radius: X.radius, color: X.color }).runInContext(Q), J.data.sourceData = Z.data, T1.UpdateResult.Updated;
    });
  }
});
var fG1 = B2.BuiltIn({
  name: "structure-selections-distance-3d",
  display: "3D Distance",
  from: D0.Molecule.Structure.Selections,
  to: D0.Shape.Representation3D,
  params: () => ({
    ...dt
  })
})({
  canAutoUpdate({ oldParams: Z, newParams: J }) {
    return !0;
  },
  apply({ a: Z, params: J }, $) {
    return n0.create("Structure Distance", async (X) => {
      var Y;
      let Q = Kt(Z.data), W = mA0({ webgl: (Y = $.canvas3d) === null || Y === void 0 ? void 0 : Y.webgl, ...$.representation.structure.themes }, () => dt);
      return await W.createOrUpdate(J, Q).runInContext(X), new D0.Shape.Representation3D({ repr: W, sourceData: Q }, { label: "Distance" });
    });
  },
  update({ a: Z, b: J, oldParams: $, newParams: X }, Y) {
    return n0.create("Structure Distance", async (Q) => {
      let W = { ...J.data.repr.props, ...X }, K = Kt(Z.data);
      return await J.data.repr.createOrUpdate(W, K).runInContext(Q), J.data.sourceData = K, T1.UpdateResult.Updated;
    });
  }
});
var hG1 = B2.BuiltIn({
  name: "structure-selections-angle-3d",
  display: "3D Angle",
  from: D0.Molecule.Structure.Selections,
  to: D0.Shape.Representation3D,
  params: () => ({
    ...nt
  })
})({
  canAutoUpdate({ oldParams: Z, newParams: J }) {
    return !0;
  },
  apply({ a: Z, params: J }, $) {
    return n0.create("Structure Angle", async (X) => {
      var Y;
      let Q = Gt(Z.data), W = eA0({ webgl: (Y = $.canvas3d) === null || Y === void 0 ? void 0 : Y.webgl, ...$.representation.structure.themes }, () => nt);
      return await W.createOrUpdate(J, Q).runInContext(X), new D0.Shape.Representation3D({ repr: W, sourceData: Q }, { label: "Angle" });
    });
  },
  update({ a: Z, b: J, oldParams: $, newParams: X }, Y) {
    return n0.create("Structure Angle", async (Q) => {
      let W = { ...J.data.repr.props, ...X }, K = Gt(Z.data);
      return await J.data.repr.createOrUpdate(W, K).runInContext(Q), J.data.sourceData = K, T1.UpdateResult.Updated;
    });
  }
});
var bG1 = B2.BuiltIn({
  name: "structure-selections-dihedral-3d",
  display: "3D Dihedral",
  from: D0.Molecule.Structure.Selections,
  to: D0.Shape.Representation3D,
  params: () => ({
    ...it
  })
})({
  canAutoUpdate({ oldParams: Z, newParams: J }) {
    return !0;
  },
  apply({ a: Z, params: J }, $) {
    return n0.create("Structure Dihedral", async (X) => {
      var Y;
      let Q = Ht(Z.data), W = XB0({ webgl: (Y = $.canvas3d) === null || Y === void 0 ? void 0 : Y.webgl, ...$.representation.structure.themes }, () => it);
      return await W.createOrUpdate(J, Q).runInContext(X), new D0.Shape.Representation3D({ repr: W, sourceData: Q }, { label: "Dihedral" });
    });
  },
  update({ a: Z, b: J, oldParams: $, newParams: X }, Y) {
    return n0.create("Structure Dihedral", async (Q) => {
      let W = { ...J.data.repr.props, ...X }, K = Ht(Z.data);
      return await J.data.repr.createOrUpdate(W, K).runInContext(Q), J.data.sourceData = K, T1.UpdateResult.Updated;
    });
  }
});
var xG1 = B2.BuiltIn({
  name: "structure-selections-label-3d",
  display: "3D Label",
  from: D0.Molecule.Structure.Selections,
  to: D0.Shape.Representation3D,
  params: () => ({
    ...pt
  })
})({
  canAutoUpdate({ oldParams: Z, newParams: J }) {
    return !0;
  },
  apply({ a: Z, params: J }, $) {
    return n0.create("Structure Label", async (X) => {
      var Y, Q, W;
      let K = Nt(Z.data), G = pA0({ webgl: (Y = $.canvas3d) === null || Y === void 0 ? void 0 : Y.webgl, ...$.representation.structure.themes }, () => pt);
      await G.createOrUpdate(J, K).runInContext(X);
      let H = !!(((Q = J.snapshotKey) === null || Q === void 0 ? void 0 : Q.trim()) || ((W = J.tooltip) === null || W === void 0 ? void 0 : W.trim()));
      return G.setState({ pickable: H, markerActions: H ? W7.Highlighting : x2.None }), new D0.Shape.Representation3D({ repr: G, sourceData: K }, { label: "Label" });
    });
  },
  update({ a: Z, b: J, oldParams: $, newParams: X }, Y) {
    return n0.create("Structure Label", async (Q) => {
      var W, K;
      let G = { ...J.data.repr.props, ...X }, H = Nt(Z.data);
      await J.data.repr.createOrUpdate(G, H).runInContext(Q), J.data.sourceData = H;
      let N = !!(((W = X.snapshotKey) === null || W === void 0 ? void 0 : W.trim()) || ((K = X.tooltip) === null || K === void 0 ? void 0 : K.trim()));
      return J.data.repr.setState({ pickable: N, markerActions: N ? W7.Highlighting : x2.None }), T1.UpdateResult.Updated;
    });
  }
});
var yG1 = B2.BuiltIn({
  name: "structure-selections-orientation-3d",
  display: "3D Orientation",
  from: D0.Molecule.Structure.Selections,
  to: D0.Shape.Representation3D,
  params: () => ({
    ...lt
  })
})({
  canAutoUpdate({ oldParams: Z, newParams: J }) {
    return !0;
  },
  apply({ a: Z, params: J }, $) {
    return n0.create("Structure Orientation", async (X) => {
      var Y;
      let Q = qt(Z.data), W = oA0({ webgl: (Y = $.canvas3d) === null || Y === void 0 ? void 0 : Y.webgl, ...$.representation.structure.themes }, () => lt);
      return await W.createOrUpdate(J, Q).runInContext(X), new D0.Shape.Representation3D({ repr: W, sourceData: Q }, { label: "Orientation" });
    });
  },
  update({ a: Z, b: J, oldParams: $, newParams: X }, Y) {
    return n0.create("Structure Orientation", async (Q) => {
      let W = { ...J.data.repr.props, ...X }, K = qt(Z.data);
      return await J.data.repr.createOrUpdate(W, K).runInContext(Q), J.data.sourceData = K, T1.UpdateResult.Updated;
    });
  }
});
var gG1 = B2.BuiltIn({
  name: "structure-selections-plane-3d",
  display: "3D Plane",
  from: D0.Molecule.Structure.Selections,
  to: D0.Shape.Representation3D,
  params: () => ({
    ...st
  })
})({
  canAutoUpdate({ oldParams: Z, newParams: J }) {
    return !0;
  },
  apply({ a: Z, params: J }, $) {
    return n0.create("Structure Plane", async (X) => {
      var Y;
      let Q = Ft(Z.data), W = KB0({ webgl: (Y = $.canvas3d) === null || Y === void 0 ? void 0 : Y.webgl, ...$.representation.structure.themes }, () => st);
      return await W.createOrUpdate(J, Q).runInContext(X), new D0.Shape.Representation3D({ repr: W, sourceData: Q }, { label: "Plane" });
    });
  },
  update({ a: Z, b: J, oldParams: $, newParams: X }, Y) {
    return n0.create("Structure Plane", async (Q) => {
      let W = { ...J.data.repr.props, ...X }, K = Ft(Z.data);
      return await J.data.repr.createOrUpdate(W, K).runInContext(Q), J.data.sourceData = K, T1.UpdateResult.Updated;
    });
  }
});

// node_modules/molstar/lib/mol-geo/util/marching-cubes/tables.js
function lR(Z, J, $) {
  return { i: Z, j: J, k: $ };
}
function n3(Z, J) {
  return { a: Z, b: J };
}
var fJ = [
  lR(0, 0, 0),
  lR(1, 0, 0),
  lR(1, 1, 0),
  lR(0, 1, 0),
  lR(0, 0, 1),
  lR(1, 0, 1),
  lR(1, 1, 1),
  lR(0, 1, 1)
], GB0 = [
  n3(fJ[0], fJ[1]),
  n3(fJ[1], fJ[2]),
  n3(fJ[2], fJ[3]),
  n3(fJ[3], fJ[0]),
  n3(fJ[4], fJ[5]),
  n3(fJ[5], fJ[6]),
  n3(fJ[6], fJ[7]),
  n3(fJ[7], fJ[4]),
  n3(fJ[0], fJ[4]),
  n3(fJ[1], fJ[5]),
  n3(fJ[2], fJ[6]),
  n3(fJ[3], fJ[7])
], HB0 = [
  { 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 }
], NB0 = [
  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
], nR = [
  [],
  [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],
  []
], sb = [
  [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]
];

// node_modules/molstar/lib/mol-geo/util/marching-cubes/builder.js
function qB0(Z, J) {
  let $ = Math.min(65536, Z * 4), X = B1.create(Float32Array, 3, Z, J && J.vertexBuffer.ref.value), Y = B1.create(Float32Array, 3, Z, J && J.normalBuffer.ref.value), Q = B1.create(Float32Array, 1, Z, J && J.groupBuffer.ref.value), W = B1.create(Uint32Array, 3, $, J && J.indexBuffer.ref.value), K = 0, G = 0;
  return {
    addVertex: (H, N, q) => {
      return ++K, B1.add3(X, H, N, q);
    },
    addNormal: (H, N, q) => {
      B1.add3(Y, H, N, q);
    },
    addGroup: (H) => {
      B1.add(Q, H);
    },
    addTriangle: (H, N, q, U) => {
      let F = H[N], E = H[q], R = H[U];
      if (F >= 0 && E >= 0 && R >= 0)
        ++G, B1.add3(W, F, E, R);
    },
    get: () => {
      let H = B1.compact(X, !0), N = B1.compact(Y, !0), q = B1.compact(W, !0), U = B1.compact(Q, !0);
      return n1.create(H, q, N, U, K, G, J);
    }
  };
}
function FB0(Z, J) {
  let $ = B1.create(Float32Array, 3, Z), X = B1.create(Float32Array, 1, Z), Y = B1.create(Float32Array, 2, Z), Q = 0;
  return {
    addVertex: (W, K, G) => {
      return B1.add3($, W, K, G);
    },
    addNormal: () => xX,
    addGroup: (W) => {
      B1.add(X, W);
    },
    addTriangle: (W, K, G, H, N) => {
      let q = W[K], U = W[G], F = W[H];
      if (q >= 0 && U >= 0 && F >= 0) {
        if (sb[K][G] & N)
          ++Q, B1.add2(Y, W[K], W[G]);
        if (sb[G][H] & N)
          ++Q, B1.add2(Y, W[G], W[H]);
        if (sb[K][H] & N)
          ++Q, B1.add2(Y, W[K], W[H]);
      }
    },
    get: () => {
      let W = B1.compact($, !0), K = B1.compact(Y, !0), G = B1.compact(X, !0), H = L$.create(Q, Q / 10, J);
      for (let N = 0;N < Q; ++N) {
        let q = K[N * 2], U = K[N * 2 + 1];
        H.add(W[q * 3], W[q * 3 + 1], W[q * 3 + 2], W[U * 3], W[U * 3 + 1], W[U * 3 + 2], G[q]);
      }
      return H.getLines();
    }
  };
}

// node_modules/molstar/lib/mol-geo/util/marching-cubes/algorithm.js
function UB0(Z) {
  return {
    ...Z,
    bottomLeft: t7(Z.bottomLeft, [0, 0, 0]),
    topRight: t7(Z.topRight, Z.scalarField.space.dimensions)
  };
}
function LB0(Z) {
  return {
    dX: Z.topRight[0] - Z.bottomLeft[0],
    dY: Z.topRight[1] - Z.bottomLeft[1],
    dZ: Z.topRight[2] - Z.bottomLeft[2]
  };
}
function Fq(Z, J) {
  return n0.create("Marching Cubes Mesh", async ($) => {
    let X = UB0(Z), { dX: Y, dY: Q, dZ: W } = LB0(X), K = Math.min(262144, Math.max(Y * Q * W / 32, 1024)), G = qB0(K, J);
    return await new at($, G, X).run(), G.get();
  });
}
function nA(Z, J) {
  return n0.create("Marching Cubes Lines", async ($) => {
    let X = UB0(Z), { dX: Y, dY: Q, dZ: W } = LB0(X), K = Math.min(262144, Math.max(Y * Q * W / 32, 1024)), G = FB0(K, J);
    return await new at($, G, X).run(), G.get();
  });
}

class at {
  async doSlices() {
    let Z = 0;
    this.edgeFilter = 15;
    for (let J = this.minZ;J < this.maxZ; J++, this.edgeFilter &= -5)
      if (this.slice(J), Z += this.sliceSize, this.ctx.shouldUpdate)
        await this.ctx.update({ message: "Computing surface...", current: Z, max: this.size });
  }
  slice(Z) {
    this.edgeFilter |= 2;
    for (let J = this.minY;J < this.maxY; J++, this.edgeFilter &= -3) {
      this.edgeFilter |= 1;
      for (let $ = this.minX;$ < this.maxX; $++, this.edgeFilter &= -2)
        this.state.processCell($, J, Z, this.edgeFilter);
    }
    this.state.clearEdgeVertexIndexSlice(Z);
  }
  async run() {
    await this.doSlices();
  }
  constructor(Z, J, $) {
    this.ctx = Z, this.minX = 0, this.minY = 0, this.minZ = 0, this.maxX = 0, this.maxY = 0, this.maxZ = 0, this.state = new RB0(J, $), this.minX = $.bottomLeft[0], this.minY = $.bottomLeft[1], this.minZ = $.bottomLeft[2], this.maxX = $.topRight[0] - 1, this.maxY = $.topRight[1] - 1, this.maxZ = $.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);
  }
}

class RB0 {
  get3dOffsetFromEdgeInfo(Z) {
    return this.nX * ((this.k + Z.k) % 2 * this.nY + this.j + Z.j) + this.i + Z.i;
  }
  clearEdgeVertexIndexSlice(Z) {
    let J = Z % 2 === 0 ? 0 : 3 * this.nX * this.nY, $ = Z % 2 === 0 ? 3 * this.nX * this.nY : this.verticesOnEdges.length;
    this.verticesOnEdges.fill(0, J, $);
  }
  interpolate(Z) {
    let J = HB0[Z], $ = 3 * this.get3dOffsetFromEdgeInfo(J) + J.e, X = this.verticesOnEdges[$];
    if (X > 0)
      return X - 1;
    let Y = this.scalarField, Q = this.scalarFieldGet, W = GB0[Z], K = W.a, G = W.b, H = K.i + this.i, N = K.j + this.j, q = K.k + this.k, U = G.i + this.i, F = G.j + this.j, E = G.k + this.k, R = Q(Y, H, N, q), z = Q(Y, U, F, E), D = (this.isoLevel - R) / (R - z);
    if (this.idField) {
      let h = this.idFieldGet(this.idField, H, N, q), x = this.idFieldGet(this.idField, U, F, E), b = D < 0.5 ? h : x;
      if (b === -1)
        b = D < 0.5 ? x : h;
      if (b === -2)
        return -1;
      this.builder.addGroup(b);
    } else
      this.builder.addGroup(0);
    let A = this.builder.addVertex(H + D * (H - U), N + D * (N - F), q + D * (q - E));
    this.verticesOnEdges[$] = A + 1;
    let B = Q(Y, Math.max(0, H - 1), N, q) - Q(Y, Math.min(this.nX - 1, H + 1), N, q), T = Q(Y, H, Math.max(0, N - 1), q) - Q(Y, H, Math.min(this.nY - 1, N + 1), q), w = Q(Y, H, N, Math.max(0, q - 1)) - Q(Y, H, N, Math.min(this.nZ - 1, q + 1)), V = Q(Y, Math.max(0, U - 1), F, E) - Q(Y, Math.min(this.nX - 1, U + 1), F, E), P = Q(Y, U, Math.max(0, F - 1), E) - Q(Y, U, Math.min(this.nY - 1, F + 1), E), I = Q(Y, U, F, Math.max(0, E - 1)) - Q(Y, U, F, Math.min(this.nZ - 1, E + 1)), S = B + D * (B - V), f = T + D * (T - P), v = w + D * (w - I);
    if (this.isoLevel >= 0)
      this.builder.addNormal(S, f, v);
    else
      this.builder.addNormal(-S, -f, -v);
    return A;
  }
  constructor(Z, J) {
    this.builder = Z, this.vertList = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], this.i = 0, this.j = 0, this.k = 0;
    let $ = J.scalarField.space.dimensions;
    if (this.nX = $[0], this.nY = $[1], this.nZ = $[2], this.isoLevel = J.isoLevel, this.scalarFieldGet = J.scalarField.space.get, this.scalarField = J.scalarField.data, J.idField)
      this.idField = J.idField.data, this.idFieldGet = J.idField.space.get;
    this.verticesOnEdges = new Int32Array(3 * this.nX * this.nY * 2);
  }
  get(Z, J, $) {
    return this.scalarFieldGet(this.scalarField, Z, J, $);
  }
  processCell(Z, J, $, X) {
    let Y = 0;
    if (this.get(Z, J, $) < this.isoLevel)
      Y |= 1;
    if (this.get(Z + 1, J, $) < this.isoLevel)
      Y |= 2;
    if (this.get(Z + 1, J + 1, $) < this.isoLevel)
      Y |= 4;
    if (this.get(Z, J + 1, $) < this.isoLevel)
      Y |= 8;
    if (this.get(Z, J, $ + 1) < this.isoLevel)
      Y |= 16;
    if (this.get(Z + 1, J, $ + 1) < this.isoLevel)
      Y |= 32;
    if (this.get(Z + 1, J + 1, $ + 1) < this.isoLevel)
      Y |= 64;
    if (this.get(Z, J + 1, $ + 1) < this.isoLevel)
      Y |= 128;
    if (Y === 0 || Y === 255)
      return;
    this.i = Z, this.j = J, this.k = $;
    let Q = NB0[Y];
    if ((Q & 1) > 0)
      this.vertList[0] = this.interpolate(0);
    if ((Q & 2) > 0)
      this.vertList[1] = this.interpolate(1);
    if ((Q & 4) > 0)
      this.vertList[2] = this.interpolate(2);
    if ((Q & 8) > 0)
      this.vertList[3] = this.interpolate(3);
    if ((Q & 16) > 0)
      this.vertList[4] = this.interpolate(4);
    if ((Q & 32) > 0)
      this.vertList[5] = this.interpolate(5);
    if ((Q & 64) > 0)
      this.vertList[6] = this.interpolate(6);
    if ((Q & 128) > 0)
      this.vertList[7] = this.interpolate(7);
    if ((Q & 256) > 0)
      this.vertList[8] = this.interpolate(8);
    if ((Q & 512) > 0)
      this.vertList[9] = this.interpolate(9);
    if ((Q & 1024) > 0)
      this.vertList[10] = this.interpolate(10);
    if ((Q & 2048) > 0)
      this.vertList[11] = this.interpolate(11);
    let W = nR[Y];
    for (let K = 0;K < W.length; K += 3) {
      let G = W[K], H = W[K + 1], N = W[K + 2];
      if (this.isoLevel >= 0)
        this.builder.addTriangle(this.vertList, G, H, N, X);
      else
        this.builder.addTriangle(this.vertList, N, H, G, X);
    }
  }
}

// node_modules/molstar/lib/mol-repr/volume/representation.js
function EB0(Z, J, $, X, Y) {
  let Q = Z.instances.length, W = new Float32Array(Q * 16);
  for (let K = 0;K < Q; ++K)
    e.toArray(Z.instances[K].transform, W, K * 16);
  return zz(W, Q, J, $, X, Y);
}
function mG1(Z, J, $, X, Y, Q) {
  let { createValues: W, createRenderableState: K } = n7.getUtils(J), G = EB0(Z, J.boundingSphere, Y.cellSize, Y.batchSize), H = W(J, G, $, X, Y), N = K(Y);
  return v3(J.kind, H, N, Q);
}
function gW(Z, J) {
  let { defaultProps: $, createGeometry: X, createLocationIterator: Y, getLoci: Q, eachLocation: W, setUpdateState: K, mustRecreate: G, dispose: H } = Z, { updateValues: N, updateBoundingSphere: q, updateRenderableState: U, createPositionIterator: F } = Z.geometryUtils, E = S5.create(), R, z, D, A, B, T = Object.assign({}, $), w = Q7.createEmpty(), V, P, I, S = -1, f, v;
  function h(m, i, r, Y0) {
    if (!r && !V)
      throw new Error("missing volume");
    if (z = Object.assign({}, T, i), D = m, A = r, B = Y0, S5.reset(E), !R)
      E.createNew = !0;
    else if (s6.areEquivalent(A.grid, V.grid) && !Q1.areInstanceTransformsEqual(A, V))
      E.updateTransform = !0;
    else if (!Q1.areEquivalent(A, V) || B !== P)
      E.createNew = !0;
    if (E.createNew) {
      E.createGeometry = !0;
      return;
    }
    if (K(E, r, z, T, D, w), !oJ.areEqual(m.color, w.color))
      E.updateColor = !0;
    if (!J9.areEqual(m.size, w.size))
      E.updateSize = !0;
    if (z.instanceGranularity !== T.instanceGranularity || z.cellSize !== T.cellSize || z.batchSize !== T.batchSize)
      E.updateTransform = !0;
    if (E.updateTransform)
      E.updateMatrix = !0;
    if (E.updateSize && !("uSize" in R.values))
      E.createGeometry = !0;
    if (E.createGeometry)
      E.updateColor = !0, E.updateSize = !0;
  }
  function x(m) {
    if (E.createNew)
      if (f = Y(A, B), m)
        R = mG1(A, m, f, D, z, J), v = F(m, R.values);
      else
        throw new Error("expected geometry to be given");
    else {
      if (!R)
        throw new Error("expected renderObject to be available");
      if (E.updateColor || E.updateSize || E.updateTransform)
        f = Y(A, B);
      if (E.updateTransform) {
        let { instanceCount: i, groupCount: r } = f;
        if (z.instanceGranularity)
          rZ(i, "instance", R.values);
        else
          rZ(i * r, "groupInstance", R.values);
      }
      if (E.updateMatrix)
        EB0(A, I.boundingSphere, z.cellSize, z.batchSize, R.values);
      if (E.createGeometry)
        if (m)
          C.updateIfChanged(R.values.drawCount, n7.getDrawCount(m)), C.updateIfChanged(R.values.uVertexCount, n7.getVertexCount(m)), C.updateIfChanged(R.values.uGroupCount, f.groupCount);
        else
          throw new Error("expected geometry to be given");
      if (E.updateTransform || E.createGeometry)
        q(R.values, m || I), v = F(m || I, R.values);
      if (E.updateSize) {
        if ("uSize" in R.values)
          DY(f, D.size, R.values);
      }
      if (E.updateColor)
        WJ(f, v, D.color, R.values);
      N(R.values, z), U(R.state, z);
    }
    if (T = z, w = D, V = A, P = B, m)
      I = m, S += 1;
  }
  function b(m, i, r, Y0) {
    let c = !1;
    if (Q1.Cell.isLoci(m)) {
      if (Q1.Cell.isLociEmpty(m))
        return !1;
      if (!Q1.areEquivalent(m.volume, i))
        return !1;
      for (let { instances: n } of m.elements)
        f0.forEach(n, (l) => {
          if (Y0(k0.ofSingleton(l)))
            c = !0;
        });
    } else if (Q1.Segment.isLoci(m)) {
      if (Q1.Segment.isLociEmpty(m))
        return !1;
      if (!Q1.areEquivalent(m.volume, i))
        return !1;
      for (let { segments: n, instances: l } of m.elements)
        if (f0.has(n, r))
          f0.forEach(l, (u) => {
            if (Y0(k0.ofSingleton(u)))
              c = !0;
          });
    } else if (Q1.Isosurface.isLoci(m)) {
      if (Q1.Isosurface.isLociEmpty(m))
        return !1;
      if (k0.is(m.instances)) {
        if (Y0(m.instances))
          c = !0;
      } else
        for (let n = 0, l = m.instances.length;n < l; ++n)
          if (Y0(k0.ofSingleton(n)))
            c = !0;
    } else if (Q1.isLoci(m)) {
      if (Q1.isLociEmpty(m))
        return !1;
      if (k0.is(m.instances)) {
        if (Y0(m.instances))
          c = !0;
      } else
        for (let n = 0, l = m.instances.length;n < l; ++n)
          if (Y0(k0.ofSingleton(n)))
            c = !0;
    }
    return c;
  }
  function g(m, i) {
    if (KJ(m))
      if (T.instanceGranularity)
        return i(k0.ofBounds(0, f.instanceCount));
      else
        return i(k0.ofBounds(0, f.groupCount * f.instanceCount));
    else if (T.instanceGranularity)
      return b(m, V, P, i);
    else
      return W(m, V, P, T, i);
  }
  return {
    get groupCount() {
      return f ? f.count : 0;
    },
    get renderObject() {
      return R;
    },
    get geometryVersion() {
      return S;
    },
    async createOrUpdate(m, i, r = {}, Y0) {
      if (h(i, r, (Y0 === null || Y0 === void 0 ? void 0 : Y0.volume) || V, (Y0 === null || Y0 === void 0 ? void 0 : Y0.key) || P), E.createGeometry) {
        let c = X(m, A, B, D, z, I);
        return lL(c) ? c.then(x) : x(c);
      } else
        x();
    },
    getLoci(m) {
      return R ? Q(m, V, P, T, R.id) : G8;
    },
    eachLocation(m) {
      f.reset();
      while (f.hasNext) {
        let { location: i, isSecondary: r } = f.move();
        m(i, r);
      }
    },
    mark(m, i) {
      return m8.mark(R, m, i, g);
    },
    setVisibility(m) {
      m8.setVisibility(R, m);
    },
    setAlphaFactor(m) {
      m8.setAlphaFactor(R, m);
    },
    setPickable(m) {
      m8.setPickable(R, m);
    },
    setColorOnly(m) {
      m8.setColorOnly(R, m);
    },
    setTransform(m, i) {
      m8.setTransform(R, m, i);
    },
    setOverpaint(m) {
      return m8.setOverpaint(R, m, g, !0);
    },
    setTransparency(m) {
      return m8.setTransparency(R, m, g, !0);
    },
    setEmissive(m) {
      return m8.setEmissive(R, m, g, !0);
    },
    setSubstance(m) {
      return m8.setSubstance(R, m, g, !0);
    },
    setClipping(m) {
      return m8.setClipping(R, m, g, !0);
    },
    setThemeStrength(m) {
      m8.setThemeStrength(R, m);
    },
    destroy() {
      if (H === null || H === void 0 || H(I), R)
        R.state.disposed = !0, R = void 0;
    },
    mustRecreate: G
  };
}
function Uq(Z) {
  return Z;
}
var Yd2 = {
  ...q1.Params
};
function i3(Z, J, $, X, Y, Q = () => [-1]) {
  let W = 0, { webgl: K } = J, G = new P6, H = new V2.GeometryState, N = bW(), q = [], U = V2.createState(), F = /* @__PURE__ */ new Map, E, R, z, D, A = Q7.createEmpty();
  async function B(f, v) {
    var h;
    let x = F.get(v);
    if (!x)
      x = X(N, E, v, D, K), F.set(v, x);
    else if ((h = x.mustRecreate) === null || h === void 0 ? void 0 : h.call(x, { volume: E, key: v }, D, K))
      x.destroy(), x = X(N, E, v, D, K), F.set(v, x);
    return x.createOrUpdate({ webgl: K, runtime: f }, A, D, { volume: E, key: v });
  }
  function T(f = {}, v) {
    if (v && v !== E) {
      if (z = $(J, v), E = v, !D)
        D = j.getDefaultValues(z);
    }
    let h = vV(Object.assign({}, D, f), E);
    return Object.assign(D, f, h), R = Q(D), n0.create("Creating or updating VolumeRepresentation", async (x) => {
      let b = new Set(F.keys());
      for (let g = 0, m = R.length;g < m; ++g) {
        let i = R[g];
        b.delete(i);
        let r = B(x, i);
        if (r)
          await r;
      }
      b.forEach((g) => {
        var m;
        (m = F.get(g)) === null || m === void 0 || m.destroy(), F.delete(g);
      }), q.length = 0, F.forEach((g) => {
        if (g.renderObject)
          q.push(g.renderObject), H.add(g.renderObject.id, g.geometryVersion);
      }), H.snapshot(), G.next(W++);
    });
  }
  function w(f, v) {
    let h = !1;
    return F.forEach((x) => {
      h = x.mark(f, v) || h;
    }), h;
  }
  function V(f, v) {
    if (v.visible !== void 0 && f)
      f.setVisibility(v.visible);
    if (v.alphaFactor !== void 0 && f)
      f.setAlphaFactor(v.alphaFactor);
    if (v.pickable !== void 0 && f)
      f.setPickable(v.pickable);
    if (v.overpaint !== void 0 && f)
      f.setOverpaint(v.overpaint);
    if (v.transparency !== void 0 && f)
      f.setTransparency(v.transparency);
    if (v.emissive !== void 0 && f)
      f.setEmissive(v.emissive);
    if (v.substance !== void 0 && f)
      f.setSubstance(v.substance);
    if (v.clipping !== void 0 && f)
      f.setClipping(v.clipping);
    if (v.transform !== void 0 && f)
      f.setTransform(v.transform);
    if (v.themeStrength !== void 0 && f)
      f.setThemeStrength(v.themeStrength);
  }
  function P(f) {
    let { visible: v, alphaFactor: h, pickable: x, overpaint: b, transparency: g, emissive: m, substance: i, clipping: r, transform: Y0, themeStrength: c, syncManually: n, markerActions: l } = f, u = {};
    if (v !== void 0)
      u.visible = v;
    if (h !== void 0)
      u.alphaFactor = h;
    if (x !== void 0)
      u.pickable = x;
    if (b !== void 0)
      u.overpaint = b;
    if (g !== void 0)
      u.transparency = g;
    if (m !== void 0)
      u.emissive = m;
    if (i !== void 0)
      u.substance = i;
    if (r !== void 0)
      u.clipping = r;
    if (c !== void 0)
      u.themeStrength = c;
    if (Y0 !== void 0 && !e.areEqual(Y0, U.transform, u8))
      u.transform = Y0;
    if (n !== void 0)
      u.syncManually = n;
    if (l !== void 0)
      u.markerActions = l;
    F.forEach((G0) => V(G0, u)), V2.updateState(U, f);
  }
  function I(f) {
    A = f;
  }
  function S() {
    F.forEach((f) => f.destroy()), F.clear();
  }
  return {
    label: Z,
    get groupCount() {
      let f = 0;
      return F.forEach((v) => {
        if (v.renderObject)
          f += v.groupCount;
      }), f;
    },
    get props() {
      return D;
    },
    get params() {
      return z;
    },
    get state() {
      return U;
    },
    get theme() {
      return A;
    },
    get geometryVersion() {
      return H.version;
    },
    renderObjects: q,
    updated: G,
    createOrUpdate: T,
    setState: P,
    setTheme: I,
    getLoci: (f) => {
      let v = G8;
      return F.forEach((h) => {
        let x = h.getLoci(f);
        if (!_7(x))
          v = x;
      }), v;
    },
    getAllLoci: () => {
      return [Y(E, D)];
    },
    eachLocation: (f) => {
      F.forEach((v) => {
        v.eachLocation(f);
      });
    },
    mark: w,
    destroy: S
  };
}

// node_modules/molstar/lib/mol-gl/shader/histogram-pyramid/sum.frag.js
var OB0 = `
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
}
`;

// node_modules/molstar/lib/mol-gl/compute/histogram-pyramid/sum.js
var dG1 = {
  ...A6,
  tTexture: o1("texture", "rgba", "float", "nearest")
}, o3 = "histopyramid-sum";
function pG1(Z, J) {
  if (Z.namedComputeRenderables[o3]) {
    let $ = Z.namedComputeRenderables[o3].values;
    C.update($.tTexture, J), Z.namedComputeRenderables[o3].update();
  } else
    Z.namedComputeRenderables[o3] = uG1(Z, J);
  return Z.namedComputeRenderables[o3];
}
function uG1(Z, J) {
  let $ = {
    ...B6,
    tTexture: C.create(J)
  }, X = { ...dG1 }, Y = v8("sum", p6, OB0, {}, { 0: "ivec4" }), Q = t8(Z, "triangles", Y, X, $);
  return e8(Q, $);
}
function cG1(Z) {
  let { gl: J, state: $ } = Z;
  $.disable(J.CULL_FACE), $.disable(J.BLEND), $.disable(J.DEPTH_TEST), $.disable(J.SCISSOR_TEST), $.depthMask(!1), $.colorMask(!0, !0, !0, !0), $.clearColor(0, 0, 0, 0);
}
var ab = new Uint8Array(4), zB0 = new Int32Array(4);
function DB0(Z, J) {
  if (K1)
    Z.timer.mark("getHistopyramidSum");
  let { gl: $, state: X, resources: Y } = Z, Q = pG1(Z, J);
  if (Z.state.currentRenderItemId = -1, !Z.namedFramebuffers[o3])
    Z.namedFramebuffers[o3] = Y.framebuffer();
  let W = Z.namedFramebuffers[o3];
  if (!Z.namedTextures[o3])
    Z.namedTextures[o3] = _2($) ? Y.texture("image-int32", "rgba", "int", "nearest") : Y.texture("image-uint8", "rgba", "ubyte", "nearest"), Z.namedTextures[o3].define(1, 1);
  if (Z.namedTextures[o3].attachFramebuffer(W, 0), cG1(Z), X.viewport(0, 0, 1, 1), Q.render(), $.finish(), Z.readPixels(0, 0, 1, 1, _2($) ? zB0 : ab), $.bindFramebuffer($.FRAMEBUFFER, null), K1)
    Z.timer.markEnd("getHistopyramidSum");
  return _2($) ? zB0[0] : VR(ab[0], ab[1], ab[2]);
}

// node_modules/molstar/lib/mol-gl/shader/histogram-pyramid/reduction.frag.js
var MB0 = `
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
}
`;

// node_modules/molstar/lib/mol-gl/compute/histogram-pyramid/reduction.js
var lG1 = {
  ...A6,
  tInputLevel: o1("texture", "rgba", "float", "nearest"),
  tPreviousLevel: o1("texture", "rgba", "float", "nearest"),
  uSize: _0("f"),
  uTexSize: _0("f"),
  uFirst: _0("b")
}, iR = "histogram-pyramid";
function nG1(Z, J, $) {
  if (Z.namedComputeRenderables[iR]) {
    let X = Z.namedComputeRenderables[iR].values;
    C.update(X.tInputLevel, J), C.update(X.tPreviousLevel, $), Z.namedComputeRenderables[iR].update();
  } else
    Z.namedComputeRenderables[iR] = iG1(Z, J, $);
  return Z.namedComputeRenderables[iR];
}
function iG1(Z, J, $) {
  let X = {
    ...B6,
    tInputLevel: C.create(J),
    tPreviousLevel: C.create($),
    uSize: C.create(0),
    uTexSize: C.create(0),
    uFirst: C.create(!0)
  }, Y = { ...lG1 }, Q = v8("reduction", p6, MB0, {}, { 0: "ivec4" }), W = t8(Z, "triangles", Q, Y, X);
  return e8(W, X);
}
function oG1(Z, J) {
  let $ = Math.pow(2, J), X = `level${J}`, Y = Z.isWebGL2 ? rb(X, Z, "image-int32", "alpha", "int", "nearest") : rb(X, Z, "image-uint8", "rgba", "ubyte", "nearest");
  Y.define($, $);
  let Q = aG1(X, Z);
  if (!Q)
    Q = AB0(X, Z);
  return Y.attachFramebuffer(Q, 0), { texture: Y, framebuffer: Q };
}
function sG1(Z) {
  let { gl: J, state: $ } = Z;
  $.disable(J.CULL_FACE), $.disable(J.BLEND), $.disable(J.DEPTH_TEST), $.enable(J.SCISSOR_TEST), $.depthMask(!1), $.colorMask(!0, !0, !0, !0), $.clearColor(0, 0, 0, 0);
}
function AB0(Z, J) {
  let $ = `${iR}-${Z}`;
  if (!J.namedFramebuffers[$])
    J.namedFramebuffers[$] = J.resources.framebuffer();
  return J.namedFramebuffers[$];
}
function rb(Z, J, $, X, Y, Q) {
  let W = `${iR}-${Z}`;
  if (!J.namedTextures[W])
    J.namedTextures[W] = J.resources.texture($, X, Y, Q);
  return J.namedTextures[W];
}
function aG1(Z, J) {
  let $ = `${iR}-${Z}`;
  return J.namedFramebuffers[$];
}
function BB0(Z, J, $, X) {
  if (K1)
    Z.timer.mark("createHistogramPyramid");
  let { gl: Y, state: Q } = Z, W = J.getWidth(), K = J.getHeight();
  if (W !== K || !nL(W))
    throw new Error("inputTexture must be of square power-of-two size");
  let G = Math.ceil(Math.log(W) / Math.log(2)), H = Math.pow(2, G), N = Math.pow(2, G), q = Math.pow(2, G - 1), U = Z.isWebGL2 ? rb("pyramid", Z, "image-int32", "alpha", "int", "nearest") : rb("pyramid", Z, "image-uint8", "rgba", "ubyte", "nearest");
  U.define(N, q);
  let F = AB0("pyramid", Z);
  if (U.attachFramebuffer(F, 0), Q.viewport(0, 0, N, q), _2(Y))
    Y.clearBufferiv(Y.COLOR, 0, [0, 0, 0, 0]);
  else
    Y.clear(Y.COLOR_BUFFER_BIT);
  let E = [];
  for (let B = 0;B < G; ++B)
    E.push(oG1(Z, B));
  let R = nG1(Z, J, E[0].texture);
  Q.currentRenderItemId = -1, sG1(Z);
  let z = 0;
  for (let B = 0;B < G; B++) {
    let T = G - 1 - B;
    E[T].framebuffer.bind();
    let V = Math.pow(2, T);
    if (C.update(R.values.uSize, Math.pow(2, B + 1) / H), C.update(R.values.uTexSize, V), C.updateIfChanged(R.values.uFirst, B === 0), B > 0)
      C.update(R.values.tPreviousLevel, E[G - B].texture), R.update();
    if (Q.currentRenderItemId = -1, Q.viewport(0, 0, V, V), Q.scissor(0, 0, V, V), _2(Y))
      Y.clearBufferiv(Y.COLOR, 0, [0, 0, 0, 0]);
    else
      Y.clear(Y.COLOR_BUFFER_BIT);
    Q.scissor(0, 0, X[0], X[1]), R.render(), U.bind(0), Y.copyTexSubImage2D(Y.TEXTURE_2D, 0, z, 0, 0, 0, V, V), U.unbind(0), z += V;
  }
  if (Y.finish(), K1)
    Z.timer.markEnd("createHistogramPyramid");
  let D = Math.max(1, DB0(Z, E[0].texture)), A = Math.ceil(D / Math.pow(2, G));
  return { pyramidTex: U, count: D, height: A, levels: G, scale: $ };
}

// node_modules/molstar/lib/mol-gl/compute/marching-cubes/tables.js
var uV;
function wB0() {
  if (uV !== void 0)
    return uV;
  uV = Z9(256, 1, Uint8Array);
  let { array: Z } = uV;
  for (let J = 0, $ = nR.length;J < $; ++J)
    Z[J] = nR[J].length / 3;
  return uV;
}
var cV;
function jB0() {
  if (cV !== void 0)
    return cV;
  cV = Z9(4096, 1, Uint8Array);
  let { array: Z } = cV;
  for (let J = 0, $ = nR.length;J < $; ++J)
    for (let X = 0;X < 16; ++X)
      if (X < nR[J].length)
        Z[J * 16 + X] = nR[J][X];
      else
        Z[J * 16 + X] = 255;
  return cV;
}

// node_modules/molstar/lib/mol-gl/shader/marching-cubes/isosurface.frag.js
var TB0 = `
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 vec3 uGridDataDim;
uniform mat4 uGridTransform;
uniform mat3 uGridTransformAdjoint;

// 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);
}

float voxelValuePadded(vec3 pos) {
    pos = min(max(vec3(0.0), pos), uGridDim - vec3(vec2(2.0), 1.0)); // remove xy padding
    vec4 v = texture3dFrom2dNearest(tVolumeData, pos / uGridDim, uGridDim, uGridTexDim.xy);
    #ifdef dValueChannel_red
        return v.r;
    #else
        return v.a;
    #endif
}

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) {
    // note that we swap x and z because the texture is flipped around y
    #if defined(dAxisOrder_012)
        float group = p.z + p.y * uGridDataDim.z + p.x * uGridDataDim.z * uGridDataDim.y; // 210
    #elif defined(dAxisOrder_021)
        float group = p.y + p.z * uGridDataDim.y + p.x * uGridDataDim.y * uGridDataDim.z; // 120
    #elif defined(dAxisOrder_102)
        float group = p.z + p.x * uGridDataDim.z + p.y * uGridDataDim.z * uGridDataDim.x; // 201
    #elif defined(dAxisOrder_120)
        float group = p.x + p.z * uGridDataDim.x + p.y * uGridDataDim.x * uGridDataDim.z; // 021
    #elif defined(dAxisOrder_201)
        float group = p.y + p.x * uGridDataDim.y + p.z * uGridDataDim.y * uGridDataDim.x; // 102
    #elif defined(dAxisOrder_210)
        float group = p.x + p.y * uGridDataDim.x + p.z * uGridDataDim.x * uGridDataDim.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);

    #ifdef dValueChannel_red
        float v0 = d0.r;
        float v1 = d1.r;
    #else
        float v0 = d0.a;
        float v1 = d1.a;
    #endif

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

    // group id
    #if __VERSION__ == 100 || defined(dConstantGroup)
        // webgl1 does not support 'flat' interpolation (i.e. no interpolation)
        // ensure a constant group id per triangle as needed
        #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(
        voxelValuePadded(b0 - c1) - voxelValuePadded(b0 + c1),
        voxelValuePadded(b0 - c3) - voxelValuePadded(b0 + c3),
        voxelValuePadded(b0 - c4) - voxelValuePadded(b0 + c4)
    ));
    vec3 n1 = -normalize(vec3(
        voxelValuePadded(b1 - c1) - voxelValuePadded(b1 + c1),
        voxelValuePadded(b1 - c3) - voxelValuePadded(b1 + c3),
        voxelValuePadded(b1 - c4) - voxelValuePadded(b1 + c4)
    ));
    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 = uGridTransformAdjoint * gl_FragData[2].xyz;
}
`;

// node_modules/molstar/lib/mol-gl/shader/marching-cubes/active-voxels.frag.js
var _B0 = `
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);
}

float voxelValue(vec3 pos) {
    pos = min(max(vec3(0.0), pos), uGridDim - vec3(1.0));
    vec4 v = texture3dFrom2dNearest(tVolumeData, pos / uGridDim, uGridDim, uGridTexDim.xy);
    #ifdef dValueChannel_red
        return v.r;
    #else
        return v.a;
    #endif
}

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(voxelValue(posXYZ), uIsoValue)
        + 2. * step(voxelValue(posXYZ + c1), uIsoValue)
        + 4. * step(voxelValue(posXYZ + c2), uIsoValue)
        + 8. * step(voxelValue(posXYZ + c3), uIsoValue)
        + 16. * step(voxelValue(posXYZ + c4), uIsoValue)
        + 32. * step(voxelValue(posXYZ + c5), uIsoValue)
        + 64. * step(voxelValue(posXYZ + c6), uIsoValue)
        + 128. * step(voxelValue(posXYZ + c7), 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);
}
`;

// node_modules/molstar/lib/mol-gl/compute/marching-cubes/active-voxels.js
var rG1 = {
  ...A6,
  tTriCount: o1("image-uint8", "alpha", "ubyte", "nearest"),
  tVolumeData: o1("texture", "rgba", "ubyte", "nearest"),
  dValueChannel: p1("string", ["red", "alpha"]),
  uIsoValue: _0("f"),
  uGridDim: _0("v3"),
  uGridTexDim: _0("v3"),
  uScale: _0("v2")
}, BH = "active-voxels";
function VB0(Z, J) {
  return _2(Z.gl) && J.format === Z.gl.RED ? "red" : "alpha";
}
function tG1(Z, J, $, X, Y, Q) {
  if (Z.namedComputeRenderables[BH]) {
    let W = Z.namedComputeRenderables[BH].values;
    C.update(W.uQuadScale, Q), C.update(W.tVolumeData, J), C.update(W.dValueChannel, VB0(Z, J)), C.updateIfChanged(W.uIsoValue, Y), C.update(W.uGridDim, $), C.update(W.uGridTexDim, X), C.update(W.uScale, Q), Z.namedComputeRenderables[BH].update();
  } else
    Z.namedComputeRenderables[BH] = eG1(Z, J, $, X, Y, Q);
  return Z.namedComputeRenderables[BH];
}
function eG1(Z, J, $, X, Y, Q) {
  let W = {
    ...B6,
    tTriCount: C.create(wB0()),
    uQuadScale: C.create(Q),
    tVolumeData: C.create(J),
    dValueChannel: C.create(VB0(Z, J)),
    uIsoValue: C.create(Y),
    uGridDim: C.create($),
    uGridTexDim: C.create(X),
    uScale: C.create(Q)
  }, K = { ...rG1 }, G = v8("active-voxels", p6, _B0), H = t8(Z, "triangles", G, K, W);
  return e8(H, W);
}
function ZH1(Z) {
  let { gl: J, state: $ } = Z;
  $.disable(J.CULL_FACE), $.disable(J.BLEND), $.disable(J.DEPTH_TEST), $.enable(J.SCISSOR_TEST), $.depthMask(!1), $.colorMask(!0, !0, !0, !0), $.clearColor(0, 0, 0, 0);
}
function IB0(Z, J, $, X, Y, Q) {
  if (K1)
    Z.timer.mark("calcActiveVoxels");
  let { gl: W, state: K, resources: G } = Z, H = J.getWidth(), N = J.getHeight();
  if (!Z.namedFramebuffers[BH])
    Z.namedFramebuffers[BH] = G.framebuffer();
  let q = Z.namedFramebuffers[BH];
  if (q.bind(), !Z.namedTextures[BH])
    Z.namedTextures[BH] = G.texture("image-uint8", "rgba", "ubyte", "nearest");
  let U = Z.namedTextures[BH];
  U.define(H, N);
  let F = tG1(Z, J, $, X, Y, Q);
  if (Z.state.currentRenderItemId = -1, U.attachFramebuffer(q, 0), ZH1(Z), K.viewport(0, 0, H, N), K.scissor(0, 0, H, N), W.clear(W.COLOR_BUFFER_BIT), K.scissor(0, 0, X[0], X[1]), F.render(), W.finish(), K1)
    Z.timer.markEnd("calcActiveVoxels");
  return U;
}

// node_modules/molstar/lib/mol-gl/compute/marching-cubes/isosurface.js
var JH1 = {
  ...A6,
  tTriIndices: o1("image-uint8", "alpha", "ubyte", "nearest"),
  tActiveVoxelsPyramid: o1("texture", "rgba", "float", "nearest"),
  tActiveVoxelsBase: o1("texture", "rgba", "float", "nearest"),
  tVolumeData: o1("texture", "rgba", "ubyte", "nearest"),
  dValueChannel: p1("string", ["red", "alpha"]),
  uIsoValue: _0("f"),
  uSize: _0("f"),
  uLevels: _0("f"),
  uCount: _0("f"),
  uInvert: _0("b"),
  uGridDim: _0("v3"),
  uGridTexDim: _0("v3"),
  uGridDataDim: _0("v3"),
  uGridTransform: _0("m4"),
  uGridTransformAdjoint: _0("m3"),
  uScale: _0("v2"),
  dPackedGroup: p1("boolean"),
  dAxisOrder: p1("string", ["012", "021", "102", "120", "201", "210"]),
  dConstantGroup: p1("boolean")
}, oR = "isosurface";
function PB0(Z, J) {
  return _2(Z.gl) && J.format === Z.gl.RED ? "red" : "alpha";
}
function $H1(Z, J, $, X, Y, Q, W, K, G, H, N, q, U, F, E, R) {
  if (Z.namedComputeRenderables[oR]) {
    let z = Z.namedComputeRenderables[oR].values;
    C.update(z.tActiveVoxelsPyramid, J), C.update(z.tActiveVoxelsBase, $), C.update(z.tVolumeData, X), C.update(z.dValueChannel, PB0(Z, X)), C.updateIfChanged(z.uIsoValue, G), C.updateIfChanged(z.uSize, Math.pow(2, H)), C.updateIfChanged(z.uLevels, H), C.updateIfChanged(z.uCount, q), C.updateIfChanged(z.uInvert, U), C.update(z.uGridDim, Y), C.update(z.uGridTexDim, Q), C.update(z.uGridDataDim, W), C.update(z.uGridTransform, K), C.update(z.uGridTransformAdjoint, h2.adjointFromMat4(h2(), K)), C.update(z.uScale, N), C.updateIfChanged(z.dPackedGroup, F), C.updateIfChanged(z.dAxisOrder, E.join("")), C.updateIfChanged(z.dConstantGroup, R), Z.namedComputeRenderables[oR].update();
  } else
    Z.namedComputeRenderables[oR] = XH1(Z, J, $, X, Y, Q, W, K, G, H, N, q, U, F, E, R);
  return Z.namedComputeRenderables[oR];
}
function XH1(Z, J, $, X, Y, Q, W, K, G, H, N, q, U, F, E, R) {
  let z = {
    ...B6,
    tTriIndices: C.create(jB0()),
    tActiveVoxelsPyramid: C.create(J),
    tActiveVoxelsBase: C.create($),
    tVolumeData: C.create(X),
    dValueChannel: C.create(PB0(Z, X)),
    uIsoValue: C.create(G),
    uSize: C.create(Math.pow(2, H)),
    uLevels: C.create(H),
    uCount: C.create(q),
    uInvert: C.create(U),
    uGridDim: C.create(Y),
    uGridTexDim: C.create(Q),
    uGridDataDim: C.create(W),
    uGridTransform: C.create(K),
    uGridTransformAdjoint: C.create(h2.adjointFromMat4(h2(), K)),
    uScale: C.create(N),
    dPackedGroup: C.create(F),
    dAxisOrder: C.create(E.join("")),
    dConstantGroup: C.create(R)
  }, D = { ...JH1 }, A = v8("isosurface", p6, TB0, { drawBuffers: "required" }), B = t8(Z, "triangles", A, D, z);
  return e8(B, z);
}
function YH1(Z) {
  let { gl: J, state: $ } = Z;
  $.disable(J.CULL_FACE), $.disable(J.BLEND), $.disable(J.DEPTH_TEST), $.disable(J.SCISSOR_TEST), $.depthMask(!1), $.colorMask(!0, !0, !0, !0), $.clearColor(0, 0, 0, 0);
}
function QH1(Z, J, $, X, Y, Q, W, K, G, H, N, q, U, F, E, R) {
  let { drawBuffers: z } = Z.extensions;
  if (!z)
    throw new Error("need WebGL draw buffers");
  if (K1)
    Z.timer.mark("createIsosurfaceBuffers");
  let { gl: D, state: A, resources: B, extensions: T } = Z, { pyramidTex: w, height: V, levels: P, scale: I, count: S } = X, f = w.getWidth();
  if (!Z.namedFramebuffers[oR])
    Z.namedFramebuffers[oR] = B.framebuffer();
  let v = Z.namedFramebuffers[oR];
  if (_2(D)) {
    if (!F)
      F = B.texture("image-float32", "rgba", "float", "nearest");
    if (!E)
      E = B.texture("image-uint8", "rgba", "ubyte", "nearest");
    if (!R)
      R = T.colorBufferHalfFloat && T.textureHalfFloat ? B.texture("image-float16", "rgba", "fp16", "nearest") : B.texture("image-float32", "rgba", "float", "nearest");
  } else {
    if (!F)
      F = B.texture("image-float32", "rgba", "float", "nearest");
    if (!E)
      E = B.texture("image-float32", "rgba", "float", "nearest");
    if (!R)
      R = B.texture("image-float32", "rgba", "float", "nearest");
  }
  F.define(f, V), E.define(f, V), R.define(f, V), F.attachFramebuffer(v, 0), E.attachFramebuffer(v, 1), R.attachFramebuffer(v, 2);
  let h = $H1(Z, w, J, $, Y, Q, W, K, G, P, I, S, H, N, q, U);
  if (Z.state.currentRenderItemId = -1, v.bind(), z.drawBuffers([
    z.COLOR_ATTACHMENT0,
    z.COLOR_ATTACHMENT1,
    z.COLOR_ATTACHMENT2
  ]), YH1(Z), A.viewport(0, 0, f, V), D.clear(D.COLOR_BUFFER_BIT), h.render(), D.finish(), K1)
    Z.timer.markEnd("createIsosurfaceBuffers");
  return { vertexTexture: F, groupTexture: E, normalTexture: R, vertexCount: S };
}
function xz(Z, J, $, X, Y, Q, W, K, G, H, N, q, U, F, E) {
  if (K1)
    Z.timer.mark("extractIsosurface");
  let R = IB0(Z, J, $, X, K, Q), z = BB0(Z, R, Q, X), D = QH1(Z, R, J, z, $, X, Y, W, K, G, H, N, q, U, F, E);
  if (K1)
    Z.timer.markEnd("extractIsosurface");
  return D;
}

// node_modules/molstar/lib/mol-repr/volume/isosurface.js
var rt = {
  isoValue: Q1.IsoValueParam,
  wrap: j.Select("auto", j.arrayToOptions(["off", "on", "auto"]))
}, WH1 = {
  ...rt,
  tryUseGpu: j.Boolean(!0),
  gpuDataType: j.Select("byte", j.arrayToOptions(["byte", "float", "halfFloat"]), { hideIf: (Z) => !Z.tryUseGpu })
};
function KH1(Z) {
  return Z.extensions.colorBufferFloat && Z.extensions.textureFloat && Z.extensions.drawBuffers;
}
function eb(Z, J) {
  if (J === "on")
    return !0;
  if (J === "off")
    return !1;
  return Z.periodicity === "xyz";
}
var lV = 1;
function tt(Z, J) {
  if (Z.grid.cells.data.length < Math.pow(10, 3))
    return !1;
  let $ = Z.grid.cells.space.dimensions, { powerOfTwoSize: X } = p3($, lV);
  return X <= J.maxTextureSize / 2;
}
function GH1(Z, J, $, X, Y) {
  if (X.tryUseGpu && Y && KH1(Y) && tt(J, Y))
    return FH1(Z);
  return NH1(Z);
}
function CB0(Z, J) {
  let $ = k0.ofLength(Z.instances.length);
  return Q1.Isosurface.Loci(Z, J.isoValue, $);
}
function et(Z, J, $, X, Y) {
  let { objectId: Q, groupId: W, instanceId: K } = Z;
  if (Y === Q) {
    let G = Q1.PickingGranularity.get(J), H = f0.ofSingleton(K);
    if (G === "volume")
      return Q1.Loci(J, H);
    else if (G === "object" || W === K7.Null)
      return Q1.Isosurface.Loci(J, X.isoValue, H);
    else {
      let N = k0.ofSingleton(W);
      return Q1.Cell.Loci(J, [{ indices: N, instances: H }]);
    }
  }
  return G8;
}
function Ze(Z, J, $, X, Y) {
  return qq(Z, J, { isoValue: X.isoValue }, Y);
}
async function HH1(Z, J, $, X, Y, Q) {
  Z.runtime.update({ message: "Marching cubes..." });
  let W = J.grid.cells;
  if (eb(J, Y.wrap))
    W = mb(J).grid.cells;
  let K = uJ(new Int32Array(J.grid.cells.data.length)), G = await Fq({
    isoLevel: Q1.IsoValue.toAbsolute(Y.isoValue, J.grid.stats).absoluteValue,
    scalarField: W,
    idField: M8.create(W.space, M8.Data1(K))
  }, Q).runAsChild(Z.runtime), H = s6.getGridToCartesianTransform(J.grid);
  if (n1.transform(G, H), Z.webgl && !Z.webgl.isWebGL2)
    n1.uniformTriangleGroup(G, !1), C.updateIfChanged(G.varyingGroup, !1);
  else
    C.updateIfChanged(G.varyingGroup, !0);
  return G.setBoundingSphere(Q1.Isosurface.getBoundingSphere(J, Y.isoValue)), G;
}
var Je = {
  ...n1.Params,
  ...iJ.Params,
  ...rt,
  ...WH1,
  quality: { ...n1.Params.quality, isEssential: !1 }
};
function NH1(Z) {
  return gW({
    defaultProps: j.getDefaultValues(Je),
    createGeometry: HH1,
    createLocationIterator: d3,
    getLoci: et,
    eachLocation: Ze,
    setUpdateState: (J, $, X, Y) => {
      J.createGeometry = !Q1.IsoValue.areSame(X.isoValue, Y.isoValue, $.grid.stats) || X.wrap !== Y.wrap;
    },
    geometryUtils: n1.Utils,
    mustRecreate: (J, $, X) => {
      return $.tryUseGpu && !!X && tt(J.volume, X);
    }
  }, Z);
}
var tb;
(function(Z) {
  Z.descriptor = p7({ name: "volume-isosurface-texture" });
  function $(Y) {
    delete Y._propertyData["volume-isosurface-texture"];
  }
  Z.clear = $;
  function X(Y, Q, W) {
    var K, G;
    let { gpuDataType: H } = W, N = eb(Y, W.wrap), q = s6.getGridToCartesianTransform(Y.grid), U = M.clone(Y.grid.cells.space.dimensions), { width: F, height: E, powerOfTwoSize: R } = p3(U, lV), z = M.create(F, E, 0), D = M.subScalar(M(), U, N ? 1 : 0), A = h0.create(F / R, E / R);
    if (R > Q.maxTextureSize / 2)
      throw new Error("volume too large for gpu isosurface extraction");
    let B = H === "halfFloat" && !Q.extensions.textureHalfFloat ? "float" : H;
    if (((K = Y._propertyData["volume-isosurface-texture"]) === null || K === void 0 ? void 0 : K.dataType) !== B || ((G = Y._propertyData["volume-isosurface-texture"]) === null || G === void 0 ? void 0 : G.wrap) !== N) {
      let T = B === "byte" ? Q.resources.texture("image-uint8", "alpha", "ubyte", "linear") : B === "halfFloat" ? Q.resources.texture("image-float16", "alpha", "fp16", "linear") : Q.resources.texture("image-float32", "alpha", "float", "linear");
      Y._propertyData["volume-isosurface-texture"] = { texture: T, dataType: B, wrap: N }, T.define(R, R), T.load(gb(Y, "data", lV, B), !0), Y.customProperties.add(Z.descriptor), Y.customProperties.assets(Z.descriptor, [{ dispose: () => T.destroy() }]);
    }
    return U[0] += lV, U[1] += lV, {
      texture: Y._propertyData["volume-isosurface-texture"].texture,
      transform: q,
      gridDimension: U,
      gridTexDim: z,
      gridDataDim: D,
      gridTexScale: A
    };
  }
  Z.get = X;
})(tb || (tb = {}));
function qH1(Z, J, $, X, Y, Q) {
  let { webgl: W } = Z;
  if (!W)
    throw new Error("webgl context required to create volume isosurface texture-mesh");
  if (J.grid.cells.data.length <= 1)
    return iJ.createEmpty(Q);
  if (eb(J, Y.wrap))
    J = mb(J);
  let { max: K, min: G } = J.grid.stats, H = K - G, N = Q1.IsoValue.toAbsolute(Y.isoValue, J.grid.stats).absoluteValue, q = (N - G) / H, U = J.grid.cells.space.axisOrderSlowToFast, F = J.grid.cells.data.length, E = Q1.getBoundingSphere(J), R = (D) => {
    let { texture: A, gridDimension: B, gridTexDim: T, gridDataDim: w, gridTexScale: V, transform: P } = tb.get(J, W, Y), I = D === null || D === void 0 ? void 0 : D.doubleBuffer.get(), S = xz(W, A, B, T, w, V, P, q, N < 0, !1, U, !0, I === null || I === void 0 ? void 0 : I.vertex, I === null || I === void 0 ? void 0 : I.group, I === null || I === void 0 ? void 0 : I.normal);
    return iJ.create(S.vertexCount, F, S.vertexTexture, S.groupTexture, S.normalTexture, E, D);
  }, z = R(Q);
  return z.meta.webgl = W, z.meta.reset = () => {
    tb.clear(J), R(z);
  }, z;
}
function FH1(Z) {
  return gW({
    defaultProps: j.getDefaultValues(Je),
    createGeometry: qH1,
    createLocationIterator: d3,
    getLoci: et,
    eachLocation: Ze,
    setUpdateState: (J, $, X, Y) => {
      J.createGeometry = !Q1.IsoValue.areSame(X.isoValue, Y.isoValue, $.grid.stats) || X.gpuDataType !== Y.gpuDataType || X.wrap !== Y.wrap;
    },
    geometryUtils: iJ.Utils,
    mustRecreate: (J, $, X) => {
      return !$.tryUseGpu || !X || !tt(J.volume, X);
    },
    dispose: (J) => {
      J.vertexTexture.ref.value.destroy(), J.groupTexture.ref.value.destroy(), J.normalTexture.ref.value.destroy(), J.doubleBuffer.destroy();
    }
  }, Z);
}
async function UH1(Z, J, $, X, Y, Q) {
  Z.runtime.update({ message: "Marching cubes..." });
  let W = J.grid.cells;
  if (eb(J, Y.wrap))
    W = mb(J).grid.cells;
  let K = uJ(new Int32Array(J.grid.cells.data.length)), G = await nA({
    isoLevel: Q1.IsoValue.toAbsolute(Y.isoValue, J.grid.stats).absoluteValue,
    scalarField: W,
    idField: M8.create(W.space, M8.Data1(K))
  }, Q).runAsChild(Z.runtime), H = s6.getGridToCartesianTransform(J.grid);
  return f6.transform(G, H), G.setBoundingSphere(Q1.Isosurface.getBoundingSphere(J, Y.isoValue)), G;
}
var kB0 = {
  ...f6.Params,
  ...rt,
  quality: { ...f6.Params.quality, isEssential: !1 },
  sizeFactor: j.Numeric(3, { min: 0, max: 10, step: 0.1 })
};
function LH1(Z) {
  return gW({
    defaultProps: j.getDefaultValues(kB0),
    createGeometry: UH1,
    createLocationIterator: d3,
    getLoci: et,
    eachLocation: Ze,
    setUpdateState: (J, $, X, Y) => {
      J.createGeometry = !Q1.IsoValue.areSame(X.isoValue, Y.isoValue, $.grid.stats) || X.wrap !== Y.wrap;
    },
    geometryUtils: f6.Utils
  }, Z);
}
var vB0 = {
  solid: (Z, J) => i3("Isosurface mesh", Z, J, GH1, CB0),
  wireframe: (Z, J) => i3("Isosurface wireframe", Z, J, LH1, CB0)
}, SB0 = {
  ...Je,
  ...kB0,
  visuals: j.MultiSelect(["solid"], j.objectToOptions(vB0)),
  bumpFrequency: j.Numeric(1, { min: 0, max: 10, step: 0.1 }, q1.ShadingCategory)
};
function RH1(Z, J) {
  let $ = j.clone(SB0);
  return $.isoValue = Q1.createIsoValueParam(Q1.IsoValue.relative(2), J.grid.stats), $;
}
function EH1(Z, J) {
  return V2.createMulti("Isosurface", Z, J, V2.StateBuilder, vB0);
}
var fB0 = Uq({
  name: "isosurface",
  label: "Isosurface",
  description: "Displays a triangulated isosurface of volumetric data.",
  factory: EH1,
  getParams: RH1,
  defaultValues: j.getDefaultValues(SB0),
  defaultColorTheme: { name: "uniform" },
  defaultSizeTheme: { name: "uniform" },
  isApplicable: (Z) => !Q1.isEmpty(Z) && !Q1.Segmentation.get(Z)
});

// node_modules/molstar/lib/mol-repr/volume/slice.js
var Xe = {
  ...VY.Params,
  quality: { ...VY.Params.quality, isEssential: !1 },
  dimension: j.MappedStatic("x", {
    x: j.Numeric(0, { min: 0, max: 0, step: 1 }, { immediateUpdate: !0 }),
    y: j.Numeric(0, { min: 0, max: 0, step: 1 }, { immediateUpdate: !0 }),
    z: j.Numeric(0, { min: 0, max: 0, step: 1 }, { immediateUpdate: !0 }),
    relativeX: j.Numeric(0, { min: 0, max: 1, step: 0.01 }, { immediateUpdate: !0 }),
    relativeY: j.Numeric(0, { min: 0, max: 1, step: 0.01 }, { immediateUpdate: !0 }),
    relativeZ: j.Numeric(0, { min: 0, max: 1, step: 0.01 }, { immediateUpdate: !0 })
  }, { isEssential: !0, hideIf: (Z) => Z.mode !== "grid", description: "Slice position in grid coordinates." }),
  isoValue: Q1.IsoValueParam,
  mode: j.Select("grid", j.arrayToOptions(["grid", "frame", "plane"]), { description: "Grid: slice through the volume along the grid axes in integer steps. Frame: slice through the volume along arbitrary axes in any step size. Plane: an arbitrary plane defined by point and normal." }),
  offset: j.Numeric(0, { min: -1, max: 1, step: 0.01 }, { isEssential: !0, immediateUpdate: !0, hideIf: (Z) => Z.mode !== "frame", description: "Relative offset from center." }),
  axis: j.Select("a", j.arrayToOptions(["a", "b", "c"]), { isEssential: !0, hideIf: (Z) => Z.mode !== "frame", description: "Axis of the frame." }),
  rotation: j.Group({
    axis: j.Vec3(M.create(1, 0, 0), {}, { description: "Axis of rotation" }),
    angle: j.Numeric(0, { min: -180, max: 180, step: 1 }, { immediateUpdate: !0, description: "Axis rotation angle in Degrees" })
  }, { isExpanded: !0, hideIf: (Z) => Z.mode !== "frame" }),
  plane: j.Group({
    point: j.Vec3(M.create(0, 0, 0), {}, { description: "Plane point" }),
    normal: j.Vec3(M.create(1, 0, 0), {}, { description: "Plane normal" })
  }, { isExpanded: !0, hideIf: (Z) => Z.mode !== "plane" })
};
function OH1(Z, J) {
  let $ = j.clone(Xe), X = J.grid.cells.space.dimensions;
  return $.dimension = j.MappedStatic("x", {
    x: j.Numeric(0, { min: 0, max: X[0] - 1, step: 1 }, { immediateUpdate: !0 }),
    y: j.Numeric(0, { min: 0, max: X[1] - 1, step: 1 }, { immediateUpdate: !0 }),
    z: j.Numeric(0, { min: 0, max: X[2] - 1, step: 1 }, { immediateUpdate: !0 }),
    relativeX: j.Numeric(0, { min: 0, max: 1, step: 0.01 }, { immediateUpdate: !0 }),
    relativeY: j.Numeric(0, { min: 0, max: 1, step: 0.01 }, { immediateUpdate: !0 }),
    relativeZ: j.Numeric(0, { min: 0, max: 1, step: 0.01 }, { immediateUpdate: !0 })
  }, { isEssential: !0, hideIf: (Y) => Y.mode !== "grid" }), $.isoValue = Q1.createIsoValueParam(Q1.IsoValue.absolute(J.grid.stats.min), J.grid.stats), $;
}
async function zH1(Z, J, $, X, Y, Q) {
  switch (Y.mode) {
    case "frame":
      return MH1(Z, J, $, X, Y, Q);
    case "grid":
      return BH1(Z, J, $, X, Y, Q);
    case "plane":
      return AH1(Z, J, $, X, Y, Q);
    default:
      T8(Y.mode);
  }
}
function DH1(Z, J) {
  let { axis: $, rotation: X, mode: Y } = J, Q = s6.getGridToCartesianTransform(Z.grid), W = e.invert(e(), Q), [K, G, H] = Z.grid.cells.space.dimensions, N = K, q = G, U = H, F = M.create(N, 0, 0), E = M.create(0, q, 0), R = M.create(0, 0, U), z = Math.max(N, q, U) / Math.max(K, G, H), D = M.create(0, 0, 0), A = M.create(N, q, U);
  M.transformMat4(D, D, Q), M.transformMat4(A, A, Q);
  let B = M.center(M(), A, D), T = M(), w = M(), V = M(), P = M();
  if ($ === "c")
    M.set(T, N, q, U), M.copy(w, F), M.copy(V, E), M.copy(P, R);
  else if ($ === "b")
    M.set(T, N, U, q), M.copy(w, F), M.copy(P, E), M.copy(V, R);
  else
    M.set(T, q, U, N), M.copy(P, F), M.copy(w, E), M.copy(V, R);
  if (X.angle !== 0) {
    let S = M();
    M.scaleAndAdd(S, S, F, X.axis[0]), M.scaleAndAdd(S, S, E, X.axis[1]), M.scaleAndAdd(S, S, R, X.axis[2]), M.normalize(S, S);
    let f = e.fromRotation(e(), _8(X.angle), S);
    M.transformDirection(w, w, f), M.transformDirection(V, V, f), M.transformDirection(P, P, f);
  }
  if (Y === "frame") {
    let S = M.distance(D, A), f = M.distance(D, A) * Math.SQRT2;
    M.set(T, f, f, S);
  }
  M.transformDirection(w, w, Q), M.transformDirection(V, V, Q), M.transformDirection(P, P, Q);
  let I = {
    type: 3,
    center: M.create(N / 2, q / 2, U / 2),
    scale: M.create(N, q, U),
    rotation: k8.identity(),
    transform: W
  };
  return { size: T, major: w, minor: V, normal: P, center: B, trim: I, resolution: z };
}
function hB0(Z, J, $, X, Y, Q) {
  let { m: W, width: K, height: G } = $, { cells: { space: H }, stats: N } = Z.grid, { min: q, max: U } = N, F = J.color.granularity === "uniform", E = "color" in J.color && J.color.color ? J.color.color : () => i0(16777215), R = M(), z = s6.getGridToCartesianTransform(Z.grid), D = e.invert(e(), z), [A, B, T] = H.dimensions, w = new Uint8Array(K * G * 4), V = new Uint8Array(K * G * 4), P = new Float32Array(K * G), I = M(), S = b$(M(), M()), f = s6.makeGetTrilinearlyInterpolated(Z.grid, "none"), v = 0;
  for (let r = 0;r < G; ++r)
    for (let Y0 = 0;Y0 < K; ++Y0) {
      let c = x8(Y0 + 0.5, 0, K - 1) / K - 0.5, n = x8(r + 0.5, 0, G - 1) / G - 0.5;
      M.set(R, n, -c, 0), M.transformMat4(R, R, W), M.copy(I, R), M.transformMat4(I, I, D);
      let l = Math.trunc(I[0]), u = Math.trunc(I[1]), G0 = Math.trunc(I[2]);
      M.copy(S.position, R);
      let F0 = E(S, !1);
      i0.toArray(F0, w, v);
      let t = aG(f(R), q, U);
      if (F)
        w[v] *= t, w[v + 1] *= t, w[v + 2] *= t;
      if (P[v / 4] = t, l >= 0 && l < A && u >= 0 && u < B && G0 >= 0 && G0 < T)
        UH(H.dataOffset(l, u, G0), V, v);
      v += 4;
    }
  let h = { width: K, height: G, array: w, flipY: !0 }, x = { width: K, height: G, array: V, flipY: !0 }, b = { width: K, height: G, array: P, flipY: !0 }, g = new Float32Array([
    -0.5,
    0.5,
    0,
    0.5,
    0.5,
    0,
    -0.5,
    -0.5,
    0,
    0.5,
    -0.5,
    0
  ]);
  SW(W, g, 0, 4);
  let m = x8(aG(Q1.IsoValue.toAbsolute(X, N).absoluteValue, q, U), 0, 1), i = VY.create(h, g, x, b, Y, m, Q);
  return i.setBoundingSphere(Q1.getBoundingSphere(Z)), i;
}
async function MH1(Z, J, $, X, Y, Q) {
  let { offset: W, isoValue: K } = Y, { size: G, major: H, minor: N, normal: q, center: U, trim: F, resolution: E } = DH1(J, Y), R = 1 / E, z = M.create(G[0], G[1], 1), D = M.setMagnitude(M(), q, G[2] / 2), A = Math.floor(G[1] * R), B = Math.floor(G[0] * R), T = e.identity(), w = M(), V = M();
  return M.add(w, U, H), e.targetTo(T, U, w, N), M.scaleAndAdd(V, U, D, W), e.setTranslation(T, V), e.mul(T, T, e.rotY90), e.scale(T, T, z), hB0(J, X, { m: T, width: A, height: B }, K, F, Q);
}
async function AH1(Z, J, $, X, Y, Q) {
  let { plane: { point: W, normal: K }, isoValue: G } = Y, H = e.fromPlane(e(), K, W), N = s6.getGridToCartesianTransform(J.grid), q = e.invert(e(), N), [U, F, E] = J.grid.cells.space.dimensions, R = U, z = F, D = E, B = 1 / (Math.max(R, z, D) / Math.max(U, F, E)), T = M.distance(M.create(0, 0, 0), M.create(R, z, D)) * Math.SQRT2, w = M.set(M(), T, T, T);
  e.mul(H, H, e.rotY90), e.scale(H, H, w);
  let V = Math.floor(w[1] * B), P = Math.floor(w[0] * B), I = {
    type: 3,
    center: M.create(R / 2, z / 2, D / 2),
    scale: M.create(R, z, D),
    rotation: k8.identity(),
    transform: q
  };
  return hB0(J, X, { m: H, width: V, height: P }, G, I, Q);
}
async function BH1(Z, J, $, X, Y, Q) {
  let { dimension: { name: W }, isoValue: K } = Y, { cells: { space: G, data: H }, stats: N } = J.grid, { min: q, max: U } = N, F = X.color.granularity === "uniform", E = "color" in X.color && X.color.color ? X.color.color : () => i0(16777215), { width: R, height: z, x: D, y: A, z: B, x0: T, y0: w, z0: V, nx: P, ny: I, nz: S } = Ye(J.grid, Y), f = new Float32Array(W === "x" || W === "relativeX" ? [D, 0, 0, D, A, 0, D, 0, B, D, A, B] : W === "y" || W === "relativeY" ? [0, A, 0, D, A, 0, 0, A, B, D, A, B] : [0, 0, B, 0, A, B, D, 0, B, D, A, B]), v = new Uint8Array(R * z * 4), h = wH1(J.grid, Y), x = new Float32Array(R * z), b = s6.getGridToCartesianTransform(J.grid), g = b$(M(), M()), m = 0;
  for (let G0 = w;G0 < I; ++G0)
    for (let F0 = T;F0 < P; ++F0)
      for (let t = V;t < S; ++t) {
        M.set(g.position, F0, G0, t), M.transformMat4(g.position, g.position, b), i0.toArray(E(g, !1), v, m);
        let Z0 = aG(G.get(H, F0, G0, t), q, U);
        if (F)
          v[m] *= Z0, v[m + 1] *= Z0, v[m + 2] *= Z0;
        x[m / 4] = Z0, m += 4;
      }
  let i = { width: R, height: z, array: v, flipY: !0 }, r = { width: R, height: z, array: h, flipY: !0 }, Y0 = { width: R, height: z, array: x, flipY: !0 }, c = s6.getGridToCartesianTransform(J.grid);
  SW(c, f, 0, 4);
  let n = VY.createEmptyTrim(), l = x8(aG(Q1.IsoValue.toAbsolute(K, N).absoluteValue, q, U), 0, 1), u = VY.create(i, f, r, Y0, n, l, Q);
  return u.setBoundingSphere(Q1.getBoundingSphere(J)), u;
}
function $e(Z, J) {
  return x8(Math.round((Z - 1) * J), 0, Z - 1);
}
function Ye(Z, J) {
  let { dimension: { name: $, params: X } } = J, { space: Y } = Z.cells, Q, W, K, G, H, N = 0, q = 0, U = 0, [F, E, R] = Y.dimensions;
  if ($ === "x")
    K = X, G = E, H = R, Q = R, W = E, N = K, F = N + 1;
  else if ($ === "y")
    K = F, G = X, H = R, Q = R, W = F, q = G, E = q + 1;
  else if ($ === "z")
    K = F, G = E, H = X, Q = F, W = E, U = H, R = U + 1;
  else if ($ === "relativeX")
    K = $e(F, X), G = E, H = R, Q = R, W = E, N = K, F = N + 1;
  else if ($ === "relativeY")
    K = F, G = $e(E, X), H = R, Q = R, W = F, q = G, E = q + 1;
  else
    K = F, G = E, H = $e(R, X), Q = F, W = E, U = H, R = U + 1;
  return {
    width: Q,
    height: W,
    x: K,
    y: G,
    z: H,
    x0: N,
    y0: q,
    z0: U,
    nx: F,
    ny: E,
    nz: R
  };
}
function wH1(Z, J) {
  let { space: $ } = Z.cells, { width: X, height: Y, x0: Q, y0: W, z0: K, nx: G, ny: H, nz: N } = Ye(Z, J), q = new Uint8Array(X * Y * 4), U = 0;
  for (let F = W;F < H; ++F)
    for (let E = Q;E < G; ++E)
      for (let R = K;R < N; ++R)
        UH($.dataOffset(E, F, R), q, U), U += 4;
  return q;
}
function jH1(Z, J) {
  let { space: $ } = Z.cells, { width: X, height: Y, x0: Q, y0: W, z0: K, nx: G, ny: H, nz: N } = Ye(Z, J), q = new Uint32Array(X * Y), U = 0;
  for (let F = W;F < H; ++F)
    for (let E = Q;E < G; ++E)
      for (let R = K;R < N; ++R)
        q[U] = $.dataOffset(E, F, R), U += 1;
  return q;
}
function bB0(Z, J, $) {
  if ($.mode === "grid") {
    let X = jH1(Z.grid, $), Y = X1.ofUnsortedArray(X);
    return Q1.Cell.Loci(Z, [{ indices: Y, instances: J }]);
  } else
    return Q1.Loci(Z, J);
}
function TH1(Z, J) {
  let $ = k0.ofLength(Z.instances.length);
  return bB0(Z, $, J);
}
function _H1(Z, J, $, X, Y) {
  let { objectId: Q, groupId: W, instanceId: K } = Z;
  if (Y === Q) {
    let G = Q1.PickingGranularity.get(J), H = f0.ofSingleton(K);
    if (G === "volume")
      return Q1.Loci(J, H);
    if (G === "object" || W === K7.Null)
      return bB0(J, H, X);
    else {
      let N = k0.ofSingleton(W);
      return Q1.Cell.Loci(J, [{ indices: N, instances: H }]);
    }
  }
  return G8;
}
function VH1(Z, J, $, X, Y) {
  return qq(Z, J, void 0, Y);
}
function IH1(Z) {
  return gW({
    defaultProps: j.getDefaultValues(Xe),
    createGeometry: zH1,
    createLocationIterator: d3,
    getLoci: _H1,
    eachLocation: VH1,
    setUpdateState: (J, $, X, Y, Q, W) => {
      J.createGeometry = X.dimension.name !== Y.dimension.name || X.dimension.params !== Y.dimension.params || X.mode !== Y.mode || !M.equals(X.rotation.axis, Y.rotation.axis) || X.rotation.angle !== Y.rotation.angle || X.offset !== Y.offset || X.axis !== Y.axis || !M.equals(X.plane.point, Y.plane.point) || !M.equals(X.plane.normal, Y.plane.normal) || !Q1.IsoValue.areSame(X.isoValue, Y.isoValue, $.grid.stats) || !oJ.areEqual(Q.color, W.color);
    },
    geometryUtils: VY.Utils
  }, Z);
}
function PH1(Z, J) {
  return i3("Slice", Z, J, IH1, TH1);
}
var xB0 = Uq({
  name: "slice",
  label: "Slice",
  description: "Slice of volume rendered as image with interpolation.",
  factory: PH1,
  getParams: OH1,
  defaultValues: j.getDefaultValues(Xe),
  defaultColorTheme: { name: "uniform" },
  defaultSizeTheme: { name: "uniform" },
  isApplicable: (Z) => !Q1.isEmpty(Z) && !Q1.Segmentation.get(Z)
});

// node_modules/molstar/lib/mol-repr/volume/direct-volume.js
function yB0(Z, J) {
  let $ = t1();
  return t1.add($, Z), t1.transform($, $, J), $;
}
function CH1(Z, J, $, X, Y) {
  let Q = $.grid.cells.space.dimensions, { width: W, height: K } = p3(Q);
  if (Math.max(W, K) > J.maxTextureSize / 2)
    throw new Error("volume too large for direct-volume rendering");
  let G = X.dataType === "halfFloat" && !J.extensions.textureHalfFloat ? "float" : X.dataType, H = gb($, "normals", 0, G), N = s6.getGridToCartesianTransform($.grid), q = yB0(Q, N), U;
  if (Y && Y.dataType.ref.value === G)
    U = Y.gridTexture.ref.value;
  else
    U = G === "byte" ? J.resources.texture("image-uint8", "rgba", "ubyte", "linear") : G === "halfFloat" ? J.resources.texture("image-float16", "rgba", "fp16", "linear") : J.resources.texture("image-float32", "rgba", "float", "linear");
  U.load(H);
  let { unitToCartn: F, cellDim: E } = gB0($.grid), R = $.grid.cells.space.axisOrderSlowToFast;
  return gX.create(q, Q, N, F, E, U, $.grid.stats, !1, R, G, Y);
}
function gB0(Z) {
  if (Z.transform.kind === "matrix")
    return {
      unitToCartn: e.mul(e(), Z.transform.matrix, e.fromScaling(e(), Z.cells.space.dimensions)),
      cellDim: e.getScaling(M(), Z.transform.matrix)
    };
  let J = Z.transform.fractionalBox, $ = t1.size(M(), J);
  return {
    unitToCartn: e.mul3(e(), Z.transform.cell.fromFractional, e.fromTranslation(e(), J.min), e.fromScaling(e(), $)),
    cellDim: M.div(M(), Z.transform.cell.size, Z.cells.space.dimensions)
  };
}
function kH1(Z, J, $, X, Y) {
  let Q = $.grid.cells.space.dimensions;
  if (Math.max(...Q) > J.max3dTextureSize / 2)
    throw new Error("volume too large for direct-volume rendering");
  let W = X.dataType === "halfFloat" && !J.extensions.textureHalfFloat ? "float" : X.dataType, K = NA0($, W), G = s6.getGridToCartesianTransform($.grid), H = yB0(Q, G), N;
  if (Y && Y.dataType.ref.value === W)
    N = Y.gridTexture.ref.value;
  else
    N = W === "byte" ? J.resources.texture("volume-uint8", "rgba", "ubyte", "linear") : W === "halfFloat" ? J.resources.texture("volume-float16", "rgba", "fp16", "linear") : J.resources.texture("volume-float32", "rgba", "float", "linear");
  N.load(K);
  let { unitToCartn: q, cellDim: U } = gB0($.grid), F = $.grid.cells.space.axisOrderSlowToFast;
  return gX.create(H, Q, G, q, U, N, $.grid.stats, !1, F, W, Y);
}
async function vH1(Z, J, $, X, Y, Q) {
  let { runtime: W, webgl: K } = Z;
  if (K === void 0)
    throw new Error("DirectVolumeVisual requires `webgl` in VisualContext");
  return K.isWebGL2 ? kH1(W, K, J, Y, Q) : CH1(W, K, J, Y, Q);
}
function SH1(Z, J) {
  let $ = k0.ofLength(Z.instances.length);
  return Q1.Loci(Z, $);
}
function fH1(Z, J, $, X, Y) {
  let { objectId: Q, groupId: W, instanceId: K } = Z;
  if (Y === Q) {
    let G = f0.ofSingleton(K), H = k0.ofSingleton(W);
    return Q1.Cell.Loci(J, [{ indices: H, instances: G }]);
  }
  return G8;
}
function hH1(Z, J, $, X, Y) {
  return qq(Z, J, void 0, Y);
}
var Qe = {
  ...gX.Params,
  quality: { ...gX.Params.quality, isEssential: !1 },
  dataType: j.Select("byte", j.arrayToOptions(["byte", "float", "halfFloat"]))
};
function bH1(Z, J) {
  let $ = j.clone(Qe);
  return $.controlPoints.getVolume = () => J, $;
}
function xH1(Z) {
  return gW({
    defaultProps: j.getDefaultValues(Qe),
    createGeometry: vH1,
    createLocationIterator: d3,
    getLoci: fH1,
    eachLocation: hH1,
    setUpdateState: (J, $, X, Y) => {
      J.createGeometry = X.dataType !== Y.dataType;
    },
    geometryUtils: gX.Utils,
    dispose: (J) => {
      J.gridTexture.ref.value.destroy();
    }
  }, Z);
}
function yH1(Z, J) {
  return i3("Direct Volume", Z, J, xH1, SH1);
}
var mB0 = Uq({
  name: "direct-volume",
  label: "Direct Volume",
  description: "Direct rendering of volumetric data.",
  factory: yH1,
  getParams: bH1,
  defaultValues: j.getDefaultValues(Qe),
  defaultColorTheme: { name: "volume-value" },
  defaultSizeTheme: { name: "uniform" },
  locationKinds: ["position-location", "direct-location"],
  isApplicable: (Z) => !Q1.isEmpty(Z) && !Q1.Segmentation.get(Z)
});

// node_modules/molstar/lib/mol-repr/volume/segment.js
var gH1 = {
  segments: j.Converted((Z) => Z.map((J) => `${J}`), (Z) => Z.map((J) => parseInt(J)), j.MultiSelect(["0"], j.arrayToOptions(["0"]), {
    isEssential: !0
  }))
};
function mH1(Z) {
  return Z.extensions.colorBufferFloat && Z.extensions.textureFloat && Z.extensions.drawBuffers;
}
var nV = 1;
function Ke(Z, J) {
  if (Z.grid.cells.data.length < Math.pow(10, 3))
    return !1;
  let $ = Z.grid.cells.space.dimensions, { powerOfTwoSize: X } = p3($, nV);
  return X <= J.maxTextureSize / 2;
}
var dH1 = e();
function dB0(Z, J) {
  let $ = s6.getGridToCartesianTransform(Z), X = e.fromTranslation(dH1, J.min);
  return e.mul(e(), $, X);
}
function pH1(Z, J, $, X, Y) {
  if (X.tryUseGpu && Y && mH1(Y) && Ke(J, Y))
    return sH1(Z);
  return nH1(Z);
}
function uH1(Z, J) {
  let $ = X1.ofUnsortedArray(J.segments), X = k0.ofLength(Z.instances.length);
  return Q1.Segment.Loci(Z, [{ segments: $, instances: X }]);
}
function pB0(Z, J, $, X, Y) {
  let { objectId: Q, groupId: W, instanceId: K } = Z;
  if (Y === Q) {
    let G = Q1.PickingGranularity.get(J), H = f0.ofSingleton(K);
    if (G === "volume")
      return Q1.Loci(J, H);
    else if (G === "object" || W === K7.Null) {
      let N = f0.ofSingleton($);
      return Q1.Segment.Loci(J, [{ segments: N, instances: H }]);
    } else {
      let N = k0.ofSingleton(W);
      return Q1.Cell.Loci(J, [{ indices: N, instances: H }]);
    }
  }
  return G8;
}
function uB0(Z, J, $, X, Y) {
  let Q = X1.ofSingleton($);
  return qq(Z, J, { segments: Q }, Y);
}
function cH1(Z, J, $) {
  let X = $.data, Y = $.space.dataOffset, Q = t1.size(M(), J), [W, K, G] = Q, H = W - 1, N = K - 1, q = G - 1, [U, F, E] = J.min, [R, z, D] = J.max, A = [...$.space.axisOrderSlowToFast], B = M8.Space(Q, A, Uint8Array), T = M8.create(B, B.create()), w = T.data, V = B.set;
  for (let P = 0;P < G; ++P)
    for (let I = 0;I < K; ++I)
      for (let S = 0;S < W; ++S) {
        let f = Z.includes(X[Y(S + U, I + F, P + E)]) ? 255 : 0, v = Z.includes(X[Y(Math.min(H + R, S + 1 + U), I + F, P + E)]) ? 255 : 0, h = Z.includes(X[Y(Math.max(0, S - 1 + U), I + F, P + E)]) ? 255 : 0, x = Z.includes(X[Y(S + U, Math.min(N + z, I + 1 + F), P + E)]) ? 255 : 0, b = Z.includes(X[Y(S + U, Math.max(0, I - 1 + F), P + E)]) ? 255 : 0, g = Z.includes(X[Y(S + U, I + F, Math.min(q + D, P + 1 + E))]) ? 255 : 0, m = Z.includes(X[Y(S + U, I + F, Math.max(0, P - 1 + E))]) ? 255 : 0;
        V(w, S, I, P, Math.round((f + f + v + h + x + b + g + m) / 8));
      }
  return T;
}
async function lH1(Z, J, $, X, Y, Q) {
  let W = Q1.Segmentation.get(J);
  if (!W)
    throw new Error("missing volume segmentation");
  Z.runtime.update({ message: "Marching cubes..." });
  let K = t1.clone(W.bounds[$]);
  t1.expand(K, K, M.create(2, 2, 2));
  let G = Array.from(W.segments.get($).values()), H = cH1(G, K, J.grid.cells), N = uJ(new Int32Array(H.data.length)), q = await Fq({
    isoLevel: 128,
    scalarField: H,
    idField: M8.create(H.space, M8.Data1(N))
  }, Q).runAsChild(Z.runtime), U = dB0(J.grid, K);
  if (n1.transform(q, U), Z.webgl && !Z.webgl.isWebGL2)
    n1.uniformTriangleGroup(q, !1), C.updateIfChanged(q.varyingGroup, !1);
  else
    C.updateIfChanged(q.varyingGroup, !0);
  let F = k0.ofLength(J.instances.length), E = f0.ofSingleton($);
  return q.setBoundingSphere(Q1.Segment.getBoundingSphere(J, [{ segments: E, instances: F }])), q;
}
var Ge = {
  ...n1.Params,
  ...iJ.Params,
  ...gH1,
  quality: { ...n1.Params.quality, isEssential: !1 },
  tryUseGpu: j.Boolean(!0)
};
function nH1(Z) {
  return gW({
    defaultProps: j.getDefaultValues(Ge),
    createGeometry: lH1,
    createLocationIterator: (J, $) => {
      let X = Q1.Segment.Location(J, $);
      return X6(J.grid.cells.data.length, J.instances ? J.instances.length : 1, 1, () => X);
    },
    getLoci: pB0,
    eachLocation: uB0,
    setUpdateState: (J, $, X, Y) => {},
    geometryUtils: n1.Utils,
    mustRecreate: (J, $, X) => {
      return $.tryUseGpu && !!X && Ke(J.volume, X);
    }
  }, Z);
}
var We = "segment-texture";
function iH1(Z, J, $) {
  let X = Q1.Segmentation.get(Z);
  if (!X)
    throw new Error("missing volume segmentation");
  let { resources: Y } = $, Q = t1.clone(X.bounds[J]);
  t1.expand(Q, Q, M.create(2, 2, 2));
  let W = dB0(Z.grid, Q), K = t1.size(M(), Q), { width: G, height: H, powerOfTwoSize: N } = p3(K, nV), q = M.create(G, H, 0), U = M.clone(K), F = h0.create(G / N, H / N);
  if (N > $.maxTextureSize / 2)
    throw new Error("volume too large for gpu segment extraction");
  if (!$.namedTextures[We])
    $.namedTextures[We] = Y.texture("image-uint8", "alpha", "ubyte", "linear");
  let E = $.namedTextures[We];
  E.define(N, N);
  let R = Array.from(X.segments.get(J).values());
  return E.load(qA0(Z, R, Q, nV), !0), K[0] += nV, K[1] += nV, {
    texture: E,
    transform: W,
    gridDimension: K,
    gridTexDim: q,
    gridDataDim: U,
    gridTexScale: F
  };
}
async function oH1(Z, J, $, X, Y, Q) {
  if (!Z.webgl)
    throw new Error("webgl context required to create volume segment texture-mesh");
  if (J.grid.cells.data.length <= 1)
    return iJ.createEmpty(Q);
  let { texture: W, gridDimension: K, gridTexDim: G, gridDataDim: H, gridTexScale: N, transform: q } = iH1(J, $, Z.webgl), U = J.grid.cells.space.axisOrderSlowToFast, F = Q === null || Q === void 0 ? void 0 : Q.doubleBuffer.get(), E = xz(Z.webgl, W, K, G, H, N, q, 0.5, !1, !1, U, !0, F === null || F === void 0 ? void 0 : F.vertex, F === null || F === void 0 ? void 0 : F.group, F === null || F === void 0 ? void 0 : F.normal), R = J.grid.cells.data.length, z = k0.ofLength(J.instances.length), D = f0.ofSingleton($), A = Q1.Segment.getBoundingSphere(J, [{ segments: D, instances: z }]);
  return iJ.create(E.vertexCount, R, E.vertexTexture, E.groupTexture, E.normalTexture, A, Q);
}
function sH1(Z) {
  return gW({
    defaultProps: j.getDefaultValues(Ge),
    createGeometry: oH1,
    createLocationIterator: (J, $) => {
      let X = Q1.Segment.Location(J, $);
      return X6(J.grid.cells.data.length, J.instances ? J.instances.length : 1, 1, () => X);
    },
    getLoci: pB0,
    eachLocation: uB0,
    setUpdateState: (J, $, X, Y) => {},
    geometryUtils: iJ.Utils,
    mustRecreate: (J, $, X) => {
      return !$.tryUseGpu || !X || !Ke(J.volume, X);
    },
    dispose: (J) => {
      J.vertexTexture.ref.value.destroy(), J.groupTexture.ref.value.destroy(), J.normalTexture.ref.value.destroy(), J.doubleBuffer.destroy();
    }
  }, Z);
}
function aH1(Z) {
  return X1.ofUnsortedArray(Z.segments);
}
var cB0 = {
  segment: (Z, J) => i3("Segment mesh", Z, J, pH1, uH1, aH1)
}, lB0 = {
  ...Ge,
  visuals: j.MultiSelect(["segment"], j.objectToOptions(cB0)),
  bumpFrequency: j.Numeric(1, { min: 0, max: 10, step: 0.1 }, q1.ShadingCategory)
};
function rH1(Z, J) {
  let $ = j.clone(lB0), X = Q1.Segmentation.get(J);
  if (X) {
    let Y = Array.from(X.segments.keys());
    $.segments = j.Converted((Q) => Q.map((W) => `${W}`), (Q) => Q.map((W) => parseInt(W)), j.MultiSelect(Y.map((Q) => `${Q}`), j.arrayToOptions(Y.map((Q) => `${Q}`)), {
      isEssential: !0
    }));
  }
  return $;
}
function tH1(Z, J) {
  return V2.createMulti("Segment", Z, J, V2.StateBuilder, cB0);
}
var nB0 = Uq({
  name: "segment",
  label: "Segment",
  description: "Displays a triangulated segment of volumetric data.",
  factory: tH1,
  getParams: rH1,
  defaultValues: j.getDefaultValues(lB0),
  defaultColorTheme: { name: "volume-segment" },
  defaultSizeTheme: { name: "uniform" },
  isApplicable: (Z) => !Q1.isEmpty(Z) && !!Q1.Segmentation.get(Z)
});

// node_modules/molstar/lib/mol-geo/geometry/spheres/spheres-builder.js
var eH1 = B1.add3, ZN1 = B1.add, wH;
(function(Z) {
  function J($ = 2048, X = 1024, Y) {
    let Q = B1.create(Float32Array, 3, X, Y ? Y.centerBuffer.ref.value : $), W = B1.create(Float32Array, 1, X, Y ? Y.groupBuffer.ref.value : $);
    return {
      add: (K, G, H, N) => {
        eH1(Q, K, G, H), ZN1(W, N);
      },
      getSpheres: () => {
        let K = B1.compact(Q, !0), G = B1.compact(W, !0);
        return R$.create(K, G, Q.elementCount, Y);
      }
    };
  }
  Z.create = J;
})(wH || (wH = {}));

// node_modules/molstar/lib/mol-geo/geometry/points/points-builder.js
var JN1 = B1.add3, $N1 = B1.add, yz;
(function(Z) {
  function J($ = 2048, X = 1024, Y) {
    let Q = B1.create(Float32Array, 3, X, Y ? Y.centerBuffer.ref.value : $), W = B1.create(Float32Array, 1, X, Y ? Y.groupBuffer.ref.value : $);
    return {
      add: (K, G, H, N) => {
        JN1(Q, K, G, H), $N1(W, N);
      },
      getPoints: () => {
        let K = B1.compact(Q, !0), G = B1.compact(W, !0);
        return YX.create(K, G, Q.elementCount, Y);
      }
    };
  }
  Z.create = J;
})(yz || (yz = {}));

// node_modules/molstar/lib/mol-repr/volume/dot.js
var oB0 = {
  isoValue: Q1.IsoValueParam,
  perturbPositions: j.Boolean(!1)
}, He = {
  ...R$.Params,
  ...n1.Params,
  ...oB0,
  tryUseImpostor: j.Boolean(!0),
  detail: j.Numeric(0, { min: 0, max: 3, step: 1 }, q1.CustomQualityParamInfo)
};
function XN1(Z, J, $, X, Y) {
  return X.tryUseImpostor && Y && Y.extensions.fragDepth && Y.extensions.textureFloat ? YN1(Z) : QN1(Z);
}
function YN1(Z) {
  return gW({
    defaultProps: j.getDefaultValues(He),
    createGeometry: WN1,
    createLocationIterator: d3,
    getLoci: Fe,
    eachLocation: Ue,
    setUpdateState: (J, $, X, Y, Q, W) => {
      J.createGeometry = !Q1.IsoValue.areSame(X.isoValue, Y.isoValue, $.grid.stats) || X.perturbPositions !== Y.perturbPositions;
    },
    geometryUtils: R$.Utils,
    mustRecreate: (J, $, X) => {
      return !$.tryUseImpostor || !X;
    }
  }, Z);
}
function QN1(Z) {
  return gW({
    defaultProps: j.getDefaultValues(He),
    createGeometry: KN1,
    createLocationIterator: d3,
    getLoci: Fe,
    eachLocation: Ue,
    setUpdateState: (J, $, X, Y, Q, W) => {
      J.createGeometry = !Q1.IsoValue.areSame(X.isoValue, Y.isoValue, $.grid.stats) || X.perturbPositions !== Y.perturbPositions || X.sizeFactor !== Y.sizeFactor || X.detail !== Y.detail;
    },
    geometryUtils: n1.Utils,
    mustRecreate: (J, $, X) => {
      return $.tryUseImpostor && !!X;
    }
  }, Z);
}
function Ne(Z) {
  return {
    ...e.extractBasis(Z),
    maxScale: e.getMaxScaleOnAxis(Z)
  };
}
var iA = M();
function qe({ x: Z, y: J, z: $, maxScale: X }) {
  let Y = (Math.random() - 0.5) * X, Q = (Math.random() - 0.5) * X, W = (Math.random() - 0.5) * X;
  return M.scale(iA, Z, Y), M.scaleAndAdd(iA, iA, J, Q), M.scaleAndAdd(iA, iA, $, W), iA;
}
function WN1(Z, J, $, X, Y, Q) {
  let { cells: { space: W, data: K }, stats: G } = J.grid, H = s6.getGridToCartesianTransform(J.grid), N = Q1.IsoValue.toAbsolute(Y.isoValue, G).absoluteValue, q = M(), [U, F, E] = W.dimensions, R = Math.ceil(U * F * E / 10), z = wH.create(R, Math.ceil(R / 2), Q), D = N < 0, A = Y.perturbPositions ? Ne(H) : void 0;
  for (let T = 0;T < E; ++T)
    for (let w = 0;w < F; ++w)
      for (let V = 0;V < U; ++V) {
        let P = W.get(K, V, w, T);
        if (!D && P < N || D && P > N)
          continue;
        let I = W.dataOffset(V, w, T);
        if (A) {
          M.set(q, V, w, T), M.transformMat4(q, q, H);
          let S = qe(A);
          M.add(q, q, S);
        } else
          M.set(q, V, w, T), M.transformMat4(q, q, H);
        z.add(q[0], q[1], q[2], I);
      }
  let B = z.getSpheres();
  return B.setBoundingSphere(Q1.Isosurface.getBoundingSphere(J, Y.isoValue)), B;
}
function KN1(Z, J, $, X, Y, Q) {
  let { detail: W, sizeFactor: K } = Y, { cells: { space: G, data: H }, stats: N } = J.grid, q = s6.getGridToCartesianTransform(J.grid), U = Q1.IsoValue.toAbsolute(Y.isoValue, N).absoluteValue, F = M(), [E, R, z] = G.dimensions, A = Math.ceil(E * R * z / 10) * _5(W), B = v1.createState(A, Math.ceil(A / 2), Q), T = Q1.Cell.Location(J), w = X.size.size, V = U < 0, P = Y.perturbPositions ? Ne(q) : void 0;
  for (let S = 0;S < z; ++S)
    for (let f = 0;f < R; ++f)
      for (let v = 0;v < E; ++v) {
        let h = G.get(H, v, f, S);
        if (!V && h < U || V && h > U)
          continue;
        let x = G.dataOffset(v, f, S);
        T.cell = x;
        let b = w(T) * K;
        if (P) {
          M.set(F, v, f, S), M.transformMat4(F, F, q);
          let g = qe(P);
          M.add(F, F, g);
        } else
          M.set(F, v, f, S), M.transformMat4(F, F, q);
        B.currentGroup = x, g8(B, F, b, W);
      }
  let I = v1.getMesh(B);
  return I.setBoundingSphere(Q1.Isosurface.getBoundingSphere(J, Y.isoValue)), I;
}
var sB0 = {
  ...YX.Params,
  ...oB0
};
function GN1(Z) {
  return gW({
    defaultProps: j.getDefaultValues(sB0),
    createGeometry: HN1,
    createLocationIterator: d3,
    getLoci: Fe,
    eachLocation: Ue,
    setUpdateState: (J, $, X, Y, Q, W) => {
      J.createGeometry = !Q1.IsoValue.areSame(X.isoValue, Y.isoValue, $.grid.stats) || X.perturbPositions !== Y.perturbPositions;
    },
    geometryUtils: YX.Utils
  }, Z);
}
function HN1(Z, J, $, X, Y, Q) {
  let { cells: { space: W, data: K }, stats: G } = J.grid, H = s6.getGridToCartesianTransform(J.grid), N = Q1.IsoValue.toAbsolute(Y.isoValue, G).absoluteValue, q = M(), [U, F, E] = W.dimensions, R = Math.ceil(U * F * E / 10), z = yz.create(R, Math.ceil(R / 2), Q), D = N < 0, A = Y.perturbPositions ? Ne(H) : void 0;
  for (let T = 0;T < E; ++T)
    for (let w = 0;w < F; ++w)
      for (let V = 0;V < U; ++V) {
        let P = W.get(K, V, w, T);
        if (!D && P < N || D && P > N)
          continue;
        let I = W.dataOffset(V, w, T);
        if (A) {
          M.set(q, V, w, T), M.transformMat4(q, q, H);
          let S = qe(A);
          M.add(q, q, S);
        } else
          M.set(q, V, w, T), M.transformMat4(q, q, H);
        z.add(q[0], q[1], q[2], I);
      }
  let B = z.getPoints();
  return B.setBoundingSphere(Q1.Isosurface.getBoundingSphere(J, Y.isoValue)), B;
}
function iB0(Z, J) {
  let $ = k0.ofLength(Z.instances.length);
  return Q1.Isosurface.Loci(Z, J.isoValue, $);
}
function Fe(Z, J, $, X, Y) {
  let { objectId: Q, groupId: W, instanceId: K } = Z;
  if (Y === Q) {
    let G = Q1.PickingGranularity.get(J), H = f0.ofSingleton(K);
    if (G === "volume")
      return Q1.Loci(J, H);
    else if (G === "object" || W === K7.Null)
      return Q1.Isosurface.Loci(J, X.isoValue, H);
    else {
      let N = k0.ofSingleton(W);
      return Q1.Cell.Loci(J, [{ indices: N, instances: H }]);
    }
  }
  return G8;
}
function Ue(Z, J, $, X, Y) {
  return qq(Z, J, { isoValue: X.isoValue }, Y);
}
var aB0 = {
  sphere: (Z, J) => i3("Dot sphere", Z, J, XN1, iB0),
  point: (Z, J) => i3("Dot point", Z, J, GN1, iB0)
}, rB0 = {
  ...He,
  ...sB0,
  visuals: j.MultiSelect(["sphere"], j.objectToOptions(aB0)),
  bumpFrequency: j.Numeric(1, { min: 0, max: 10, step: 0.1 }, q1.ShadingCategory)
};
function NN1(Z, J) {
  let $ = j.clone(rB0);
  return $.isoValue = Q1.createIsoValueParam(Q1.IsoValue.relative(2), J.grid.stats), $;
}
function qN1(Z, J) {
  return V2.createMulti("Dot", Z, J, V2.StateBuilder, aB0);
}
var tB0 = Uq({
  name: "dot",
  label: "Dot",
  description: "Displays dots of volumetric data.",
  factory: qN1,
  getParams: NN1,
  defaultValues: j.getDefaultValues(rB0),
  defaultColorTheme: { name: "uniform" },
  defaultSizeTheme: { name: "uniform" },
  isApplicable: (Z) => !Q1.isEmpty(Z) && !Q1.Segmentation.get(Z)
});

// node_modules/molstar/lib/mol-repr/volume/registry.js
class sR extends xV {
  constructor() {
    super();
    B7(sR.BuiltIn, (Z, J) => {
      if (Z.name !== J)
        throw new Error(`Fix BuiltInVolumeRepresentations to have matching names. ${Z.name} ${J}`);
      this.add(Z);
    });
  }
}
(function(Z) {
  Z.BuiltIn = {
    "direct-volume": mB0,
    dot: tB0,
    isosurface: fB0,
    segment: nB0,
    slice: xB0
  };
})(sR || (sR = {}));

// node_modules/molstar/lib/mol-plugin/behavior/dynamic/volume-streaming/transformers.js
function eB0(Z, J, $, X) {
  Z.push({
    source: J === "em" ? { name: "em", params: { isoValue: Q1.IsoValue.absolute(X || 0) } } : { name: "x-ray", params: {} },
    dataId: $
  });
}
var iV = a$.build({
  display: { name: "Volume Streaming" },
  from: D0.Molecule.Structure,
  params(Z, J) {
    let $ = QU0(Z && Z.data), X = WU0($, Z && Z.data);
    return {
      method: j.Select($, [["em", "EM"], ["x-ray", "X-Ray"]]),
      entries: j.ObjectList({ id: j.Text(X[0] || "") }, ({ id: Y }) => Y, { defaultValue: X.map((Y) => ({ id: Y })) }),
      defaultView: j.Select($ === "em" ? "auto" : "selection-box", y$.ViewTypeOptions),
      options: j.Group({
        serverUrl: j.Text(J.config.get(W8.VolumeStreaming.DefaultServer) || "https://ds.litemol.org"),
        behaviorRef: j.Text("", { isHidden: !0 }),
        emContourProvider: j.Select("emdb", [["emdb", "EMDB"], ["pdbe", "PDBe"]], { isHidden: !0 }),
        channelParams: j.Value({}, { isHidden: !0 })
      })
    };
  },
  isApplicable: (Z, J, $) => {
    let X = $.config.get(W8.VolumeStreaming.CanStream);
    if (X)
      return X(Z.data, $);
    return Z.data.models.length === 1 && O2.probablyHasDensityMap(Z.data.models[0]);
  }
})(({ ref: Z, state: J, params: $ }, X) => n0.create("Volume Streaming", async (Y) => {
  let Q = [];
  for (let q = 0, U = $.entries.length;q < U; ++q) {
    let F = $.entries[q].id.toLowerCase(), E;
    if ($.method === "em") {
      if (!F.toUpperCase().startsWith("EMD")) {
        await Y.update("Getting EMDB info...");
        let R = await KU0(X, Y, F);
        for (let z = 0, D = R.length;z < D; ++z) {
          let A = R[z], B;
          try {
            B = await ds($.options.emContourProvider, X, Y, A);
          } catch (T) {
            console.info(`Could not get map info for ${A}: ${T}`);
            continue;
          }
          eB0(Q, $.method, A, B || 0);
        }
        continue;
      }
      try {
        E = await ds($.options.emContourProvider, X, Y, F);
      } catch (R) {
        console.info(`Could not get map info for ${F}: ${R}`);
        continue;
      }
    }
    eB0(Q, $.method, F, E || 0);
  }
  let W = J.build().to(Z).applyOrUpdateTagged(y$.RootTag, UN1, {
    serverUrl: $.options.serverUrl,
    entries: Q
  });
  await W.commit();
  let K = W.selector;
  if (!K.isOk)
    return;
  let G = J.tree.children.get(K.ref);
  if ((G === null || G === void 0 ? void 0 : G.size) > 0)
    await X.managers.structure.hierarchy.remove(G === null || G === void 0 ? void 0 : G.toArray());
  let H = K.cell.obj, N = J.build().to(W.ref).apply(oV, j.getDefaultValues(y$.createParams({ data: H.data, defaultView: $.defaultView, channelParams: $.options.channelParams })), { ref: $.options.behaviorRef ? $.options.behaviorRef : void 0 });
  if ($.method === "em")
    N.apply(Zx, { channel: "em" }, { state: { isGhost: !0 }, tags: "em" });
  else
    N.apply(Zx, { channel: "2fo-fc" }, { state: { isGhost: !0 }, tags: "2fo-fc" }), N.apply(Zx, { channel: "fo-fc(+ve)" }, { state: { isGhost: !0 }, tags: "fo-fc(+ve)" }), N.apply(Zx, { channel: "fo-fc(-ve)" }, { state: { isGhost: !0 }, tags: "fo-fc(-ve)" });
  await J.updateTree(N).runInContext(Y);
})), Jw0 = a$.build({
  display: { name: "Boxify Volume Streaming", description: "Make the current box permanent." },
  from: y$,
  isApplicable: (Z) => Z.data.params.entry.params.view.name === "selection-box"
})(({ a: Z, ref: J, state: $ }, X) => {
  let Y = Z.data.params;
  if (Y.entry.params.view.name !== "selection-box")
    return;
  let Q = t1.create(M.clone(Y.entry.params.view.params.bottomLeft), M.clone(Y.entry.params.view.params.topRight)), W = Y.entry.params.view.params.radius;
  t1.expand(Q, Q, M.create(W, W, W));
  let K = {
    ...Y,
    entry: {
      name: Y.entry.name,
      params: {
        ...Y.entry.params,
        view: {
          name: "box",
          params: {
            bottomLeft: Q.min,
            topRight: Q.max
          }
        }
      }
    }
  };
  return $.updateTree($.build().to(J).update(K));
}), FN1 = {
  dataId: j.Text(""),
  source: j.MappedStatic("x-ray", {
    em: j.Group({
      isoValue: Q1.createIsoValueParam(Q1.IsoValue.relative(1))
    }),
    "x-ray": j.Group({})
  })
};
var UN1 = B2.BuiltIn({
  name: "create-volume-streaming-info",
  display: { name: "Volume Streaming Info" },
  from: D0.Molecule.Structure,
  to: P_,
  params(Z) {
    return {
      serverUrl: j.Text("https://ds.litemol.org"),
      entries: j.ObjectList(FN1, ({ dataId: J }) => J, {
        defaultValue: [{ dataId: "", source: { name: "x-ray", params: {} } }]
      })
    };
  }
})({
  apply: ({ a: Z, params: J }, $) => n0.create("", async (X) => {
    let Y = [];
    for (let W = 0, K = J.entries.length;W < K; ++W) {
      let G = J.entries[W], H = G.dataId, N = G.source.name === "em" ? G.source.params.isoValue : Q1.IsoValue.relative(1);
      await X.update("Getting server header...");
      let q = await $.fetch({ url: HR(J.serverUrl, `${G.source.name}/${H.toLocaleLowerCase()}`), type: "json" }).runInContext(X);
      Y.push({
        dataId: H,
        kind: G.source.name,
        header: q,
        emDefaultContourLevel: N
      });
    }
    let Q = {
      serverUrl: J.serverUrl,
      entries: Y,
      structure: Z.data
    };
    return new P_(Q, { label: "Volume Server", description: `${Y.map((W) => W.dataId).join(", ")}` });
  })
});
var oV = B2.BuiltIn({
  name: "create-volume-streaming-behavior",
  display: { name: "Volume Streaming Behavior" },
  from: P_,
  to: y$,
  params(Z) {
    return y$.createParams({ data: Z && Z.data });
  }
})({
  canAutoUpdate: ({ oldParams: Z, newParams: J }) => {
    return Z.entry.params.view === J.entry.params.view || J.entry.params.view.name === "selection-box" || J.entry.params.view.name === "camera-target" || J.entry.params.view.name === "off";
  },
  apply: ({ a: Z, params: J }, $) => n0.create("Volume streaming", async (X) => {
    let Y = new y$.Behavior($, Z.data);
    return await Y.update(J), new y$(Y, { label: "Volume Streaming", description: Y.getDescription() });
  }),
  update({ a: Z, b: J, oldParams: $, newParams: X }) {
    return n0.create("Update Volume Streaming", async (Y) => {
      if ($.entry.name !== X.entry.name) {
        if ("em" in X.entry.params.channels) {
          let { emDefaultContourLevel: W } = J.data.infoMap.get(X.entry.name);
          if (W)
            X.entry.params.channels.em.isoValue = W;
        }
      }
      let Q = await J.data.update(X) ? T1.UpdateResult.Updated : T1.UpdateResult.Unchanged;
      return J.description = J.data.getDescription(), Q;
    });
  }
});
var Zx = B2.BuiltIn({
  name: "create-volume-streaming-visual",
  display: { name: "Volume Streaming Visual" },
  from: y$,
  to: D0.Volume.Representation3D,
  params: {
    channel: j.Select("em", y$.ChannelTypeOptions, { isHidden: !0 })
  }
})({
  apply: ({ a: Z, params: J, spine: $ }, X) => n0.create("Volume Representation", async (Y) => {
    var Q, W;
    let K = Z.data.channels[J.channel];
    if (!K)
      return LZ.Null;
    let G = Zw0(Z.data, J.channel), H = sR.BuiltIn.isosurface, N = G.type.params || {}, q = H.factory({ webgl: (Q = X.canvas3d) === null || Q === void 0 ? void 0 : Q.webgl, ...X.representation.volume.themes }, H.getParams);
    q.setTheme(Q7.create(X.representation.volume.themes, { volume: K.data }, G));
    let U = (W = $.getAncestorOfType(D0.Molecule.Structure)) === null || W === void 0 ? void 0 : W.data, F = (U === null || U === void 0 ? void 0 : U.models.length) === 0 ? void 0 : dN.get(U === null || U === void 0 ? void 0 : U.models[0]);
    if (await q.createOrUpdate(N, K.data).runInContext(Y), F)
      q.setState({ transform: F });
    return new D0.Volume.Representation3D({ repr: q, sourceData: K.data }, { label: `${Math.round(K.isoValue.relativeValue * 100) / 100} σ [${J.channel}]` });
  }),
  update: ({ a: Z, b: J, newParams: $, spine: X }, Y) => n0.create("Volume Representation", async (Q) => {
    let W = Z.data.channels[$.channel];
    if (!W)
      return T1.UpdateResult.Unchanged;
    let K = J.data.repr.state.visible, G = Zw0(Z.data, $.channel), H = { ...J.data.repr.props, ...G.type.params };
    return J.data.repr.setTheme(Q7.create(Y.representation.volume.themes, { volume: W.data }, G)), await J.data.repr.createOrUpdate(H, W.data).runInContext(Q), J.data.repr.setState({ visible: K }), J.data.sourceData = W.data, T1.UpdateResult.Updated;
  })
});
function Zw0(Z, J) {
  let $ = Z.channels[J];
  return l3.getDefaultParamsStatic(Z.plugin, "isosurface", { isoValue: $.isoValue, alpha: $.opacity, visuals: $.wireframe ? ["wireframe"] : ["solid"] }, "uniform", { value: $.color });
}

// node_modules/molstar/lib/mol-plugin-state/animation/model.js
var RQ;
(function(Z) {
  function J(X) {
    return X;
  }
  Z.create = J;
  function $(X, Y) {
    var Q, W;
    if (Y.customDurationMs)
      return Y.customDurationMs;
    let K = (W = (Q = Y.definition).getDuration) === null || W === void 0 ? void 0 : W.call(Q, Y.params, X);
    if ((K === null || K === void 0 ? void 0 : K.kind) === "fixed")
      return K.durationMs;
  }
  Z.getDuration = $;
})(RQ || (RQ = {}));

// node_modules/molstar/lib/mol-plugin-state/animation/built-in/assembly-unwind.js
var $w0 = RQ.create({
  name: "built-in.animate-assembly-unwind",
  display: { name: "Unwind Assembly" },
  isExportable: !0,
  params: (Z) => {
    let J = [["all", "All"]], $ = Z.state.data.select(f2.Generators.rootsOfType(D0.Molecule.Structure));
    for (let X of $)
      J.push([X.transform.ref, X.obj.data.models[0].label]);
    return {
      durationInMs: j.Numeric(3000, { min: 100, max: 1e4, step: 100 }),
      playOnce: j.Boolean(!1),
      target: j.Select(J[0][0], J)
    };
  },
  canApply(Z) {
    let J = Z.state.data, $ = D8.RootRef;
    return { canApply: J.select(f2.Generators.ofType(D0.Molecule.Structure.Representation3D, $)).length > 0 };
  },
  getDuration: (Z) => {
    return {
      kind: "fixed",
      durationMs: Z.durationInMs
    };
  },
  initialState: () => ({ t: 0 }),
  setup(Z, J, $) {
    let X = $.state.data, Y = !Z.target || Z.target === "all" ? D8.RootRef : Z.target, Q = X.select(f2.Generators.ofType(D0.Molecule.Structure.Representation3D, Y)), W = X.build(), K = !1;
    for (let G of Q) {
      if (X.select(f2.Generators.ofTransformer(H1.Representation.UnwindStructureAssemblyRepresentation3D, G.transform.ref)).length > 0)
        continue;
      K = !0, W.to(G).apply(H1.Representation.UnwindStructureAssemblyRepresentation3D, { t: 0 }, { tags: "animate-assembly-unwind" });
    }
    if (!K)
      return;
    return W.commit({ doNotUpdateCurrent: !0 });
  },
  teardown(Z, J, $) {
    let X = $.state.data, Y = X.select(f2.Generators.ofType(D0.Molecule.Structure.Representation3DState).withTag("animate-assembly-unwind"));
    if (Y.length === 0)
      return;
    let Q = X.build();
    for (let W of Y)
      Q.delete(W.transform.ref);
    return Q.commit();
  },
  async apply(Z, J, $) {
    let X = $.plugin.state.data, Y = !$.params.target || $.params.target === "all" ? D8.RootRef : $.params.target, Q = X.select(f2.Generators.ofTransformer(H1.Representation.UnwindStructureAssemblyRepresentation3D, Y));
    if (Q.length === 0)
      return { kind: "finished" };
    let W = X.build(), K = (J.current - J.lastApplied) / $.params.durationInMs, G = Z.t + K, H = !1;
    if ($.params.playOnce && G >= 1)
      H = !0, G = 1;
    else
      G = G % 1;
    for (let N of Q)
      W.to(N).update({ t: G });
    if (await h1.State.Update($.plugin, { state: X, tree: W, options: { doNotLogTiming: !0 } }), H)
      return { kind: "finished" };
    return { kind: "next", state: { t: G } };
  }
});

// node_modules/molstar/lib/mol-plugin-state/animation/built-in/camera-spin.js
var Jx = M(), Xw0 = M(), Yw0 = k8(), Qw0 = RQ.create({
  name: "built-in.animate-camera-spin",
  display: { name: "Camera Spin", description: "Spin the 3D scene around the x-axis in view space" },
  isExportable: !0,
  params: () => ({
    durationInMs: j.Numeric(4000, { min: 100, max: 20000, step: 100 }),
    speed: j.Numeric(1, { min: 1, max: 10, step: 1 }, { description: "How many times to spin in the specified duration." }),
    direction: j.Select("cw", [["cw", "Clockwise"], ["ccw", "Counter Clockwise"]], { cycle: !0 })
  }),
  initialState: (Z, J) => {
    var $;
    return { snapshot: ($ = J.canvas3d) === null || $ === void 0 ? void 0 : $.camera.getSnapshot() };
  },
  getDuration: (Z) => ({ kind: "fixed", durationMs: Z.durationInMs }),
  teardown: (Z, J, $) => {
    var X;
    (X = $.canvas3d) === null || X === void 0 || X.requestCameraReset({ snapshot: J.snapshot, durationMs: 0 });
  },
  async apply(Z, J, $) {
    var X, Y;
    if (J.current === 0)
      return { kind: "next", state: Z };
    let Q = Z.snapshot;
    if (Q.radiusMax < 0.0001)
      return { kind: "finished" };
    let W = J.animation ? ((X = J.animation) === null || X === void 0 ? void 0 : X.currentFrame) / (J.animation.frameCount + 1) : x8(J.current / $.params.durationInMs, 0, 1), K = 2 * Math.PI * W * $.params.speed * ($.params.direction === "ccw" ? -1 : 1);
    M.sub(Jx, Q.position, Q.target), M.normalize(Xw0, Q.up), k8.setAxisAngle(Yw0, Xw0, K), M.transformQuat(Jx, Jx, Yw0);
    let G = M.add(M(), Q.target, Jx);
    if ((Y = $.plugin.canvas3d) === null || Y === void 0 || Y.requestCameraReset({ snapshot: { ...Q, position: G }, durationMs: 0 }), W >= 0.99999)
      return { kind: "finished" };
    return { kind: "next", state: Z };
  }
});

// node_modules/molstar/lib/mol-plugin-state/animation/built-in/model-index.js
var Ww0 = RQ.create({
  name: "built-in.animate-model-index",
  display: { name: "Animate Trajectory" },
  isExportable: !0,
  params: () => ({
    mode: j.MappedStatic("loop", {
      palindrome: j.Group({}),
      loop: j.Group({ direction: j.Select("forward", [["forward", "Forward"], ["backward", "Backward"]]) }),
      once: j.Group({ direction: j.Select("forward", [["forward", "Forward"], ["backward", "Backward"]]) }, { isFlat: !0 })
    }, { options: [["palindrome", "Palindrome"], ["loop", "Loop"], ["once", "Once"]] }),
    duration: j.MappedStatic("fixed", {
      fixed: j.Group({
        durationInS: j.Numeric(5, { min: 1, max: 120, step: 0.1 }, { description: "Duration in seconds" })
      }, { isFlat: !0 }),
      computed: j.Group({
        targetFps: j.Numeric(30, { min: 5, max: 250, step: 1 }, { label: "Target FPS" })
      }, { isFlat: !0 }),
      sequential: j.Group({
        maxFps: j.Numeric(30, { min: 5, max: 60, step: 1 })
      }, { isFlat: !0 })
    })
  }),
  canApply(Z) {
    let J = Z.state.data, $ = J.select(f2.Generators.ofTransformer(H1.Model.ModelFromTrajectory));
    for (let X of $) {
      let Y = f2.findAncestorOfType(J.tree, J.cells, X.transform.ref, D0.Molecule.Trajectory);
      if (Y && Y.obj && Y.obj.data.frameCount > 1)
        return { canApply: !0 };
    }
    return { canApply: !1, reason: "No trajectory to animate" };
  },
  getDuration: (Z, J) => {
    var $;
    if ((($ = Z.duration) === null || $ === void 0 ? void 0 : $.name) === "fixed")
      return { kind: "fixed", durationMs: Z.duration.params.durationInS * 1000 };
    else if (Z.duration.name === "computed") {
      let X = J.state.data, Y = X.select(f2.Generators.ofTransformer(H1.Model.ModelFromTrajectory)), Q = 0;
      for (let W of Y) {
        let K = f2.findAncestorOfType(X.tree, X.cells, W.transform.ref, D0.Molecule.Trajectory);
        if (!K || !K.obj)
          continue;
        let G = K.obj;
        Q = Math.max(Math.ceil(1000 * G.data.frameCount / Z.duration.params.targetFps), Q);
      }
      return { kind: "fixed", durationMs: Q };
    }
    return { kind: "unknown" };
  },
  initialState: () => ({}),
  async apply(Z, J, $) {
    if ($.params.duration.name === "sequential" && J.current > 0 && J.current - J.lastApplied < 1000 / $.params.duration.params.maxFps)
      return { kind: "skip" };
    let X = $.plugin.state.data, Y = X.select(f2.Generators.ofTransformer(H1.Model.ModelFromTrajectory));
    if (Y.length === 0)
      return { kind: "finished" };
    let Q = X.build(), W = $.params, K = Z.palindromeDirections || {}, G = !1, H = !0;
    for (let N of Y) {
      let q = f2.findAncestorOfType(X.tree, X.cells, N.transform.ref, D0.Molecule.Trajectory);
      if (!q || !q.obj)
        continue;
      let U = q.obj;
      if (U.data.frameCount <= 1)
        continue;
      Q.to(N).update((F) => {
        let E = U.data.frameCount;
        if (E !== 1)
          H = !1;
        else
          return F;
        if (W.duration.name === "sequential") {
          let R = 1;
          if (W.mode.name === "once") {
            if (R = W.mode.params.direction === "backward" ? -1 : 1, R === -1 && F.modelIndex === 0 || R === 1 && F.modelIndex === E - 1)
              return G = !0, F;
          } else if (W.mode.name === "palindrome")
            if (F.modelIndex === 0)
              R = 1;
            else if (F.modelIndex === E - 1)
              R = -1;
            else
              R = K[N.transform.ref] || 1;
          K[N.transform.ref] = R;
          let z = (F.modelIndex + R) % E;
          if (z < 0)
            z += E;
          return G = G || R === -1 && z === 0 || R === 1 && z === E - 1, { modelIndex: z };
        } else {
          let R = W.duration.name === "fixed" ? W.duration.params.durationInS * 1000 : Math.ceil(1000 * U.data.frameCount / W.duration.params.targetFps);
          if (W.mode.name === "once" && J.current >= R)
            return G = !0, { modelIndex: U.data.frameCount - 1 };
          let z = J.current % R / R;
          if (W.mode.name === "loop") {
            if (W.mode.params.direction === "backward")
              z = 1 - z;
          }
          if (W.mode.name === "palindrome") {
            if (z = 2 * z, z > 1)
              z = 2 - z;
          }
          return { modelIndex: Math.min(Math.floor(U.data.frameCount * z), U.data.frameCount - 1) };
        }
      });
    }
    if (!H)
      await h1.State.Update($.plugin, { state: X, tree: Q, options: { doNotLogTiming: !0 } });
    if (H || W.mode.name === "once" && G)
      return { kind: "finished" };
    if (W.mode.name === "palindrome")
      return { kind: "next", state: { palindromeDirections: K } };
    return { kind: "next", state: {} };
  }
});

// node_modules/molstar/lib/mol-canvas3d/camera/util.js
function bZ() {
  return bZ.zero();
}
(function(Z) {
  function J() {
    return { x: 0, y: 0, width: 0, height: 0 };
  }
  Z.zero = J;
  function $(G, H, N, q) {
    return { x: G, y: H, width: N, height: q };
  }
  Z.create = $;
  function X(G) {
    return { ...G };
  }
  Z.clone = X;
  function Y(G, H) {
    return Object.assign(G, H);
  }
  Z.copy = Y;
  function Q(G, H, N, q, U) {
    return G.x = H, G.y = N, G.width = q, G.height = U, G;
  }
  Z.set = Q;
  function W(G, H) {
    return G[0] = H.x, G[1] = H.y, G[2] = H.width, G[3] = H.height, G;
  }
  Z.toVec4 = W;
  function K(G, H) {
    return G.x === H.x && G.y === H.y && G.width === H.width && G.height === H.height;
  }
  Z.equals = K;
})(bZ || (bZ = {}));
var Lq = E2();
function $x(Z, J, $, X) {
  let { x: Y, y: Q, width: W, height: K } = $;
  E2.set(Lq, J[0], J[1], J[2], 1), E2.transformMat4(Lq, Lq, X);
  let G = Lq[3];
  if (G !== 0)
    Lq[0] /= G, Lq[1] /= G, Lq[2] /= G;
  return Z[0] = (Lq[0] + 1) * W * 0.5 + Y, Z[1] = (Lq[1] + 1) * K * 0.5 + Q, Z[2] = (Lq[2] + 1) * 0.5, Z[3] = G === 0 ? 0 : 1 / G, Z;
}
function Rq(Z, J, $, X) {
  let { x: Y, y: Q, width: W, height: K } = $, G = J[0] - Y, H = J[1] - Q, N = J[2];
  return Z[0] = 2 * G / W - 1, Z[1] = 2 * H / K - 1, Z[2] = 2 * N - 1, M.transformMat4(Z, Z, X);
}

// node_modules/molstar/lib/mol-util/input/input-observer.js
function gz(Z) {
  if (typeof Z === "object") {
    if ("buttons" in Z)
      return Z.buttons;
    else if ("which" in Z) {
      let J = Z.which;
      if (J === 2)
        return 4;
      else if (J === 3)
        return 2;
      else if (J > 0)
        return 1 << J - 1;
    }
  }
  return 0;
}
function oA(Z) {
  if (typeof Z === "object") {
    if ("button" in Z) {
      let J = Z.button;
      if (J === 1)
        return 4;
      else if (J === 2)
        return 2;
      else if (J >= 0)
        return 1 << J;
    }
  }
  return 0;
}
function Yx(Z) {
  return {
    alt: "altKey" in Z ? Z.altKey : !1,
    shift: "shiftKey" in Z ? Z.shiftKey : !1,
    control: "ctrlKey" in Z ? Z.ctrlKey : !1,
    meta: "metaKey" in Z ? Z.metaKey : !1
  };
}
var Kw0 = {
  noScroll: !0,
  noMiddleClickScroll: !0,
  noContextMenu: !0,
  noPinchZoom: !0,
  noTextSelect: !0,
  preventGestures: !1,
  mask: (Z, J) => !0,
  pixelScale: 1
}, hJ;
(function(Z) {
  Z.None = Y();
  function J(Q, W) {
    return Q.shift === W.shift && Q.alt === W.alt && Q.control === W.control && Q.meta === W.meta;
  }
  Z.areEqual = J;
  function $(Q) {
    return J(Q, Z.None);
  }
  Z.areNone = $;
  function X(Q) {
    if (!Q)
      return 0;
    let W = 0;
    if (Q.shift)
      W++;
    if (Q.alt)
      W++;
    if (Q.control)
      W++;
    if (Q.meta)
      W++;
    return W;
  }
  Z.size = X;
  function Y(Q = {}) {
    return {
      shift: !!Q.shift,
      alt: !!Q.alt,
      control: !!Q.control,
      meta: !!Q.meta
    };
  }
  Z.create = Y;
})(hJ || (hJ = {}));
var V8;
(function(Z) {
  Z.has = r7.has, Z.create = r7.create;
  let J;
  (function($) {
    $[$.None = 0] = "None", $[$.Primary = 1] = "Primary", $[$.Secondary = 2] = "Secondary", $[$.Auxilary = 4] = "Auxilary", $[$.Forth = 8] = "Forth", $[$.Five = 16] = "Five", $[$.Trigger = 32] = "Trigger", $[$.Squeeze = 48] = "Squeeze";
  })(J = Z.Flag || (Z.Flag = {}));
})(V8 || (V8 = {}));
var Le = {
  key: "",
  code: "",
  modifiers: hJ.None,
  x: -1,
  y: -1,
  pageX: -1,
  pageY: -1,
  preventDefault: xX
}, aR;
(function(Z) {
  Z[Z.Stopped = 0] = "Stopped", Z[Z.Started = 1] = "Started", Z[Z.Moving = 2] = "Moving";
})(aR || (aR = {}));
function Gw0() {
  return {
    drag: new P6,
    interactionEnd: new P6,
    click: new P6,
    move: new P6,
    wheel: new P6,
    pinch: new P6,
    gesture: new P6,
    resize: new P6,
    leave: new P6,
    enter: new P6,
    modifiers: new P6,
    key: new P6,
    keyUp: new P6,
    keyDown: new P6,
    lock: new P6,
    trackedPointers: new P6
  };
}
var LN1 = ["Backspace", "Delete"], Xx;
(function(Z) {
  function J(X = {}) {
    let { noScroll: Y, noContextMenu: Q } = { ...Kw0, ...X };
    return {
      noScroll: Y,
      noContextMenu: Q,
      pointerLock: !1,
      width: 0,
      height: 0,
      pixelRatio: 1,
      ...Gw0(),
      setPixelScale: xX,
      updateTrackedPointers: xX,
      updateScreenTouches: xX,
      requestPointerLock: xX,
      exitPointerLock: xX,
      dispose: xX
    };
  }
  Z.create = J;
  function $(X, Y = {}) {
    let { noScroll: Q, noMiddleClickScroll: W, noContextMenu: K, noPinchZoom: G, noTextSelect: H, mask: N, pixelScale: q, preventGestures: U } = { ...Kw0, ...Y }, F = X.clientWidth * I(), E = X.clientHeight * I(), R = !1, z = bZ(), D = h0(), A = h0(), B = h0(), T = h0(), w = h0(), V = {
      shift: !1,
      alt: !1,
      control: !1,
      meta: !1
    }, P = {
      x: -1,
      y: -1,
      pageX: -1,
      pageY: -1
    };
    function I() {
      return window.devicePixelRatio * q;
    }
    function S() {
      return { ...V };
    }
    function f(d0) {
      return d0.target === document.body || d0.target === X;
    }
    let v = aR.Stopped, h = !1, x = V8.create(V8.Flag.None), b = V8.Flag.None, g = !1, m = !1, i;
    if (typeof window.ResizeObserver !== "undefined")
      i = new window.ResizeObserver(W2);
    let r = Gw0(), { drag: Y0, interactionEnd: c, wheel: n, pinch: l, gesture: u, click: G0, move: F0, leave: t, enter: Z0, resize: U0, modifiers: a, key: Q0, keyUp: $0, keyDown: R0, lock: X0, trackedPointers: E0 } = r;
    V0();
    function V0() {
      if (X.addEventListener("contextmenu", A0, !1), X.addEventListener("wheel", N2, !1), X.addEventListener("mousedown", L8, !1), window.addEventListener("mousemove", R8, !1), window.addEventListener("mouseup", w0, !1), X.addEventListener("touchstart", O8, !1), X.addEventListener("touchmove", z6, !1), X.addEventListener("touchend", n8, !1), X.addEventListener("gesturechange", d8, !1), X.addEventListener("gesturestart", g1, !1), X.addEventListener("gestureend", I1, !1), window.addEventListener("blur", a0), window.addEventListener("keyup", Y1, !1), window.addEventListener("keydown", D1, !1), window.addEventListener("keypress", u1, !1), document.addEventListener("pointerlockchange", N0, !1), document.addEventListener("pointerlockerror", q0, !1), i != null)
        i.observe(X.parentElement);
      else
        window.addEventListener("resize", W2, !1);
    }
    function u0() {
      if (h)
        return;
      if (h = !0, X.removeEventListener("contextmenu", A0, !1), X.removeEventListener("wheel", N2, !1), X.removeEventListener("mousedown", L8, !1), window.removeEventListener("mousemove", R8, !1), window.removeEventListener("mouseup", w0, !1), X.removeEventListener("touchstart", O8, !1), X.removeEventListener("touchmove", z6, !1), X.removeEventListener("touchend", n8, !1), X.removeEventListener("gesturechange", d8, !1), X.removeEventListener("gesturestart", g1, !1), X.removeEventListener("gestureend", I1, !1), window.removeEventListener("blur", a0), window.removeEventListener("keyup", Y1, !1), window.removeEventListener("keydown", D1, !1), window.removeEventListener("keypress", u1, !1), document.removeEventListener("pointerlockchange", N0, !1), document.removeEventListener("pointerlockerror", q0, !1), L1.remove(), i != null)
        i.unobserve(X.parentElement), i.disconnect();
      else
        window.removeEventListener("resize", W2, !1);
    }
    function N0() {
      if (X.ownerDocument.pointerLockElement === X)
        R = !0;
      else
        R = !1;
      s2(R), X0.next(R);
    }
    function q0() {
      console.error("Unable to use Pointer Lock API"), R = !1, s2(R), X0.next(R);
    }
    function A0(d0) {
      if (!N(d0.clientX, d0.clientY))
        return;
      if (K)
        d0.preventDefault();
    }
    function S0(d0) {
      V.alt = d0.altKey, V.shift = d0.shiftKey, V.control = d0.ctrlKey, V.meta = d0.metaKey;
    }
    function a0() {
      if (x || V.shift || V.alt || V.meta || V.control)
        x = 0, V.shift = V.alt = V.control = V.meta = !1;
    }
    function D1(d0) {
      let d1 = !1;
      if (!V.alt && d0.altKey)
        d1 = !0, V.alt = !0;
      if (!V.shift && d0.shiftKey)
        d1 = !0, V.shift = !0;
      if (!V.control && d0.ctrlKey)
        d1 = !0, V.control = !0;
      if (!V.meta && d0.metaKey)
        d1 = !0, V.meta = !0;
      if (d1 && g)
        a.next(S());
      if (f(d0) && g)
        R0.next({
          key: d0.key,
          code: d0.code,
          modifiers: S(),
          ...P,
          preventDefault: () => d0.preventDefault()
        });
    }
    function Y1(d0) {
      let d1 = !1;
      if (V.alt && !d0.altKey)
        d1 = !0, V.alt = !1;
      if (V.shift && !d0.shiftKey)
        d1 = !0, V.shift = !1;
      if (V.control && !d0.ctrlKey)
        d1 = !0, V.control = !1;
      if (V.meta && !d0.metaKey)
        d1 = !0, V.meta = !1;
      if (d1 && g)
        a.next(S());
      if (LN1.includes(d0.key))
        u1(d0);
      if (f(d0) && g)
        $0.next({
          key: d0.key,
          code: d0.code,
          modifiers: S(),
          ...P,
          preventDefault: () => d0.preventDefault()
        });
    }
    function u1(d0) {
      if (!f(d0) || !g)
        return;
      Q0.next({
        key: d0.key,
        code: d0.code,
        modifiers: S(),
        ...P,
        preventDefault: () => d0.preventDefault()
      });
    }
    let b0 = {
      primary: { prev: void 0, down: h0(), end: h0(), axes: [] },
      secondary: { prev: void 0, down: h0(), end: h0(), axes: [] },
      distance: -1
    };
    function x0(d0, d1, A2) {
      let B8 = V8.has(d1, d0);
      return (A2 ? V8.has(A2, d0) : !1) && !B8;
    }
    function m0(d0, d1) {
      let { x: A2, y: B8, dx: Z6, dy: t6, ray: D2, buttons: vZ, axes: c6 } = d0, [HZ, pY] = [A2, B8], GW = hJ.create(), lH = !0, MJ = d1 ? b0.secondary : b0.primary, { prev: q7 } = MJ;
      if (vZ === V8.Flag.Secondary)
        F0.next({ x: A2, y: B8, pageX: HZ, pageY: pY, buttons: V8.Flag.None, button: V8.Flag.None, modifiers: GW, inside: !0, onElement: !0, ray: D2 });
      else if ((q7 === null || q7 === void 0 ? void 0 : q7.buttons) === V8.Flag.Secondary)
        t.next(void 0);
      let BX = V8.has(vZ, V8.Flag.Primary), wX = q7 ? V8.has(q7.buttons, V8.Flag.Primary) : !1;
      if (wX && !BX) {
        if (h0.set(MJ.end, A2, B8), h0.distance(MJ.end, MJ.down) < 20)
          G0.next({ x: A2, y: B8, pageX: HZ, pageY: pY, buttons: V8.Flag.Trigger, button: V8.Flag.Trigger, modifiers: GW, ray: D2 });
        c.next(void 0);
      }
      if (BX) {
        let v0 = !wX;
        if (Y0.next({ x: A2, y: B8, dx: Z6, dy: t6, pageX: HZ, pageY: pY, buttons: V8.Flag.Trigger, button: V8.Flag.Trigger, modifiers: GW, isStart: v0, useDelta: !0 }), v0)
          h0.set(MJ.down, A2, B8);
      }
      let v7 = { x: 0, y: 0, pageX: 0, pageY: 0, modifiers: GW, preventDefault: () => {} };
      if (x0(V8.Flag.Forth, vZ, q7 === null || q7 === void 0 ? void 0 : q7.buttons)) {
        let v0 = d1 ? "GamepadX" : "GamepadA";
        $0.next({ ...v7, code: v0, key: v0 });
      }
      if (x0(V8.Flag.Five, vZ, q7 === null || q7 === void 0 ? void 0 : q7.buttons)) {
        let v0 = d1 ? "GamepadY" : "GamepadB";
        $0.next({ ...v7, code: v0, key: v0 });
      }
      if (c6) {
        if (c6[2] < 0)
          R0.next({ ...v7, code: "GamepadLeft", key: "GamepadLeft" }), $0.next({ ...v7, code: "GamepadRight", key: "GamepadRight" });
        else if (c6[2] > 0)
          R0.next({ ...v7, code: "GamepadRight", key: "GamepadRight" }), $0.next({ ...v7, code: "GamepadLeft", key: "GamepadLeft" });
        else if (c6[2] !== MJ.axes[2])
          $0.next({ ...v7, code: "GamepadLeft", key: "GamepadLeft" }), $0.next({ ...v7, code: "GamepadRight", key: "GamepadRight" });
        if (c6[3] < 0)
          R0.next({ ...v7, code: "GamepadUp", key: "GamepadUp" }), $0.next({ ...v7, code: "GamepadDown", key: "GamepadDown" });
        else if (c6[3] > 0)
          R0.next({ ...v7, code: "GamepadDown", key: "GamepadDown" }), $0.next({ ...v7, code: "GamepadUp", key: "GamepadUp" });
        else if (c6[3] !== MJ.axes[3])
          $0.next({ ...v7, code: "GamepadUp", key: "GamepadUp" }), $0.next({ ...v7, code: "GamepadDown", key: "GamepadDown" });
      }
      MJ.axes = c6 || [], MJ.prev = d0;
    }
    function e0(d0, d1, A2) {
      let B8 = M.distance(d0.ray.origin, d1.ray.origin);
      if (b0.distance > 0) {
        let Z6 = B8 / b0.distance;
        u.next({
          scale: Z6,
          rotation: 0,
          deltaScale: 0,
          deltaRotation: 0,
          buttons: A2,
          button: A2,
          modifiers: S()
        });
      }
      b0.distance = B8;
    }
    function p(d0) {
      let d1, A2;
      for (let B8 of d0)
        if (B8.handedness === "right")
          d1 = B8;
        else if (B8.handedness === "left")
          A2 = B8;
      if (!d1 && A2)
        d1 = A2, A2 = void 0;
      if ((d1 === null || d1 === void 0 ? void 0 : d1.buttons) === V8.Flag.Primary && (A2 === null || A2 === void 0 ? void 0 : A2.buttons) === V8.Flag.Primary)
        e0(d1, A2, V8.Flag.Trigger);
      else if ((d1 === null || d1 === void 0 ? void 0 : d1.buttons) === V8.Flag.Secondary && (A2 === null || A2 === void 0 ? void 0 : A2.buttons) === V8.Flag.Secondary)
        e0(d1, A2, V8.Flag.Squeeze);
      else {
        if (b0.distance === -1) {
          if (d1)
            m0(d1, !1);
          if (A2)
            m0(A2, !0);
        }
        if (!(d1 === null || d1 === void 0 ? void 0 : d1.buttons) && !(A2 === null || A2 === void 0 ? void 0 : A2.buttons))
          b0.distance = -1;
      }
    }
    let J0 = void 0, T0 = void 0, o0 = -1;
    function y0(d0) {
      if (d0.length === 2) {
        let MJ = h0.fromObj(d0[0]), q7 = h0.fromObj(d0[1]), BX = h0.distance(MJ, q7), wX = V8.Flag.Trigger;
        if (o0 > 0) {
          let v7 = BX / o0;
          u.next({
            scale: v7,
            rotation: 0,
            deltaScale: 0,
            deltaRotation: 0,
            buttons: wX,
            button: wX,
            modifiers: S()
          });
        }
        o0 = BX, J0 = void 0;
        return;
      }
      o0 = -1;
      let d1 = d0[0];
      if (!d1) {
        if (T0 && J0) {
          let MJ = h0.fromObj(T0), q7 = h0.fromObj(J0);
          if (h0.distance(MJ, q7) < 10) {
            let [BX, wX] = MJ, [v7, v0] = [BX, wX], E1 = hJ.create(), c1 = V8.Flag.Trigger, { ray: L2 } = T0;
            G0.next({ x: BX, y: wX, pageX: v7, pageY: v0, buttons: c1, button: c1, modifiers: E1, ray: L2 });
          }
          c.next(void 0);
        }
        J0 = void 0, T0 = void 0;
        return;
      }
      let A2 = h0.fromObj(d1), [B8, Z6] = A2, [t6, D2] = [B8, Z6], vZ = hJ.create(), c6 = V8.Flag.Trigger, HZ = !0, pY = J0 === void 0, GW = J0 ? B8 - J0.x : 0, lH = J0 ? Z6 - J0.y : 0;
      if (J0 = d1, pY)
        T0 = d1;
      Y0.next({ x: B8, y: Z6, dx: GW, dy: lH, pageX: t6, pageY: D2, buttons: c6, button: c6, modifiers: vZ, isStart: pY, useDelta: HZ });
    }
    function $1(d0) {
      let d1 = d0.touches[0], A2 = d0.touches[1];
      return {
        clientX: (d1.clientX + A2.clientX) / 2,
        clientY: (d1.clientY + A2.clientY) / 2,
        pageX: (d1.pageX + A2.pageX) / 2,
        pageY: (d1.pageY + A2.pageY) / 2,
        target: d0.target
      };
    }
    function F1(d0) {
      let d1 = d0.touches[0].pageX - d0.touches[1].pageX, A2 = d0.touches[0].pageY - d0.touches[1].pageY;
      return Math.sqrt(d1 * d1 + A2 * A2);
    }
    let A1 = -1, P1 = void 0, S1 = h0(), _1 = h0();
    function a1(d0) {
      if (A1 < 0)
        return;
      h0.set(_1, d0.touches[0].pageX, d0.touches[0].pageY), A1 += h0.distance(S1, _1), h0.copy(S1, _1);
    }
    let U2 = h0(), G2 = !1, P2 = 0, v2 = 1;
    function O8(d0) {
      if (d0.preventDefault(), P1 = void 0, A1 = -1, d0.touches.length === 1)
        x = b = V8.Flag.Primary, A1 = 0, h0.set(S1, d0.touches[0].pageX, d0.touches[0].pageY), P1 = d0.touches[0], l0(d0.touches[0]), h0.copy(U2, A), G2 = !0;
      else if (d0.touches.length === 2) {
        x = V8.Flag.Secondary | V8.Flag.Auxilary, b = V8.Flag.Secondary, S0(d0), v2 = 1, P2 = F1(d0);
        let { pageX: d1, pageY: A2 } = v6($1(d0));
        if (!G2)
          W6(U2, $1(d0)), G2 = !0;
        l.next({
          isStart: !0,
          distance: P2,
          delta: 0,
          fraction: v2,
          fractionDelta: 0,
          startX: U2[0],
          startY: U2[1],
          centerPageX: d1,
          centerPageY: A2,
          buttons: x,
          button: b,
          modifiers: S()
        });
      } else if (d0.touches.length === 3)
        x = b = V8.Flag.Forth, l0($1(d0));
    }
    function n8(d0) {
      if (P0(), P1 && A1 <= 4) {
        let d1 = P1;
        if (!N(d1.clientX, d1.clientY))
          return;
        W6(_1, d1);
        let { pageX: A2, pageY: B8 } = v6(d1), [Z6, t6] = _1;
        G0.next({ x: Z6, y: t6, pageX: A2, pageY: B8, buttons: x, button: b, modifiers: S() });
      }
      P1 = void 0, G2 = !1;
    }
    function z6(d0) {
      if (b = V8.Flag.None, G) {
        if (d0.preventDefault(), d0.stopPropagation(), d0.originalEvent)
          d0.originalEvent.preventDefault(), d0.originalEvent.stopPropagation();
      }
      if (P1 = void 0, d0.touches.length === 1)
        x = V8.Flag.Primary, P1 = d0.touches[0], a1(d0), J2(d0.touches[0]);
      else if (d0.touches.length === 2) {
        x = V8.Flag.Secondary | V8.Flag.Auxilary, b = V8.Flag.Secondary, S0(d0);
        let { pageX: d1, pageY: A2 } = v6($1(d0)), B8 = F1(d0), Z6 = P2 - B8, t6 = P2 / B8, D2 = t6 - v2;
        v2 = t6, l.next({
          isStart: !1,
          distance: B8,
          delta: Z6,
          fraction: t6,
          fractionDelta: D2,
          startX: U2[0],
          startY: U2[1],
          centerPageX: d1,
          centerPageY: A2,
          buttons: x,
          button: b,
          modifiers: S()
        });
      } else if (d0.touches.length === 3)
        x = V8.Flag.Forth, J2($1(d0));
    }
    function L8(d0) {
      if (S0(d0), x = gz(d0), b = oA(d0), W && x === V8.Flag.Auxilary)
        d0.preventDefault;
      l0(d0);
    }
    function R8(d0) {
      S0(d0), x = gz(d0), b = V8.Flag.None, J2(d0);
    }
    function w0(d0) {
      S0(d0), x = gz(d0), b = oA(d0), z1(d0), P0();
    }
    function P0() {
      c.next(void 0);
    }
    function l0(d0) {
      if (!N(d0.clientX, d0.clientY))
        return;
      if (W6(A, d0), h0.copy(D, A), z2(A))
        v = aR.Started;
    }
    function z1(d0) {
      if (v = aR.Stopped, !N(d0.clientX, d0.clientY))
        return;
      if (W6(B, d0), !m && h0.distance(B, D) < 4) {
        let { pageX: d1, pageY: A2 } = v6(d0), [B8, Z6] = B;
        G0.next({ x: B8, y: Z6, pageX: d1, pageY: A2, buttons: x, button: b, modifiers: S() });
      }
      m = !1;
    }
    function J2(d0) {
      var d1;
      W6(B, d0);
      let { pageX: A2, pageY: B8 } = v6(d0), [Z6, t6] = B, { movementX: D2, movementY: vZ } = d0, c6 = z2(B) && N(d0.clientX, d0.clientY);
      if (g && !c6)
        t.next(void 0);
      else if (!g && c6)
        Z0.next(void 0);
      if (g = c6, P.x = Z6, P.y = t6, P.pageX = A2, P.pageY = B8, F0.next({ x: Z6, y: t6, pageX: A2, pageY: B8, movementX: D2, movementY: vZ, buttons: x, button: b, modifiers: S(), inside: c6, onElement: d0.target === X }), v === aR.Stopped)
        return;
      if (H)
        (d1 = d0.preventDefault) === null || d1 === void 0 || d1.call(d0);
      if (h0.div(T, h0.sub(T, B, A), p8(w)), h0.magnitude(T) < u8)
        return;
      let HZ = v === aR.Started;
      if (HZ && !N(d0.clientX, d0.clientY))
        return;
      if (h0.distance(B, D) >= 4)
        m = !0;
      let [pY, GW] = T;
      Y0.next({ x: Z6, y: t6, dx: pY, dy: GW, pageX: A2, pageY: B8, buttons: x, button: b, modifiers: S(), isStart: HZ }), h0.copy(A, B), v = aR.Moving;
    }
    function N2(d0) {
      if (!N(d0.clientX, d0.clientY))
        return;
      W6(B, d0);
      let { pageX: d1, pageY: A2 } = v6(d0), [B8, Z6] = B;
      if (Q)
        d0.preventDefault();
      let t6 = Re(d0);
      if (x = b = V8.Flag.Auxilary, t6.dx || t6.dy || t6.dz)
        n.next({ x: B8, y: Z6, pageX: d1, pageY: A2, ...t6, buttons: x, button: b, modifiers: S() });
    }
    function X8(d0) {
      var d1, A2;
      if (!U)
        return;
      d0.preventDefault(), (d1 = d0.stopImmediatePropagation) === null || d1 === void 0 || d1.call(d0), (A2 = d0.stopPropagation) === null || A2 === void 0 || A2.call(d0);
    }
    let c0 = 0, M1 = 0;
    function g1(d0) {
      X8(d0), c0 = d0.scale, M1 = d0.rotation, u.next({ scale: d0.scale, rotation: d0.rotation, deltaRotation: 0, deltaScale: 0, isStart: !0, buttons: x, button: b, modifiers: S() });
    }
    function l2(d0, d1) {
      u.next({
        scale: d0.scale,
        rotation: d0.rotation,
        deltaRotation: M1 - d0.rotation,
        deltaScale: c0 - d0.scale,
        isEnd: d1,
        buttons: x,
        button: b,
        modifiers: S()
      }), M1 = d0.rotation, c0 = d0.scale;
    }
    function d8(d0) {
      X8(d0), l2(d0);
    }
    function I1(d0) {
      X8(d0), l2(d0, !0);
    }
    function W2() {
      F = X.clientWidth * I(), E = X.clientHeight * I(), U0.next({});
    }
    function z2(d0) {
      if (X instanceof Window || X instanceof Document || X === document.body)
        return !0;
      else {
        let d1 = X.getBoundingClientRect();
        return d0[0] >= 0 && d0[1] >= 0 && d0[0] < d1.width && d0[1] < d1.height;
      }
    }
    function p8(d0) {
      return d0[0] = X.clientWidth, d0[1] = X.clientHeight, d0;
    }
    function W6(d0, d1) {
      if (F = X.clientWidth * I(), E = X.clientHeight * I(), R) {
        let A2 = I();
        d0[0] = (z.x + z.width / 2) / A2, d0[1] = (E - (z.y + z.height / 2)) / A2;
      } else {
        let A2 = X.getBoundingClientRect();
        d0[0] = (d1.clientX || 0) - A2.left, d0[1] = (d1.clientY || 0) - A2.top;
      }
      return d0;
    }
    function v6(d0) {
      if (R)
        return {
          pageX: Math.round(window.innerWidth / 2) + z.x,
          pageY: Math.round(window.innerHeight / 2) + z.y
        };
      else
        return {
          pageX: d0.pageX,
          pageY: d0.pageY
        };
    }
    let AZ = 30, L1 = q2();
    function q2() {
      var d0;
      let d1 = document.createElement("div"), A2 = "30%", B8 = "10%", Z6 = "#000 30%, #0000 0 calc(100% - 30%), #000 0", t6 = "linear-gradient(0deg, #000 30%, #0000 0 calc(100% - 30%), #000 0) 50%/10% 100% no-repeat", D2 = "linear-gradient(90deg, #000 30%, #0000 0 calc(100% - 30%), #000 0) 50%/100% 10% no-repeat", vZ = "radial-gradient(circle at 50%, #000 5%, #0000 5%)";
      return Object.assign(d1.style, {
        width: `${AZ}px`,
        aspectRatio: 1,
        background: "linear-gradient(0deg, #000 30%, #0000 0 calc(100% - 30%), #000 0) 50%/10% 100% no-repeat, linear-gradient(90deg, #000 30%, #0000 0 calc(100% - 30%), #000 0) 50%/100% 10% no-repeat, radial-gradient(circle at 50%, #000 5%, #0000 5%)",
        display: "none",
        zIndex: 1000,
        position: "absolute",
        mixBlendMode: "difference",
        filter: "invert(1)"
      }), (d0 = X.parentElement) === null || d0 === void 0 || d0.appendChild(d1), d1;
    }
    function s2(d0) {
      if (L1.style.display = d0 ? "block" : "none", d0) {
        let d1 = I(), A2 = (z.x + z.width / 2) / d1, B8 = (z.y + z.height / 2) / d1;
        L1.style.width = `${AZ}px`, L1.style.left = `calc(${A2}px - ${AZ / 2}px)`, L1.style.bottom = `calc(${B8}px - ${AZ / 2}px)`;
      }
    }
    return {
      get noScroll() {
        return Q;
      },
      set noScroll(d0) {
        Q = d0;
      },
      get noContextMenu() {
        return K;
      },
      set noContextMenu(d0) {
        K = d0;
      },
      get width() {
        return F;
      },
      get height() {
        return E;
      },
      get pixelRatio() {
        return I();
      },
      get pointerLock() {
        return R;
      },
      ...r,
      setPixelScale: (d0) => {
        q = d0, F = X.clientWidth * I(), E = X.clientHeight * I();
      },
      updateTrackedPointers: (d0) => {
        p(d0), E0.next(d0);
      },
      updateScreenTouches: (d0) => {
        y0(d0);
      },
      requestPointerLock: (d0) => {
        if (z = d0, !R)
          X.requestPointerLock();
      },
      exitPointerLock: () => {
        if (R)
          X.ownerDocument.exitPointerLock();
      },
      dispose: u0
    };
  }
  Z.fromElement = $;
})(Xx || (Xx = {}));
function Re(Z) {
  let Y = 0, Q = 0, W = 0, K = 0, G = 0;
  if ("detail" in Z)
    Q = Z.detail;
  if ("wheelDelta" in Z)
    Q = -Z.wheelDelta / 120;
  if ("wheelDeltaY" in Z)
    Q = -Z.wheelDeltaY / 120;
  if ("wheelDeltaX" in Z)
    Y = -Z.wheelDeltaX / 120;
  if ("axis" in Z && Z.axis === Z.HORIZONTAL_AXIS)
    Y = Q, Q = 0;
  if (W = Y * 10, K = Q * 10, "deltaY" in Z)
    K = Z.deltaY;
  if ("deltaX" in Z)
    W = Z.deltaX;
  if ("deltaZ" in Z)
    G = Z.deltaZ;
  if ((W || K || G) && Z.deltaMode)
    if (Z.deltaMode === 1)
      W *= 40, K *= 40, G *= 40;
    else
      W *= 800, K *= 800, G *= 800;
  if (W && !Y)
    Y = W < 0 ? -1 : 1;
  if (K && !Q)
    Q = K < 0 ? -1 : 1;
  return { spinX: Y, spinY: Q, dx: W, dy: K, dz: G };
}

// node_modules/molstar/lib/mol-gl/renderer.js
var qU;
(function(Z) {
  Z[Z.None = 0] = "None", Z[Z.Object = 1] = "Object", Z[Z.Instance = 2] = "Instance", Z[Z.Group = 3] = "Group";
})(qU || (qU = {}));
var sV;
(function(Z) {
  Z[Z.None = 0] = "None", Z[Z.Depth = 1] = "Depth", Z[Z.Mask = 2] = "Mask";
})(sV || (sV = {}));
var aA = {
  backgroundColor: j.Color(i0(0), { description: "Background color of the 3D canvas" }),
  pickingAlphaThreshold: j.Numeric(0.5, { min: 0, max: 1, step: 0.01 }, { description: "The minimum opacity value needed for an object to be pickable." }),
  colorMarker: j.Boolean(!0, { description: "Enable color marker" }),
  highlightColor: j.Color(i0.fromNormalizedRgb(1, 0.4, 0.6)),
  selectColor: j.Color(i0.fromNormalizedRgb(0.2, 1, 0.1)),
  dimColor: j.Color(i0.fromNormalizedRgb(1, 1, 1)),
  highlightStrength: j.Numeric(0.3, { min: 0, max: 1, step: 0.1 }),
  selectStrength: j.Numeric(0.3, { min: 0, max: 1, step: 0.1 }),
  dimStrength: j.Numeric(0, { min: 0, max: 1, step: 0.1 }),
  markerPriority: j.Select(1, [[1, "Highlight"], [2, "Select"]]),
  xrayEdgeFalloff: j.Numeric(1, { min: 0, max: 3, step: 0.1 }),
  celSteps: j.Numeric(5, { min: 2, max: 16, step: 1 }),
  exposure: j.Numeric(1, { min: 0, max: 3, step: 0.01 }),
  light: j.ObjectList({
    inclination: j.Numeric(150, { min: 0, max: 180, step: 1 }),
    azimuth: j.Numeric(320, { min: 0, max: 360, step: 1 }),
    color: j.Color(i0.fromNormalizedRgb(1, 1, 1)),
    intensity: j.Numeric(0.6, { min: 0, max: 5, step: 0.01 })
  }, (Z) => i0.toHexString(Z.color), { defaultValue: [{
    inclination: 150,
    azimuth: 320,
    color: i0.fromNormalizedRgb(1, 1, 1),
    intensity: 0.6
  }] }),
  ambientColor: j.Color(i0.fromNormalizedRgb(1, 1, 1)),
  ambientIntensity: j.Numeric(0.4, { min: 0, max: 2, step: 0.01 })
}, sA = M(), Ee = M();
function Hw0(Z, J) {
  let $ = Z.length, { direction: X, color: Y } = J || {
    direction: new Array($ * 3).fill(0),
    color: new Array($ * 3).fill(0)
  };
  for (let Q = 0;Q < $; ++Q) {
    let W = Z[Q];
    M.directionFromSpherical(sA, _8(W.inclination), _8(W.azimuth), 1), M.toArray(sA, X, Q * 3), M.scale(Ee, i0.toVec3Normalized(Ee, W.color), W.intensity), M.toArray(Ee, Y, Q * 3);
  }
  return { count: $, direction: X, color: Y };
}
function Oe(Z, J) {
  let $ = new Array(Z.count * 3);
  for (let X = 0, Y = Z.count;X < Y; ++X)
    M.fromArray(sA, Z.direction, X * 3), M.transformDirection(sA, sA, J), M.toArray(sA, $, X * 3);
  return $;
}
var Qx;
(function(Z) {
  let J;
  (function(Y) {
    Y[Y.None = 0] = "None", Y[Y.BlendedFront = 1] = "BlendedFront", Y[Y.BlendedBack = 2] = "BlendedBack";
  })(J || (J = {}));
  let $;
  (function(Y) {
    Y[Y.All = 0] = "All", Y[Y.Opaque = 1] = "Opaque", Y[Y.Transparent = 2] = "Transparent";
  })($ || ($ = {}));
  function X(Y, Q = {}) {
    let { gl: W, state: K, stats: G } = Y, H = j.merge(aA, j.getDefaultValues(aA), Q), N = Hw0(H.light), q = bZ(), U = h0.create(W.drawingBufferWidth, W.drawingBufferHeight), F = i0.toVec3Normalized(M(), H.backgroundColor), E = !1, R = null, z = Y.resources.texture("image-uint8", "rgba", "ubyte", "nearest");
    z.define(1, 1), z.load({ array: new Uint8Array([255, 255, 255, 255]), width: 1, height: 1 });
    let D = [
      ["tDepth", z]
    ], A = e(), B = e(), T = e(), w = e(), V = e(), P = e(), I = e(), S = e(), f = e(), v = e(), h = e(), x = M(), b = M(), g = M(), m = tZ(), i = h0(), r = lN(), Y0 = 1, c = C0(), n = M();
    M.scale(n, i0.toArrayNormalized(H.ambientColor, n, 0), H.ambientIntensity);
    let l = {
      uDrawId: C.create(0),
      uModel: C.create(e.identity()),
      uView: C.create(B),
      uInvView: C.create(T),
      uModelView: C.create(w),
      uInvModelView: C.create(V),
      uInvProjection: C.create(P),
      uProjection: C.create(e()),
      uModelViewProjection: C.create(I),
      uInvModelViewProjection: C.create(S),
      uHasHeadRotation: C.create(!1),
      uInvHeadRotation: C.create(f),
      uHasEyeCamera: C.create(!1),
      uModelViewEye: C.create(v),
      uInvModelViewEye: C.create(h),
      uIsAsymmetricProjection: C.create(!1),
      uIsOrtho: C.create(1),
      uViewOffset: C.create(i),
      uModelScale: C.create(1),
      uPixelRatio: C.create(Y.pixelRatio),
      uViewport: C.create(bZ.toVec4(E2(), q)),
      uDrawingBufferSize: C.create(U),
      uCameraPosition: C.create(b),
      uCameraDir: C.create(x),
      uCameraPlane: C.create(tZ.toArray(m, E2(), 0)),
      uNear: C.create(1),
      uFar: C.create(1e4),
      uFog: C.create(!0),
      uFogNear: C.create(1),
      uFogFar: C.create(1e4),
      uFogColor: C.create(F),
      uRenderMask: C.create(0),
      uMarkingDepthTest: C.create(!1),
      uPickType: C.create(qU.None),
      uMarkingType: C.create(sV.None),
      uTransparentBackground: C.create(!1),
      uLightDirection: C.create(N.direction),
      uLightColor: C.create(N.color),
      uAmbientColor: C.create(n),
      uPickingAlphaThreshold: C.create(H.pickingAlphaThreshold),
      uHighlightColor: C.create(i0.toVec3Normalized(M(), H.highlightColor)),
      uSelectColor: C.create(i0.toVec3Normalized(M(), H.selectColor)),
      uDimColor: C.create(i0.toVec3Normalized(M(), H.dimColor)),
      uHighlightStrength: C.create(H.highlightStrength),
      uSelectStrength: C.create(H.selectStrength),
      uDimStrength: C.create(H.dimStrength),
      uMarkerPriority: C.create(H.markerPriority),
      uMarkerAverage: C.create(0),
      uXrayEdgeFalloff: C.create(H.xrayEdgeFalloff),
      uCelSteps: C.create(H.celSteps),
      uExposure: C.create(H.exposure)
    }, u = Object.entries(l), G0 = !0, F0 = (b0, x0, m0) => {
      var e0, p, J0;
      if (b0.state.disposed || !b0.state.visible || !b0.state.pickable && x0 === "pick")
        return;
      if (!b0.values.drawCount.ref.value)
        return;
      if (C0.scaleNX(c, b0.values.boundingSphere.ref.value, Y0), !lN.intersectsSphere3D(r, c))
        return;
      let [T0, o0] = b0.values.uLod.ref.value;
      if (T0 !== 0 || o0 !== 0) {
        let { center: F1, radius: A1 } = c, P1 = tZ.distanceToPoint(m, F1);
        if (P1 + A1 < T0 * Y0)
          return;
        if (P1 - A1 > o0 * Y0)
          return;
      }
      if (Y0 === 1) {
        if (R !== null && R(c))
          return;
        let F1 = b0.values.instanceGrid.ref.value.cellSize > 0, A1 = b0.values.uInstanceCount.ref.value > 1;
        if (F1 && (A1 || b0.values.lodLevels))
          b0.cull(m, r, R, Y.stats);
        else
          b0.uncull();
      } else if (b0.values.lodLevels) {
        let { center: F1, radius: A1 } = c, P1 = tZ.distanceToPoint(m, F1);
        b0.cullSimple(P1, A1, Y0);
      } else
        b0.uncull();
      let $1 = b0.getProgram(x0);
      if (K.currentProgramId !== $1.id)
        G0 = !0, $1.use();
      if (G0)
        $1.setUniforms(u), $1.bindTextures(D, 0), G0 = !1;
      if (b0.values.dGeometryType.ref.value === "directVolume") {
        if (x0 !== "color")
          return;
        K.disable(W.CULL_FACE), K.frontFace(W.CCW);
      } else if (m0 === J.BlendedFront)
        if (K.enable(W.CULL_FACE), (e0 = b0.values.dFlipSided) === null || e0 === void 0 ? void 0 : e0.ref.value)
          K.frontFace(W.CW), K.cullFace(W.FRONT);
        else
          K.frontFace(W.CCW), K.cullFace(W.BACK);
      else if (m0 === J.BlendedBack)
        if (K.enable(W.CULL_FACE), (p = b0.values.dFlipSided) === null || p === void 0 ? void 0 : p.ref.value)
          K.frontFace(W.CW), K.cullFace(W.BACK);
        else
          K.frontFace(W.CCW), K.cullFace(W.FRONT);
      else {
        if (b0.values.uDoubleSided)
          if (b0.values.uDoubleSided.ref.value || b0.values.hasReflection.ref.value)
            K.disable(W.CULL_FACE);
          else
            K.enable(W.CULL_FACE);
        else
          K.disable(W.CULL_FACE);
        if ((J0 = b0.values.dFlipSided) === null || J0 === void 0 ? void 0 : J0.ref.value)
          K.frontFace(W.CW), K.cullFace(W.FRONT);
        else
          K.frontFace(W.CCW), K.cullFace(W.BACK);
      }
      b0.render(x0, D.length);
    }, t = (b0, x0) => {
      if (C.update(l.uView, b0.view), C.update(l.uInvView, e.invert(T, b0.view)), C.update(l.uProjection, b0.projection), C.update(l.uInvProjection, e.invert(P, b0.projection)), C.updateIfChanged(l.uIsOrtho, b0.state.mode === "orthographic" ? 1 : 0), C.update(l.uViewOffset, b0.viewOffset.enabled ? h0.set(i, b0.viewOffset.offsetX * 16, b0.viewOffset.offsetY * 16) : h0.set(i, 0, 0)), C.updateIfChanged(l.uModelScale, b0.scale), C.update(l.uCameraPosition, e.getTranslation(b, T)), M.scale(g, b0.state.target, b0.scale), M.normalize(x, M.sub(x, g, b)), C.update(l.uCameraDir, x), C.updateIfChanged(l.uFar, b0.far), C.updateIfChanged(l.uNear, b0.near), C.updateIfChanged(l.uFog, b0.state.fog > 0), C.updateIfChanged(l.uFogFar, b0.fogFar), C.updateIfChanged(l.uFogNear, b0.fogNear), C.updateIfChanged(l.uTransparentBackground, E), lN.fromProjectionMatrix(r, b0.projectionView), tZ.copy(m, r[lN.PlaneIndex.Near]), m.constant -= tZ.distanceToPoint(m, b), C.update(l.uCameraPlane, tZ.toArray(m, l.uCameraPlane.ref.value, 0)), C.updateIfChanged(l.uMarkerAverage, x0.markerAverage), !e.isZero(b0.headRotation))
        C.updateIfChanged(l.uHasHeadRotation, !0), C.update(l.uInvHeadRotation, e.invert(f, b0.headRotation)), C.update(l.uLightDirection, Oe(N, f));
      else
        C.updateIfChanged(l.uHasHeadRotation, !1), C.updateIfChanged(l.uInvHeadRotation, e.id), C.update(l.uLightDirection, N.direction);
      C.update(l.uIsAsymmetricProjection, b0.isAsymmetricProjection);
    }, Z0 = (b0, x0, m0, e0, p) => {
      if (z_(D, "tDepth", m0 || z), Y0 = x0.scale, C.update(l.uModel, e.scaleUniformly(A, b0.view, Y0)), C.update(l.uModelView, e.mul(w, x0.view, A)), C.update(l.uInvModelView, e.invert(V, w)), C.update(l.uModelViewProjection, e.mul(I, w, x0.projection)), C.update(l.uInvModelViewProjection, e.invert(S, I)), C.updateIfChanged(l.uRenderMask, e0), C.updateIfChanged(l.uMarkingDepthTest, p), !e.isZero(x0.viewEye))
        C.updateIfChanged(l.uHasEyeCamera, !0), C.update(l.uModelViewEye, e.mul(v, x0.viewEye, A)), C.update(l.uInvModelViewEye, e.invert(h, v));
      else
        C.updateIfChanged(l.uHasEyeCamera, !1), C.updateIfChanged(l.uModelViewEye, e.id), C.updateIfChanged(l.uInvModelViewEye, e.id);
      K.enable(W.SCISSOR_TEST), K.colorMask(!0, !0, !0, !0);
      let { x: T0, y: o0, width: y0, height: $1 } = q;
      K.viewport(T0, o0, y0, $1), K.scissor(T0, o0, y0, $1), G0 = !0, K.currentRenderItemId = -1;
    }, U0 = function(b0) {
      var x0, m0, e0, p;
      let J0 = x8(b0.values.alpha.ref.value * b0.state.alphaFactor, 0, 1), T0 = ((x0 = b0.values.dXrayShaded) === null || x0 === void 0 ? void 0 : x0.ref.value) === "on" || ((m0 = b0.values.dXrayShaded) === null || m0 === void 0 ? void 0 : m0.ref.value) === "inverted";
      return J0 === 1 && b0.values.transparencyAverage.ref.value !== 1 && b0.values.dGeometryType.ref.value !== "directVolume" && ((e0 = b0.values.dPointStyle) === null || e0 === void 0 ? void 0 : e0.ref.value) !== "fuzzy" && !T0 || ((p = b0.values.dTransparentBackfaces) === null || p === void 0 ? void 0 : p.ref.value) === "opaque";
    }, a = function(b0) {
      var x0, m0, e0;
      let p = x8(b0.values.alpha.ref.value * b0.state.alphaFactor, 0, 1), J0 = ((x0 = b0.values.dXrayShaded) === null || x0 === void 0 ? void 0 : x0.ref.value) === "on" || ((m0 = b0.values.dXrayShaded) === null || m0 === void 0 ? void 0 : m0.ref.value) === "inverted";
      return p !== 0 && (p < 1 || b0.values.transparencyAverage.ref.value > 0 || b0.values.dGeometryType.ref.value === "directVolume" || ((e0 = b0.values.dPointStyle) === null || e0 === void 0 ? void 0 : e0.ref.value) === "fuzzy" || b0.values.dGeometryType.ref.value === "text" || b0.values.dGeometryType.ref.value === "image" || J0);
    }, Q0 = (b0, x0, m0, e0) => {
      if (K1)
        Y.timer.mark("Renderer.renderPick");
      K.disable(W.BLEND), K.enable(W.DEPTH_TEST), K.depthMask(!0), Z0(b0, x0, null, $.All, !1), C.updateIfChanged(l.uPickType, e0);
      let { renderables: p } = b0;
      for (let J0 = 0, T0 = p.length;J0 < T0; ++J0)
        if (!p[J0].state.colorOnly)
          F0(p[J0], m0, J.None);
      if (K1)
        Y.timer.markEnd("Renderer.renderPick");
    }, $0 = (b0, x0) => {
      if (K1)
        Y.timer.mark("Renderer.renderDepth");
      K.disable(W.BLEND), K.enable(W.DEPTH_TEST), K.depthMask(!0), Z0(b0, x0, null, $.All, !1);
      let { renderables: m0 } = b0;
      for (let e0 = 0, p = m0.length;e0 < p; ++e0)
        F0(m0[e0], "depth", J.None);
      if (K1)
        Y.timer.markEnd("Renderer.renderDepth");
    }, R0 = (b0, x0) => {
      if (K1)
        Y.timer.mark("Renderer.renderDepthOpaque");
      K.disable(W.BLEND), K.enable(W.DEPTH_TEST), K.depthMask(!0), Z0(b0, x0, null, $.Opaque, !1);
      let { renderables: m0 } = b0;
      for (let e0 = 0, p = m0.length;e0 < p; ++e0) {
        let J0 = m0[e0];
        if (U0(J0))
          F0(J0, "depth", J.None);
      }
      if (K1)
        Y.timer.markEnd("Renderer.renderDepthOpaque");
    }, X0 = (b0, x0) => {
      if (K1)
        Y.timer.mark("Renderer.renderDepthOpaqueBack");
      K.disable(W.BLEND), K.enable(W.DEPTH_TEST), K.depthMask(!0), K.depthFunc(W.GREATER), Z0(b0, x0, null, $.Opaque, !1);
      let { renderables: m0 } = b0;
      for (let e0 = 0, p = m0.length;e0 < p; ++e0) {
        let J0 = m0[e0];
        if (U0(J0))
          F0(J0, "depth", J.BlendedBack);
      }
      if (K.depthFunc(W.LESS), K1)
        Y.timer.markEnd("Renderer.renderDepthOpaqueBack");
    }, E0 = (b0, x0, m0) => {
      if (K1)
        Y.timer.mark("Renderer.renderDepthTransparent");
      K.disable(W.BLEND), K.enable(W.DEPTH_TEST), K.depthMask(!0), Z0(b0, x0, m0, $.Transparent, !1);
      let { renderables: e0 } = b0;
      for (let p = 0, J0 = e0.length;p < J0; ++p) {
        let T0 = e0[p];
        if (a(T0))
          F0(T0, "depth", J.None);
      }
      if (K1)
        Y.timer.markEnd("Renderer.renderDepthTransparent");
    }, V0 = (b0, x0) => {
      if (K1)
        Y.timer.mark("Renderer.renderMarkingDepth");
      K.disable(W.BLEND), K.enable(W.DEPTH_TEST), K.depthMask(!0), Z0(b0, x0, null, $.All, !1), C.updateIfChanged(l.uMarkingType, sV.Depth);
      let { renderables: m0 } = b0;
      for (let e0 = 0, p = m0.length;e0 < p; ++e0) {
        let J0 = m0[e0];
        if (x8(J0.values.alpha.ref.value * J0.state.alphaFactor, 0, 1) !== 0 && J0.values.transparencyAverage.ref.value !== 1 && J0.values.markerAverage.ref.value !== 1)
          F0(m0[e0], "marking", J.None);
      }
      if (K1)
        Y.timer.markEnd("Renderer.renderMarkingDepth");
    }, u0 = (b0, x0, m0) => {
      if (K1)
        Y.timer.mark("Renderer.renderMarkingMask");
      K.disable(W.BLEND), K.enable(W.DEPTH_TEST), K.depthMask(!0), Z0(b0, x0, m0, $.All, !!m0), C.updateIfChanged(l.uMarkingType, sV.Mask);
      let { renderables: e0 } = b0;
      for (let p = 0, J0 = e0.length;p < J0; ++p)
        if (e0[p].values.markerAverage.ref.value > 0)
          F0(e0[p], "marking", J.None);
      if (K1)
        Y.timer.markEnd("Renderer.renderMarkingMask");
    }, N0 = (b0, x0) => {
      if (K1)
        Y.timer.mark("Renderer.renderEmissive");
      K.disable(W.BLEND), K.enable(W.DEPTH_TEST), K.depthMask(!0), Z0(b0, x0, null, $.Opaque, !1);
      let { renderables: m0 } = b0;
      for (let e0 = 0, p = m0.length;e0 < p; ++e0) {
        let J0 = m0[e0];
        if (U0(J0))
          F0(J0, "emissive", J.None);
      }
      if (K1)
        Y.timer.markEnd("Renderer.renderEmissive");
    }, q0 = (b0, x0) => {
      if (K1)
        Y.timer.mark("Renderer.renderTracing");
      K.disable(W.BLEND), K.enable(W.DEPTH_TEST), K.depthMask(!0), Z0(b0, x0, null, $.Opaque, !1);
      let { renderables: m0 } = b0;
      for (let e0 = 0, p = m0.length;e0 < p; ++e0) {
        let J0 = m0[e0];
        if (U0(J0))
          F0(J0, "tracing", J.None);
      }
      if (K1)
        Y.timer.markEnd("Renderer.renderTracing");
    }, A0 = (b0, x0) => {
      if (b0.hasOpaque)
        S0(b0, x0);
      if (b0.opacityAverage < 1)
        a0(b0, x0);
    }, S0 = (b0, x0) => {
      if (K1)
        Y.timer.mark("Renderer.renderOpaque");
      K.disable(W.BLEND), K.enable(W.DEPTH_TEST), K.depthMask(!0), Z0(b0, x0, null, $.Opaque, !1);
      let { renderables: m0 } = b0;
      for (let e0 = 0, p = m0.length;e0 < p; ++e0) {
        let J0 = m0[e0];
        if (U0(J0))
          F0(J0, "color", J.None);
      }
      if (K1)
        Y.timer.markEnd("Renderer.renderOpaque");
    }, a0 = (b0, x0) => {
      var m0, e0;
      if (K1)
        Y.timer.mark("Renderer.renderBlendedTransparent");
      if (E)
        K.blendFunc(W.ONE, W.ONE_MINUS_SRC_ALPHA);
      else
        K.blendFuncSeparate(W.SRC_ALPHA, W.ONE_MINUS_SRC_ALPHA, W.ONE, W.ONE_MINUS_SRC_ALPHA);
      K.enable(W.BLEND), K.enable(W.DEPTH_TEST), K.depthMask(!1), Z0(b0, x0, null, $.Transparent, !1);
      let { renderables: p } = b0;
      for (let J0 = 0, T0 = p.length;J0 < T0; ++J0) {
        let o0 = p[J0];
        if (a(o0))
          if ((m0 = o0.values.uDoubleSided) === null || m0 === void 0 ? void 0 : m0.ref.value) {
            if (((e0 = o0.values.dTransparentBackfaces) === null || e0 === void 0 ? void 0 : e0.ref.value) !== "opaque")
              F0(o0, "color", J.BlendedBack);
            F0(o0, "color", J.BlendedFront);
          } else
            F0(o0, "color", J.None);
      }
      if (K1)
        Y.timer.markEnd("Renderer.renderBlendedTransparent");
    };
    return {
      clear: (b0, x0, m0) => {
        if (K.enable(W.SCISSOR_TEST), K.enable(W.DEPTH_TEST), K.colorMask(!0, !0, !0, !0), K.depthMask(!0), m0 || E && !x0)
          K.clearColor(0, 0, 0, 0);
        else if (b0)
          K.clearColor(F[0], F[1], F[2], 1);
        else
          K.clearColor(1, 1, 1, 1);
        W.clear(W.COLOR_BUFFER_BIT | W.DEPTH_BUFFER_BIT);
      },
      clearDepth: (b0 = !1) => {
        if (K.enable(W.SCISSOR_TEST), K.enable(W.DEPTH_TEST), K.depthMask(!0), b0)
          K.colorMask(!0, !0, !0, !0), K.clearColor(1, 1, 1, 1), W.clear(W.COLOR_BUFFER_BIT | W.DEPTH_BUFFER_BIT);
        else
          W.clear(W.DEPTH_BUFFER_BIT);
      },
      update: t,
      renderPick: Q0,
      renderDepth: $0,
      renderDepthOpaque: R0,
      renderDepthOpaqueBack: X0,
      renderDepthTransparent: E0,
      renderMarkingDepth: V0,
      renderMarkingMask: u0,
      renderEmissive: N0,
      renderTracing: q0,
      renderBlended: A0,
      renderOpaque: S0,
      renderBlendedTransparent: a0,
      renderVolume: (b0, x0, m0) => {
        if (K1)
          Y.timer.mark("Renderer.renderVolume");
        K.blendFunc(W.ONE, W.ONE_MINUS_SRC_ALPHA), K.enable(W.BLEND), K.disable(W.DEPTH_TEST), K.depthMask(!1), Z0(b0, x0, m0, $.Transparent, !1);
        let { renderables: e0 } = b0;
        for (let p = 0, J0 = e0.length;p < J0; ++p) {
          let T0 = e0[p];
          if (T0.values.dGeometryType.ref.value === "directVolume")
            F0(T0, "color", J.None);
        }
        if (K1)
          Y.timer.markEnd("Renderer.renderVolume");
      },
      renderWboitTransparent: (b0, x0, m0) => {
        if (K1)
          Y.timer.mark("Renderer.renderWboitTransparent");
        Z0(b0, x0, m0, $.Transparent, !1);
        let { renderables: e0 } = b0;
        for (let p = 0, J0 = e0.length;p < J0; ++p) {
          let T0 = e0[p];
          if (a(T0))
            F0(T0, "color", J.None);
        }
        if (K1)
          Y.timer.markEnd("Renderer.renderWboitTransparent");
      },
      renderDpoitTransparent: (b0, x0, m0, e0) => {
        if (K1)
          Y.timer.mark("Renderer.renderDpoitTransparent");
        K.enable(W.BLEND), z_(D, "tDpoitDepth", e0.depth), z_(D, "tDpoitFrontColor", e0.frontColor), z_(D, "tDpoitBackColor", e0.backColor), Z0(b0, x0, m0, $.Transparent, !1);
        let { renderables: p } = b0;
        for (let J0 = 0, T0 = p.length;J0 < T0; ++J0) {
          let o0 = p[J0];
          if (a(o0))
            F0(o0, "color", J.None);
        }
        if (K1)
          Y.timer.markEnd("Renderer.renderDpoitTransparent");
      },
      setProps: (b0) => {
        if (b0.backgroundColor !== void 0 && b0.backgroundColor !== H.backgroundColor)
          H.backgroundColor = b0.backgroundColor, i0.toVec3Normalized(F, H.backgroundColor), C.update(l.uFogColor, M.copy(l.uFogColor.ref.value, F));
        if (b0.pickingAlphaThreshold !== void 0 && b0.pickingAlphaThreshold !== H.pickingAlphaThreshold)
          H.pickingAlphaThreshold = b0.pickingAlphaThreshold, C.update(l.uPickingAlphaThreshold, H.pickingAlphaThreshold);
        if (b0.colorMarker !== void 0 && b0.colorMarker !== H.colorMarker)
          H.colorMarker = b0.colorMarker;
        if (b0.highlightColor !== void 0 && b0.highlightColor !== H.highlightColor)
          H.highlightColor = b0.highlightColor, C.update(l.uHighlightColor, i0.toVec3Normalized(l.uHighlightColor.ref.value, H.highlightColor));
        if (b0.selectColor !== void 0 && b0.selectColor !== H.selectColor)
          H.selectColor = b0.selectColor, C.update(l.uSelectColor, i0.toVec3Normalized(l.uSelectColor.ref.value, H.selectColor));
        if (b0.dimColor !== void 0 && b0.dimColor !== H.dimColor)
          H.dimColor = b0.dimColor, C.update(l.uDimColor, i0.toVec3Normalized(l.uDimColor.ref.value, H.dimColor));
        if (b0.highlightStrength !== void 0 && b0.highlightStrength !== H.highlightStrength)
          H.highlightStrength = b0.highlightStrength, C.update(l.uHighlightStrength, H.highlightStrength);
        if (b0.selectStrength !== void 0 && b0.selectStrength !== H.selectStrength)
          H.selectStrength = b0.selectStrength, C.update(l.uSelectStrength, H.selectStrength);
        if (b0.dimStrength !== void 0 && b0.dimStrength !== H.dimStrength)
          H.dimStrength = b0.dimStrength, C.update(l.uDimStrength, H.dimStrength);
        if (b0.markerPriority !== void 0 && b0.markerPriority !== H.markerPriority)
          H.markerPriority = b0.markerPriority, C.update(l.uMarkerPriority, H.markerPriority);
        if (b0.xrayEdgeFalloff !== void 0 && b0.xrayEdgeFalloff !== H.xrayEdgeFalloff)
          H.xrayEdgeFalloff = b0.xrayEdgeFalloff, C.update(l.uXrayEdgeFalloff, H.xrayEdgeFalloff);
        if (b0.celSteps !== void 0 && b0.celSteps !== H.celSteps)
          H.celSteps = b0.celSteps, C.update(l.uCelSteps, H.celSteps);
        if (b0.exposure !== void 0 && b0.exposure !== H.exposure)
          H.exposure = b0.exposure, C.update(l.uExposure, H.exposure);
        if (b0.light !== void 0 && !QY(b0.light, H.light))
          H.light = b0.light, Object.assign(N, Hw0(b0.light, N)), C.update(l.uLightDirection, N.direction), C.update(l.uLightColor, N.color);
        if (b0.ambientColor !== void 0 && b0.ambientColor !== H.ambientColor)
          H.ambientColor = b0.ambientColor, M.scale(n, i0.toArrayNormalized(H.ambientColor, n, 0), H.ambientIntensity), C.update(l.uAmbientColor, n);
        if (b0.ambientIntensity !== void 0 && b0.ambientIntensity !== H.ambientIntensity)
          H.ambientIntensity = b0.ambientIntensity, M.scale(n, i0.toArrayNormalized(H.ambientColor, n, 0), H.ambientIntensity), C.update(l.uAmbientColor, n);
      },
      setViewport: (b0, x0, m0, e0) => {
        if (K.viewport(b0, x0, m0, e0), K.scissor(b0, x0, m0, e0), b0 !== q.x || x0 !== q.y || m0 !== q.width || e0 !== q.height)
          bZ.set(q, b0, x0, m0, e0), C.update(l.uViewport, E2.set(l.uViewport.ref.value, b0, x0, m0, e0));
      },
      setTransparentBackground: (b0) => {
        E = b0;
      },
      setDrawingBufferSize: (b0, x0) => {
        if (b0 !== U[0] || x0 !== U[1])
          C.update(l.uDrawingBufferSize, h0.set(U, b0, x0));
      },
      setPixelRatio: (b0) => {
        C.update(l.uPixelRatio, b0);
      },
      setOcclusionTest: (b0) => {
        R = b0;
      },
      props: H,
      get stats() {
        return {
          programCount: Y.stats.resourceCounts.program,
          shaderCount: Y.stats.resourceCounts.shader,
          attributeCount: Y.stats.resourceCounts.attribute,
          elementsCount: Y.stats.resourceCounts.elements,
          framebufferCount: Y.stats.resourceCounts.framebuffer,
          renderbufferCount: Y.stats.resourceCounts.renderbuffer,
          textureCount: Y.stats.resourceCounts.texture,
          vertexArrayCount: Y.stats.resourceCounts.vertexArray,
          drawCount: G.drawCount,
          instanceCount: G.instanceCount,
          instancedDrawCount: G.instancedDrawCount
        };
      },
      get light() {
        return N;
      },
      get ambientColor() {
        return l.uAmbientColor.ref.value;
      },
      dispose: () => {}
    };
  }
  Z.create = X;
})(Qx || (Qx = {}));

// node_modules/molstar/lib/mol-util/binding.js
function e1(Z, J = "", $ = "") {
  return e1.create(Z, J, $);
}
(function(Z) {
  function J(N, q = "", U = "") {
    return { triggers: N, action: q, description: U };
  }
  Z.create = J;
  function $(N) {
    return !!N && Array.isArray(N.triggers) && typeof N.action === "string";
  }
  Z.isBinding = $, Z.Empty = { triggers: [], action: "", description: "" };
  function X(N) {
    return N.triggers.length === 0 || N.triggers.every((q) => q.buttons === void 0 && q.modifiers === void 0 && !q.code);
  }
  Z.isEmpty = X;
  function Y(N, q, U) {
    return N.triggers.some((F) => G.match(F, q, U));
  }
  Z.match = Y;
  function Q(N, q, U, F) {
    return N.triggers.some((E) => G.matchKey(E, q, U, F));
  }
  Z.matchKey = Q;
  function W(N) {
    return N.triggers.map(G.format).join(" or ");
  }
  Z.formatTriggers = W;
  function K(N, q = "") {
    let U = N.description || v$(q);
    return n50(U, { triggers: "<i>" + W(N) + "</i>" });
  }
  Z.format = K;
  function G(N, q) {
    return G.create(N, q);
  }
  Z.Trigger = G;
  function H(N, q) {
    return G.create(void 0, q, N);
  }
  Z.TriggerKey = H, function(N) {
    function q(R, z, D) {
      return { buttons: R, modifiers: z, code: D };
    }
    N.create = q, N.Empty = {};
    function U(R, z, D) {
      let { buttons: A, modifiers: B } = R;
      return A !== void 0 && (A === z || V8.has(A, z)) && (!B || hJ.areEqual(B, D));
    }
    N.match = U;
    function F(R, z, D, A) {
      let { modifiers: B, code: T } = R;
      return T !== void 0 && (T === z || T.length === 1 && z.length === 4 && z.startsWith("Key") && !!A && A.length === 1 && A.toUpperCase() === T.toUpperCase()) && (!B || hJ.areEqual(B, D));
    }
    N.matchKey = F;
    function E(R) {
      let z = [], D = RN1(R.buttons, R.code);
      if (D)
        z.push(D);
      let A = ON1(R.code);
      if (A)
        z.push(A);
      let B = EN1(R.modifiers);
      if (B)
        z.push(B);
      return z.join(" + ");
    }
    N.format = E;
  }(G = Z.Trigger || (Z.Trigger = {}));
})(e1 || (e1 = {}));
var rR = V8;
function RN1(Z, J) {
  let $ = [];
  if (Z === void 0 && !J)
    $.push("any mouse button");
  else if (Z === 0)
    $.push("mouse hover");
  else if (Z !== void 0) {
    if (rR.has(Z, rR.Flag.Primary))
      $.push("left mouse button");
    if (rR.has(Z, rR.Flag.Secondary))
      $.push("right mouse button");
    if (rR.has(Z, rR.Flag.Auxilary))
      $.push("wheel/middle mouse button");
    if (rR.has(Z, rR.Flag.Forth))
      $.push("three fingers");
  }
  return $.join(" + ");
}
function EN1(Z, J) {
  let $ = [];
  if (Z) {
    if (Z.alt)
      $.push("alt key");
    if (Z.control)
      $.push("control key");
    if (Z.meta)
      $.push("meta/command key");
    if (Z.shift)
      $.push("shift key");
    if (J && $.length === 0)
      $.push("no key");
  } else if (J)
    $.push("any key");
  return $.join(" + ");
}
function ON1(Z) {
  if (Z === null || Z === void 0 ? void 0 : Z.startsWith("Key"))
    Z = Z.substring(3);
  return Z && s$(Z).toLowerCase();
}

// node_modules/molstar/lib/mol-canvas3d/controls/trackball.js
var FU = V8, fK = hJ, UU = e1.Trigger, sQ = e1.TriggerKey, zN1 = {
  dragRotate: e1([
    UU(FU.Flag.Primary, fK.create()),
    UU(FU.Flag.Trigger)
  ], "Rotate", "Drag using ${triggers}"),
  dragRotateZ: e1([UU(FU.Flag.Primary, fK.create({ shift: !0, control: !0 }))], "Rotate around z-axis (roll)", "Drag using ${triggers}"),
  dragPan: e1([
    UU(FU.Flag.Secondary, fK.create()),
    UU(FU.Flag.Primary, fK.create({ control: !0 }))
  ], "Pan", "Drag using ${triggers}"),
  dragZoom: e1.Empty,
  dragFocus: e1([UU(FU.Flag.Forth, fK.create())], "Focus", "Drag using ${triggers}"),
  dragFocusZoom: e1([UU(FU.Flag.Auxilary, fK.create())], "Focus and zoom", "Drag using ${triggers}"),
  scrollZoom: e1([UU(FU.Flag.Auxilary, fK.create())], "Zoom", "Scroll using ${triggers}"),
  scrollFocus: e1([UU(FU.Flag.Auxilary, fK.create({ shift: !0 }))], "Clip", "Scroll using ${triggers}"),
  scrollFocusZoom: e1.Empty,
  keyMoveForward: e1([
    sQ("KeyW"),
    sQ("GamepadUp")
  ], "Move forward", "Press ${triggers}"),
  keyMoveBack: e1([
    sQ("KeyS"),
    sQ("GamepadDown")
  ], "Move back", "Press ${triggers}"),
  keyMoveLeft: e1([sQ("KeyA")], "Move left", "Press ${triggers}"),
  keyMoveRight: e1([sQ("KeyD")], "Move right", "Press ${triggers}"),
  keyMoveUp: e1([sQ("KeyR")], "Move up", "Press ${triggers}"),
  keyMoveDown: e1([sQ("KeyF")], "Move down", "Press ${triggers}"),
  keyRollLeft: e1([sQ("KeyQ")], "Roll left", "Press ${triggers}"),
  keyRollRight: e1([sQ("KeyE")], "Roll right", "Press ${triggers}"),
  keyPitchUp: e1([sQ("ArrowUp", fK.create({ shift: !0 }))], "Pitch up", "Press ${triggers}"),
  keyPitchDown: e1([sQ("ArrowDown", fK.create({ shift: !0 }))], "Pitch down", "Press ${triggers}"),
  keyYawLeft: e1([sQ("ArrowLeft", fK.create({ shift: !0 }))], "Yaw left", "Press ${triggers}"),
  keyYawRight: e1([sQ("ArrowRight", fK.create({ shift: !0 }))], "Yaw right", "Press ${triggers}"),
  boostMove: e1([sQ("ShiftLeft")], "Boost move", "Press ${triggers}"),
  enablePointerLock: e1([sQ("Space", fK.create({ control: !0 }))], "Enable pointer lock", "Press ${triggers}")
}, ze = {
  rotateSpeed: j.Numeric(5, { min: 1, max: 10, step: 1 }),
  zoomSpeed: j.Numeric(7, { min: 1, max: 15, step: 1 }),
  panSpeed: j.Numeric(1, { min: 0.1, max: 5, step: 0.1 }),
  moveSpeed: j.Numeric(0.75, { min: 0.1, max: 3, step: 0.1 }),
  boostMoveFactor: j.Numeric(5, { min: 0.1, max: 10, step: 0.1 }),
  flyMode: j.Boolean(!1),
  animate: j.MappedStatic("off", {
    off: j.EmptyGroup(),
    spin: j.Group({
      speed: j.Numeric(0.1, { min: -2, max: 2, step: 0.01 }, { description: "Number of rotations per second" })
    }, { description: "Spin the 3D scene around the x-axis in view space" }),
    rock: j.Group({
      speed: j.Numeric(0.3, { min: -5, max: 5, step: 0.1 }, { description: "Number of oscilations per second" }),
      angle: j.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: j.Boolean(!0, { isHidden: !0 }),
  dynamicDampingFactor: j.Numeric(0.2, {}, { isHidden: !0 }),
  minDistance: j.Numeric(0.01, {}, { isHidden: !0 }),
  maxDistance: j.Numeric(1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000, {}, { isHidden: !0 }),
  gestureScaleFactor: j.Numeric(1, {}, { isHidden: !0 }),
  maxWheelDelta: j.Numeric(0.02, {}, { isHidden: !0 }),
  autoAdjustMinMaxDistance: j.MappedStatic("on", {
    off: j.EmptyGroup(),
    on: j.Group({
      minDistanceFactor: j.Numeric(0),
      minDistancePadding: j.Numeric(5),
      maxDistanceFactor: j.Numeric(10),
      maxDistanceMin: j.Numeric(20)
    })
  }, { isHidden: !0 })
}, De = {
  bindings: zN1
};
var Wx;
(function(Z) {
  function J($, X, Y, Q = {}, W = {}) {
    let K = {
      ...j.getDefaultValues(ze),
      ...Q
    }, G = {
      ...De,
      ...W
    }, H = G.bindings, N = bZ.clone(X.viewport), q = !1, U = $.drag.subscribe(G2), F = $.interactionEnd.subscribe(P2), E = $.wheel.subscribe(v2), R = $.pinch.subscribe(O8), z = $.keyDown.subscribe(z6), D = $.keyUp.subscribe(L8), A = $.move.subscribe(n8), B = $.lock.subscribe(P0), T = $.leave.subscribe(z1), w = !1, V = M(), P = M(), I = h0(), S = h0(), f = M(), v = 0, h = h0(), x = h0(), b = 0, g = 0, m = 0, i = h0(), r = h0(), Y0 = h0(), c = h0(), n = h0(), l = h0(), u = M.clone(X.target), G0 = M.clone(X.position), F0 = M.clone(X.up), t = h0();
    function Z0(I1, W2) {
      return h0.set(t, (I1 - N.x) / N.width, (W2 - N.y) / N.height);
    }
    let U0 = h0();
    function a(I1, W2) {
      return h0.set(U0, (I1 - N.width * 0.5 - N.x) / (N.width * 0.5), (N.height + 2 * (N.y - W2)) / N.width);
    }
    function Q0() {
      let I1 = $.width / $.height || 1;
      return K.rotateSpeed * $.pixelRatio * I1;
    }
    let $0 = M(), R0 = k8(), X0 = M(), E0 = M(), V0 = M(), u0 = M();
    function N0() {
      let I1 = S[0] - I[0], W2 = S[1] - I[1];
      M.set(u0, I1, W2, 0);
      let z2 = M.magnitude(u0) * Q0();
      if (z2)
        M.sub(P, X.position, X.target), M.normalize(X0, P), M.normalize(E0, X.up), M.normalize(V0, M.cross(V0, E0, X0)), M.setMagnitude(E0, E0, W2), M.setMagnitude(V0, V0, I1), M.add(u0, E0, V0), M.normalize($0, M.cross($0, u0, P)), k8.setAxisAngle(R0, $0, z2), M.transformQuat(P, P, R0), M.transformQuat(X.up, X.up, R0), M.copy(f, $0), v = z2;
      else if (!K.staticMoving && v)
        v *= Math.sqrt(1 - K.dynamicDampingFactor), M.sub(P, X.position, X.target), k8.setAxisAngle(R0, f, v), M.transformQuat(P, P, R0), M.transformQuat(X.up, X.up, R0);
      h0.copy(I, S);
    }
    let q0 = k8(), A0 = M();
    function S0() {
      let I1 = (y0.rollRight - y0.rollLeft) / 45, W2 = (x[0] - h[0]) * -Math.sign(x[1]), z2 = (x[1] - h[1]) * -Math.sign(x[0]), p8 = -K.rotateSpeed * (-W2 + z2) + I1;
      if (p8)
        M.normalize(A0, P), k8.setAxisAngle(q0, A0, p8), M.transformQuat(X.up, X.up, q0), b = p8;
      else if (!K.staticMoving && b)
        b *= Math.sqrt(1 - K.dynamicDampingFactor), M.normalize(A0, P), k8.setAxisAngle(q0, A0, b), M.transformQuat(X.up, X.up, q0);
      h0.copy(h, x);
    }
    let a0 = k8(), D1 = M();
    function Y1() {
      let I1 = (y0.pitchUp - y0.pitchDown) / (K.flyMode ? 360 : 90), W2 = -K.rotateSpeed * I1;
      if (W2)
        M.cross(D1, P, X.up), M.normalize(D1, D1), k8.setAxisAngle(a0, D1, W2), M.transformQuat(P, P, a0), M.transformQuat(X.up, X.up, a0), g = W2;
      else if (!K.staticMoving && g)
        g *= Math.sqrt(1 - K.dynamicDampingFactor), M.cross(D1, P, X.up), M.normalize(D1, D1), k8.setAxisAngle(a0, D1, g), M.transformQuat(P, P, a0), M.transformQuat(X.up, X.up, a0);
    }
    let u1 = k8(), b0 = M();
    function x0() {
      let I1 = (y0.yawRight - y0.yawLeft) / (K.flyMode ? 360 : 90), W2 = -K.rotateSpeed * I1;
      if (W2)
        M.normalize(b0, X.up), k8.setAxisAngle(u1, b0, W2), M.transformQuat(P, P, u1), M.transformQuat(X.up, X.up, u1), m = W2;
      else if (!K.staticMoving && m)
        m *= Math.sqrt(1 - K.dynamicDampingFactor), M.normalize(b0, X.up), k8.setAxisAngle(u1, b0, m), M.transformQuat(P, P, u1), M.transformQuat(X.up, X.up, u1);
    }
    function m0() {
      let I1 = 1 + (r[1] - i[1]) * K.zoomSpeed;
      if (I1 !== 1 && I1 > 0)
        M.scale(P, P, I1);
      if (K.staticMoving)
        h0.copy(i, r);
      else
        i[1] += (r[1] - i[1]) * K.dynamicDampingFactor;
    }
    function e0() {
      let I1 = (c[1] - Y0[1]) * K.zoomSpeed;
      if (I1 !== 0) {
        let W2 = Math.max(1, X.state.radius + X.state.radius * I1);
        X.setState({ radius: W2 });
      }
      if (K.staticMoving)
        h0.copy(Y0, c);
      else
        Y0[1] += (c[1] - Y0[1]) * K.dynamicDampingFactor;
    }
    let p = h0(), J0 = M(), T0 = M();
    function o0() {
      if (h0.sub(p, h0.copy(p, l), n), h0.squaredMagnitude(p)) {
        let I1 = $.pixelRatio * K.panSpeed;
        if (p[0] *= 1 / X.zoom * X.viewport.width * I1, p[1] *= 1 / X.zoom * X.viewport.height * I1, M.cross(T0, M.copy(T0, P), X.up), M.setMagnitude(T0, T0, p[0]), M.setMagnitude(J0, X.up, p[1]), M.add(T0, T0, J0), M.add(X.position, X.position, T0), M.add(X.target, X.target, T0), K.staticMoving)
          h0.copy(n, l);
        else
          h0.sub(p, l, n), h0.scale(p, p, K.dynamicDampingFactor), h0.add(n, n, p);
      }
    }
    let y0 = {
      moveUp: 0,
      moveDown: 0,
      moveLeft: 0,
      moveRight: 0,
      moveForward: 0,
      moveBack: 0,
      pitchUp: 0,
      pitchDown: 0,
      yawLeft: 0,
      yawRight: 0,
      rollLeft: 0,
      rollRight: 0,
      boostMove: 0
    }, $1 = M(), F1 = M();
    function A1(I1) {
      M.sub(F1, X.position, X.target);
      let W2 = Math.max(X.state.minNear, K.minDistance);
      M.setMagnitude(F1, F1, W2);
      let z2 = K.flyMode || $.pointerLock, p8 = I1 * 0.06 * K.moveSpeed * (y0.boostMove === 1 ? K.boostMoveFactor : 1);
      if (y0.moveForward === 1) {
        if (M.distance(X.position, Y.boundingSphereVisible.center) < Y.boundingSphereVisible.radius && z2)
          M.normalize($1, F1), M.scaleAndSub(X.position, X.position, $1, p8);
        else
          M.sub($1, X.position, X.target), M.scale($1, $1, 1 - p8 / 100), M.add(X.position, X.target, $1);
        if (z2)
          M.sub(X.target, X.position, F1);
      }
      if (y0.moveBack === 1) {
        if (M.distance(X.position, Y.boundingSphereVisible.center) < Y.boundingSphereVisible.radius && z2)
          M.normalize($1, F1), M.scaleAndAdd(X.position, X.position, $1, p8);
        else
          M.sub($1, X.position, X.target), M.scale($1, $1, 1 + p8 / 100), M.add(X.position, X.target, $1);
        if (z2)
          M.sub(X.target, X.position, F1);
      }
      if (y0.moveLeft === 1)
        if (M.cross($1, F1, X.up), M.normalize($1, $1), z2)
          M.scaleAndAdd(X.position, X.position, $1, p8), M.sub(X.target, X.position, F1);
        else
          M.scaleAndSub(X.position, X.position, $1, p8), M.sub(X.target, X.position, P);
      if (y0.moveRight === 1)
        if (M.cross($1, F1, X.up), M.normalize($1, $1), z2)
          M.scaleAndSub(X.position, X.position, $1, p8), M.sub(X.target, X.position, F1);
        else
          M.scaleAndAdd(X.position, X.position, $1, p8), M.sub(X.target, X.position, P);
      if (y0.moveUp === 1)
        if (M.normalize($1, X.up), z2)
          M.scaleAndAdd(X.position, X.position, $1, p8), M.sub(X.target, X.position, F1);
        else
          M.scaleAndSub(X.position, X.position, $1, p8), M.sub(X.target, X.position, P);
      if (y0.moveDown === 1)
        if (M.normalize($1, X.up), z2)
          M.scaleAndSub(X.position, X.position, $1, p8), M.sub(X.target, X.position, F1);
        else
          M.scaleAndAdd(X.position, X.position, $1, p8), M.sub(X.target, X.position, P);
      if (z2) {
        let W6 = M.distance(X.position, Y.boundingSphereVisible.center);
        X.setState({ minFar: W6 + Y.boundingSphereVisible.radius });
      }
    }
    function P1() {
      let I1 = Math.min(Math.max(X.state.radiusMax * 1000, 0.01), K.maxDistance);
      if (M.squaredMagnitude(P) > I1 * I1)
        M.setMagnitude(P, P, I1), M.add(X.position, X.target, P), h0.copy(i, r), h0.copy(Y0, c);
      if (M.squaredMagnitude(P) < K.minDistance * K.minDistance)
        M.setMagnitude(P, P, K.minDistance), M.add(X.position, X.target, P), h0.copy(i, r), h0.copy(Y0, c);
    }
    function S1(I1, W2) {
      return I1 *= $.pixelRatio, W2 *= $.pixelRatio, I1 > N.x + N.width || $.height - W2 > N.y + N.height || I1 < N.x || $.height - W2 < N.y;
    }
    let _1 = -1;
    function a1(I1) {
      if (_1 === I1)
        return;
      let W2 = I1 - _1;
      if (_1 > 0) {
        if (K.animate.name === "spin")
          X8(W2);
        else if (K.animate.name === "rock")
          g1(W2);
      }
      if (M.sub(P, X.position, X.target), N0(), S0(), Y1(), x0(), m0(), e0(), o0(), M.add(X.position, X.target, P), P1(), _1 > 0)
        A1(Math.min(W2, 250));
      if (M.sub(P, X.position, X.target), P1(), M.squaredDistance(V, X.position) > u8)
        M.copy(V, X.position);
      _1 = I1;
    }
    function U2() {
      M.copy(X.target, u), M.copy(X.position, G0), M.copy(X.up, F0), M.sub(P, X.position, X.target), M.copy(V, X.position);
    }
    function G2({ x: I1, y: W2, dx: z2, dy: p8, pageX: W6, pageY: v6, buttons: AZ, modifiers: L1, isStart: q2, useDelta: s2 }) {
      let d0 = !s2 && S1(I1, W2);
      if (q2 && d0)
        return;
      if (!q2 && !w)
        return;
      w = !0, l2();
      let d1 = e1.match(H.dragRotate, AZ, L1), A2 = e1.match(H.dragRotateZ, AZ, L1), B8 = e1.match(H.dragPan, AZ, L1), Z6 = e1.match(H.dragZoom, AZ, L1), t6 = e1.match(H.dragFocus, AZ, L1), D2 = e1.match(H.dragFocusZoom, AZ, L1);
      if (s2 && d1)
        h0.copy(I, a(W6 - z2, v6 - p8));
      a(W6, v6), Z0(W6, v6);
      let vZ = $.pixelRatio, c6 = (I1 * vZ - N.width / 2 - N.x) / N.width, HZ = -($.height - W2 * vZ - N.height / 2 - N.y) / N.height;
      if (q2) {
        if (d1)
          h0.copy(S, U0), h0.copy(I, S);
        if (A2)
          h0.set(x, c6, HZ), h0.copy(h, x);
        if (Z6 || D2)
          h0.copy(i, t), h0.copy(r, i);
        if (t6)
          h0.copy(Y0, t), h0.copy(c, Y0);
        if (B8)
          h0.copy(n, t), h0.copy(l, n);
      }
      if (d1)
        h0.copy(S, U0);
      if (A2)
        h0.set(x, c6, HZ);
      if (Z6 || D2)
        h0.copy(r, t);
      if (t6)
        h0.copy(c, t);
      if (D2) {
        let pY = M.distance(X.state.position, X.state.target);
        X.setState({ radius: pY / 5 });
      }
      if (B8)
        h0.copy(l, t);
    }
    function P2() {
      w = !1;
    }
    function v2({ x: I1, y: W2, spinX: z2, spinY: p8, dz: W6, buttons: v6, modifiers: AZ }) {
      if (S1(I1, W2))
        return;
      let L1 = d50(z2 * 0.075, p8 * 0.075, W6 * 0.0001);
      if (L1 < -K.maxWheelDelta)
        L1 = -K.maxWheelDelta;
      else if (L1 > K.maxWheelDelta)
        L1 = K.maxWheelDelta;
      if (e1.match(H.scrollZoom, v6, AZ))
        r[1] += L1;
      if (e1.match(H.scrollFocus, v6, AZ))
        c[1] += L1;
    }
    function O8({ isStart: I1, startX: W2, startY: z2, centerPageX: p8, centerPageY: W6, fractionDelta: v6, buttons: AZ, modifiers: L1 }) {
      if (S1(W2, z2))
        return;
      let q2 = e1.match(H.dragPan, AZ, L1), s2 = e1.match(H.scrollZoom, AZ, L1);
      if (w = q2 || s2, q2)
        if (Z0(p8, W6), I1)
          h0.copy(n, t), h0.copy(l, n);
        else
          h0.copy(l, t);
      if (s2)
        r[1] += K.gestureScaleFactor * v6;
    }
    function n8({ movementX: I1, movementY: W2 }) {
      if (!$.pointerLock || I1 === void 0 || W2 === void 0)
        return;
      let z2 = N.width * 0.5 - N.x, p8 = N.height * 0.5 - N.y;
      h0.copy(I, a(z2, p8)), h0.copy(S, a(I1 + z2, W2 + p8));
    }
    function z6({ modifiers: I1, code: W2, key: z2, x: p8, y: W6 }) {
      if (S1(p8, W6))
        return;
      if (e1.matchKey(H.keyMoveForward, W2, I1, z2))
        y0.moveForward = 1;
      else if (e1.matchKey(H.keyMoveBack, W2, I1, z2))
        y0.moveBack = 1;
      else if (e1.matchKey(H.keyMoveLeft, W2, I1, z2))
        y0.moveLeft = 1;
      else if (e1.matchKey(H.keyMoveRight, W2, I1, z2))
        y0.moveRight = 1;
      else if (e1.matchKey(H.keyMoveUp, W2, I1, z2))
        y0.moveUp = 1;
      else if (e1.matchKey(H.keyMoveDown, W2, I1, z2))
        y0.moveDown = 1;
      else if (e1.matchKey(H.keyRollLeft, W2, I1, z2))
        y0.rollLeft = 1;
      else if (e1.matchKey(H.keyRollRight, W2, I1, z2))
        y0.rollRight = 1;
      else if (e1.matchKey(H.keyPitchUp, W2, I1, z2))
        y0.pitchUp = 1;
      else if (e1.matchKey(H.keyPitchDown, W2, I1, z2))
        y0.pitchDown = 1;
      else if (e1.matchKey(H.keyYawLeft, W2, I1, z2))
        y0.yawLeft = 1;
      else if (e1.matchKey(H.keyYawRight, W2, I1, z2))
        y0.yawRight = 1;
      if (e1.matchKey(H.boostMove, W2, I1, z2))
        y0.boostMove = 1;
      if (e1.matchKey(H.enablePointerLock, W2, I1, z2))
        $.requestPointerLock(N);
    }
    function L8({ modifiers: I1, code: W2, key: z2, x: p8, y: W6 }) {
      var v6, AZ, L1, q2, s2, d0, d1, A2, B8, Z6, t6, D2;
      if (S1(p8, W6))
        return;
      let vZ = !1;
      if (W2.startsWith("Alt"))
        vZ = !0, I1.alt = !0;
      else if (W2.startsWith("Shift"))
        vZ = !0, I1.shift = !0;
      else if (W2.startsWith("Control"))
        vZ = !0, I1.control = !0;
      else if (W2.startsWith("Meta"))
        vZ = !0, I1.meta = !0;
      let c6 = [];
      if (vZ) {
        if (y0.moveForward)
          c6.push(((v6 = H.keyMoveForward.triggers[0]) === null || v6 === void 0 ? void 0 : v6.code) || "");
        if (y0.moveBack)
          c6.push(((AZ = H.keyMoveBack.triggers[0]) === null || AZ === void 0 ? void 0 : AZ.code) || "");
        if (y0.moveLeft)
          c6.push(((L1 = H.keyMoveLeft.triggers[0]) === null || L1 === void 0 ? void 0 : L1.code) || "");
        if (y0.moveRight)
          c6.push(((q2 = H.keyMoveRight.triggers[0]) === null || q2 === void 0 ? void 0 : q2.code) || "");
        if (y0.moveUp)
          c6.push(((s2 = H.keyMoveUp.triggers[0]) === null || s2 === void 0 ? void 0 : s2.code) || "");
        if (y0.moveDown)
          c6.push(((d0 = H.keyMoveDown.triggers[0]) === null || d0 === void 0 ? void 0 : d0.code) || "");
        if (y0.rollLeft)
          c6.push(((d1 = H.keyRollLeft.triggers[0]) === null || d1 === void 0 ? void 0 : d1.code) || "");
        if (y0.rollRight)
          c6.push(((A2 = H.keyRollRight.triggers[0]) === null || A2 === void 0 ? void 0 : A2.code) || "");
        if (y0.pitchUp)
          c6.push(((B8 = H.keyPitchUp.triggers[0]) === null || B8 === void 0 ? void 0 : B8.code) || "");
        if (y0.pitchDown)
          c6.push(((Z6 = H.keyPitchDown.triggers[0]) === null || Z6 === void 0 ? void 0 : Z6.code) || "");
        if (y0.yawLeft)
          c6.push(((t6 = H.keyYawLeft.triggers[0]) === null || t6 === void 0 ? void 0 : t6.code) || "");
        if (y0.yawRight)
          c6.push(((D2 = H.keyYawRight.triggers[0]) === null || D2 === void 0 ? void 0 : D2.code) || "");
      } else
        c6.push(W2);
      for (let HZ of c6)
        if (e1.matchKey(H.keyMoveForward, HZ, I1, z2))
          y0.moveForward = 0;
        else if (e1.matchKey(H.keyMoveBack, HZ, I1, z2))
          y0.moveBack = 0;
        else if (e1.matchKey(H.keyMoveLeft, HZ, I1, z2))
          y0.moveLeft = 0;
        else if (e1.matchKey(H.keyMoveRight, HZ, I1, z2))
          y0.moveRight = 0;
        else if (e1.matchKey(H.keyMoveUp, HZ, I1, z2))
          y0.moveUp = 0;
        else if (e1.matchKey(H.keyMoveDown, HZ, I1, z2))
          y0.moveDown = 0;
        else if (e1.matchKey(H.keyRollLeft, HZ, I1, z2))
          y0.rollLeft = 0;
        else if (e1.matchKey(H.keyRollRight, HZ, I1, z2))
          y0.rollRight = 0;
        else if (e1.matchKey(H.keyPitchUp, HZ, I1, z2))
          y0.pitchUp = 0;
        else if (e1.matchKey(H.keyPitchDown, HZ, I1, z2))
          y0.pitchDown = 0;
        else if (e1.matchKey(H.keyYawLeft, HZ, I1, z2))
          y0.yawLeft = 0;
        else if (e1.matchKey(H.keyYawRight, HZ, I1, z2))
          y0.yawRight = 0;
      if (e1.matchKey(H.boostMove, W2, I1, z2))
        y0.boostMove = 0;
    }
    function R8() {
      M.sub(F1, X.position, X.target);
      let I1 = Math.max(X.state.minNear, K.minDistance);
      M.setMagnitude(F1, F1, I1), M.sub(X.target, X.position, F1);
      let W2 = M.distance(X.position, Y.boundingSphereVisible.center);
      X.setState({ minFar: W2 + Y.boundingSphereVisible.radius });
    }
    function w0() {
      let { center: I1, radius: W2 } = Y.boundingSphereVisible;
      if (M.distance(X.position, I1) > W2) {
        let p8 = X.getFocus(I1, W2);
        X.setState({ ...p8, minFar: 0 });
      } else
        X.setState({
          minFar: 0,
          radius: Y.boundingSphereVisible.radius
        });
    }
    function P0(I1) {
      if (I1)
        R8();
      else
        w0();
    }
    function l0() {
      y0.moveForward = 0, y0.moveBack = 0, y0.moveLeft = 0, y0.moveRight = 0, y0.moveUp = 0, y0.moveDown = 0, y0.rollLeft = 0, y0.rollRight = 0, y0.pitchUp = 0, y0.pitchDown = 0, y0.yawLeft = 0, y0.yawRight = 0, y0.boostMove = 0;
    }
    function z1() {
      l0();
    }
    function J2() {
      if (q)
        return;
      q = !0, U.unsubscribe(), E.unsubscribe(), R.unsubscribe(), F.unsubscribe(), z.unsubscribe(), D.unsubscribe(), A.unsubscribe(), B.unsubscribe(), T.unsubscribe();
    }
    let N2 = h0.create(0.005, 0);
    function X8(I1) {
      if (K.animate.name !== "spin" || K.animate.params.speed === 0 || w)
        return;
      let W2 = 2 * Math.PI * K.animate.params.speed / 1000;
      N2[0] = I1 * W2 / Q0(), h0.add(S, I, N2);
    }
    let c0 = 0, M1 = h0.create(0.005, 0);
    function g1(I1) {
      if (K.animate.name !== "rock" || K.animate.params.speed === 0 || w)
        return;
      let W2 = I1 / 1000 * K.animate.params.speed, z2 = _8(K.animate.params.angle) / Q0(), p8 = Math.sin(c0 * Math.PI * 2) * z2, W6 = Math.sin((c0 + W2) * Math.PI * 2) * z2;
      if (M1[0] = W6 - p8, h0.add(S, I, M1), c0 += W2, c0 >= 1)
        c0 = 0;
    }
    function l2() {
      c0 = 0;
    }
    function d8(I1) {
      _1 = -1, a1(I1);
    }
    return {
      viewport: N,
      get isAnimating() {
        return K.animate.name !== "off";
      },
      get isMoving() {
        return y0.moveForward === 1 || y0.moveBack === 1 || y0.moveLeft === 1 || y0.moveRight === 1 || y0.moveUp === 1 || y0.moveDown === 1 || y0.rollLeft === 1 || y0.rollRight === 1 || y0.pitchUp === 1 || y0.pitchDown === 1 || y0.yawLeft === 1 || y0.yawRight === 1;
      },
      get props() {
        return K;
      },
      setProps: (I1) => {
        var W2;
        if (((W2 = I1.animate) === null || W2 === void 0 ? void 0 : W2.name) === "rock" && K.animate.name !== "rock")
          l2();
        if (I1.flyMode !== void 0 && I1.flyMode !== K.flyMode)
          if (I1.flyMode)
            R8();
          else
            w0();
        Object.assign(K, I1);
      },
      get attribs() {
        return G;
      },
      setAttribs: (I1) => {
        Object.assign(G, I1), Object.assign(H, G.bindings);
      },
      start: d8,
      update: a1,
      reset: U2,
      dispose: J2
    };
  }
  Z.create = J;
})(Wx || (Wx = {}));

// node_modules/molstar/lib/mol-gl/object3d.js
var Kx;
(function(Z) {
  function J() {
    return {
      view: e.identity(),
      position: M.create(0, 0, 0),
      direction: M.create(0, 0, -1),
      up: M.create(0, 1, 0)
    };
  }
  Z.create = J;
})(Kx || (Kx = {}));

// node_modules/molstar/lib/mol-gl/commit-queue.js
class Me {
  constructor() {
    this.removeList = d_(), this.removeMap = /* @__PURE__ */ new Map, this.addList = d_(), this.addMap = /* @__PURE__ */ new Map;
  }
  get isEmpty() {
    return this.removeList.count === 0 && this.addList.count === 0;
  }
  get size() {
    return this.removeMap.size + this.addMap.size;
  }
  add(Z) {
    if (this.removeMap.has(Z)) {
      let $ = this.removeMap.get(Z);
      this.removeMap.delete(Z), this.removeList.remove($);
    }
    if (this.addMap.has(Z))
      return;
    let J = this.addList.addLast(Z);
    this.addMap.set(Z, J);
  }
  remove(Z) {
    if (this.addMap.has(Z)) {
      let $ = this.addMap.get(Z);
      this.addMap.delete(Z), this.addList.remove($);
    }
    if (this.removeMap.has(Z))
      return;
    let J = this.removeList.addLast(Z);
    this.removeMap.set(Z, J);
  }
  tryGetRemove() {
    let Z = this.removeList.removeFirst();
    if (Z)
      this.removeMap.delete(Z);
    return Z;
  }
  tryGetAdd() {
    let Z = this.addList.removeFirst();
    if (Z)
      this.addMap.delete(Z);
    return Z;
  }
}

// node_modules/molstar/lib/mol-gl/scene.js
var aV = new $J("98");
function Nw0(Z, J, $) {
  aV.reset();
  for (let X = 0, Y = Z.length;X < Y; ++X) {
    if ($ && !Z[X].state.visible)
      continue;
    if (!Z[X].values.drawCount.ref.value)
      continue;
    let Q = Z[X].values.boundingSphere.ref.value;
    if (!Q.radius)
      continue;
    aV.includeSphere(Q);
  }
  aV.finishedIncludeStep();
  for (let X = 0, Y = Z.length;X < Y; ++X) {
    if ($ && !Z[X].state.visible)
      continue;
    if (!Z[X].values.drawCount.ref.value)
      continue;
    let Q = Z[X].values.boundingSphere.ref.value;
    if (!Q.radius)
      continue;
    aV.radiusSphere(Q);
  }
  return aV.getSphere(J);
}
function DN1(Z, J) {
  let $ = Z.getProgram("color").id, X = J.getProgram("color").id, Y = Z.materialId, Q = J.materialId;
  if ($ !== X)
    return $ - X;
  else if (Y !== Q)
    return Y - Q;
  else
    return Z.id - J.id;
}
var s3;
(function(Z) {
  function J($, X = "blended", Y = { dColorMarker: !0, dLightCount: 1 }) {
    let Q = /* @__PURE__ */ new Map, W = [], K = C0(), G = C0(), H = [], N = [], q = !0, U = !0, F = !0, E = !0, R = !0, z = !0, D = !0, A = 0, B = 0, T = 0, w = 0, V = !1, P = Kx.create(), { view: I, position: S, direction: f, up: v } = P;
    function h(F0) {
      if (!Q.has(F0)) {
        let t = JO0($, F0, X, Y);
        if (W.push(t), F0.type === "direct-volume")
          N.push(t);
        else
          H.push(t);
        Q.set(F0, t), q = !0, U = !0;
      } else
        console.warn(`RenderObject with id '${F0.id}' already present`);
    }
    function x(F0) {
      let t = Q.get(F0);
      if (t)
        t.dispose(), L3(W, t), L3(H, t), L3(N, t), Q.delete(F0), q = !0, U = !0;
    }
    let b = 100;
    function g(F0) {
      let t = m6(), Z0 = 0;
      while (!0) {
        let U0 = m.tryGetRemove();
        if (!U0)
          break;
        if (x(U0), ++Z0 % b === 0 && m6() - t > F0)
          return !1;
      }
      while (!0) {
        let U0 = m.tryGetAdd();
        if (!U0)
          break;
        if (h(U0), ++Z0 % b === 0 && m6() - t > F0)
          return !1;
      }
      return W.sort(DN1), F = !0, E = !0, R = !0, z = !0, D = !0, !0;
    }
    let m = new Me, i = -1;
    function r() {
      let F0 = 23;
      for (let t = 0, Z0 = W.length;t < Z0; ++t) {
        if (!W[t].state.visible)
          continue;
        F0 = 31 * F0 + W[t].id | 0;
      }
      if (F0 = bS(F0), F0 === -1)
        F0 = 0;
      return F0;
    }
    function Y0() {
      let F0 = r();
      if (F0 !== i)
        return U = !0, F = !0, E = !0, R = !0, z = !0, D = !0, i = F0, !0;
      else
        return !1;
    }
    function c() {
      if (H.length === 0)
        return 0;
      let F0 = 0, t = 0;
      for (let Z0 = 0, U0 = H.length;Z0 < U0; ++Z0) {
        if (!H[Z0].state.visible)
          continue;
        t += H[Z0].values.markerAverage.ref.value, F0 += 1;
      }
      return F0 > 0 ? t / F0 : 0;
    }
    function n() {
      if (H.length === 0)
        return 0;
      let F0 = 0, t = 0;
      for (let Z0 = 0, U0 = H.length;Z0 < U0; ++Z0) {
        if (!H[Z0].state.visible)
          continue;
        t += H[Z0].values.emissiveAverage.ref.value + H[Z0].values.uEmissive.ref.value, F0 += 1;
      }
      return F0 > 0 ? t / F0 : 0;
    }
    function l() {
      var F0, t, Z0;
      if (H.length === 0)
        return 0;
      let U0 = 0, a = 0;
      for (let Q0 = 0, $0 = H.length;Q0 < $0; ++Q0) {
        let R0 = H[Q0];
        if (!R0.state.visible)
          continue;
        let X0 = x8(R0.values.alpha.ref.value * R0.state.alphaFactor, 0, 1), E0 = ((F0 = R0.values.dXrayShaded) === null || F0 === void 0 ? void 0 : F0.ref.value) === "on" || ((t = R0.values.dXrayShaded) === null || t === void 0 ? void 0 : t.ref.value) === "inverted" ? 0.5 : 1, V0 = ((Z0 = R0.values.dPointStyle) === null || Z0 === void 0 ? void 0 : Z0.ref.value) === "fuzzy" ? 0.5 : 1, u0 = R0.values.dGeometryType.ref.value === "text" ? 0.5 : 1, N0 = R0.values.dGeometryType.ref.value === "image" ? 0.5 : 1;
        a += (1 - R0.values.transparencyAverage.ref.value) * X0 * E0 * V0 * u0 * N0, U0 += 1;
      }
      return U0 > 0 ? a / U0 : 0;
    }
    function u() {
      var F0, t, Z0;
      if (H.length === 0)
        return 1;
      let U0 = 1, a = [];
      for (let Q0 = 0, $0 = H.length;Q0 < $0; ++Q0) {
        let R0 = H[Q0];
        if (!R0.state.visible)
          continue;
        a.length = 0;
        let X0 = x8(R0.values.alpha.ref.value * R0.state.alphaFactor, 0, 1);
        if (X0 < 1)
          a.push(1 - X0);
        if (((F0 = R0.values.dXrayShaded) === null || F0 === void 0 ? void 0 : F0.ref.value) === "on" || ((t = R0.values.dXrayShaded) === null || t === void 0 ? void 0 : t.ref.value) === "inverted" || ((Z0 = R0.values.dPointStyle) === null || Z0 === void 0 ? void 0 : Z0.ref.value) === "fuzzy" || R0.values.dGeometryType.ref.value === "text" || R0.values.dGeometryType.ref.value === "image")
          a.push(0.5);
        if (R0.values.transparencyMin.ref.value > 0)
          a.push(R0.values.transparencyMin.ref.value);
        U0 = Math.min(U0, ...a);
      }
      return U0;
    }
    function G0() {
      var F0;
      if (H.length === 0)
        return !1;
      for (let t = 0, Z0 = H.length;t < Z0; ++t) {
        let U0 = H[t];
        if (!U0.state.visible)
          continue;
        if (U0.state.opaque)
          return !0;
        if (U0.state.alphaFactor === 1 && U0.values.alpha.ref.value === 1 && U0.values.transparencyAverage.ref.value !== 1)
          return !0;
        if (((F0 = U0.values.dTransparentBackfaces) === null || F0 === void 0 ? void 0 : F0.ref.value) === "opaque")
          return !0;
      }
      return !1;
    }
    return {
      view: I,
      position: S,
      direction: f,
      up: v,
      renderables: W,
      primitives: { view: I, position: S, direction: f, up: v, renderables: H },
      volumes: { view: I, position: S, direction: f, up: v, renderables: N },
      syncVisibility: Y0,
      setTransparency: (F0) => {
        X = F0;
        for (let t = 0, Z0 = W.length;t < Z0; ++t)
          W[t].setTransparency(F0);
      },
      setGlobals: (F0) => {
        Y = F0;
        for (let t of W)
          C.updateIfChanged(t.values.dColorMarker, F0.dColorMarker), C.updateIfChanged(t.values.dLightCount, F0.dLightCount), t.update();
      },
      update(F0, t) {
        var Z0;
        if (F0)
          for (let U0 = 0, a = F0.length;U0 < a; ++U0)
            (Z0 = Q.get(F0[U0])) === null || Z0 === void 0 || Z0.update();
        else
          for (let U0 = 0, a = W.length;U0 < a; ++U0)
            W[U0].update();
        if (!t)
          q = !0, U = !0;
        else
          Y0();
        F = !0, E = !0, R = !0, z = !0, D = !0;
      },
      add: (F0) => m.add(F0),
      remove: (F0) => m.remove(F0),
      commit: (F0 = Number.MAX_VALUE) => g(F0),
      get commitQueueSize() {
        return m.size;
      },
      get needsCommit() {
        return !m.isEmpty;
      },
      has: (F0) => {
        return Q.has(F0);
      },
      clear: () => {
        for (let F0 = 0, t = W.length;F0 < t; ++F0)
          W[F0].dispose();
        W.length = 0, H.length = 0, N.length = 0, Q.clear(), q = !0, U = !0;
      },
      forEach: (F0) => {
        Q.forEach(F0);
      },
      get count() {
        return W.length;
      },
      get boundingSphere() {
        if (q)
          Nw0(W, K, !1), q = !1;
        return K;
      },
      get boundingSphereVisible() {
        if (U)
          Nw0(W, G, !0), U = !1;
        return G;
      },
      get transparency() {
        return X;
      },
      get markerAverage() {
        if (F)
          A = c(), F = !1;
        return A;
      },
      get emissiveAverage() {
        if (E)
          B = n(), E = !1;
        return B;
      },
      get opacityAverage() {
        if (R)
          T = l(), R = !1;
        return T;
      },
      get transparencyMin() {
        if (z)
          w = u(), z = !1;
        return w;
      },
      get hasOpaque() {
        if (D)
          V = G0(), D = !1;
        return V;
      }
    };
  }
  Z.create = J;
})(s3 || (s3 = {}));

// node_modules/molstar/lib/mol-canvas3d/camera/transition.js
class mz {
  get source() {
    return this._source;
  }
  get target() {
    return this._target;
  }
  apply(Z, J = 0, $) {
    if (!this.inTransition || J > 0)
      O6.copySnapshot(this._source, this.camera.state);
    if (!this.inTransition)
      O6.copySnapshot(this._target, this.camera.state);
    if (O6.copySnapshot(this._target, Z), this._target.radius > this._target.radiusMax)
      this._target.radius = this._target.radiusMax;
    if (this._target.radius < 0.01)
      this._target.radius = 0.01;
    if (this._target.radiusMax < 0.01)
      this._target.radiusMax = 0.01;
    if (!this.inTransition && J <= 0 || typeof Z.mode !== "undefined" && Z.mode !== this.camera.state.mode) {
      this.finish(this._target);
      return;
    }
    if (this.inTransition = !0, this.func = $ || mz.defaultTransition, !this.inTransition || J > 0)
      this.start = this.t, this.durationMs = J;
  }
  tick(Z) {
    this.t = Z, this.update();
  }
  finish(Z) {
    O6.copySnapshot(this.camera.state, Z), this.inTransition = !1;
  }
  update() {
    if (!this.inTransition)
      return;
    let Z = Math.min((this.t - this.start) / this.durationMs, 1);
    if (Z === 1) {
      this.finish(this._target);
      return;
    }
    this.func(this._current, Z, this._source, this._target), O6.copySnapshot(this.camera.state, this._current);
  }
  constructor(Z) {
    this.camera = Z, this.t = 0, this.func = mz.defaultTransition, this.start = 0, this.inTransition = !1, this.durationMs = 0, this._source = O6.createDefaultSnapshot(), this._target = O6.createDefaultSnapshot(), this._current = O6.createDefaultSnapshot();
  }
}
(function(Z) {
  let J = k8.identity(), $ = k8.identity(), X = M(), Y = M();
  function Q(W, K, G, H) {
    O6.copySnapshot(W, H), k8.slerp(J, k8.Identity, k8.rotationTo(J, G.up, H.up), K), M.transformQuat(W.up, G.up, J), M.lerp(W.target, G.target, H.target, K);
    let N = M.distance(G.target, G.position), q = M.distance(H.target, H.position), U = pZ(N, q, K);
    M.sub(X, G.position, G.target), M.normalize(X, X), M.sub(Y, H.position, H.target), M.normalize(Y, Y), k8.rotationTo($, X, Y), k8.slerp($, k8.Identity, $, K), M.transformQuat(X, X, $), M.scale(X, X, U), M.add(W.position, W.target, X), W.radius = pZ(G.radius, H.radius, K), W.radiusMax = pZ(G.radiusMax, H.radiusMax, K), W.fov = pZ(G.fov, H.fov, K), W.fog = pZ(G.fog, H.fog, K);
  }
  Z.defaultTransition = Q;
})(mz || (mz = {}));

// node_modules/molstar/lib/mol-canvas3d/camera.js
var qw0 = E2();

class O6 {
  get position() {
    return this.state.position;
  }
  set position(Z) {
    M.copy(this.state.position, Z);
  }
  get up() {
    return this.state.up;
  }
  set up(Z) {
    M.copy(this.state.up, Z);
  }
  get target() {
    return this.state.target;
  }
  set target(Z) {
    M.copy(this.state.target, Z);
  }
  update() {
    let Z = this.state;
    if (Z.radiusMax === 0)
      return !1;
    let J = M.distance(Z.position, Z.target), $ = this.minTargetDistance / this.scale;
    if (J < $)
      M.sub(this.deltaDirection, Z.target, Z.position), M.setMagnitude(this.deltaDirection, this.deltaDirection, $), M.sub(Z.position, Z.target, this.deltaDirection);
    let X = 2 * Math.tan(Z.fov / 2) * M.distance(Z.position, Z.target) * this.scale;
    switch (this.zoom = this.viewport.height / X, BN1(this), this.state.mode) {
      case "orthographic":
        MN1(this);
        break;
      case "perspective":
        AN1(this);
        break;
      default:
        T8(this.state.mode);
    }
    let Y = !e.areEqual(this.projection, this.prevProjection, u8) || !e.areEqual(this.view, this.prevView, u8);
    if (Y) {
      if (e.mul(this.projectionView, this.projection, this.view), !e.tryInvert(this.inverseProjectionView, this.projectionView))
        return e.copy(this.view, this.prevView), e.copy(this.projection, this.prevProjection), e.mul(this.projectionView, this.projection, this.view), !1;
      e.copy(this.prevView, this.view), e.copy(this.prevProjection, this.projection);
    }
    return Y;
  }
  setState(Z, J) {
    this.transition.apply(Z, J), this.stateChanged.next(Z);
  }
  getSnapshot() {
    return O6.copySnapshot(O6.createDefaultSnapshot(), this.state);
  }
  getTargetDistance(Z) {
    return Math.max(this.minTargetDistance / this.scale, O6.targetDistance(Z, this.state.mode, this.state.fov, this.viewport.width, this.viewport.height));
  }
  getFocus(Z, J, $, X, Y) {
    var Q, W;
    let K = Math.max(J, 0.01), G = this.getTargetDistance(K);
    if (M.sub(this.deltaDirection, (Q = Y === null || Y === void 0 ? void 0 : Y.target) !== null && Q !== void 0 ? Q : this.target, (W = Y === null || Y === void 0 ? void 0 : Y.position) !== null && W !== void 0 ? W : this.position), X)
      M.matchDirection(this.deltaDirection, X, this.deltaDirection);
    M.setMagnitude(this.deltaDirection, this.deltaDirection, G), M.sub(this.newPosition, Z, this.deltaDirection);
    let H = O6.copySnapshot(O6.createDefaultSnapshot(), this.state);
    if (H.target = M.clone(Z), H.radius = K, H.position = M.clone(this.newPosition), $)
      M.matchDirection(H.up, $, H.up);
    return H;
  }
  getCenter(Z, J) {
    M.sub(this.deltaDirection, this.target, this.position), M.sub(this.newPosition, Z, this.deltaDirection);
    let $ = O6.copySnapshot(O6.createDefaultSnapshot(), this.state);
    if ($.target = M.clone(Z), $.position = M.clone(this.newPosition), J)
      $.radius = Math.max(J, 0.01);
    return $;
  }
  getInvariantFocus(Z, J, $, X) {
    let Y = Math.max(J, 0.01), Q = this.getTargetDistance(Y);
    M.copy(this.deltaDirection, X), M.setMagnitude(this.deltaDirection, this.deltaDirection, Q), M.sub(this.newPosition, Z, this.deltaDirection);
    let W = O6.copySnapshot(O6.createDefaultSnapshot(), this.state);
    return W.target = M.clone(Z), W.radius = Y, W.position = M.clone(this.newPosition), M.copy(W.up, $), W;
  }
  focus(Z, J, $, X, Y) {
    if (J > 0)
      this.setState(this.getFocus(Z, J, X, Y), $);
  }
  center(Z, J) {
    this.setState(this.getCenter(Z), J);
  }
  project(Z, J) {
    return $x(Z, J, this.viewport, this.projectionView);
  }
  unproject(Z, J) {
    return Rq(Z, J, this.viewport, this.inverseProjectionView);
  }
  getPixelSize(Z) {
    this.project(qw0, Z);
    let J = qw0[3], $ = this.viewport.width, X = this.projection[0];
    return 2 / J / ($ * Math.abs(X));
  }
  getRay(Z, J, $) {
    if (this.state.mode === "orthographic")
      M.set(Z.origin, J, $, 0), this.unproject(Z.origin, Z.origin), M.normalize(Z.direction, M.sub(Z.direction, this.target, this.position)), M.scaleAndAdd(Z.origin, Z.origin, Z.direction, -this.near);
    else
      M.copy(Z.origin, this.state.position), M.scale(Z.origin, Z.origin, this.scale), M.set(Z.direction, J, $, 0.5), this.unproject(Z.direction, Z.direction), M.normalize(Z.direction, M.sub(Z.direction, Z.direction, Z.origin));
    return Z;
  }
  constructor(Z, J = bZ.create(0, 0, 128, 128)) {
    this.view = e.identity(), this.projection = e.identity(), this.projectionView = e.identity(), this.inverseProjectionView = e.identity(), this.headRotation = e.zero(), this.viewEye = e.zero(), this.isAsymmetricProjection = !1, this.state = O6.createDefaultSnapshot(), this.viewOffset = O6.ViewOffset(), this.disabled = !1, this.near = 1, this.far = 1e4, this.fogNear = 5000, this.fogFar = 1e4, this.zoom = 1, this.forceFull = !1, this.scale = 1, this.minTargetDistance = 0, this.transition = new mz(this), this.stateChanged = new G$(this.state), this.prevProjection = e.identity(), this.prevView = e.identity(), this.deltaDirection = M(), this.newPosition = M(), this.viewport = J, O6.copySnapshot(this.state, Z);
  }
}
(function(Z) {
  function J() {
    return {
      enabled: !1,
      fullWidth: 1,
      fullHeight: 1,
      offsetX: 0,
      offsetY: 0,
      width: 1,
      height: 1
    };
  }
  Z.ViewOffset = J;
  function $(G, H, N, q, U, F, E) {
    G.fullWidth = H, G.fullHeight = N, G.offsetX = q, G.offsetY = U, G.width = F, G.height = E;
  }
  Z.setViewOffset = $;
  function X(G, H) {
    G.enabled = H.enabled, G.fullWidth = H.fullWidth, G.fullHeight = H.fullHeight, G.offsetX = H.offsetX, G.offsetY = H.offsetY, G.width = H.width, G.height = H.height;
  }
  Z.copyViewOffset = X;
  function Y(G, H, N, q, U) {
    let F = Math.max(G, 0.01), E = q / U, R = U < q ? 1 : E;
    if (H === "orthographic")
      return Math.abs(F / R / Math.tan(N / 2));
    else
      return Math.abs(F / R / Math.sin(N / 2));
  }
  Z.targetDistance = Y;
  function Q() {
    return {
      mode: "perspective",
      fov: Math.PI / 4,
      position: M.create(0, 0, 100),
      up: M.create(0, 1, 0),
      target: M.create(0, 0, 0),
      radius: 0,
      radiusMax: 10,
      fog: 50,
      clipFar: !0,
      minNear: 5,
      minFar: 0
    };
  }
  Z.createDefaultSnapshot = Q;
  function W(G, H) {
    if (!H)
      return G;
    if (typeof H.mode !== "undefined")
      G.mode = H.mode;
    if (typeof H.fov !== "undefined")
      G.fov = H.fov;
    if (typeof H.position !== "undefined")
      M.copy(G.position, H.position);
    if (typeof H.up !== "undefined")
      M.copy(G.up, H.up);
    if (typeof H.target !== "undefined")
      M.copy(G.target, H.target);
    if (typeof H.radius !== "undefined")
      G.radius = H.radius;
    if (typeof H.radiusMax !== "undefined")
      G.radiusMax = H.radiusMax;
    if (typeof H.fog !== "undefined")
      G.fog = H.fog;
    if (typeof H.clipFar !== "undefined")
      G.clipFar = H.clipFar;
    if (typeof H.minNear !== "undefined")
      G.minNear = H.minNear;
    if (typeof H.minFar !== "undefined")
      G.minFar = H.minFar;
    return G;
  }
  Z.copySnapshot = W;
  function K(G, H) {
    return G.mode === H.mode && G.fov === H.fov && G.radius === H.radius && G.radiusMax === H.radiusMax && G.fog === H.fog && G.clipFar === H.clipFar && G.minNear === H.minNear && G.minFar === H.minFar && M.exactEquals(G.position, H.position) && M.exactEquals(G.up, H.up) && M.exactEquals(G.target, H.target);
  }
  Z.areSnapshotsEqual = K;
})(O6 || (O6 = {}));
var Gx = M(), Hx = M();
function Fw0(Z) {
  if (Z.scale === 1)
    e.lookAt(Z.view, Z.state.position, Z.state.target, Z.state.up);
  else
    M.scale(Gx, Z.state.position, Z.scale), M.scale(Hx, Z.state.target, Z.scale), e.lookAt(Z.view, Gx, Hx, Z.state.up);
}
function MN1(Z) {
  let { viewport: J, zoom: $, near: X, far: Y, viewOffset: Q } = Z, W = -J.width / 2, K = J.width / 2, G = J.height / 2, H = -J.height / 2, N = (K - W) / (2 * $), q = (G - H) / (2 * $), U = (K + W) / 2, F = (G + H) / 2, E = U - N, R = U + N, z = F + q, D = F - q;
  if (Q.enabled) {
    let A = $ / (Q.width / Q.fullWidth), B = $ / (Q.height / Q.fullHeight), T = (K - W) / Q.width, w = (G - H) / Q.height;
    E += T * (Q.offsetX / A), R = E + T * (Q.width / A), z -= w * (Q.offsetY / B), D = z - w * (Q.height / B);
  }
  e.ortho(Z.projection, E, R, z, D, X, Y), Fw0(Z);
}
function AN1(Z) {
  let J = Z.viewport.width / Z.viewport.height, { near: $, far: X, viewOffset: Y } = Z, Q = $ * Math.tan(0.5 * Z.state.fov), W = 2 * Q, K = J * W, G = -0.5 * K;
  if (Y.enabled)
    G += Y.offsetX * K / Y.fullWidth, Q -= Y.offsetY * W / Y.fullHeight, K *= Y.width / Y.fullWidth, W *= Y.height / Y.fullHeight;
  e.perspective(Z.projection, G, G + K, Q, Q - W, $, X), Fw0(Z);
}
function BN1(Z) {
  let { forceFull: J, scale: $ } = Z, { radius: X, radiusMax: Y, mode: Q, fog: W, clipFar: K, minNear: G, minFar: H } = Z.state;
  if (Y *= $, H *= $, G *= $, X *= $, J)
    X = Y;
  let N = 0.01 * $;
  if (X < N)
    X = N;
  let q = Math.max(K ? X : Y, H);
  M.scale(Hx, Z.state.target, $), M.scale(Gx, Z.state.position, $);
  let U = M.distance(Gx, Hx), F = J ? 0.01 : U - X, E = U + q;
  if (J)
    G = F;
  if (Q === "perspective")
    F = Math.max(Math.min(Y, G), F), E = Math.max(G, E);
  else
    F = Math.max(Math.min(Y, G), F), E = Math.max(G, E);
  if (F === E)
    E = F + 0.01 * $;
  let R = -(50 - W) / 50, z = U - q * R, D = E;
  Z.near = F, Z.far = E, Z.fogNear = z, Z.fogFar = D;
}

// node_modules/molstar/lib/mol-canvas3d/helper/bounding-sphere-helper.js
var rV = {
  sceneBoundingSpheres: j.Boolean(!1, { description: "Show full scene bounding spheres." }),
  visibleSceneBoundingSpheres: j.Boolean(!1, { description: "Show visible scene bounding spheres." }),
  objectBoundingSpheres: j.Boolean(!1, { description: "Show bounding spheres of visible render objects." }),
  instanceBoundingSpheres: j.Boolean(!1, { description: "Show bounding spheres of visible instances." })
};

class Ae {
  constructor(Z, J, $) {
    this.objectsData = /* @__PURE__ */ new Map, this.instancesData = /* @__PURE__ */ new Map, this.scene = s3.create(Z, "blended"), this.parent = J, this._props = { ...j.getDefaultValues(rV), ...$ };
  }
  update() {
    let Z = Nx(this.scene, this.parent.boundingSphere, this.sceneData, c2.lightgrey, jN1);
    if (Z)
      this.sceneData = Z;
    let J = Nx(this.scene, this.parent.boundingSphereVisible, this.visibleSceneData, c2.black, TN1);
    if (J)
      this.visibleSceneData = J;
    this.parent.forEach(($, X) => {
      let Y = this.objectsData.get(X), Q = Nx(this.scene, $.values.boundingSphere.ref.value, Y, c2.tomato, _N1);
      if (Q)
        this.objectsData.set(X, Q);
      let W = this.instancesData.get(X), K = Nx(this.scene, $.values.invariantBoundingSphere.ref.value, W, c2.skyblue, VN1, {
        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,
        instanceGrid: X.values.instanceGrid
      });
      if (K)
        this.instancesData.set(X, K);
    }), this.objectsData.forEach(($, X) => {
      if (!this.parent.has(X))
        this.scene.remove($.renderObject), this.objectsData.delete(X);
    }), this.instancesData.forEach(($, X) => {
      if (!this.parent.has(X))
        this.scene.remove($.renderObject), this.instancesData.delete(X);
    }), this.scene.update(void 0, !1), this.scene.commit();
  }
  syncVisibility() {
    if (this.sceneData)
      this.sceneData.renderObject.state.visible = this._props.sceneBoundingSpheres;
    if (this.visibleSceneData)
      this.visibleSceneData.renderObject.state.visible = this._props.visibleSceneBoundingSpheres;
    this.parent.forEach((Z, J) => {
      let $ = this.objectsData.get(J);
      if ($)
        $.renderObject.state.visible = J.state.visible && this._props.objectBoundingSpheres;
      let X = this.instancesData.get(J);
      if (X)
        X.renderObject.state.visible = J.state.visible && this._props.instanceBoundingSpheres;
    });
  }
  clear() {
    this.sceneData = void 0, this.objectsData.clear(), this.scene.clear();
  }
  get isEnabled() {
    return this._props.sceneBoundingSpheres || this._props.visibleSceneBoundingSpheres || this._props.objectBoundingSpheres || this._props.instanceBoundingSpheres;
  }
  get props() {
    return this._props;
  }
  setProps(Z) {
    if (Object.assign(this._props, Z), this.isEnabled)
      this.update();
  }
}
function Nx(Z, J, $, X, Y, Q) {
  if (!$ || !C0.equals($.boundingSphere, J)) {
    let W = wN1(J, $ && $.mesh), K = $ ? $.renderObject : IN1(W, X, Y, Q);
    if ($)
      C.updateIfChanged(K.values.drawCount, n7.getDrawCount(W));
    else
      Z.add(K);
    return { boundingSphere: C0.clone(J), renderObject: K, mesh: W };
  }
}
function wN1(Z, J) {
  let X = _5(2), Y = v1.createState(X, X / 2, J);
  if (Z.radius) {
    if (g8(Y, Z.center, Z.radius, 2), C0.hasExtrema(Z))
      for (let Q of Z.extrema)
        g8(Y, Q, 1, 0);
  }
  return v1.getMesh(Y);
}
var jN1 = bW(), TN1 = bW(), _N1 = bW(), VN1 = bW();
function IN1(Z, J, $, X) {
  let Y = n1.Utils.createValuesSimple(Z, { alpha: 0.1, doubleSided: !1, cellSize: 0, batchSize: 0 }, J, 1, X);
  return v3("mesh", Y, { disposed: !1, visible: !0, alphaFactor: 1, pickable: !1, colorOnly: !1, opaque: !1, writeDepth: !1 }, $);
}

// node_modules/molstar/lib/mol-canvas3d/helper/interaction-events.js
var Be = M(), we = M(), Uw0 = M(), je = {
  maxFps: j.Numeric(30, { min: 10, max: 60, step: 10 }),
  preferAtomPixelPadding: j.Numeric(3, { min: 0, max: 20, step: 1 }, { description: "Number of extra pixels at which to prefer atoms over bonds." }),
  convertCoordsToRay: j.Boolean(!1, { description: "Convert screen coordinates to ray for picking." })
};

class Te {
  setProps(Z) {
    Object.assign(this.props, Z);
  }
  getTarget() {
    if (this.ray)
      return this.ray;
    else if (this.props.convertCoordsToRay)
      return this.camera.getRay(GQ(), this.endX, this.input.height - this.endY);
    else
      return h0.create(this.endX, this.endY);
  }
  handleMove() {
    if (this.startX !== this.endX || this.startY !== this.endY || this.input.pointerLock && !this.controls.isMoving)
      this.pickData = this.canvasAsyncIdentify(this.getTarget()), this.startX = this.endX, this.startY = this.endY;
  }
  handleClick() {
    let Z = this.canvasIdentify(this.getTarget()), J = this.getLoci(Z === null || Z === void 0 ? void 0 : Z.id, Z === null || Z === void 0 ? void 0 : Z.position);
    this.events.click.next({ current: J, buttons: this.buttons, button: this.button, modifiers: this.modifiers, page: h0.create(this.endX, this.endY), position: Z === null || Z === void 0 ? void 0 : Z.position }), this.prevLoci = J;
  }
  handleDrag() {
    if ((this.startX !== this.endX || this.startY !== this.endY || this.input.pointerLock && !this.controls.isMoving) && !this.outsideViewport(this.startX, this.startY, this.ray))
      this.events.drag.next({ current: this.prevLoci, buttons: this.buttons, button: this.button, modifiers: this.modifiers, pageStart: h0.create(this.startX, this.startY), pageEnd: h0.create(this.endX, this.endY) }), this.startX = this.endX, this.startY = this.endY;
  }
  tick(Z) {
    if (!this.inside)
      return;
    if (this.pickData) {
      let J = this.pickData.tryGet();
      if (J !== "pending") {
        if (this.position = J === null || J === void 0 ? void 0 : J.position, this.inside) {
          let $ = this.getLoci(J === null || J === void 0 ? void 0 : J.id, J === null || J === void 0 ? void 0 : J.position);
          this.events.hover.next({ current: $, buttons: this.buttons, button: this.button, modifiers: this.modifiers, page: h0.create(this.endX, this.endY), position: J === null || J === void 0 ? void 0 : J.position }), this.prevLoci = $;
        }
        this.pickData = void 0;
      }
    }
    if (Z - this.prevT > 1000 / this.props.maxFps)
      if (this.prevT = Z, this.isInteracting)
        this.handleDrag();
      else
        this.handleMove();
  }
  leave() {
    if (this.inside = !1, !V2.Loci.isEmpty(this.prevLoci))
      this.prevLoci = V2.Loci.Empty, this.events.hover.next({ current: this.prevLoci, buttons: this.buttons, button: this.button, modifiers: this.modifiers });
  }
  move(Z, J, $, X, Y, Q) {
    this.inside = !0, this.buttons = $, this.button = X, this.modifiers = Y, this.ray = Q, this.endX = Z, this.endY = J;
  }
  click(Z, J, $, X, Y, Q) {
    this.endX = Z, this.endY = J, this.buttons = $, this.button = X, this.modifiers = Y, this.ray = Q, this.handleClick();
  }
  drag(Z, J, $, X, Y) {
    this.endX = Z, this.endY = J, this.buttons = $, this.button = X, this.modifiers = Y, this.handleDrag();
  }
  modify(Z) {
    if (hJ.areEqual(Z, this.modifiers))
      return;
    this.modifiers = Z, this.events.hover.next({ current: this.prevLoci, buttons: this.buttons, button: this.button, modifiers: this.modifiers, page: h0.create(this.endX, this.endY), position: this.position });
  }
  outsideViewport(Z, J, $) {
    if ($)
      return !1;
    let { input: X, camera: { viewport: Y } } = this;
    return Z *= X.pixelRatio, J *= X.pixelRatio, Z > Y.x + Y.width || X.height - J > Y.y + Y.height || Z < Y.x || X.height - J < Y.y;
  }
  getLoci(Z, J) {
    var $;
    let { repr: X, loci: Y } = this.lociGetter(Z);
    if (J && X && $2.isLoci(Y) && Y.bonds.length === 2) {
      let { aUnit: Q, aIndex: W } = Y.bonds[0];
      Q.conformation.position(Q.elements[W], Be), M.sub(Uw0, this.camera.state.position, this.camera.state.target), M.projectPointOnPlane(we, J, Uw0, Be);
      let K = this.camera.getPixelSize(we), G = X.theme.size.size(Y.bonds[0]) * (($ = X.props.sizeFactor) !== null && $ !== void 0 ? $ : 1);
      if (X.props.lineSizeAttenuation === !1)
        G *= K / 2;
      if (G += this.props.preferAtomPixelPadding * K, M.distance(we, Be) < G)
        return { repr: X, loci: $2.toFirstStructureElementLoci(Y) };
    }
    return { repr: X, loci: Y };
  }
  dispose() {
    this.ev.dispose();
  }
  constructor(Z, J, $, X, Y, Q, W = {}) {
    this.canvasIdentify = Z, this.canvasAsyncIdentify = J, this.lociGetter = $, this.input = X, this.camera = Y, this.controls = Q, this.ev = xQ.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.ray = void 0, this.pickData = void 0, this.position = void 0, this.isInteracting = !1, this.prevLoci = V2.Loci.Empty, this.prevT = 0, this.inside = !1, this.buttons = V8.create(0), this.button = V8.create(0), this.modifiers = hJ.None, this.props = { ...j.getDefaultValues(je), ...W }, X.drag.subscribe(({ x: K, y: G, buttons: H, button: N, modifiers: q }) => {
      this.isInteracting = !0, this.drag(K, G, H, N, q);
    }), X.move.subscribe(({ x: K, y: G, inside: H, buttons: N, button: q, modifiers: U, onElement: F, ray: E }) => {
      if (!H || this.isInteracting)
        return;
      if (!F) {
        this.leave();
        return;
      }
      this.move(K, G, N, q, U, E);
    }), X.leave.subscribe(() => {
      this.leave();
    }), X.click.subscribe(({ x: K, y: G, buttons: H, button: N, modifiers: q, ray: U }) => {
      if (this.outsideViewport(K, G, U))
        return;
      this.click(K, G, H, N, q, U);
    }), X.interactionEnd.subscribe(() => {
      this.isInteracting = !1;
    }), X.modifiers.subscribe((K) => {
      this.modify(K);
    });
  }
}

// node_modules/molstar/lib/mol-gl/shader/postprocessing.frag.js
var Lw0 = `
precision highp float;
precision highp int;
precision highp sampler2D;

uniform sampler2D tSsaoDepth;
uniform sampler2D tSsaoDepthTransparent;
uniform sampler2D tColor;
uniform sampler2D tTransparentColor;
uniform sampler2D tDepthOpaque;
uniform sampler2D tDepthTransparent;
uniform sampler2D tShadows;
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 vec3 uOcclusionColor;
uniform bool uTransparentBackground;
uniform vec2 uOcclusionOffset;

#include common

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

float getDepthOpaque(const in vec2 coords) {
    #ifdef depthTextureSupport
        return texture2D(tDepthOpaque, coords).r;
    #else
        return unpackRGBAToDepth(texture2D(tDepthOpaque, coords));
    #endif
}

float getDepthTransparent(const in vec2 coords) {
    return unpackRGBAToDepthWithAlpha(texture2D(tDepthTransparent, coords)).x;
}

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

int squaredOutlineScale = dOutlineScale * dOutlineScale;
void getOutline(const in vec2 coords, out bool hasOpaque, out bool hasTransparent, out float opaqueDepth, out float transparentDepth, out float alpha) {
    vec2 invTexSize = 1.0 / uTexSize;

    hasOpaque = false;
    hasTransparent = false;
    opaqueDepth = 1.0;
    transparentDepth = 1.0;
    alpha = 0.0;
    for (int y = -dOutlineScale; y <= dOutlineScale; y++) {
        for (int x = -dOutlineScale; x <= dOutlineScale; x++) {
            if (x * x + y * y > squaredOutlineScale) {
                continue;
            }

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

            vec4 sampleOutlineCombined = texture2D(tOutlines, sampleCoords);
            float sampleOpaqueDepth = unpackRGToUnitInterval(sampleOutlineCombined.gb);
            float sampleTransparentDepth = sampleOutlineCombined.a;
            vec2 sampleFlagWithAlpha = unpack2x4(sampleOutlineCombined.r);

            float sampleFlag = sampleFlagWithAlpha.x;
            float sampleAlpha = clamp(sampleFlagWithAlpha.y * 0.5, 0.01, 1.0);

            if ((sampleFlag > 0.20 && sampleFlag < 0.30) || (sampleFlag > 0.70 && sampleFlag < 0.80)) { // transparent || both
                if (sampleOpaqueDepth < opaqueDepth) {
                    hasOpaque = true;
                    opaqueDepth = sampleOpaqueDepth;
                }
            }

            if ((((sampleFlag > 0.45 && sampleFlag < 0.55) || (sampleFlag > 0.70 && sampleFlag < 0.80))) && sampleTransparentDepth < transparentDepth) { // transparent || both
                hasTransparent = true;
                transparentDepth = sampleTransparentDepth;
                alpha = sampleAlpha;
            }
        }
    }
}

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;
}

float getSsaoTransparent(vec2 coords) {
    float rawSsao = unpackRGToUnitInterval(texture2D(tSsaoDepthTransparent, 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 opaqueDepth = getDepthOpaque(coords);
    float transparentDepth = 1.0;
    #ifdef dBlendTransparency
        bool blendTransparency = true;
        vec4 transparentColor = texture2D(tTransparentColor, coords);

        #if defined(dOutlineEnable) || defined(dOcclusionEnable) && defined(dOcclusionIncludeTransparency)
            transparentDepth = getDepthTransparent(coords);
        #endif
    #endif

    #if defined(dOcclusionEnable) || defined(dShadowEnable)
        bool isOpaqueBackground = isBackground(opaqueDepth);
        float viewDist = abs(getViewZ(opaqueDepth));
        float fogFactor = smoothstep(uFogNear, uFogFar, viewDist);
    #endif

    #if defined(dOcclusionEnable)
        if (!isOpaqueBackground) {
            float occlusionFactor = getSsao(coords + uOcclusionOffset);

            if (!uTransparentBackground) {
                color.rgb = mix(mix(uOcclusionColor, uFogColor, fogFactor), color.rgb, occlusionFactor);
            } else {
                color.rgb = mix(uOcclusionColor * (1.0 - fogFactor), color.rgb, occlusionFactor);
            }
        }
        #if defined(dBlendTransparency) && defined(dOcclusionIncludeTransparency)
            if (!isBackground(transparentDepth)) {
                float viewDist = abs(getViewZ(transparentDepth));
                float fogFactor = smoothstep(uFogNear, uFogFar, viewDist);
                float occlusionFactor = getSsaoTransparent(coords + uOcclusionOffset);
                transparentColor.rgb = mix(uOcclusionColor * (1.0 - fogFactor), transparentColor.rgb, occlusionFactor);
            }
        #endif
    #endif

    #ifdef dShadowEnable
        if (!isOpaqueBackground) {
            vec4 shadow = texture2D(tShadows, coords);
            if (!uTransparentBackground) {
                color.rgb = mix(mix(vec3(0), uFogColor, fogFactor), color.rgb, shadow.a);
            } else {
                color.rgb = mix(vec3(0) * (1.0 - fogFactor), color.rgb, shadow.a);
            }
        }
    #endif

    // outline needs to be handled after occlusion and shadow to keep them clean
    #ifdef dOutlineEnable
        bool hasOpaque;
        bool hasTransparent;
        float outlineOpaqueDepth;
        float outlineTransparentDepth;
        float outlineAlpha;
        getOutline(coords, hasOpaque, hasTransparent, outlineOpaqueDepth, outlineTransparentDepth, outlineAlpha);

        if (hasOpaque) {
            float viewDist = abs(getViewZ(outlineOpaqueDepth));
            float fogFactor = smoothstep(uFogNear, uFogFar, viewDist);
            if (!uTransparentBackground) {
                color.rgb = mix(uOutlineColor, uFogColor, fogFactor);
            } else {
                color.a = 1.0 - fogFactor;
                color.rgb = mix(uOutlineColor, vec3(0.0), fogFactor);
            }
        }

        #ifdef dBlendTransparency
            if (hasTransparent) {
                if (hasOpaque && outlineOpaqueDepth < outlineTransparentDepth) {
                    blendTransparency = false;
                } else {
                    float finalOutlineAlpha = clamp(outlineAlpha * 2.0, 0.0, 1.0);
                    float viewDist = abs(getViewZ(outlineTransparentDepth));
                    float fogFactor = smoothstep(uFogNear, uFogFar, viewDist);
                    float finalAlpha = max(transparentColor.a, finalOutlineAlpha * (1.0 - fogFactor));
                    transparentColor.a = finalAlpha;
                    transparentColor.rgb = uOutlineColor * finalAlpha;
                }
            }
        #endif
    #endif

    #ifdef dBlendTransparency
        if (blendTransparency) {
            float alpha = transparentColor.a;
            if (alpha != 0.0) {
                // blending
                color = transparentColor + color * (1.0 - alpha);
            }
        }
    #endif

    gl_FragColor = color;
}
`;

// node_modules/molstar/lib/mol-gl/shader/fxaa.frag.js
var Rw0 = `
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);
}
`;

// node_modules/molstar/lib/mol-canvas3d/passes/fxaa.js
var Ew0 = {
  edgeThresholdMin: j.Numeric(0.0312, { min: 0.0312, max: 0.0833, step: 0.0001 }, { description: "Trims the algorithm from processing darks." }),
  edgeThresholdMax: j.Numeric(0.063, { min: 0.063, max: 0.333, step: 0.001 }, { description: "The minimum amount of local contrast required to apply algorithm." }),
  iterations: j.Numeric(12, { min: 0, max: 16, step: 1 }, { description: "Number of edge exploration steps." }),
  subpixelQuality: j.Numeric(0.3, { min: 0, max: 1, step: 0.01 }, { description: "Choose the amount of sub-pixel aliasing removal." })
};

class _e {
  constructor(Z, J) {
    this.webgl = Z, this.renderable = kN1(Z, J);
  }
  updateState(Z) {
    let { gl: J, state: $ } = this.webgl;
    $.enable(J.SCISSOR_TEST), $.disable(J.BLEND), $.disable(J.DEPTH_TEST), $.depthMask(!1);
    let { x: X, y: Y, width: Q, height: W } = Z;
    $.viewport(X, Y, Q, W), $.scissor(X, Y, Q, W), $.clearColor(0, 0, 0, 1), J.clear(J.COLOR_BUFFER_BIT);
  }
  setSize(Z, J) {
    C.update(this.renderable.values.uTexSizeInv, h0.set(this.renderable.values.uTexSizeInv.ref.value, 1 / Z, 1 / J));
  }
  update(Z, J) {
    let { values: $ } = this.renderable, { edgeThresholdMin: X, edgeThresholdMax: Y, iterations: Q, subpixelQuality: W } = J, K = !1;
    if ($.tColor.ref.value !== Z)
      C.update(this.renderable.values.tColor, Z), K = !0;
    if ($.dEdgeThresholdMin.ref.value !== X)
      K = !0;
    if (C.updateIfChanged($.dEdgeThresholdMin, X), $.dEdgeThresholdMax.ref.value !== Y)
      K = !0;
    if (C.updateIfChanged($.dEdgeThresholdMax, Y), $.dIterations.ref.value !== Q)
      K = !0;
    if (C.updateIfChanged($.dIterations, Q), $.dSubpixelQuality.ref.value !== W)
      K = !0;
    if (C.updateIfChanged($.dSubpixelQuality, W), K)
      this.renderable.update();
  }
  render(Z, J) {
    if (K1)
      this.webgl.timer.mark("FxaaPass.render");
    if (J)
      J.bind();
    else
      this.webgl.bindDrawingBuffer();
    if (this.updateState(Z), this.renderable.render(), K1)
      this.webgl.timer.markEnd("FxaaPass.render");
  }
}
var PN1 = {
  ...A6,
  tColor: o1("texture", "rgba", "ubyte", "linear"),
  uTexSizeInv: _0("v2"),
  dEdgeThresholdMin: p1("number"),
  dEdgeThresholdMax: p1("number"),
  dIterations: p1("number"),
  dSubpixelQuality: p1("number")
}, CN1 = v8("fxaa", p6, Rw0);
function kN1(Z, J) {
  let $ = J.getWidth(), X = J.getHeight(), Y = {
    ...B6,
    tColor: C.create(J),
    uTexSizeInv: C.create(h0.create(1 / $, 1 / X)),
    dEdgeThresholdMin: C.create(0.0312),
    dEdgeThresholdMax: C.create(0.125),
    dIterations: C.create(12),
    dSubpixelQuality: C.create(0.3)
  }, Q = { ...PN1 }, W = t8(Z, "triangles", CN1, Q, Y);
  return e8(W, Y);
}

// node_modules/molstar/lib/mol-gl/shader/smaa/blend.vert.js
var Ow0 = `
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);
}
`;

// node_modules/molstar/lib/mol-gl/shader/smaa/blend.frag.js
var zw0 = `
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);
}
`;

// node_modules/molstar/lib/mol-gl/shader/smaa/weights.vert.js
var Dw0 = `
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);
}
`;

// node_modules/molstar/lib/mol-gl/shader/smaa/weights.frag.js
var Mw0 = `
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));
}
`;

// node_modules/molstar/lib/mol-gl/shader/smaa/edges.vert.js
var Aw0 = `
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);
}
`;

// node_modules/molstar/lib/mol-gl/shader/smaa/edges.frag.js
var Bw0 = `
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);
}
`;

// node_modules/molstar/lib/mol-canvas3d/passes/smaa.js
var ww0 = {
  edgeThreshold: j.Numeric(0.1, { min: 0.05, max: 0.15, step: 0.01 }),
  maxSearchSteps: j.Numeric(16, { min: 0, max: 32, step: 1 })
};

class Ve {
  get supported() {
    return this._supported;
  }
  constructor(Z, J) {
    if (this.webgl = Z, this._supported = !1, typeof HTMLImageElement === "undefined") {
      if (y2)
        console.log('Missing "HTMLImageElement" required for "SMAA"');
      return;
    }
    let $ = J.getWidth(), X = J.getHeight();
    this.edgesTarget = Z.createRenderTarget($, X, !1, "uint8", "linear"), this.weightsTarget = Z.createRenderTarget($, X, !1, "uint8", "linear"), this.edgesRenderable = fN1(Z, J), this.weightsRenderable = xN1(Z, this.edgesTarget.texture), this.blendRenderable = mN1(Z, J, this.weightsTarget.texture), this._supported = !0;
  }
  getByteCount() {
    if (!this.supported)
      return 0;
    return this.edgesTarget.getByteCount() + this.weightsTarget.getByteCount();
  }
  updateState(Z) {
    let { gl: J, state: $ } = this.webgl;
    $.enable(J.SCISSOR_TEST), $.disable(J.BLEND), $.disable(J.DEPTH_TEST), $.depthMask(!1);
    let { x: X, y: Y, width: Q, height: W } = Z;
    $.viewport(X, Y, Q, W), $.scissor(X, Y, Q, W), $.colorMask(!0, !0, !0, !0), $.clearColor(0, 0, 0, 1), J.clear(J.COLOR_BUFFER_BIT), C.update(this.edgesRenderable.values.uViewport, bZ.toVec4(this.edgesRenderable.values.uViewport.ref.value, Z)), C.update(this.weightsRenderable.values.uViewport, bZ.toVec4(this.weightsRenderable.values.uViewport.ref.value, Z)), C.update(this.blendRenderable.values.uViewport, bZ.toVec4(this.blendRenderable.values.uViewport.ref.value, Z));
  }
  setSize(Z, J) {
    let $ = this.edgesTarget.getWidth(), X = this.edgesTarget.getHeight();
    if (Z !== $ || J !== X)
      this.edgesTarget.setSize(Z, J), this.weightsTarget.setSize(Z, J), C.update(this.edgesRenderable.values.uTexSizeInv, h0.set(this.edgesRenderable.values.uTexSizeInv.ref.value, 1 / Z, 1 / J)), C.update(this.weightsRenderable.values.uTexSizeInv, h0.set(this.weightsRenderable.values.uTexSizeInv.ref.value, 1 / Z, 1 / J)), C.update(this.blendRenderable.values.uTexSizeInv, h0.set(this.blendRenderable.values.uTexSizeInv.ref.value, 1 / Z, 1 / J));
  }
  update(Z, J) {
    let $ = !1;
    if (this.edgesRenderable.values.tColor.ref.value !== Z)
      C.update(this.edgesRenderable.values.tColor, Z), $ = !0;
    if (this.edgesRenderable.values.dEdgeThreshold.ref.value !== J.edgeThreshold)
      C.update(this.edgesRenderable.values.dEdgeThreshold, J.edgeThreshold), $ = !0;
    if ($)
      this.edgesRenderable.update();
    if (this.weightsRenderable.values.dMaxSearchSteps.ref.value !== J.maxSearchSteps)
      C.update(this.weightsRenderable.values.dMaxSearchSteps, J.maxSearchSteps), this.weightsRenderable.update();
    if (this.blendRenderable.values.tColor.ref.value !== Z)
      C.update(this.blendRenderable.values.tColor, Z), this.blendRenderable.update();
  }
  render(Z, J) {
    if (K1)
      this.webgl.timer.mark("SmaaPass.render");
    if (this.edgesTarget.bind(), this.updateState(Z), this.edgesRenderable.render(), this.weightsTarget.bind(), this.updateState(Z), this.weightsRenderable.render(), J)
      J.bind();
    else
      this.webgl.bindDrawingBuffer();
    if (this.updateState(Z), this.blendRenderable.render(), K1)
      this.webgl.timer.markEnd("SmaaPass.render");
  }
}
var vN1 = {
  ...A6,
  tColor: o1("texture", "rgba", "ubyte", "linear"),
  uTexSizeInv: _0("v2"),
  uViewport: _0("v4"),
  dEdgeThreshold: p1("number")
}, SN1 = v8("smaa-edges", Aw0, Bw0);
function fN1(Z, J) {
  let $ = J.getWidth(), X = J.getHeight(), Y = {
    ...B6,
    tColor: C.create(J),
    uTexSizeInv: C.create(h0.create(1 / $, 1 / X)),
    uViewport: C.create(E2()),
    dEdgeThreshold: C.create(0.1)
  }, Q = { ...vN1 }, W = t8(Z, "triangles", SN1, Q, Y);
  return e8(W, Y);
}
var hN1 = {
  ...A6,
  tEdges: o1("texture", "rgba", "ubyte", "linear"),
  tArea: o1("texture", "rgb", "ubyte", "linear"),
  tSearch: o1("texture", "rgba", "ubyte", "nearest"),
  uTexSizeInv: _0("v2"),
  uViewport: _0("v4"),
  dMaxSearchSteps: p1("number")
}, bN1 = v8("smaa-weights", Dw0, Mw0);
function xN1(Z, J) {
  let $ = J.getWidth(), X = J.getHeight(), Y = Z.resources.texture("image-uint8", "rgb", "ubyte", "linear"), Q = Z.resources.texture("image-uint8", "rgba", "ubyte", "nearest"), W = {
    ...B6,
    tEdges: C.create(J),
    tArea: C.create(Y),
    tSearch: C.create(Q),
    uTexSizeInv: C.create(h0.create(1 / $, 1 / X)),
    uViewport: C.create(E2()),
    dMaxSearchSteps: C.create(16)
  };
  Ya(dN1(), W.tArea, Y), Ya(pN1(), W.tSearch, Q);
  let K = { ...hN1 }, G = t8(Z, "triangles", bN1, K, W);
  return e8(G, W);
}
var yN1 = {
  ...A6,
  tColor: o1("texture", "rgba", "ubyte", "linear"),
  tWeights: o1("texture", "rgba", "ubyte", "linear"),
  uTexSizeInv: _0("v2"),
  uViewport: _0("v4")
}, gN1 = v8("smaa-blend", Ow0, zw0);
function mN1(Z, J, $) {
  let X = J.getWidth(), Y = J.getHeight(), Q = {
    ...B6,
    tColor: C.create(J),
    tWeights: C.create($),
    uTexSizeInv: C.create(h0.create(1 / X, 1 / Y)),
    uViewport: C.create(E2())
  }, W = { ...yN1 }, K = t8(Z, "triangles", gN1, W, Q);
  return e8(K, Q);
}
function dN1() {
  return "data:image/png;base64, ";
}
function pN1() {
  return "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEIAAAAhCAAAAABIXyLAAAAAOElEQVRIx2NgGAWjYBSMglEwEICREYRgFBZBqDCSLA2MGPUIVQETE9iNUAqLR5gIeoQKRgwXjwAAGn4AtaFeYLEAAAAASUVORK5CYII=";
}

// node_modules/molstar/lib/mol-gl/shader/background.frag.js
var jw0 = `
precision mediump float;
precision mediump samplerCube;
precision mediump sampler2D;

#if defined(dVariant_skybox)
    uniform samplerCube tSkybox;
    uniform mat4 uViewDirectionProjectionInverse;
    uniform float uBlur;
    uniform float uOpacity;
    uniform float uSaturation;
    uniform float uLightness;
    uniform mat3 uRotation;
#elif defined(dVariant_image)
    uniform sampler2D tImage;
    uniform vec2 uImageScale;
    uniform vec2 uImageOffset;
    uniform float uBlur;
    uniform float uOpacity;
    uniform float uSaturation;
    uniform float uLightness;
#elif defined(dVariant_horizontalGradient) || defined(dVariant_radialGradient)
    uniform vec3 uGradientColorA;
    uniform vec3 uGradientColorB;
    uniform float uGradientRatio;
#endif

uniform vec2 uTexSize;
uniform vec4 uViewport;
uniform bool uViewportAdjusted;
varying vec4 vPosition;

// TODO: add as general pp option to remove banding?
// Iestyn's RGB dither from http://alex.vlachos.com/graphics/Alex_Vlachos_Advanced_VR_Rendering_GDC2015.pdf
vec3 ScreenSpaceDither(vec2 vScreenPos) {
    vec3 vDither = vec3(dot(vec2(171.0, 231.0), vScreenPos.xy));
    vDither.rgb = fract(vDither.rgb / vec3(103.0, 71.0, 97.0));
    return vDither.rgb / 255.0;
}

vec3 saturateColor(vec3 c, float amount) {
    // https://www.w3.org/TR/WCAG21/#dfn-relative-luminance
    const vec3 W = vec3(0.2125, 0.7154, 0.0721);
    vec3 intensity = vec3(dot(c, W));
    return mix(intensity, c, 1.0 + amount);
}

vec3 lightenColor(vec3 c, float amount) {
    return c + amount;
}

void main() {
    #if defined(dVariant_skybox)
        vec4 t = uViewDirectionProjectionInverse * vPosition;
        #ifdef enabledShaderTextureLod
            gl_FragColor = textureCubeLodEXT(tSkybox, uRotation * normalize(t.xyz / t.w), uBlur * 8.0);
        #else
            gl_FragColor = textureCube(tSkybox, uRotation * normalize(t.xyz / t.w));
        #endif
        gl_FragColor.a = uOpacity;
        gl_FragColor.rgb = lightenColor(saturateColor(gl_FragColor.rgb, uSaturation), uLightness);
    #elif defined(dVariant_image)
        vec2 coords;
        if (uViewportAdjusted) {
            coords = ((gl_FragCoord.xy - uViewport.xy) * (uTexSize / uViewport.zw) / uImageScale) + uImageOffset;
        } else {
            coords = (gl_FragCoord.xy / uImageScale) + uImageOffset;
        }
        #ifdef enabledShaderTextureLod
            gl_FragColor = texture2DLodEXT(tImage, vec2(coords.x, 1.0 - coords.y), uBlur * 8.0);
        #else
            gl_FragColor = texture2D(tImage, vec2(coords.x, 1.0 - coords.y));
        #endif
        gl_FragColor.a = uOpacity;
        gl_FragColor.rgb = lightenColor(saturateColor(gl_FragColor.rgb, uSaturation), uLightness);
    #elif defined(dVariant_horizontalGradient)
        float d;
        if (uViewportAdjusted) {
            d = ((gl_FragCoord.y - uViewport.y) * (uTexSize.y / uViewport.w) / uTexSize.y) + 1.0 - (uGradientRatio * 2.0);
        } else {
            d = (gl_FragCoord.y / uTexSize.y) + 1.0 - (uGradientRatio * 2.0);
        }
        gl_FragColor = vec4(mix(uGradientColorB, uGradientColorA, clamp(d, 0.0, 1.0)), 1.0);
        gl_FragColor.rgb += ScreenSpaceDither(gl_FragCoord.xy);
    #elif defined(dVariant_radialGradient)
        float d;
        if (uViewportAdjusted) {
            d = distance(vec2(0.5), (gl_FragCoord.xy - uViewport.xy) * (uTexSize / uViewport.zw) / uTexSize) + uGradientRatio - 0.5;
        } else {
            d = distance(vec2(0.5), gl_FragCoord.xy / uTexSize) + uGradientRatio - 0.5;
        }
        gl_FragColor = vec4(mix(uGradientColorB, uGradientColorA, 1.0 - clamp(d, 0.0, 1.0)), 1.0);
        gl_FragColor.rgb += ScreenSpaceDither(gl_FragCoord.xy);
    #endif
}
`;

// node_modules/molstar/lib/mol-gl/shader/background.vert.js
var Tw0 = `
precision mediump float;

attribute vec2 aPosition;

varying vec4 vPosition;

void main() {
    vPosition = vec4(aPosition, 1.0, 1.0);
    gl_Position = vec4(aPosition, 1.0, 1.0);
}
`;

// node_modules/molstar/lib/mol-math/linear-algebra/3d/euler.js
function tV() {
  return tV.zero();
}
(function(Z) {
  function J() {
    let F = [0.1, 0, 0];
    return F[0] = 0, F;
  }
  Z.zero = J;
  function $(F, E, R) {
    let z = J();
    return z[0] = F, z[1] = E, z[2] = R, z;
  }
  Z.create = $;
  function X(F, E, R, z) {
    return F[0] = E, F[0] = R, F[0] = z, F;
  }
  Z.set = X;
  function Y(F) {
    let E = J();
    return E[0] = F[0], E[1] = F[1], E[2] = F[2], E;
  }
  Z.clone = Y;
  function Q(F, E) {
    return F[0] = E[0], F[1] = E[1], F[2] = E[2], F;
  }
  Z.copy = Q;
  function W(F, E, R) {
    let z = E[0], D = E[4], A = E[8], B = E[1], T = E[5], w = E[9], V = E[2], P = E[6], I = E[10];
    switch (R) {
      case "XYZ":
        if (F[1] = Math.asin(x8(A, -1, 1)), Math.abs(A) < 0.9999999)
          F[0] = Math.atan2(-w, I), F[2] = Math.atan2(-D, z);
        else
          F[0] = Math.atan2(P, T), F[2] = 0;
        break;
      case "YXZ":
        if (F[0] = Math.asin(-x8(w, -1, 1)), Math.abs(w) < 0.9999999)
          F[1] = Math.atan2(A, I), F[2] = Math.atan2(B, T);
        else
          F[1] = Math.atan2(-V, z), F[2] = 0;
        break;
      case "ZXY":
        if (F[0] = Math.asin(x8(P, -1, 1)), Math.abs(P) < 0.9999999)
          F[1] = Math.atan2(-V, I), F[2] = Math.atan2(-D, T);
        else
          F[1] = 0, F[2] = Math.atan2(B, z);
        break;
      case "ZYX":
        if (F[1] = Math.asin(-x8(V, -1, 1)), Math.abs(V) < 0.9999999)
          F[0] = Math.atan2(P, I), F[2] = Math.atan2(B, z);
        else
          F[0] = 0, F[2] = Math.atan2(-D, T);
        break;
      case "YZX":
        if (F[2] = Math.asin(x8(B, -1, 1)), Math.abs(B) < 0.9999999)
          F[0] = Math.atan2(-w, T), F[1] = Math.atan2(-V, z);
        else
          F[0] = 0, F[1] = Math.atan2(A, I);
        break;
      case "XZY":
        if (F[2] = Math.asin(-x8(D, -1, 1)), Math.abs(D) < 0.9999999)
          F[0] = Math.atan2(P, T), F[1] = Math.atan2(A, z);
        else
          F[0] = Math.atan2(-w, I), F[1] = 0;
        break;
      default:
        T8(R);
    }
    return F;
  }
  Z.fromMat4 = W;
  let K = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
  function G(F, E, R) {
    return e.fromQuat(K, E), W(F, K, R);
  }
  Z.fromQuat = G;
  function H(F, E) {
    return X(F, E[0], E[1], E[2]);
  }
  Z.fromVec3 = H;
  function N(F, E) {
    return F[0] === E[0] && F[1] === E[1] && F[2] === E[2];
  }
  Z.exactEquals = N;
  function q(F, E, R) {
    return F[0] = E[R + 0], F[1] = E[R + 1], F[2] = E[R + 2], F;
  }
  Z.fromArray = q;
  function U(F, E, R) {
    return E[R + 0] = F[0], E[R + 1] = F[1], E[R + 2] = F[2], E;
  }
  Z.toArray = U;
})(tV || (tV = {}));

// node_modules/molstar/lib/mol-canvas3d/passes/background.js
var Cw0 = {
  opacity: j.Numeric(1, { min: 0, max: 1, step: 0.01 }),
  saturation: j.Numeric(0, { min: -1, max: 1, step: 0.01 }),
  lightness: j.Numeric(0, { min: -1, max: 1, step: 0.01 })
}, uN1 = {
  faces: j.MappedStatic("urls", {
    urls: j.Group({
      nx: j.Text("", { label: "Negative X / Left" }),
      ny: j.Text("", { label: "Negative Y / Bottom" }),
      nz: j.Text("", { label: "Negative Z / Back" }),
      px: j.Text("", { label: "Positive X / Right" }),
      py: j.Text("", { label: "Positive Y / Top" }),
      pz: j.Text("", { label: "Positive Z / Front" })
    }, { isExpanded: !0, label: "URLs" }),
    files: j.Group({
      nx: j.File({ label: "Negative X / Left", accept: "image/*" }),
      ny: j.File({ label: "Negative Y / Bottom", accept: "image/*" }),
      nz: j.File({ label: "Negative Z / Back", accept: "image/*" }),
      px: j.File({ label: "Positive X / Right", accept: "image/*" }),
      py: j.File({ label: "Positive Y / Top", accept: "image/*" }),
      pz: j.File({ label: "Positive Z / Front", accept: "image/*" })
    }, { isExpanded: !0, label: "Files" })
  }),
  blur: j.Numeric(0, { min: 0, max: 1, step: 0.01 }, { description: 'Note, this only works in WebGL2 or when "EXT_shader_texture_lod" is available.' }),
  rotation: j.Group({
    x: j.Numeric(0, { min: 0, max: 360, step: 1 }, { immediateUpdate: !0 }),
    y: j.Numeric(0, { min: 0, max: 360, step: 1 }, { immediateUpdate: !0 }),
    z: j.Numeric(0, { min: 0, max: 360, step: 1 }, { immediateUpdate: !0 })
  }),
  ...Cw0
}, cN1 = {
  source: j.MappedStatic("url", {
    url: j.Text(""),
    file: j.File({ accept: "image/*" })
  }),
  blur: j.Numeric(0, { min: 0, max: 1, step: 0.01 }, { description: 'Note, this only works in WebGL2 or with power-of-two images and when "EXT_shader_texture_lod" is available.' }),
  ...Cw0,
  coverage: j.Select("viewport", j.arrayToOptions(["viewport", "canvas"]))
}, lN1 = {
  topColor: j.Color(i0(14540253)),
  bottomColor: j.Color(i0(15658734)),
  ratio: j.Numeric(0.5, { min: 0, max: 1, step: 0.01 }),
  coverage: j.Select("viewport", j.arrayToOptions(["viewport", "canvas"]))
}, nN1 = {
  centerColor: j.Color(i0(14540253)),
  edgeColor: j.Color(i0(15658734)),
  ratio: j.Numeric(0.5, { min: 0, max: 1, step: 0.01 }),
  coverage: j.Select("viewport", j.arrayToOptions(["viewport", "canvas"]))
}, kw0 = {
  variant: j.MappedStatic("off", {
    off: j.EmptyGroup(),
    skybox: j.Group(uN1, { isExpanded: !0 }),
    image: j.Group(cN1, { isExpanded: !0 }),
    horizontalGradient: j.Group(lN1, { isExpanded: !0 }),
    radialGradient: j.Group(nN1, { isExpanded: !0 })
  }, { label: "Environment" })
};

class Ie {
  constructor(Z, J, $, X) {
    this.webgl = Z, this.assetManager = J, this.camera = new O6, this.target = M(), this.position = M(), this.dir = M(), this.bgColor = M(), this.renderable = Jq1(Z, $, X);
  }
  setSize(Z, J) {
    let [$, X] = this.renderable.values.uTexSize.ref.value;
    if (Z !== $ || J !== X)
      C.update(this.renderable.values.uTexSize, h0.set(this.renderable.values.uTexSize.ref.value, Z, J));
  }
  clearSkybox() {
    if (this.skybox !== void 0)
      this.skybox.texture.destroy(), this.skybox.assets.forEach((Z) => this.assetManager.release(Z)), this.skybox = void 0;
  }
  updateSkybox(Z, J, $) {
    var X;
    let Y = (X = this.skybox) === null || X === void 0 ? void 0 : X.props.faces, Q = J.faces.params;
    if (!Q.nx || !Q.ny || !Q.nz || !Q.px || !Q.py || !Q.pz) {
      this.clearSkybox(), $ === null || $ === void 0 || $(!1);
      return;
    }
    if (!this.skybox || !Y || !sN1(J.faces, this.skybox.props.faces)) {
      this.clearSkybox();
      let { texture: H, assets: N } = aN1(this.webgl, this.assetManager, J.faces, (q) => {
        if (this.skybox)
          this.skybox.loaded = !q;
        $ === null || $ === void 0 || $(!0);
      });
      this.skybox = { texture: H, props: { ...J }, assets: N, loaded: !1 }, C.update(this.renderable.values.tSkybox, H), this.renderable.update();
    } else
      $ === null || $ === void 0 || $(!1);
    if (!this.skybox)
      return;
    let W = Z;
    if (Z.state.mode === "orthographic")
      this.camera.setState({ ...Z.state, mode: "perspective" }), this.camera.update(), W = this.camera;
    let K = this.renderable.values.uViewDirectionProjectionInverse.ref.value;
    if (e.isZero(Z.headRotation))
      M.sub(this.dir, W.state.position, W.state.target), M.setMagnitude(this.dir, this.dir, 0.1), M.copy(this.position, this.dir), e.lookAt(K, this.position, this.target, W.state.up);
    else
      e.invert(K, Z.headRotation);
    e.mul(K, W.projection, K), e.invert(K, K), C.update(this.renderable.values.uViewDirectionProjectionInverse, K);
    let G = this.renderable.values.uRotation.ref.value;
    h2.fromEuler(G, tV.create(_8(J.rotation.x), _8(J.rotation.y), _8(J.rotation.z)), "XYZ"), C.update(this.renderable.values.uRotation, G), C.updateIfChanged(this.renderable.values.uBlur, J.blur), C.updateIfChanged(this.renderable.values.uOpacity, J.opacity), C.updateIfChanged(this.renderable.values.uSaturation, J.saturation), C.updateIfChanged(this.renderable.values.uLightness, J.lightness), C.updateIfChanged(this.renderable.values.dVariant, "skybox"), this.renderable.update();
  }
  clearImage() {
    if (this.image !== void 0)
      this.image.texture.destroy(), this.assetManager.release(this.image.asset), this.image = void 0;
  }
  updateImage(Z, J) {
    if (!Z.source.params) {
      this.clearImage(), J === null || J === void 0 || J(!1);
      return;
    }
    if (!this.image || !this.image.props.source.params || !rN1(Z.source, this.image.props.source)) {
      this.clearImage();
      let { texture: $, asset: X } = tN1(this.webgl, this.assetManager, Z.source, (Y) => {
        if (this.image)
          this.image.loaded = !Y;
        J === null || J === void 0 || J(!0);
      });
      this.image = { texture: $, props: { ...Z }, asset: X, loaded: !1 }, C.update(this.renderable.values.tImage, $), this.renderable.update();
    } else
      J === null || J === void 0 || J(!1);
    if (!this.image)
      return;
    C.updateIfChanged(this.renderable.values.uBlur, Z.blur), C.updateIfChanged(this.renderable.values.uOpacity, Z.opacity), C.updateIfChanged(this.renderable.values.uSaturation, Z.saturation), C.updateIfChanged(this.renderable.values.uLightness, Z.lightness), C.updateIfChanged(this.renderable.values.uViewportAdjusted, Z.coverage === "viewport" ? !0 : !1), C.updateIfChanged(this.renderable.values.dVariant, "image"), this.renderable.update();
  }
  updateImageScaling() {
    var Z, J;
    let $ = this.renderable.values, [X, Y] = $.uTexSize.ref.value, Q = ((Z = this.image) === null || Z === void 0 ? void 0 : Z.texture.getWidth()) || 0, W = ((J = this.image) === null || J === void 0 ? void 0 : J.texture.getHeight()) || 0, K = X / Y, G = Q / W;
    if (K < G)
      C.update($.uImageScale, h0.set($.uImageScale.ref.value, Q * Y / W, Y));
    else
      C.update($.uImageScale, h0.set($.uImageScale.ref.value, X, W * X / Q));
    let [H, N] = $.uImageScale.ref.value, q = H / N;
    if (q > K)
      C.update($.uImageOffset, h0.set($.uImageOffset.ref.value, (1 - K / q) / 2, 0));
    else
      C.update($.uImageOffset, h0.set($.uImageOffset.ref.value, 0, (1 - q / K) / 2));
  }
  updateGradient(Z, J, $, X, Y) {
    C.update(this.renderable.values.uGradientColorA, i0.toVec3Normalized(this.renderable.values.uGradientColorA.ref.value, Z)), C.update(this.renderable.values.uGradientColorB, i0.toVec3Normalized(this.renderable.values.uGradientColorB.ref.value, J)), C.updateIfChanged(this.renderable.values.uGradientRatio, $), C.updateIfChanged(this.renderable.values.uViewportAdjusted, Y), C.updateIfChanged(this.renderable.values.dVariant, X), this.renderable.update();
  }
  update(Z, J, $) {
    if (J.variant.name === "off") {
      this.clearSkybox(), this.clearImage(), $ === null || $ === void 0 || $(!1);
      return;
    } else if (J.variant.name === "skybox")
      this.clearImage(), this.updateSkybox(Z, J.variant.params, $);
    else if (J.variant.name === "image")
      this.clearSkybox(), this.updateImage(J.variant.params, $);
    else if (J.variant.name === "horizontalGradient")
      this.clearSkybox(), this.clearImage(), this.updateGradient(J.variant.params.topColor, J.variant.params.bottomColor, J.variant.params.ratio, J.variant.name, J.variant.params.coverage === "viewport" ? !0 : !1), $ === null || $ === void 0 || $(!1);
    else if (J.variant.name === "radialGradient")
      this.clearSkybox(), this.clearImage(), this.updateGradient(J.variant.params.centerColor, J.variant.params.edgeColor, J.variant.params.ratio, J.variant.name, J.variant.params.coverage === "viewport" ? !0 : !1), $ === null || $ === void 0 || $(!1);
    let { x: X, y: Y, width: Q, height: W } = Z.viewport;
    C.update(this.renderable.values.uViewport, E2.set(this.renderable.values.uViewport.ref.value, X, Y, Q, W));
  }
  _isEnabled(Z) {
    return !!(this.skybox && this.skybox.loaded || this.image && this.image.loaded || Z.variant.name === "horizontalGradient" || Z.variant.name === "radialGradient");
  }
  isEnabled(Z) {
    return Z.enabled && this._isEnabled(Z.background);
  }
  isReady() {
    return !!(this.skybox && this.skybox.loaded || this.image && this.image.loaded || this.renderable.values.dVariant.ref.value === "horizontalGradient" || this.renderable.values.dVariant.ref.value === "radialGradient");
  }
  clear(Z, J, $) {
    let { gl: X, state: Y } = this.webgl;
    if (this._isEnabled(Z)) {
      if (J)
        Y.clearColor(0, 0, 0, 0);
      else
        i0.toVec3Normalized(this.bgColor, $), Y.clearColor(this.bgColor[0], this.bgColor[1], this.bgColor[2], 1);
      X.clear(X.COLOR_BUFFER_BIT), Y.enable(X.BLEND), Y.blendFuncSeparate(X.SRC_ALPHA, X.ONE_MINUS_SRC_ALPHA, X.ONE, X.ONE_MINUS_SRC_ALPHA);
    } else
      Y.clearColor(0, 0, 0, 1), X.clear(X.COLOR_BUFFER_BIT);
  }
  render(Z) {
    if (!this._isEnabled(Z) || !this.isReady())
      return;
    if (this.renderable.values.dVariant.ref.value === "image")
      this.updateImageScaling();
    if (K1)
      this.webgl.timer.mark("BackgroundPass.render");
    if (this.renderable.render(), K1)
      this.webgl.timer.markEnd("BackgroundPass.render");
  }
  dispose() {
    this.clearSkybox(), this.clearImage();
  }
}
var _w0 = "background-skybox";
function iN1(Z, J) {
  if (J.name === "urls")
    return {
      nx: E6.getUrlAsset(Z, J.params.nx),
      ny: E6.getUrlAsset(Z, J.params.ny),
      nz: E6.getUrlAsset(Z, J.params.nz),
      px: E6.getUrlAsset(Z, J.params.px),
      py: E6.getUrlAsset(Z, J.params.py),
      pz: E6.getUrlAsset(Z, J.params.pz)
    };
  else
    return {
      nx: J.params.nx,
      ny: J.params.ny,
      nz: J.params.nz,
      px: J.params.px,
      py: J.params.py,
      pz: J.params.pz
    };
}
function oN1(Z, J) {
  let $ = (X) => {
    return Z.resolve(X, "binary").run().then((Y) => new Blob([Y.data]));
  };
  return {
    nx: $(J.nx),
    ny: $(J.ny),
    nz: $(J.nz),
    px: $(J.px),
    py: $(J.py),
    pz: $(J.pz)
  };
}
function Vw0(Z) {
  var J, $, X, Y, Q, W;
  if (Z.name === "urls")
    return `${_w0}_${Z.params.nx}|${Z.params.ny}|${Z.params.nz}|${Z.params.px}|${Z.params.py}|${Z.params.pz}`;
  else
    return `${_w0}_${(J = Z.params.nx) === null || J === void 0 ? void 0 : J.id}|${($ = Z.params.ny) === null || $ === void 0 ? void 0 : $.id}|${(X = Z.params.nz) === null || X === void 0 ? void 0 : X.id}|${(Y = Z.params.px) === null || Y === void 0 ? void 0 : Y.id}|${(Q = Z.params.py) === null || Q === void 0 ? void 0 : Q.id}|${(W = Z.params.pz) === null || W === void 0 ? void 0 : W.id}`;
}
function sN1(Z, J) {
  return Vw0(Z) === Vw0(J);
}
function aN1(Z, J, $, X) {
  let Y = iN1(J, $), Q = oN1(J, Y), W = [Y.nx, Y.ny, Y.nz, Y.px, Y.py, Y.pz];
  if (typeof HTMLImageElement === "undefined")
    return console.error('Missing "HTMLImageElement" required for background skybox'), X === null || X === void 0 || X(!0), { texture: k9(), assets: W };
  return { texture: Z.resources.cubeTexture(Q, !0, X), assets: W };
}
var Iw0 = "background-image";
function Pw0(Z) {
  var J;
  if (Z.name === "url")
    return `${Iw0}_${Z.params}`;
  else
    return `${Iw0}_${(J = Z.params) === null || J === void 0 ? void 0 : J.id}`;
}
function rN1(Z, J) {
  return Pw0(Z) === Pw0(J);
}
function tN1(Z, J, $, X) {
  var Y;
  let Q = $.name === "url" ? (Y = J.tryFindFilename($.params)) !== null && Y !== void 0 ? Y : E6.getUrlAsset(J, $.params) : $.params;
  if (typeof HTMLImageElement === "undefined")
    return console.error('Missing "HTMLImageElement" required for background image'), X === null || X === void 0 || X(!0), { texture: k9(), asset: Q };
  let W = Z.resources.texture("image-uint8", "rgba", "ubyte", "linear"), K = new Image;
  return K.onload = () => {
    if (W.load(K), Z.isWebGL2 || nL(K.width) && nL(K.height))
      W.mipmap();
    X === null || X === void 0 || X();
  }, K.onerror = () => {
    X === null || X === void 0 || X(!0);
  }, J.resolve(Q, "binary").run().then((G) => {
    let H = new Blob([G.data]);
    K.src = URL.createObjectURL(H);
  }), { texture: W, asset: Q };
}
var eN1 = {
  drawCount: zZ("number"),
  instanceCount: zZ("number"),
  aPosition: a6("float32", 2, 0),
  tSkybox: o1("texture", "rgba", "ubyte", "linear"),
  tImage: o1("texture", "rgba", "ubyte", "linear"),
  uImageScale: _0("v2"),
  uImageOffset: _0("v2"),
  uTexSize: _0("v2"),
  uViewport: _0("v4"),
  uViewportAdjusted: _0("b"),
  uViewDirectionProjectionInverse: _0("m4"),
  uGradientColorA: _0("v3"),
  uGradientColorB: _0("v3"),
  uGradientRatio: _0("f"),
  uBlur: _0("f"),
  uOpacity: _0("f"),
  uSaturation: _0("f"),
  uLightness: _0("f"),
  uRotation: _0("m3"),
  dVariant: p1("string", ["skybox", "image", "verticalGradient", "horizontalGradient", "radialGradient"])
}, Zq1 = v8("background", Tw0, jw0, {
  shaderTextureLod: "optional"
});
function Jq1(Z, J, $) {
  let X = {
    drawCount: C.create(6),
    instanceCount: C.create(1),
    aPosition: C.create(RV),
    tSkybox: C.create(k9()),
    tImage: C.create(k9()),
    uImageScale: C.create(h0()),
    uImageOffset: C.create(h0()),
    uTexSize: C.create(h0.create(J, $)),
    uViewport: C.create(E2()),
    uViewportAdjusted: C.create(!0),
    uViewDirectionProjectionInverse: C.create(e()),
    uGradientColorA: C.create(M()),
    uGradientColorB: C.create(M()),
    uGradientRatio: C.create(0.5),
    uBlur: C.create(0),
    uOpacity: C.create(1),
    uSaturation: C.create(0),
    uLightness: C.create(0),
    uRotation: C.create(h2.identity()),
    dVariant: C.create("skybox")
  }, Y = { ...eN1 }, Q = t8(Z, "triangles", Zq1, Y, X);
  return e8(Q, X);
}

// node_modules/molstar/lib/mol-gl/shader/cas.frag.js
var vw0 = `
precision mediump float;
precision mediump sampler2D;

uniform sampler2D tColor;
uniform vec2 uTexSizeInv;

uniform float uSharpness;

// adapted from https://www.shadertoy.com/view/stXSWB

/*
* FidelityFX Super Resolution scales up a low resolution
* image, while adding fine detail.
*
* MIT Open License
*
* https://gpuopen.com/fsr
*
* Left: FSR processed
* Right: Original texture, bilinear interpolation
*
* Mouse at top: Sharpness 0 stops (maximum)
* Mouse at bottom: Sharpness 2 stops (minimum)
*
* It works in two passes-
*   EASU upsamples the image with a clamped Lanczos kernel.
*   RCAS sharpens the image at the target resolution.
*
* I needed to make a few changes to improve readability and
* WebGL compatibility in an algorithm I don't fully understand.
* Expect bugs.
*
* Shader not currently running for WebGL1 targets (eg. mobile Safari)
*
* There is kind of no point to using FSR in Shadertoy, as it renders buffers
* at full target resolution. But this might be useful for WebGL based demos
* running smaller-than-target render buffers.
*
* For sharpening with a full resolution render buffer,
* FidelityFX CAS is a better option.
* https://www.shadertoy.com/view/ftsXzM
*
* For readability and compatibility, these optimisations have been removed:
*   * Fast approximate inverse and inversesqrt
*   * textureGather fetches (not WebGL compatible)
*   * Multiplying by reciprocal instead of division
*
* Apologies to AMD for the numerous slowdowns and errors I have introduced.
*
*/

/***** RCAS *****/
#define FSR_RCAS_LIMIT (0.25-(1.0/16.0))

// Input callback prototypes that need to be implemented by calling shader
vec4 FsrRcasLoadF(vec2 p);
//------------------------------------------------------------------------------------------------------------------------------
void FsrRcasCon(
    out float con,
    // The scale is {0.0 := maximum, to N>0, where N is the number of stops (halving) of the reduction of sharpness}.
    float sharpness
) {
    // Transform from stops to linear value.
    con = exp2(-sharpness);
}

vec3 FsrRcasF(
    vec2 ip, // Integer pixel position in output.
    float con
) {
    // Constant generated by RcasSetup().
    // Algorithm uses minimal 3x3 pixel neighborhood.
    //    b
    //  d e f
    //    h
    vec2 sp = vec2(ip);
    vec3 b = FsrRcasLoadF(sp + vec2( 0,-1)).rgb;
    vec3 d = FsrRcasLoadF(sp + vec2(-1, 0)).rgb;
    vec3 e = FsrRcasLoadF(sp).rgb;
    vec3 f = FsrRcasLoadF(sp + vec2( 1, 0)).rgb;
    vec3 h = FsrRcasLoadF(sp + vec2( 0, 1)).rgb;

    // Luma times 2.
    float bL = b.g + .5 * (b.b + b.r);
    float dL = d.g + .5 * (d.b + d.r);
    float eL = e.g + .5 * (e.b + e.r);
    float fL = f.g + .5 * (f.b + f.r);
    float hL = h.g + .5 * (h.b + h.r);

    // Noise detection.
    #ifdef dDenoise
        float nz = .25 * (bL + dL + fL + hL) - eL;
        nz=clamp(
            abs(nz)
            /(
                max(max(bL,dL),max(eL,max(fL,hL)))
                -min(min(bL,dL),min(eL,min(fL,hL)))
            ),
            0., 1.
        );
        nz=1.-.5*nz;
    #endif

    // Min and max of ring.
    vec3 mn4 = min(b, min(f, h));
    vec3 mx4 = max(b, max(f, h));

    // Immediate constants for peak range.
    vec2 peakC = vec2(1., -4.);

    // Limiters, these need to be high precision RCPs.
    vec3 hitMin = mn4 / (4. * mx4);
    vec3 hitMax = (peakC.x - mx4) / (4.* mn4 + peakC.y);
    vec3 lobeRGB = max(-hitMin, hitMax);
    float lobe = max(
        -FSR_RCAS_LIMIT,
        min(max(lobeRGB.r, max(lobeRGB.g, lobeRGB.b)), 0.)
    )*con;

    // Apply noise removal.
    #ifdef dDenoise
        lobe *= nz;
    #endif

    // Resolve, which needs the medium precision rcp approximation to avoid visible tonality changes.
    return (lobe * (b + d + h + f) + e) / (4. * lobe + 1.);
}


vec4 FsrRcasLoadF(vec2 p) {
    return texture2D(tColor, p * uTexSizeInv);
}

void main() {
    // Set up constants
    float con;
    FsrRcasCon(con, uSharpness);

    // Perform RCAS pass
    vec3 col = FsrRcasF(gl_FragCoord.xy, con);

    gl_FragColor = vec4(col, FsrRcasLoadF(gl_FragCoord.xy).a);
}
`;

// node_modules/molstar/lib/mol-canvas3d/passes/cas.js
var Sw0 = {
  sharpness: j.Numeric(0.5, { min: 0, max: 1, step: 0.05 }),
  denoise: j.Boolean(!0)
};

class Pe {
  constructor(Z, J) {
    this.webgl = Z, this.renderable = Yq1(Z, J);
  }
  updateState(Z) {
    let { gl: J, state: $ } = this.webgl;
    $.enable(J.SCISSOR_TEST), $.disable(J.BLEND), $.disable(J.DEPTH_TEST), $.depthMask(!1);
    let { x: X, y: Y, width: Q, height: W } = Z;
    $.viewport(X, Y, Q, W), $.scissor(X, Y, Q, W), $.clearColor(0, 0, 0, 1), J.clear(J.COLOR_BUFFER_BIT);
  }
  setSize(Z, J) {
    C.update(this.renderable.values.uTexSizeInv, h0.set(this.renderable.values.uTexSizeInv.ref.value, 1 / Z, 1 / J));
  }
  update(Z, J) {
    let { values: $ } = this.renderable, { sharpness: X, denoise: Y } = J, Q = !1;
    if ($.tColor.ref.value !== Z)
      C.update(this.renderable.values.tColor, Z), Q = !0;
    if (C.updateIfChanged($.uSharpness, 2 - 2 * Math.pow(X, 0.25)), $.dDenoise.ref.value !== Y)
      Q = !0;
    if (C.updateIfChanged($.dDenoise, Y), Q)
      this.renderable.update();
  }
  render(Z, J) {
    if (K1)
      this.webgl.timer.mark("CasPass.render");
    if (J)
      J.bind();
    else
      this.webgl.bindDrawingBuffer();
    if (this.updateState(Z), this.renderable.render(), K1)
      this.webgl.timer.markEnd("CasPass.render");
  }
}
var $q1 = {
  ...A6,
  tColor: o1("texture", "rgba", "ubyte", "linear"),
  uTexSizeInv: _0("v2"),
  uSharpness: _0("f"),
  dDenoise: p1("boolean")
}, Xq1 = v8("cas", p6, vw0);
function Yq1(Z, J) {
  let $ = J.getWidth(), X = J.getHeight(), Y = {
    ...B6,
    tColor: C.create(J),
    uTexSizeInv: C.create(h0.create(1 / $, 1 / X)),
    uSharpness: C.create(0.5),
    dDenoise: C.create(!0)
  }, Q = { ...$q1 }, W = t8(Z, "triangles", Xq1, Q, Y);
  return e8(W, Y);
}

// node_modules/molstar/lib/mol-gl/shader/dof.frag.js
var fw0 = `
precision highp float;
precision highp int;
precision highp sampler2D;

#include common

uniform sampler2D tColor;
uniform sampler2D tDepthOpaque;
uniform sampler2D tDepthTransparent;

uniform vec2 uTexSize;
uniform vec4 uBounds;

uniform float uBlurSpread;
uniform float uInFocus;
uniform float uPPM;

uniform float uNear; // Near plane
uniform float uFar;  // Far plane

uniform mat4 uInvProjection; // Inverse projection
uniform mat4 uProjection; // projection

uniform int uMode; // 0-planar, 1-spherical
uniform vec3 uCenter; // Center of focus sphere in view space

// Function to convert depth value from depth buffer to view space Z
float getViewZ(const in float depth) {
    #if dOrthographic == 1
        return orthographicDepthToViewZ(depth, uNear, uFar);
    #else
        return perspectiveDepthToViewZ(depth, uNear, uFar);
    #endif
}

// Retrieve depth from opaque depth texture
float getDepthOpaque(const in vec2 coords) {
    #ifdef depthTextureSupport
        return texture2D(tDepthOpaque, coords).r;
    #else
        return unpackRGBAToDepth(texture2D(tDepthOpaque, coords));
    #endif
}

// Retrieve depth from transparent depth texture
float getDepthTransparent(const in vec2 coords) {
    return unpackRGBAToDepthWithAlpha(texture2D(tDepthTransparent, coords)).x;
}

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

float getDepth(const in vec2 coords) {
    return min(getDepthOpaque(coords), getDepthTransparent(coords));
}

float getCOC(vec2 uv) {
    float depth = getDepth(uv);
    float viewDist = getViewZ(depth);
    vec3 aposition = screenSpaceToViewSpace(vec3(uv.xy, depth), uInvProjection);
    float focusDist = length(aposition - uCenter);
    float coc = 0.0;  // Circle of Confusion
    if (uMode == 0) { // planar Depth of field
        coc = (abs(viewDist) - uInFocus) / uPPM;  //focus distance, focus range
    } else if(uMode == 1) { // spherical Depth of field
        coc = focusDist / uPPM ;
    }
    coc = clamp(coc, -1.0, 1.0);
    return coc;
}

// Simple box blur for blurring the image
vec3 getBlurredImage(vec2 coords) {
    vec4 blurColor = vec4(0);
    vec2 texelSize = vec2(1.0 / uTexSize.x, 1.0 / uTexSize.y);
    float count = 0.0;
    for (int x = 0; x < int(dBlurSize); x++) {
        for (int y = 0; y < int(dBlurSize); y++) {
            vec2 offset = vec2(float(x) - float(dBlurSize) / 2.0, float(y) - float(dBlurSize) / 2.0);
            vec2 uvPixel = coords.xy + offset * texelSize * uBlurSpread;
            float coc = getCOC(uvPixel);
            coc = smoothstep(0.0, 1.0, abs(coc));
            // mix blurColor with new color with weight coc
            blurColor.rgb = blurColor.rgb + texture2D(tColor, uvPixel).xyz * coc;
            count+=coc;
        }
    }
    blurColor = blurColor / count;
    return blurColor.rgb;
}

// simplification from https://catlikecoding.com/unity/tutorials/advanced-rendering/depth-of-field/
void main() {
    vec2 uv = gl_FragCoord.xy / uTexSize;
    vec4 color = texture2D(tColor, uv);
    float depth = getDepth(uv);

    float viewDist = getViewZ(depth);

    vec3 aposition = screenSpaceToViewSpace(vec3(uv.xy, depth), uInvProjection);
    float focusDist = length(aposition - uCenter);
    vec3 blurColor = getBlurredImage(uv);

    float coc = getCOC(uv); // Circle of Confusion

    // for debugging the coc
    // color.rgb = (coc < 0.0) ? (1.0 - abs(coc)) * vec3(1.0,0.0,0.0) : vec3(0.0, 1.0 - coc, 0.0) ;//mix(color.rgb, blurColor.rgb, abs(coc));
    color.rgb = mix(color.rgb, blurColor, smoothstep(0.0, 1.0, abs(coc))); // Smooth blending based on CoC
    gl_FragColor = color;
}
`;

// node_modules/molstar/lib/mol-canvas3d/passes/dof.js
var hw0 = {
  blurSize: j.Numeric(9, { min: 1, max: 32, step: 1 }),
  blurSpread: j.Numeric(1, { min: 0, max: 10, step: 0.1 }),
  inFocus: j.Numeric(0, { min: -5000, max: 5000, step: 1 }, { description: "Distance from the scene center that will be in focus" }),
  PPM: j.Numeric(20, { min: 0, max: 5000, step: 0.1 }, { description: "Size of the area that will be in focus" }),
  center: j.Select("camera-target", j.arrayToOptions(["scene-center", "camera-target"])),
  mode: j.Select("plane", j.arrayToOptions(["plane", "sphere"]))
};

class jH {
  static isEnabled(Z) {
    return Z.enabled && Z.dof.name !== "off";
  }
  constructor(Z, J, $) {
    this.webgl = Z, this.target = Z.createRenderTarget(J, $, !1);
    let X = k9();
    this.renderable = Kq1(Z, X, X, X);
  }
  getByteCount() {
    return this.target.getByteCount();
  }
  updateState(Z) {
    let { gl: J, state: $ } = this.webgl;
    $.enable(J.SCISSOR_TEST), $.disable(J.BLEND), $.disable(J.DEPTH_TEST), $.depthMask(!1);
    let { x: X, y: Y, width: Q, height: W } = Z;
    $.viewport(X, Y, Q, W), $.scissor(X, Y, Q, W), $.clearColor(0, 0, 0, 1), J.clear(J.COLOR_BUFFER_BIT);
  }
  setSize(Z, J) {
    let $ = this.target.texture.getWidth(), X = this.target.texture.getHeight();
    if (Z !== $ || J !== X)
      this.target.setSize(Z, J), C.update(this.renderable.values.uTexSize, h0.set(this.renderable.values.uTexSize.ref.value, Z, J));
  }
  update(Z, J, $, X, Y, Q) {
    let W = !1;
    if (this.renderable.values.tColor.ref.value !== J)
      C.update(this.renderable.values.tColor, J), W = !0;
    if (this.renderable.values.tDepthOpaque.ref.value !== $)
      C.update(this.renderable.values.tDepthOpaque, $), W = !0;
    if (this.renderable.values.tDepthTransparent.ref.value !== X)
      C.update(this.renderable.values.tDepthTransparent, X), W = !0;
    let K = Z.state.mode === "orthographic" ? 1 : 0, G = this.renderable.values.uInvProjection.ref.value;
    e.invert(G, Z.projection);
    let [H, N] = this.renderable.values.uTexSize.ref.value, q = Z.viewport;
    C.update(this.renderable.values.uProjection, Z.projection), C.update(this.renderable.values.uInvProjection, G), C.update(this.renderable.values.uMode, Y.mode === "sphere" ? 1 : 0), E2.set(this.renderable.values.uBounds.ref.value, q.x / H, q.y / N, (q.x + q.width) / H, (q.y + q.height) / N), C.update(this.renderable.values.uBounds, this.renderable.values.uBounds.ref.value), C.updateIfChanged(this.renderable.values.uNear, Z.near), C.updateIfChanged(this.renderable.values.uFar, Z.far), C.updateIfChanged(this.renderable.values.dOrthographic, K);
    let U = Math.round(Y.blurSize * this.webgl.pixelRatio);
    if (this.renderable.values.dBlurSize.ref.value !== U)
      C.update(this.renderable.values.dBlurSize, U), W = !0;
    let F = Y.center === "scene-center" ? Q.center : Z.state.target, R = M.distance(Z.state.position, F) + Y.inFocus;
    C.updateIfChanged(this.renderable.values.uInFocus, R * Z.scale);
    let z = this.renderable.values.uCenter.ref.value;
    if (M.transformMat4(z, F, Z.view), C.update(this.renderable.values.uCenter, z), C.updateIfChanged(this.renderable.values.uBlurSpread, Y.blurSpread), C.updateIfChanged(this.renderable.values.uPPM, Y.PPM * Z.scale), W)
      this.renderable.update();
  }
  render(Z, J) {
    if (K1)
      this.webgl.timer.mark("DofPass.render");
    if (J)
      J.bind();
    else
      this.webgl.bindDrawingBuffer();
    if (this.updateState(Z), this.renderable.render(), K1)
      this.webgl.timer.markEnd("DofPass.render");
  }
}
var Qq1 = {
  ...A6,
  tDepthOpaque: o1("texture", "rgba", "ubyte", "nearest"),
  tDepthTransparent: o1("texture", "rgba", "ubyte", "nearest"),
  tColor: o1("texture", "rgba", "ubyte", "nearest"),
  uTexSize: _0("v2"),
  uProjection: _0("m4"),
  uInvProjection: _0("m4"),
  uBounds: _0("v4"),
  uCenter: _0("v3"),
  uMode: _0("i"),
  dOrthographic: p1("number"),
  uNear: _0("f"),
  uFar: _0("f"),
  dBlurSize: p1("number"),
  uBlurSpread: _0("f"),
  uInFocus: _0("f"),
  uPPM: _0("f")
}, Wq1 = v8("dof", p6, fw0);
function Kq1(Z, J, $, X) {
  let Y = J.getWidth(), Q = J.getHeight(), W = {
    ...B6,
    tDepthOpaque: C.create($),
    tDepthTransparent: C.create(X),
    tColor: C.create(J),
    uTexSize: C.create(h0.create(Y, Q)),
    uProjection: C.create(e.identity()),
    uInvProjection: C.create(e.identity()),
    uBounds: C.create(E2()),
    uCenter: C.create(M()),
    uMode: C.create(0),
    dOrthographic: C.create(0),
    uNear: C.create(1),
    uFar: C.create(1e4),
    dBlurSize: C.create(5),
    uBlurSpread: C.create(300),
    uInFocus: C.create(20),
    uPPM: C.create(20)
  }, K = { ...Qq1 }, G = t8(Z, "triangles", Wq1, K, W);
  return e8(G, W);
}

// node_modules/molstar/lib/mol-gl/shader/bloom/composite.frag.js
var bw0 = `
precision highp float;
precision highp int;
precision highp sampler2D;

uniform vec2 uTexSizeInv;

uniform sampler2D tBlur1;
uniform sampler2D tBlur2;
uniform sampler2D tBlur3;
uniform sampler2D tBlur4;
uniform sampler2D tBlur5;
uniform float uBloomStrength;
uniform float uBloomRadius;
uniform float uBloomFactors[5];
uniform vec3 uBloomTints[5];

float lerpBloomFactor(const in float factor) {
    float mirrorFactor = 1.2 - factor;
    return mix(factor, mirrorFactor, uBloomRadius);
}

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

    gl_FragColor = uBloomStrength * (
        lerpBloomFactor(uBloomFactors[0]) * vec4(uBloomTints[0], 1.0) * texture2D(tBlur1, coords) +
        lerpBloomFactor(uBloomFactors[1]) * vec4(uBloomTints[1], 1.0) * texture2D(tBlur2, coords) +
        lerpBloomFactor(uBloomFactors[2]) * vec4(uBloomTints[2], 1.0) * texture2D(tBlur3, coords) +
        lerpBloomFactor(uBloomFactors[3]) * vec4(uBloomTints[3], 1.0) * texture2D(tBlur4, coords) +
        lerpBloomFactor(uBloomFactors[4]) * vec4(uBloomTints[4], 1.0) * texture2D(tBlur5, coords)
    );
}
`;

// node_modules/molstar/lib/mol-gl/shader/bloom/luminosity.frag.js
var xw0 = `
precision highp float;
precision highp int;
precision highp sampler2D;

uniform sampler2D tColor;
uniform sampler2D tEmissive;
uniform sampler2D tDepth;
uniform vec2 uTexSizeInv;

uniform vec3 uDefaultColor;
uniform float uDefaultOpacity;
uniform float uLuminosityThreshold;
uniform float uSmoothWidth;

#include common

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

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

void main(void) {
    vec2 coords = gl_FragCoord.xy * uTexSizeInv;
    vec4 texel = texture2D(tColor, coords);
    float emissive = texture2D(tEmissive, coords).a;
    float depth = getDepth(coords);

    if (isBackground(depth)) {
        gl_FragColor = vec4(0.0, 0.0, 0.0, 0.0);
        return;
    }

    vec4 outputColor = vec4(uDefaultColor.rgb, uDefaultOpacity);

    #if defined(dMode_luminosity)
        vec3 luma = vec3(0.299, 0.587, 0.114);
        float v = dot(texel.xyz, luma);
        float alpha = smoothstep(uLuminosityThreshold, uLuminosityThreshold + uSmoothWidth, v);

        gl_FragColor = mix(outputColor, texel, alpha);
    #elif defined(dMode_emissive)
        gl_FragColor = mix(outputColor, texel, emissive);
    #endif
}
`;

// node_modules/molstar/lib/mol-gl/shader/bloom/blur.frag.js
var yw0 = `
precision highp float;
precision highp int;
precision highp sampler2D;

uniform sampler2D tInput;
uniform vec2 uTexSizeInv;

uniform vec2 uDirection;
uniform float uGaussianCoefficients[dKernelRadius];

void main(void) {
    vec2 coords = gl_FragCoord.xy * uTexSizeInv;
    float weightSum = uGaussianCoefficients[0];
    vec4 diffuseSum = texture2D(tInput, coords) * weightSum;

    for(int i = 1; i < dKernelRadius; ++i) {
        float x = float(i);
        float w = uGaussianCoefficients[i];
        vec2 offset = uDirection * uTexSizeInv * x;
        vec4 sample1 = texture2D(tInput, coords + offset);
        vec4 sample2 = texture2D(tInput, coords - offset);
        diffuseSum += (sample1 + sample2) * w;
        weightSum += 2.0 * w;
    }

    gl_FragColor = diffuseSum / weightSum;
}
`;

// node_modules/molstar/lib/mol-canvas3d/passes/bloom.js
var Ce = 5, gw0 = {
  strength: j.Numeric(1, { min: 0, max: 3, step: 0.1 }),
  radius: j.Numeric(0, { min: 0, max: 1, step: 0.01 }),
  threshold: j.Numeric(0, { min: 0, max: 1, step: 0.01 }, { description: "Luminosity threshold", hideIf: (Z) => Z.mode === "emissive" }),
  mode: j.Select("emissive", [["luminosity", "Luminosity"], ["emissive", "Emissive"]])
};

class tR {
  static isEnabled(Z) {
    return Z.enabled && Z.bloom.name === "on";
  }
  constructor(Z, J, $) {
    this.webgl = Z, this.horizontalBlurTargets = [], this.verticalBlurTargets = [], this.emissiveTarget = Z.createRenderTarget(J, $, !0, "uint8", "linear", "rgba"), this.luminosityTarget = Z.createRenderTarget(J, $, !1, "uint8", "linear"), this.compositeTarget = Z.createRenderTarget(J, $, !1, "uint8", "linear");
    let X = Math.round(J / 2), Y = Math.round($ / 2);
    for (let W = 0;W < Ce; ++W)
      this.horizontalBlurTargets[W] = Z.createRenderTarget(X, Y, !1, "uint8", "linear"), this.verticalBlurTargets[W] = Z.createRenderTarget(X, Y, !1, "uint8", "linear"), X = Math.round(X / 2), Y = Math.round(Y / 2);
    let Q = k9();
    this.luminosityRenderable = Nq1(Z, Q, Q, Q), this.blurRenderable = Oq1(Z, Q), this.compositeRenderable = Mq1(Z, J, $, this.verticalBlurTargets[0].texture, this.verticalBlurTargets[1].texture, this.verticalBlurTargets[2].texture, this.verticalBlurTargets[3].texture, this.verticalBlurTargets[4].texture), this.copyRenderable = T5(Z, this.compositeTarget.texture);
  }
  getByteCount() {
    return this.emissiveTarget.getByteCount() + this.luminosityTarget.getByteCount() + this.compositeTarget.getByteCount() + this.horizontalBlurTargets.reduce((Z, J) => Z + J.getByteCount(), 0) + this.verticalBlurTargets.reduce((Z, J) => Z + J.getByteCount(), 0);
  }
  setSize(Z, J) {
    let $ = this.luminosityTarget.getWidth(), X = this.luminosityTarget.getHeight();
    if (Z !== $ || J !== X) {
      this.emissiveTarget.setSize(Z, J), this.luminosityTarget.setSize(Z, J), this.compositeTarget.setSize(Z, J);
      let Y = Math.round(Z / 2), Q = Math.round(J / 2);
      for (let W = 0;W < Ce; ++W)
        this.horizontalBlurTargets[W].setSize(Y, Q), this.verticalBlurTargets[W].setSize(Y, Q), Y = Math.round(Y / 2), Q = Math.round(Q / 2);
      C.update(this.luminosityRenderable.values.uTexSizeInv, h0.set(this.compositeRenderable.values.uTexSizeInv.ref.value, 1 / Z, 1 / J)), C.update(this.compositeRenderable.values.uTexSizeInv, h0.set(this.compositeRenderable.values.uTexSizeInv.ref.value, 1 / Z, 1 / J)), C.update(this.copyRenderable.values.uTexSize, h0.set(this.copyRenderable.values.uTexSize.ref.value, Z, J));
    }
  }
  update(Z, J, $, X) {
    let Y = !1;
    if (this.luminosityRenderable.values.tColor.ref.value !== Z)
      C.update(this.luminosityRenderable.values.tColor, Z), Y = !0;
    if (this.luminosityRenderable.values.tEmissive.ref.value !== J)
      C.update(this.luminosityRenderable.values.tEmissive, J), Y = !0;
    if (this.luminosityRenderable.values.tDepth.ref.value !== $)
      C.update(this.luminosityRenderable.values.tDepth, $), Y = !0;
    if (this.luminosityRenderable.values.dMode.ref.value !== X.mode)
      C.update(this.luminosityRenderable.values.dMode, X.mode), Y = !0;
    if (C.updateIfChanged(this.luminosityRenderable.values.uLuminosityThreshold, X.threshold), Y)
      this.luminosityRenderable.update();
    let Q = !1;
    if (this.blurRenderable.values.tInput.ref.value !== Z)
      C.update(this.blurRenderable.values.tInput, Z), Q = !0;
    if (Q)
      this.blurRenderable.update();
    C.update(this.compositeRenderable.values.uBloomRadius, X.radius), C.update(this.compositeRenderable.values.uBloomStrength, X.strength);
  }
  render(Z, J) {
    if (K1)
      this.webgl.timer.mark("BloomPass.render");
    let { gl: $, state: X } = this.webgl, { x: Y, y: Q, width: W, height: K } = Z;
    X.viewport(Y, Q, W, K), X.scissor(Y, Q, W, K), X.enable($.SCISSOR_TEST), X.disable($.BLEND), X.disable($.DEPTH_TEST), X.depthMask(!1), this.luminosityTarget.bind(), this.luminosityRenderable.render();
    for (let G = 0;G < Ce; ++G) {
      let H = this.horizontalBlurTargets[G].getWidth(), N = this.horizontalBlurTargets[G].getHeight();
      X.viewport(0, 0, H, N), X.scissor(0, 0, H, N), C.update(this.blurRenderable.values.dKernelRadius, ke[G]), C.update(this.blurRenderable.values.uGaussianCoefficients, Fq1(ke[G])), C.update(this.blurRenderable.values.uTexSizeInv, h0.set(this.blurRenderable.values.uTexSizeInv.ref.value, 1 / H, 1 / N)), this.horizontalBlurTargets[G].bind(), C.update(this.blurRenderable.values.tInput, G === 0 ? this.luminosityTarget.texture : this.verticalBlurTargets[G - 1].texture), C.update(this.blurRenderable.values.uDirection, Uq1), this.blurRenderable.update(), this.blurRenderable.render(), this.verticalBlurTargets[G].bind(), C.update(this.blurRenderable.values.tInput, this.horizontalBlurTargets[G].texture), C.update(this.blurRenderable.values.uDirection, Lq1), this.blurRenderable.update(), this.blurRenderable.render();
    }
    if (X.viewport(Y, Q, W, K), X.scissor(Y, Q, W, K), this.compositeTarget.bind(), this.compositeRenderable.update(), this.compositeRenderable.render(), J)
      J.bind();
    else
      this.webgl.bindDrawingBuffer();
    if (X.enable($.BLEND), X.blendFunc($.ONE, $.ONE), this.copyRenderable.render(), K1)
      this.webgl.timer.markEnd("BloomPass.render");
  }
}
var Gq1 = {
  ...A6,
  tColor: o1("texture", "rgba", "ubyte", "linear"),
  tEmissive: o1("texture", "rgba", "ubyte", "linear"),
  tDepth: o1("texture", "rgba", "ubyte", "nearest"),
  uTexSizeInv: _0("v2"),
  uDefaultColor: _0("v3"),
  uDefaultOpacity: _0("f"),
  uLuminosityThreshold: _0("f"),
  uSmoothWidth: _0("f"),
  dMode: p1("string", ["luminosity", "emissive"])
}, Hq1 = v8("Bloom Luminosity", p6, xw0);
function Nq1(Z, J, $, X) {
  let Y = J.getWidth(), Q = J.getHeight(), W = {
    ...B6,
    tColor: C.create(J),
    tEmissive: C.create($),
    tDepth: C.create(X),
    uTexSizeInv: C.create(h0.create(1 / Y, 1 / Q)),
    uDefaultColor: C.create(M()),
    uDefaultOpacity: C.create(0),
    uLuminosityThreshold: C.create(0),
    uSmoothWidth: C.create(1),
    dMode: C.create("emissive")
  }, K = { ...Gq1 }, G = t8(Z, "triangles", Hq1, K, W);
  return e8(G, W);
}
function qq1(Z) {
  let J = [];
  for (let $ = 0;$ < Z; ++$)
    J.push(0.39894 * Math.exp(-0.5 * $ * $ / (Z * Z)) / Z);
  return J;
}
var Fq1 = QH(qq1), ke = [3, 5, 7, 9, 11], Uq1 = h0.create(1, 0), Lq1 = h0.create(0, 1), Rq1 = {
  ...A6,
  tInput: o1("texture", "rgba", "ubyte", "linear"),
  uTexSizeInv: _0("v2"),
  uDirection: _0("v2"),
  uGaussianCoefficients: _0("f[]"),
  dKernelRadius: p1("number")
}, Eq1 = v8("Bloom Blur", p6, yw0);
function Oq1(Z, J) {
  let $ = J.getWidth(), X = J.getHeight(), Y = {
    ...B6,
    tInput: C.create(J),
    uTexSizeInv: C.create(h0.create(1 / $, 1 / X)),
    uDirection: C.create(h0()),
    uGaussianCoefficients: C.create([]),
    dKernelRadius: C.create(ke[0])
  }, Q = { ...Rq1 }, W = t8(Z, "triangles", Eq1, Q, Y);
  return e8(W, Y);
}
var zq1 = {
  ...A6,
  tBlur1: o1("texture", "rgba", "ubyte", "linear"),
  tBlur2: o1("texture", "rgba", "ubyte", "linear"),
  tBlur3: o1("texture", "rgba", "ubyte", "linear"),
  tBlur4: o1("texture", "rgba", "ubyte", "linear"),
  tBlur5: o1("texture", "rgba", "ubyte", "linear"),
  uTexSizeInv: _0("v2"),
  uBloomStrength: _0("f"),
  uBloomRadius: _0("f"),
  uBloomFactors: _0("f[]"),
  uBloomTints: _0("v3[]")
}, Dq1 = v8("Bloom Composite", p6, bw0);
function Mq1(Z, J, $, X, Y, Q, W, K) {
  let G = {
    ...B6,
    uTexSizeInv: C.create(h0.create(J, $)),
    tBlur1: C.create(X),
    tBlur2: C.create(Y),
    tBlur3: C.create(Q),
    tBlur4: C.create(W),
    tBlur5: C.create(K),
    uBloomStrength: C.create(1),
    uBloomRadius: C.create(0),
    uBloomFactors: C.create([1, 0.8, 0.6, 0.4, 0.2]),
    uBloomTints: C.create(new Array(15).fill(1))
  }, H = { ...zq1 }, N = t8(Z, "triangles", Dq1, H, G);
  return e8(N, G);
}

// node_modules/molstar/lib/mol-gl/shader/outlines.frag.js
var mw0 = `
precision highp float;
precision highp int;
precision highp sampler2D;

uniform sampler2D tDepthOpaque;
uniform sampler2D tDepthTransparent;
uniform vec2 uTexSize;

uniform float uNear;
uniform float uFar;
uniform mat4 uInvProjection;

uniform float uOutlineThreshold;

#include common

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

float getDepthOpaque(const in vec2 coords) {
    #ifdef depthTextureSupport
        return texture2D(tDepthOpaque, coords).r;
    #else
        return unpackRGBAToDepth(texture2D(tDepthOpaque, coords));
    #endif
}

vec2 getDepthTransparentWithAlpha(const in vec2 coords) {
    #ifdef dTransparentOutline
        return unpackRGBAToDepthWithAlpha(texture2D(tDepthTransparent, coords));
    #else
        return vec2(1.0, 0.0);
    #endif
}

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

float getPixelSize(const in vec2 coords, const in float depth) {
    vec3 viewPos0 = screenSpaceToViewSpace(vec3(coords, depth), uInvProjection);
    vec3 viewPos1 = screenSpaceToViewSpace(vec3(coords + vec2(1.0, 0.0) / uTexSize, depth), uInvProjection);
    return distance(viewPos0, viewPos1);
}

void main(void) {
    float backgroundViewZ = 2.0 * uFar;

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

    float selfDepthOpaque = getDepthOpaque(coords);
    float selfViewZOpaque = isBackground(selfDepthOpaque) ? backgroundViewZ : getViewZ(selfDepthOpaque);
    float pixelSizeOpaque = getPixelSize(coords, selfDepthOpaque) * uOutlineThreshold;

    vec2 selfDepthTransparentWithAlpha = getDepthTransparentWithAlpha(coords);
    float selfDepthTransparent = selfDepthTransparentWithAlpha.x;
    float selfViewZTransparent = isBackground(selfDepthTransparent) ? backgroundViewZ : getViewZ(selfDepthTransparent);
    float pixelSizeTransparent = getPixelSize(coords, selfDepthTransparent) * uOutlineThreshold;

    float bestOpaqueDepth = 1.0;
    float bestTransparentDepth = 1.0;
    float bestTransparentAlpha = 0.0;

    float opaqueOutlineFlag = 0.0;
    float transparentOutlineFlag = 0.0;

    for (int y = -1; y <= 1; y++) {
        for (int x = -1; x <= 1; x++) {
            vec2 sampleCoords = coords + vec2(float(x), float(y)) * invTexSize;

            // Opaque
            float sampleDepthOpaque = getDepthOpaque(sampleCoords);
            float sampleViewZOpaque = isBackground(sampleDepthOpaque) ? backgroundViewZ : getViewZ(sampleDepthOpaque);
            if (abs(selfViewZOpaque - sampleViewZOpaque) > pixelSizeOpaque && selfDepthOpaque > sampleDepthOpaque && sampleDepthOpaque <= bestOpaqueDepth) {
                bestOpaqueDepth = sampleDepthOpaque;
                opaqueOutlineFlag = 1.0;
            }

            // Transparent
            vec2 sampleDepthTransparentWithAlpha = getDepthTransparentWithAlpha(sampleCoords);
            float sampleDepthTransparent = sampleDepthTransparentWithAlpha.x;
            float sampleAlphaTransparent = sampleDepthTransparentWithAlpha.y;
            float sampleViewZTransparent = isBackground(sampleDepthTransparent) ? backgroundViewZ : getViewZ(sampleDepthTransparent);
            if (abs(selfViewZTransparent - sampleViewZTransparent) > pixelSizeTransparent && selfDepthTransparent > sampleDepthTransparent && sampleDepthTransparent <= bestTransparentDepth) {
                bestTransparentDepth = sampleDepthTransparent;
                bestTransparentAlpha = sampleAlphaTransparent;
                transparentOutlineFlag = 1.0;
            }
        }
    }

    if (transparentOutlineFlag > 0.0 && bestOpaqueDepth < 1.0 && bestTransparentDepth > bestOpaqueDepth) {
        transparentOutlineFlag = 0.0;
        bestTransparentAlpha = 0.0;
    }

    vec2 depthPacked; // Pack depth in G/B channels
    float outlineTypeFlag = 0.0;
    if (opaqueOutlineFlag > 0.0 && transparentOutlineFlag > 0.0) {
        outlineTypeFlag = 0.75; // Both
        depthPacked = packUnitIntervalToRG(bestOpaqueDepth);
    } else if (transparentOutlineFlag > 0.0) {
        outlineTypeFlag = 0.5;  // Transparent only
        depthPacked = packUnitIntervalToRG(bestTransparentDepth);
    } else if (opaqueOutlineFlag > 0.0) {
        outlineTypeFlag = 0.25; // Opaque only
        depthPacked = packUnitIntervalToRG(bestOpaqueDepth);
    }

    float alpha = clamp(bestTransparentAlpha, 0.0, 0.5) * 2.0; // limiting to range [0.0, 0.5] to improve alpha precision since we don't need a wider range
    float packedFlagWithAlpha = pack2x4(vec2(outlineTypeFlag, alpha)); // pack outlineType with alpha
    gl_FragColor = vec4(packedFlagWithAlpha, depthPacked.x, depthPacked.y, bestTransparentDepth);
}
`;

// node_modules/molstar/lib/mol-canvas3d/passes/outline.js
var dw0 = {
  scale: j.Numeric(1, { min: 1, max: 5, step: 1 }),
  threshold: j.Numeric(0.33, { min: 0.01, max: 1, step: 0.01 }),
  color: j.Color(i0(0)),
  includeTransparent: j.Boolean(!0, { description: "Whether to show outline for transparent objects" })
};

class LU {
  static isEnabled(Z) {
    return Z.enabled && Z.outline.name !== "off";
  }
  constructor(Z, J, $, X, Y) {
    this.webgl = Z, this.target = Z.createRenderTarget(J, $, !1), this.renderable = Bq1(Z, Y, X, !0);
  }
  getByteCount() {
    return this.target.getByteCount();
  }
  setSize(Z, J) {
    let [$, X] = this.renderable.values.uTexSize.ref.value;
    if (Z !== $ || J !== X)
      this.target.setSize(Z, J), C.update(this.renderable.values.uTexSize, h0.set(this.renderable.values.uTexSize.ref.value, Z, J));
  }
  update(Z, J, $, X) {
    var Y;
    let Q = !1, W = Z.state.mode === "orthographic" ? 1 : 0, K = this.renderable.values.uInvProjection.ref.value;
    e.invert(K, Z.projection);
    let G = (Y = J.includeTransparent) !== null && Y !== void 0 ? Y : !0, H = Math.max(1, Math.round(J.scale * this.webgl.pixelRatio)) - 1, N = 50 * J.threshold * this.webgl.pixelRatio;
    if (C.updateIfChanged(this.renderable.values.uNear, Z.near), C.updateIfChanged(this.renderable.values.uFar, Z.far), C.update(this.renderable.values.uInvProjection, K), this.renderable.values.dTransparentOutline.ref.value !== G)
      Q = !0, C.update(this.renderable.values.dTransparentOutline, G);
    if (this.renderable.values.dOrthographic.ref.value !== W)
      Q = !0, C.update(this.renderable.values.dOrthographic, W);
    if (C.updateIfChanged(this.renderable.values.uOutlineThreshold, N), this.renderable.values.tDepthTransparent.ref.value !== $)
      Q = !0, C.update(this.renderable.values.tDepthTransparent, $);
    if (this.renderable.values.tDepthOpaque.ref.value !== X)
      Q = !0, C.update(this.renderable.values.tDepthOpaque, X);
    if (Q)
      this.renderable.update();
    return { transparentOutline: G, outlineScale: H };
  }
  render() {
    if (K1)
      this.webgl.timer.mark("OutlinePass.render");
    if (this.target.bind(), this.renderable.render(), K1)
      this.webgl.timer.markEnd("OutlinePass.render");
  }
}
var Aq1 = {
  ...A6,
  tDepthOpaque: o1("texture", "rgba", "ubyte", "nearest"),
  tDepthTransparent: o1("texture", "rgba", "ubyte", "nearest"),
  uTexSize: _0("v2"),
  dOrthographic: p1("number"),
  uNear: _0("f"),
  uFar: _0("f"),
  uInvProjection: _0("m4"),
  uOutlineThreshold: _0("f"),
  dTransparentOutline: p1("boolean")
};
function Bq1(Z, J, $, X) {
  let Y = J.getWidth(), Q = J.getHeight(), W = {
    ...B6,
    tDepthOpaque: C.create(J),
    tDepthTransparent: C.create($),
    uTexSize: C.create(h0.create(Y, Q)),
    dOrthographic: C.create(0),
    uNear: C.create(1),
    uFar: C.create(1e4),
    uInvProjection: C.create(e.identity()),
    uOutlineThreshold: C.create(0.33),
    dTransparentOutline: C.create(X)
  }, K = { ...Aq1 }, G = v8("outlines", p6, mw0), H = t8(Z, "triangles", G, K, W);
  return e8(H, W);
}

// node_modules/molstar/lib/mol-gl/shader/shadows.frag.js
var pw0 = `
precision highp float;
precision highp int;
precision highp sampler2D;

#include common

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

uniform float uNear;
uniform float uFar;

#if dLightCount != 0
    uniform vec3 uLightDirection[dLightCount];
    uniform vec3 uLightColor[dLightCount];
#endif

uniform vec3 uAmbientColor;

uniform mat4 uProjection;
uniform mat4 uInvProjection;

uniform float uMaxDistance;
uniform float uTolerance;

// Map full [0,1] coords -> bounds [0,1] coords
vec2 fullCoordsToBoundsCoords(vec2 fullCoords) {
    return (fullCoords - uBounds.xy) / (uBounds.zw - uBounds.xy);
}

// Map bounds [0,1] coords -> full [0,1] coords
vec2 boundsCoordsToFullCoords(vec2 boundsCoords) {
    return uBounds.xy + (uBounds.zw - uBounds.xy) * boundsCoords;
}

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 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) {
    #ifdef depthTextureSupport
        return texture2D(tDepth, coords).r;
    #else
        return unpackRGBAToDepth(texture2D(tDepth, coords));
    #endif
}

float screenFade(const in vec2 coords) {
    vec2 c = (coords - uBounds.xy) / (uBounds.zw - uBounds.xy);
    vec2 fade = max(12.0 * abs(c - 0.5) - 5.0, vec2(0.0));
    return saturate(1.0 - dot(fade, fade));
}

// based on https://panoskarabelas.com/posts/screen_space_shadows/
vec3 screenSpaceShadow(const in vec3 position, const in vec3 lightDirection, const in vec3 lightColor, const in float stepLength) {
    // Ray position and direction (in view-space)
    vec3 rayPos = position;
    vec3 rayDir = -lightDirection;

    // Compute ray step
    vec3 rayStep = rayDir * stepLength;

    // Ray march towards the light
    vec4 rayCoords = vec4(0.0);
    for (int i = 0; i < dSteps; ++i) {
        // Step the ray
        rayPos += rayStep;

        rayCoords = uProjection * vec4(rayPos, 1.0);
        rayCoords.xyz = (rayCoords.xyz / rayCoords.w) * 0.5 + 0.5;
        rayCoords.xy = boundsCoordsToFullCoords(rayCoords.xy);

        if (outsideBounds(rayCoords.xy)) {
            return lightColor;
        }

        // Compute the difference between the ray's and the camera's depth
        float depth = getDepth(rayCoords.xy);
        float viewZ = getViewZ(depth);
        float zDelta = rayPos.z - viewZ;

        if (zDelta < uTolerance) {
            // Fade out as we approach the edges of the screen
            return mix(vec3(0.0), lightColor, 1.0 - screenFade(rayCoords.xy));
        }
    }

    return lightColor;
}

void main(void) {
    vec2 invTexSize = 1.0 / uTexSize;
    vec2 selfCoords = gl_FragCoord.xy * invTexSize;
    float selfDepth = getDepth(selfCoords);

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

    vec2 selfBoundsCoords = fullCoordsToBoundsCoords(selfCoords);
    if (any(lessThan(selfBoundsCoords, vec2(0.0))) || any(greaterThan(selfBoundsCoords, vec2(1.0)))) {
        gl_FragColor = vec4(0.0);
        return;
    }

    vec3 selfViewPos = screenSpaceToViewSpace(vec3(selfBoundsCoords, selfDepth), uInvProjection);
    float stepLength = uMaxDistance / float(dSteps);

    float l = length(uAmbientColor);
    float a = l;
    #if dLightCount != 0
        vec3 s;
        #pragma unroll_loop_start
        for (int i = 0; i < dLightCount; ++i) {
            s = screenSpaceShadow(selfViewPos, uLightDirection[i], uLightColor[i], stepLength);
            l += length(s);
            a += length(uLightColor[i]);
        }
        #pragma unroll_loop_end
    #endif

    gl_FragColor = vec4(l / a);
}
`;

// node_modules/molstar/lib/mol-canvas3d/passes/shadow.js
var uw0 = {
  steps: j.Numeric(1, { min: 1, max: 64, step: 1 }),
  maxDistance: j.Numeric(3, { min: 0, max: 256, step: 1 }),
  tolerance: j.Numeric(1, { min: 0, max: 10, step: 0.1 })
};

class eV {
  static isEnabled(Z) {
    return Z.enabled && Z.shadow.name !== "off";
  }
  constructor(Z, J, $, X) {
    this.webgl = Z, this.invProjection = e.identity(), this.invHeadRotation = e.identity(), this.target = Z.createRenderTarget(J, $, !1), this.renderable = jq1(Z, X);
  }
  getByteCount() {
    return this.target.getByteCount();
  }
  setSize(Z, J) {
    let [$, X] = this.renderable.values.uTexSize.ref.value;
    if (Z !== $ || J !== X)
      this.target.setSize(Z, J), C.update(this.renderable.values.uTexSize, h0.set(this.renderable.values.uTexSize.ref.value, Z, J));
  }
  update(Z, J, $, X) {
    let Y = !1, Q = Z.state.mode === "orthographic" ? 1 : 0, [W, K] = this.renderable.values.uTexSize.ref.value, G = Z.viewport;
    if (C.update(this.renderable.values.uProjection, Z.projection), C.update(this.renderable.values.uInvProjection, e.invert(this.invProjection, Z.projection)), E2.set(this.renderable.values.uBounds.ref.value, G.x / W, G.y / K, (G.x + G.width) / W, (G.y + G.height) / K), C.update(this.renderable.values.uBounds, this.renderable.values.uBounds.ref.value), C.updateIfChanged(this.renderable.values.uNear, Z.near), C.updateIfChanged(this.renderable.values.uFar, Z.far), this.renderable.values.dOrthographic.ref.value !== Q)
      C.update(this.renderable.values.dOrthographic, Q), Y = !0;
    if (C.updateIfChanged(this.renderable.values.uMaxDistance, X.maxDistance * Z.scale), C.updateIfChanged(this.renderable.values.uTolerance, X.tolerance * Z.scale), this.renderable.values.dSteps.ref.value !== X.steps)
      C.update(this.renderable.values.dSteps, X.steps), Y = !0;
    if (!e.isZero(Z.headRotation))
      C.update(this.renderable.values.uLightDirection, Oe(J, e.invert(this.invHeadRotation, Z.headRotation)));
    else
      C.update(this.renderable.values.uLightDirection, J.direction);
    if (C.update(this.renderable.values.uLightColor, J.color), this.renderable.values.dLightCount.ref.value !== J.count)
      C.update(this.renderable.values.dLightCount, J.count), Y = !0;
    if (C.update(this.renderable.values.uAmbientColor, $), Y)
      this.renderable.update();
  }
  render() {
    if (K1)
      this.webgl.timer.mark("ShadowPass.render");
    if (this.target.bind(), this.renderable.render(), K1)
      this.webgl.timer.markEnd("ShadowPass.render");
  }
}
var wq1 = {
  ...A6,
  tDepth: o1("texture", "rgba", "ubyte", "nearest"),
  uTexSize: _0("v2"),
  uProjection: _0("m4"),
  uInvProjection: _0("m4"),
  uBounds: _0("v4"),
  dOrthographic: p1("number"),
  uNear: _0("f"),
  uFar: _0("f"),
  dSteps: p1("number"),
  uMaxDistance: _0("f"),
  uTolerance: _0("f"),
  uLightDirection: _0("v3[]"),
  uLightColor: _0("v3[]"),
  dLightCount: p1("number"),
  uAmbientColor: _0("v3")
};
function jq1(Z, J) {
  let $ = J.getWidth(), X = J.getHeight(), Y = {
    ...B6,
    tDepth: C.create(J),
    uTexSize: C.create(h0.create($, X)),
    uProjection: C.create(e.identity()),
    uInvProjection: C.create(e.identity()),
    uBounds: C.create(E2()),
    dOrthographic: C.create(0),
    uNear: C.create(1),
    uFar: C.create(1e4),
    dSteps: C.create(1),
    uMaxDistance: C.create(3),
    uTolerance: C.create(1),
    uLightDirection: C.create([]),
    uLightColor: C.create([]),
    dLightCount: C.create(0),
    uAmbientColor: C.create(M())
  }, Q = { ...wq1 }, W = v8("shadows", p6, pw0), K = t8(Z, "triangles", W, Q, Y);
  return e8(K, Y);
}

// node_modules/molstar/lib/mol-gl/shader/ssao.frag.js
var cw0 = `
precision highp float;
precision highp int;
precision highp sampler2D;

#include common


uniform sampler2D tDepth;
uniform sampler2D tDepthHalf;
uniform sampler2D tDepthQuarter;

#if defined(dIncludeTransparent)
    uniform sampler2D tDepthTransparent;
    uniform sampler2D tDepthHalfTransparent;
    uniform sampler2D tDepthQuarterTransparent;
#endif

uniform int uTransparencyFlag;

uniform vec2 uTexSize;
uniform vec4 uBounds;

uniform vec3 uSamples[dNSamples];

uniform mat4 uProjection;
uniform mat4 uInvProjection;

#ifdef dMultiScale
    uniform float uLevelRadius[dLevels];
    uniform float uLevelBias[dLevels];
    uniform float uNearThreshold;
    uniform float uFarThreshold;
#else
    uniform float uRadius;
#endif
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;
}

float getDepth(const in vec2 coords, const in int transparentFlag) {
    vec2 c = vec2(clamp(coords.x, uBounds.x, uBounds.z), clamp(coords.y, uBounds.y, uBounds.w));
    if (transparentFlag == 1){
        #if defined(dIncludeTransparent)
            return unpackRGBAToDepthWithAlpha(texture2D(tDepthTransparent, c)).x;
        #else
            return 1.0;
        #endif
    } else {
        #ifdef depthTextureSupport
            return texture2D(tDepth, c).r;
        #else
            return unpackRGBAToDepth(texture2D(tDepth, c));
        #endif
    }
}

#if defined(dIncludeTransparent)
    vec2 getDepthTransparentWithAlpha(const in vec2 coords){
        vec2 c = vec2(clamp(coords.x, uBounds.x, uBounds.z), clamp(coords.y, uBounds.y, uBounds.w));
        return unpackRGBAToDepthWithAlpha(texture2D(tDepthTransparent, c));
    }
#endif

#define dQuarterThreshold 0.1
#define dHalfThreshold 0.05

float getMappedDepth(const in vec2 coords, const in vec2 selfCoords) {
    vec2 c = vec2(clamp(coords.x, uBounds.x, uBounds.z), clamp(coords.y, uBounds.y, uBounds.w));
    float d = distance(coords, selfCoords);
    #ifdef depthTextureSupport
        if (d > dQuarterThreshold) {
            return texture2D(tDepthQuarter, c).r;
        } else if (d > dHalfThreshold) {
            return texture2D(tDepthHalf, c).r;
        } else {
            return texture2D(tDepth, c).r;
        }
    #else
        if (d > dQuarterThreshold) {
            return unpackRGBAToDepth(texture2D(tDepthQuarter, c));
        } else if (d > dHalfThreshold) {
            return unpackRGBAToDepth(texture2D(tDepthHalf, c));
        } else {
            return unpackRGBAToDepth(texture2D(tDepth, c));
        }
    #endif
}

#if defined(dIncludeTransparent)
    vec2 getMappedDepthTransparentWithAlpha(const in vec2 coords, const in vec2 selfCoords) {
        vec2 c = vec2(clamp(coords.x, uBounds.x, uBounds.z), clamp(coords.y, uBounds.y, uBounds.w));
        float d = distance(coords, selfCoords);
        if (d > dQuarterThreshold) {
            return unpackRGBAToDepthWithAlpha(texture2D(tDepthQuarterTransparent, c));
        } else if (d > dHalfThreshold) {
            return unpackRGBAToDepthWithAlpha(texture2D(tDepthHalfTransparent, c));
        } else {
            return unpackRGBAToDepthWithAlpha(texture2D(tDepthTransparent, c));
        }
    }
#endif

// adapted from https://gist.github.com/bgolus/a07ed65602c009d5e2f753826e8078a0
vec3 viewNormalAtPixelPositionAccurate(const in vec2 vpos, const in int transparentFlag) {
    // current pixel's depth
    float c = getDepth(vpos, transparentFlag);

    // get current pixel's view space position
    vec3 viewSpacePos_c = screenSpaceToViewSpace(vec3(vpos, c), uInvProjection);

    // get view space position at 1 pixel offsets in each major direction
    vec3 viewSpacePos_l = screenSpaceToViewSpace(vec3(vpos + vec2(-1.0, 0.0) / uTexSize, getDepth(vpos + vec2(-1.0, 0.0) / uTexSize, transparentFlag)), uInvProjection);
    vec3 viewSpacePos_r = screenSpaceToViewSpace(vec3(vpos + vec2( 1.0, 0.0) / uTexSize, getDepth(vpos + vec2( 1.0, 0.0) / uTexSize, transparentFlag)), uInvProjection);
    vec3 viewSpacePos_d = screenSpaceToViewSpace(vec3(vpos + vec2( 0.0,-1.0) / uTexSize, getDepth(vpos + vec2( 0.0,-1.0) / uTexSize, transparentFlag)), uInvProjection);
    vec3 viewSpacePos_u = screenSpaceToViewSpace(vec3(vpos + vec2( 0.0, 1.0) / uTexSize, getDepth(vpos + vec2( 0.0, 1.0) / uTexSize, transparentFlag)), uInvProjection);

    // get the difference between the current and each offset position
    vec3 l = viewSpacePos_c - viewSpacePos_l;
    vec3 r = viewSpacePos_r - viewSpacePos_c;
    vec3 d = viewSpacePos_c - viewSpacePos_d;
    vec3 u = viewSpacePos_u - viewSpacePos_c;

    // get depth values at 1 & 2 pixels offsets from current along the horizontal axis
    vec4 H = vec4(
        getDepth(vpos + vec2(-1.0, 0.0) / uTexSize, transparentFlag),
        getDepth(vpos + vec2( 1.0, 0.0) / uTexSize, transparentFlag),
        getDepth(vpos + vec2(-2.0, 0.0) / uTexSize, transparentFlag),
        getDepth(vpos + vec2( 2.0, 0.0) / uTexSize, transparentFlag)
    );

    // get depth values at 1 & 2 pixels offsets from current along the vertical axis
    vec4 V = vec4(
        getDepth(vpos + vec2(0.0,-1.0) / uTexSize, transparentFlag),
        getDepth(vpos + vec2(0.0, 1.0) / uTexSize, transparentFlag),
        getDepth(vpos + vec2(0.0,-2.0) / uTexSize, transparentFlag),
        getDepth(vpos + vec2(0.0, 2.0) / uTexSize, transparentFlag)
    );

    // current pixel's depth difference from slope of offset depth samples
    // differs from original article because we're using non-linear depth values
    // see article's comments
    vec2 he = abs((2.0 * H.xy - H.zw) - c);
    vec2 ve = abs((2.0 * V.xy - V.zw) - c);

    // pick horizontal and vertical diff with the smallest depth difference from slopes
    vec3 hDeriv = he.x < he.y ? l : r;
    vec3 vDeriv = ve.x < ve.y ? d : u;

    // get view space normal from the cross product of the best derivatives
    vec3 viewNormal = normalize(cross(hDeriv, vDeriv));

    return viewNormal;
}

float getPixelSize(const in vec2 coords, const in float depth) {
    vec3 viewPos0 = screenSpaceToViewSpace(vec3(coords, depth), uInvProjection);
    vec3 viewPos1 = screenSpaceToViewSpace(vec3(coords + vec2(1.0, 0.0) / uTexSize, depth), uInvProjection);
    return distance(viewPos0, viewPos1);
}

// 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, uTransparencyFlag);
    vec2 selfPackedDepth = packUnitIntervalToRG(selfDepth);

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

    vec3 selfViewNormal = viewNormalAtPixelPositionAccurate(selfCoords, uTransparencyFlag);
    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;
    #ifdef dMultiScale
        float pixelSize = getPixelSize(selfCoords, selfDepth);

        for(int l = 0; l < dLevels; l++) {
            // TODO: smooth transition
            if (pixelSize * uNearThreshold > uLevelRadius[l]) continue;
            if (pixelSize * uFarThreshold < uLevelRadius[l]) continue;

            float levelOcclusion = 0.0;
            for(int i = 0; i < dNSamples; i++) {
                // get sample position:
                vec3 sampleViewPos = TBN * uSamples[i];
                sampleViewPos = selfViewPos + sampleViewPos * uLevelRadius[l];

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

                // get sample depth:
                float sampleOcc = 0.0;
                #ifdef dIllumination
                    if (uTransparencyFlag == 1) {
                #endif
                    float sampleDepth = getMappedDepth(offset.xy, selfCoords);
                    float sampleViewZ = screenSpaceToViewSpace(vec3(offset.xy, sampleDepth), uInvProjection).z;

                    sampleOcc = step(sampleViewPos.z + 0.025, sampleViewZ) * smootherstep(0.0, 1.0, uLevelRadius[l] / abs(selfViewPos.z - sampleViewZ)) * uLevelBias[l];
                #ifdef dIllumination
                    }
                #endif
                #if defined(dIncludeTransparent)
                    vec2 sampleDepthWithAlpha = getMappedDepthTransparentWithAlpha(offset.xy, selfCoords);
                    if (!isBackground(sampleDepthWithAlpha.x)) {
                        float sampleViewZ = screenSpaceToViewSpace(vec3(offset.xy, sampleDepthWithAlpha.x), uInvProjection).z;
                        sampleOcc = max(sampleOcc, step(sampleViewPos.z + 0.025, sampleViewZ) * smootherstep(0.0, 1.0, uLevelRadius[l] / abs(selfViewPos.z - sampleViewZ)) * uLevelBias[l] * sampleDepthWithAlpha.y);
                    }
                #endif

                levelOcclusion += sampleOcc;
            }
            occlusion = max(occlusion, levelOcclusion);
        }
    #else
        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 sampleOcc = 0.0;
            #ifdef dIllumination
                if (uTransparencyFlag == 1) {
            #endif
                    // NOTE: using getMappedDepth here causes issues on some mobile devices
                    float sampleDepth = getDepth(offset.xy, 0);
                    float sampleViewZ = screenSpaceToViewSpace(vec3(offset.xy, sampleDepth), uInvProjection).z;

                    sampleOcc = step(sampleViewPos.z + 0.025, sampleViewZ) * smootherstep(0.0, 1.0, uRadius / abs(selfViewPos.z - sampleViewZ));
            #ifdef dIllumination
                }
            #endif
            #if defined(dIncludeTransparent)
                vec2 sampleDepthWithAlpha = getDepthTransparentWithAlpha(offset.xy);
                if (!isBackground(sampleDepthWithAlpha.x)) {
                    float sampleViewZ = screenSpaceToViewSpace(vec3(offset.xy, sampleDepthWithAlpha.x), uInvProjection).z;
                    sampleOcc = max(sampleOcc, step(sampleViewPos.z + 0.025, sampleViewZ) * smootherstep(0.0, 1.0, uRadius / abs(selfViewPos.z - sampleViewZ)) * sampleDepthWithAlpha.y);
                }
            #endif

            occlusion += sampleOcc;
        }
    #endif
    occlusion = 1.0 - (uBias * occlusion / float(dNSamples));

    vec2 packedOcclusion = packUnitIntervalToRG(clamp(occlusion, 0.01, 1.0));

    gl_FragColor = vec4(packedOcclusion, selfPackedDepth);
}
`;

// node_modules/molstar/lib/mol-gl/shader/ssao-blur.frag.js
var lw0 = `
precision highp float;
precision highp int;
precision highp sampler2D;

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

uniform float uKernel[dOcclusionKernelSize];
uniform float uBlurDepthBias;

uniform float uBlurDirectionX;
uniform float uBlurDirectionY;

uniform mat4 uInvProjection;
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 isNearClip(const in float depth) {
    return depth == 0.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 getPixelSize(const in vec2 coords, const in float depth) {
    vec3 viewPos0 = screenSpaceToViewSpace(vec3(coords, depth), uInvProjection);
    vec3 viewPos1 = screenSpaceToViewSpace(vec3(coords + vec2(1.0, 0.0) / uTexSize, depth), uInvProjection);
    return distance(viewPos0, viewPos1);
}

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) or if near clip
    if ((isBackground(selfDepth) && uBlurDirectionY != 0.0) || isNearClip(selfDepth)) {
        gl_FragColor = vec4(packUnitIntervalToRG(1.0), packedDepth);
        return;
    }

    float selfViewZ = getViewZ(selfDepth);
    float pixelSize = getPixelSize(coords, selfDepth);

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

    float sum = 0.0;
    float kernelSum = 0.0;
    const int halfKernelSize = dOcclusionKernelSize / 2;
    // only if kernelSize is odd
    for (int i = -halfKernelSize; i <= halfKernelSize; i++) {
        if (abs(float(i)) > 1.0 && abs(float(i)) * pixelSize > 0.8) continue;

        vec2 sampleCoords = coords + float(i) * offset;
        if (outsideBounds(sampleCoords)) {
            continue;
        }

        vec4 sampleSsaoDepth = texture2D(tSsaoDepth, sampleCoords);

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

        float sampleViewZ = getViewZ(sampleDepth);
        if (abs(selfViewZ - sampleViewZ) >= uBlurDepthBias) {
            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);
}
`;

// node_modules/molstar/lib/mol-canvas3d/passes/ssao.js
var iw0 = {
  samples: j.Numeric(32, { min: 1, max: 256, step: 1 }),
  multiScale: j.MappedStatic("off", {
    on: j.Group({
      levels: j.ObjectList({
        radius: j.Numeric(5, { min: 0, max: 20, step: 0.1 }, { description: "Final occlusion radius is 2^x" }),
        bias: j.Numeric(1, { min: 0, max: 3, step: 0.1 })
      }, (Z) => `${Z.radius}, ${Z.bias}`, { defaultValue: [
        { radius: 2, bias: 1 },
        { radius: 5, bias: 1 },
        { radius: 8, bias: 1 },
        { radius: 11, bias: 1 }
      ] }),
      nearThreshold: j.Numeric(10, { min: 0, max: 50, step: 1 }),
      farThreshold: j.Numeric(1500, { min: 0, max: 1e4, step: 100 })
    }),
    off: j.Group({})
  }, { cycle: !0 }),
  radius: j.Numeric(5, { min: 0, max: 20, step: 0.1 }, { description: "Final occlusion radius is 2^x", hideIf: (Z) => (Z === null || Z === void 0 ? void 0 : Z.multiScale.name) === "on" }),
  bias: j.Numeric(0.8, { min: 0, max: 3, step: 0.1 }),
  blurKernelSize: j.Numeric(15, { min: 1, max: 25, step: 2 }),
  blurDepthBias: j.Numeric(0.5, { min: 0, max: 1, step: 0.01 }),
  resolutionScale: j.Numeric(1, { min: 0.1, max: 1, step: 0.05 }, { description: "Adjust resolution of occlusion calculation" }),
  color: j.Color(i0(0)),
  transparentThreshold: j.Numeric(0.4, { min: 0, max: 1, step: 0.05 })
};
function Tq1(Z, J, $) {
  let X = Z.length, { radius: Y, bias: Q } = $ || {
    radius: new Array(X * 3).fill(0),
    bias: new Array(X * 3).fill(0)
  };
  Z = Z.slice().sort((W, K) => W.radius - K.radius);
  for (let W = 0;W < X; ++W) {
    let K = Z[W];
    Y[W] = Math.pow(2, K.radius) * J, Q[W] = K.bias;
  }
  return { count: X, radius: Y, bias: Q };
}

class TH {
  static isEnabled(Z) {
    return Z.enabled && Z.occlusion.name !== "off";
  }
  static isTransparentEnabled(Z, J) {
    return Z.opacityAverage < 1 && Z.transparencyMin < J.transparentThreshold;
  }
  calcSsaoScale(Z) {
    return Math.min(1, 1 / this.webgl.pixelRatio) * Z;
  }
  getDepthTexture() {
    return this.ssaoScale === 1 ? this.depthTextureOpaque : this.downsampledDepthTargetOpaque.texture;
  }
  getTransparentDepthTexture() {
    return this.ssaoScale === 1 ? this.depthTextureTransparent : this.downsampledDepthTargetTransparent.texture;
  }
  constructor(Z, J, $, X, Y, Q) {
    this.webgl = Z, this.invProjection = e.identity(), this.levelsCameraScale = -1;
    let { textureFloatLinear: W } = Z.extensions;
    this.depthTextureOpaque = Y, this.depthTextureTransparent = Q, this.nSamples = 1, this.blurKernelSize = 1, this.ssaoScale = this.calcSsaoScale(1), this.texSize = [J, $], this.levels = [], this.framebuffer = Z.resources.framebuffer(), this.blurFirstPassFramebuffer = Z.resources.framebuffer(), this.blurSecondPassFramebuffer = Z.resources.framebuffer();
    let K = Math.floor(J * this.ssaoScale), G = Math.floor($ * this.ssaoScale), H = Math.max(1, Math.floor(K * 0.5)), N = Math.max(1, Math.floor(G * 0.5)), q = Math.max(1, Math.floor(K * 0.25)), U = Math.max(1, Math.floor(G * 0.25)), F = W ? "linear" : "nearest";
    this.downsampledDepthTargetOpaque = X ? Z.createRenderTarget(K, G, !1, "uint8", "linear", "rgba") : Z.createRenderTarget(K, G, !1, "float32", F, Z.isWebGL2 ? "alpha" : "rgba"), this.downsampleDepthRenderableOpaque = T5(Z, Y);
    let E = this.getDepthTexture();
    this.depthHalfTargetOpaque = X ? Z.createRenderTarget(H, N, !1, "uint8", "linear", "rgba") : Z.createRenderTarget(H, N, !1, "float32", F, Z.isWebGL2 ? "alpha" : "rgba"), this.depthHalfRenderableOpaque = T5(Z, E), this.depthQuarterTargetOpaque = X ? Z.createRenderTarget(q, U, !1, "uint8", "linear", "rgba") : Z.createRenderTarget(q, U, !1, "float32", F, Z.isWebGL2 ? "alpha" : "rgba"), this.depthQuarterRenderableOpaque = T5(Z, this.depthHalfTargetOpaque.texture), this.downsampledDepthTargetTransparent = Z.createRenderTarget(K, G, !1, "uint8", "linear", "rgba"), this.downsampleDepthRenderableTransparent = T5(Z, Q);
    let R = this.getTransparentDepthTexture();
    this.depthHalfTargetTransparent = Z.createRenderTarget(H, N, !1, "uint8", "linear", "rgba"), this.depthHalfRenderableTransparent = T5(Z, R), this.depthQuarterTargetTransparent = Z.createRenderTarget(q, U, !1, "uint8", "linear", "rgba"), this.depthQuarterRenderableTransparent = T5(Z, this.depthHalfTargetTransparent.texture), this.ssaoDepthTexture = Z.resources.texture("image-uint8", "rgba", "ubyte", "linear"), this.ssaoDepthTexture.define(K, G), this.ssaoDepthTexture.attachFramebuffer(this.framebuffer, "color0"), this.ssaoDepthTransparentTexture = Z.resources.texture("image-uint8", "rgba", "ubyte", "linear"), this.ssaoDepthTransparentTexture.define(K, G), this.depthBlurProxyTexture = Z.resources.texture("image-uint8", "rgba", "ubyte", "linear"), this.depthBlurProxyTexture.define(K, G), this.depthBlurProxyTexture.attachFramebuffer(this.blurFirstPassFramebuffer, "color0"), this.renderable = Vq1(Z, E, this.depthHalfTargetOpaque.texture, this.depthQuarterTargetOpaque.texture, R, this.depthHalfTargetTransparent.texture, this.depthQuarterTargetTransparent.texture), this.blurFirstPassRenderable = nw0(Z, this.ssaoDepthTransparentTexture, "horizontal"), this.blurSecondPassRenderable = nw0(Z, this.depthBlurProxyTexture, "vertical");
  }
  getByteCount() {
    return this.downsampledDepthTargetOpaque.getByteCount() + this.depthHalfTargetOpaque.getByteCount() + this.depthQuarterTargetOpaque.getByteCount() + this.downsampledDepthTargetTransparent.getByteCount() + this.depthHalfTargetTransparent.getByteCount() + this.depthQuarterTargetTransparent.getByteCount() + this.ssaoDepthTexture.getByteCount() + this.ssaoDepthTransparentTexture.getByteCount() + this.depthBlurProxyTexture.getByteCount();
  }
  setSize(Z, J) {
    let [$, X] = this.texSize, Y = this.calcSsaoScale(1);
    if (Z !== $ || J !== X || this.ssaoScale !== Y) {
      this.texSize.splice(0, 2, Z, J);
      let Q = Math.floor(Z * this.ssaoScale), W = Math.floor(J * this.ssaoScale);
      this.ssaoDepthTexture.define(Q, W), this.ssaoDepthTransparentTexture.define(Q, W), this.depthBlurProxyTexture.define(Q, W);
      let K = Math.max(1, Math.floor(Q * 0.5)), G = Math.max(1, Math.floor(W * 0.5)), H = Math.max(1, Math.floor(Q * 0.25)), N = Math.max(1, Math.floor(W * 0.25));
      this.downsampledDepthTargetOpaque.setSize(Q, W), this.depthHalfTargetOpaque.setSize(K, G), this.depthQuarterTargetOpaque.setSize(H, N), C.update(this.downsampleDepthRenderableOpaque.values.uTexSize, h0.set(this.downsampleDepthRenderableOpaque.values.uTexSize.ref.value, Q, W)), C.update(this.depthHalfRenderableOpaque.values.uTexSize, h0.set(this.depthHalfRenderableOpaque.values.uTexSize.ref.value, K, G)), C.update(this.depthQuarterRenderableOpaque.values.uTexSize, h0.set(this.depthQuarterRenderableOpaque.values.uTexSize.ref.value, H, N)), this.downsampledDepthTargetTransparent.setSize(Q, W), this.depthHalfTargetTransparent.setSize(K, G), this.depthQuarterTargetTransparent.setSize(H, N), C.update(this.downsampleDepthRenderableTransparent.values.uTexSize, h0.set(this.downsampleDepthRenderableTransparent.values.uTexSize.ref.value, Q, W)), C.update(this.depthHalfRenderableTransparent.values.uTexSize, h0.set(this.depthHalfRenderableTransparent.values.uTexSize.ref.value, K, G)), C.update(this.depthQuarterRenderableTransparent.values.uTexSize, h0.set(this.depthQuarterRenderableTransparent.values.uTexSize.ref.value, H, N)), C.update(this.renderable.values.uTexSize, h0.set(this.renderable.values.uTexSize.ref.value, Q, W)), C.update(this.blurFirstPassRenderable.values.uTexSize, h0.set(this.blurFirstPassRenderable.values.uTexSize.ref.value, Q, W)), C.update(this.blurSecondPassRenderable.values.uTexSize, h0.set(this.blurSecondPassRenderable.values.uTexSize.ref.value, Q, W));
      let q = this.getDepthTexture(), U = this.getTransparentDepthTexture();
      C.update(this.depthHalfRenderableOpaque.values.tColor, q), C.update(this.depthHalfRenderableTransparent.values.tColor, U), C.update(this.renderable.values.tDepth, q), C.update(this.renderable.values.tDepthTransparent, U), this.depthHalfRenderableOpaque.update(), this.depthHalfRenderableTransparent.update(), this.renderable.update();
    }
  }
  reset() {
    this.ssaoDepthTexture.attachFramebuffer(this.framebuffer, "color0"), this.depthBlurProxyTexture.attachFramebuffer(this.blurFirstPassFramebuffer, "color0");
  }
  update(Z, J, $, X = !1) {
    let Y = !1, Q = !1, W = !1, K = Z.state.mode === "orthographic" ? 1 : 0, G = e.invert(this.invProjection, Z.projection), [H, N] = this.texSize, q = Z.viewport;
    C.update(this.renderable.values.uProjection, Z.projection), C.update(this.renderable.values.uInvProjection, G);
    let U = this.renderable.values.uBounds, F = this.ssaoScale;
    if (E2.set(U.ref.value, Math.floor(q.x * F) / (H * F), Math.floor(q.y * F) / (N * F), Math.ceil((q.x + q.width) * F) / (H * F), Math.ceil((q.y + q.height) * F) / (N * F)), C.update(U, U.ref.value), C.update(this.blurFirstPassRenderable.values.uBounds, U.ref.value), C.update(this.blurSecondPassRenderable.values.uBounds, U.ref.value), C.updateIfChanged(this.blurFirstPassRenderable.values.uNear, Z.near), C.updateIfChanged(this.blurSecondPassRenderable.values.uNear, Z.near), C.updateIfChanged(this.blurFirstPassRenderable.values.uFar, Z.far), C.updateIfChanged(this.blurSecondPassRenderable.values.uFar, Z.far), C.update(this.blurFirstPassRenderable.values.uInvProjection, G), C.update(this.blurSecondPassRenderable.values.uInvProjection, G), C.update(this.blurFirstPassRenderable.values.uBlurDepthBias, $.blurDepthBias * Z.scale), C.update(this.blurSecondPassRenderable.values.uBlurDepthBias, $.blurDepthBias * Z.scale), this.blurFirstPassRenderable.values.dOrthographic.ref.value !== K)
      Q = !0, C.update(this.blurFirstPassRenderable.values.dOrthographic, K), C.update(this.blurSecondPassRenderable.values.dOrthographic, K);
    let E = TH.isTransparentEnabled(J, $);
    if (this.renderable.values.dIncludeTransparent.ref.value !== E)
      Y = !0, C.update(this.renderable.values.dIncludeTransparent, E);
    if (this.renderable.values.dIllumination.ref.value !== X)
      Y = !0, C.update(this.renderable.values.dIllumination, X);
    if (this.nSamples !== $.samples)
      Y = !0, this.nSamples = $.samples, C.update(this.renderable.values.uSamples, sw0(this.nSamples)), C.updateIfChanged(this.renderable.values.dNSamples, this.nSamples);
    let R = $.multiScale.name === "on";
    if (this.renderable.values.dMultiScale.ref.value !== R)
      Y = !0, C.update(this.renderable.values.dMultiScale, R);
    if ($.multiScale.name === "on") {
      let D = $.multiScale.params;
      if (this.levelsCameraScale !== Z.scale || !QY(this.levels, D.levels)) {
        Y = !0, this.levelsCameraScale = Z.scale, this.levels = D.levels;
        let A = Tq1(D.levels, Z.scale);
        C.updateIfChanged(this.renderable.values.dLevels, A.count), C.update(this.renderable.values.uLevelRadius, A.radius), C.update(this.renderable.values.uLevelBias, A.bias);
      }
      C.updateIfChanged(this.renderable.values.uNearThreshold, D.nearThreshold), C.updateIfChanged(this.renderable.values.uFarThreshold, D.farThreshold);
    } else
      C.updateIfChanged(this.renderable.values.uRadius, Math.pow(2, $.radius) * Z.scale);
    if (C.updateIfChanged(this.renderable.values.uBias, $.bias), this.blurKernelSize !== $.blurKernelSize) {
      Q = !0, this.blurKernelSize = $.blurKernelSize;
      let D = ow0(this.blurKernelSize);
      C.update(this.blurFirstPassRenderable.values.uKernel, D), C.update(this.blurSecondPassRenderable.values.uKernel, D), C.update(this.blurFirstPassRenderable.values.dOcclusionKernelSize, this.blurKernelSize), C.update(this.blurSecondPassRenderable.values.dOcclusionKernelSize, this.blurKernelSize);
    }
    let z = this.calcSsaoScale($.resolutionScale);
    if (this.ssaoScale !== z) {
      Y = !0, W = !0, this.ssaoScale = z;
      let D = Math.floor(H * this.ssaoScale), A = Math.floor(N * this.ssaoScale);
      this.ssaoDepthTexture.define(D, A), this.ssaoDepthTransparentTexture.define(D, A), this.depthBlurProxyTexture.define(D, A);
      let B = Math.floor(D * 0.5), T = Math.floor(A * 0.5), w = Math.floor(D * 0.25), V = Math.floor(A * 0.25);
      this.downsampledDepthTargetOpaque.setSize(D, A), this.depthHalfTargetOpaque.setSize(B, T), this.depthQuarterTargetOpaque.setSize(w, V);
      let P = this.getDepthTexture();
      C.update(this.depthHalfRenderableOpaque.values.tColor, P), C.update(this.renderable.values.tDepth, P), C.update(this.renderable.values.tDepthHalf, this.depthHalfTargetOpaque.texture), C.update(this.renderable.values.tDepthQuarter, this.depthQuarterTargetOpaque.texture), C.update(this.downsampleDepthRenderableOpaque.values.uTexSize, h0.set(this.downsampleDepthRenderableOpaque.values.uTexSize.ref.value, D, A)), C.update(this.depthHalfRenderableOpaque.values.uTexSize, h0.set(this.depthHalfRenderableOpaque.values.uTexSize.ref.value, B, T)), C.update(this.depthQuarterRenderableOpaque.values.uTexSize, h0.set(this.depthQuarterRenderableOpaque.values.uTexSize.ref.value, w, V)), this.downsampledDepthTargetTransparent.setSize(D, A), this.depthHalfTargetTransparent.setSize(B, T), this.depthQuarterTargetTransparent.setSize(w, V);
      let I = this.getTransparentDepthTexture();
      C.update(this.depthHalfRenderableTransparent.values.tColor, I), C.update(this.renderable.values.tDepthTransparent, I), C.update(this.renderable.values.tDepthHalfTransparent, this.depthHalfTargetTransparent.texture), C.update(this.renderable.values.tDepthQuarterTransparent, this.depthQuarterTargetTransparent.texture), C.update(this.downsampleDepthRenderableTransparent.values.uTexSize, h0.set(this.downsampleDepthRenderableTransparent.values.uTexSize.ref.value, D, A)), C.update(this.depthHalfRenderableTransparent.values.uTexSize, h0.set(this.depthHalfRenderableTransparent.values.uTexSize.ref.value, B, T)), C.update(this.depthQuarterRenderableTransparent.values.uTexSize, h0.set(this.depthQuarterRenderableTransparent.values.uTexSize.ref.value, w, V)), C.update(this.renderable.values.uTexSize, h0.set(this.renderable.values.uTexSize.ref.value, D, A)), C.update(this.blurFirstPassRenderable.values.uTexSize, h0.set(this.blurFirstPassRenderable.values.uTexSize.ref.value, D, A)), C.update(this.blurSecondPassRenderable.values.uTexSize, h0.set(this.blurSecondPassRenderable.values.uTexSize.ref.value, D, A));
    }
    if (Y)
      this.renderable.update();
    if (Q)
      this.blurFirstPassRenderable.update(), this.blurSecondPassRenderable.update();
    if (W)
      this.depthHalfRenderableOpaque.update(), this.depthHalfRenderableTransparent.update();
  }
  render(Z) {
    if (K1)
      this.webgl.timer.mark("SSAO.render");
    let { state: J } = this.webgl, { x: $, y: X, width: Y, height: Q } = Z.viewport, W = this.renderable.values.dIncludeTransparent.ref.value, K = this.renderable.values.dMultiScale.ref.value, G = Math.floor($ * this.ssaoScale), H = Math.floor(X * this.ssaoScale), N = Math.ceil(Y * this.ssaoScale), q = Math.ceil(Q * this.ssaoScale);
    if (J.viewport(G, H, N, q), J.scissor(G, H, N, q), this.ssaoScale < 1) {
      if (K1)
        this.webgl.timer.mark("SSAO.downsample");
      if (this.downsampledDepthTargetOpaque.bind(), this.downsampleDepthRenderableOpaque.render(), W)
        this.downsampledDepthTargetTransparent.bind(), this.downsampleDepthRenderableTransparent.render();
      if (K1)
        this.webgl.timer.markEnd("SSAO.downsample");
    }
    if (K1)
      this.webgl.timer.mark("SSAO.half");
    if (K)
      this.depthHalfTargetOpaque.bind(), this.depthHalfRenderableOpaque.render();
    if (K && W)
      this.depthHalfTargetTransparent.bind(), this.depthHalfRenderableTransparent.render();
    if (K1)
      this.webgl.timer.markEnd("SSAO.half");
    if (K1)
      this.webgl.timer.mark("SSAO.quarter");
    if (K)
      this.depthQuarterTargetOpaque.bind(), this.depthQuarterRenderableOpaque.render();
    if (K && W)
      this.depthQuarterTargetTransparent.bind(), this.depthQuarterRenderableTransparent.render();
    if (K1)
      this.webgl.timer.markEnd("SSAO.quarter");
    if (K1)
      this.webgl.timer.mark("SSAO.opaque");
    if (this.ssaoDepthTexture.attachFramebuffer(this.framebuffer, "color0"), C.update(this.renderable.values.uTransparencyFlag, 0), this.framebuffer.bind(), this.renderable.render(), K1)
      this.webgl.timer.markEnd("SSAO.opaque");
    if (K1)
      this.webgl.timer.mark("SSAO.blurOpaque");
    if (C.update(this.blurFirstPassRenderable.values.tSsaoDepth, this.ssaoDepthTexture), this.blurFirstPassRenderable.update(), this.blurFirstPassFramebuffer.bind(), this.blurFirstPassRenderable.render(), this.ssaoDepthTexture.attachFramebuffer(this.blurSecondPassFramebuffer, "color0"), this.blurSecondPassFramebuffer.bind(), this.blurSecondPassRenderable.render(), K1)
      this.webgl.timer.markEnd("SSAO.blurOpaque");
    if (W) {
      if (K1)
        this.webgl.timer.mark("SSAO.transparent ");
      if (this.ssaoDepthTransparentTexture.attachFramebuffer(this.framebuffer, "color0"), C.update(this.renderable.values.uTransparencyFlag, 1), this.framebuffer.bind(), this.renderable.render(), K1)
        this.webgl.timer.markEnd("SSAO.transparent ");
      if (K1)
        this.webgl.timer.mark("SSAO.blurTransparent ");
      if (C.update(this.blurFirstPassRenderable.values.tSsaoDepth, this.ssaoDepthTransparentTexture), this.blurFirstPassRenderable.update(), this.blurFirstPassFramebuffer.bind(), this.blurFirstPassRenderable.render(), this.ssaoDepthTransparentTexture.attachFramebuffer(this.blurSecondPassFramebuffer, "color0"), this.blurSecondPassFramebuffer.bind(), this.blurSecondPassRenderable.render(), K1)
        this.webgl.timer.markEnd("SSAO.blurTransparent ");
    }
    if (K1)
      this.webgl.timer.markEnd("SSAO.render");
  }
}
var _q1 = {
  ...A6,
  tDepth: o1("texture", "rgba", "ubyte", "linear"),
  tDepthHalf: o1("texture", "rgba", "ubyte", "linear"),
  tDepthQuarter: o1("texture", "rgba", "ubyte", "linear"),
  dIllumination: p1("boolean"),
  uTransparencyFlag: _0("i"),
  dIncludeTransparent: p1("boolean"),
  tDepthTransparent: o1("texture", "rgba", "ubyte", "linear"),
  tDepthHalfTransparent: o1("texture", "rgba", "ubyte", "linear"),
  tDepthQuarterTransparent: o1("texture", "rgba", "ubyte", "linear"),
  uSamples: _0("v3[]"),
  dNSamples: p1("number"),
  uProjection: _0("m4"),
  uInvProjection: _0("m4"),
  uBounds: _0("v4"),
  uTexSize: _0("v2"),
  uRadius: _0("f"),
  uBias: _0("f"),
  dMultiScale: p1("boolean"),
  dLevels: p1("number"),
  uLevelRadius: _0("f[]"),
  uLevelBias: _0("f[]"),
  uNearThreshold: _0("f"),
  uFarThreshold: _0("f")
};
function Vq1(Z, J, $, X, Y, Q, W) {
  let K = {
    ...B6,
    tDepth: C.create(J),
    tDepthHalf: C.create($),
    tDepthQuarter: C.create(X),
    dIllumination: C.create(!1),
    dIncludeTransparent: C.create(!0),
    uTransparencyFlag: C.create(0),
    tDepthTransparent: C.create(Y),
    tDepthHalfTransparent: C.create(Q),
    tDepthQuarterTransparent: C.create(W),
    uSamples: C.create(sw0(32)),
    dNSamples: C.create(32),
    uProjection: C.create(e.identity()),
    uInvProjection: C.create(e.identity()),
    uBounds: C.create(E2()),
    uTexSize: C.create(h0.create(Z.gl.drawingBufferWidth, Z.gl.drawingBufferHeight)),
    uRadius: C.create(Math.pow(2, 5)),
    uBias: C.create(0.8),
    dMultiScale: C.create(!1),
    dLevels: C.create(3),
    uLevelRadius: C.create([Math.pow(2, 2), Math.pow(2, 5), Math.pow(2, 8)]),
    uLevelBias: C.create([0.8, 0.8, 0.8]),
    uNearThreshold: C.create(10),
    uFarThreshold: C.create(1500)
  }, G = { ..._q1 }, H = v8("ssao", p6, cw0), N = t8(Z, "triangles", H, G, K);
  return e8(N, K);
}
var Iq1 = {
  ...A6,
  tSsaoDepth: o1("texture", "rgba", "ubyte", "nearest"),
  uTexSize: _0("v2"),
  uKernel: _0("f[]"),
  dOcclusionKernelSize: p1("number"),
  uBlurDepthBias: _0("f"),
  uBlurDirectionX: _0("f"),
  uBlurDirectionY: _0("f"),
  uInvProjection: _0("m4"),
  uNear: _0("f"),
  uFar: _0("f"),
  uBounds: _0("v4"),
  dOrthographic: p1("number")
};
function nw0(Z, J, $) {
  let X = {
    ...B6,
    tSsaoDepth: C.create(J),
    uTexSize: C.create(h0.create(J.getWidth(), J.getHeight())),
    uKernel: C.create(ow0(15)),
    dOcclusionKernelSize: C.create(15),
    uBlurDepthBias: C.create(0.5),
    uBlurDirectionX: C.create($ === "horizontal" ? 1 : 0),
    uBlurDirectionY: C.create($ === "vertical" ? 1 : 0),
    uInvProjection: C.create(e.identity()),
    uNear: C.create(0),
    uFar: C.create(1e4),
    uBounds: C.create(E2()),
    dOrthographic: C.create(0)
  }, Y = { ...Iq1 }, Q = v8("ssao_blur", p6, lw0), W = t8(Z, "triangles", Q, Y, X);
  return e8(W, X);
}
function ow0(Z) {
  let J = Z / 3, $ = Math.floor((Z + 1) / 2), X = [];
  for (let Y = 0;Y < $; Y++)
    X.push(1 / (Math.sqrt(2 * Math.PI) * J) * Math.exp(-Y * Y / (2 * J * J)));
  return X;
}
var qx = [];
for (let Z = 0;Z < 256; Z++) {
  let J = M();
  J[0] = Math.random() * 2 - 1, J[1] = Math.random() * 2 - 1, J[2] = Math.random(), M.normalize(J, J), M.scale(J, J, Math.random()), qx.push(J);
}
function sw0(Z) {
  let J = [];
  for (let $ = 0;$ < Z; $++) {
    let X = ($ * $ + 2 * $ + 1) / (Z * Z);
    X = 0.1 + X * 0.9, J.push(qx[$][0] * X), J.push(qx[$][1] * X), J.push(qx[$][2] * X);
  }
  return J;
}

// node_modules/molstar/lib/mol-canvas3d/passes/postprocessing.js
var Pq1 = {
  ...A6,
  tSsaoDepth: o1("texture", "rgba", "ubyte", "nearest"),
  tSsaoDepthTransparent: o1("texture", "rgba", "ubyte", "nearest"),
  tColor: o1("texture", "rgba", "ubyte", "nearest"),
  tTransparentColor: o1("texture", "rgba", "ubyte", "nearest"),
  dBlendTransparency: p1("boolean"),
  tDepthOpaque: o1("texture", "rgba", "ubyte", "nearest"),
  tDepthTransparent: o1("texture", "rgba", "ubyte", "nearest"),
  tShadows: o1("texture", "rgba", "ubyte", "nearest"),
  tOutlines: o1("texture", "rgba", "ubyte", "nearest"),
  uTexSize: _0("v2"),
  dOrthographic: p1("number"),
  uNear: _0("f"),
  uFar: _0("f"),
  uFogNear: _0("f"),
  uFogFar: _0("f"),
  uFogColor: _0("v3"),
  uOutlineColor: _0("v3"),
  uOcclusionColor: _0("v3"),
  uTransparentBackground: _0("b"),
  dOcclusionEnable: p1("boolean"),
  dOcclusionSingleDepth: p1("boolean"),
  dOcclusionIncludeOpacity: p1("boolean"),
  dOcclusionIncludeTransparency: p1("boolean"),
  uOcclusionOffset: _0("v2"),
  dShadowEnable: p1("boolean"),
  dOutlineEnable: p1("boolean"),
  dOutlineScale: p1("number"),
  dTransparentOutline: p1("boolean")
};
function Cq1(Z, J, $, X, Y, Q, W, K, G, H) {
  let N = {
    ...B6,
    tSsaoDepth: C.create(K),
    tSsaoDepthTransparent: C.create(G),
    tColor: C.create(J),
    tTransparentColor: C.create($),
    dBlendTransparency: C.create(!0),
    tDepthOpaque: C.create(X),
    tDepthTransparent: C.create(Y),
    tShadows: C.create(Q),
    tOutlines: C.create(W),
    uTexSize: C.create(h0.create(J.getWidth(), J.getHeight())),
    dOrthographic: C.create(0),
    uNear: C.create(1),
    uFar: C.create(1e4),
    uFogNear: C.create(1e4),
    uFogFar: C.create(1e4),
    uFogColor: C.create(M.create(1, 1, 1)),
    uOutlineColor: C.create(M.create(0, 0, 0)),
    uOcclusionColor: C.create(M.create(0, 0, 0)),
    uTransparentBackground: C.create(!1),
    dOcclusionEnable: C.create(!0),
    dOcclusionSingleDepth: C.create(!1),
    dOcclusionIncludeOpacity: C.create(!0),
    dOcclusionIncludeTransparency: C.create(!1),
    uOcclusionOffset: C.create(h0.create(0, 0)),
    dShadowEnable: C.create(!1),
    dOutlineEnable: C.create(!1),
    dOutlineScale: C.create(1),
    dTransparentOutline: C.create(H)
  }, q = { ...Pq1 }, U = v8("postprocessing", p6, Lw0), F = t8(Z, "triangles", U, q, N);
  return e8(F, N);
}
var rA = {
  enabled: j.Boolean(!0),
  occlusion: j.MappedStatic("on", {
    on: j.Group(iw0),
    off: j.Group({})
  }, { cycle: !0, description: "Darken occluded crevices with the ambient occlusion effect", hideIf: (Z) => Z.enabled === !1 }),
  shadow: j.MappedStatic("off", {
    on: j.Group(uw0),
    off: j.Group({})
  }, { cycle: !0, description: "Simplistic shadows", hideIf: (Z) => Z.enabled === !1 }),
  outline: j.MappedStatic("off", {
    on: j.Group(dw0),
    off: j.Group({})
  }, { cycle: !0, description: "Draw outline around 3D objects", hideIf: (Z) => Z.enabled === !1 }),
  dof: j.MappedStatic("off", {
    on: j.Group(hw0),
    off: j.Group({})
  }, { cycle: !0, description: "DOF", hideIf: (Z) => Z.enabled === !1 }),
  antialiasing: j.MappedStatic("smaa", {
    fxaa: j.Group(Ew0),
    smaa: j.Group(ww0),
    off: j.Group({})
  }, { options: [["fxaa", "FXAA"], ["smaa", "SMAA"], ["off", "Off"]], description: "Smooth pixel edges", hideIf: (Z) => Z.enabled === !1 }),
  sharpening: j.MappedStatic("off", {
    on: j.Group(Sw0),
    off: j.Group({})
  }, { cycle: !0, description: "Contrast Adaptive Sharpening", hideIf: (Z) => Z.enabled === !1 }),
  background: j.Group(kw0, { isFlat: !0, hideIf: (Z) => Z.enabled === !1 }),
  bloom: j.MappedStatic("on", {
    on: j.Group(gw0),
    off: j.Group({})
  }, { cycle: !0, description: "Bloom", hideIf: (Z) => Z.enabled === !1 })
};

class bJ {
  static isEnabled(Z) {
    return Z.enabled && (TH.isEnabled(Z) || eV.isEnabled(Z) || LU.isEnabled(Z) || Z.background.variant.name !== "off");
  }
  static isTransparentDepthRequired(Z, J) {
    return J.enabled && (jH.isEnabled(J) || LU.isEnabled(J) && bJ.isTransparentOutlineEnabled(J) || TH.isEnabled(J) && bJ.isTransparentSsaoEnabled(Z, J)) && Z.opacityAverage < 1;
  }
  static isTransparentOutlineEnabled(Z) {
    var J;
    return Z.enabled && LU.isEnabled(Z) && ((J = Z.outline.params.includeTransparent) !== null && J !== void 0 ? J : !0);
  }
  static isTransparentSsaoEnabled(Z, J) {
    return J.enabled && TH.isEnabled(J) && TH.isTransparentEnabled(Z, J.occlusion.params);
  }
  static isSsaoEnabled(Z) {
    return Z.enabled && TH.isEnabled(Z);
  }
  constructor(Z, J, $) {
    this.webgl = Z, this.drawPass = $, this.occlusionOffset = [0, 0], this.transparentBackground = !1;
    let { colorTarget: X, transparentColorTarget: Y, depthTextureOpaque: Q, depthTextureTransparent: W, packedDepth: K } = $, G = X.getWidth(), H = X.getHeight();
    this.target = Z.createRenderTarget(G, H, !1, "uint8", "linear"), this.ssao = new TH(Z, G, H, K, Q, W), this.shadow = new eV(Z, G, H, Q), this.outline = new LU(Z, G, H, W, Q), this.renderable = Cq1(Z, X.texture, Y.texture, Q, W, this.shadow.target.texture, this.outline.target.texture, this.ssao.ssaoDepthTexture, this.ssao.ssaoDepthTransparentTexture, !0), this.background = new Ie(Z, J, G, H);
  }
  getByteCount() {
    return this.target.getByteCount() + this.ssao.getByteCount() + this.shadow.getByteCount() + this.outline.getByteCount();
  }
  setSize(Z, J) {
    let [$, X] = this.renderable.values.uTexSize.ref.value;
    if (Z !== $ || J !== X)
      this.target.setSize(Z, J), C.update(this.renderable.values.uTexSize, h0.set(this.renderable.values.uTexSize.ref.value, Z, J));
    this.ssao.setSize(Z, J), this.shadow.setSize(Z, J), this.outline.setSize(Z, J), this.background.setSize(Z, J);
  }
  reset() {
    this.ssao.reset();
  }
  updateState(Z, J, $, X, Y, Q, W) {
    let K = !1, G = Z.state.mode === "orthographic" ? 1 : 0, H = LU.isEnabled(Y), N = eV.isEnabled(Y), q = TH.isEnabled(Y);
    if (q) {
      let R = Y.occlusion.params;
      this.ssao.update(Z, J, R);
      let z = TH.isTransparentEnabled(J, R);
      if (this.renderable.values.dOcclusionIncludeTransparency.ref.value !== z)
        K = !0, C.update(this.renderable.values.dOcclusionIncludeTransparency, z);
      C.update(this.renderable.values.uOcclusionColor, i0.toVec3Normalized(this.renderable.values.uOcclusionColor.ref.value, R.color));
    }
    if (N)
      this.shadow.update(Z, Q, W, Y.shadow.params);
    if (H) {
      let R = Y.outline.params, { transparentOutline: z, outlineScale: D } = this.outline.update(Z, R, this.drawPass.depthTextureTransparent, this.drawPass.depthTextureOpaque);
      if (C.update(this.renderable.values.uOutlineColor, i0.toVec3Normalized(this.renderable.values.uOutlineColor.ref.value, R.color)), this.renderable.values.dOutlineScale.ref.value !== D)
        K = !0, C.update(this.renderable.values.dOutlineScale, D);
      if (this.renderable.values.dTransparentOutline.ref.value !== z)
        K = !0, C.update(this.renderable.values.dTransparentOutline, z);
    }
    if (C.updateIfChanged(this.renderable.values.uFar, Z.far), C.updateIfChanged(this.renderable.values.uNear, Z.near), C.updateIfChanged(this.renderable.values.uFogFar, Z.fogFar), C.updateIfChanged(this.renderable.values.uFogNear, Z.fogNear), C.update(this.renderable.values.uFogColor, i0.toVec3Normalized(this.renderable.values.uFogColor.ref.value, X)), C.updateIfChanged(this.renderable.values.uTransparentBackground, $), this.renderable.values.dOrthographic.ref.value !== G)
      K = !0, C.update(this.renderable.values.dOrthographic, G);
    if (this.renderable.values.dOutlineEnable.ref.value !== H)
      K = !0, C.update(this.renderable.values.dOutlineEnable, H);
    if (this.renderable.values.dShadowEnable.ref.value !== N)
      K = !0, C.update(this.renderable.values.dShadowEnable, N);
    if (this.renderable.values.dOcclusionEnable.ref.value !== q)
      K = !0, C.update(this.renderable.values.dOcclusionEnable, q);
    let U = J.opacityAverage < 1;
    if (this.renderable.values.dBlendTransparency.ref.value !== U)
      K = !0, C.update(this.renderable.values.dBlendTransparency, U);
    if (K)
      this.renderable.update();
    let { gl: F, state: E } = this.webgl;
    E.enable(F.SCISSOR_TEST), E.disable(F.BLEND), E.disable(F.DEPTH_TEST), E.depthMask(!1);
  }
  setOcclusionOffset(Z, J) {
    this.occlusionOffset[0] = Z, this.occlusionOffset[1] = J, C.update(this.renderable.values.uOcclusionOffset, h0.set(this.renderable.values.uOcclusionOffset.ref.value, Z, J));
  }
  setTransparentBackground(Z) {
    this.transparentBackground = Z;
  }
  render(Z, J, $, X, Y, Q, W, K) {
    if (K1)
      this.webgl.timer.mark("PostprocessingPass.render");
    this.updateState(Z, J, X, Y, Q, W, K);
    let { state: G } = this.webgl, { x: H, y: N, width: q, height: U } = Z.viewport;
    if (Q.occlusion.name === "on" && this.occlusionOffset[0] === 0 && this.occlusionOffset[1] === 0)
      this.ssao.render(Z);
    if (G.viewport(H, N, q, U), G.scissor(H, N, q, U), Q.outline.name === "on")
      this.outline.render();
    if (Q.shadow.name === "on")
      this.shadow.render();
    if ($)
      this.webgl.bindDrawingBuffer();
    else
      this.target.bind();
    if (this.background.update(Z, Q.background), this.background.clear(Q.background, this.transparentBackground, Y), this.background.render(Q.background), this.renderable.render(), K1)
      this.webgl.timer.markEnd("PostprocessingPass.render");
  }
}

class RU {
  static isEnabled(Z) {
    return Z.enabled && (Z.antialiasing.name !== "off" || Z.sharpening.name !== "off");
  }
  constructor(Z, J, $) {
    this.target = Z.createRenderTarget(J, $, !1), this.internalTarget = Z.createRenderTarget(J, $, !1), this.fxaa = new _e(Z, this.target.texture), this.smaa = new Ve(Z, this.target.texture), this.cas = new Pe(Z, this.target.texture);
  }
  getByteCount() {
    return this.target.getByteCount() + this.internalTarget.getByteCount() + this.smaa.getByteCount();
  }
  setSize(Z, J) {
    let $ = this.target.texture.getWidth(), X = this.target.texture.getHeight();
    if (Z !== $ || J !== X) {
      if (this.target.setSize(Z, J), this.internalTarget.setSize(Z, J), this.fxaa.setSize(Z, J), this.smaa.supported)
        this.smaa.setSize(Z, J);
      this.cas.setSize(Z, J);
    }
  }
  _renderFxaa(Z, J, $, X) {
    if (X.antialiasing.name !== "fxaa")
      return;
    this.fxaa.update(J, X.antialiasing.params), this.fxaa.render(Z.viewport, $);
  }
  _renderSmaa(Z, J, $, X) {
    if (X.antialiasing.name !== "smaa")
      return;
    this.smaa.update(J, X.antialiasing.params), this.smaa.render(Z.viewport, $);
  }
  _renderAntialiasing(Z, J, $, X) {
    if (X.antialiasing.name === "fxaa")
      this._renderFxaa(Z, J, $, X);
    else if (X.antialiasing.name === "smaa")
      this._renderSmaa(Z, J, $, X);
  }
  _renderCas(Z, J, $, X) {
    if (X.sharpening.name !== "on")
      return;
    if (X.antialiasing.name !== "off")
      J = this.internalTarget.texture;
    this.cas.update(J, X.sharpening.params), this.cas.render(Z.viewport, $);
  }
  render(Z, J, $, X) {
    if (X.antialiasing.name === "off" && X.sharpening.name === "off")
      return;
    if (X.antialiasing.name === "smaa" && !this.smaa.supported) {
      console.error('SMAA not supported, missing "HTMLImageElement"');
      return;
    }
    let Y = $ === !0 ? void 0 : $ === !1 ? this.target : $;
    if (X.sharpening.name === "off")
      this._renderAntialiasing(Z, J, Y, X);
    else if (X.antialiasing.name === "off")
      this._renderCas(Z, J, Y, X);
    else
      this._renderAntialiasing(Z, J, this.internalTarget, X), this._renderCas(Z, J, Y, X);
  }
}

// node_modules/molstar/lib/mol-gl/shader/compose.frag.js
var Fx = `
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;
}
`;

// node_modules/molstar/lib/mol-canvas3d/passes/multi-sample.js
var kq1 = {
  ...A6,
  tColor: o1("texture", "rgba", "ubyte", "nearest"),
  uTexSize: _0("v2"),
  uWeight: _0("f")
}, vq1 = v8("compose", p6, Fx);
function Sq1(Z, J) {
  let $ = {
    ...B6,
    tColor: C.create(J),
    uTexSize: C.create(h0.create(J.getWidth(), J.getHeight())),
    uWeight: C.create(1)
  }, X = { ...kq1 }, Y = t8(Z, "triangles", vq1, X, $);
  return e8(Y, $);
}
var Ux = {
  mode: j.Select("temporal", [["off", "Off"], ["on", "On"], ["temporal", "Temporal"]]),
  sampleLevel: j.Numeric(2, { min: 0, max: 5, step: 1 }, { description: "Take level^2 samples." }),
  reduceFlicker: j.Boolean(!0, { description: 'Reduce flicker in "temporal" mode.' }),
  reuseOcclusion: j.Boolean(!0, { description: "Reuse occlusion data. It is faster but has some artefacts." })
};

class eR {
  static isEnabled(Z) {
    return Z.mode !== "off";
  }
  constructor(Z, J) {
    this.webgl = Z, this.drawPass = J;
    let { colorBufferFloat: $, textureFloat: X, colorBufferHalfFloat: Y, textureHalfFloat: Q } = Z.extensions, W = J.colorTarget.getWidth(), K = J.colorTarget.getHeight();
    this.colorTarget = Z.createRenderTarget(W, K, !1);
    let G = Y && Q ? "fp16" : $ && X ? "float32" : "uint8";
    this.composeTarget = Z.createRenderTarget(W, K, !1, G), this.holdTarget = Z.createRenderTarget(W, K, !1), this.compose = Sq1(Z, J.colorTarget.texture);
  }
  getByteCount() {
    return this.colorTarget.getByteCount() + this.composeTarget.getByteCount() + this.holdTarget.getByteCount();
  }
  syncSize() {
    let Z = this.drawPass.colorTarget.getWidth(), J = this.drawPass.colorTarget.getHeight(), [$, X] = this.compose.values.uTexSize.ref.value;
    if (Z !== $ || J !== X)
      this.colorTarget.setSize(Z, J), this.composeTarget.setSize(Z, J), this.holdTarget.setSize(Z, J), C.update(this.compose.values.uTexSize, h0.set(this.compose.values.uTexSize.ref.value, Z, J));
  }
  render(Z, J, $, X, Y) {
    if ($.multiSample.mode === "temporal" && !Y)
      return this.renderTemporalMultiSample(Z, J, $, X);
    else
      return this.renderMultiSample(J, X, $), -2;
  }
  bindOutputTarget(Z) {
    if (Z)
      this.webgl.bindDrawingBuffer();
    else
      this.colorTarget.bind();
  }
  renderMultiSample(Z, J, $) {
    let { camera: X } = Z, { compose: Y, composeTarget: Q, drawPass: W, webgl: K } = this, { gl: G, state: H } = K;
    if (K1)
      K.timer.mark("MultiSamplePass.renderMultiSample");
    let N = ZI[Math.max(0, Math.min($.multiSample.sampleLevel, 5))], { x: q, y: U, width: F, height: E } = X.viewport, R = 1 / N.length, z = 0.03125;
    X.viewOffset.enabled = !0, C.update(Y.values.tColor, W.getColorTarget($.postprocessing).texture), Y.update();
    for (let D = 0;D < N.length; ++D) {
      let A = N[D];
      O6.setViewOffset(X.viewOffset, F, E, A[0], A[1], F, E), X.update();
      let B = -0.5 + (D + 0.5) / N.length, T = R + z * B;
      if (C.update(Y.values.uWeight, T), D === 0 || !$.multiSample.reuseOcclusion)
        W.postprocessing.setOcclusionOffset(0, 0);
      else
        W.postprocessing.setOcclusionOffset(A[0] / F, A[1] / E);
      if (W.render(Z, $, !1), Q.bind(), H.enable(G.BLEND), H.blendEquationSeparate(G.FUNC_ADD, G.FUNC_ADD), H.blendFuncSeparate(G.ONE, G.ONE, G.ONE, G.ONE), H.disable(G.DEPTH_TEST), H.depthMask(!1), H.viewport(q, U, F, E), H.scissor(q, U, F, E), D === 0)
        H.clearColor(0, 0, 0, 0), G.clear(G.COLOR_BUFFER_BIT);
      Y.render();
    }
    if (W.postprocessing.setOcclusionOffset(0, 0), C.update(Y.values.uWeight, 1), C.update(Y.values.tColor, Q.texture), Y.update(), this.bindOutputTarget(J), H.viewport(q, U, F, E), H.scissor(q, U, F, E), H.disable(G.BLEND), Y.render(), X.viewOffset.enabled = !1, X.update(), K1)
      K.timer.markEnd("MultiSamplePass.renderMultiSample");
  }
  renderTemporalMultiSample(Z, J, $, X) {
    let { camera: Y } = J, { compose: Q, composeTarget: W, holdTarget: K, drawPass: G, webgl: H } = this, { gl: N, state: q } = H;
    if (K1)
      H.timer.mark("MultiSamplePass.renderTemporalMultiSample");
    let U = ZI[Math.max(0, Math.min($.multiSample.sampleLevel, 5))];
    if (Z === -2 || Z >= U.length)
      return -2;
    let { x: F, y: E, width: R, height: z } = Y.viewport, D = 1 / U.length;
    if (Z === -1)
      G.render(J, $, !1), C.update(Q.values.uWeight, 1), C.update(Q.values.tColor, G.getColorTarget($.postprocessing).texture), Q.update(), K.bind(), q.disable(N.BLEND), q.disable(N.DEPTH_TEST), q.depthMask(!1), q.viewport(F, E, R, z), q.scissor(F, E, R, z), Q.render(), Z += 1;
    else {
      Y.viewOffset.enabled = !0, C.update(Q.values.tColor, G.getColorTarget($.postprocessing).texture), C.update(Q.values.uWeight, D), Q.update();
      let B = Math.pow(2, Math.max(0, $.multiSample.sampleLevel - 2));
      for (let T = 0;T < B; ++T) {
        let w = U[Z];
        if (O6.setViewOffset(Y.viewOffset, R, z, w[0], w[1], R, z), Y.update(), Z === 0 || !$.multiSample.reuseOcclusion)
          G.postprocessing.setOcclusionOffset(0, 0);
        else
          G.postprocessing.setOcclusionOffset(w[0] / R, w[1] / z);
        if (G.render(J, $, !1), W.bind(), q.enable(N.BLEND), q.blendEquationSeparate(N.FUNC_ADD, N.FUNC_ADD), q.blendFuncSeparate(N.ONE, N.ONE, N.ONE, N.ONE), q.disable(N.DEPTH_TEST), q.depthMask(!1), q.viewport(F, E, R, z), q.scissor(F, E, R, z), Z === 0)
          q.clearColor(0, 0, 0, 0), N.clear(N.COLOR_BUFFER_BIT);
        if (Q.render(), Z += 1, Z >= U.length)
          break;
      }
    }
    G.postprocessing.setOcclusionOffset(0, 0), this.bindOutputTarget(X), q.viewport(F, E, R, z), q.scissor(F, E, R, z);
    let A = Z * D;
    if (A > 0)
      C.update(Q.values.uWeight, 1), C.update(Q.values.tColor, W.texture), Q.update(), q.disable(N.BLEND), Q.render();
    if (A < 1) {
      if (C.update(Q.values.uWeight, 1 - A), C.update(Q.values.tColor, K.texture), Q.update(), A === 0)
        q.disable(N.BLEND);
      else
        q.enable(N.BLEND);
      Q.render();
    }
    if (Y.viewOffset.enabled = !1, Y.update(), K1)
      H.timer.markEnd("MultiSamplePass.renderTemporalMultiSample");
    return Z >= U.length ? -2 : Z;
  }
}
var ZI = [
  [
    [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]
  ]
];
ZI.forEach((Z) => {
  Z.forEach((J) => {
    J[0] *= 0.0625, J[1] *= 0.0625;
  });
});

class JI {
  update(Z, J) {
    if (Z)
      this.sampleIndex = -1;
    return J.mode === "temporal" ? this.sampleIndex !== -2 : !1;
  }
  render(Z, J, $, X) {
    return this.sampleIndex = this.multiSamplePass.render(this.sampleIndex, Z, J, $, !!X), this.sampleIndex < 0;
  }
  constructor(Z) {
    this.multiSamplePass = Z, this.sampleIndex = -2;
  }
}

// node_modules/molstar/lib/mol-canvas3d/passes/pick.js
var rw0 = {
  pickPadding: 1,
  maxAsyncReadLag: 5
};

class $I {
  constructor(Z, J, $, X) {
    this.webgl = Z, this.width = J, this.height = $, this.pickScale = X;
    let Y = X / Z.pixelRatio;
    this.pickWidth = Math.ceil(J * Y), this.pickHeight = Math.ceil($ * Y);
    let { resources: Q, extensions: { drawBuffers: W }, gl: K } = Z;
    if (W)
      this.objectPickTexture = Q.texture("image-uint8", "rgba", "ubyte", "nearest"), this.objectPickTexture.define(this.pickWidth, this.pickHeight), this.instancePickTexture = Q.texture("image-uint8", "rgba", "ubyte", "nearest"), this.instancePickTexture.define(this.pickWidth, this.pickHeight), this.groupPickTexture = Q.texture("image-uint8", "rgba", "ubyte", "nearest"), this.groupPickTexture.define(this.pickWidth, this.pickHeight), this.depthPickTexture = Q.texture("image-uint8", "rgba", "ubyte", "nearest"), this.depthPickTexture.define(this.pickWidth, this.pickHeight), this.framebuffer = Q.framebuffer(), this.objectPickFramebuffer = Q.framebuffer(), this.instancePickFramebuffer = Q.framebuffer(), this.groupPickFramebuffer = Q.framebuffer(), this.depthPickFramebuffer = Q.framebuffer(), this.framebuffer.bind(), W.drawBuffers([
        W.COLOR_ATTACHMENT0,
        W.COLOR_ATTACHMENT1,
        W.COLOR_ATTACHMENT2,
        W.COLOR_ATTACHMENT3
      ]), this.objectPickTexture.attachFramebuffer(this.framebuffer, "color0"), this.instancePickTexture.attachFramebuffer(this.framebuffer, "color1"), this.groupPickTexture.attachFramebuffer(this.framebuffer, "color2"), this.depthPickTexture.attachFramebuffer(this.framebuffer, "color3"), this.depthRenderbuffer = _2(K) ? Q.renderbuffer("depth32f", "depth", this.pickWidth, this.pickHeight) : Q.renderbuffer("depth16", "depth", this.pickWidth, this.pickHeight), this.depthRenderbuffer.attachFramebuffer(this.framebuffer), this.objectPickTexture.attachFramebuffer(this.objectPickFramebuffer, "color0"), this.instancePickTexture.attachFramebuffer(this.instancePickFramebuffer, "color0"), this.groupPickTexture.attachFramebuffer(this.groupPickFramebuffer, "color0"), this.depthPickTexture.attachFramebuffer(this.depthPickFramebuffer, "color0");
    else
      this.objectPickTarget = Z.createRenderTarget(this.pickWidth, this.pickHeight), this.instancePickTarget = Z.createRenderTarget(this.pickWidth, this.pickHeight), this.groupPickTarget = Z.createRenderTarget(this.pickWidth, this.pickHeight), this.depthPickTarget = Z.createRenderTarget(this.pickWidth, this.pickHeight);
  }
  getByteCount() {
    if (this.webgl.extensions.drawBuffers)
      return this.objectPickTexture.getByteCount() + this.instancePickTexture.getByteCount() + this.groupPickTexture.getByteCount() + this.depthPickTexture.getByteCount() + this.depthRenderbuffer.getByteCount();
    else
      return this.objectPickTarget.getByteCount() + this.instancePickTarget.getByteCount() + this.groupPickTarget.getByteCount() + this.depthPickTarget.getByteCount();
  }
  dispose() {
    if (this.webgl.extensions.drawBuffers)
      this.framebuffer.destroy(), this.objectPickTexture.destroy(), this.instancePickTexture.destroy(), this.groupPickTexture.destroy(), this.depthPickTexture.destroy(), this.objectPickFramebuffer.destroy(), this.instancePickFramebuffer.destroy(), this.groupPickFramebuffer.destroy(), this.depthPickFramebuffer.destroy(), this.depthRenderbuffer.destroy();
    else
      this.objectPickTarget.destroy(), this.instancePickTarget.destroy(), this.groupPickTarget.destroy(), this.depthPickTarget.destroy();
  }
  get pickRatio() {
    return this.pickScale / this.webgl.pixelRatio;
  }
  setPickScale(Z) {
    this.pickScale = Z, this.setSize(this.width, this.height);
  }
  bindObject() {
    if (this.webgl.extensions.drawBuffers)
      this.objectPickFramebuffer.bind();
    else
      this.objectPickTarget.bind();
  }
  bindInstance() {
    if (this.webgl.extensions.drawBuffers)
      this.instancePickFramebuffer.bind();
    else
      this.instancePickTarget.bind();
  }
  bindGroup() {
    if (this.webgl.extensions.drawBuffers)
      this.groupPickFramebuffer.bind();
    else
      this.groupPickTarget.bind();
  }
  bindDepth() {
    if (this.webgl.extensions.drawBuffers)
      this.depthPickFramebuffer.bind();
    else
      this.depthPickTarget.bind();
  }
  get drawingBufferHeight() {
    return this.height;
  }
  setSize(Z, J) {
    this.width = Z, this.height = J;
    let $ = this.pickScale / this.webgl.pixelRatio, X = Math.ceil(this.width * $), Y = Math.ceil(this.height * $);
    if (X !== this.pickWidth || Y !== this.pickHeight)
      if (this.pickWidth = X, this.pickHeight = Y, this.webgl.extensions.drawBuffers)
        this.objectPickTexture.define(this.pickWidth, this.pickHeight), this.instancePickTexture.define(this.pickWidth, this.pickHeight), this.groupPickTexture.define(this.pickWidth, this.pickHeight), this.depthPickTexture.define(this.pickWidth, this.pickHeight), this.depthRenderbuffer.setSize(this.pickWidth, this.pickHeight);
      else
        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);
  }
  reset() {
    let { drawBuffers: Z } = this.webgl.extensions;
    if (Z)
      this.framebuffer.bind(), Z.drawBuffers([
        Z.COLOR_ATTACHMENT0,
        Z.COLOR_ATTACHMENT1,
        Z.COLOR_ATTACHMENT2,
        Z.COLOR_ATTACHMENT3
      ]), this.objectPickTexture.attachFramebuffer(this.framebuffer, "color0"), this.instancePickTexture.attachFramebuffer(this.framebuffer, "color1"), this.groupPickTexture.attachFramebuffer(this.framebuffer, "color2"), this.depthPickTexture.attachFramebuffer(this.framebuffer, "color3"), this.depthRenderbuffer.attachFramebuffer(this.framebuffer), this.objectPickTexture.attachFramebuffer(this.objectPickFramebuffer, "color0"), this.instancePickTexture.attachFramebuffer(this.instancePickFramebuffer, "color0"), this.groupPickTexture.attachFramebuffer(this.groupPickFramebuffer, "color0"), this.depthPickTexture.attachFramebuffer(this.depthPickFramebuffer, "color0");
  }
  renderVariant(Z, J, $, X, Y, Q) {
    if (Z.clear(!1), Z.update(J, $), Z.renderPick($.primitives, J, Y, Q), X.handle.isEnabled)
      Z.renderPick(X.handle.scene, J, Y, Q);
    if (X.camera.isEnabled)
      X.camera.update(J), Z.update(X.camera.camera, X.camera.scene), Z.renderPick(X.camera.scene, X.camera.camera, Y, Q);
  }
  render(Z, J, $, X) {
    if (this.webgl.extensions.drawBuffers)
      this.framebuffer.bind(), this.renderVariant(Z, J, $, X, "pick", qU.None);
    else
      this.objectPickTarget.bind(), this.renderVariant(Z, J, $, X, "pick", qU.Object), this.instancePickTarget.bind(), this.renderVariant(Z, J, $, X, "pick", qU.Instance), this.groupPickTarget.bind(), this.renderVariant(Z, J, $, X, "pick", qU.Group), this.depthPickTarget.bind(), this.renderVariant(Z, J, $, X, "depth", qU.None);
  }
}
var aw0 = !1;
function Lx(Z) {
  if (Z.isWebGL2)
    return !0;
  if (y2 && !aw0)
    console.log("WebGL2 required for async picking. Falling back to synchronous picking."), aw0 = !0;
  return !1;
}
var aQ;
(function(Z) {
  Z[Z.Pending = 0] = "Pending", Z[Z.Resolved = 1] = "Resolved", Z[Z.Failed = 2] = "Failed";
})(aQ || (aQ = {}));

class XI {
  setup() {
    let Z = this.viewport.width * this.viewport.height * 4;
    if (!this.object || this.object.length !== Z)
      this.object = new Uint8Array(Z), this.instance = new Uint8Array(Z), this.group = new Uint8Array(Z), this.depth = new Uint8Array(Z);
  }
  setViewport(Z, J, $, X) {
    bZ.set(this.viewport, Z, J, $, X), this.setup();
  }
  read() {
    if (K1)
      this.webgl.timer.mark("PickBuffers.read");
    let { x: Z, y: J, width: $, height: X } = this.viewport;
    if (this.pickPass.bindObject(), this.webgl.readPixels(Z, J, $, X, this.object), this.pickPass.bindInstance(), this.webgl.readPixels(Z, J, $, X, this.instance), this.pickPass.bindGroup(), this.webgl.readPixels(Z, J, $, X, this.group), this.pickPass.bindDepth(), this.webgl.readPixels(Z, J, $, X, this.depth), this.ready = !0, K1)
      this.webgl.timer.markEnd("PickBuffers.read");
  }
  asyncRead() {
    let { gl: Z } = this.webgl;
    if (!_2(Z))
      return;
    if (K1)
      this.webgl.timer.mark("PickBuffers.asyncRead");
    if (this.fenceSync !== null)
      Z.deleteSync(this.fenceSync);
    let { x: J, y: $, width: X, height: Y } = this.viewport;
    if (this.pickPass.bindObject(), this.objectBuffer.read(J, $, X, Y), this.pickPass.bindInstance(), this.instanceBuffer.read(J, $, X, Y), this.pickPass.bindGroup(), this.groupBuffer.read(J, $, X, Y), this.pickPass.bindDepth(), this.depthBuffer.read(J, $, X, Y), this.fenceTimestamp = m6(), this.fenceSync = Z.fenceSync(Z.SYNC_GPU_COMMANDS_COMPLETE, 0), Z.flush(), this.ready = !1, K1)
      this.webgl.timer.markEnd("PickBuffers.asyncRead");
  }
  check() {
    if (this.ready)
      return aQ.Resolved;
    if (this.fenceSync === null)
      return aQ.Failed;
    let { gl: Z } = this.webgl;
    if (!_2(Z))
      return aQ.Failed;
    let J = Z.clientWaitSync(this.fenceSync, 0, 0);
    if (J === Z.WAIT_FAILED || this.lag >= this.maxAsyncReadLag) {
      if (J !== Z.WAIT_FAILED && m6() - this.fenceTimestamp < 16.666666666666668)
        return this.lag += 1, aQ.Pending;
      return Z.deleteSync(this.fenceSync), this.fenceSync = null, this.lag = 0, this.ready = !1, aQ.Failed;
    } else if (J === Z.TIMEOUT_EXPIRED)
      return this.lag += 1, aQ.Pending;
    else
      return this.objectBuffer.getSubData(this.object), this.instanceBuffer.getSubData(this.instance), this.groupBuffer.getSubData(this.group), this.depthBuffer.getSubData(this.depth), Z.deleteSync(this.fenceSync), this.fenceSync = null, this.lag = 0, this.ready = !0, aQ.Resolved;
  }
  getIdx(Z, J) {
    return (J * this.viewport.width + Z) * 4;
  }
  getDepth(Z, J) {
    if (!this.ready)
      return -1;
    let $ = this.getIdx(Z, J), X = this.depth;
    return wE0(X[$], X[$ + 1], X[$ + 2], X[$ + 3]);
  }
  getId(Z, J, $) {
    if (!this.ready)
      return -1;
    let X = this.getIdx(Z, J);
    return VR($[X], $[X + 1], $[X + 2]);
  }
  getObjectId(Z, J) {
    return this.getId(Z, J, this.object);
  }
  getInstanceId(Z, J) {
    return this.getId(Z, J, this.instance);
  }
  getGroupId(Z, J) {
    return this.getId(Z, J, this.group);
  }
  getPickingId(Z, J) {
    let $ = this.getObjectId(Z, J);
    if ($ === -1 || $ === K7.Null)
      return;
    let X = this.getInstanceId(Z, J);
    if (X === -1 || X === K7.Null)
      return;
    let Y = this.getGroupId(Z, J);
    if (Y === -1)
      return;
    return { objectId: $, instanceId: X, groupId: Y };
  }
  reset() {
    this.fenceSync = null, this.ready = !1, this.lag = 0, this.fenceTimestamp = 0;
  }
  dispose() {
    let { gl: Z } = this.webgl;
    if (!_2(Z))
      return;
    if (this.objectBuffer.destroy(), this.instanceBuffer.destroy(), this.groupBuffer.destroy(), this.depthBuffer.destroy(), this.fenceSync !== null)
      Z.deleteSync(this.fenceSync), this.fenceSync = null;
  }
  constructor(Z, J, $ = 5) {
    if (this.webgl = Z, this.pickPass = J, this.maxAsyncReadLag = $, this.viewport = bZ.create(0, 0, 0, 0), this.fenceSync = null, this.fenceTimestamp = 0, this.ready = !1, this.lag = 0, Z.isWebGL2)
      this.objectBuffer = Z.resources.pixelPack("rgba", "ubyte"), this.instanceBuffer = Z.resources.pixelPack("rgba", "ubyte"), this.groupBuffer = Z.resources.pixelPack("rgba", "ubyte"), this.depthBuffer = Z.resources.pixelPack("rgba", "ubyte");
    this.setup();
  }
}

// node_modules/molstar/lib/mol-canvas3d/camera/stereo.js
var fe = {
  eyeSeparation: j.Numeric(0.062, { min: 0.02, max: 0.1, step: 0.001 }, { description: "Distance between left and right camera." }),
  focus: j.Numeric(10, { min: 1, max: 20, step: 0.1 }, { description: "Apparent object distance." })
}, fq1 = j.getDefaultValues(fe);
class Eq {
  get viewport() {
    return this.parent.viewport;
  }
  get viewOffset() {
    return this.parent.viewOffset;
  }
  constructor(Z, J = {}) {
    this.parent = Z, this.left = new ve, this.right = new ve, this.props = { ...fq1, ...J };
  }
  setProps(Z) {
    Object.assign(this.props, Z);
  }
  update(Z) {
    if (this.parent.update(), Z)
      bq1(this.parent, this.left, this.right, Z);
    else
      hq1(this.parent, this.props, this.left, this.right);
  }
}
(function(Z) {
  function J($) {
    return "left" in $ && "right" in $;
  }
  Z.is = J;
})(Eq || (Eq = {}));

class ve {
  constructor() {
    this.viewport = bZ.create(0, 0, 0, 0), this.view = e(), this.projection = e(), this.projectionView = e(), this.inverseProjectionView = e(), this.headRotation = e(), this.viewEye = e(), this.isAsymmetricProjection = !0, this.state = O6.createDefaultSnapshot(), this.viewOffset = O6.ViewOffset(), this.far = 0, this.near = 0, this.fogFar = 0, this.fogNear = 0, this.forceFull = !1, this.scale = 0, this.minTargetDistance = 0, this.disabled = !1;
  }
  getRay(Z, J, $) {
    return e.getTranslation(Z.origin, e.invert(e(), this.view)), M.set(Z.direction, J, $, 0.5), Rq(Z.direction, Z.direction, this.viewport, this.inverseProjectionView), M.normalize(Z.direction, M.sub(Z.direction, Z.direction, Z.origin)), Z;
  }
}
var tw0 = e.identity(), ew0 = e.identity();
function Se(Z, J) {
  bZ.copy(J.viewport, Z.viewport), e.copy(J.view, Z.view), e.copy(J.projection, Z.projection), e.copy(J.headRotation, Z.headRotation), O6.copySnapshot(J.state, Z.state), O6.copyViewOffset(J.viewOffset, Z.viewOffset), J.far = Z.far, J.near = Z.near, J.fogFar = Z.fogFar, J.fogNear = Z.fogNear, J.forceFull = Z.forceFull, J.scale = Z.scale, J.minTargetDistance = Z.minTargetDistance;
}
function hq1(Z, J, $, X) {
  Se(Z, $), Se(Z, X);
  let Y = Math.floor(Z.viewport.width / 2), Q = Y / Z.viewport.height;
  $.viewport.width = Y, X.viewport.x += Y, X.viewport.width -= Y;
  let W = J.eyeSeparation / 2, K = W * Z.near / J.focus, G = Z.near * Math.tan(Z.state.fov * 0.5), H, N;
  tw0[12] = -W, ew0[12] = W, H = -G * Q + K, N = G * Q + K, $.projection[0] = 2 * Z.near / (N - H), $.projection[8] = (N + H) / (N - H), e.mul($.view, $.view, tw0), e.mul($.projectionView, $.projection, $.view), e.invert($.inverseProjectionView, $.projectionView), H = -G * Q - K, N = G * Q - K, X.projection[0] = 2 * Z.near / (N - H), X.projection[8] = (N + H) / (N - H), e.mul(X.view, X.view, ew0), e.mul(X.projectionView, X.projection, X.view), e.invert(X.inverseProjectionView, X.projectionView), $.disabled = !1, X.disabled = !1;
}
function bq1(Z, J, $, X) {
  if (Zj0(Z, J, X.pose.views[0], X.layer), X.pose.views.length === 1)
    $.disabled = !0;
  else
    Zj0(Z, $, X.pose.views[1], X.layer);
}
function Zj0(Z, J, $, X) {
  Se(Z, J);
  let Y = X.getViewport($);
  bZ.set(J.viewport, Y.x, Y.y, Y.width, Y.height), e.fromArray(J.projection, $.projectionMatrix, 0), e.fromArray(J.view, $.transform.inverse.matrix, 0), e.mul(J.projectionView, J.projection, J.view), e.invert(J.inverseProjectionView, J.projectionView), J.disabled = !1;
}

// node_modules/molstar/lib/mol-canvas3d/helper/pick-helper.js
class he {
  setViewport(Z, J, $, X) {
    bZ.set(this.viewport, Z, J, $, X), this.update();
  }
  setPickPadding(Z) {
    if (this.pickPadding !== Z)
      this.pickPadding = Z, this.update();
  }
  update() {
    let { x: Z, y: J, width: $, height: X } = this.viewport;
    this.pickRatio = this.pickPass.pickRatio, this.pickX = Math.ceil(Z * this.pickRatio), this.pickY = Math.ceil(J * this.pickRatio);
    let Y = Math.floor($ * this.pickRatio), Q = Math.floor(X * this.pickRatio);
    if (Y !== this.pickWidth || Q !== this.pickHeight)
      this.pickWidth = Y, this.pickHeight = Q, this.halfPickWidth = Math.floor(this.pickWidth / 2), this.buffers.setViewport(this.pickX, this.pickY, this.pickWidth, this.pickHeight);
    this.spiral = BS(Math.ceil(this.pickRatio * this.pickPadding)), this.dirty = !0;
  }
  render(Z) {
    if (K1)
      this.webgl.timer.mark("PickHelper.render", { captureStats: !0 });
    let { pickX: J, pickY: $, pickWidth: X, pickHeight: Y, halfPickWidth: Q } = this, { renderer: W, scene: K, helper: G } = this;
    if (W.setTransparentBackground(!1), W.setDrawingBufferSize(X, Y), W.setPixelRatio(this.pickRatio), Eq.is(Z))
      W.setViewport(J, $, Q, Y), this.pickPass.render(W, Z.left, K, G), W.setViewport(J + Q, $, X - Q, Y), this.pickPass.render(W, Z.right, K, G);
    else
      W.setViewport(J, $, X, Y), this.pickPass.render(W, Z, K, G);
    if (this.dirty = !1, K1)
      this.webgl.timer.markEnd("PickHelper.render");
  }
  identifyInternal(Z, J, $) {
    if (this.webgl.isContextLost)
      return;
    let { webgl: X, pickRatio: Y } = this;
    if (X.isContextLost)
      return;
    Z *= X.pixelRatio, J *= X.pixelRatio, J = this.pickPass.drawingBufferHeight - J;
    let { viewport: Q } = this;
    if (Z < Q.x || J < Q.y || Z > Q.x + Q.width || J > Q.y + Q.height)
      return;
    let W = Z - Q.x, K = J - Q.y, G = Math.floor(W * Y), H = Math.floor(K * Y), N = this.buffers.getPickingId(G, H);
    if (N === void 0)
      return;
    let q = this.buffers.getDepth(G, H), U = M.create(Z, J, q);
    if (Eq.is($)) {
      let F = Math.floor(Q.width / 2);
      if (Z > Q.x + F)
        U[0] = Q.x + (W - F) * 2, Rq(U, U, Q, $.right.inverseProjectionView);
      else
        U[0] = Q.x + W * 2, Rq(U, U, Q, $.left.inverseProjectionView);
    } else
      Rq(U, U, Q, $.inverseProjectionView);
    return { id: N, position: U };
  }
  prepare() {
    if (this.pickRatio !== this.pickPass.pickRatio)
      this.update();
  }
  getPickData(Z, J, $) {
    for (let X of this.spiral) {
      let Y = this.identifyInternal(Z + X[0], J + X[1], $);
      if (Y)
        return Y;
    }
  }
  identify(Z, J, $) {
    if (this.prepare(), this.dirty) {
      if (K1)
        this.webgl.timer.mark("PickHelper.identify");
      if (this.webgl.resources.finalizePrograms(["pick"], !0), this.render($), this.buffers.read(), K1)
        this.webgl.timer.markEnd("PickHelper.identify");
    }
    return this.getPickData(Z, J, $);
  }
  asyncIdentify(Z, J, $) {
    if (this.prepare(), this.dirty) {
      if (K1)
        this.webgl.timer.mark("PickHelper.asyncIdentify");
      if (this.render($), this.buffers.asyncRead(), K1)
        this.webgl.timer.markEnd("PickHelper.asyncIdentify");
    }
    return {
      tryGet: () => {
        let X = this.buffers.check();
        if (X === aQ.Resolved)
          return this.getPickData(Z, J, $);
        else if (X === aQ.Pending)
          return "pending";
        else if (X === aQ.Failed)
          this.dirty = !0;
      }
    };
  }
  reset() {
    this.buffers.reset(), this.dirty = !0;
  }
  dispose() {
    this.buffers.dispose();
  }
  constructor(Z, J, $, X, Y, Q, W) {
    if (this.webgl = Z, this.renderer = J, this.scene = $, this.helper = X, this.pickPass = Y, this.dirty = !0, this.buffers = new XI(this.webgl, this.pickPass), this.viewport = bZ(), this.setViewport(Q.x, Q.y, Q.width, Q.height), this.pickPadding = W.pickPadding, !Lx(Z))
      this.asyncIdentify = (K, G, H) => ({
        tryGet: () => this.identify(K, G, H)
      });
  }
}

// node_modules/molstar/lib/mol-gl/shader/evaluate-wboit.frag.js
var Jj0 = `
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);
}
`;

// node_modules/molstar/lib/mol-canvas3d/passes/wboit.js
var xq1 = {
  ...A6,
  tWboitA: o1("texture", "rgba", "float", "nearest"),
  tWboitB: o1("texture", "rgba", "float", "nearest"),
  uTexSize: _0("v2")
}, yq1 = v8("evaluate-wboit", p6, Jj0);
function gq1(Z, J, $) {
  let X = {
    ...B6,
    tWboitA: C.create(J),
    tWboitB: C.create($),
    uTexSize: C.create(h0.create(J.getWidth(), J.getHeight()))
  }, Y = { ...xq1 }, Q = t8(Z, "triangles", yq1, Y, X);
  return e8(Q, X);
}

class Rx {
  get supported() {
    return this._supported;
  }
  getByteCount() {
    if (!this._supported)
      return 0;
    return this.textureA.getByteCount() + this.textureB.getByteCount() + this.depthRenderbuffer.getByteCount();
  }
  bind() {
    let { state: Z, gl: J } = this.webgl;
    this.framebuffer.bind(), Z.clearColor(0, 0, 0, 1), J.clear(J.COLOR_BUFFER_BIT), Z.disable(J.DEPTH_TEST), Z.blendFuncSeparate(J.ONE, J.ONE, J.ZERO, J.ONE_MINUS_SRC_ALPHA), Z.enable(J.BLEND);
  }
  render() {
    if (K1)
      this.webgl.timer.mark("WboitPass.render");
    let { state: Z, gl: J } = this.webgl;
    if (Z.blendFuncSeparate(J.SRC_ALPHA, J.ONE_MINUS_SRC_ALPHA, J.ONE, J.ONE_MINUS_SRC_ALPHA), Z.enable(J.BLEND), this.renderable.update(), this.renderable.render(), K1)
      this.webgl.timer.markEnd("WboitPass.render");
  }
  setSize(Z, J) {
    let [$, X] = this.renderable.values.uTexSize.ref.value;
    if (Z !== $ || J !== X)
      this.textureA.define(Z, J), this.textureB.define(Z, J), this.depthRenderbuffer.setSize(Z, J), C.update(this.renderable.values.uTexSize, h0.set(this.renderable.values.uTexSize.ref.value, Z, J));
  }
  reset() {
    if (this._supported)
      this._init();
  }
  _init() {
    let { extensions: { drawBuffers: Z } } = this.webgl;
    this.framebuffer.bind(), Z.drawBuffers([
      Z.COLOR_ATTACHMENT0,
      Z.COLOR_ATTACHMENT1
    ]), this.textureA.attachFramebuffer(this.framebuffer, "color0"), this.textureB.attachFramebuffer(this.framebuffer, "color1"), this.depthRenderbuffer.attachFramebuffer(this.framebuffer);
  }
  static isSupported(Z) {
    let { extensions: { drawBuffers: J, textureFloat: $, colorBufferFloat: X, depthTexture: Y } } = Z;
    if (!$ || !X || !Y || !J) {
      if (y2) {
        let Q = [];
        if (!$)
          Q.push("textureFloat");
        if (!X)
          Q.push("colorBufferFloat");
        if (!Y)
          Q.push("depthTexture");
        if (!J)
          Q.push("drawBuffers");
        console.log(`Missing "${Q.join('", "')}" extensions required for "wboit"`);
      }
      return !1;
    } else
      return !0;
  }
  constructor(Z, J, $) {
    if (this.webgl = Z, this._supported = !1, !Rx.isSupported(Z))
      return;
    let { resources: X, gl: Y } = Z;
    this.textureA = X.texture("image-float32", "rgba", "float", "nearest"), this.textureA.define(J, $), this.textureB = X.texture("image-float32", "rgba", "float", "nearest"), this.textureB.define(J, $), this.depthRenderbuffer = _2(Y) ? X.renderbuffer("depth32f", "depth", J, $) : X.renderbuffer("depth16", "depth", J, $), this.renderable = gq1(Z, this.textureA, this.textureB), this.framebuffer = X.framebuffer(), this._supported = !0, this._init();
  }
}

// node_modules/molstar/lib/mol-gl/shader/evaluate-dpoit.frag.js
var $j0 = `
precision highp float;

uniform sampler2D tDpoitFrontColor;
uniform vec2 uTexSize;

void main() {
    vec2 coords = gl_FragCoord.xy / uTexSize;
    gl_FragColor = texture2D(tDpoitFrontColor, coords);
}
`;

// node_modules/molstar/lib/mol-gl/shader/blend-back-dpoit.frag.js
var Xj0 = `
    precision highp float;

    uniform sampler2D tDpoitBackColor;
    uniform vec2 uTexSize;

    void main() {
        vec2 coords = gl_FragCoord.xy / uTexSize;
        gl_FragColor = texture2D(tDpoitBackColor, coords);
        if (gl_FragColor.a == 0.0) {
            discard;
        }
    }
`;

// node_modules/molstar/lib/mol-canvas3d/passes/dpoit.js
var mq1 = {
  ...A6,
  tDpoitBackColor: o1("texture", "rgba", "float", "nearest"),
  uTexSize: _0("v2")
}, dq1 = v8("blend-back-dpoit", p6, Xj0);
function pq1(Z, J) {
  let $ = {
    ...B6,
    tDpoitBackColor: C.create(J),
    uTexSize: C.create(h0.create(J.getWidth(), J.getHeight()))
  }, X = { ...mq1 }, Y = t8(Z, "triangles", dq1, X, $);
  return e8(Y, $);
}
var uq1 = {
  ...A6,
  tDpoitFrontColor: o1("texture", "rgba", "float", "nearest"),
  uTexSize: _0("v2")
}, cq1 = v8("evaluate-dpoit", p6, $j0);
function lq1(Z, J) {
  let $ = {
    ...B6,
    tDpoitFrontColor: C.create(J),
    uTexSize: C.create(h0.create(J.getWidth(), J.getHeight()))
  }, X = { ...uq1 }, Y = t8(Z, "triangles", cq1, X, $);
  return e8(Y, $);
}

class Ex {
  get supported() {
    return this._supported;
  }
  getByteCount() {
    if (!this._supported)
      return 0;
    return this.depthTextures[0].getByteCount() + this.depthTextures[1].getByteCount() + this.colorFrontTextures[0].getByteCount() + this.colorFrontTextures[1].getByteCount() + this.colorBackTextures[0].getByteCount() + this.colorBackTextures[1].getByteCount();
  }
  bind() {
    let { state: Z, gl: J, extensions: { blendMinMax: $ } } = this.webgl;
    return this.passCount = 0, this.depthFramebuffers[0].bind(), Z.clearColor(this.DEPTH_CLEAR_VALUE, this.DEPTH_CLEAR_VALUE, 0, 0), J.clear(J.COLOR_BUFFER_BIT), this.depthFramebuffers[1].bind(), Z.clearColor(-this.MIN_DEPTH, this.MAX_DEPTH, 0, 0), J.clear(J.COLOR_BUFFER_BIT), this.colorFramebuffers[0].bind(), Z.clearColor(0, 0, 0, 0), J.clear(J.COLOR_BUFFER_BIT), this.colorFramebuffers[1].bind(), Z.clearColor(0, 0, 0, 0), J.clear(J.COLOR_BUFFER_BIT), this.depthFramebuffers[0].bind(), Z.blendEquation($.MAX), Z.depthMask(!1), {
      depth: this.depthTextures[1],
      frontColor: this.colorFrontTextures[1],
      backColor: this.colorBackTextures[1]
    };
  }
  bindDualDepthPeeling() {
    let { state: Z, gl: J, extensions: { blendMinMax: $ } } = this.webgl;
    return this.readId = this.passCount % 2, this.writeId = 1 - this.readId, this.passCount += 1, this.depthFramebuffers[this.writeId].bind(), Z.clearColor(this.DEPTH_CLEAR_VALUE, this.DEPTH_CLEAR_VALUE, 0, 0), J.clear(J.COLOR_BUFFER_BIT), this.colorFramebuffers[this.writeId].bind(), Z.clearColor(0, 0, 0, 0), J.clear(J.COLOR_BUFFER_BIT), this.depthFramebuffers[this.writeId].bind(), Z.blendEquation($.MAX), Z.depthMask(!1), {
      depth: this.depthTextures[this.readId],
      frontColor: this.colorFrontTextures[this.readId],
      backColor: this.colorBackTextures[this.readId]
    };
  }
  renderBlendBack() {
    if (K1)
      this.webgl.timer.mark("DpoitPass.renderBlendBack");
    let { state: Z, gl: J } = this.webgl;
    if (Z.blendEquation(J.FUNC_ADD), Z.blendFuncSeparate(J.SRC_ALPHA, J.ONE_MINUS_SRC_ALPHA, J.ONE, J.ONE_MINUS_SRC_ALPHA), C.update(this.blendBackRenderable.values.tDpoitBackColor, this.colorBackTextures[this.writeId]), this.blendBackRenderable.update(), this.blendBackRenderable.render(), K1)
      this.webgl.timer.markEnd("DpoitPass.renderBlendBack");
  }
  render() {
    if (K1)
      this.webgl.timer.mark("DpoitPass.render");
    let { state: Z, gl: J } = this.webgl;
    if (Z.blendEquation(J.FUNC_ADD), Z.blendFunc(J.ONE, J.ONE_MINUS_SRC_ALPHA), C.update(this.renderable.values.tDpoitFrontColor, this.colorFrontTextures[this.writeId]), this.renderable.update(), this.renderable.render(), K1)
      this.webgl.timer.markEnd("DpoitPass.render");
  }
  setSize(Z, J) {
    let [$, X] = this.renderable.values.uTexSize.ref.value;
    if (Z !== $ || J !== X) {
      for (let Y = 0;Y < 2; Y++)
        this.depthTextures[Y].define(Z, J), this.colorFrontTextures[Y].define(Z, J), this.colorBackTextures[Y].define(Z, J);
      C.update(this.renderable.values.uTexSize, h0.set(this.renderable.values.uTexSize.ref.value, Z, J)), C.update(this.blendBackRenderable.values.uTexSize, h0.set(this.blendBackRenderable.values.uTexSize.ref.value, Z, J));
    }
  }
  reset() {
    if (this._supported)
      this._init();
  }
  _init() {
    let { extensions: { drawBuffers: Z } } = this.webgl;
    for (let J = 0;J < 2; J++)
      this.depthFramebuffers[J].bind(), Z.drawBuffers([
        Z.COLOR_ATTACHMENT0,
        Z.COLOR_ATTACHMENT1,
        Z.COLOR_ATTACHMENT2
      ]), this.colorFrontTextures[J].attachFramebuffer(this.depthFramebuffers[J], "color0"), this.colorBackTextures[J].attachFramebuffer(this.depthFramebuffers[J], "color1"), this.depthTextures[J].attachFramebuffer(this.depthFramebuffers[J], "color2"), this.colorFramebuffers[J].bind(), Z.drawBuffers([
        Z.COLOR_ATTACHMENT0,
        Z.COLOR_ATTACHMENT1
      ]), this.colorFrontTextures[J].attachFramebuffer(this.colorFramebuffers[J], "color0"), this.colorBackTextures[J].attachFramebuffer(this.colorFramebuffers[J], "color1");
  }
  static isSupported(Z) {
    let { extensions: { drawBuffers: J, textureFloat: $, colorBufferFloat: X, depthTexture: Y, blendMinMax: Q } } = Z;
    if (!$ || !X || !Y || !J || !Q) {
      if (y2) {
        let W = [];
        if (!$)
          W.push("textureFloat");
        if (!X)
          W.push("colorBufferFloat");
        if (!Y)
          W.push("depthTexture");
        if (!J)
          W.push("drawBuffers");
        if (!Q)
          W.push("blendMinMax");
        console.log(`Missing "${W.join('", "')}" extensions required for "dpoit"`);
      }
      return !1;
    } else
      return !0;
  }
  constructor(Z, J, $) {
    if (this.webgl = Z, this.DEPTH_CLEAR_VALUE = -99999, this.MAX_DEPTH = 1, this.MIN_DEPTH = 0, this.passCount = 0, this._supported = !1, !Ex.isSupported(Z))
      return;
    let { resources: X, extensions: { colorBufferHalfFloat: Y, textureHalfFloat: Q } } = Z;
    if (_2(Z.gl))
      this.depthTextures = [
        X.texture("image-float32", "rg", "float", "nearest"),
        X.texture("image-float32", "rg", "float", "nearest")
      ], this.colorFrontTextures = Y && Q ? [
        X.texture("image-float16", "rgba", "fp16", "nearest"),
        X.texture("image-float16", "rgba", "fp16", "nearest")
      ] : [
        X.texture("image-float32", "rgba", "float", "nearest"),
        X.texture("image-float32", "rgba", "float", "nearest")
      ], this.colorBackTextures = Y && Q ? [
        X.texture("image-float16", "rgba", "fp16", "nearest"),
        X.texture("image-float16", "rgba", "fp16", "nearest")
      ] : [
        X.texture("image-float32", "rgba", "float", "nearest"),
        X.texture("image-float32", "rgba", "float", "nearest")
      ];
    else
      this.depthTextures = [
        X.texture("image-float32", "rgba", "float", "nearest"),
        X.texture("image-float32", "rgba", "float", "nearest")
      ], this.colorFrontTextures = [
        X.texture("image-float32", "rgba", "float", "nearest"),
        X.texture("image-float32", "rgba", "float", "nearest")
      ], this.colorBackTextures = [
        X.texture("image-float32", "rgba", "float", "nearest"),
        X.texture("image-float32", "rgba", "float", "nearest")
      ];
    this.depthTextures[0].define(J, $), this.depthTextures[1].define(J, $), this.colorFrontTextures[0].define(J, $), this.colorFrontTextures[1].define(J, $), this.colorBackTextures[0].define(J, $), this.colorBackTextures[1].define(J, $), this.depthFramebuffers = [X.framebuffer(), X.framebuffer()], this.colorFramebuffers = [X.framebuffer(), X.framebuffer()], this.blendBackRenderable = pq1(Z, this.colorBackTextures[0]), this.renderable = lq1(Z, this.colorFrontTextures[0]), this._supported = !0, this._init();
  }
}

// node_modules/molstar/lib/mol-gl/shader/marking/overlay.frag.js
var Yj0 = `
precision highp float;
precision highp sampler2D;

uniform vec2 uTexSizeInv;
uniform sampler2D tEdgeTexture;
uniform vec3 uHighlightEdgeColor;
uniform vec3 uSelectEdgeColor;
uniform float uHighlightEdgeStrength;
uniform float uSelectEdgeStrength;
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;
        float edgeStrength = edgeValue.b == 1.0 ? uHighlightEdgeStrength : uSelectEdgeStrength;
        gl_FragColor.a *= edgeStrength;
    } else {
        gl_FragColor = vec4(0.0);
    }
}
`;

// node_modules/molstar/lib/mol-gl/shader/marking/edge.frag.js
var Qj0 = `
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);
}
`;

// node_modules/molstar/lib/mol-canvas3d/passes/marking.js
var Ox = {
  enabled: j.Boolean(!0),
  highlightEdgeColor: j.Color(i0.darken(i0.fromNormalizedRgb(1, 0.4, 0.6), 1)),
  selectEdgeColor: j.Color(i0.darken(i0.fromNormalizedRgb(0.2, 1, 0.1), 1)),
  edgeScale: j.Numeric(1, { min: 1, max: 3, step: 1 }, { description: "Thickness of the edge." }),
  highlightEdgeStrength: j.Numeric(1, { min: 0, max: 1, step: 0.1 }),
  selectEdgeStrength: j.Numeric(1, { min: 0, max: 1, step: 0.1 }),
  ghostEdgeStrength: j.Numeric(0.3, { 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: j.Numeric(1.5, { min: 0, max: 3, step: 0.1 }, { description: "Factor to multiply the inner edge color with - for added contrast." })
};

class EU {
  static isEnabled(Z) {
    return Z.enabled;
  }
  constructor(Z, J, $) {
    this.webgl = Z, this.depthTarget = Z.createRenderTarget(J, $), this.maskTarget = Z.createRenderTarget(J, $), this.edgesTarget = Z.createRenderTarget(J, $), this.edge = oq1(Z, this.maskTarget.texture), this.overlay = rq1(Z, this.edgesTarget.texture);
  }
  getByteCount() {
    return this.depthTarget.getByteCount() + this.maskTarget.getByteCount() + this.edgesTarget.getByteCount();
  }
  setEdgeState(Z) {
    let { gl: J, state: $ } = this.webgl;
    $.enable(J.SCISSOR_TEST), $.enable(J.BLEND), $.blendFunc(J.ONE, J.ONE), $.blendEquation(J.FUNC_ADD), $.disable(J.DEPTH_TEST), $.depthMask(!1);
    let { x: X, y: Y, width: Q, height: W } = Z;
    $.viewport(X, Y, Q, W), $.scissor(X, Y, Q, W), $.clearColor(0, 0, 0, 0), J.clear(J.COLOR_BUFFER_BIT);
  }
  setOverlayState(Z) {
    let { gl: J, state: $ } = this.webgl;
    $.enable(J.SCISSOR_TEST), $.enable(J.BLEND), $.blendFunc(J.SRC_ALPHA, J.ONE_MINUS_SRC_ALPHA), $.blendEquation(J.FUNC_ADD), $.disable(J.DEPTH_TEST), $.depthMask(!1);
    let { x: X, y: Y, width: Q, height: W } = Z;
    $.viewport(X, Y, Q, W), $.scissor(X, Y, Q, W);
  }
  setSize(Z, J) {
    let $ = this.depthTarget.getWidth(), X = this.depthTarget.getHeight();
    if (Z !== $ || J !== X)
      this.depthTarget.setSize(Z, J), this.maskTarget.setSize(Z, J), this.edgesTarget.setSize(Z, J), C.update(this.edge.values.uTexSizeInv, h0.set(this.edge.values.uTexSizeInv.ref.value, 1 / Z, 1 / J)), C.update(this.overlay.values.uTexSizeInv, h0.set(this.overlay.values.uTexSizeInv.ref.value, 1 / Z, 1 / J));
  }
  update(Z) {
    let { highlightEdgeColor: J, selectEdgeColor: $, edgeScale: X, innerEdgeFactor: Y, ghostEdgeStrength: Q, highlightEdgeStrength: W, selectEdgeStrength: K } = Z, { values: G } = this.edge, H = Math.max(1, Math.round(X * this.webgl.pixelRatio));
    if (G.dEdgeScale.ref.value !== H)
      C.update(G.dEdgeScale, H), this.edge.update();
    let { values: N } = this.overlay;
    C.update(N.uHighlightEdgeColor, i0.toVec3Normalized(N.uHighlightEdgeColor.ref.value, J)), C.update(N.uSelectEdgeColor, i0.toVec3Normalized(N.uSelectEdgeColor.ref.value, $)), C.updateIfChanged(N.uInnerEdgeFactor, Y), C.updateIfChanged(N.uGhostEdgeStrength, Q), C.updateIfChanged(N.uHighlightEdgeStrength, W), C.updateIfChanged(N.uSelectEdgeStrength, K);
  }
  render(Z, J) {
    if (K1)
      this.webgl.timer.mark("MarkingPass.render");
    if (this.edgesTarget.bind(), this.setEdgeState(Z), this.edge.render(), J.bind(), this.setOverlayState(Z), this.overlay.render(), K1)
      this.webgl.timer.markEnd("MarkingPass.render");
  }
}
var nq1 = {
  ...A6,
  tMaskTexture: o1("texture", "rgba", "ubyte", "linear"),
  uTexSizeInv: _0("v2"),
  dEdgeScale: p1("number")
}, iq1 = v8("edge", p6, Qj0);
function oq1(Z, J) {
  let $ = J.getWidth(), X = J.getHeight(), Y = {
    ...B6,
    tMaskTexture: C.create(J),
    uTexSizeInv: C.create(h0.create(1 / $, 1 / X)),
    dEdgeScale: C.create(1)
  }, Q = { ...nq1 }, W = t8(Z, "triangles", iq1, Q, Y);
  return e8(W, Y);
}
var sq1 = {
  ...A6,
  tEdgeTexture: o1("texture", "rgba", "ubyte", "linear"),
  uTexSizeInv: _0("v2"),
  uHighlightEdgeColor: _0("v3"),
  uSelectEdgeColor: _0("v3"),
  uHighlightEdgeStrength: _0("f"),
  uSelectEdgeStrength: _0("f"),
  uGhostEdgeStrength: _0("f"),
  uInnerEdgeFactor: _0("f")
}, aq1 = v8("overlay", p6, Yj0);
function rq1(Z, J) {
  let $ = J.getWidth(), X = J.getHeight(), Y = {
    ...B6,
    tEdgeTexture: C.create(J),
    uTexSizeInv: C.create(h0.create(1 / $, 1 / X)),
    uHighlightEdgeColor: C.create(M()),
    uSelectEdgeColor: C.create(M()),
    uHighlightEdgeStrength: C.create(1),
    uSelectEdgeStrength: C.create(1),
    uGhostEdgeStrength: C.create(0),
    uInnerEdgeFactor: C.create(0)
  }, Q = { ...sq1 }, W = t8(Z, "triangles", aq1, Q, Y);
  return e8(W, Y);
}

// node_modules/molstar/lib/mol-canvas3d/passes/draw.js
class YI {
  setTransparency(Z) {
    if (Z === "wboit") {
      if (this.transparencyMode = this.wboit.supported ? "wboit" : "blended", y2 && !this.wboit.supported)
        console.log('Missing "wboit" support, falling back to "blended".');
    } else if (Z === "dpoit") {
      if (this.transparencyMode = this.dpoit.supported ? "dpoit" : "blended", y2 && !this.dpoit.supported)
        console.log('Missing "dpoit" support, falling back to "blended".');
    } else
      this.transparencyMode = "blended";
    this.depthTextureOpaque.detachFramebuffer(this.postprocessing.target.framebuffer, "depth");
  }
  get transparency() {
    return this.transparencyMode;
  }
  constructor(Z, J, $, X, Y) {
    this.webgl = Z, this.transparencyMode = "blended";
    let { extensions: Q, resources: W, isWebGL2: K } = Z;
    if (this.drawTarget = Z.createDrawTarget(), this.colorTarget = Z.createRenderTarget($, X, !0, "uint8", "linear"), this.transparentColorTarget = Z.createRenderTarget($, X, !1, "uint8", "linear"), this.packedDepth = !Q.depthTexture, this.depthTargetTransparent = Z.createRenderTarget($, X), this.depthTextureTransparent = this.depthTargetTransparent.texture, this.depthTargetOpaque = this.packedDepth ? Z.createRenderTarget($, X) : null, this.depthTextureOpaque = this.depthTargetOpaque ? this.depthTargetOpaque.texture : W.texture("image-depth", "depth", K ? "float" : "ushort", "nearest"), !this.packedDepth)
      this.depthTextureOpaque.define($, X);
    this.wboit = new Rx(Z, $, X), this.dpoit = new Ex(Z, $, X), this.marking = new EU(Z, $, X), this.postprocessing = new bJ(Z, J, this), this.antialiasing = new RU(Z, $, X), this.bloom = new tR(Z, $, X), this.dof = new jH(Z, $, X), this.copyFboTarget = T5(Z, this.colorTarget.texture), this.copyFboPostprocessing = T5(Z, this.postprocessing.target.texture), this.setTransparency(Y);
  }
  getByteCount() {
    return this.drawTarget.getByteCount() + this.colorTarget.getByteCount() + this.transparentColorTarget.getByteCount() + this.depthTargetTransparent.getByteCount() + (this.depthTargetOpaque ? this.depthTargetOpaque.getByteCount() : this.depthTextureOpaque.getByteCount()) + this.wboit.getByteCount() + this.dpoit.getByteCount() + this.marking.getByteCount() + this.postprocessing.getByteCount() + this.antialiasing.getByteCount() + this.bloom.getByteCount() + this.dof.getByteCount();
  }
  reset() {
    this.wboit.reset(), this.dpoit.reset(), this.postprocessing.reset();
  }
  setSize(Z, J) {
    let $ = this.colorTarget.getWidth(), X = this.colorTarget.getHeight();
    if (Z !== $ || J !== X) {
      if (this.colorTarget.setSize(Z, J), this.depthTargetTransparent.setSize(Z, J), this.transparentColorTarget.setSize(Z, J), this.depthTargetOpaque)
        this.depthTargetOpaque.setSize(Z, J);
      else
        this.depthTextureOpaque.define(Z, J);
      C.update(this.copyFboTarget.values.uTexSize, h0.set(this.copyFboTarget.values.uTexSize.ref.value, Z, J)), C.update(this.copyFboPostprocessing.values.uTexSize, h0.set(this.copyFboPostprocessing.values.uTexSize.ref.value, Z, J));
    }
    if (this.wboit.supported)
      this.wboit.setSize(Z, J);
    if (this.dpoit.supported)
      this.dpoit.setSize(Z, J);
    this.marking.setSize(Z, J), this.postprocessing.setSize(Z, J), this.antialiasing.setSize(Z, J), this.dof.setSize(Z, J), this.bloom.setSize(Z, J);
  }
  _renderDpoit(Z, J, $, X, Y, Q) {
    if (!this.dpoit.supported)
      throw new Error("expected dpoit to be supported");
    if (this.depthTextureOpaque.attachFramebuffer(this.colorTarget.framebuffer, "depth"), Z.clear(!0), $.hasOpaque)
      Z.renderOpaque($.primitives, J);
    if (this.depthTextureOpaque.detachFramebuffer(this.colorTarget.framebuffer, "depth"), bJ.isTransparentDepthRequired($, Q)) {
      if (this.depthTargetTransparent.bind(), Z.clearDepth(!0), $.opacityAverage < 1)
        Z.renderDepthTransparent($.primitives, J, this.depthTextureOpaque);
    }
    let W = bJ.isEnabled(Q);
    if ($.opacityAverage < 1) {
      let K = W ? this.transparentColorTarget : this.colorTarget;
      if (W)
        K.bind(), Z.clear(!1, !1, !0);
      let G = this.dpoit.bind();
      Z.renderDpoitTransparent($.primitives, J, this.depthTextureOpaque, G);
      for (let H = 0;H < X; H++) {
        if (K1)
          this.webgl.timer.mark("DpoitPass.layer");
        let N = this.dpoit.bindDualDepthPeeling();
        if (Z.renderDpoitTransparent($.primitives, J, this.depthTextureOpaque, N), X > 1)
          K.bind(), this.dpoit.renderBlendBack();
        if (K1)
          this.webgl.timer.markEnd("DpoitPass.layer");
      }
      K.bind(), this.dpoit.render();
    }
    if (bJ.isEnabled(Q))
      this.postprocessing.render(J, $, !1, Y, Z.props.backgroundColor, Q, Z.light, Z.ambientColor);
    if ($.volumes.renderables.length > 0)
      Z.renderVolume($.volumes, J, this.depthTextureOpaque);
  }
  _renderWboit(Z, J, $, X, Y) {
    if (!this.wboit.supported)
      throw new Error("expected wboit to be supported");
    if (this.depthTextureOpaque.attachFramebuffer(this.colorTarget.framebuffer, "depth"), Z.clear(!0), $.hasOpaque)
      Z.renderOpaque($.primitives, J);
    if (bJ.isTransparentDepthRequired($, Y)) {
      if (this.depthTargetTransparent.bind(), Z.clearDepth(!0), $.opacityAverage < 1)
        Z.renderDepthTransparent($.primitives, J, this.depthTextureOpaque);
    }
    let Q = bJ.isEnabled(Y);
    if ($.opacityAverage < 1) {
      let W = Q ? this.transparentColorTarget : this.colorTarget;
      if (Q)
        W.bind(), Z.clear(!1, !1, !0);
      this.wboit.bind(), Z.renderWboitTransparent($.primitives, J, this.depthTextureOpaque), W.bind(), this.wboit.render();
    }
    if (bJ.isEnabled(Y))
      this.postprocessing.render(J, $, !1, X, Z.props.backgroundColor, Y, Z.light, Z.ambientColor);
    if ($.volumes.renderables.length > 0)
      this.wboit.bind(), Z.renderWboitTransparent($.volumes, J, this.depthTextureOpaque), (Q ? this.postprocessing.target : this.colorTarget).bind(), this.wboit.render();
  }
  _renderBlended(Z, J, $, X, Y, Q) {
    var W, K, G, H, N, q;
    if (X)
      this.drawTarget.bind();
    else if (!this.packedDepth)
      this.depthTextureOpaque.attachFramebuffer(this.colorTarget.framebuffer, "depth");
    else
      this.colorTarget.bind();
    if (Z.clear(!0), $.hasOpaque)
      Z.renderOpaque($.primitives, J);
    if (!X) {
      if (this.depthTargetOpaque)
        this.depthTargetOpaque.bind(), Z.clearDepth(!0), Z.renderDepthOpaque($.primitives, J), this.colorTarget.bind();
      if (bJ.isTransparentDepthRequired($, Q)) {
        if (this.depthTargetTransparent.bind(), Z.clearDepth(!0), $.opacityAverage < 1)
          Z.renderDepthTransparent($.primitives, J, this.depthTextureOpaque);
      }
      let U = bJ.isEnabled(Q);
      if ($.opacityAverage < 1) {
        if (U)
          if (this.transparentColorTarget.bind(), Z.clear(!1, !1, !0), !this.packedDepth)
            this.depthTextureOpaque.attachFramebuffer(this.transparentColorTarget.framebuffer, "depth");
          else
            (W = this.colorTarget.depthRenderbuffer) === null || W === void 0 || W.attachFramebuffer(this.transparentColorTarget.framebuffer);
        if (Z.renderBlendedTransparent($.primitives, J), U)
          if (!this.packedDepth)
            this.depthTextureOpaque.detachFramebuffer(this.transparentColorTarget.framebuffer, "depth");
          else
            (K = this.colorTarget.depthRenderbuffer) === null || K === void 0 || K.detachFramebuffer(this.transparentColorTarget.framebuffer);
      }
      if (U) {
        if (!this.packedDepth)
          this.depthTextureOpaque.detachFramebuffer(this.postprocessing.target.framebuffer, "depth");
        else
          (G = this.colorTarget.depthRenderbuffer) === null || G === void 0 || G.detachFramebuffer(this.postprocessing.target.framebuffer);
        if (this.postprocessing.render(J, $, !1, Y, Z.props.backgroundColor, Q, Z.light, Z.ambientColor), !this.packedDepth)
          this.depthTextureOpaque.attachFramebuffer(this.postprocessing.target.framebuffer, "depth");
        else
          (H = this.colorTarget.depthRenderbuffer) === null || H === void 0 || H.attachFramebuffer(this.postprocessing.target.framebuffer);
      }
      if ($.volumes.renderables.length > 0) {
        let F = bJ.isEnabled(Q) ? this.postprocessing.target : this.colorTarget;
        if (!this.packedDepth)
          this.depthTextureOpaque.detachFramebuffer(F.framebuffer, "depth");
        else
          (N = this.colorTarget.depthRenderbuffer) === null || N === void 0 || N.detachFramebuffer(F.framebuffer);
        if (F.bind(), Z.renderVolume($.volumes, J, this.depthTextureOpaque), !this.packedDepth)
          this.depthTextureOpaque.attachFramebuffer(F.framebuffer, "depth");
        else
          (q = this.colorTarget.depthRenderbuffer) === null || q === void 0 || q.attachFramebuffer(F.framebuffer);
        F.bind();
      }
    } else if ($.opacityAverage < 1)
      Z.renderBlendedTransparent($.primitives, J);
  }
  _render(Z, J, $, X, Y, Q, W) {
    var K, G;
    if (J.disabled)
      return;
    let H = $.volumes.renderables.length > 0, N = bJ.isEnabled(W.postprocessing), q = RU.isEnabled(W.postprocessing), U = EU.isEnabled(W.marking), F = jH.isEnabled(W.postprocessing), E = tR.isEnabled(W.postprocessing), { x: R, y: z, width: D, height: A } = J.viewport;
    if (Z.setViewport(R, z, D, A), Z.update(J, $), Q && !q && Y)
      this.drawTarget.bind(), Z.clear(!1);
    let B = !1;
    if (this.transparencyMode === "wboit" && this.wboit.supported)
      this._renderWboit(Z, J, $, Q, W.postprocessing), B = !0;
    else if (this.transparencyMode === "dpoit" && this.dpoit.supported)
      this._renderDpoit(Z, J, $, W.dpoitIterations, Q, W.postprocessing), B = !0;
    else
      this._renderBlended(Z, J, $, !H && !N && !q && Y, Q, W.postprocessing);
    let T = N ? this.postprocessing.target : !Y || H || B ? this.colorTarget : this.drawTarget;
    if (U && $.markerAverage > 0) {
      let V = W.marking.ghostEdgeStrength < 1;
      if (V && $.markerAverage !== 1)
        this.marking.depthTarget.bind(), Z.clear(!1, !0), Z.renderMarkingDepth($.primitives, J);
      this.marking.maskTarget.bind(), Z.clear(!1, !0), Z.renderMarkingMask($.primitives, J, V ? this.marking.depthTarget.texture : null), this.marking.update(W.marking), this.marking.render(J.viewport, T);
    } else
      T.bind();
    if (X.debug.isEnabled)
      X.debug.syncVisibility(), Z.renderBlended(X.debug.scene, J);
    if (X.handle.isEnabled)
      Z.renderBlended(X.handle.scene, J);
    if (X.pointer.isEnabled)
      X.pointer.setCamera(J), Z.update(X.pointer.camera, X.pointer.scene), Z.renderBlended(X.pointer.scene, X.pointer.camera);
    if (X.camera.isEnabled)
      X.camera.update(J), Z.update(X.camera.camera, X.camera.scene), Z.renderBlended(X.camera.scene, X.camera.camera);
    let w = !1;
    if (q) {
      let V = bJ.isEnabled(W.postprocessing) ? this.postprocessing.target.texture : this.colorTarget.texture;
      this.antialiasing.render(J, V, Y && !F, W.postprocessing);
    } else if (Y && !jH.isEnabled(W.postprocessing))
      w = !0;
    if (F && W.postprocessing.dof.name === "on") {
      let V = RU.isEnabled(W.postprocessing) ? this.antialiasing.target.texture : bJ.isEnabled(W.postprocessing) ? this.postprocessing.target.texture : this.colorTarget.texture;
      this.dof.update(J, V, ((K = this.depthTargetOpaque) === null || K === void 0 ? void 0 : K.texture) || this.depthTextureOpaque, this.depthTextureTransparent, W.postprocessing.dof.params, $.boundingSphereVisible), this.dof.render(J.viewport, Y ? void 0 : this.getColorTarget(W.postprocessing));
    } else if (Y && !RU.isEnabled(W.postprocessing))
      w = !0;
    if (w) {
      if (this.drawTarget.bind(), this.webgl.state.disable(this.webgl.gl.DEPTH_TEST), N)
        this.copyFboPostprocessing.render();
      else if (H || B)
        this.copyFboTarget.render();
    }
    if (E && W.postprocessing.bloom.name === "on") {
      let V = W.postprocessing.bloom.params.mode === "emissive";
      if (V && $.emissiveAverage > 0)
        this.bloom.emissiveTarget.bind(), Z.clear(!1, !0), Z.update(J, $), Z.renderEmissive($.primitives, J);
      if (!V || $.emissiveAverage > 0)
        this.bloom.update(this.colorTarget.texture, this.bloom.emissiveTarget.texture, ((G = this.depthTargetOpaque) === null || G === void 0 ? void 0 : G.texture) || this.depthTextureOpaque, W.postprocessing.bloom.params), this.bloom.render(J.viewport, Y ? void 0 : this.getColorTarget(W.postprocessing));
    }
    this.webgl.gl.flush();
  }
  render(Z, J, $) {
    if (K1)
      this.webgl.timer.mark("DrawPass.render");
    let { renderer: X, camera: Y, scene: Q, helper: W } = Z;
    this.postprocessing.setTransparentBackground(J.transparentBackground);
    let K = J.transparentBackground || this.postprocessing.background.isEnabled(J.postprocessing);
    if (X.setTransparentBackground(K), X.setDrawingBufferSize(this.colorTarget.getWidth(), this.colorTarget.getHeight()), X.setPixelRatio(this.webgl.pixelRatio), Eq.is(Y)) {
      if (K1)
        this.webgl.timer.mark("StereoCamera.left");
      if (this._render(X, Y.left, Q, W, $, K, J), K1)
        this.webgl.timer.markEnd("StereoCamera.left");
      if (K1)
        this.webgl.timer.mark("StereoCamera.right");
      if (this._render(X, Y.right, Q, W, $, K, J), K1)
        this.webgl.timer.markEnd("StereoCamera.right");
    } else
      this._render(X, Y, Q, W, $, K, J);
    if (K1)
      this.webgl.timer.markEnd("DrawPass.render");
  }
  getColorTarget(Z) {
    if (jH.isEnabled(Z))
      return this.dof.target;
    else if (RU.isEnabled(Z))
      return this.antialiasing.target;
    else if (bJ.isEnabled(Z))
      return this.postprocessing.target;
    return this.colorTarget;
  }
}

// node_modules/molstar/lib/mol-util/image.js
var tA;
(function(Z) {
  function J(Y, Q, W) {
    return { array: Y, width: Q, height: W };
  }
  Z.create = J;
  function $(Y) {
    let { array: Q, width: W, height: K } = Y, G = Q.length / (W * K), H = W * G;
    for (let N = 0, q = K / 2;N < q; ++N)
      for (let U = 0, F = H;U < F; ++U) {
        let E = N * H + U, R = (K - N - 1) * H + U, z = Q[E];
        Q[E] = Q[R], Q[R] = z;
      }
    return Y;
  }
  Z.flipY = $;
  function X(Y) {
    let { array: Q } = Y, W = Q instanceof Uint8Array ? 255 : 1;
    for (let K = 0, G = Q.length;K < G; K += 4) {
      let H = Q[K + 3] / W;
      Q[K] /= H, Q[K + 1] /= H, Q[K + 2] /= H;
    }
    return Y;
  }
  Z.divideByAlpha = X;
})(tA || (tA = {}));

// node_modules/molstar/lib/mol-canvas3d/helper/camera-helper.js
var tq1 = {
  alpha: j.Numeric(0.51, { min: 0, max: 1, step: 0.01 }, { isEssential: !0, label: "Opacity" }),
  colorX: j.Color(c2.red, { isEssential: !0 }),
  colorY: j.Color(c2.green, { isEssential: !0 }),
  colorZ: j.Color(c2.blue, { isEssential: !0 }),
  scale: j.Numeric(0.33, { min: 0.1, max: 2, step: 0.1 }, { isEssential: !0 }),
  location: j.Select("bottom-left", j.arrayToOptions(["bottom-left", "bottom-right", "top-left", "top-right"])),
  locationOffsetX: j.Numeric(0),
  locationOffsetY: j.Numeric(0),
  originColor: j.Color(c2.grey),
  radiusScale: j.Numeric(0.075, { min: 0.01, max: 0.3, step: 0.001 }),
  showPlanes: j.Boolean(!0),
  planeColorXY: j.Color(c2.grey, { label: "Plane Color XY" }),
  planeColorXZ: j.Color(c2.grey, { label: "Plane Color XZ" }),
  planeColorYZ: j.Color(c2.grey, { label: "Plane Color YZ" }),
  showLabels: j.Boolean(!1),
  labelX: j.Text("X"),
  labelY: j.Text("Y"),
  labelZ: j.Text("Z"),
  labelColorX: j.Color(c2.grey),
  labelColorY: j.Color(c2.grey),
  labelColorZ: j.Color(c2.grey),
  labelOpacity: j.Numeric(1, { min: 0, max: 1, step: 0.01 }),
  labelScale: j.Numeric(0.25, { min: 0.1, max: 1, step: 0.01 })
}, ZE = {
  axes: j.MappedStatic("on", {
    on: j.Group(tq1),
    off: j.Group({})
  }, { cycle: !0, description: "Show camera orientation axes" })
};

class QI {
  constructor(Z, J = {}) {
    this.webgl = Z, this.props = {
      axes: { name: "off", params: {} }
    }, this.pixelRatio = 1, this.eachGroup = ($, X) => {
      if (!zx($))
        return !1;
      let Y = !1;
      if (this.meshRenderObject) {
        let Q = this.meshRenderObject.values.uGroupCount.ref.value;
        for (let { groupId: W, instanceId: K } of $.elements) {
          let G = K * Q + W;
          if (X(k0.ofSingleton(G)))
            Y = !0;
        }
      }
      if (this.textRenderObject) {
        let Q = this.textRenderObject.values.uGroupCount.ref.value;
        for (let { groupId: W, instanceId: K } of $.elements) {
          let G = K * Q + W;
          if (X(k0.ofSingleton(G)))
            Y = !0;
        }
      }
      return Y;
    }, this.scene = s3.create(Z, "blended"), this.camera = new O6, M.set(this.camera.up, 0, 1, 0), M.set(this.camera.target, 0, 0, 0), this.setProps(J);
  }
  setProps(Z) {
    this.props = WQ(this.props, (J) => {
      if (Z.axes !== void 0) {
        if (J.axes.name = Z.axes.name, Z.axes.name === "on") {
          this.scene.clear(), this.pixelRatio = this.webgl.pixelRatio;
          let $ = {
            ...Z.axes.params,
            scale: Z.axes.params.scale * this.pixelRatio,
            labelScale: Z.axes.params.labelScale * this.pixelRatio
          };
          if (this.meshRenderObject = YF1($), this.scene.add(this.meshRenderObject), Z.axes.params.showLabels)
            this.textRenderObject = KF1($), this.scene.add(this.textRenderObject);
          else
            this.textRenderObject = void 0;
          this.scene.commit(), M.set(this.camera.position, 0, 0, $.scale * 200), e.lookAt(this.camera.view, this.camera.position, this.camera.target, this.camera.up), J.axes.params = { ...Z.axes.params };
        }
      }
    });
  }
  get isEnabled() {
    return this.props.axes.name === "on";
  }
  getLoci(Z) {
    let { objectId: J, groupId: $, instanceId: X } = Z;
    if ((!this.meshRenderObject || J !== this.meshRenderObject.id) && (!this.textRenderObject || J !== this.textRenderObject.id) || $ === eZ.None)
      return G8;
    return ZF1(this, $, X);
  }
  mark(Z, J) {
    if (!W7.is(W7.Highlighting, J))
      return !1;
    if (!KJ(Z)) {
      if (!zx(Z))
        return !1;
      if (Z.data !== this)
        return !1;
    }
    return m8.mark(this.meshRenderObject, Z, J, this.eachGroup) || m8.mark(this.textRenderObject, Z, J, this.eachGroup);
  }
  update(Z) {
    if (!this.meshRenderObject || this.props.axes.name === "off")
      return;
    if (this.pixelRatio !== this.webgl.pixelRatio)
      this.setProps(this.props);
    JF1(this.camera, Z.viewport, Z.viewOffset), e.extractRotation(this.scene.view, Z.view);
    let J = this.textRenderObject ? this.textRenderObject.values.boundingSphere.ref.value.radius : this.meshRenderObject.values.boundingSphere.ref.value.radius, $ = this.props.axes.params.location, X = this.props.axes.params.locationOffsetX * this.pixelRatio, Y = this.props.axes.params.locationOffsetY * this.pixelRatio;
    if ($ === "bottom-left")
      e.setTranslation(this.scene.view, M.create(-Z.viewport.width / 2 + J + X, -Z.viewport.height / 2 + J + Y, 0));
    else if ($ === "bottom-right")
      e.setTranslation(this.scene.view, M.create(Z.viewport.width / 2 - J - X, -Z.viewport.height / 2 + J + Y, 0));
    else if ($ === "top-left")
      e.setTranslation(this.scene.view, M.create(-Z.viewport.width / 2 + J + X, Z.viewport.height / 2 - J - Y, 0));
    else if ($ === "top-right")
      e.setTranslation(this.scene.view, M.create(Z.viewport.width / 2 - J - X, Z.viewport.height / 2 - J - Y, 0));
    else
      T8($);
  }
}
var eZ;
(function(Z) {
  Z[Z.None = 0] = "None", Z[Z.X = 1] = "X", Z[Z.Y = 2] = "Y", Z[Z.Z = 3] = "Z", Z[Z.XY = 4] = "XY", Z[Z.XZ = 5] = "XZ", Z[Z.YZ = 6] = "YZ", Z[Z.Origin = 7] = "Origin";
})(eZ || (eZ = {}));
function eq1(Z, J) {
  let $ = J.props.axes, X = $.name === "on" ? $.params.labelX : "X", Y = $.name === "on" ? $.params.labelY : "Y", Q = $.name === "on" ? $.params.labelZ : "Z";
  switch (Z) {
    case eZ.X:
      return `${X} Axis`;
    case eZ.Y:
      return `${Y} Axis`;
    case eZ.Z:
      return `${Q} Axis`;
    case eZ.XY:
      return `${X}${Y} Plane`;
    case eZ.XZ:
      return `${X}${Q} Plane`;
    case eZ.YZ:
      return `${Y}${Q} Plane`;
    case eZ.Origin:
      return "Origin";
    default:
      return "Axes";
  }
}
function ZF1(Z, J, $) {
  return PR("camera-axes", Z, [{ groupId: J, instanceId: $ }], void 0, () => eq1(J, Z));
}
function zx(Z) {
  return Z.kind === "data-loci" && Z.tag === "camera-axes";
}
function JF1(Z, J, $) {
  let { near: X, far: Y } = Z, Q = -J.width / 2, W = J.width / 2, K = J.height / 2, G = -J.height / 2, H = (W - Q) / 2, N = (K - G) / 2, q = (W + Q) / 2, U = (K + G) / 2, F = q - H, E = q + H, R = U + N, z = U - N;
  if ($.enabled) {
    let D = (W - Q) / $.width, A = (K - G) / $.height;
    F += D * $.offsetX, E = F + D * $.width, R -= A * $.offsetY, z = R - A * $.height;
  }
  e.ortho(Z.projection, F, E, R, z, X, Y);
}
function $F1(Z, J) {
  let $ = v1.createState(512, 256, J), X = 100 * Z.scale, Y = Z.radiusScale * X, Q = Z.showLabels ? 100 * Z.labelScale / 3 : 0, W = M.scale(M(), M.unitX, X - Q), K = M.scale(M(), M.unitY, X - Q), G = M.scale(M(), M.unitZ, X - Q), H = { radiusTop: Y, radiusBottom: Y, radialSegments: 32 };
  if ($.currentGroup = eZ.Origin, g8($, M.origin, Y, 2), $.currentGroup = eZ.X, g8($, W, Y, 2), q6($, M.origin, W, 1, H), $.currentGroup = eZ.Y, g8($, K, Y, 2), q6($, M.origin, K, 1, H), $.currentGroup = eZ.Z, g8($, G, Y, 2), q6($, M.origin, G, 1, H), Z.showPlanes) {
    M.scale(W, W, 0.5), M.scale(K, K, 0.5), M.scale(G, G, 0.5), $.currentGroup = eZ.XY, v1.addTriangle($, M.origin, W, K), v1.addTriangle($, M.origin, K, W);
    let N = M.add(M(), W, K);
    v1.addTriangle($, N, W, K), v1.addTriangle($, N, K, W), $.currentGroup = eZ.XZ, v1.addTriangle($, M.origin, W, G), v1.addTriangle($, M.origin, G, W);
    let q = M.add(M(), W, G);
    v1.addTriangle($, q, W, G), v1.addTriangle($, q, G, W), $.currentGroup = eZ.YZ, v1.addTriangle($, M.origin, K, G), v1.addTriangle($, M.origin, G, K);
    let U = M.add(M(), K, G);
    v1.addTriangle($, U, K, G), v1.addTriangle($, U, G, K);
  }
  return v1.getMesh($);
}
function XF1(Z, J) {
  let $ = 100 * Z.scale, X = $F1(Z, J === null || J === void 0 ? void 0 : J.geometry);
  X.setBoundingSphere(C0.create(M.create($ / 2, $ / 2, $ / 2), $ + $ / 4));
  let Y = (Q) => {
    switch (Q) {
      case eZ.X:
        return Z.colorX;
      case eZ.Y:
        return Z.colorY;
      case eZ.Z:
        return Z.colorZ;
      case eZ.XY:
        return Z.planeColorXY;
      case eZ.XZ:
        return Z.planeColorXZ;
      case eZ.YZ:
        return Z.planeColorYZ;
      case eZ.Origin:
        return Z.originColor;
      default:
        return c2.grey;
    }
  };
  return c8.create("axes-mesh", {}, X, Y, () => 1, () => "");
}
function YF1(Z) {
  let J = XF1(Z);
  return c8.createRenderObject(J, {
    ...j.getDefaultValues(n1.Params),
    ...Z,
    ignoreLight: !0,
    cellSize: 0
  });
}
function QF1(Z, J) {
  let $ = iQ.create(Z, 8, 8, J), X = 100 * Z.scale, Y = M.scale(M(), M.unitX, X), Q = M.scale(M(), M.unitY, X), W = M.scale(M(), M.unitZ, X), K = 100 * Z.labelScale;
  return $.add(Z.labelX, Y[0], Y[1], Y[2], 0, K, eZ.X), $.add(Z.labelY, Q[0], Q[1], Q[2], 0, K, eZ.Y), $.add(Z.labelZ, W[0], W[1], W[2], 0, K, eZ.Z), $.getText();
}
function WF1(Z, J) {
  let $ = 100 * Z.scale, X = QF1(Z, J === null || J === void 0 ? void 0 : J.geometry);
  X.setBoundingSphere(C0.create(M.create($ / 2, $ / 2, $ / 2), $));
  let Y = (Q) => {
    switch (Q) {
      case eZ.X:
        return Z.labelColorX;
      case eZ.Y:
        return Z.labelColorY;
      case eZ.Z:
        return Z.labelColorZ;
      default:
        return c2.grey;
    }
  };
  return c8.create("axes-text", {}, X, Y, () => 1, () => "");
}
function KF1(Z) {
  let J = WF1(Z);
  return c8.createRenderObject(J, {
    ...j.getDefaultValues(IJ.Params),
    ...Z,
    alpha: Z.labelOpacity,
    cellSize: 0
  });
}

// node_modules/molstar/lib/mol-gl/shader/illumination/compose.frag.js
var Wj0 = `
precision highp float;
precision highp sampler2D;

uniform sampler2D tShaded;
uniform sampler2D tColor;
uniform sampler2D tNormal;
uniform sampler2D tTransparentColor;
uniform sampler2D tSsaoDepth;
uniform sampler2D tSsaoDepthTransparent;
uniform sampler2D tDepthOpaque;
uniform sampler2D tDepthTransparent;
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 vec3 uOcclusionColor;
uniform bool uTransparentBackground;

uniform float uDenoiseThreshold;

#include common

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

float getDepthOpaque(const in vec2 coords) {
    #ifdef depthTextureSupport
        return texture2D(tDepthOpaque, coords).r;
    #else
        return unpackRGBAToDepth(texture2D(tDepthOpaque, coords));
    #endif
}

float getDepthTransparent(const in vec2 coords) {
    #if defined(dTransparentOutline) || defined(dOcclusionEnable)
        return unpackRGBAToDepthWithAlpha(texture2D(tDepthTransparent, coords)).x;
    #else
        return 1.0;
    #endif
}

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

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;
}

float getSsaoTransparent(vec2 coords) {
    float rawSsao = unpackRGToUnitInterval(texture2D(tSsaoDepthTransparent, 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;
}

//

// TODO: investigate
// https://interplayoflight.wordpress.com/2022/03/26/raytraced-global-illumination-denoising/

//

#define INV_SQRT_OF_2PI 0.39894228040143267793994605993439  // 1.0/SQRT_OF_2PI
#define INV_PI 0.31830988618379067153776752674503

// https://github.com/BrutPitt/glslSmartDeNoise
//
//  smartDeNoise - parameters
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
//  sampler2D tex     - sampler image / texture
//  vec2 uv           - actual fragment coord
//  float sigma  >  0 - sigma Standard Deviation
//  float kSigma >= 0 - sigma coefficient
//      kSigma * sigma  -->  radius of the circular kernel
//  float threshold   - edge sharpening threshold

float NormalWeightStrength = 6.0;

vec4 smartDeNoise(sampler2D tex, vec2 uv) {
    float sigma = 3.0;
    float kSigma = 2.0;
    float threshold = uDenoiseThreshold;

    vec4 centrPx = texture2D(tex, uv);
    if (threshold == 0.0) return centrPx;

    float invSigmaQx2 = 0.5 / (sigma * sigma);      // 1.0 / (sigma^2 * 2.0)
    float invSigmaQx2PI = INV_PI * invSigmaQx2;    // 1.0 / (sqrt(PI) * sigma)

    float invThresholdSqx2 = 0.5 / (threshold * threshold);     // 1.0 / (sigma^2 * 2.0)
    float invThresholdSqrt2PI = INV_SQRT_OF_2PI / threshold;   // 1.0 / (sqrt(2*PI) * sigma)

    float zBuff = 0.0;
    vec4 aBuff = vec4(0.0);

    vec3 normal = texture2D(tNormal, uv).xyz;

    for (int x = -6; x <= 6; ++x) {
        for (int y = -6; y <= 6; ++y) {
            vec2 d = vec2(float(x), float(y));

            float blurFactor = exp(-dot(d , d) * invSigmaQx2) * invSigmaQx2PI;
            vec2 uvSample = uv + d / uTexSize;

            vec3 normalSample = texture2D(tNormal, uvSample).xyz;
            float normalW = saturate(dot(normal, normalSample));
            normalW = pow(normalW, NormalWeightStrength);
            blurFactor *= normalW;

            vec4 walkPx = texture2D(tex, uvSample);

            vec4 dC = walkPx - centrPx;
            float deltaFactor = exp(-dot(dC, dC) * invThresholdSqx2) * invThresholdSqrt2PI * blurFactor;

            zBuff += deltaFactor;
            aBuff += deltaFactor * walkPx;
        }
    }

    if (zBuff <= EPSILON) {
        return centrPx;
    }

    return aBuff / zBuff;
}

int squaredOutlineScale = dOutlineScale * dOutlineScale;
void getOutline(const in vec2 coords, out bool hasOpaque, out bool hasTransparent, out float opaqueDepth, out float transparentDepth, out float alpha) {
    vec2 invTexSize = 1.0 / uTexSize;
    
    hasOpaque = false;
    hasTransparent = false;
    opaqueDepth = 1.0;
    transparentDepth = 1.0;
    alpha = 0.0;
    for (int y = -dOutlineScale; y <= dOutlineScale; y++) {
        for (int x = -dOutlineScale; x <= dOutlineScale; x++) {
            if (x * x + y * y > squaredOutlineScale) {
                continue;
            }

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

            vec4 sampleOutlineCombined = texture2D(tOutlines, sampleCoords);
            float sampleOpaqueDepth = unpackRGToUnitInterval(sampleOutlineCombined.gb);
            float sampleTransparentDepth = sampleOutlineCombined.a;
            vec2 sampleFlagWithAlpha = unpack2x4(sampleOutlineCombined.r);

            float sampleFlag = sampleFlagWithAlpha.x;
            float sampleAlpha = clamp(sampleFlagWithAlpha.y * 0.5, 0.01, 1.0);
            
            if ((sampleFlag > 0.20 && sampleFlag < 0.30) || (sampleFlag > 0.70 && sampleFlag < 0.80)) { // transparent || both
                if (sampleOpaqueDepth < opaqueDepth) {
                    hasOpaque = true;
                    opaqueDepth = sampleOpaqueDepth;
                }
            }
            
            if ((((sampleFlag > 0.45 && sampleFlag < 0.55) || (sampleFlag > 0.70 && sampleFlag < 0.80))) && sampleTransparentDepth < transparentDepth) { // transparent || both
                hasTransparent = true;
                transparentDepth = sampleTransparentDepth;
                alpha = sampleAlpha;
            }
        }
    }
}

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

    #ifdef dDenoise
        vec4 color = smartDeNoise(tColor, coords);
    #else
        vec4 color = texture2D(tColor, coords);
    #endif

    float opaqueDepth = getDepthOpaque(coords);
    float backgroundViewZ = 2.0 * uFar;
    float opaqueSelfViewZ = isBackground(opaqueDepth) ? backgroundViewZ : getViewZ(opaqueDepth);
    float fogFactor = smoothstep(uFogNear, uFogFar, abs(opaqueSelfViewZ));
    float fogAlpha = 1.0 - fogFactor;

    float transparentDepth = 1.0;
    #ifdef dBlendTransparency
        bool blendTransparency = true;
        vec4 transparentColor = texture2D(tTransparentColor, coords);

        transparentDepth = getDepthTransparent(coords);
    #endif

    float alpha = 1.0;
    if (!uTransparentBackground) {
        // mix opaque objects with background color
        color.rgb = mix(color.rgb, uFogColor, fogFactor);
    } else {
        // pre-multiplied alpha expected for transparent background
        alpha = fogAlpha;
        color.rgb *= fogAlpha;
    }

    #if defined(dOcclusionEnable)
        if (!isBackground(opaqueDepth)) {
            float occlusionFactor = getSsao(coords);

            if (!uTransparentBackground) {
                color.rgb = mix(mix(uOcclusionColor, uFogColor, fogFactor), color.rgb, occlusionFactor);
            } else {
                color.rgb = mix(uOcclusionColor * (1.0 - fogFactor), color.rgb, occlusionFactor);
            }
        }
        #ifdef dBlendTransparency
            if (!isBackground(transparentDepth)) {
                float viewDist = abs(getViewZ(transparentDepth));
                float fogFactor = smoothstep(uFogNear, uFogFar, viewDist);
                float occlusionFactor = getSsaoTransparent(coords);
                transparentColor.rgb = mix(uOcclusionColor * (1.0 - fogFactor), transparentColor.rgb, occlusionFactor);
            }
        #endif
    #endif

    #ifdef dOutlineEnable
        bool hasOpaque;
        bool hasTransparent;
        float outlineOpaqueDepth;
        float outlineTransparentDepth;
        float outlineAlpha;
        getOutline(coords, hasOpaque, hasTransparent, outlineOpaqueDepth, outlineTransparentDepth, outlineAlpha);

        if (hasOpaque) {
            float viewDist = abs(getViewZ(outlineOpaqueDepth));
            float fogFactor = smoothstep(uFogNear, uFogFar, viewDist);
            if (!uTransparentBackground) {                    
                color.rgb = mix(uOutlineColor, uFogColor, fogFactor);
            } else {
                alpha = 1.0 - fogFactor;
                color.rgb = mix(uOutlineColor, vec3(0.0), fogFactor);
            }
        }  

        #ifdef dBlendTransparency            
            if (hasTransparent) {
                if (hasOpaque && outlineOpaqueDepth < outlineTransparentDepth) {
                    blendTransparency = false;
                } else {
                    float finalOutlineAlpha = clamp(outlineAlpha * 2.0, 0.0, 1.0);
                    float viewDist = abs(getViewZ(outlineTransparentDepth));
                    float fogFactor = smoothstep(uFogNear, uFogFar, viewDist);
                    float finalAlpha = max(transparentColor.a, finalOutlineAlpha * (1.0 - fogFactor));
                    transparentColor.a = finalAlpha;
                    transparentColor.rgb = uOutlineColor * finalAlpha;
                }
            }
        #endif
    #endif

    #ifdef dBlendTransparency
        if (blendTransparency) {
            if (transparentColor.a != 0.0) {
                // blending
                color = transparentColor + color * (1.0 - transparentColor.a);
                alpha = transparentColor.a + alpha * (1.0 - transparentColor.a);
            }
        }
    #endif

    gl_FragColor = vec4(color.rgb, alpha);
}
`;

// node_modules/molstar/lib/mol-gl/shader/illumination/trace.frag.js
var Kj0 = `
precision highp int;
precision highp float;
precision highp sampler2D;

uniform sampler2D tColor;
uniform sampler2D tNormal;
uniform sampler2D tShaded;
uniform sampler2D tThickness;
uniform sampler2D tAccumulate;
uniform sampler2D tDepth;
uniform vec2 uTexSize;
uniform vec4 uBounds;

uniform float uNear;
uniform float uFar;
uniform float uFogNear;
uniform float uFogFar;
uniform vec3 uFogColor;

#if dLightCount != 0
    uniform vec3 uLightDirection[dLightCount];
    uniform vec3 uLightColor[dLightCount];
#endif
uniform vec3 uAmbientColor;
uniform vec3 uLightStrength;

uniform int uFrameNo;

uniform float uRayDistance;
uniform float uMinThickness;
uniform float uThicknessFactor;
uniform float uThickness;

uniform float uShadowSoftness;
uniform float uShadowThickness;

uniform mat4 uProjection;
uniform mat4 uInvProjection;

#include common

// parts adapted from
// - https://blog.demofox.org/2020/05/25/casual-shadertoy-path-tracing-1-basic-camera-diffuse-emissive/
// - https://github.com/0beqz/realism-effects/blob/v2-debug/src/ssgi/shader/ssgi.frag

//

// after a hit, it moves the ray this far along the normal away from a surface.
// Helps prevent incorrect intersections when rays bounce off of objects.
#define RayPosNormalNudge 0.0001

#if __VERSION__ == 100
    #define StateType float

    // from https://www.shadertoy.com/view/4djSRW
    float hash14(vec4 p4) {
        p4 = fract(p4  * vec4(0.1031, 0.1030, 0.0973, 0.1099));
        p4 += dot(p4, p4.wzxy + 33.33);
        return fract((p4.x + p4.y) * (p4.z + p4.w));
    }

    float randomFloat(inout float state) {
        state += 0.06711056;
        return 1.0 - hash14(vec4(gl_FragCoord.xy, float(uFrameNo), state));
    }
#else
    #define StateType uint

    // https://www.pcg-random.org/
    // https://jcgt.org/published/0009/03/02/
    uint pcg(inout uint seed) {
        seed = seed * 747796405u + 2891336453u;
        uint word = ((seed >> ((seed >> 28u) + 4u)) ^ seed) * 277803737u;
        return (word >> 22u) ^ word;
    }

    float randomFloat(inout uint state) {
        return float(pcg(state)) / 4294967296.0;
    }
#endif

vec3 randomUnitVector(inout StateType state) {
    float z = randomFloat(state) * 2.0 - 1.0;
    float a = randomFloat(state) * TWO_PI;
    float r = sqrt(1.0 - z * z);
    float x = r * cos(a);
    float y = r * sin(a);
    return vec3(x, y, z);
}

struct RayHitInfo {
    bool missed;
    vec3 position;
    vec3 normal;
    vec3 color;
    vec3 emissive;
};

//

float getDepth(const in vec2 coords) {
    vec2 c = vec2(clamp(coords.x, uBounds.x, uBounds.z), clamp(coords.y, uBounds.y, uBounds.w));
    return texture2D(tDepth, c).r;
}

float getThickness(const in vec2 coords) {
    vec2 c = vec2(clamp(coords.x, uBounds.x, uBounds.z), clamp(coords.y, uBounds.y, uBounds.w));
    return unpackRGBAToDepth(texture2D(tThickness, c));
}

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

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

vec2 viewSpaceToScreenSpace(const vec3 position) {
    vec4 projectedCoord = uProjection * vec4(position, 1.0);
    projectedCoord.xy /= projectedCoord.w;
    // [-1, 1] --> [0, 1] (NDC to screen position)
    projectedCoord.xy = projectedCoord.xy * 0.5 + 0.5;
    return projectedCoord.xy;
}

vec2 binarySearch(inout vec3 dir, inout vec3 hitPos) {
    float rayHitDepthDifference;
    vec2 coords;

    dir *= 0.5;
    hitPos -= dir;

    for (int i = 0; i < dRefineSteps; i++) {
        coords = viewSpaceToScreenSpace(hitPos);
        float depth = getDepth(coords);
        float z = getViewZ(depth);
        rayHitDepthDifference = z - hitPos.z;

        dir *= 0.5;
        if (rayHitDepthDifference >= 0.0) {
            hitPos -= dir;
        } else {
            hitPos += dir;
        }
    }

    coords = viewSpaceToScreenSpace(hitPos);

    return coords;
}

float calculateGrowthFactor(float begin, float end, float steps) {
    return pow(end / begin, 1.0 / steps);
}

vec2 rayMarch(in vec3 dir, in float thickness, inout vec3 hitPos, out bool missed) {
    float rayHitDepthDifference;
    vec2 coords;

    float begin = float(dFirstStepSize);
    dir *= begin;
    missed = false;
    float gf = calculateGrowthFactor(begin, uRayDistance, float(dSteps));

    for (int i = 1; i < dSteps; i++) {
        hitPos += dir;
        dir *= gf;

        coords = viewSpaceToScreenSpace(hitPos);
        float depth = getDepth(coords);
        float z = getViewZ(depth);
        rayHitDepthDifference = z - hitPos.z;

        if (thickness == 0.0) {
            #ifdef dThicknessMode_auto
                thickness = max(uMinThickness, (getViewZ(getThickness(coords)) - z) * uThicknessFactor * texture2D(tColor, coords).a);
            #else
                thickness = uThickness;
            #endif
        }

        if (rayHitDepthDifference >= 0.0 && rayHitDepthDifference < thickness) {
            if (dRefineSteps == 0) {
                return coords;
            } else {
                return binarySearch(dir, hitPos);
            }
        }
    }

    missed = true;

    return coords;
}

//

void trace(in vec3 rayPos, in vec3 rayDir, inout RayHitInfo hitInfo) {
    vec3 hitPos = vec3(rayPos);
    bool missed;
    vec2 coords;
    coords = rayMarch(rayDir, 0.0, hitPos, missed);

    hitInfo.missed = missed;
    hitInfo.position = hitPos;
    hitInfo.normal = -texture2D(tNormal, coords).rgb;
    hitInfo.color = texture2D(tColor, coords).rgb;
    hitInfo.emissive = texture2D(tColor, coords).rgb * texture2D(tNormal, coords).a * 2.0;

    float depth = getDepth(coords);
    if (isBackground(depth)) {
        hitInfo.emissive = vec3(0.0);
    }
}

vec3 viewPos;

vec3 colorForRay(in vec3 startRayPos, in vec3 startRayDir, inout StateType rngState) {
    vec3 ret = vec3(0.0, 0.0, 0.0);

    vec3 throughput = vec3(1.0, 1.0, 1.0);
    vec3 rayPos = startRayPos;
    vec3 rayDir = startRayDir;

    RayHitInfo hitInfo;
    RayHitInfo prevHitInfo;

    for (int bounceIndex = 0; bounceIndex <= dBounces; ++bounceIndex) {
        // shoot a ray out into the world
        if (bounceIndex == 0) {
            vec2 coords = gl_FragCoord.xy / uTexSize;
            float depth = getDepth(coords);

            hitInfo.missed = false;
            hitInfo.position = screenSpaceToViewSpace(vec3(coords, depth), uInvProjection);
            hitInfo.normal = -texture2D(tNormal, coords).rgb;
            hitInfo.color = texture2D(tShaded, coords).rgb;
            hitInfo.emissive = texture2D(tColor, coords).rgb * texture2D(tNormal, coords).a;

            // shadow
            #ifdef dShadowEnable
                #if dLightCount != 0
                    vec3 directLight = vec3(uAmbientColor);
                    #pragma unroll_loop_start
                    bool missed;
                    vec3 hitPos;
                    for (int i = 0; i < dLightCount; ++i) {
                        missed = false;
                        hitPos = viewPos + hitInfo.normal * RayPosNormalNudge;
                        hitPos += -uLightDirection[i] * (randomFloat(rngState));
                        rayMarch(-uLightDirection[i] + randomUnitVector(rngState) * uShadowSoftness, uShadowThickness, hitPos, missed);
                        if (missed) directLight += uLightColor[i];
                    }
                    #pragma unroll_loop_end
                    hitInfo.color *= directLight / uLightStrength;
                #endif
            #endif

            if (hitInfo.normal == vec3(0.0)) {
                hitInfo.missed = true;
            }
        } else {
            prevHitInfo = hitInfo;
            trace(rayPos, rayDir, hitInfo);
        }

        // if the ray missed, we are done
        if (hitInfo.missed) {
            vec3 accIrradiance = vec3(1.0);
            #ifdef dGlow
                if (bounceIndex > 1) {
                    accIrradiance = uLightStrength;
                }
            #else
                if (bounceIndex > 1) {
                    accIrradiance = uAmbientColor;
                    #if dLightCount != 0
                        #pragma unroll_loop_start
                        float dotNL;
                        vec3 irradiance;
                        for (int i = 0; i < dLightCount; ++i) {
                            dotNL = saturate(dot(prevHitInfo.normal, -uLightDirection[i]));
                            irradiance = dotNL * uLightColor[i];
                            accIrradiance += irradiance;
                        }
                        #pragma unroll_loop_end
                    #endif
                }
            #endif
            ret += prevHitInfo.color * accIrradiance * throughput;
            break;
        }

        // add emissive light
        ret += hitInfo.emissive * throughput;

        // update the ray position
        rayPos = hitInfo.position + hitInfo.normal * RayPosNormalNudge;

        // new ray direction from normal oriented cosine weighted hemisphere sample
        rayDir = normalize(hitInfo.normal + randomUnitVector(rngState));

        if (bounceIndex == 0) {
            continue;
        }

        // update the colorMultiplier.
        throughput *= hitInfo.color;

        // Russian Roulette
        // As the throughput gets smaller, the ray is more likely to get terminated early.
        // Survivors have their value boosted to make up for fewer samples being in the average.
        {
            float p = max(throughput.r, max(throughput.g, throughput.b));
            if (randomFloat(rngState) > p)
                break;

            // Add the energy we 'lose' by randomly terminating paths
            throughput *= 1.0 / p;
        }
    }

    // return pixel color
    return ret;
}

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

    if (isBackground(depth)) {
        gl_FragColor = texture2D(tColor, coords);
        return;
    }

    #if __VERSION__ == 100
        float rngState = 26699.0;
    #else
        // initialize a random number state based on gl_FragCoord and uFrameNo
        uint rngState = uint(uint(gl_FragCoord.x) * 1973u + uint(gl_FragCoord.y) * 9277u + uint(uFrameNo) * 26699u) | 1u;
    #endif

    vec3 cameraPos = vec3(0.0, 0.0, 0.0);
    viewPos = screenSpaceToViewSpace(vec3(coords, depth), uInvProjection);
    vec3 rayDir = normalize(viewPos);

    // raytrace for this pixel
    vec3 color = vec3(0.0, 0.0, 0.0);
    for (int index = 0; index < int(dRendersPerFrame); ++index) {
        color += colorForRay(cameraPos, rayDir, rngState) / float(dRendersPerFrame);
    }

    // average the frames together
    vec4 lastFrameColor = texture2D(tAccumulate, coords);
    float blend = (uFrameNo < 1 || lastFrameColor.a == 0.0) ? 1.0 : 1.0 / (1.0 + (1.0 / lastFrameColor.a));
    color = mix(lastFrameColor.rgb, color, blend);

    // show the result
    gl_FragColor = vec4(color, blend);
}
`;

// node_modules/molstar/lib/mol-gl/shader/illumination/accumulate.frag.js
var Gj0 = `
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;
}
`;

// node_modules/molstar/lib/mol-canvas3d/passes/tracing.js
var Hj0 = {
  rendersPerFrame: j.Interval([1, 16], { min: 1, max: 64, step: 1 }, { description: "Number of rays per pixel each frame. May be adjusted to reach targetFps but will stay within given interval." }),
  targetFps: j.Numeric(30, { min: 0, max: 120, step: 0.1 }, { description: "Target FPS per frame. If observed FPS is lower or higher, some parameters may get adjusted." }),
  steps: j.Numeric(32, { min: 1, max: 1024, step: 1 }),
  firstStepSize: j.Numeric(0.01, { min: 0.001, max: 1, step: 0.001 }),
  refineSteps: j.Numeric(4, { min: 0, max: 8, step: 1 }, { description: "Number of refine steps per ray hit. May be lower to reach targetFps." }),
  rayDistance: j.Numeric(256, { min: 1, max: 8192, step: 1 }, { description: "Maximum distance a ray can travel (in world units)." }),
  thicknessMode: j.Select("auto", j.arrayToOptions(["auto", "fixed"])),
  minThickness: j.Numeric(0.5, { min: 0.1, max: 16, step: 0.1 }, { hideIf: (Z) => Z.thicknessMode === "fixed" }),
  thicknessFactor: j.Numeric(1, { min: 0.1, max: 2, step: 0.05 }, { hideIf: (Z) => Z.thicknessMode === "fixed" }),
  thickness: j.Numeric(4, { min: 0.1, max: 512, step: 0.1 }, { hideIf: (Z) => Z.thicknessMode === "auto" }),
  bounces: j.Numeric(4, { min: 1, max: 32, step: 1 }, { description: "Number of bounces for each ray." }),
  glow: j.Boolean(!0, { description: "Bounced rays always get the full light. This produces a slight glowing effect." }),
  shadowEnable: j.Boolean(!1),
  shadowSoftness: j.Numeric(0.1, { min: 0.01, max: 1, step: 0.01 }),
  shadowThickness: j.Numeric(0.5, { min: 0.1, max: 32, step: 0.1 })
};

class be {
  constructor(Z, J) {
    this.webgl = Z, this.drawPass = J, this.clearAdjustedProps = !0, this.prevTime = 0, this.currTime = 0, this.rendersPerFrame = 1, this.refineSteps = 1, this.steps = 16;
    let { extensions: { drawBuffers: $, colorBufferHalfFloat: X, textureHalfFloat: Y }, resources: Q, isWebGL2: W } = Z, { depthTextureOpaque: K } = J, G = K.getWidth(), H = K.getHeight();
    if (W)
      this.shadedTextureOpaque = Q.texture("image-uint8", "rgba", "ubyte", "nearest"), this.shadedTextureOpaque.define(G, H), this.normalTextureOpaque = X && Y ? Q.texture("image-float16", "rgba", "fp16", "nearest") : Q.texture("image-float32", "rgba", "float", "nearest"), this.normalTextureOpaque.define(G, H), this.colorTextureOpaque = Q.texture("image-uint8", "rgba", "ubyte", "nearest"), this.colorTextureOpaque.define(G, H);
    else
      this.shadedTextureOpaque = Q.texture("image-float32", "rgba", "float", "nearest"), this.shadedTextureOpaque.define(G, H), this.normalTextureOpaque = Q.texture("image-float32", "rgba", "float", "nearest"), this.normalTextureOpaque.define(G, H), this.colorTextureOpaque = Q.texture("image-float32", "rgba", "float", "nearest"), this.colorTextureOpaque.define(G, H);
    this.framebuffer = Q.framebuffer(), this.framebuffer.bind(), $.drawBuffers([
      $.COLOR_ATTACHMENT0,
      $.COLOR_ATTACHMENT1,
      $.COLOR_ATTACHMENT2
    ]), this.shadedTextureOpaque.attachFramebuffer(this.framebuffer, "color0"), this.normalTextureOpaque.attachFramebuffer(this.framebuffer, "color1"), this.colorTextureOpaque.attachFramebuffer(this.framebuffer, "color2"), this.thicknessTarget = Z.createRenderTarget(G, H, !0, "uint8", "nearest"), this.holdTarget = Z.createRenderTarget(G, H, !1, "float32"), this.accumulateTarget = Z.createRenderTarget(G, H, !1, "float32"), this.composeTarget = Z.createRenderTarget(G, H, !1, "uint8", "linear"), this.traceRenderable = NF1(Z, this.colorTextureOpaque, this.normalTextureOpaque, this.shadedTextureOpaque, this.thicknessTarget.texture, this.accumulateTarget.texture, this.drawPass.depthTextureOpaque), this.accumulateRenderable = UF1(Z, this.holdTarget.texture);
  }
  getByteCount() {
    return this.thicknessTarget.getByteCount() + this.holdTarget.getByteCount() + this.accumulateTarget.getByteCount() + this.composeTarget.getByteCount() + this.colorTextureOpaque.getByteCount() + this.normalTextureOpaque.getByteCount() + this.shadedTextureOpaque.getByteCount();
  }
  renderInput(Z, J, $, X) {
    if (K1)
      this.webgl.timer.mark("TracePass.renderInput");
    let { gl: Y, state: Q } = this.webgl;
    if (this.framebuffer.bind(), this.drawPass.depthTextureOpaque.attachFramebuffer(this.framebuffer, "depth"), Z.clear(!0), Z.renderTracing($.primitives, J), X.thicknessMode === "auto")
      this.thicknessTarget.bind(), Q.clearColor(0, 0, 0, 0), Y.clear(Y.COLOR_BUFFER_BIT | Y.DEPTH_BUFFER_BIT), Z.renderDepthOpaqueBack($.primitives, J);
    if (K1)
      this.webgl.timer.markEnd("TracePass.renderInput");
  }
  setSize(Z, J) {
    let $ = this.composeTarget.getWidth(), X = this.composeTarget.getHeight();
    if (Z !== $ || J !== X)
      this.thicknessTarget.setSize(Z, J), this.holdTarget.setSize(Z, J), this.accumulateTarget.setSize(Z, J), this.composeTarget.setSize(Z, J), this.colorTextureOpaque.define(Z, J), this.normalTextureOpaque.define(Z, J), this.shadedTextureOpaque.define(Z, J), C.update(this.traceRenderable.values.uTexSize, h0.set(this.traceRenderable.values.uTexSize.ref.value, Z, J)), C.update(this.accumulateRenderable.values.uTexSize, h0.set(this.accumulateRenderable.values.uTexSize.ref.value, Z, J));
  }
  reset() {
    let { drawBuffers: Z } = this.webgl.extensions;
    this.framebuffer.bind(), Z.drawBuffers([
      Z.COLOR_ATTACHMENT0,
      Z.COLOR_ATTACHMENT1,
      Z.COLOR_ATTACHMENT2
    ]), this.shadedTextureOpaque.attachFramebuffer(this.framebuffer, "color0"), this.normalTextureOpaque.attachFramebuffer(this.framebuffer, "color1"), this.colorTextureOpaque.attachFramebuffer(this.framebuffer, "color2"), this.restart(!0);
  }
  restart(Z = !1) {
    let { gl: J, state: $ } = this.webgl;
    if (this.accumulateTarget.bind(), $.clearColor(0, 0, 0, 0), J.clear(J.COLOR_BUFFER_BIT), this.composeTarget.bind(), $.clearColor(0, 0, 0, 0), J.clear(J.COLOR_BUFFER_BIT), Z)
      this.prevTime = 0, this.currTime = 0, this.clearAdjustedProps = !0;
  }
  increaseAdjustedProps(Z) {
    if (this.steps += 1, this.steps > Z.steps)
      this.refineSteps += 1;
    if (this.refineSteps > Z.refineSteps)
      this.rendersPerFrame += 1;
  }
  decreaseAdjustedProps(Z) {
    let J = Math.min(1, Z.refineSteps);
    if (this.rendersPerFrame -= 1, this.rendersPerFrame < 1)
      this.refineSteps -= 1;
    if (this.refineSteps < J)
      this.steps -= 1;
  }
  getAdjustedProps(Z, J) {
    this.currTime = m6();
    let $ = Math.min(1, Z.refineSteps), X = Math.round(Z.steps / 2);
    if (this.clearAdjustedProps)
      this.rendersPerFrame = Z.rendersPerFrame[0], this.refineSteps = $, this.steps = X, this.clearAdjustedProps = !1;
    if (J > 0) {
      let Y = 1000 / Z.targetFps, Q = this.currTime - this.prevTime, W = Math.round(Q / Y);
      if (W >= 2)
        while (W > 0)
          this.decreaseAdjustedProps(Z), W -= 1;
      else if (Q < Y)
        this.increaseAdjustedProps(Z);
      else if (Q > Y + 0.5)
        this.decreaseAdjustedProps(Z);
    }
    return this.prevTime = this.currTime, this.rendersPerFrame = x8(this.rendersPerFrame, Z.rendersPerFrame[0], Z.rendersPerFrame[1]), this.refineSteps = x8(this.refineSteps, $, Z.refineSteps), this.steps = x8(this.steps, X, Z.steps), {
      rendersPerFrame: J === 0 ? Math.ceil(this.rendersPerFrame / 2) : this.rendersPerFrame,
      refineSteps: J === 0 ? $ : this.refineSteps,
      steps: J === 0 ? X : this.steps
    };
  }
  render(Z, J, $, X, Y) {
    let { rendersPerFrame: Q, refineSteps: W, steps: K } = this.getAdjustedProps($, X);
    if (K1)
      this.webgl.timer.mark("TracePass.render", {
        note: `${Q} rendersPerFrame, ${W} refineSteps, ${K} steps`
      });
    let { renderer: G, camera: H, scene: N } = Z, { gl: q, state: U } = this.webgl, { x: F, y: E, width: R, height: z } = H.viewport;
    if (X === 0 || Y)
      G.setTransparentBackground(J), G.setDrawingBufferSize(this.composeTarget.getWidth(), this.composeTarget.getHeight()), G.setPixelRatio(this.webgl.pixelRatio), G.setViewport(F, E, R, z), G.update(H, N), this.renderInput(G, H, N, $);
    U.disable(q.BLEND), U.disable(q.DEPTH_TEST), U.disable(q.CULL_FACE), U.depthMask(!1), U.viewport(F, E, R, z), U.scissor(F, E, R, z);
    let D = e.identity();
    e.invert(D, H.projection);
    let A = H.state.mode === "orthographic" ? 1 : 0, [B, T] = this.traceRenderable.values.uTexSize.ref.value, w = H.viewport, V = M();
    M.scale(V, i0.toArrayNormalized(G.props.ambientColor, V, 0), G.props.ambientIntensity);
    let P = M.clone(V);
    for (let S = 0, f = G.light.count;S < f; ++S) {
      let v = M.fromArray(M(), G.light.color, S * 3);
      M.add(P, P, v);
    }
    this.holdTarget.bind();
    let I = !1;
    if (C.update(this.traceRenderable.values.uFrameNo, X), this.traceRenderable.values.dRendersPerFrame.ref.value !== Q)
      C.update(this.traceRenderable.values.dRendersPerFrame, Q), I = !0;
    if (C.update(this.traceRenderable.values.uProjection, H.projection), C.update(this.traceRenderable.values.uInvProjection, D), E2.set(this.traceRenderable.values.uBounds.ref.value, w.x / B, w.y / T, (w.x + w.width) / B, (w.y + w.height) / T), C.update(this.traceRenderable.values.uBounds, this.traceRenderable.values.uBounds.ref.value), C.updateIfChanged(this.traceRenderable.values.uNear, H.near), C.updateIfChanged(this.traceRenderable.values.uFar, H.far), C.updateIfChanged(this.traceRenderable.values.uFogFar, H.fogFar), C.updateIfChanged(this.traceRenderable.values.uFogNear, H.fogNear), C.update(this.traceRenderable.values.uFogColor, i0.toVec3Normalized(this.traceRenderable.values.uFogColor.ref.value, G.props.backgroundColor)), this.traceRenderable.values.dOrthographic.ref.value !== A)
      C.update(this.traceRenderable.values.dOrthographic, A), I = !0;
    if (C.update(this.traceRenderable.values.uLightDirection, G.light.direction), C.update(this.traceRenderable.values.uLightColor, G.light.color), this.traceRenderable.values.dLightCount.ref.value !== G.light.count)
      C.update(this.traceRenderable.values.dLightCount, G.light.count), I = !0;
    if (C.update(this.traceRenderable.values.uAmbientColor, V), C.update(this.traceRenderable.values.uLightStrength, P), this.traceRenderable.values.dGlow.ref.value !== $.glow)
      C.update(this.traceRenderable.values.dGlow, $.glow), I = !0;
    if (this.traceRenderable.values.dBounces.ref.value !== $.bounces)
      C.update(this.traceRenderable.values.dBounces, $.bounces), I = !0;
    if (this.traceRenderable.values.dSteps.ref.value !== K)
      C.update(this.traceRenderable.values.dSteps, K), I = !0;
    if (this.traceRenderable.values.dFirstStepSize.ref.value !== $.firstStepSize)
      C.update(this.traceRenderable.values.dFirstStepSize, $.firstStepSize), I = !0;
    if (this.traceRenderable.values.dRefineSteps.ref.value !== W)
      C.update(this.traceRenderable.values.dRefineSteps, W), I = !0;
    if (C.updateIfChanged(this.traceRenderable.values.uRayDistance, $.rayDistance), this.traceRenderable.values.dThicknessMode.ref.value !== $.thicknessMode)
      C.update(this.traceRenderable.values.dThicknessMode, $.thicknessMode), I = !0;
    if (C.updateIfChanged(this.traceRenderable.values.uMinThickness, $.minThickness), C.updateIfChanged(this.traceRenderable.values.uThicknessFactor, $.thicknessFactor), C.updateIfChanged(this.traceRenderable.values.uThickness, $.thickness), this.traceRenderable.values.dShadowEnable.ref.value !== $.shadowEnable)
      C.update(this.traceRenderable.values.dShadowEnable, $.shadowEnable), I = !0;
    if (C.updateIfChanged(this.traceRenderable.values.uShadowSoftness, $.shadowSoftness), C.updateIfChanged(this.traceRenderable.values.uShadowThickness, $.shadowThickness), I)
      this.traceRenderable.update();
    if (K1)
      this.webgl.timer.mark("TracePass.renderTrace");
    if (this.traceRenderable.render(), K1)
      this.webgl.timer.markEnd("TracePass.renderTrace");
    if (this.accumulateTarget.bind(), this.accumulateRenderable.render(), K1)
      this.webgl.timer.markEnd("TracePass.render");
  }
}
var GF1 = {
  ...A6,
  tColor: o1("texture", "rgba", "ubyte", "nearest"),
  tNormal: o1("texture", "rgba", "ubyte", "nearest"),
  tShaded: o1("texture", "rgba", "ubyte", "nearest"),
  tThickness: o1("texture", "rgba", "ubyte", "nearest"),
  tAccumulate: o1("texture", "rgba", "ubyte", "nearest"),
  tDepth: o1("texture", "rgba", "ubyte", "nearest"),
  uTexSize: _0("v2"),
  dOrthographic: p1("number"),
  uNear: _0("f"),
  uFar: _0("f"),
  uFogNear: _0("f"),
  uFogFar: _0("f"),
  uFogColor: _0("v3"),
  uProjection: _0("m4"),
  uInvProjection: _0("m4"),
  uBounds: _0("v4"),
  uLightDirection: _0("v3[]"),
  uLightColor: _0("v3[]"),
  dLightCount: p1("number"),
  uAmbientColor: _0("v3"),
  uLightStrength: _0("v3"),
  uFrameNo: _0("i"),
  dRendersPerFrame: p1("number"),
  dGlow: p1("boolean"),
  dBounces: p1("number"),
  dSteps: p1("number"),
  dFirstStepSize: p1("number"),
  dRefineSteps: p1("number"),
  uRayDistance: _0("f"),
  dThicknessMode: p1("string"),
  uMinThickness: _0("f"),
  uThicknessFactor: _0("f"),
  uThickness: _0("f"),
  dShadowEnable: p1("boolean"),
  uShadowSoftness: _0("f"),
  uShadowThickness: _0("f")
}, HF1 = v8("trace", p6, Kj0);
function NF1(Z, J, $, X, Y, Q, W) {
  let K = {
    ...B6,
    tColor: C.create(J),
    tNormal: C.create($),
    tShaded: C.create(X),
    tThickness: C.create(Y),
    tAccumulate: C.create(Q),
    tDepth: C.create(W),
    uTexSize: C.create(h0.create(J.getWidth(), J.getHeight())),
    dOrthographic: C.create(0),
    uNear: C.create(1),
    uFar: C.create(1e4),
    uFogNear: C.create(1e4),
    uFogFar: C.create(1e4),
    uFogColor: C.create(M.create(1, 1, 1)),
    uProjection: C.create(e.identity()),
    uInvProjection: C.create(e.identity()),
    uBounds: C.create(E2()),
    uLightDirection: C.create([]),
    uLightColor: C.create([]),
    dLightCount: C.create(0),
    uAmbientColor: C.create(M()),
    uLightStrength: C.create(M.create(1, 1, 1)),
    uFrameNo: C.create(0),
    dRendersPerFrame: C.create(1),
    dGlow: C.create(!0),
    dBounces: C.create(4),
    dSteps: C.create(32),
    dFirstStepSize: C.create(0.01),
    dRefineSteps: C.create(4),
    uRayDistance: C.create(256),
    dThicknessMode: C.create("auto"),
    uMinThickness: C.create(0.5),
    uThicknessFactor: C.create(1),
    uThickness: C.create(4),
    dShadowEnable: C.create(!1),
    uShadowSoftness: C.create(0.1),
    uShadowThickness: C.create(0.1)
  }, G = { ...GF1 }, H = t8(Z, "triangles", HF1, G, K);
  return e8(H, K);
}
var qF1 = {
  ...A6,
  tColor: o1("texture", "rgba", "ubyte", "nearest"),
  uTexSize: _0("v2"),
  uWeight: _0("f")
}, FF1 = v8("accumulate", p6, Gj0);
function UF1(Z, J) {
  let $ = {
    ...B6,
    tColor: C.create(J),
    uTexSize: C.create(h0.create(J.getWidth(), J.getHeight())),
    uWeight: C.create(1)
  }, X = { ...qF1 }, Y = t8(Z, "triangles", FF1, X, $);
  return e8(Y, $);
}

// node_modules/molstar/lib/mol-canvas3d/passes/illumination.js
var Nj0 = !1;
function qj0(Z) {
  let { drawBuffers: J, textureFloat: $, colorBufferFloat: X, depthTexture: Y } = Z.extensions;
  if (!$ || !X || !Y || !J) {
    if (y2 && !Nj0) {
      let Q = [];
      if (!$)
        Q.push("textureFloat");
      if (!X)
        Q.push("colorBufferFloat");
      if (!Y)
        Q.push("depthTexture");
      if (!J)
        Q.push("drawBuffers");
      console.log(`Missing "${Q.join('", "')}" extensions required for "illumination"`), Nj0 = !0;
    }
    return !1;
  } else
    return !0;
}
var Dx = {
  enabled: j.Boolean(!1),
  maxIterations: j.Numeric(5, { min: 0, max: 16, step: 1 }, { description: "Maximum number of tracing iterations. Final iteration count is 2^x." }),
  denoise: j.Boolean(!0),
  denoiseThreshold: j.Interval([0.15, 1], { min: 0, max: 4, step: 0.01 }, { description: "Threshold for denoising. Automatically adjusted within given interval based on current iteration." }),
  ignoreOutline: j.Boolean(!0, { description: "Ignore outline in illumination pass where it is generally not needed for visual clarity. Useful when illumination is often toggled on/off." }),
  ...Hj0
};

class OU {
  get iteration() {
    return this._iteration;
  }
  get colorTarget() {
    return this._colorTarget;
  }
  get supported() {
    return this._supported;
  }
  getByteCount() {
    if (!this._supported)
      return 0;
    return this.tracing.getByteCount() + this.transparentTarget.getByteCount() + this.outputTarget.getByteCount() + this.multiSampleComposeTarget.getByteCount() + this.multiSampleHoldTarget.getByteCount() + this.multiSampleAccumulateTarget.getByteCount();
  }
  getMaxIterations(Z) {
    return Math.pow(2, Z.maxIterations);
  }
  static isSupported(Z) {
    return qj0(Z);
  }
  static isEnabled(Z, J) {
    return J.enabled && qj0(Z);
  }
  constructor(Z, J) {
    if (this.webgl = Z, this.drawPass = J, this._iteration = 0, this._supported = !1, this.prevSampleIndex = -1, !OU.isSupported(Z))
      return;
    let { colorTarget: $ } = J, X = $.getWidth(), Y = $.getHeight();
    this.tracing = new be(Z, this.drawPass), this.transparentTarget = Z.createRenderTarget(X, Y, !1, "uint8", "nearest"), this.outputTarget = Z.createRenderTarget(X, Y, !1, "uint8", "linear"), this.copyRenderable = T5(Z, this.transparentTarget.texture), this.composeRenderable = EF1(Z, this.tracing.accumulateTarget.texture, this.tracing.normalTextureOpaque, this.tracing.colorTextureOpaque, this.drawPass.depthTextureOpaque, this.drawPass.depthTargetTransparent.texture, this.drawPass.postprocessing.outline.target.texture, this.transparentTarget.texture, this.drawPass.postprocessing.ssao.ssaoDepthTexture, this.drawPass.postprocessing.ssao.ssaoDepthTransparentTexture, !1), this.multiSampleComposeTarget = Z.createRenderTarget(X, Y, !1, "float32"), this.multiSampleHoldTarget = Z.createRenderTarget(X, Y, !1), this.multiSampleAccumulateTarget = Z.createRenderTarget(X, Y, !1, "float32"), this.multiSampleCompose = DF1(Z, this.outputTarget.texture), this._supported = !0;
  }
  renderInput(Z, J, $, X) {
    if (K1)
      this.webgl.timer.mark("IlluminationPass.renderInput");
    let { gl: Y, state: Q } = this.webgl, W = EU.isEnabled(X.marking), K = $.opacityAverage < 1 || $.volumes.renderables.length > 0, G = W && $.markerAverage > 0;
    this.transparentTarget.bind(), Q.clearColor(0, 0, 0, 0), Y.clear(Y.COLOR_BUFFER_BIT);
    let H = bJ.isTransparentOutlineEnabled(X.postprocessing) && !X.illumination.ignoreOutline, N = jH.isEnabled(X.postprocessing), q = bJ.isTransparentSsaoEnabled($, X.postprocessing);
    if (H || N || q)
      this.drawPass.depthTargetTransparent.bind(), Z.clearDepth(!0);
    if (K) {
      if (this.drawPass.transparency === "wboit") {
        if (this.drawPass.wboit.bind(), Z.renderWboitTransparent($.primitives, J, this.drawPass.depthTextureOpaque), $.volumes.renderables.length > 0)
          Z.renderWboitTransparent($.volumes, J, this.drawPass.depthTextureOpaque);
        this.transparentTarget.bind(), this.drawPass.wboit.render();
      } else if (this.drawPass.transparency === "dpoit") {
        let U = this.drawPass.dpoit.bind();
        Z.renderDpoitTransparent($.primitives, J, this.drawPass.depthTextureOpaque, U);
        for (let F = 0, E = X.dpoitIterations;F < E; F++) {
          if (K1)
            this.webgl.timer.mark("DpoitPass.layer");
          let R = this.drawPass.dpoit.bindDualDepthPeeling();
          if (Z.renderDpoitTransparent($.primitives, J, this.drawPass.depthTextureOpaque, R), E > 1)
            this.transparentTarget.bind(), this.drawPass.dpoit.renderBlendBack();
          if (K1)
            this.webgl.timer.markEnd("DpoitPass.layer");
        }
        if (this.transparentTarget.bind(), this.drawPass.dpoit.render(), $.volumes.renderables.length > 0)
          Z.renderVolume($.volumes, J, this.drawPass.depthTextureOpaque);
      } else if (this.transparentTarget.bind(), this.drawPass.depthTextureOpaque.attachFramebuffer(this.transparentTarget.framebuffer, "depth"), Z.renderBlendedTransparent($.primitives, J), this.drawPass.depthTextureOpaque.detachFramebuffer(this.transparentTarget.framebuffer, "depth"), $.volumes.renderables.length > 0)
        Z.renderVolume($.volumes, J, this.drawPass.depthTextureOpaque);
      if (H || N || q) {
        if (this.drawPass.depthTargetTransparent.bind(), $.opacityAverage < 1)
          Z.renderDepthTransparent($.primitives, J, this.drawPass.depthTextureOpaque);
      }
      if (q)
        this.drawPass.postprocessing.ssao.update(J, $, X.postprocessing.occlusion.params, !0), this.drawPass.postprocessing.ssao.render(J);
    }
    if (G) {
      let U = X.marking.ghostEdgeStrength < 1;
      if (U && $.markerAverage !== 1)
        this.drawPass.marking.depthTarget.bind(), Z.clear(!1, !0), Z.renderMarkingDepth($.primitives, J);
      this.drawPass.marking.maskTarget.bind(), Z.clear(!1, !0), Z.renderMarkingMask($.primitives, J, U ? this.drawPass.marking.depthTarget.texture : null), this.drawPass.marking.update(X.marking), this.drawPass.marking.render(J.viewport, this.transparentTarget);
    }
    if (this.tracing.composeTarget.bind(), Q.clearColor(0, 0, 0, 0), Y.clear(Y.COLOR_BUFFER_BIT), K1)
      this.webgl.timer.markEnd("IlluminationPass.renderInput");
  }
  shouldRender(Z) {
    return this._supported && Z.enabled && this._iteration < this.getMaxIterations(Z);
  }
  setSize(Z, J) {
    if (!this._supported)
      return;
    let $ = this.outputTarget.getWidth(), X = this.outputTarget.getHeight();
    if (Z !== $ || J !== X)
      this.tracing.setSize(Z, J), this.transparentTarget.setSize(Z, J), this.outputTarget.setSize(Z, J), C.update(this.copyRenderable.values.uTexSize, h0.set(this.copyRenderable.values.uTexSize.ref.value, Z, J)), C.update(this.composeRenderable.values.uTexSize, h0.set(this.composeRenderable.values.uTexSize.ref.value, Z, J)), this.multiSampleComposeTarget.setSize(Z, J), this.multiSampleHoldTarget.setSize(Z, J), this.multiSampleAccumulateTarget.setSize(Z, J), C.update(this.multiSampleCompose.values.uTexSize, h0.set(this.multiSampleCompose.values.uTexSize.ref.value, Z, J));
    this.drawPass.setSize(Z, J);
  }
  reset() {
    if (!this._supported)
      return;
    this.tracing.reset(), this._iteration = 0, this.prevSampleIndex = -1;
  }
  restart(Z = !1) {
    if (!this._supported)
      return;
    this.tracing.restart(Z), this._iteration = 0, this.prevSampleIndex = -1;
  }
  renderInternal(Z, J, $, X) {
    if (!this.shouldRender(J.illumination))
      return;
    if (K1)
      this.webgl.timer.mark("IlluminationPass.render", {
        note: `iteration ${this._iteration + 1} of ${this.getMaxIterations(J.illumination)}`
      });
    this.tracing.render(Z, J.transparentBackground, J.illumination, this._iteration, X);
    let { renderer: Y, camera: Q, scene: W, helper: K } = Z, { gl: G, state: H } = this.webgl, { x: N, y: q, width: U, height: F } = Q.viewport;
    if (this._iteration === 0 || X)
      Y.setTransparentBackground(J.transparentBackground), Y.setDrawingBufferSize(this.tracing.composeTarget.getWidth(), this.tracing.composeTarget.getHeight()), Y.setPixelRatio(this.webgl.pixelRatio), Y.setViewport(N, q, U, F), Y.update(Q, W), this.renderInput(Y, Q, W, J);
    H.disable(G.BLEND), H.disable(G.DEPTH_TEST), H.disable(G.CULL_FACE), H.depthMask(!1), H.viewport(N, q, U, F), H.scissor(N, q, U, F);
    let E = Q.state.mode === "orthographic" ? 1 : 0, R = RU.isEnabled(J.postprocessing), z = LU.isEnabled(J.postprocessing) && !J.illumination.ignoreOutline, D = bJ.isTransparentSsaoEnabled(W, J.postprocessing), A = tR.isEnabled(J.postprocessing), B = jH.isEnabled(J.postprocessing), T = EU.isEnabled(J.marking), w = W.opacityAverage < 1 || W.volumes.renderables.length > 0, V = T && W.markerAverage > 0, P = !1;
    if (this.composeRenderable.values.dOutlineEnable.ref.value !== z)
      P = !0, C.update(this.composeRenderable.values.dOutlineEnable, z);
    if (z && J.postprocessing.outline.name === "on") {
      let { transparentOutline: x, outlineScale: b } = this.drawPass.postprocessing.outline.update(Q, J.postprocessing.outline.params, this.drawPass.depthTargetTransparent.texture, this.drawPass.depthTextureOpaque);
      if (this.drawPass.postprocessing.outline.render(), C.update(this.composeRenderable.values.uOutlineColor, i0.toVec3Normalized(this.composeRenderable.values.uOutlineColor.ref.value, J.postprocessing.outline.params.color)), this.composeRenderable.values.dOutlineScale.ref.value !== b)
        P = !0, C.update(this.composeRenderable.values.dOutlineScale, b);
      if (this.composeRenderable.values.dTransparentOutline.ref.value !== x)
        P = !0, C.update(this.composeRenderable.values.dTransparentOutline, x);
    }
    if (this.composeRenderable.values.dOcclusionEnable.ref.value !== D)
      P = !0, C.update(this.composeRenderable.values.dOcclusionEnable, D);
    if (D && J.postprocessing.occlusion.name === "on")
      C.update(this.composeRenderable.values.uOcclusionColor, i0.toVec3Normalized(this.composeRenderable.values.uOcclusionColor.ref.value, J.postprocessing.occlusion.params.color));
    let I = w || V;
    if (this.composeRenderable.values.dBlendTransparency.ref.value !== I)
      P = !0, C.update(this.composeRenderable.values.dBlendTransparency, I);
    if (C.updateIfChanged(this.composeRenderable.values.uNear, Q.near), C.updateIfChanged(this.composeRenderable.values.uFar, Q.far), C.updateIfChanged(this.composeRenderable.values.uFogFar, Q.fogFar), C.updateIfChanged(this.composeRenderable.values.uFogNear, Q.fogNear), C.update(this.composeRenderable.values.uFogColor, i0.toVec3Normalized(this.composeRenderable.values.uFogColor.ref.value, Y.props.backgroundColor)), this.composeRenderable.values.dOrthographic.ref.value !== E)
      C.update(this.composeRenderable.values.dOrthographic, E), P = !0;
    if ($ && !R && !B)
      this.webgl.bindDrawingBuffer();
    else
      this.tracing.composeTarget.bind();
    if (this._colorTarget = this.tracing.composeTarget, this.drawPass.postprocessing.background.update(Q, J.postprocessing.background), this.drawPass.postprocessing.background.clear(J.postprocessing.background, J.transparentBackground, Y.props.backgroundColor), this.drawPass.postprocessing.background.render(J.postprocessing.background), C.updateIfChanged(this.composeRenderable.values.uTransparentBackground, J.transparentBackground || this.drawPass.postprocessing.background.isEnabled(J.postprocessing)), this.composeRenderable.values.dDenoise.ref.value !== J.illumination.denoise)
      C.update(this.composeRenderable.values.dDenoise, J.illumination.denoise), P = !0;
    let f = J.multiSample.mode === "on" ? J.illumination.denoiseThreshold[0] : pZ(J.illumination.denoiseThreshold[1], J.illumination.denoiseThreshold[0], x8(this.iteration / (this.getMaxIterations(J.illumination) / 2), 0, 1));
    if (C.updateIfChanged(this.composeRenderable.values.uDenoiseThreshold, f), P)
      this.composeRenderable.update();
    if (this.composeRenderable.render(), Y.setDrawingBufferSize(this.tracing.composeTarget.getWidth(), this.tracing.composeTarget.getHeight()), Y.setPixelRatio(this.webgl.pixelRatio), Y.setViewport(N, q, U, F), Y.update(Q, W), K.debug.isEnabled)
      K.debug.syncVisibility(), Y.renderBlended(K.debug.scene, Q);
    if (K.handle.isEnabled)
      Y.renderBlended(K.handle.scene, Q);
    if (K.camera.isEnabled)
      K.camera.update(Q), Y.update(K.camera.camera, K.camera.scene), Y.renderBlended(K.camera.scene, K.camera.camera);
    let v = !1, h = this.outputTarget;
    if (R) {
      let x = $ && !B;
      if (this.drawPass.antialiasing.render(Q, this.tracing.composeTarget.texture, x ? !0 : this.outputTarget, J.postprocessing), x)
        v = !0;
      else
        this._colorTarget = this.outputTarget, h = this.tracing.composeTarget;
    }
    if (A && J.postprocessing.bloom.name === "on") {
      let x = $ && !B || v;
      this.drawPass.bloom.update(this.tracing.colorTextureOpaque, this.tracing.normalTextureOpaque, this.drawPass.depthTextureOpaque, J.postprocessing.bloom.params), this.drawPass.bloom.render(Q.viewport, x ? void 0 : this._colorTarget);
    }
    if (B && J.postprocessing.dof.name === "on") {
      let x = $ || v;
      if (this.drawPass.dof.update(Q, this._colorTarget.texture, this.drawPass.depthTextureOpaque, this.drawPass.depthTargetTransparent.texture, J.postprocessing.dof.params, W.boundingSphereVisible), this.drawPass.dof.render(Q.viewport, x ? void 0 : h), !x)
        this._colorTarget = h;
    }
    if (this._iteration += 1, K1)
      this.webgl.timer.markEnd("IlluminationPass.render");
    this.webgl.gl.flush();
  }
  renderMultiSample(Z, J, $) {
    let { camera: X } = Z, { multiSampleCompose: Y, multiSampleComposeTarget: Q, multiSampleHoldTarget: W, webgl: K } = this, { gl: G, state: H } = K, N = ZI[Math.max(0, Math.min(J.multiSample.sampleLevel, 5))], q = this.getMaxIterations(J.illumination), U = Math.min(this._iteration, q), F = Math.floor(U / q * N.length);
    if (K1)
      K.timer.mark("IlluminationPass.renderMultiSample", {
        note: `sampleIndex ${F + 1} of ${N.length}`
      });
    let { x: E, y: R, width: z, height: D } = X.viewport, A = 1 / q;
    if (U === 0)
      this.renderInternal(Z, J, !1, !0), C.update(Y.values.uWeight, 1), C.update(Y.values.tColor, this._colorTarget.texture), Y.update(), W.bind(), H.disable(G.BLEND), H.disable(G.DEPTH_TEST), H.depthMask(!1), H.viewport(E, R, z, D), H.scissor(E, R, z, D), Y.render();
    else {
      X.viewOffset.enabled = !0, C.update(Y.values.tColor, this._colorTarget.texture), C.update(Y.values.uWeight, A), Y.update();
      let T = N[F];
      if (O6.setViewOffset(X.viewOffset, z, D, T[0], T[1], z, D), X.update(), this.renderInternal(Z, J, !1, this.prevSampleIndex !== F), Q.bind(), H.enable(G.BLEND), H.blendEquationSeparate(G.FUNC_ADD, G.FUNC_ADD), H.blendFuncSeparate(G.ONE, G.ONE, G.ONE, G.ONE), H.disable(G.DEPTH_TEST), H.depthMask(!1), H.viewport(E, R, z, D), H.scissor(E, R, z, D), U === 1)
        H.clearColor(0, 0, 0, 0), G.clear(G.COLOR_BUFFER_BIT);
      Y.render();
    }
    if (this.prevSampleIndex = F, $)
      this.webgl.bindDrawingBuffer();
    else
      this.multiSampleAccumulateTarget.bind();
    H.viewport(E, R, z, D), H.scissor(E, R, z, D);
    let B = U * A;
    if (B > 0)
      C.update(Y.values.uWeight, 1), C.update(Y.values.tColor, Q.texture), Y.update(), H.disable(G.BLEND), Y.render();
    if (B < 1) {
      if (C.update(Y.values.uWeight, 1 - B), C.update(Y.values.tColor, W.texture), Y.update(), B === 0)
        H.disable(G.BLEND);
      else
        H.enable(G.BLEND);
      Y.render();
    }
    if (!$) {
      if (H.disable(G.BLEND), this.colorTarget.bind(), this.copyRenderable.values.tColor.ref.value !== this.multiSampleAccumulateTarget.texture)
        C.update(this.copyRenderable.values.tColor, this.multiSampleAccumulateTarget.texture), this.copyRenderable.update();
      this.copyRenderable.render();
    }
    if (X.viewOffset.enabled = !1, X.update(), K1)
      K.timer.markEnd("IlluminationPass.renderMultiSample");
  }
  render(Z, J, $) {
    if (!this._supported)
      return;
    if (J.multiSample.mode === "on")
      this.renderMultiSample(Z, J, $);
    else
      this.renderInternal(Z, J, $, !1);
  }
}
var LF1 = {
  ...A6,
  tColor: o1("texture", "rgba", "ubyte", "nearest"),
  tNormal: o1("texture", "rgba", "ubyte", "nearest"),
  tShaded: o1("texture", "rgba", "ubyte", "nearest"),
  tTransparentColor: o1("texture", "rgba", "ubyte", "nearest"),
  dBlendTransparency: p1("boolean"),
  tSsaoDepth: o1("texture", "rgba", "ubyte", "nearest"),
  tSsaoDepthTransparent: o1("texture", "rgba", "ubyte", "nearest"),
  tDepthOpaque: o1("texture", "rgba", "ubyte", "nearest"),
  tDepthTransparent: o1("texture", "rgba", "ubyte", "nearest"),
  tOutlines: o1("texture", "rgba", "ubyte", "nearest"),
  uTexSize: _0("v2"),
  dDenoise: p1("boolean"),
  uDenoiseThreshold: _0("f"),
  dOrthographic: p1("number"),
  uNear: _0("f"),
  uFar: _0("f"),
  uFogNear: _0("f"),
  uFogFar: _0("f"),
  uFogColor: _0("v3"),
  uOutlineColor: _0("v3"),
  uOcclusionColor: _0("v3"),
  uTransparentBackground: _0("b"),
  dOcclusionEnable: p1("boolean"),
  dOutlineEnable: p1("boolean"),
  dOutlineScale: p1("number"),
  dTransparentOutline: p1("boolean")
}, RF1 = v8("compose", p6, Wj0);
function EF1(Z, J, $, X, Y, Q, W, K, G, H, N) {
  let q = {
    ...B6,
    tColor: C.create(J),
    tNormal: C.create($),
    tShaded: C.create(X),
    tTransparentColor: C.create(K),
    dBlendTransparency: C.create(!0),
    tSsaoDepth: C.create(G),
    tSsaoDepthTransparent: C.create(H),
    tDepthOpaque: C.create(Y),
    tDepthTransparent: C.create(Q),
    tOutlines: C.create(W),
    uTexSize: C.create(h0.create(J.getWidth(), J.getHeight())),
    dDenoise: C.create(!0),
    uDenoiseThreshold: C.create(0.1),
    dOrthographic: C.create(0),
    uNear: C.create(1),
    uFar: C.create(1e4),
    uFogNear: C.create(1e4),
    uFogFar: C.create(1e4),
    uFogColor: C.create(M.create(1, 1, 1)),
    uOutlineColor: C.create(M.create(0, 0, 0)),
    uOcclusionColor: C.create(M.create(0, 0, 0)),
    uTransparentBackground: C.create(!1),
    dOcclusionEnable: C.create(!1),
    dOutlineEnable: C.create(!1),
    dOutlineScale: C.create(1),
    dTransparentOutline: C.create(N)
  }, U = { ...LF1 }, F = t8(Z, "triangles", RF1, U, q);
  return e8(F, q);
}
var OF1 = {
  ...A6,
  tColor: o1("texture", "rgba", "ubyte", "nearest"),
  uTexSize: _0("v2"),
  uWeight: _0("f")
}, zF1 = v8("compose", p6, Fx);
function DF1(Z, J) {
  let $ = {
    ...B6,
    tColor: C.create(J),
    uTexSize: C.create(h0.create(J.getWidth(), J.getHeight())),
    uWeight: C.create(1)
  }, X = { ...OF1 }, Y = t8(Z, "triangles", zF1, X, $);
  return e8(Y, $);
}

// node_modules/molstar/lib/mol-canvas3d/helper/shader-manager.js
class eA {
  static ensureRequired(Z, J, $) {
    let X = new eA(Z, J);
    X.updateRequired($), X.finalizeRequired(!0);
  }
  constructor(Z, J) {
    this.webgl = Z, this.scene = J, this.required = [];
  }
  updateRequired(Z) {
    if (this.required.length = 0, this.required.push("color"), OU.isEnabled(this.webgl, Z.illumination))
      this.required.push("tracing");
    if (EU.isEnabled(Z.marking) && this.scene.markerAverage > 0)
      this.required.push("marking");
    if (tR.isEnabled(Z.postprocessing) && this.scene.emissiveAverage > 0)
      this.required.push("emissive");
    if (bJ.isTransparentDepthRequired(this.scene, Z.postprocessing) || !this.webgl.extensions.drawBuffers || !this.webgl.extensions.depthTexture || OU.isEnabled(this.webgl, Z.illumination))
      this.required.push("depth");
    this.webgl.resources.linkPrograms(this.required);
  }
  finalizeRequired(Z) {
    return this.finalize(this.required, Z);
  }
  finalize(Z, J) {
    return this.webgl.resources.finalizePrograms(Z, J);
  }
}

// node_modules/molstar/lib/mol-canvas3d/passes/image.js
var MF1 = {
  transparentBackground: j.Boolean(!1),
  dpoitIterations: j.Numeric(2, { min: 1, max: 10, step: 1 }),
  multiSample: j.Group(Ux),
  postprocessing: j.Group(rA),
  marking: j.Group(Ox),
  illumination: j.Group(Dx),
  cameraHelper: j.Group(ZE),
  renderer: j.Group(aA)
};

class xe {
  get colorTarget() {
    return this._colorTarget;
  }
  get width() {
    return this._width;
  }
  get height() {
    return this._height;
  }
  constructor(Z, J, $, X, Y, Q, W) {
    this.webgl = Z, this.renderer = $, this.scene = X, this.camera = Y, this._width = 0, this._height = 0, this._camera = new O6, this.props = { ...j.getDefaultValues(MF1), ...W }, this.drawPass = new YI(Z, J, 128, 128, X.transparency), this.illuminationPass = new OU(Z, this.drawPass), this.multiSamplePass = new eR(Z, this.drawPass), this.multiSampleHelper = new JI(this.multiSamplePass), this.helper = {
      camera: new QI(Z, this.props.cameraHelper),
      debug: Q.debug,
      handle: Q.handle,
      pointer: Q.pointer
    }, this.setSize(1024, 768);
  }
  getByteCount() {
    return this.drawPass.getByteCount() + this.illuminationPass.getByteCount() + this.multiSamplePass.getByteCount();
  }
  updateBackground() {
    return new Promise((Z) => {
      this.drawPass.postprocessing.background.update(this.camera, this.props.postprocessing.background, () => {
        Z();
      });
    });
  }
  setSize(Z, J) {
    if (Z === this._width && J === this._height)
      return;
    this._width = Z, this._height = J, this.drawPass.setSize(Z, J), this.illuminationPass.setSize(Z, J), this.multiSamplePass.syncSize();
  }
  setProps(Z = {}) {
    if (Object.assign(this.props, Z), Z.cameraHelper)
      this.helper.camera.setProps(Z.cameraHelper);
  }
  async render(Z) {
    this.drawPass.setTransparency(this.scene.transparency), eA.ensureRequired(this.webgl, this.scene, this.props), O6.copySnapshot(this._camera.state, this.camera.state), bZ.set(this._camera.viewport, 0, 0, this._width, this._height), this._camera.update();
    let J = { renderer: this.renderer, camera: this._camera, scene: this.scene, helper: this.helper };
    if (this.illuminationPass.supported && this.props.illumination.enabled) {
      await Z.update({ message: "Tracing...", current: 1, max: this.illuminationPass.getMaxIterations(this.props.illumination) }), this.illuminationPass.restart(!0);
      while (this.illuminationPass.shouldRender(this.props.illumination)) {
        if (K1)
          this.webgl.timer.mark("ImagePass.render", { captureStats: !0 });
        if (this.illuminationPass.render(J, this.props, !1), K1)
          this.webgl.timer.markEnd("ImagePass.render");
        if (Z.shouldUpdate)
          await Z.update({ current: this.illuminationPass.iteration });
        await this.webgl.waitForGpuCommandsComplete();
      }
      this._colorTarget = this.illuminationPass.colorTarget;
    } else {
      if (K1)
        this.webgl.timer.mark("ImagePass.render", { captureStats: !0 });
      if (eR.isEnabled(this.props.multiSample))
        this.multiSampleHelper.render(J, this.props, !1), this._colorTarget = this.multiSamplePass.colorTarget;
      else
        this.drawPass.render(J, this.props, !1), this._colorTarget = this.drawPass.getColorTarget(this.props.postprocessing);
      if (K1)
        this.webgl.timer.markEnd("ImagePass.render");
    }
    if (K1) {
      let $ = this.webgl.timer.resolve();
      if ($)
        for (let X of $)
          qV([X]);
    }
    if (y2)
      console.log(`image pass byte count ${(this.getByteCount() / 1024 / 1024).toFixed(3)} MiB`);
  }
  async getImageData(Z, J, $, X) {
    var Y, Q;
    this.setSize(J, $), await this.render(Z), this.colorTarget.bind();
    let W = (Y = X === null || X === void 0 ? void 0 : X.width) !== null && Y !== void 0 ? Y : J, K = (Q = X === null || X === void 0 ? void 0 : X.height) !== null && Q !== void 0 ? Q : $, G = new Uint8Array(W * K * 4);
    if (!X)
      this.webgl.readPixels(0, 0, W, K, G);
    else
      this.webgl.readPixels(X.x, $ - X.y - X.height, W, K, G);
    let H = tA.create(G, W, K);
    return tA.flipY(H), tA.divideByAlpha(H), new ImageData(new Uint8ClampedArray(G), W, K);
  }
}

// node_modules/molstar/lib/mol-canvas3d/helper/handle-helper.js
var AF1 = {
  ...n1.Params,
  alpha: { ...n1.Params.alpha, defaultValue: 1 },
  ignoreLight: { ...n1.Params.ignoreLight, defaultValue: !0 },
  colorX: j.Color(c2.red, { isEssential: !0 }),
  colorY: j.Color(c2.green, { isEssential: !0 }),
  colorZ: j.Color(c2.blue, { isEssential: !0 }),
  scale: j.Numeric(0.33, { min: 0.1, max: 2, step: 0.1 }, { isEssential: !0 })
}, Mx = {
  handle: j.MappedStatic("off", {
    on: j.Group(AF1),
    off: j.Group({})
  }, { cycle: !0, description: "Show handle tool" })
};

class ye {
  getBoundingSphere(Z, J) {
    if (this.renderObject)
      C0.copy(Z, this.renderObject.values.invariantBoundingSphere.ref.value), e.fromArray(this._transform, this.renderObject.values.aTransform.ref.value, J * 16), C0.transform(Z, Z, this._transform);
    return Z;
  }
  setProps(Z) {
    this.props = WQ(this.props, (J) => {
      if (Z.handle !== void 0) {
        if (J.handle.name = Z.handle.name, Z.handle.name === "on") {
          this.scene.clear(), this.pixelRatio = this.webgl.pixelRatio;
          let $ = {
            ...Z.handle.params,
            scale: Z.handle.params.scale * this.webgl.pixelRatio,
            cellSize: 0
          };
          this.renderObject = TF1($), this.scene.add(this.renderObject), this.scene.commit(), J.handle.params = { ...Z.handle.params };
        }
      }
    });
  }
  get isEnabled() {
    return this.props.handle.name === "on";
  }
  update(Z, J, $) {
    if (!this.renderObject)
      return;
    if (this.pixelRatio !== this.webgl.pixelRatio)
      this.setProps(this.props);
    e.setTranslation(this.renderObject.values.aTransform.ref.value, J), e.fromMat3(this.renderObject.values.aTransform.ref.value, $), C.update(this.renderObject.values.aTransform, this.renderObject.values.aTransform.ref.value), this.scene.update([this.renderObject], !0);
  }
  getLoci(Z) {
    let { objectId: J, groupId: $, instanceId: X } = Z;
    if (!this.renderObject || J !== this.renderObject.id)
      return G8;
    return wF1(this, $, X);
  }
  mark(Z, J) {
    if (!W7.is(W7.Highlighting, J))
      return !1;
    if (!KJ(Z)) {
      if (!Fj0(Z))
        return !1;
      if (Z.data !== this)
        return !1;
    }
    return m8.mark(this.renderObject, Z, J, this.eachGroup);
  }
  constructor(Z, J = {}) {
    this.webgl = Z, this.props = {
      handle: { name: "off", params: {} }
    }, this.pixelRatio = 1, this._transform = e(), this.eachGroup = ($, X) => {
      if (!this.renderObject)
        return !1;
      if (!Fj0($))
        return !1;
      let Y = !1, Q = this.renderObject.values.uGroupCount.ref.value, { elements: W } = $;
      for (let { groupId: K, instanceId: G } of W) {
        let H = G * Q + K;
        if (X(k0.ofSingleton(H)))
          Y = !0;
      }
      return Y;
    }, this.scene = s3.create(Z, "blended"), this.setProps(J);
  }
}
function BF1(Z, J) {
  let $ = v1.createState(512, 256, J), X = 0.05 * Z, Y = M.scale(M(), M.unitX, Z), Q = M.scale(M(), M.unitY, Z), W = M.scale(M(), M.unitZ, Z), K = { radiusTop: X, radiusBottom: X, radialSegments: 32 };
  return $.currentGroup = dz.TranslateScreenXY, g8($, M.origin, X * 3, 2), $.currentGroup = dz.TranslateObjectX, g8($, Y, X, 2), q6($, M.origin, Y, 1, K), $.currentGroup = dz.TranslateObjectY, g8($, Q, X, 2), q6($, M.origin, Q, 1, K), $.currentGroup = dz.TranslateObjectZ, g8($, W, X, 2), q6($, M.origin, W, 1, K), v1.getMesh($);
}
var dz = {
  None: 0,
  TranslateScreenXY: 1,
  TranslateObjectX: 3,
  TranslateObjectY: 4,
  TranslateObjectZ: 5
};
function wF1(Z, J, $) {
  return PR("handle", Z, [{ groupId: J, instanceId: $ }], (X) => Z.getBoundingSphere(X, $), () => `Handle Helper | Group Id ${J} | Instance Id ${$}`);
}
function Fj0(Z) {
  return Z.kind === "data-loci" && Z.tag === "handle";
}
function jF1(Z, J) {
  let $ = 10 * Z.scale, X = BF1($, J === null || J === void 0 ? void 0 : J.geometry);
  X.setBoundingSphere(C0.create(M.create($ / 2, $ / 2, $ / 2), $ + $ / 4));
  let Y = (Q) => {
    switch (Q) {
      case dz.TranslateObjectX:
        return Z.colorX;
      case dz.TranslateObjectY:
        return Z.colorY;
      case dz.TranslateObjectZ:
        return Z.colorZ;
      default:
        return c2.grey;
    }
  };
  return c8.create("handle", {}, X, Y, () => 1, () => "");
}
function TF1(Z) {
  let J = jF1(Z);
  return c8.createRenderObject(J, Z);
}

// node_modules/molstar/lib/mol-canvas3d/helper/pointer-helper.js
var KI = {
  ...n1.Params,
  enabled: j.Select("off", j.arrayToOptions(["on", "off"]), { isEssential: !0 }),
  ignoreLight: { ...n1.Params.ignoreLight, defaultValue: !0 },
  color: j.Color(c2.grey, { isEssential: !0 }),
  hitColor: j.Color(c2.pink, { isEssential: !0 })
};

class me {
  setProps(Z) {
    if (Object.assign(this.props, Z), this.isEnabled)
      this.update(this.pointers, this.points, this.hit);
  }
  ensureEnabled() {
    if (this.props.enabled !== "on")
      this.props.enabled = "on";
  }
  get isEnabled() {
    return this.props.enabled === "on";
  }
  setCamera(Z) {
    O6.copySnapshot(this.camera.state, Z.state), bZ.copy(this.camera.viewport, Z.viewport), e.copy(this.camera.view, Z.view), e.copy(this.camera.projection, Z.projection), e.copy(this.camera.projectionView, Z.projectionView), e.copy(this.camera.headRotation, Z.headRotation), O6.copyViewOffset(this.camera.viewOffset, Z.viewOffset), this.camera.far = Z.far, this.camera.near = Z.near, this.camera.fogFar = Z.fogFar, this.camera.fogNear = Z.fogNear, this.camera.forceFull = Z.forceFull, this.camera.scale = 1, this.modelScale = Z.scale;
  }
  update(Z, J, $) {
    if (this.pointers = Z, this.points = J, this.hit = $, this.props.enabled !== "on") {
      if (this.renderObject)
        this.renderObject.state.visible = !1;
      return;
    }
    this.shape = Uj0(this.getData(), this.props, this.shape), C.updateIfChanged(this.renderObject.values.drawCount, n7.getDrawCount(this.shape.geometry)), C.updateIfChanged(this.renderObject.values.uVertexCount, n7.getVertexCount(this.shape.geometry)), C.updateIfChanged(this.renderObject.values.uGroupCount, 2), n1.Utils.updateBoundingSphere(this.renderObject.values, this.shape.geometry), n1.Utils.updateValues(this.renderObject.values, this.props), n1.Utils.updateRenderableState(this.renderObject.state, this.props), this.renderObject.state.visible = !0, this.scene.update(void 0, !1), this.scene.commit();
  }
  getData() {
    return {
      pointers: this.pointers,
      points: this.points,
      hit: this.hit,
      modelScale: this.modelScale,
      camera: this.camera,
      pixels: 12
    };
  }
  constructor(Z, J = {}) {
    this.pixelScale = 1, this.modelScale = 1, this.pointers = [], this.points = [], this.hit = void 0, this.scene = s3.create(Z, "blended"), this.props = { ...j.getDefaultValues(KI), ...J }, this.camera = new O6, this.shape = Uj0(this.getData(), this.props, this.shape), this.renderObject = IF1(this.shape, this.props), this.scene.add(this.renderObject);
  }
}
var WI;
(function(Z) {
  Z[Z.None = 0] = "None", Z[Z.Hit = 1] = "Hit";
})(WI || (WI = {}));
var _F1 = M();
function ge(Z, J, $, X) {
  let Y = M.scale(_F1, $.state.position, X), Q = M.distance(Z, Y);
  return 2 * Math.tan($.state.fov / 2) * Q / $.viewport.height * J;
}
function VF1(Z, J) {
  let $ = v1.createState(512, 256, J), X = 0.0005, Y = { radiusTop: 0.0005, radiusBottom: 0.0005, radialSegments: 32 }, { modelScale: Q, camera: W, pixels: K } = Z;
  $.currentGroup = WI.None;
  for (let G of Z.pointers) {
    b40($, G, 0.2, Y);
    let H = ge(G.origin, K, W, Q);
    g8($, G.origin, H, 1);
  }
  for (let G of Z.points) {
    let H = ge(G, K, W, Q);
    g8($, G, H, 1);
  }
  if (Z.hit) {
    $.currentGroup = WI.Hit;
    let G = ge(Z.hit, K, W, Q);
    g8($, Z.hit, G, 1);
  }
  return v1.getMesh($);
}
function Uj0(Z, J, $) {
  let X = VF1(Z, $ === null || $ === void 0 ? void 0 : $.geometry), Y = (Q) => {
    switch (Q) {
      case WI.Hit:
        return J.hitColor;
      default:
        return J.color;
    }
  };
  return c8.create("pointer-mesh", Z, X, Y, () => 1, () => "", void 0, 2);
}
function IF1(Z, J) {
  return c8.createRenderObject(Z, {
    ...j.getDefaultValues(n1.Params),
    ...J,
    ignoreLight: J.ignoreLight,
    cellSize: 0
  });
}

// node_modules/molstar/lib/mol-canvas3d/helper/helper.js
var PF1 = {
  debug: j.Group(rV),
  camera: j.Group({
    helper: j.Group(ZE)
  }),
  handle: j.Group(Mx),
  pointer: j.Group(KI)
}, CF1 = j.getDefaultValues(PF1);

class de {
  constructor(Z, J, $ = {}) {
    let X = { ...CF1, ...$ };
    this.debug = new Ae(Z, J, X.debug), this.camera = new QI(Z, X.camera.helper), this.handle = new ye(Z, X.handle), this.pointer = new me(Z, X.pointer);
  }
}

// node_modules/molstar/lib/mol-canvas3d/passes/passes.js
class pe {
  constructor(Z, J, $ = {}) {
    this.webgl = Z;
    let X = this.webgl.getDrawingBufferSize();
    this.draw = new YI(Z, J, X.width, X.height, $.transparency || "blended"), this.pick = new $I(Z, X.width, X.height, $.pickScale || 0.25), this.multiSample = new eR(Z, this.draw), this.illumination = new OU(Z, this.draw);
  }
  getByteCount() {
    return this.draw.getByteCount() + this.pick.getByteCount() + this.multiSample.getByteCount() + this.illumination.getByteCount();
  }
  setPickScale(Z) {
    this.pick.setPickScale(Z);
  }
  setTransparency(Z) {
    this.draw.setTransparency(Z);
  }
  updateSize() {
    let Z = this.webgl.getDrawingBufferSize(), J = Math.max(Z.width, 2), $ = Math.max(Z.height, 2);
    this.draw.setSize(J, $), this.pick.setSize(J, $), this.multiSample.syncSize(), this.illumination.setSize(J, $);
  }
}

// node_modules/molstar/lib/mol-gl/shader/hi-z.frag.js
var Lj0 = `
precision highp float;
precision highp sampler2D;

uniform sampler2D tPreviousLevel;
uniform vec2 uInvSize;
uniform vec2 uOffset;

void main(void) {
    vec2 position = gl_FragCoord.xy * uInvSize + uOffset;

    float x = texture(tPreviousLevel, position).r;
    float y = textureOffset(tPreviousLevel, position, ivec2(-1, 0)).r;
    float z = textureOffset(tPreviousLevel, position, ivec2(-1, -1)).r;
    float w = textureOffset(tPreviousLevel, position, ivec2(0, -1)).r;

    gl_FragColor = vec4(max(max(x, y), max(z, w)));
}
`;

// node_modules/molstar/lib/mol-gl/compute/hi-z.js
var kF1 = {
  ...A6,
  tPreviousLevel: o1("texture", "alpha", "float", "nearest"),
  uInvSize: _0("v2"),
  uOffset: _0("v2")
}, vF1 = v8("hi-z", p6, Lj0);
function Rj0(Z, J) {
  let $ = {
    ...B6,
    tPreviousLevel: C.create(J),
    uInvSize: C.create(h0()),
    uOffset: C.create(h0())
  }, X = { ...kF1 }, Y = t8(Z, "triangles", vF1, X, $);
  return e8(Y, $);
}

// node_modules/molstar/lib/mol-math/approx.js
var Ej0 = new ArrayBuffer(4), X08 = new Int32Array(Ej0), Y08 = new Float32Array(Ej0);
var Oj0 = new ArrayBuffer(4), SF1 = new Int32Array(Oj0), fF1 = new Float32Array(Oj0);
function hF1(Z) {
  let J = Z < -126 ? -126 : Z;
  return SF1[0] = 8388608 * (J + 126.94269504), fF1[0];
}
function zj0(Z) {
  return hF1(1.44269504 * Z);
}
var Dj0 = new ArrayBuffer(8), Q08 = new Int32Array(Dj0), W08 = new Float32Array(Dj0);
var Mj0 = new ArrayBuffer(4), bF1 = new Int32Array(Mj0), xF1 = new Float32Array(Mj0);
function Aj0(Z) {
  return xF1[0] = Z, bF1[0] * 0.00000011920928955078125 - 126.94269504;
}
var K08 = Math.PI / 2, G08 = 2 * Math.PI, H08 = 1 / (2 * Math.PI), N08 = 2 / Math.PI, q08 = 4 / Math.PI, F08 = 4 / (Math.PI * Math.PI), U08 = Math.PI / 2 - 2 * Math.PI;
var Bj0 = new ArrayBuffer(16), L08 = new Int32Array(Bj0), R08 = new Float32Array(Bj0);
var wj0 = new ArrayBuffer(8), E08 = new Int32Array(wj0), O08 = new Float32Array(wj0);
var jj0 = new ArrayBuffer(4), z08 = new Int32Array(jj0), D08 = new Float32Array(jj0);
var M08 = Math.PI / 4;

// node_modules/molstar/lib/mol-canvas3d/passes/hi-z.js
var yF1 = M.transformMat4, Tj0 = E2.set, gF1 = Aj0;
function mF1(Z, J, $) {
  return J * $ / (($ - J) * Z - $);
}
function dF1(Z, J, $) {
  return Z * (J - $) - J;
}
function Ax(Z, J, $, X) {
  return X[11] === -1 ? mF1(Z, J, $) : dF1(Z, J, $);
}
function pF1(Z, J, $, X) {
  let Y = J[0] * $, Q = J[1] * $, W = J[2] * $, K = J[2] * J[2] - $ * $, G = Math.sqrt(J[0] * J[0] + K), H = (G * J[0] - W) / (G * J[2] + Y) * X[0], N = (G * J[0] + W) / (G * J[2] - Y) * X[0], q = Math.sqrt(J[1] * J[1] + K), U = (q * J[1] - W) / (q * J[2] + Q) * X[5], F = (q * J[1] + W) / (q * J[2] - Q) * X[5];
  return Tj0(Z, N * -0.5 + 0.5, U * 0.5 + 0.5, H * -0.5 + 0.5, F * 0.5 + 0.5);
}
function uF1(Z, J, $, X) {
  let Y = X[0], Q = X[5], W = (J[0] + $) * Y, K = (J[0] - $) * Y, G = (J[1] + $) * Q, H = (J[1] - $) * Q;
  return Tj0(Z, K * 0.5 + 0.5, G * -0.5 + 0.5, W * 0.5 + 0.5, H * -0.5 + 0.5);
}
function cF1(Z, J, $, X) {
  return X[11] === -1 ? pF1(Z, J, $, X) : uF1(Z, J, $, X);
}
var ue = {
  enabled: j.Boolean(!1, { description: "Hierarchical Z-buffer occlusion culling. Only available for WebGL2." }),
  maxFrameLag: j.Numeric(10, { min: 1, max: 30, step: 1 }, { description: "Maximum number of frames to wait for Z-buffer data." }),
  minLevel: j.Numeric(3, { min: 1, max: 10, step: 1 })
};

class ce {
  getByteCount() {
    if (!this.supported)
      return 0;
    return this.tex.getByteCount() + this.buf.getByteCount() + this.levelData.reduce((Z, J) => Z + J.texture.getByteCount(), 0);
  }
  clear() {
    if (!this.supported)
      return;
    let { gl: Z } = this.webgl;
    if (!_2(Z))
      return;
    if (this.sync !== null)
      Z.deleteSync(this.sync), this.sync = null;
    if (this.frameLag = 0, this.ready = !1, this.debug)
      this.debug.rect.style.display = "none", this.debug.container.style.display = "none";
  }
  render(Z) {
    if (!this.supported || !this.props.enabled)
      return;
    let { gl: J, state: $ } = this.webgl;
    if (!_2(J) || this.sync !== null)
      return;
    if (this.nextNear = Z.near, this.nextFar = Z.far, e.copy(this.nextView, Z.view), e.copy(this.nextProjection, Z.projection), K1)
      this.webgl.timer.mark("hi-Z");
    $.disable(J.CULL_FACE), $.disable(J.BLEND), $.disable(J.DEPTH_TEST), $.disable(J.SCISSOR_TEST), $.depthMask(!1), $.colorMask(!0, !0, !0, !0), $.clearColor(0, 0, 0, 0);
    let X = this.renderable.values, Y = Math.pow(2, Math.ceil(Math.log(Math.max(J.drawingBufferWidth, J.drawingBufferHeight)) / Math.log(2)) - 1);
    for (let K = 0, G = this.levelData.length;K < G; ++K) {
      let H = this.levelData[K];
      if (H.framebuffer.bind(), K > 0)
        C.update(X.uInvSize, H.invSize), C.update(X.uOffset, h0.set(X.uOffset.ref.value, 0, 0)), C.update(X.tPreviousLevel, this.levelData[K - 1].texture);
      else
        C.update(X.uInvSize, h0.set(X.uInvSize.ref.value, 1 / Y, 1 / Y)), C.update(X.uOffset, h0.set(X.uOffset.ref.value, this.viewport.x / J.drawingBufferWidth, this.viewport.y / J.drawingBufferHeight)), C.update(X.tPreviousLevel, this.drawPass.depthTextureOpaque);
      if ($.currentRenderItemId = -1, $.viewport(0, 0, H.size[0], H.size[1]), J.clear(J.COLOR_BUFFER_BIT), this.renderable.update(), this.renderable.render(), K >= this.props.minLevel)
        this.tex.bind(0), J.copyTexSubImage2D(J.TEXTURE_2D, 0, H.offset, 0, 0, 0, H.size[0], H.size[1]), this.tex.unbind(0);
    }
    this.tex.attachFramebuffer(this.fb, 0);
    let Q = this.tex.getWidth(), W = this.tex.getHeight();
    if (this.buf.read(0, 0, Q, W), this.sync = J.fenceSync(J.SYNC_GPU_COMMANDS_COMPLETE, 0), J.flush(), K1)
      this.webgl.timer.markEnd("hi-Z");
  }
  tick() {
    if (!this.supported || !this.props.enabled || this.sync === null)
      return;
    let { gl: Z } = this.webgl;
    if (!_2(Z))
      return;
    let J = Z.clientWaitSync(this.sync, 0, 0);
    if (J === Z.WAIT_FAILED || this.frameLag >= this.props.maxFrameLag)
      Z.deleteSync(this.sync), this.sync = null, this.frameLag = 0, this.ready = !1;
    else if (J === Z.TIMEOUT_EXPIRED)
      this.frameLag += 1;
    else
      this.buf.getSubData(this.buffer), Z.deleteSync(this.sync), this.sync = null, this.frameLag = 0, this.ready = !0, this.near = this.nextNear, this.far = this.nextFar, e.copy(this.view, this.nextView), e.copy(this.projection, this.nextProjection);
  }
  transform(Z) {
    let { view: J, vp: $ } = this;
    yF1($, Z.center, J);
    let X = Z.radius * 1.2 + 1.52;
    return { vp: $, r: X };
  }
  project(Z, J) {
    let { projection: $, aabb: X, viewport: Y } = this;
    cF1(X, Z, J, $);
    let Q = X[2] - X[0], W = X[3] - X[1], K = Math.max(Q * Y.width, W * Y.height), G = Math.ceil(gF1(K / 2));
    return { aabb: X, w: Q, h: W, pr: K, lod: G };
  }
  setViewport(Z, J, $, X) {
    if (!this.supported)
      return;
    $ = Math.max($, 2), X = Math.max(X, 2), bZ.set(this.viewport, Z, J, $, X);
    let Y = Math.ceil(Math.log(Math.max($, X)) / Math.log(2));
    if (Y === this.levelData.length)
      return;
    let { minLevel: Q } = this.props;
    this.buffer = new Float32Array(Math.pow(2, Y - Q) * Math.pow(2, Y - 1 - Q)), this.tex.define(Math.pow(2, Y - Q), Math.pow(2, Y - 1 - Q));
    for (let K of this.levelData)
      K.framebuffer.destroy(), K.texture.destroy();
    this.levelData.length = 0;
    for (let K = 0;K < Y; ++K) {
      let G = this.webgl.resources.framebuffer(), H = Math.pow(2, Y - K - 1), N = h0.create(H, H), q = h0.create(1 / H, 1 / H), U = this.webgl.resources.texture("image-float32", "alpha", "float", "nearest");
      U.define(H, H), U.attachFramebuffer(G, 0), this.levelData.push({ texture: U, framebuffer: G, size: N, invSize: q, offset: 0 });
    }
    let W = 0;
    for (let K = 0, G = Y;K < G; ++K) {
      let H = this.levelData[K];
      if (K >= Q)
        this.levelData[K].offset = W, W += H.size[0];
    }
    this.clear();
  }
  setProps(Z) {
    if (!this.supported)
      return;
    if (this.props.minLevel !== Z.minLevel) {
      Object.assign(this.props, Z);
      let { x: J, y: $, width: X, height: Y } = this.viewport;
      this.setViewport(J, $, X, Y);
    } else if (Object.assign(this.props, Z), !this.props.enabled)
      this.clear();
  }
  initDebug(Z) {
    if (!Z.parentElement)
      return;
    let J = document.createElement("div");
    Object.assign(J.style, {
      display: "block",
      position: "absolute",
      pointerEvents: "none"
    }), Z.parentElement.appendChild(J);
    let $ = document.createElement("canvas"), X = $.getContext("2d");
    if (!X)
      throw new Error("Could not create canvas 2d context");
    Object.assign($.style, {
      width: "100%",
      height: "100%",
      imageRendering: "pixelated",
      position: "relative",
      pointerEvents: "none"
    }), J.appendChild($);
    let Y = document.createElement("div");
    Object.assign(Y.style, {
      display: "none",
      position: "absolute",
      pointerEvents: "none"
    }), Z.parentElement.appendChild(Y), this.debug = { container: J, canvas: $, ctx: X, rect: Y };
  }
  canDebug(Z) {
    return this.supported && this.props.enabled && this.ready && !!this.debug;
  }
  showRect(Z, J) {
    if (!this.canDebug(this.debug))
      return;
    let { gl: { drawingBufferHeight: $ }, pixelRatio: X } = this.webgl, { viewport: { x: Y, y: Q, width: W, height: K } } = this, G = (Z[0] * W + Y) / X, H = (Z[1] * K - Q) / X, N = (Z[2] * W + Y) / X, q = (Z[3] * K - Q) / X, U = ($ - K) / X;
    Object.assign(this.debug.rect.style, {
      border: J ? "solid red" : "solid green",
      display: "block",
      left: `${G}px`,
      top: `${H + U}px`,
      width: `${N - G}px`,
      height: `${q - H}px`
    });
  }
  showBuffer(Z) {
    if (!this.canDebug(this.debug))
      return;
    if (Z >= this.levelData.length || Z < this.props.minLevel) {
      this.debug.container.style.display = "none";
      return;
    }
    let { offset: J, size: [$, X] } = this.levelData[Z], Y = this.tex.getWidth(), Q = new Uint8ClampedArray($ * X * 4);
    Q.fill(255);
    for (let U = 0;U < X; ++U)
      for (let F = 0;F < $; ++F) {
        let E = (X - U - 1) * $ + F, R = this.buffer[U * Y + F + J] * 255;
        Q[E * 4 + 0] = R, Q[E * 4 + 3] = 255 - R;
      }
    let W = new ImageData(Q, $, X);
    this.debug.canvas.width = W.width, this.debug.canvas.height = W.height, this.debug.ctx.putImageData(W, 0, 0);
    let { viewport: { x: K, y: G, width: H, height: N }, webgl: { pixelRatio: q } } = this;
    Object.assign(this.debug.container.style, {
      display: "block",
      bottom: `${G / q}px`,
      left: `${K / q}px`,
      width: `${H / q}px`,
      height: `${N / q}px`
    });
  }
  debugOcclusion(Z) {
    if (!this.canDebug(this.debug))
      return;
    if (!Z) {
      this.debug.rect.style.display = "none", this.debug.container.style.display = "none";
      return;
    }
    let J = this.isOccluded(Z), { vp: $, r: X } = this.transform(Z), { aabb: Y, lod: Q } = this.project($, X);
    this.showRect(Y, J), this.showBuffer(Q);
  }
  reset() {
    this.sync = null, this.ready = !1, this.frameLag = 0, this.levelData.length = 0;
    let { x: Z, y: J, width: $, height: X } = this.viewport;
    this.setViewport(Z, J, $, X);
  }
  dispose() {
    if (!this.supported)
      return;
    this.clear(), this.fb.destroy(), this.tex.destroy(), this.buf.destroy(), this.renderable.dispose();
    for (let Z of this.levelData)
      Z.framebuffer.destroy(), Z.texture.destroy();
  }
  constructor(Z, J, $, X) {
    this.webgl = Z, this.drawPass = J, this.viewport = bZ(), this.near = 0, this.far = 0, this.view = e(), this.projection = e(), this.nextNear = 0, this.nextFar = 0, this.nextView = e(), this.nextProjection = e(), this.aabb = E2(), this.vp = M(), this.levelData = [], this.sync = null, this.buffer = new Float32Array(0), this.frameLag = 0, this.ready = !1, this.isOccluded = (G) => {
      if (!this.supported || !this.props.enabled || !this.ready)
        return !1;
      let { vp: H, r: N } = this.transform(G), { near: q, far: U, projection: F } = this, E = H[2] + N;
      if (-E < q)
        return !1;
      let { aabb: R, w: z, h: D, lod: A } = this.project(H, N);
      if (A >= this.levelData.length || A < this.props.minLevel)
        return !1;
      let { offset: B, size: T } = this.levelData[A], w = R[0] + z / 2, V = R[1] + D / 2, P = T[0], I = w * P, S = V * P, f = Math.floor(I), v = Math.ceil(S), h = this.tex.getWidth();
      if (f + 1 >= P || v + 1 >= P)
        return !1;
      let x = (P - v - 1) * h + f + B;
      if (E > Ax(this.buffer[x], q, U, F))
        return !1;
      if (E > Ax(this.buffer[x + 1], q, U, F))
        return !1;
      let b = (P - v + 1 - 1) * h + f + B;
      if (E > Ax(this.buffer[b], q, U, F))
        return !1;
      if (E > Ax(this.buffer[b + 1], q, U, F))
        return !1;
      return !0;
    }, this.props = { ...j.getDefaultValues(ue), ...X };
    let { gl: Y, extensions: Q } = Z;
    if (!_2(Y) || !Q.colorBufferFloat) {
      if (y2)
        console.log('Missing webgl2 and/or colorBufferFloat support required for "Hi-Z"');
      this.supported = !1;
      return;
    }
    this.fb = Z.resources.framebuffer(), this.tex = Z.resources.texture("image-float32", "alpha", "float", "nearest"), this.tex.attachFramebuffer(this.fb, 0);
    let W = Y.getParameter(Y.IMPLEMENTATION_COLOR_READ_FORMAT), K = Y.getParameter(Y.IMPLEMENTATION_COLOR_READ_TYPE);
    if (W !== Y.RED || K !== Y.FLOAT) {
      if (y2)
        console.log('Missing red/float reading support required for "Hi-Z"');
      this.supported = !1;
      return;
    }
    if (this.supported = !0, this.buf = Z.resources.pixelPack("alpha", "float"), this.renderable = Rj0(Z, this.drawPass.depthTextureOpaque), y2 && $)
      this.initDebug($);
  }
}

// node_modules/molstar/lib/mol-canvas3d/helper/xr-manager.js
var lF1 = V8, nF1 = e1.Trigger, _j0 = e1.TriggerKey;
function iF1(Z) {
  let J = e.getDecomposition(Z);
  return new XRRigidTransform(M.toObj(J.position), k8.toObj(J.quaternion));
}
function Vj0(Z, J) {
  let $ = M.fromObj(Z.transform.position), X = e.fromArray(e(), Z.transform.matrix, 0), Y = e.getDecomposition(X), Q = e.fromQuat(e(), Y.quaternion), W = M.transformMat4(M(), M.negUnitZ, Q), K = GQ.create($, W);
  if (J)
    GQ.transform(K, K, e.invert(e(), J));
  return K;
}
var oF1 = {
  exit: e1([_j0("GamepadB")]),
  togglePassthrough: e1([_j0("GamepadA")]),
  gestureScale: e1([nF1(lF1.Flag.Trigger)])
}, le = {
  bindings: oF1
}, ne = {
  minTargetDistance: j.Numeric(0.4, { min: 0.001, max: 1, step: 0.001 }),
  disablePostprocessing: j.Boolean(!0),
  resolutionScale: j.Numeric(1, { min: 0.1, max: 2, step: 0.1 }),
  sceneRadiusInMeters: j.Numeric(0.25, { min: 0.01, max: 2, step: 0.01 }, { description: "The radius of the scene bounding sphere in meters, used to set the initial camera scale." })
};

class ie {
  get session() {
    return this.xrSession;
  }
  setProps(Z) {
    Object.assign(this.props, Z);
  }
  setAttribs(Z) {
    Object.assign(this.attribs, Z);
  }
  intersect(Z, J, $, X) {
    let Y = M(), Q = Vj0(X, J);
    if (tZ.intersectRay3D(Y, $, Q)) {
      let { height: W } = Z.viewport, K = $x(E2(), Y, Z.viewport, Z.projectionView), G = h0.create(Math.floor(K[0]), W - Math.floor(K[1]));
      return { point: Y, screen: G };
    }
  }
  setScaleFactor(Z) {
    this.scaleFactor = Z;
  }
  resetScale() {
    this.scaleFactor = 1, this.prevScale = 0;
  }
  update(Z) {
    var J, $, X, Y, Q, W, K;
    let { xrSession: G, xrRefSpace: H, input: N, camera: q, stereoCamera: U, pointerHelper: F } = this;
    if (!Z || !G || !H)
      return !1;
    q.scale = q.scale * this.scaleFactor, this.prevScale = q.scale;
    let E = M.sub(M(), q.position, q.target);
    M.scaleAndAdd(q.position, q.position, E, 1 - this.scaleFactor), this.scaleFactor = 1;
    let R = iF1(q.view), z = H.getOffsetReferenceSpace(R), D = Z.getViewerPose(z);
    if (!D)
      return !1;
    let A = Z.getViewerPose(H);
    if (A) {
      let g = k8.fromObj(A.transform.orientation);
      e.fromQuat(q.headRotation, g);
    }
    let { depthFar: B, depthNear: T, baseLayer: w } = G.renderState;
    if (!w)
      return !1;
    if (B !== q.far || T !== q.near)
      G.updateRenderState({
        depthNear: q.near,
        depthFar: q.far
      });
    U.update({ pose: D, layer: w });
    let V = U.left, P = M.scale(M(), V.state.target, V.scale), I = e.getTranslation(M(), e.invert(e(), V.view)), S = M.sub(M(), I, P), f = tZ.fromNormalAndCoplanarPoint(tZ(), S, P), v = [], h = [], x = [], b = [];
    if (G.inputSources)
      for (let g of G.inputSources) {
        if (g.targetRayMode === "screen") {
          if (g.gamepad) {
            let { axes: E0 } = g.gamepad, { width: V0, height: u0 } = V.viewport, N0 = (E0[0] + 1) / 2 * V0, q0 = (E0[1] + 1) / 2 * u0, A0 = V.getRay(GQ(), N0, u0 - q0);
            b.push({ x: N0, y: q0, ray: A0 });
          }
          continue;
        }
        if (g.targetRayMode !== "tracked-pointer")
          continue;
        let { handedness: m, targetRaySpace: i, gamepad: r } = g;
        if (!m)
          continue;
        let Y0 = Z.getPose(i, H);
        if (!Y0)
          continue;
        let c = Vj0(Y0, q.view);
        v.push(c);
        let n = C0.scaleNX(C0(), this.scene.boundingSphereVisible, V.scale), l = M();
        if (GQ.intersectSphere3D(l, c, n))
          h.push(l);
        let u = V8.create(V8.Flag.None);
        if ((J = r === null || r === void 0 ? void 0 : r.buttons[0]) === null || J === void 0 ? void 0 : J.pressed)
          u |= V8.Flag.Primary;
        if (($ = r === null || r === void 0 ? void 0 : r.buttons[1]) === null || $ === void 0 ? void 0 : $.pressed)
          u |= V8.Flag.Secondary;
        if ((X = r === null || r === void 0 ? void 0 : r.buttons[3]) === null || X === void 0 ? void 0 : X.pressed)
          u |= V8.Flag.Auxilary;
        if ((Y = r === null || r === void 0 ? void 0 : r.buttons[4]) === null || Y === void 0 ? void 0 : Y.pressed)
          u |= V8.Flag.Forth;
        if ((Q = r === null || r === void 0 ? void 0 : r.buttons[5]) === null || Q === void 0 ? void 0 : Q.pressed)
          u |= V8.Flag.Five;
        let G0 = m === "left" ? this.prevInput.left : this.prevInput.right, F0 = this.intersect(V, q.view, f, Y0), t = G0 ? this.intersect(V, q.view, f, G0.targetRayPose) : void 0, [Z0, U0] = (W = F0 === null || F0 === void 0 ? void 0 : F0.screen) !== null && W !== void 0 ? W : [0, 0], [a, Q0] = (K = t === null || t === void 0 ? void 0 : t.screen) !== null && K !== void 0 ? K : [Z0, U0], $0 = h0.set(h0(), Z0 - a, U0 - Q0);
        h0.setMagnitude($0, $0, Math.min(100, h0.magnitude($0)));
        let [R0, X0] = h0.round($0, $0);
        if (x.push({
          handedness: m,
          buttons: u,
          x: Z0,
          y: U0,
          dx: R0,
          dy: X0,
          ray: c,
          axes: r === null || r === void 0 ? void 0 : r.axes
        }), m === "left")
          this.prevInput.left = { targetRayPose: Y0 };
        else
          this.prevInput.right = { targetRayPose: Y0 };
      }
    else
      this.prevInput.left = void 0, this.prevInput.right = void 0;
    return N.updateTrackedPointers(x), N.updateScreenTouches(b), F.ensureEnabled(), F.update(v, h, this.hit), !0;
  }
  async setSession(Z) {
    if (this.xrSession === Z)
      return;
    if (await this.webgl.xr.set(Z, { resolutionScale: this.props.resolutionScale }), this.xrSession = this.webgl.xr.session, this.prevInput = {}, this.hit = void 0, this.xrSession) {
      this.xrRefSpace = await this.xrSession.requestReferenceSpace("local"), this.pointerHelper.setProps({ enabled: "on" });
      let J = this.prevScale;
      if (J === 0) {
        let { radius: $ } = this.scene.boundingSphereVisible;
        J = $ ? 1 / $ * this.props.sceneRadiusInMeters : 0.01;
      }
      this.camera.forceFull = !0, this.camera.scale = J, this.camera.minTargetDistance = this.props.minTargetDistance, this.prevScale = J;
    } else
      this.xrRefSpace = void 0, e.setZero(this.camera.headRotation), this.pointerHelper.setProps({ enabled: "off" }), this.camera.forceFull = !1, this.camera.scale = 1, this.camera.minTargetDistance = 0;
  }
  async end() {
    await this.webgl.xr.end();
  }
  async request() {
    if (!navigator.xr)
      return;
    let Z = await navigator.xr.isSessionSupported("immersive-ar") ? await navigator.xr.requestSession("immersive-ar") : await navigator.xr.requestSession("immersive-vr");
    await this.setSession(Z);
  }
  dispose() {
    var Z;
    this.hoverSub.unsubscribe(), this.keyUpSub.unsubscribe(), this.gestureSub.unsubscribe(), this.sessionChangedSub.unsubscribe(), this.togglePassthrough.complete(), this.sessionChanged.complete(), this.isSupported.complete(), (Z = navigator.xr) === null || Z === void 0 || Z.removeEventListener("devicechange", this.checkSupported);
  }
  constructor(Z, J, $, X, Y, Q, W, K = {}, G = {}) {
    var H;
    this.webgl = Z, this.input = J, this.scene = $, this.camera = X, this.stereoCamera = Y, this.pointerHelper = Q, this.interactionHelper = W, this.togglePassthrough = new P6, this.sessionChanged = new P6, this.isSupported = new G$(!1), this.xrSession = void 0, this.xrRefSpace = void 0, this.scaleFactor = 1, this.prevScale = 0, this.prevInput = {}, this.hit = void 0, this.checkSupported = async () => {
      if (!navigator.xr)
        return !1;
      let [N, q] = await Promise.all([
        navigator.xr.isSessionSupported("immersive-ar"),
        navigator.xr.isSessionSupported("immersive-vr")
      ]);
      this.isSupported.next(N || q);
    }, this.props = { ...j.getDefaultValues(ne), ...K }, this.attribs = { ...le, ...G }, this.hoverSub = this.interactionHelper.events.hover.subscribe(({ position: N }) => {
      this.hit = N;
    }), this.sessionChangedSub = Z.xr.changed.subscribe(async () => {
      await this.setSession(Z.xr.session), this.sessionChanged.next();
    }), this.checkSupported(), (H = navigator.xr) === null || H === void 0 || H.addEventListener("devicechange", this.checkSupported), this.keyUpSub = J.keyUp.subscribe(({ code: N, modifiers: q, key: U }) => {
      let F = this.attribs.bindings;
      if (e1.matchKey(F.exit, N, q, U))
        this.end();
      if (e1.matchKey(F.togglePassthrough, N, q, U))
        this.togglePassthrough.next();
    }), this.gestureSub = J.gesture.subscribe(({ scale: N, button: q, modifiers: U }) => {
      let F = this.attribs.bindings;
      if (e1.match(F.gestureScale, q, U))
        this.setScaleFactor(N);
    });
  }
}

// node_modules/molstar/lib/mol-canvas3d/helper/ray-helper.js
class oe {
  setPickPadding(Z) {
    if (this.pickPadding !== Z)
      this.pickPadding = Z, this.update();
  }
  update() {
    let Z = this.pickPadding * 2 + 1;
    bZ.set(this.viewport, 0, 0, Z, Z), this.buffers.setViewport(0, 0, Z, Z), this.spiral = BS(this.pickPadding), this.size = Z, this.pickPass.setSize(Z, Z);
  }
  render(Z) {
    if (K1)
      this.webgl.timer.mark("RayHelper.render", { captureStats: !0 });
    let { renderer: J, scene: $, helper: X } = this;
    if (J.setTransparentBackground(!1), J.setDrawingBufferSize(this.size, this.size), J.setPixelRatio(1), J.setViewport(0, 0, this.size, this.size), this.pickPass.render(J, Z, $, X), K1)
      this.webgl.timer.markEnd("RayHelper.render");
  }
  identifyInternal(Z, J) {
    if (this.webgl.isContextLost)
      return;
    let { viewport: $ } = this, X = this.buffers.getPickingId(Z, J);
    if (X === void 0)
      return;
    let Y = this.buffers.getDepth(Z, J), Q = M.create(Z, J, Y);
    return Rq(Q, Q, $, this.camera.inverseProjectionView), { id: X, position: Q };
  }
  prepare(Z, J) {
    this.camera.far = J.far, this.camera.near = J.near, this.camera.fogFar = J.fogFar, this.camera.fogNear = J.fogNear, this.camera.forceFull = J.forceFull, this.camera.scale = J.scale, bZ.copy(this.camera.viewport, this.viewport), O6.copySnapshot(this.camera.state, { ...J.state, mode: "orthographic" }), sF1(this.camera, Z, J.up), e.mul(this.camera.projectionView, this.camera.projection, this.camera.view), e.tryInvert(this.camera.inverseProjectionView, this.camera.projectionView), e.copy(this.camera.viewEye, J.view);
  }
  getPickData() {
    let Z = this.pickPadding;
    for (let J of this.spiral) {
      let $ = this.identifyInternal(Z + J[0], Z + J[1]);
      if ($)
        return $;
    }
  }
  intersectsScene(Z, J) {
    return C0.scaleNX(this.sphere, this.scene.boundingSphereVisible, J), GQ.isInsideSphere3D(Z, this.sphere) || GQ.isIntersectingSphere3D(Z, this.sphere);
  }
  identify(Z, J) {
    if (!this.intersectsScene(Z, J.scale))
      return;
    if (this.prepare(Z, J), K1)
      this.webgl.timer.mark("RayHelper.identify");
    if (this.render(this.camera), this.buffers.read(), K1)
      this.webgl.timer.markEnd("RayHelper.identify");
    return this.getPickData();
  }
  asyncIdentify(Z, J) {
    if (!this.intersectsScene(Z, J.scale))
      return;
    if (this.prepare(Z, J), K1)
      this.webgl.timer.mark("RayHelper.asyncIdentify");
    if (this.render(this.camera), this.buffers.asyncRead(), K1)
      this.webgl.timer.markEnd("RayHelper.asyncIdentify");
    return {
      tryGet: () => {
        let $ = this.buffers.check();
        if ($ === aQ.Resolved)
          return this.getPickData();
        else if ($ === aQ.Pending)
          return "pending";
      }
    };
  }
  reset() {
    this.buffers.reset(), this.pickPass.reset();
  }
  dispose() {
    this.buffers.dispose(), this.pickPass.dispose();
  }
  constructor(Z, J, $, X, Y) {
    this.webgl = Z, this.renderer = J, this.scene = $, this.helper = X, this.viewport = bZ(), this.sphere = C0();
    let Q = Y.pickPadding * 2 + 1;
    if (this.camera = new O6, this.pickPass = new $I(Z, Q, Q, 1), this.buffers = new XI(this.webgl, this.pickPass, Y.maxAsyncReadLag), this.pickPadding = Y.pickPadding, this.update(), !Lx(Z))
      this.asyncIdentify = (W, K) => ({
        tryGet: () => this.identify(W, K)
      });
  }
}
function sF1(Z, J, $) {
  let { near: X, far: Y, viewport: Q } = Z, W = 2 * Math.tan(_8(0.1) / 2) * M.distance(Z.position, Z.target) * Z.scale, K = Q.height / W, G = -Q.width / 2, H = Q.width / 2, N = Q.height / 2, q = -Q.height / 2, U = (H - G) / (2 * K), F = (N - q) / (2 * K), E = (H + G) / 2, R = (N + q) / 2, z = E - U, D = E + U, A = R + F, B = R - F;
  e.ortho(Z.projection, z, D, A, B, X, Y);
  let T = M.normalize(M(), J.direction), w = k8.fromUnitVec3(k8(), T, M.negUnitZ);
  k8.invert(w, w);
  let V = M.clone(J.origin), P = M.add(M(), V, T);
  e.lookAt(Z.view, V, P, $);
}

// node_modules/molstar/lib/mol-canvas3d/canvas3d.js
var aF1 = {
  intensity: j.Numeric(15, { min: 1, max: 100, step: 1 })
}, J$ = {
  camera: j.Group({
    mode: j.Select("perspective", j.arrayToOptions(["perspective", "orthographic"]), { label: "Camera" }),
    helper: j.Group(ZE, { isFlat: !0 }),
    stereo: j.MappedStatic("off", {
      on: j.Group(fe),
      off: j.Group({})
    }, { cycle: !0, hideIf: (Z) => (Z === null || Z === void 0 ? void 0 : Z.mode) !== "perspective" }),
    fov: j.Numeric(45, { min: 10, max: 130, step: 1 }, { label: "Field of View" }),
    manualReset: j.Boolean(!1, { isHidden: !0 })
  }, { pivot: "mode" }),
  cameraFog: j.MappedStatic("on", {
    on: j.Group(aF1),
    off: j.Group({})
  }, { cycle: !0, description: "Show fog in the distance" }),
  cameraClipping: j.Group({
    radius: j.Numeric(100, { min: 0, max: 99, step: 1 }, { label: "Clipping", description: "How much of the scene to show." }),
    far: j.Boolean(!0, { description: "Hide scene in the distance" }),
    minNear: j.Numeric(1, { min: 0.1, max: 100, step: 0.1 }, { description: "Minimal allowed distance of near clipping plane from the camera. Note, may cause performance issues rendering impostors when set too small and cause issues with outline rendering when too close to 0." })
  }, { pivot: "radius" }),
  viewport: j.MappedStatic("canvas", {
    canvas: j.Group({}),
    "static-frame": j.Group({
      x: j.Numeric(0),
      y: j.Numeric(0),
      width: j.Numeric(128),
      height: j.Numeric(128)
    }),
    "relative-frame": j.Group({
      x: j.Numeric(0.33, { min: 0, max: 1, step: 0.01 }),
      y: j.Numeric(0.33, { min: 0, max: 1, step: 0.01 }),
      width: j.Numeric(0.5, { min: 0.01, max: 1, step: 0.01 }),
      height: j.Numeric(0.5, { min: 0.01, max: 1, step: 0.01 })
    })
  }),
  cameraResetDurationMs: j.Numeric(250, { min: 0, max: 1000, step: 1 }, { description: "The time it takes to reset the camera." }),
  sceneRadiusFactor: j.Numeric(1, { min: 1, max: 10, step: 0.1 }),
  transparentBackground: j.Boolean(!1),
  checkeredTransparentBackground: j.Boolean(!1),
  dpoitIterations: j.Numeric(2, { min: 1, max: 10, step: 1 }),
  pickPadding: j.Numeric(3, { min: 0, max: 10, step: 1 }, { description: "Extra pixels to around target to check in case target is empty." }),
  userInteractionReleaseMs: j.Numeric(250, { min: 0, max: 1000, step: 1 }, { description: "The time before the user is not considered interacting anymore." }),
  multiSample: j.Group(Ux),
  postprocessing: j.Group(rA),
  marking: j.Group(Ox),
  illumination: j.Group(Dx),
  hiZ: j.Group(ue),
  renderer: j.Group(aA),
  trackball: j.Group(ze),
  interaction: j.Group(je),
  debug: j.Group(rV),
  handle: j.Group(Mx),
  pointer: j.Group(KI),
  xr: j.Group(ne, { label: "XR" })
}, GI = j.getDefaultValues(J$), rF1 = {
  trackball: De,
  xr: le
};
var a3;
(function(Z) {
  Z.DefaultAttribs = {
    powerPreference: "high-performance",
    failIfMajorPerformanceCaveat: !1,
    antialias: !0,
    preserveDrawingBuffer: !0,
    preferWebGl1: !1,
    handleResize: () => {}
  }, Z.Params = {
    resolutionMode: j.Select("auto", j.arrayToOptions(["auto", "scaled", "native"])),
    pixelScale: j.Numeric(1, { min: 0.1, max: 2, step: 0.05 }),
    pickScale: j.Numeric(0.25, { min: 0.1, max: 1, step: 0.05 }),
    transparency: j.Select("wboit", [["blended", "Blended"], ["wboit", "Weighted, Blended"], ["dpoit", "Depth Peeling"]])
  }, Z.DefaultProps = j.getDefaultValues(Z.Params);
  function J($, X, Y = {}, Q = {}) {
    let W = { ...Z.DefaultAttribs, ...Y }, K = { ...Z.DefaultProps, ...Q }, { powerPreference: G, failIfMajorPerformanceCaveat: H, antialias: N, preserveDrawingBuffer: q, preferWebGl1: U } = W, F = hR0($, {
      powerPreference: G,
      failIfMajorPerformanceCaveat: H,
      antialias: N,
      preserveDrawingBuffer: q,
      alpha: !0,
      depth: !0,
      premultipliedAlpha: !0,
      preferWebGl1: U
    });
    if (F === null)
      throw new Error("Could not create a WebGL rendering context");
    let E = () => {
      let f = K.pixelScale / (typeof window !== "undefined" ? (window === null || window === void 0 ? void 0 : window.devicePixelRatio) || 1 : 1);
      if (K.resolutionMode === "auto")
        return $U0() ? f : K.pixelScale;
      return K.resolutionMode === "native" ? K.pixelScale : f;
    }, R = () => {
      let f = E();
      B.setPixelScale(f), T.setPixelScale(f);
    }, { pickScale: z, transparency: D } = K, A = E(), B = Xx.fromElement($, { pixelScale: A, preventGestures: !0 }), T = mR0(F, { pixelScale: A }), w = new pe(T, X, { pickScale: z, transparency: D });
    if (y2) {
      let f = F.getExtension("WEBGL_lose_context");
      if (f)
        $.addEventListener("mousedown", (v) => {
          if (T.isContextLost)
            return;
          if (!v.shiftKey || !v.ctrlKey || !v.altKey)
            return;
          if (y2)
            console.log("lose context");
          f.loseContext(), setTimeout(() => {
            if (!T.isContextLost)
              return;
            if (y2)
              console.log("restore context");
            f.restoreContext();
          }, 1000);
        }, !1);
    }
    let V = new P6, P = (f) => {
      if (T.setContextLost(), f.preventDefault(), y2)
        console.log("context lost");
      V.next(m6());
    }, I = () => {
      if (!T.isContextLost)
        return;
      if (T.handleContextRestored(() => {
        w.draw.reset(), w.pick.reset(), w.illumination.reset();
      }), y2)
        console.log("context restored");
    };
    $.addEventListener("webglcontextlost", P, !1), $.addEventListener("webglcontextrestored", I, !1);
    let S = new G$(void 0);
    return {
      canvas: $,
      webgl: T,
      input: B,
      passes: w,
      attribs: W,
      get props() {
        return { ...K };
      },
      contextLost: V,
      contextRestored: T.contextRestored,
      assetManager: X,
      changed: S,
      get pixelScale() {
        return E();
      },
      syncPixelScale: R,
      setProps: (f) => {
        if (!f)
          return;
        let v = !1, h = !1;
        if (f.resolutionMode !== void 0 && f.resolutionMode !== K.resolutionMode)
          K.resolutionMode = f.resolutionMode, h = !0;
        if (f.pixelScale !== void 0 && f.pixelScale !== K.pixelScale)
          K.pixelScale = f.pixelScale, h = !0;
        if (h)
          R(), W.handleResize(), v = !0;
        if (f.pickScale !== void 0 && f.pickScale !== K.pickScale)
          K.pickScale = f.pickScale, w.setPickScale(f.pickScale), v = !0;
        if (f.transparency !== void 0 && f.transparency !== K.transparency)
          K.transparency = f.transparency, w.setTransparency(f.transparency), v = !0;
        if (v)
          S.next(void 0);
      },
      dispose: (f) => {
        B.dispose(), $.removeEventListener("webglcontextlost", P, !1), $.removeEventListener("webglcontextrestored", I, !1), T.destroy(f), V.complete(), S.complete();
      }
    };
  }
  Z.fromCanvas = J;
})(a3 || (a3 = {}));
var tF1 = typeof window !== "undefined" ? window.requestAnimationFrame : (Z) => setImmediate(() => Z(Date.now())), Ij0 = typeof window !== "undefined" ? window.cancelAnimationFrame : (Z) => clearImmediate(Z);
function Pj0(Z, J) {
  if (J.transparentBackground && J.checkeredTransparentBackground)
    Object.assign(Z.style, {
      "background-image": "linear-gradient(45deg, lightgrey 25%, transparent 25%, transparent 75%, lightgrey 75%, lightgrey), linear-gradient(45deg, lightgrey 25%, transparent 25%, transparent 75%, lightgrey 75%, lightgrey)",
      "background-size": "60px 60px",
      "background-position": "0 0, 30px 30px"
    });
  else
    Object.assign(Z.style, {
      "background-image": "",
      "background-size": "",
      "background-position": ""
    });
}
var Bx;
(function(Z) {
  function J($, X = {}, Y = {}) {
    var Q, W;
    let { webgl: K, input: G, passes: H, assetManager: N, canvas: q, contextLost: U } = $, F = { ...W$(GI), ...W$(X) }, E = { ...W$(rF1), ...W$(Y) }, R = /* @__PURE__ */ new Map, z = /* @__PURE__ */ new Map, D = new G$(0), A = new P6, B = m6(), T = new G$(0), w = new G$(0), V = new G$(0), { contextRestored: P } = K, I = 0, S = 0, f = 128, v = 128, h = !1, x = 0;
    Pj0(q, F), v6();
    let b = s3.create(K, H.draw.transparency, {
      dColorMarker: F.renderer.colorMarker,
      dLightCount: (Q = F.renderer.light) === null || Q === void 0 ? void 0 : Q.length
    });
    function g() {
      return b.boundingSphere.radius * F.sceneRadiusFactor;
    }
    let m = new O6({
      position: M.create(0, 0, 100),
      mode: F.camera.mode,
      fog: F.cameraFog.name === "on" ? F.cameraFog.params.intensity : 0,
      clipFar: F.cameraClipping.far,
      minNear: F.cameraClipping.minNear,
      fov: _8(F.camera.fov)
    }, { x: I, y: S, width: f, height: v }), i = new Eq(m, F.camera.stereo.params), r = Wx.create(G, m, b, F.trackball, E.trackball), Y0 = new de(K, b, F), c = new ce(K, H.draw, q, F.hiZ), n = Qx.create(K, F.renderer);
    n.setOcclusionTest(c.isOccluded);
    let l = new eA(K, b);
    l.updateRequired(F);
    let u = {
      pickPadding: F.pickPadding,
      maxAsyncReadLag: rw0.maxAsyncReadLag
    }, G0 = new he(K, n, b, Y0, H.pick, { x: I, y: S, width: f, height: v }, u), F0 = new oe(K, n, b, Y0, u), t = new Te(v2, O8, D1, G, m, r, F.interaction), Z0 = new JI(H.multiSample);
    H.draw.postprocessing.background.update(m, F.postprocessing.background, (L1) => {
      if (L1)
        y0();
    });
    let U0 = !1, a = void 0, Q0 = void 0, $0 = !1;
    function R0() {
      return {
        transparency: $.props.transparency,
        transparentBackground: F.transparentBackground,
        hiZ: c.props.enabled,
        postprocessing: F.postprocessing.enabled,
        axes: W$(Y0.camera.props.axes)
      };
    }
    let X0 = R0();
    function E0() {
      Object.assign(X0, R0());
    }
    function V0() {
      F.postprocessing.enabled = X0.postprocessing, F.transparentBackground = X0.transparentBackground, $.setProps({ transparency: X0.transparency }), c.setProps({ enabled: X0.hiZ }), Y0.camera.setProps({ axes: X0.axes });
    }
    function u0() {
      var L1;
      if (F.postprocessing.enabled = !N0.props.disablePostprocessing, $.setProps({ transparency: "blended" }), c.setProps({ enabled: !1 }), Y0.camera.setProps({ axes: { name: "off", params: {} } }), ((L1 = N0.session) === null || L1 === void 0 ? void 0 : L1.environmentBlendMode) === "alpha-blend")
        F.transparentBackground = A0;
    }
    let N0 = new ie(K, G, b, m, i, Y0.pointer, t, F.xr, E.xr), q0 = {
      request: async () => {
        try {
          await N0.request();
        } catch (L1) {
          console.error(L1), q0.requestFailed.next(L1);
        }
      },
      end: () => N0.end(),
      isSupported: new G$(!1),
      isPresenting: new G$(!1),
      requestFailed: new P6
    }, A0 = !1, S0 = [
      N0.isSupported.subscribe((L1) => q0.isSupported.next(L1)),
      N0.togglePassthrough.subscribe(() => {
        var L1;
        if (((L1 = N0.session) === null || L1 === void 0 ? void 0 : L1.environmentBlendMode) === "alpha-blend")
          A0 = !F.transparentBackground;
      }),
      N0.sessionChanged.subscribe(() => {
        var L1;
        if (m0 = null, $0 = !0, N0.session)
          E0(), A0 = ((L1 = N0.session) === null || L1 === void 0 ? void 0 : L1.environmentBlendMode) === "alpha-blend", u0();
        else
          V0();
        P2(), q0.isPresenting.next(!!N0.session);
      })
    ], a0 = !0;
    function D1(L1) {
      let q2 = G8, s2 = V2.Empty;
      if (L1) {
        let d0 = Y0.camera.getLoci(L1);
        if (d0 !== G8)
          return { loci: d0, repr: s2 };
        q2 = Y0.handle.getLoci(L1), R.forEach((d1, A2) => {
          let B8 = A2.getLoci(L1);
          if (!_7(B8)) {
            if (!_7(q2))
              console.warn("found another loci, this should not happen");
            q2 = B8, s2 = A2;
          }
        });
      }
      return { loci: q2, repr: s2 };
    }
    let Y1 = [];
    function u1(L1, q2) {
      Y1.push([L1, q2]);
    }
    function b0() {
      let L1 = !1;
      for (let [q2, s2] of Y1)
        L1 = x0(q2, s2) || L1;
      if (Y1 = [], L1)
        b.update(void 0, !0), Y0.handle.scene.update(void 0, !0), Y0.camera.scene.update(void 0, !0), l.updateRequired(F), l.finalizeRequired(!0), A.next();
      return L1;
    }
    function x0(L1, q2) {
      let { repr: s2, loci: d0 } = L1, d1 = !1;
      if (s2)
        d1 = s2.mark(d0, q2) || d1;
      else
        R.forEach((A2, B8) => {
          d1 = B8.mark(d0, q2) || d1;
        });
      return d1 = Y0.handle.mark(d0, q2) || d1, d1 = Y0.camera.mark(d0, q2) || d1, d1;
    }
    let m0 = null;
    function e0(L1, q2) {
      if (K.isContextLost)
        return !1;
      if (K.xr.session && !q2)
        return !1;
      let s2 = !1;
      if ($0)
        I1(!1), $0 = !1, s2 = !0;
      let d0 = K.getDrawingBufferSize();
      if (I > d0.width || I + f < 0 || S > d0.height || S + v < 0)
        return !1;
      if (m0 !== null && !q2)
        if (K.checkSyncStatus(m0))
          m0 = null;
        else
          return !1;
      if (q2)
        u0(), F.transparentBackground = A0;
      let d1 = b0() && (n.props.colorMarker || F.marking.enabled), A2 = !1;
      r.update(x);
      let B8 = m.update(), Z6 = N0.update(q2);
      if (!Z6 && q2)
        return !1;
      let t6 = L1 || B8 || s2 || h || Z6;
      if (h = !1, H.illumination.supported && F.illumination.enabled && !q2) {
        if (t6 || d1)
          n.setOcclusionTest(null), H.illumination.restart();
        if (H.illumination.shouldRender(F.illumination) && (!p8 && b.count > 0 || H.illumination.iteration === 0 || F.userInteractionReleaseMs === 0)) {
          if (K1)
            K.timer.mark("Canvas3D.render", { captureStats: !0 });
          let D2 = { renderer: n, camera: m, scene: b, helper: Y0 };
          if (H.illumination.render(D2, F, !0), K1)
            K.timer.markEnd("Canvas3D.render");
          G0.dirty = G0.dirty || t6, A2 = !0;
        }
      } else {
        let D2 = Z0.update(d1 || t6, F.multiSample) && !q2;
        if (t6 || D2 || d1) {
          n.setOcclusionTest(c.isOccluded);
          let vZ = m;
          if (F.camera.stereo.name === "on" || Z6) {
            if (!Z6)
              i.update();
            vZ = i;
          }
          if (K1)
            K.timer.mark("Canvas3D.render", { captureStats: !0 });
          let c6 = { renderer: n, camera: vZ, scene: b, helper: Y0 };
          if (eR.isEnabled(F.multiSample) && !q2) {
            let HZ = F.multiSample.reduceFlicker && !B8 && d1 && !r.isAnimating;
            Z0.render(c6, F, !0, HZ);
          } else
            H.draw.render(c6, F, !0);
          if (c.render(m), K1)
            K.timer.markEnd("Canvas3D.render");
          G0.dirty = G0.dirty || t6, A2 = !0;
        }
      }
      if (A2 && !q2)
        m0 = K.getFenceSync();
      return A2;
    }
    let p = !1, J0 = !1, T0 = !1;
    function o0(L1) {
      if (J0 || T0)
        return;
      if (!l.finalizeRequired(L1 === null || L1 === void 0 ? void 0 : L1.isSynchronous)) {
        h = !0;
        return;
      }
      if (e0(!!(L1 === null || L1 === void 0 ? void 0 : L1.force), L1 === null || L1 === void 0 ? void 0 : L1.xrFrame) && a0)
        T.next(m6() - B);
    }
    function y0() {
      h = !0;
    }
    let $1 = 0;
    function F1(L1, q2) {
      if (T0)
        return;
      if (K.xr.session && !(q2 === null || q2 === void 0 ? void 0 : q2.xrFrame))
        return;
      if (x = L1, n8(q2 === null || q2 === void 0 ? void 0 : q2.isSynchronous), q2 === null || q2 === void 0 ? void 0 : q2.updateControls)
        r.update(x);
      if (m.transition.tick(x), c.tick(), q2 === null || q2 === void 0 ? void 0 : q2.manualDraw)
        return;
      if (o0({ isSynchronous: q2 === null || q2 === void 0 ? void 0 : q2.isSynchronous, xrFrame: q2 === null || q2 === void 0 ? void 0 : q2.xrFrame }), !m.transition.inTransition && !K.isContextLost)
        t.tick(x);
    }
    let A1 = void 0;
    function P1(L1) {
      return A1 = L1, K.xr.session ? K.xr.session.requestAnimationFrame(L1) : tF1(L1);
    }
    function S1(L1) {
      A1 = void 0, K.xr.session ? K.xr.session.cancelAnimationFrame(L1) : Ij0(L1);
    }
    function _1(L1, q2) {
      F1(m6(), { xrFrame: q2 }), $1 = P1(_1);
    }
    function a1(L1) {
      B = L1, r.start(L1);
    }
    function U2() {
      if (J0 = !1, r.start(m6()), $1 === 0)
        _1(0);
    }
    function G2(L1 = !1) {
      if (J0 = L1, $1 !== 0)
        S1($1), $1 = 0;
    }
    function P2() {
      if (J0 = !1, A1)
        P1(A1);
    }
    function v2(L1) {
      if (K.isContextLost)
        return;
      if (l.finalize(["pick"], !0), "origin" in L1)
        return F0.identify(L1, m);
      else {
        let q2 = F.camera.stereo.name === "on" ? i : m;
        return G0.identify(L1[0], L1[1], q2);
      }
    }
    function O8(L1) {
      if (K.isContextLost)
        return;
      if (l.finalize(["pick"], !0), "origin" in L1)
        return F0.asyncIdentify(L1, m);
      else {
        let q2 = F.camera.stereo.name === "on" ? i : m;
        return G0.asyncIdentify(L1[0], L1[1], q2);
      }
    }
    function n8(L1 = !1) {
      let q2 = l0(L1);
      if (l.updateRequired(F), q2) {
        if (z6(), p) {
          if (Y0.debug.isEnabled)
            Y0.debug.update();
          o0({ force: !0 }), p = !1;
        }
        w.next(m6());
      }
    }
    function z6() {
      if (!U0)
        return;
      if (!q0.isPresenting.value)
        N0.resetScale();
      let L1 = b.boundingSphereVisible, { center: q2, radius: s2 } = L1, d0 = r.props.autoAdjustMinMaxDistance;
      if (d0.name === "on") {
        let d1 = d0.params.minDistanceFactor * s2 + d0.params.minDistancePadding, A2 = Math.max(d0.params.maxDistanceFactor * s2, d0.params.maxDistanceMin);
        r.setProps({ minDistance: d1, maxDistance: A2 });
      }
      if (s2 > 0) {
        let d1 = a === void 0 ? F.cameraResetDurationMs : a, A2 = m.getFocus(q2, s2), B8 = typeof Q0 === "function" ? Q0(b, m) : Q0, Z6 = B8 ? { ...A2, ...B8 } : A2;
        m.setState({ ...Z6, radiusMax: g() }, d1);
      }
      a = void 0, Q0 = void 0, U0 = !1;
    }
    let L8 = C0(), R8 = C0();
    function w0() {
      if (m.state.radiusMax === 0)
        return !0;
      if (m.transition.inTransition || Q0)
        return !1;
      let L1 = !0, q2 = !0;
      C0.set(R8, m.state.target, m.state.radius);
      for (let s2 of b.renderables) {
        if (!s2.state.visible)
          continue;
        let d0 = s2.values.boundingSphere.ref.value;
        if (!d0.radius)
          continue;
        q2 = !1;
        let d1 = M.distance(R8.center, d0.center);
        if ((d1 > R8.radius || d1 > d0.radius || d0.radius > m.state.radiusMax) && !C0.includes(L8, d0))
          return !0;
        if (C0.overlaps(R8, d0))
          L1 = !1;
      }
      return L1 || !q2 && R8.radius <= 0.1;
    }
    let P0 = 250;
    function l0(L1) {
      if (!b.needsCommit)
        return !0;
      if (C0.copy(L8, b.boundingSphereVisible), c.clear(), !b.commit(L1 ? void 0 : P0))
        return V.next(b.commitQueueSize), !1;
      if (V.next(0), Y0.debug.isEnabled)
        Y0.debug.update();
      if (!F.camera.manualReset && (D.value === 0 || w0()))
        U0 = !0;
      if (L8.radius === 0)
        a = 0;
      if (!F.camera.manualReset)
        m.setState({ radiusMax: g() }, 0);
      if (D.next(R.size), y2)
        z1();
      return !0;
    }
    function z1() {
      let L1 = b.renderables.map((Z6) => ({
        drawCount: Z6.values.drawCount.ref.value,
        instanceCount: Z6.values.instanceCount.ref.value,
        materialId: Z6.materialId,
        renderItemId: Z6.id,
        geometryType: Z6.values.dGeometryType.ref.value,
        "byteCount [MiB]": zH0(Z6.getByteCount() / 1024 / 1024, 3)
      }));
      if (console.groupCollapsed(`${L1.length} RenderItems`), L1.length <= 64)
        console.table(L1);
      else
        console.log(L1);
      console.log(JSON.stringify(K.stats, void 0, 4));
      let { texture: q2, cubeTexture: s2, attribute: d0, elements: d1, pixelPack: A2, renderbuffer: B8 } = K.resources.getByteCounts();
      if (console.log(JSON.stringify({
        texture: `${(q2 / 1024 / 1024).toFixed(3)} MiB`,
        cubeTexture: `${(s2 / 1024 / 1024).toFixed(3)} MiB`,
        attribute: `${(d0 / 1024 / 1024).toFixed(3)} MiB`,
        elements: `${(d1 / 1024 / 1024).toFixed(3)} MiB`,
        pixelPack: `${(A2 / 1024 / 1024).toFixed(3)} MiB`,
        renderbuffer: `${(B8 / 1024 / 1024).toFixed(3)} MiB`
      }, void 0, 4)), console.log(JSON.stringify({
        renderables: `${(b.renderables.reduce((Z6, t6) => Z6 + t6.getByteCount(), 0) / 1024 / 1024).toFixed(3)} MiB`,
        passes: {
          draw: `${(H.draw.getByteCount() / 1024 / 1024).toFixed(3)} MiB`,
          illumination: `${(H.illumination.getByteCount() / 1024 / 1024).toFixed(3)} MiB`,
          pick: `${(H.pick.getByteCount() / 1024 / 1024).toFixed(3)} MiB`,
          hiZ: `${(c.getByteCount() / 1024 / 1024).toFixed(3)} MiB`
        }
      }, void 0, 4)), K1)
        console.log(JSON.stringify(K.timer.formatedStats(), void 0, 4));
      console.groupEnd();
    }
    function J2(L1) {
      X8(L1);
      let q2 = R.get(L1), s2 = /* @__PURE__ */ new Set;
      if (L1.renderObjects.forEach((d0) => s2.add(d0)), q2) {
        if (!uZ.areEqual(s2, q2))
          s2.forEach((d0) => {
            if (!q2.has(d0))
              b.add(d0);
          }), q2.forEach((d0) => {
            if (!s2.has(d0))
              b.remove(d0);
          });
      } else
        L1.renderObjects.forEach((d0) => b.add(d0));
      if (R.set(L1, s2), b.update(L1.renderObjects, !1), p = !0, y2)
        z1();
    }
    function N2(L1) {
      c0(L1);
      let q2 = R.get(L1);
      if (q2) {
        if (q2.forEach((s2) => b.remove(s2)), R.delete(L1), p = !0, y2)
          z1();
      }
    }
    function X8(L1) {
      if (z.has(L1))
        return;
      z.set(L1, L1.updated.subscribe((q2) => {
        if (!L1.state.syncManually)
          J2(L1);
      }));
    }
    function c0(L1) {
      let q2 = z.get(L1);
      if (q2)
        q2.unsubscribe(), z.delete(L1);
    }
    function M1() {
      let L1 = b.boundingSphere.radius > 0 ? 100 - Math.round(m.transition.target.radius / g() * 100) : 0;
      return {
        camera: {
          mode: m.state.mode,
          helper: { ...Y0.camera.props },
          stereo: { ...F.camera.stereo },
          fov: Math.round(k$(m.state.fov)),
          manualReset: !!F.camera.manualReset
        },
        cameraFog: m.state.fog > 0 ? { name: "on", params: { intensity: m.state.fog } } : { name: "off", params: {} },
        cameraClipping: {
          far: m.state.clipFar,
          radius: L1,
          minNear: m.state.minNear
        },
        cameraResetDurationMs: F.cameraResetDurationMs,
        sceneRadiusFactor: F.sceneRadiusFactor,
        transparentBackground: F.transparentBackground,
        checkeredTransparentBackground: F.checkeredTransparentBackground,
        dpoitIterations: F.dpoitIterations,
        pickPadding: F.pickPadding,
        userInteractionReleaseMs: F.userInteractionReleaseMs,
        viewport: F.viewport,
        postprocessing: { ...F.postprocessing },
        marking: { ...F.marking },
        multiSample: { ...F.multiSample },
        illumination: { ...F.illumination },
        hiZ: { ...c.props },
        renderer: { ...n.props },
        trackball: { ...r.props },
        interaction: { ...t.props },
        debug: { ...Y0.debug.props },
        handle: { ...Y0.handle.props },
        pointer: { ...Y0.pointer.props },
        xr: { ...N0.props }
      };
    }
    let g1 = U === null || U === void 0 ? void 0 : U.subscribe(() => {
      T0 = !0, m0 = null, G0.dirty = !0;
    }), l2 = P.subscribe(() => {
      G0.reset(), F0.reset(), c.reset(), b.forEach((L1) => {
        var q2;
        if ((q2 = L1.values.meta) === null || q2 === void 0 ? void 0 : q2.ref.value.reset)
          L1.values.meta.ref.value.reset(), L1.update();
      }), T0 = !1, o0({ force: !0 }), o0({ force: !0 });
    }), d8 = new G$(0);
    function I1(L1 = !0) {
      if (H.updateSize(), v6(), AZ(), L1)
        y0();
      d8.next(+/* @__PURE__ */ new Date);
    }
    t50(z1);
    let W2 = (W = $.changed) === null || W === void 0 ? void 0 : W.subscribe(() => {
      b.setTransparency(H.draw.transparency), y0();
    }), z2 = !1, p8 = !1, W6 = [
      G.drag.subscribe(() => {
        z2 = !0;
      }),
      G.interactionEnd.subscribe(() => {
        z2 = !1;
      }),
      O5(G.drag, G.pinch, G.wheel, G.interactionEnd).subscribe(() => {
        A.next();
      }),
      A.subscribe(() => {
        p8 = !0;
      }),
      A.pipe(QR(F.userInteractionReleaseMs)).subscribe(() => {
        if (p8 = z2, !z2 && H.illumination.supported && F.illumination.enabled)
          y0();
      })
    ];
    if (y2 && q) {
      let L1 = void 0, q2 = (s2) => {
        let d0 = s2 && d2.getBoundingSphere(d2.normalize(s2, "residue"));
        c.debugOcclusion(d0);
      };
      G.click.subscribe((s2) => {
        if (!s2.modifiers.control || s2.button !== 2)
          return;
        let d0 = v2(h0.create(s2.x, s2.y));
        if (!d0) {
          L1 = void 0, q2(L1);
          return;
        }
        L1 = D1(d0.id).loci, q2(L1);
      }), T.subscribe(() => {
        setTimeout(() => {
          q2(L1);
        }, 100);
      });
    }
    return {
      webgl: K,
      add: J2,
      remove: N2,
      commit: n8,
      update: (L1, q2) => {
        if (L1) {
          if (!R.has(L1))
            return;
          b.update(L1.renderObjects, !!q2);
        } else
          b.update(void 0, !!q2);
        p = !0;
      },
      clear: () => {
        if (z.forEach((L1) => L1.unsubscribe()), z.clear(), R.clear(), b.clear(), Y0.debug.clear(), m0 !== null)
          K.deleteSync(m0), m0 = null;
        y0(), D.next(R.size);
      },
      syncVisibility: () => {
        if (m.state.radiusMax === 0)
          U0 = !0, a = 0;
        if (b.syncVisibility()) {
          if (Y0.debug.isEnabled)
            Y0.debug.update();
        }
        y0();
      },
      requestDraw: y0,
      tick: F1,
      animate: U2,
      resetTime: a1,
      pause: G2,
      resume: P2,
      requestAnimationFrame: P1,
      cancelAnimationFrame: S1,
      identify: v2,
      asyncIdentify: O8,
      mark: u1,
      getLoci: D1,
      handleResize: I1,
      requestResize: () => {
        $0 = !0;
      },
      requestCameraReset: (L1) => {
        a = L1 === null || L1 === void 0 ? void 0 : L1.durationMs, Q0 = L1 === null || L1 === void 0 ? void 0 : L1.snapshot, U0 = !0;
      },
      camera: m,
      boundingSphere: b.boundingSphere,
      boundingSphereVisible: b.boundingSphereVisible,
      get notifyDidDraw() {
        return a0;
      },
      set notifyDidDraw(L1) {
        a0 = L1;
      },
      didDraw: T,
      commited: w,
      commitQueueSize: V,
      reprCount: D,
      resized: d8,
      setProps: (L1, q2 = !1) => {
        var s2, d0, d1, A2, B8, Z6, t6;
        let D2 = typeof L1 === "function" ? WQ(M1(), L1) : L1;
        if (D2.sceneRadiusFactor !== void 0)
          F.sceneRadiusFactor = D2.sceneRadiusFactor, m.setState({ radiusMax: g() }, 0);
        let vZ = Object.create(null);
        if (D2.camera && D2.camera.mode !== void 0 && D2.camera.mode !== m.state.mode)
          vZ.mode = D2.camera.mode;
        let c6 = Math.round(k$(m.state.fov));
        if (D2.camera && D2.camera.fov !== void 0 && D2.camera.fov !== c6)
          vZ.fov = _8(D2.camera.fov);
        if (D2.cameraFog !== void 0 && D2.cameraFog.params) {
          let HZ = D2.cameraFog.name === "on" ? D2.cameraFog.params.intensity : 0;
          if (HZ !== m.state.fog)
            vZ.fog = HZ;
        }
        if (D2.cameraClipping !== void 0) {
          if (D2.cameraClipping.far !== void 0 && D2.cameraClipping.far !== m.state.clipFar)
            vZ.clipFar = D2.cameraClipping.far;
          if (D2.cameraClipping.minNear !== void 0 && D2.cameraClipping.minNear !== m.state.minNear)
            vZ.minNear = D2.cameraClipping.minNear;
          if (D2.cameraClipping.radius !== void 0) {
            let HZ = g() / 100 * (100 - D2.cameraClipping.radius);
            if (HZ > 0 && HZ !== vZ.radius)
              vZ.radius = Math.max(HZ, 0.01);
          }
        }
        if (Object.keys(vZ).length > 0)
          m.setState(vZ);
        if ((s2 = D2.camera) === null || s2 === void 0 ? void 0 : s2.helper)
          Y0.camera.setProps(D2.camera.helper);
        if (((d0 = D2.camera) === null || d0 === void 0 ? void 0 : d0.manualReset) !== void 0)
          F.camera.manualReset = D2.camera.manualReset;
        if (((d1 = D2.camera) === null || d1 === void 0 ? void 0 : d1.stereo) !== void 0)
          Object.assign(F.camera.stereo, D2.camera.stereo), i.setProps(F.camera.stereo.params);
        if (D2.cameraResetDurationMs !== void 0)
          F.cameraResetDurationMs = D2.cameraResetDurationMs;
        if (D2.transparentBackground !== void 0)
          F.transparentBackground = D2.transparentBackground;
        if (D2.checkeredTransparentBackground !== void 0)
          F.checkeredTransparentBackground = D2.checkeredTransparentBackground;
        if (D2.dpoitIterations !== void 0)
          F.dpoitIterations = D2.dpoitIterations;
        if (D2.pickPadding !== void 0)
          F.pickPadding = D2.pickPadding, G0.setPickPadding(F.pickPadding);
        if (D2.userInteractionReleaseMs !== void 0)
          F.userInteractionReleaseMs = D2.userInteractionReleaseMs;
        if (D2.viewport !== void 0) {
          if (!(F.viewport === D2.viewport || F.viewport.name === D2.viewport.name && xO(F.viewport.params, D2.viewport.params)))
            F.viewport = D2.viewport, v6(), AZ();
        }
        if ((A2 = D2.postprocessing) === null || A2 === void 0 ? void 0 : A2.background)
          Object.assign(F.postprocessing.background, D2.postprocessing.background), H.draw.postprocessing.background.update(m, F.postprocessing.background, (HZ) => {
            if (HZ && !q2)
              y0();
          });
        if (D2.postprocessing)
          Object.assign(F.postprocessing, D2.postprocessing);
        if (D2.marking)
          Object.assign(F.marking, D2.marking);
        if (D2.illumination)
          Object.assign(F.illumination, D2.illumination);
        if (D2.multiSample)
          Object.assign(F.multiSample, D2.multiSample);
        if (D2.hiZ)
          c.setProps(D2.hiZ);
        if (D2.renderer)
          b.setGlobals({
            dColorMarker: (B8 = D2.renderer.colorMarker) !== null && B8 !== void 0 ? B8 : n.props.colorMarker,
            dLightCount: (t6 = (Z6 = D2.renderer.light) === null || Z6 === void 0 ? void 0 : Z6.length) !== null && t6 !== void 0 ? t6 : n.props.light.length
          }), n.setProps(D2.renderer);
        if (D2.trackball)
          r.setProps(D2.trackball);
        if (D2.interaction)
          t.setProps(D2.interaction);
        if (D2.debug)
          Y0.debug.setProps(D2.debug);
        if (D2.handle)
          Y0.handle.setProps(D2.handle);
        if (D2.pointer)
          Y0.pointer.setProps(D2.pointer);
        if (D2.xr)
          N0.setProps(D2.xr);
        if (vZ.mode === "orthographic")
          F.camera.stereo.name = "off";
        if ("transparentBackground" in D2 || "checkeredTransparentBackground" in D2 || D2.renderer && "backgroundColor" in D2.renderer)
          Pj0(q, F);
        if (l.updateRequired(F), !q2)
          y0();
      },
      setAttribs: (L1) => {
        if (L1.trackball)
          r.setAttribs(L1.trackball);
        if (L1.xr)
          N0.setAttribs(L1.xr);
      },
      getImagePass: (L1 = {}) => {
        return new xe(K, N, n, b, m, Y0, L1);
      },
      getRenderObjects() {
        let L1 = [];
        return b.forEach((q2, s2) => L1.push(s2)), L1;
      },
      get props() {
        return M1();
      },
      get attribs() {
        return {
          trackball: r.attribs,
          xr: N0.attribs
        };
      },
      get input() {
        return G;
      },
      get stats() {
        return n.stats;
      },
      get interaction() {
        return t.events;
      },
      xr: q0,
      dispose: () => {
        g1 === null || g1 === void 0 || g1.unsubscribe(), l2.unsubscribe(), W2 === null || W2 === void 0 || W2.unsubscribe();
        for (let L1 of S0)
          L1.unsubscribe();
        S0.length = 0;
        for (let L1 of W6)
          L1.unsubscribe();
        if (W6.length = 0, Ij0($1), A1 = void 0, Y1 = [], b.clear(), Y0.debug.clear(), r.dispose(), n.dispose(), t.dispose(), c.dispose(), G0.dispose(), F0.dispose(), N0.dispose(), m0 !== null)
          K.deleteSync(m0), m0 = null;
        D.complete(), A.complete(), T.complete(), d8.complete(), w.complete(), V.complete(), q0.isPresenting.complete(), q0.isSupported.complete(), q0.requestFailed.complete(), e50(z1);
      }
    };
    function v6() {
      let L1 = I, q2 = S, s2 = f, d0 = v, d1 = K.getDrawingBufferSize();
      if (F.viewport.name === "canvas")
        I = 0, S = 0, f = d1.width, v = d1.height;
      else if (F.viewport.name === "static-frame")
        I = F.viewport.params.x * K.pixelRatio, v = F.viewport.params.height * K.pixelRatio, S = d1.height - v - F.viewport.params.y * K.pixelRatio, f = F.viewport.params.width * K.pixelRatio;
      else if (F.viewport.name === "relative-frame")
        I = Math.round(F.viewport.params.x * d1.width), v = Math.round(F.viewport.params.height * d1.height), S = Math.round(d1.height - v - F.viewport.params.y * d1.height), f = Math.round(F.viewport.params.width * d1.width);
      if (L1 !== I || q2 !== S || s2 !== f || d0 !== v)
        h = !0;
    }
    function AZ() {
      G0.setViewport(I, S, f, v), n.setViewport(I, S, f, v), bZ.set(m.viewport, I, S, f, v), bZ.set(r.viewport, I, S, f, v), c.setViewport(I, S, f, v);
    }
  }
  Z.create = J;
})(Bx || (Bx = {}));

// node_modules/molstar/lib/mol-plugin-state/component.js
class Oq {
  constructor() {
    this.subs = void 0;
  }
  subscribe(Z, J) {
    if (!Z)
      return { unsubscribe: () => {} };
    if (typeof this.subs === "undefined")
      this.subs = [];
    let $ = Z.subscribe(J);
    return this.subs.push($), {
      unsubscribe: () => {
        if ($ && this.subs && L3(this.subs, $))
          $.unsubscribe(), $ = void 0;
      }
    };
  }
  get ev() {
    return this._ev || (this._ev = xQ.create());
  }
  dispose() {
    if (this._ev)
      this._ev.dispose();
    if (this.subs) {
      for (let Z of this.subs)
        Z.unsubscribe();
      this.subs = void 0;
    }
  }
}

class pX extends Oq {
  updateState(...Z) {
    let J = this.state, $ = u50(J, Z);
    if ($ !== J)
      return this._state = $, !0;
    return !1;
  }
  get state() {
    return this._state;
  }
  constructor(Z) {
    super();
    this._state = Z;
  }
}
// node_modules/molstar/lib/mol-plugin/behavior/static/state.js
var ae = {};
y9(ae, {
  setSubtreeVisibility: () => _H,
  registerDefault: () => $U1,
  Update: () => bj0,
  ToggleVisibility: () => mj0,
  ToggleExpanded: () => gj0,
  SyncBehaviors: () => fj0,
  Snapshots: () => uj0,
  SetCurrentObject: () => hj0,
  RemoveObject: () => yj0,
  Highlight: () => dj0,
  ClearHighlights: () => pj0,
  ApplyAction: () => xj0
});

// node_modules/molstar/lib/mol-plugin/version.js
var wx = "5.5.0", Cj0 = /* @__PURE__ */ new Date(1766404231865);

// node_modules/molstar/lib/mol-canvas3d/util.js
function eF1(Z, J, $, X = 1) {
  Z.width = Math.round(window.devicePixelRatio * X * J), Z.height = Math.round(window.devicePixelRatio * X * $), Object.assign(Z.style, { width: `${J}px`, height: `${$}px` });
}
function kj0(Z, J, $ = 1) {
  let { innerWidth: X, innerHeight: Y } = window;
  if (J !== document.body)
    X = J.offsetWidth, Y = J.offsetHeight;
  eF1(Z, X, Y, $);
}
function ZU1(Z, J, $, X) {
  let Y = atob(Z.toDataURL($, X).split(",")[1]), Q = Y.length, W = Q >> 2, K = new Uint8Array(Q), G = new Uint32Array(K.buffer, 0, W), H = 0;
  for (let q = 0;q < W; ++q)
    G[q] = Y.charCodeAt(H++) | Y.charCodeAt(H++) << 8 | Y.charCodeAt(H++) << 16 | Y.charCodeAt(H++) << 24;
  let N = Q & 3;
  while (N--)
    K[H] = Y.charCodeAt(H++);
  J(new Blob([K], { type: $ || "image/png" }));
}
async function HI(Z, J, $) {
  return new Promise((X, Y) => {
    let Q = (W) => {
      if (W)
        X(W);
      else
        Y("no blob returned");
    };
    if (!HTMLCanvasElement.prototype.toBlob)
      ZU1(Z, Q, J, $);
    else
      Z.toBlob(Q, J, $);
  });
}

// node_modules/molstar/lib/mol-util/single-task-queue.js
class se {
  constructor() {
    this.queue = [];
  }
  run(Z) {
    if (this.queue.length < 2)
      this.queue.push(Z);
    else
      this.queue[this.queue.length - 1] = Z;
    if (this.queue.length === 1)
      this.next();
  }
  async next() {
    while (this.queue.length > 0)
      try {
        let Z = this.queue[0];
        await Z();
      } catch (Z) {
        console.error("Error in SingleTaskQueue execution:", Z);
      } finally {
        this.queue.shift();
      }
  }
}

// node_modules/molstar/lib/mol-plugin-state/manager/snapshots.js
class EQ extends pX {
  updateState(Z) {
    if ("current" in Z && !("currentAnimationTimeMs" in Z))
      return super.updateState({ ...Z, currentAnimationTimeMs: 0 });
    else
      return super.updateState(Z);
  }
  get current() {
    let Z = this.state.current;
    return this.state.entries.find((J) => J.snapshot.id === Z);
  }
  getIndex(Z) {
    return this.state.entries.indexOf(Z);
  }
  getEntry(Z) {
    if (!Z)
      return;
    return this.entryMap.get(Z);
  }
  remove(Z) {
    let J = this.entryMap.get(Z);
    if (!J)
      return;
    if (J === null || J === void 0 ? void 0 : J.image)
      this.plugin.managers.asset.delete(J.image);
    this.entryMap.delete(Z), this.updateState({
      current: this.state.current === Z ? void 0 : this.state.current,
      entries: this.state.entries.delete(this.getIndex(J))
    }), this.events.changed.next(void 0);
  }
  add(Z) {
    this.entryMap.set(Z.snapshot.id, Z), this.updateState({ current: Z.snapshot.id, entries: this.state.entries.push(Z) }), this.events.changed.next(void 0);
  }
  replace(Z, J, $) {
    var X, Y, Q, W;
    let K = this.getEntry(Z);
    if (!K)
      return;
    if (this.defaultSnapshotId = void 0, K === null || K === void 0 ? void 0 : K.image)
      this.plugin.managers.asset.delete(K.image);
    let G = this.getIndex(K), H = EQ.Entry(J, {
      key: (X = $ === null || $ === void 0 ? void 0 : $.key) !== null && X !== void 0 ? X : K.key,
      name: (Y = $ === null || $ === void 0 ? void 0 : $.name) !== null && Y !== void 0 ? Y : K.name,
      description: (Q = $ === null || $ === void 0 ? void 0 : $.description) !== null && Q !== void 0 ? Q : K.description,
      descriptionFormat: (W = $ === null || $ === void 0 ? void 0 : $.descriptionFormat) !== null && W !== void 0 ? W : K.descriptionFormat,
      image: $ === null || $ === void 0 ? void 0 : $.image
    });
    this.entryMap.set(J.id, H), this.updateState({ current: H.snapshot.id, entries: this.state.entries.set(G, H) }), this.events.changed.next(void 0);
  }
  move(Z, J) {
    let $ = this.state.entries.size;
    if ($ < 2)
      return;
    let X = this.getEntry(Z);
    if (!X)
      return;
    let Y = this.getIndex(X), Q = (Y + J) % $;
    if (Q < 0)
      Q += $;
    let W = this.state.entries.get(Q), K = this.state.entries.asMutable();
    K.set(Q, X), K.set(Y, W), this.updateState({ current: X.snapshot.id, entries: K.asImmutable() }), this.events.changed.next(void 0);
  }
  update(Z, J) {
    var $, X, Y;
    let Q = this.getIndex(Z);
    if (Q < 0)
      return;
    let W = this.state.entries.set(Q, {
      ...Z,
      key: (($ = J.key) === null || $ === void 0 ? void 0 : $.trim()) || void 0,
      name: ((X = J.name) === null || X === void 0 ? void 0 : X.trim()) || void 0,
      description: ((Y = J.description) === null || Y === void 0 ? void 0 : Y.trim()) || void 0,
      descriptionFormat: J.descriptionFormat
    });
    this.updateState({ entries: W }), this.entryMap.set(Z.snapshot.id, this.state.entries.get(Q)), this.events.changed.next(void 0);
  }
  clear() {
    if (this.state.entries.size === 0)
      return;
    this.entryMap.forEach((Z) => {
      if (Z === null || Z === void 0 ? void 0 : Z.image)
        this.plugin.managers.asset.delete(Z.image);
    }), this.entryMap.clear(), this.updateState({ current: void 0, entries: jN() }), this.events.changed.next(void 0);
  }
  applyKey(Z) {
    let J = this.state.entries.find(($) => $.key === Z);
    if (!J)
      return;
    this.updateState({ current: J.snapshot.id }), this.events.changed.next(void 0), this.plugin.state.setSnapshot(J.snapshot);
  }
  setCurrent(Z) {
    let J = this.getEntry(Z);
    if (J)
      this.updateState({ current: Z }), this.events.changed.next(void 0);
    return J && J.snapshot;
  }
  setSnapshotAnimationFrame(Z, J = !1) {
    var $;
    let X = this.getEntry(this.state.current);
    if (!X)
      return;
    let Y = ($ = uX.getStateTransitionFrameIndex(X.snapshot, Z)) !== null && $ !== void 0 ? $ : 0;
    if (this.updateState({ currentAnimationTimeMs: Z }))
      this.events.changed.next(void 0);
    if (J)
      this.animationFrameQueue.run(() => {
        return this.plugin.state.setAnimationSnapshot(X.snapshot, Y !== null && Y !== void 0 ? Y : 0);
      });
    return Y;
  }
  getNextId(Z, J) {
    let $ = this.state.entries.size;
    if (!Z) {
      if ($ === 0)
        return;
      let Q = J === -1 ? $ - 1 : 0;
      return this.state.entries.get(Q).snapshot.id;
    }
    let X = this.getEntry(Z);
    if (!X)
      return;
    let Y = this.getIndex(X);
    if (Y < 0)
      return;
    if (Y = (Y + J) % $, Y < 0)
      Y += $;
    return this.state.entries.get(Y).snapshot.id;
  }
  applyNext(Z) {
    let J = this.getNextId(this.state.current, Z);
    if (J) {
      let $ = this.setCurrent(J);
      if ($)
        return this.plugin.state.setSnapshot($);
    }
  }
  async setStateSnapshot(Z) {
    var J;
    this.clear();
    let $ = jN().asMutable();
    for (let W of Z.entries)
      this.entryMap.set(W.snapshot.id, W), $.push(W);
    let X = Z.current ? Z.current : Z.entries.length > 0 ? Z.entries[0].snapshot.id : void 0;
    if (this.updateState({
      current: X,
      entries: $.asImmutable(),
      isPlaying: !1,
      nextSnapshotDelayInMs: Z.playback ? Z.playback.nextSnapshotDelayInMs : EQ.DefaultNextSnapshotDelayInMs
    }), this.events.changed.next(void 0), !X)
      return;
    let Y = this.getEntry(X), Q = Y && Y.snapshot;
    if (!Q)
      return;
    if (await this.plugin.state.setSnapshot(Q), (J = Z.playback) === null || J === void 0 ? void 0 : J.isPlaying)
      this.play({ delayFirst: !0 });
    return Q;
  }
  async syncCurrent(Z) {
    var J, $;
    let X = this.state.entries.size === 0, Y = this.state.entries.size === 1 && this.state.current && (!this.defaultSnapshotId || this.state.current === this.defaultSnapshotId);
    if (!X && !Y)
      return;
    let Q = this.plugin.state.getSnapshot(Z === null || Z === void 0 ? void 0 : Z.params), W = (($ = (J = Z === null || Z === void 0 ? void 0 : Z.params) === null || J === void 0 ? void 0 : J.image) !== null && $ !== void 0 ? $ : this.plugin.state.snapshotParams.value.image) ? await EQ.getCanvasImageAsset(this.plugin, `${Q.id}-image.png`) : void 0;
    if (X)
      this.add(EQ.Entry(Q, { name: Z === null || Z === void 0 ? void 0 : Z.name, description: Z === null || Z === void 0 ? void 0 : Z.description, descriptionFormat: Z === null || Z === void 0 ? void 0 : Z.descriptionFormat, image: W }));
    else if (Y) {
      let K = this.getEntry(this.state.current);
      if (K === null || K === void 0 ? void 0 : K.image)
        this.plugin.managers.asset.delete(K.image);
      this.replace(this.state.current, Q, { image: W });
    }
    this.defaultSnapshotId = Q.id;
  }
  async getStateSnapshot(Z) {
    await this.syncCurrent(Z);
    let J = this.state.entries.valueSeq().toArray();
    for (let $ = 0;$ < J.length; $++) {
      if (!J[$]._transientData)
        continue;
      J[$] = { ...J[$] }, delete J[$]._transientData;
    }
    return {
      timestamp: +/* @__PURE__ */ new Date,
      version: wx,
      name: Z && Z.name,
      description: Z && Z.description,
      current: this.state.current,
      playback: {
        isPlaying: !!(Z && Z.playOnLoad),
        nextSnapshotDelayInMs: this.state.nextSnapshotDelayInMs
      },
      entries: J
    };
  }
  async serialize(Z) {
    let J = JSON.stringify(await this.getStateSnapshot({ params: Z === null || Z === void 0 ? void 0 : Z.params }), null, 2);
    if (!(Z === null || Z === void 0 ? void 0 : Z.type) || Z.type === "json" || Z.type === "molj")
      return new Blob([J], { type: "application/json;charset=utf-8" });
    else {
      let $ = new Uint8Array(AM(J));
      sL($, 0, J);
      let X = {
        "state.json": $
      }, Y = [];
      for (let { asset: W, file: K } of this.plugin.managers.asset.assets)
        Y.push([W.id, W]), X[`assets/${W.id}`] = new Uint8Array(await K.arrayBuffer());
      if (Y.length > 0) {
        let W = JSON.stringify(Y, null, 2), K = new Uint8Array(AM(W));
        sL(K, 0, W), X["assets.json"] = K;
      }
      let Q = await this.plugin.runTask(jK0(X));
      return new Blob([Q], { type: "application/zip" });
    }
  }
  async open(Z) {
    try {
      let J = Z.name.toLowerCase();
      if (J.endsWith("json") || J.endsWith("molj")) {
        let $ = await this.plugin.runTask(SN(Z, "string")), X = JSON.parse(oL.toString($));
        if (EQ.isStateSnapshot(X))
          await this.setStateSnapshot(X);
        else if (EQ.isStateSnapshot(X.data))
          await this.setStateSnapshot(X.data);
        else
          await this.plugin.state.setSnapshot(X);
      } else {
        let $ = await this.plugin.runTask(SN(Z, "zip")), X = Object.create(null);
        B7($, (W, K) => {
          if (K === "state.json" || K === "assets.json")
            return;
          let G = K.substring(K.indexOf("/") + 1);
          X[G] = W;
        });
        let Y = new File([$["state.json"]], "state.json"), Q = await this.plugin.runTask(SN(Y, "json"));
        if ($["assets.json"]) {
          let W = new File([$["assets.json"]], "assets.json"), K = await this.plugin.runTask(SN(W, "json"));
          for (let [G, H] of K)
            this.plugin.managers.asset.set(H, new File([X[G]], H.name));
        }
        await this.setStateSnapshot(Q);
      }
      this.events.opened.next(void 0);
    } catch (J) {
      console.error(J), this.plugin.log.error("Error reading state");
    }
  }
  async startPlayback() {
    let { current: Z } = this;
    if (!Z)
      return;
    if (Z.snapshot.transition) {
      let J = this.setCurrent(this.state.current);
      await this.plugin.state.setSnapshot(J);
      let $ = typeof J.durationInMs !== "undefined" ? J.durationInMs : this.state.nextSnapshotDelayInMs;
      if (this.state.isPlaying)
        this.timeoutHandle = setTimeout(this.next, $);
    } else
      return this.next();
  }
  async play(Z) {
    if (this.state.isPlaying && !(Z === null || Z === void 0 ? void 0 : Z.delayFirst))
      if (Z === null || Z === void 0 ? void 0 : Z.restart)
        await this.stop();
      else
        return;
    if (this.updateState({ isPlaying: !0 }), Z === null || Z === void 0 ? void 0 : Z.delayFirst) {
      let J = this.getEntry(this.state.current);
      if (!J) {
        this.next();
        return;
      }
      this.events.changed.next(void 0);
      let $ = J.snapshot, X = typeof $.durationInMs !== "undefined" ? $.durationInMs : this.state.nextSnapshotDelayInMs;
      this.timeoutHandle = setTimeout(this.next, X);
    } else
      this.startPlayback();
  }
  async stop() {
    if (await this.plugin.managers.animation.stop(), this.updateState({ isPlaying: !1 }), typeof this.timeoutHandle !== "undefined")
      clearTimeout(this.timeoutHandle);
    this.timeoutHandle = void 0, this.events.changed.next(void 0);
  }
  async togglePlay() {
    if (this.state.isPlaying)
      await this.stop(), this.plugin.managers.markdownExtensions.audio.pause();
    else
      await this.play();
  }
  dispose() {
    super.dispose(), this.entryMap.clear();
  }
  constructor(Z) {
    super({
      current: void 0,
      entries: jN(),
      isPlaying: !1,
      nextSnapshotDelayInMs: EQ.DefaultNextSnapshotDelayInMs
    });
    this.plugin = Z, this.entryMap = /* @__PURE__ */ new Map, this.defaultSnapshotId = void 0, this.events = {
      changed: this.ev(),
      opened: this.ev()
    }, this.animationFrameQueue = new se, this.timeoutHandle = void 0, this.next = async () => {
      this.timeoutHandle = void 0;
      let J = this.getNextId(this.state.current, 1);
      if (!J || J === this.state.current) {
        this.stop();
        return;
      }
      let $ = this.setCurrent(J);
      await this.plugin.state.setSnapshot($);
      let X = typeof $.durationInMs !== "undefined" ? $.durationInMs : this.state.nextSnapshotDelayInMs;
      if (this.state.isPlaying)
        this.timeoutHandle = setTimeout(this.next, X);
    };
  }
}
EQ.DefaultNextSnapshotDelayInMs = 1500;
(function(Z) {
  function J(Y, Q) {
    return { timestamp: +/* @__PURE__ */ new Date, snapshot: Y, ...Q };
  }
  Z.Entry = J;
  function $(Y) {
    let Q = Y;
    return !!Q && !!Q.timestamp && !!Q.entries;
  }
  Z.isStateSnapshot = $;
  async function X(Y, Q) {
    let W = n0.create("Render Screenshot", async (K) => {
      if (!Y.helpers.viewportScreenshot)
        return;
      let G = await Y.helpers.viewportScreenshot.getPreview(K, 512);
      if (!G)
        return;
      let H = await HI(G.canvas, "png"), N = new File([H], Q), q = { kind: "file", id: R6.create22(), name: Q };
      return Y.managers.asset.set(q, N), q;
    });
    return Y.runTask(W);
  }
  Z.getCanvasImageAsset = X;
})(EQ || (EQ = {}));

// node_modules/molstar/lib/mol-util/date.js
function vj0() {
  let Z = /* @__PURE__ */ new Date, J = Z.getFullYear(), $ = Z.getMonth() + 1, X = Z.getDate(), Y = Z.getHours(), Q = Z.getMinutes(), W = Z.getSeconds();
  return J + "-" + $ + "-" + X + "-" + Y + "-" + Q + "-" + W;
}

// node_modules/molstar/lib/mol-util/download.js
function JU1(Z) {
  if (!window.open(Z, "_blank"))
    window.location.href = Z;
}
function Sj0(Z) {
  try {
    Z.dispatchEvent(new MouseEvent("click"));
  } catch (J) {
    let $ = document.createEvent("MouseEvents");
    $.initMouseEvent("click", !0, !0, window, 0, 0, 0, 80, 20, !1, !1, !1, !1, 0, null), Z.dispatchEvent($);
  }
}
function jx(Z, J = "download") {
  if (!Z)
    return;
  if ("download" in HTMLAnchorElement.prototype) {
    let $ = document.createElement("a");
    if ($.download = J, $.rel = "noopener", typeof Z === "string")
      $.href = Z, Sj0($);
    else
      $.href = URL.createObjectURL(Z), setTimeout(() => URL.revokeObjectURL($.href), 40000), setTimeout(() => Sj0($));
  } else if (typeof navigator !== "undefined" && navigator.msSaveOrOpenBlob)
    navigator.msSaveOrOpenBlob(Z, J);
  else {
    let $ = window.navigator.userAgent, X = /Safari/i.test($), Y = /CriOS\/[\d]+/.test($), Q = (W) => {
      JU1(Y ? W : W.replace(/^data:[^;]*;/, "data:attachment/file;"));
    };
    if ((X || Y) && FileReader)
      if (Z instanceof Blob) {
        let W = new FileReader;
        W.onloadend = () => Q(W.result), W.readAsDataURL(Z);
      } else
        Q(Z);
    else {
      let W = URL.createObjectURL(typeof Z === "string" ? new Blob([Z]) : Z);
      location.href = W, setTimeout(() => URL.revokeObjectURL(W), 40000);
    }
  }
}

// node_modules/molstar/lib/mol-plugin/behavior/static/state.js
function $U1(Z) {
  fj0(Z), hj0(Z), bj0(Z), xj0(Z), yj0(Z), gj0(Z), mj0(Z), dj0(Z), pj0(Z), uj0(Z);
}
function fj0(Z) {
  Z.state.events.object.created.subscribe((J) => {
    if (!D0.isBehavior(J.obj))
      return;
    J.obj.data.register(J.ref);
  }), Z.state.events.object.removed.subscribe((J) => {
    var $, X, Y, Q;
    if (!D0.isBehavior(J.obj))
      return;
    (X = ($ = J.obj.data).unregister) === null || X === void 0 || X.call($), (Q = (Y = J.obj.data).dispose) === null || Q === void 0 || Q.call(Y);
  }), Z.state.events.object.updated.subscribe((J) => {
    var $, X, Y, Q;
    if (J.action === "recreate") {
      if (J.oldObj && D0.isBehavior(J.oldObj))
        (X = ($ = J.oldObj.data).unregister) === null || X === void 0 || X.call($), (Q = (Y = J.oldObj.data).dispose) === null || Q === void 0 || Q.call(Y);
      if (J.obj && D0.isBehavior(J.obj))
        J.obj.data.register(J.ref);
    }
  });
}
function hj0(Z) {
  h1.State.SetCurrentObject.subscribe(Z, ({ state: J, ref: $ }) => J.setCurrent($));
}
function bj0(Z) {
  h1.State.Update.subscribe(Z, ({ state: J, tree: $, options: X }) => Z.runTask(J.updateTree($, X)));
}
function xj0(Z) {
  h1.State.ApplyAction.subscribe(Z, ({ state: J, action: $, ref: X }) => Z.runTask(J.applyAction($.action, $.params, X)));
}
function yj0(Z) {
  function J($, X) {
    let Y = $.build().delete(X);
    return Z.runTask($.updateTree(Y));
  }
  h1.State.RemoveObject.subscribe(Z, ({ state: $, ref: X, removeParentGhosts: Y }) => {
    if (Y) {
      let Q = $.tree, W = Q.transforms.get(X);
      if (W.parent === X)
        return J($, X);
      while (!0) {
        let K = Q.children.get(W.parent);
        if (W.parent === W.ref || K.size > 1)
          return J($, W.ref);
        let G = Q.transforms.get(W.parent);
        if (!G.state.isGhost)
          return J($, W.ref);
        W = G;
      }
    } else
      return J($, X);
  });
}
function gj0(Z) {
  h1.State.ToggleExpanded.subscribe(Z, ({ state: J, ref: $ }) => J.updateCellState($, ({ isCollapsed: X }) => ({ isCollapsed: !X })));
}
function mj0(Z) {
  h1.State.ToggleVisibility.subscribe(Z, ({ state: J, ref: $ }) => _H(J, $, !J.cells.get($).state.isHidden));
}
function _H(Z, J, $) {
  i9.doPreOrder(Z.tree, Z.transforms.get(J), { state: Z, value: $ }, XU1);
}
function XU1(Z, J, $) {
  $.state.updateCellState(Z.ref, { isHidden: $.value });
}
function dj0(Z) {
  h1.Interactivity.Object.Highlight.subscribe(Z, ({ state: J, ref: $ }) => {
    if (!Z.canvas3d || Z.isBusy)
      return;
    Z.managers.interactivity.lociHighlights.clearHighlights();
    let X = typeof $ === "string" ? [$] : $;
    for (let Y of X) {
      let Q = J.cells.get(Y);
      if (!Q)
        continue;
      if (D0.Molecule.Structure.is(Q.obj))
        Z.managers.interactivity.lociHighlights.highlight({ loci: s0.Loci(Q.obj.data) }, !1);
      else if (Q && D0.isRepresentation3D(Q.obj)) {
        let { repr: W } = Q.obj.data;
        for (let K of W.getAllLoci())
          Z.managers.interactivity.lociHighlights.highlight({ loci: K, repr: W }, !1);
      } else if (D0.Molecule.Structure.Selections.is(Q.obj))
        for (let W of Q.obj.data)
          Z.managers.interactivity.lociHighlights.highlight({ loci: W.loci }, !1);
    }
  });
}
function pj0(Z) {
  h1.Interactivity.ClearHighlights.subscribe(Z, () => {
    Z.managers.interactivity.lociHighlights.clearHighlights();
  });
}
function uj0(Z) {
  Z.config.set(W8.State.CurrentServer, Z.config.get(W8.State.DefaultServer)), h1.State.Snapshots.Clear.subscribe(Z, () => {
    Z.managers.snapshot.clear();
  }), h1.State.Snapshots.Remove.subscribe(Z, ({ id: J }) => {
    Z.managers.snapshot.remove(J);
  }), h1.State.Snapshots.Add.subscribe(Z, async ({ key: J, name: $, description: X, descriptionFormat: Y, params: Q }) => {
    var W;
    let K = Z.state.getSnapshot(Q), G = ((W = Q === null || Q === void 0 ? void 0 : Q.image) !== null && W !== void 0 ? W : Z.state.snapshotParams.value.image) ? await EQ.getCanvasImageAsset(Z, `${K.id}-image.png`) : void 0, H = EQ.Entry(K, { key: J, name: $, description: X, descriptionFormat: Y, image: G });
    Z.managers.snapshot.add(H);
  }), h1.State.Snapshots.Replace.subscribe(Z, async ({ id: J, params: $ }) => {
    var X;
    let Y = Z.state.getSnapshot($), Q = ((X = $ === null || $ === void 0 ? void 0 : $.image) !== null && X !== void 0 ? X : Z.state.snapshotParams.value.image) ? await EQ.getCanvasImageAsset(Z, `${Y.id}-image.png`) : void 0;
    Z.managers.snapshot.replace(J, Z.state.getSnapshot($), { image: Q });
  }), h1.State.Snapshots.Move.subscribe(Z, ({ id: J, dir: $ }) => {
    Z.managers.snapshot.move(J, $);
  }), h1.State.Snapshots.Apply.subscribe(Z, ({ id: J }) => {
    let $ = Z.managers.snapshot.setCurrent(J);
    if (!$)
      return;
    return Z.state.setSnapshot($);
  }), h1.State.Snapshots.Upload.subscribe(Z, async ({ name: J, description: $, playOnLoad: X, serverUrl: Y, params: Q }) => {
    return fetch(HR(Y, `set?name=${encodeURIComponent(J || "")}&description=${encodeURIComponent($ || "")}`), {
      method: "POST",
      mode: "cors",
      referrer: "no-referrer",
      headers: { "Content-Type": "application/json; charset=utf-8" },
      body: JSON.stringify(await Z.managers.snapshot.getStateSnapshot({ name: J, description: $, playOnLoad: X }))
    });
  }), h1.State.Snapshots.Fetch.subscribe(Z, async ({ url: J }) => {
    let $ = await Z.runTask(Z.fetch({ url: J, type: "json" }));
    await Z.managers.snapshot.setStateSnapshot($.data);
  }), h1.State.Snapshots.DownloadToFile.subscribe(Z, async ({ name: J, type: $, params: X }) => {
    let Y = `mol-star_state_${J || vj0()}.${$ === "json" ? "molj" : "molx"}`, Q = await Z.managers.snapshot.serialize({ type: $, params: X });
    jx(Q, `${Y}`);
  }), h1.State.Snapshots.OpenFile.subscribe(Z, ({ file: J }) => {
    return Z.managers.snapshot.open(J);
  }), h1.State.Snapshots.OpenUrl.subscribe(Z, async ({ url: J, type: $ }) => {
    let X = await Z.runTask(Z.fetch({ url: J, type: "binary" }));
    return Z.managers.snapshot.open(new File([X], `state.${$}`));
  });
}

// node_modules/molstar/lib/mol-plugin/behavior/static/representation.js
var te = {};
y9(te, {
  registerDefault: () => YU1,
  UpdateRepresentationVisibility: () => nj0,
  SyncStructureRepresentation3DState: () => lj0,
  SyncRepresentationToCanvas: () => cj0
});
function YU1(Z) {
  cj0(Z), lj0(Z), nj0(Z);
}
function cj0(Z) {
  let J = Z.state.data.events;
  J.object.created.subscribe(($) => {
    var X;
    if (!D0.isRepresentation3D($.obj))
      return;
    re($.state.cells.get($.ref), $.obj.data.repr), $.obj.data.repr.setState({ syncManually: !0 }), (X = Z.canvas3d) === null || X === void 0 || X.add($.obj.data.repr);
  }), J.object.updated.subscribe(($) => {
    var X, Y;
    if ($.oldObj && D0.isRepresentation3D($.oldObj))
      (X = Z.canvas3d) === null || X === void 0 || X.remove($.oldObj.data.repr), $.oldObj.data.repr.destroy();
    if (!D0.isRepresentation3D($.obj))
      return;
    if (re($.state.cells.get($.ref), $.obj.data.repr), $.action === "recreate")
      $.obj.data.repr.setState({ syncManually: !0 });
    (Y = Z.canvas3d) === null || Y === void 0 || Y.add($.obj.data.repr);
  }), J.object.removed.subscribe(($) => {
    var X;
    if (!D0.isRepresentation3D($.obj))
      return;
    (X = Z.canvas3d) === null || X === void 0 || X.remove($.obj.data.repr), $.obj.data.repr.destroy();
  });
}
function lj0(Z) {
  let J = Z.state.data.events;
  J.object.created.subscribe(($) => {
    var X;
    if (!D0.Molecule.Structure.Representation3DState.is($.obj))
      return;
    let Y = $.obj.data;
    Y.repr.setState(Y.state), (X = Z.canvas3d) === null || X === void 0 || X.update(Y.repr);
  }), J.object.updated.subscribe(($) => {
    var X;
    if (!D0.Molecule.Structure.Representation3DState.is($.obj))
      return;
    let Y = $.obj.data;
    Y.repr.setState(Y.state), (X = Z.canvas3d) === null || X === void 0 || X.update(Y.repr);
  }), J.object.removed.subscribe(($) => {
    var X;
    if (!D0.Molecule.Structure.Representation3DState.is($.obj))
      return;
    let Y = $.obj.data;
    Y.repr.setState(Y.initialState), (X = Z.canvas3d) === null || X === void 0 || X.update(Y.repr);
  });
}
function nj0(Z) {
  Z.state.data.events.cell.stateUpdated.subscribe((J) => {
    var $;
    let X = J.state.cells.get(J.ref);
    if (!D0.isRepresentation3D(X.obj))
      return;
    if (re(X, X.obj.data.repr))
      ($ = Z.canvas3d) === null || $ === void 0 || $.syncVisibility();
  });
}
function re(Z, J) {
  if (J.state.visible === !!Z.state.isHidden)
    return J.setState({ visible: !Z.state.isHidden }), !0;
  else
    return !1;
}

// node_modules/molstar/lib/mol-plugin/behavior/static/camera.js
var ee = {};
y9(ee, {
  registerDefault: () => QU1,
  SetSnapshot: () => oj0,
  ResetAxes: () => tj0,
  Reset: () => ij0,
  OrientAxes: () => rj0,
  FocusObject: () => aj0,
  Focus: () => sj0
});
function QU1(Z) {
  ij0(Z), sj0(Z), aj0(Z), oj0(Z), rj0(Z), tj0(Z);
}
function ij0(Z) {
  h1.Camera.Reset.subscribe(Z, (J) => {
    Z.managers.camera.reset(J === null || J === void 0 ? void 0 : J.snapshot, J === null || J === void 0 ? void 0 : J.durationMs);
  });
}
function oj0(Z) {
  h1.Camera.SetSnapshot.subscribe(Z, ({ snapshot: J, durationMs: $ }) => {
    Z.managers.camera.setSnapshot(J, $);
  });
}
function sj0(Z) {
  h1.Camera.Focus.subscribe(Z, ({ center: J, radius: $, durationMs: X }) => {
    Z.managers.camera.focusSphere({ center: J, radius: $ }, { durationMs: X }), Z.events.canvas3d.settingsUpdated.next(void 0);
  });
}
function aj0(Z) {
  h1.Camera.FocusObject.subscribe(Z, async (J) => {
    Z.managers.camera.focusObject(J);
  });
}
function rj0(Z) {
  h1.Camera.OrientAxes.subscribe(Z, ({ structures: J, durationMs: $ }) => {
    Z.managers.camera.orientAxes(J, $);
  });
}
function tj0(Z) {
  h1.Camera.ResetAxes.subscribe(Z, ({ durationMs: J }) => {
    Z.managers.camera.resetAxes(J);
  });
}

// node_modules/molstar/lib/mol-plugin/behavior/static/misc.js
var Z00 = {};
y9(Z00, {
  registerDefault: () => WU1,
  Canvas3DSetSettings: () => ej0
});
function WU1(Z) {
  ej0(Z);
}
function ej0(Z) {
  h1.Canvas3D.ResetSettings.subscribe(Z, () => {
    var J;
    (J = Z.canvas3d) === null || J === void 0 || J.setProps(GI), Z.events.canvas3d.settingsUpdated.next(void 0);
  }), h1.Canvas3D.SetSettings.subscribe(Z, (J) => {
    var $;
    if (!Z.canvas3d)
      return;
    ($ = Z.canvas3d) === null || $ === void 0 || $.setProps(J.settings), Z.events.canvas3d.settingsUpdated.next(void 0);
  });
}

// node_modules/molstar/lib/mol-plugin/behavior/dynamic/representation.js
var $00 = {};
y9($00, {
  SelectLoci: () => J00,
  HighlightLoci: () => HU1,
  FocusLoci: () => pz,
  DefaultSelectLociBindings: () => ZT0,
  DefaultLociLabelProvider: () => qU1,
  DefaultFocusLociBindings: () => JT0
});
var zq = V8, Mq = hJ, Dq = e1.Trigger, KU1 = {
  hoverHighlightOnly: e1([Dq(zq.Flag.None)], "Highlight", "Hover element using ${triggers}"),
  hoverHighlightOnlyExtend: e1([Dq(zq.Flag.None, Mq.create({ shift: !0 }))], "Extend highlight", "From selected to hovered element along polymer using ${triggers}")
}, GU1 = {
  bindings: j.Value(KU1, { isHidden: !0 }),
  ignore: j.Value([], { isHidden: !0 }),
  preferAtoms: j.Boolean(!1, { description: "Always prefer atoms over bonds" }),
  mark: j.Boolean(!0)
}, HU1 = i8.create({
  name: "representation-highlight-loci",
  category: "interaction",
  ctor: class extends i8.Handler {
    constructor() {
      super(...arguments);
      this.lociMarkProvider = (Z, J) => {
        if (!this.ctx.canvas3d || !this.params.mark)
          return;
        this.ctx.canvas3d.mark(Z, J);
      };
    }
    getLoci(Z) {
      return this.params.preferAtoms && $2.isLoci(Z) && Z.bonds.length === 2 ? $2.toFirstStructureElementLoci(Z) : Z;
    }
    register() {
      this.subscribeObservable(this.ctx.behaviors.interaction.hover, ({ current: Z, buttons: J, modifiers: $ }) => {
        if (!this.ctx.canvas3d || this.ctx.isBusy)
          return;
        let X = this.getLoci(Z.loci);
        if (this.params.ignore.includes(X.kind)) {
          this.ctx.managers.interactivity.lociHighlights.highlightOnly({ repr: Z.repr, loci: G8 });
          return;
        }
        let Y = !1;
        if (e1.match(this.params.bindings.hoverHighlightOnly, J, $))
          this.ctx.managers.interactivity.lociHighlights.highlightOnly({ loci: X }), Y = !0;
        if (e1.match(this.params.bindings.hoverHighlightOnlyExtend, J, $))
          this.ctx.managers.interactivity.lociHighlights.highlightOnlyExtend({ loci: X }), Y = !0;
        if (!Y)
          this.ctx.managers.interactivity.lociHighlights.highlightOnly({ repr: Z.repr, loci: G8 });
      }), this.ctx.managers.interactivity.lociHighlights.addProvider(this.lociMarkProvider);
    }
    unregister() {
      this.ctx.managers.interactivity.lociHighlights.removeProvider(this.lociMarkProvider);
    }
  },
  params: () => GU1,
  display: { name: "Highlight Loci on Canvas" }
}), ZT0 = {
  clickSelect: e1.Empty,
  clickSelectOnly: e1.Empty,
  clickToggle: e1([Dq(zq.Flag.Primary, Mq.create())], "Toggle selection", "Click on element using ${triggers}"),
  clickToggleExtend: e1([Dq(zq.Flag.Primary, Mq.create({ shift: !0 }))], "Toggle extended selection", "Click on element using ${triggers} to extend selection along polymer"),
  clickDeselect: e1.Empty,
  clickDeselectAllOnEmpty: e1([Dq(zq.Flag.Primary, Mq.create())], "Deselect all", "Click on nothing using ${triggers}")
}, NU1 = {
  bindings: j.Value(ZT0, { isHidden: !0 }),
  ignore: j.Value([], { isHidden: !0 }),
  preferAtoms: j.Boolean(!1, { description: "Always prefer atoms over bonds" }),
  mark: j.Boolean(!0)
}, J00 = i8.create({
  name: "representation-select-loci",
  category: "interaction",
  ctor: class extends i8.Handler {
    getLoci(Z) {
      return this.params.preferAtoms && $2.isLoci(Z) && Z.bonds.length === 2 ? $2.toFirstStructureElementLoci(Z) : Z;
    }
    applySelectMark(Z, J) {
      let $ = this.ctx.state.data.cells.get(Z);
      if ($ && D0.isRepresentation3D($.obj)) {
        this.spine.current = $;
        let X = this.spine.getRootOfType(D0.Molecule.Structure);
        if (X) {
          if (J)
            this.lociMarkProvider({ loci: s0.Loci(X.data) }, x2.Deselect);
          let Y = this.ctx.managers.structure.selection.getLoci(X.data);
          this.lociMarkProvider({ loci: Y }, x2.Select);
        }
      }
    }
    register() {
      let Z = (X) => d2.isEmpty(X), J = (X) => !d2.isEmpty(X), $ = [
        ["clickSelect", (X) => this.ctx.managers.interactivity.lociSelects.select(X), J],
        ["clickToggle", (X) => this.ctx.managers.interactivity.lociSelects.toggle(X), J],
        ["clickToggleExtend", (X) => this.ctx.managers.interactivity.lociSelects.toggleExtend(X), J],
        ["clickSelectOnly", (X) => this.ctx.managers.interactivity.lociSelects.selectOnly(X), J],
        ["clickDeselect", (X) => this.ctx.managers.interactivity.lociSelects.deselect(X), J],
        ["clickDeselectAllOnEmpty", () => this.ctx.managers.interactivity.lociSelects.deselectAll(), Z]
      ];
      $.sort((X, Y) => {
        let Q = this.params.bindings[X[0]], W = this.params.bindings[Y[0]], K = Q.triggers.length === 0 ? 0 : yX(Q.triggers.map((H) => Mq.size(H.modifiers)));
        return (W.triggers.length === 0 ? 0 : yX(W.triggers.map((H) => Mq.size(H.modifiers)))) - K;
      }), this.subscribeObservable(this.ctx.behaviors.interaction.click, ({ current: X, button: Y, modifiers: Q }) => {
        if (!this.ctx.canvas3d || this.ctx.isBusy || !this.ctx.selectionMode)
          return;
        let W = this.getLoci(X.loci);
        if (this.params.ignore.includes(W.kind))
          return;
        for (let [K, G, H] of $)
          if (e1.match(this.params.bindings[K], Y, Q) && (!H || H(W))) {
            G({ repr: X.repr, loci: W });
            break;
          }
      }), this.ctx.managers.interactivity.lociSelects.addProvider(this.lociMarkProvider), this.subscribeObservable(this.ctx.state.events.object.created, ({ ref: X }) => this.applySelectMark(X)), this.subscribeObservable(this.ctx.state.events.object.updated, ({ ref: X, obj: Y, oldObj: Q, oldData: W, action: K }) => {
        let G = this.ctx.state.data.cells.get(X);
        if (G && D0.Molecule.Structure.is(G.obj)) {
          let H = Y.data, N = K === "recreate" ? Q === null || Q === void 0 ? void 0 : Q.data : K === "in-place" ? W : void 0;
          if (N && s0.areEquivalent(H, N) && s0.areHierarchiesEqual(H, N))
            return;
          let q = this.ctx.state.data.select(f2.children(X).ofType(D0.Molecule.Structure.Representation3D));
          for (let U of q)
            this.applySelectMark(U.transform.ref, !0);
        }
      });
    }
    unregister() {
      this.ctx.managers.interactivity.lociSelects.removeProvider(this.lociMarkProvider);
    }
    constructor(Z, J) {
      super(Z, J);
      this.lociMarkProvider = ($, X) => {
        if (!this.ctx.canvas3d || !this.params.mark)
          return;
        this.ctx.canvas3d.mark({ loci: $.loci }, X);
      }, this.spine = new GR.Impl(Z.state.data.cells);
    }
  },
  params: () => NU1,
  display: { name: "Select Loci on Canvas" }
}), qU1 = i8.create({
  name: "default-loci-label-provider",
  category: "interaction",
  ctor: class {
    register() {
      this.ctx.managers.lociLabels.addProvider(this.f);
    }
    unregister() {
      this.ctx.managers.lociLabels.removeProvider(this.f);
    }
    constructor(Z) {
      this.ctx = Z, this.f = {
        label: (J) => {
          let $ = [];
          if (W0.Loci.is(J)) {
            let X = /* @__PURE__ */ new Set;
            for (let { unit: Y } of J.elements) {
              let Q = W0.Location.create(J.structure, Y, Y.elements[0]), W = w1.entity.pdbx_description(Q).join(", ");
              X.add(W);
            }
            if (X.size === 1)
              X.forEach((Y) => $.push(Y));
          }
          return $.push(c3(J)), $.filter((X) => !!X).join("</br>");
        },
        group: (J) => J.toString().replace(/Model [0-9]+/g, "Models"),
        priority: 100
      };
    }
  },
  display: { name: "Provide Default Loci Label" }
}), JT0 = {
  clickFocus: e1([
    Dq(zq.Flag.Primary, Mq.create()),
    Dq(zq.Flag.Trigger)
  ], "Representation Focus", "Click element using ${triggers}"),
  clickFocusAdd: e1([
    Dq(zq.Flag.Primary, Mq.create({ control: !0 })),
    Dq(zq.Flag.Primary, Mq.create({ meta: !0 }))
  ], "Representation Focus Add", "Click element using ${triggers}"),
  clickFocusExtend: e1([
    Dq(zq.Flag.Primary, Mq.create({ shift: !0 }))
  ], "Representation Focus Extend", "Click on element using ${triggers}"),
  clickFocusSelectMode: e1([], "Representation Focus (Selection Mode)", "Click element using ${triggers}"),
  clickFocusAddSelectMode: e1([], "Representation Focus Add (Selection Mode)", "Click element using ${triggers}"),
  clickFocusExtendSelectMode: e1([], "Representation Focus Extend (Selection Mode)", "Click on element using ${triggers}")
}, FU1 = {
  bindings: j.Value(JT0, { isHidden: !0 })
}, pz = i8.create({
  name: "representation-focus-loci",
  category: "interaction",
  ctor: class extends i8.Handler {
    register() {
      this.subscribeObservable(this.ctx.behaviors.interaction.click, ({ current: Z, button: J, modifiers: $ }) => {
        var X, Y, Q, W, K, G, H;
        let { clickFocus: N, clickFocusAdd: q, clickFocusExtend: U, clickFocusSelectMode: F, clickFocusAddSelectMode: E, clickFocusExtendSelectMode: R } = this.params.bindings, z = this.ctx.selectionMode ? F : N, D = e1.match(z, J, $), A = this.ctx.selectionMode ? E : q, B = e1.match(A, J, $), T = this.ctx.selectionMode ? R : U, w = e1.match(T, J, $);
        if (!D && !B && !w)
          return;
        let V = (W = (Q = (Y = (X = Z.repr) === null || X === void 0 ? void 0 : X.props) === null || Y === void 0 ? void 0 : Y.snapshotKey) === null || Q === void 0 ? void 0 : Q.trim()) !== null && W !== void 0 ? W : "";
        if (!this.ctx.selectionMode && D && V) {
          this.ctx.managers.snapshot.applyKey(V);
          return;
        }
        let P = (G = (K = Z.repr) === null || K === void 0 ? void 0 : K.props) === null || G === void 0 ? void 0 : G.markdownCommands;
        if (!this.ctx.selectionMode && D && typeof P === "object") {
          if (Object.keys(P).length > 0) {
            this.ctx.managers.markdownExtensions.tryExecute("click", P);
            return;
          }
        }
        let { granularity: I } = this.ctx.managers.interactivity.props;
        if (I !== "residue" && I !== "element")
          return;
        let S = d2.normalize(Z.loci, "residue"), f = this.ctx.managers.structure.focus.current;
        if (f && d2.areEqual(f.loci, S))
          this.ctx.managers.structure.focus.clear();
        else if (D)
          this.ctx.managers.structure.focus.setFromLoci(S);
        else {
          if (w)
            this.ctx.managers.structure.focus.extendFromLoci(S);
          else
            this.ctx.managers.structure.focus.toggleFromLoci(S);
          let v = (H = this.ctx.managers.structure.focus.current) === null || H === void 0 ? void 0 : H.loci;
          if (v)
            this.ctx.managers.camera.focusLoci(v);
        }
      });
    }
  },
  params: () => FU1,
  display: { name: "Representation Focus Loci on Canvas" }
});

// node_modules/molstar/lib/mol-plugin/behavior/dynamic/camera.js
var Q00 = {};
y9(Q00, {
  FocusLoci: () => LU1,
  DefaultFocusLociBindings: () => $T0,
  DefaultClickResetCameraOnEmptySelectMode: () => Y00,
  DefaultClickResetCameraOnEmpty: () => X00,
  CameraControls: () => OU1,
  CameraAxisHelper: () => RU1
});
var r3 = V8, VH = hJ, t3 = e1.Trigger, NI = e1.TriggerKey, X00 = e1([
  t3(r3.Flag.Primary, VH.create()),
  t3(r3.Flag.Secondary, VH.create()),
  t3(r3.Flag.Primary, VH.create({ control: !0 })),
  t3(r3.Flag.Trigger)
], "Reset camera focus", "Click on nothing using ${triggers}"), Y00 = e1([
  t3(r3.Flag.Secondary, VH.create()),
  t3(r3.Flag.Primary, VH.create({ control: !0 }))
], "Reset camera focus (Selection Mode)", "Click on nothing using ${triggers}"), $T0 = {
  clickCenterFocus: e1([
    t3(r3.Flag.Primary, VH.create()),
    t3(r3.Flag.Secondary, VH.create()),
    t3(r3.Flag.Primary, VH.create({ control: !0 })),
    t3(r3.Flag.Trigger)
  ], "Camera center and focus", "Click element using ${triggers}"),
  clickCenterFocusSelectMode: e1([
    t3(r3.Flag.Secondary, VH.create()),
    t3(r3.Flag.Primary, VH.create({ control: !0 }))
  ], "Camera center and focus (Selection Mode)", "Click element using ${triggers}"),
  clickResetCameraOnEmpty: X00,
  clickResetCameraOnEmptySelectMode: Y00
}, UU1 = {
  minRadius: j.Numeric(8, { min: 1, max: 50, step: 1 }),
  extraRadius: j.Numeric(4, { min: 1, max: 50, step: 1 }, { description: "Value added to the bounding-sphere radius of the Loci" }),
  durationMs: j.Numeric(250, { min: 0, max: 1000, step: 1 }, { description: "Camera transition duration" }),
  bindings: j.Value($T0, { isHidden: !0 })
}, LU1 = i8.create({
  name: "camera-focus-loci",
  category: "interaction",
  ctor: class extends i8.Handler {
    register() {
      this.subscribeObservable(this.ctx.behaviors.interaction.click, ({ current: Z, button: J, modifiers: $ }) => {
        var X, Y, Q, W, K, G, H, N;
        if (!this.ctx.canvas3d)
          return;
        let q = this.ctx.selectionMode ? this.params.bindings.clickCenterFocusSelectMode : this.params.bindings.clickCenterFocus, U = this.ctx.selectionMode ? (X = this.params.bindings.clickResetCameraOnEmptySelectMode) !== null && X !== void 0 ? X : Y00 : (Y = this.params.bindings.clickResetCameraOnEmpty) !== null && Y !== void 0 ? Y : X00;
        if (d2.isEmpty(Z.loci) && e1.match(U, J, $)) {
          h1.Camera.Reset(this.ctx, {});
          return;
        }
        let F = (G = (K = (W = (Q = Z.repr) === null || Q === void 0 ? void 0 : Q.props) === null || W === void 0 ? void 0 : W.snapshotKey) === null || K === void 0 ? void 0 : K.trim()) !== null && G !== void 0 ? G : "", E = (N = (H = Z.repr) === null || H === void 0 ? void 0 : H.props) === null || N === void 0 ? void 0 : N.markdownCommands;
        if (F || typeof E === "object" && Object.keys(E).length > 0)
          return;
        if (e1.match(q, J, $)) {
          let R = d2.normalize(Z.loci, this.ctx.managers.interactivity.props.granularity);
          this.ctx.managers.camera.focusLoci(R, this.params);
        }
      });
    }
  },
  params: () => UU1,
  display: { name: "Camera Focus Loci on Canvas" }
}), RU1 = i8.create({
  name: "camera-axis-helper",
  category: "interaction",
  ctor: class extends i8.Handler {
    register() {
      let Z = eZ.None, J = 0;
      this.subscribeObservable(this.ctx.behaviors.interaction.click, ({ current: $ }) => {
        if (!this.ctx.canvas3d || !zx($.loci))
          return;
        let X = $.loci.elements[0].groupId;
        if (X === eZ.None) {
          Z = eZ.None, J = 0;
          return;
        }
        let { camera: Y } = this.ctx.canvas3d, Q, W;
        if (X >= eZ.X && X <= eZ.Z) {
          Z = eZ.None, J = 0;
          let K = M.sub(M(), Y.target, Y.position), G = M.cross(M(), K, Y.up);
          if (W = M(), W[X - 1] = 1, Q = M.cross(M(), W, G), M.magnitude(Q) === 0)
            Q = K;
        } else {
          if (Z === X)
            J = (J + 1) % 2;
          else
            Z = X, J = 0;
          if (X === eZ.XY)
            W = J ? M.unitX : M.unitY, Q = M.negUnitZ;
          else if (X === eZ.XZ)
            W = J ? M.unitX : M.unitZ, Q = M.negUnitY;
          else
            W = J ? M.unitY : M.unitZ, Q = M.negUnitX;
        }
        this.ctx.canvas3d.requestCameraReset({
          snapshot: (K, G) => G.getInvariantFocus(K.boundingSphereVisible.center, K.boundingSphereVisible.radius, W, Q)
        });
      });
    }
  },
  params: () => ({}),
  display: { name: "Camera Axis Helper" }
}), XT0 = {
  keySpinAnimation: e1([NI("I")], "Spin Animation", "Press ${triggers}"),
  keyRockAnimation: e1([NI("O")], "Rock Animation", "Press ${triggers}"),
  keyToggleFlyMode: e1([NI("Space", VH.create({ shift: !0 }))], "Toggle Fly Mode", "Press ${triggers}"),
  keyResetView: e1([NI("T")], "Reset View", "Press ${triggers}"),
  keyGlobalIllumination: e1([NI("G")], "Global Illumination", "Press ${triggers}")
}, EU1 = {
  bindings: j.Value(XT0, { isHidden: !0 })
}, OU1 = i8.create({
  name: "camera-controls",
  category: "interaction",
  ctor: class extends i8.Handler {
    register() {
      this.subscribeObservable(this.ctx.behaviors.interaction.key, ({ code: Z, key: J, modifiers: $ }) => {
        var X;
        if (!this.ctx.canvas3d)
          return;
        let Y = { ...XT0, ...this.params.bindings }, Q = this.ctx.canvas3d.props.trackball, W = this.ctx.canvas3d.props.illumination;
        if (e1.matchKey(Y.keySpinAnimation, Z, $, J)) {
          let K = Q.animate.name !== "spin" ? "spin" : "off";
          if (K === "off")
            h1.Canvas3D.SetSettings(this.ctx, {
              settings: {
                trackball: {
                  ...Q,
                  animate: { name: K, params: {} }
                }
              }
            });
          else
            h1.Canvas3D.SetSettings(this.ctx, {
              settings: {
                trackball: {
                  ...Q,
                  animate: { name: K, params: { speed: 0.1 } }
                }
              }
            });
        }
        if (e1.matchKey(Y.keyRockAnimation, Z, $, J)) {
          let K = Q.animate.name !== "rock" ? "rock" : "off";
          if (K === "off")
            h1.Canvas3D.SetSettings(this.ctx, {
              settings: {
                trackball: {
                  ...Q,
                  animate: { name: K, params: {} }
                }
              }
            });
          else
            h1.Canvas3D.SetSettings(this.ctx, {
              settings: {
                trackball: {
                  ...Q,
                  animate: { name: K, params: { speed: 0.3, angle: 10 } }
                }
              }
            });
        }
        if (e1.matchKey(Y.keyToggleFlyMode, Z, $, J)) {
          let K = !Q.flyMode;
          if (h1.Canvas3D.SetSettings(this.ctx, {
            settings: {
              trackball: {
                ...Q,
                flyMode: K
              }
            }
          }), (X = this.ctx.canvas3dContext) === null || X === void 0 ? void 0 : X.canvas)
            this.ctx.canvas3dContext.canvas.style.cursor = K ? "crosshair" : "unset";
        }
        if (e1.matchKey(Y.keyResetView, Z, $, J))
          h1.Camera.Reset(this.ctx, {});
        if (e1.matchKey(Y.keyGlobalIllumination, Z, $, J))
          h1.Canvas3D.SetSettings(this.ctx, {
            settings: {
              illumination: {
                ...W,
                enabled: !W.enabled
              }
            }
          });
      });
    }
  },
  params: () => EU1,
  display: { name: "Camera Controls on Canvas" }
});

// node_modules/molstar/lib/mol-plugin/behavior/dynamic/state.js
var W00 = {};
y9(W00, {
  SnapshotControls: () => MU1
});
var Tx = hJ, ZB = e1.TriggerKey, zU1 = {
  next: e1([
    ZB("ArrowRight", Tx.create({ control: !0 })),
    ZB("GamepadY")
  ]),
  previous: e1([
    ZB("ArrowLeft", Tx.create({ control: !0 })),
    ZB("GamepadX")
  ]),
  first: e1([
    ZB("ArrowUp", Tx.create({ control: !0 }))
  ]),
  last: e1([
    ZB("ArrowDown", Tx.create({ control: !0 }))
  ])
}, DU1 = {
  bindings: j.Value(zU1, { isHidden: !0 })
}, MU1 = i8.create({
  name: "snapshot-controls",
  category: "interaction",
  ctor: class extends i8.Handler {
    register() {
      this.subscribeObservable(this.ctx.behaviors.interaction.keyReleased, ({ code: Z, modifiers: J, key: $ }) => {
        if (!this.ctx.canvas3d || this.ctx.isBusy)
          return;
        let X = this.params.bindings, { snapshot: Y } = this.ctx.managers;
        if (e1.matchKey(X.next, Z, J, $))
          Y.applyNext(1);
        if (e1.matchKey(X.previous, Z, J, $))
          Y.applyNext(-1);
        if (e1.matchKey(X.first, Z, J, $)) {
          let Q = Y.state.entries.get(0), W = Y.setCurrent(Q.snapshot.id);
          if (W)
            return this.ctx.state.setSnapshot(W);
        }
        if (e1.matchKey(X.last, Z, J, $)) {
          let Q = Y.state.entries.get(Y.state.entries.size - 1), W = Y.setCurrent(Q.snapshot.id);
          if (W)
            return this.ctx.state.setSnapshot(W);
        }
      });
    }
  },
  params: () => DU1,
  display: { name: "Snapshot Controls" }
});

// node_modules/molstar/lib/mol-plugin/behavior/dynamic/custom-props.js
var n00 = {};
y9(n00, {
  ValenceModel: () => o_0,
  StructureInfo: () => YT0,
  SecondaryStructure: () => i_0,
  Interactions: () => n_0,
  CrossLinkRestraint: () => QV0,
  BestDatabaseSequenceMapping: () => r_0,
  AccessibleSurfaceArea: () => UT0
});

// node_modules/molstar/lib/mol-plugin/behavior/dynamic/custom-props/structure-info.js
var YT0 = i8.create({
  name: "structure-info-prop",
  category: "custom-props",
  display: { name: "Structure Info" },
  ctor: class extends i8.Handler {
    get maxModelIndex() {
      var Z, J;
      let $ = -1, X = this.ctx.state.data.select(f2.Generators.rootsOfType(D0.Molecule.Model));
      for (let Y of X) {
        let Q = ((Z = Y.obj) === null || Z === void 0 ? void 0 : Z.data) && O2.Index.get((J = Y.obj) === null || J === void 0 ? void 0 : J.data).value;
        if (Q !== void 0 && Q > $)
          $ = Q;
      }
      return $;
    }
    get maxStructureIndex() {
      var Z, J;
      let $ = -1, X = this.ctx.state.data.select(f2.Generators.rootsOfType(D0.Molecule.Structure));
      for (let Y of X) {
        let Q = ((Z = Y.obj) === null || Z === void 0 ? void 0 : Z.data) && s0.Index.get((J = Y.obj) === null || J === void 0 ? void 0 : J.data).value;
        if (Q !== void 0 && Q > $)
          $ = Q;
      }
      return $;
    }
    get asymIdOffset() {
      var Z;
      let J = 0, $ = 0, X = this.ctx.state.data.select(f2.Generators.rootsOfType(D0.Molecule.Model));
      for (let Y of X) {
        let Q = (Z = Y.obj) === null || Z === void 0 ? void 0 : Z.data;
        if (Q) {
          let W = O2.AsymIdCount.get(Q), K = O2.AsymIdOffset.get(Q).value;
          if (W !== void 0 && K !== void 0)
            J = Math.max(J, K.auth + W.auth), $ = Math.max($, K.label + W.label);
        }
      }
      return { auth: J, label: $ };
    }
    setModelMaxIndex() {
      var Z;
      let J = this.maxModelIndex, $ = this.ctx.state.data.select(f2.Generators.rootsOfType(D0.Molecule.Model));
      for (let X of $) {
        let Y = (Z = X.obj) === null || Z === void 0 ? void 0 : Z.data;
        if (Y) {
          if (O2.MaxIndex.get(Y).value !== J)
            O2.MaxIndex.set(Y, { value: J }, J);
        }
      }
    }
    setStructureMaxIndex() {
      var Z;
      let J = this.maxModelIndex, $ = this.ctx.state.data.select(f2.Generators.rootsOfType(D0.Molecule.Structure));
      for (let X of $) {
        let Y = (Z = X.obj) === null || Z === void 0 ? void 0 : Z.data;
        if (Y) {
          if (s0.MaxIndex.get(Y).value !== J)
            s0.MaxIndex.set(Y, { value: J }, J);
        }
      }
    }
    handleModel(Z, J) {
      if (O2.Index.get(Z).value === void 0) {
        let $ = J && O2.Index.get(J).value, X = $ !== null && $ !== void 0 ? $ : this.maxModelIndex + 1;
        O2.Index.set(Z, { value: X }, X);
      }
      if (O2.AsymIdOffset.get(Z).value === void 0) {
        let $ = J && O2.AsymIdOffset.get(J).value, X = $ !== null && $ !== void 0 ? $ : { ...this.asymIdOffset };
        O2.AsymIdOffset.set(Z, { value: X }, X);
      }
    }
    handleStructure(Z, J) {
      if (Z.parent !== void 0)
        return;
      if (s0.Index.get(Z).value !== void 0)
        return;
      let $ = J && s0.Index.get(J).value, X = $ !== null && $ !== void 0 ? $ : this.maxStructureIndex + 1;
      s0.Index.set(Z, { value: X }, X);
    }
    handle(Z, J, $) {
      if (D0.Molecule.Structure.is(J)) {
        if (!this.ctx.state.data.tree.transforms.get(Z).transformer.definition.isDecorator && J.data.parent === void 0)
          this.handleStructure(J.data, $ === null || $ === void 0 ? void 0 : $.data);
      } else if (D0.Molecule.Model.is(J)) {
        if (!this.ctx.state.data.tree.transforms.get(Z).transformer.definition.isDecorator)
          this.handleModel(J.data, $ === null || $ === void 0 ? void 0 : $.data);
      }
    }
    register() {
      this.ctx.customModelProperties.register(O2.AsymIdOffset, !0), this.ctx.customModelProperties.register(O2.Index, !0), this.ctx.customModelProperties.register(O2.MaxIndex, !0), this.ctx.customStructureProperties.register(s0.Index, !0), this.ctx.customStructureProperties.register(s0.MaxIndex, !0), this.subscribeObservable(this.ctx.state.data.events.object.created, (Z) => {
        this.handle(Z.ref, Z.obj), this.setModelMaxIndex(), this.setStructureMaxIndex();
      }), this.subscribeObservable(this.ctx.state.data.events.object.updated, (Z) => {
        this.handle(Z.ref, Z.obj, Z.oldObj);
      });
    }
    unregister() {
      this.ctx.customModelProperties.unregister(O2.AsymIdOffset.descriptor.name), this.ctx.customModelProperties.unregister(O2.Index.descriptor.name), this.ctx.customModelProperties.unregister(O2.MaxIndex.descriptor.name), this.ctx.customStructureProperties.unregister(s0.Index.descriptor.name), this.ctx.customStructureProperties.unregister(s0.MaxIndex.descriptor.name);
    }
  }
});
// node_modules/molstar/lib/mol-model-props/computed/accessible-surface-area/shrake-rupley/common.js
var IH = [
  -1,
  1.76,
  1.87,
  1.65,
  1.5,
  1.4,
  1.85,
  1.8,
  1.6,
  1.4
], _x = {
  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
}, QT0 = 121;

// node_modules/molstar/lib/mol-model-props/computed/accessible-surface-area/shrake-rupley/radii.js
function WT0(Z) {
  let { key: J } = w1.residue, { type_symbol: $, label_atom_id: X, label_comp_id: Y } = w1.atom, { structure: Q, atomRadiusType: W, serialResidueIndex: K } = Z, G = W0.Location.create(Q), H = 0, N = 0, q = -1;
  G.structure = Q;
  for (let U = 0, F = 0, E = Q.units.length;U < E; ++U) {
    let R = Q.units[U], { elements: z } = R;
    G.unit = R, H = -1;
    for (let D = 0, A = z.length;D < A; ++D) {
      let B = z[D], T = F + D;
      if (G.element = B, N = J(G), H !== N)
        ++q;
      H = N;
      let w = $(G), V = M5(w);
      if (A3(V)) {
        W[T] = 0, K[T] = -1;
        continue;
      }
      let P = X(G), I = rM(R, B);
      if (I === e2.Water || !Z.nonPolymer && !MR(I)) {
        W[T] = 0, K[T] = -1;
        continue;
      }
      let S = Y(G);
      if (Z.traceOnly && (P !== "CA" && P !== "BB" || !_x[S])) {
        W[T] = 0, K[T] = q;
        continue;
      }
      if (XJ(I))
        W[T] = BU1(P, w, S);
      else if (I === e2.Protein)
        W[T] = AU1(P, w, S);
      else
        W[T] = K00(w);
      K[T] = q;
    }
    F += z.length;
  }
}
function AU1(Z, J, $) {
  switch (J) {
    case "O":
      return 5;
    case "S":
      return 6;
    case "N":
      return Z === "NZ" ? 4 : 3;
    case "C":
      switch (Z) {
        case "C":
        case "CE1":
        case "CE2":
        case "CE3":
        case "CH2":
        case "CZ":
        case "CZ2":
        case "CZ3":
          return 1;
        case "CA":
        case "CB":
        case "CE":
        case "CG1":
        case "CG2":
          return 2;
        default:
          switch ($) {
            case "PHE":
            case "TRP":
            case "TYR":
            case "HIS":
            case "ASP":
            case "ASN":
              return 1;
            case "PRO":
            case "LYS":
            case "ARG":
            case "MET":
            case "ILE":
            case "LEU":
              return 2;
            case "GLU":
            case "GLN":
              return Z === "CD" ? 1 : 2;
          }
      }
  }
  return K00(J);
}
function BU1(Z, J, $) {
  switch (J) {
    case "C":
      return 7;
    case "N":
      return 8;
    case "P":
      return 9;
    case "O":
      return 5;
  }
  return K00(J);
}
function K00(Z) {
  let J = D5(Z), $ = IH.indexOf(J);
  if ($ === -1)
    $ = IH.length, IH[$] = J;
  return $;
}

// node_modules/molstar/lib/mol-model-props/computed/accessible-surface-area/shrake-rupley/area.js
var KT0 = 5000;
async function GT0(Z, J) {
  let { atomRadiusType: $ } = J;
  for (let X = 0;X < $.length; X += KT0) {
    if (Z.shouldUpdate)
      await Z.update({ message: "Computing per residue surface accessibility...", current: X, max: $.length });
    wU1(J, X, Math.min(X + KT0, $.length));
  }
}
function wU1(Z, J, $) {
  let { structure: X, atomRadiusType: Y, serialResidueIndex: Q, area: W, spherePoints: K, scalingConstant: G, maxLookupRadius: H, probeSize: N } = Z, { lookup3d: q, serialMapping: U, unitIndexMap: F, units: E } = X, { cumulativeUnitElementCount: R, elementIndices: z, unitIndices: D } = U;
  for (let A = J;A < $; ++A) {
    let B = IH[Y[A]];
    if (B === IH[0])
      continue;
    let T = E[D[A]], w = z[A], V = T.conformation.x(w), P = T.conformation.y(w), I = T.conformation.z(w), { count: S, units: f, indices: v, squaredDistances: h } = q.find(V, P, I, H), x = N + B, b = N + x, g = [];
    for (let i = 0;i < S; ++i) {
      let r = f[i], Y0 = R[F.get(r.id)] + v[i], c = z[Y0], n = IH[Y[Y0]];
      if (T === r && w === c || n === IH[0])
        continue;
      let l = N + n;
      if (h[i] < (b + n) * (b + n)) {
        let u = z[Y0];
        g[g.length] = [
          h[i],
          (h[i] + x * x - l * l) / (2 * x),
          r.conformation.x(u) - V,
          r.conformation.y(u) - P,
          r.conformation.z(u) - I
        ];
      }
    }
    g.sort((i, r) => i[0] - r[0]);
    let m = 0;
    Z:
      for (let i = 0;i < K.length; ++i) {
        let [r, Y0, c] = K[i];
        for (let n = 0;n < g.length; ++n) {
          let [, l, u, G0, F0] = g[n];
          if (r * u + Y0 * G0 + c * F0 > l)
            continue Z;
        }
        ++m;
      }
    W[Q[A]] += G * m * x * x;
  }
}

// node_modules/molstar/lib/mol-model-props/computed/accessible-surface-area/shrake-rupley.js
var G00 = {
  numberOfSpherePoints: j.Numeric(92, { min: 12, max: 360, step: 1 }, { description: "Number of sphere points to sample per atom: 92 (original paper), 960 (BioJava), 3000 (EPPIC) - see Shrake A, Rupley JA: Environment and exposure to solvent of protein atoms. Lysozyme and insulin. J Mol Biol 1973." }),
  probeSize: j.Numeric(1.4, { min: 0.1, max: 4, step: 0.01 }, { description: "Corresponds to the size of a water molecule: 1.4 (original paper), 1.5 (occassionally used)" }),
  nonPolymer: j.Boolean(!1, { description: "Include non-polymer atoms as occluders." }),
  traceOnly: j.Boolean(!1, { description: "Compute only using alpha-carbons, if true increase probeSize accordingly (e.g., 4 A). Considers only canonical amino acids." })
};
var Aq;
(function(Z) {
  function J(N, q = {}) {
    let U = { ...j.getDefaultValues(G00), ...q };
    return n0.create("Compute Accessible Surface Area", async (F) => {
      return await $(F, N, U);
    });
  }
  Z.compute = J;
  async function $(N, q, U) {
    let F = X(q, U);
    WT0(F), await GT0(N, F);
    let { area: E, serialResidueIndex: R } = F;
    return { area: E, serialResidueIndex: R };
  }
  function X(N, q) {
    let { elementCount: U, atomicResidueCount: F } = N, { probeSize: E, nonPolymer: R, traceOnly: z, numberOfSpherePoints: D } = q;
    return {
      structure: N,
      probeSize: E,
      nonPolymer: R,
      traceOnly: z,
      spherePoints: Y(D),
      scalingConstant: 4 * Math.PI / D,
      maxLookupRadius: 2 * q.probeSize + 2 * IH[2],
      atomRadiusType: new Int8Array(U),
      serialResidueIndex: new Int32Array(U),
      area: new Float32Array(F)
    };
  }
  function Y(N) {
    let q = [], U = Math.PI * (3 - Math.sqrt(5)), F = 2 / N;
    for (let E = 0;E < N; ++E) {
      let R = E * F - 1 + F / 2, z = Math.sqrt(1 - R * R), D = E * U;
      q[q.length] = M.create(Math.cos(D) * z, R, Math.sin(D) * z);
    }
    return q;
  }
  let Q;
  (function(N) {
    N[N.NA = 0] = "NA", N[N.Buried = 1] = "Buried", N[N.Accessible = 2] = "Accessible";
  })(Q = Z.Flags || (Z.Flags = {})), Z.Flag = {
    NA: Q.NA,
    Buried: Q.Buried,
    Accessible: Q.Accessible
  };
  function W(N, q) {
    let U = _x[N] || QT0;
    return q / U;
  }
  Z.normalize = W;
  function K(N, q) {
    let { area: U, serialResidueIndex: F } = q, E = F[X1.indexOf(X1.ofSortedArray(N.structure.root.serialMapping.elementIndices), N.element)];
    if (E === -1)
      return -1;
    return U[E];
  }
  Z.getValue = K;
  function G(N, q) {
    let U = K(N, q);
    return U === -1 ? -1 : W(w1.atom.label_comp_id(N), U);
  }
  Z.getNormalizedValue = G;
  function H(N, q) {
    let U = G(N, q);
    return U === -1 ? Q.NA : U < 0.16 ? Q.Buried : Q.Accessible;
  }
  Z.getFlag = H;
})(Aq || (Aq = {}));

// node_modules/molstar/lib/mol-model-props/computed/accessible-surface-area.js
var H00 = {
  ...G00
}, Vx = {
  isBuried: NH.Dynamic(lM("computed", "accessible-surface-area.is-buried", r0.Bool), (Z) => {
    if (!j0.isAtomic(Z.element.unit))
      return !1;
    let J = f5.get(Z.element.structure).value;
    if (!J)
      return !1;
    return Aq.getFlag(Z.element, J) === Aq.Flags.Buried;
  }),
  isAccessible: NH.Dynamic(lM("computed", "accessible-surface-area.is-accessible", r0.Bool), (Z) => {
    if (!j0.isAtomic(Z.element.unit))
      return !1;
    let J = f5.get(Z.element.structure).value;
    if (!J)
      return !1;
    return Aq.getFlag(Z.element, J) === Aq.Flags.Accessible;
  })
}, f5 = IW.createProvider({
  label: "Accessible Surface Area",
  descriptor: p7({
    name: "molstar_accessible_surface_area",
    symbols: Vx
  }),
  type: "root",
  defaultParams: H00,
  getParams: (Z) => H00,
  isApplicable: (Z) => !0,
  obtain: async (Z, J, $) => {
    let X = { ...j.getDefaultValues(H00), ...$ };
    return { value: await Aq.compute(J, X).runInContext(Z.runtime) };
  }
});

// node_modules/molstar/lib/mol-model-props/computed/themes/accessible-surface-area.js
var N00 = i0(16448250), jU1 = "Assigns a color based on the relative accessible surface area of a residue.", HT0 = {
  list: j.ColorList("yellow-green-blue", { presetKind: "scale" })
};
function TU1(Z) {
  return HT0;
}
function NT0(Z, J) {
  let $, X = _J.create({
    listOrName: J.list.colors,
    minLabel: "buried",
    maxLabel: "exposed",
    domain: [0, 1]
  }), Y = Z.structure && f5.get(Z.structure), Q = Y ? SQ(Y.id, Y.version) : -1;
  if ((Y === null || Y === void 0 ? void 0 : Y.value) && Z.structure) {
    let W = W0.Location.create(Z.structure), K = Y.value, G = (H) => {
      let N = Aq.getNormalizedValue(H, K);
      return N === -1 ? N00 : X.color(N);
    };
    $ = (H) => {
      if (W0.Location.is(H) && j0.isAtomic(H.unit))
        return G(H);
      else if ($2.isLocation(H))
        return W.unit = H.aUnit, W.element = H.aUnit.elements[H.aIndex], G(W);
      return N00;
    };
  } else
    $ = () => N00;
  return {
    factory: NT0,
    granularity: "group",
    preferSmoothing: !0,
    color: $,
    props: J,
    contextHash: Q,
    description: jU1,
    legend: X ? X.legend : void 0
  };
}
var q00 = {
  name: "accessible-surface-area",
  label: "Accessible Surface Area",
  category: $8.Residue,
  factory: NT0,
  getParams: TU1,
  defaultValues: j.getDefaultValues(HT0),
  isApplicable: (Z) => !!Z.structure,
  ensureCustomProperties: {
    attach: (Z, J) => J.structure ? f5.attach(Z, J.structure, void 0, !0) : Promise.resolve(),
    detach: (Z) => Z.structure && f5.ref(Z.structure, !1)
  }
};

// node_modules/molstar/lib/mol-plugin/behavior/dynamic/custom-props/computed/accessible-surface-area.js
var UT0 = i8.create({
  name: "computed-accessible-surface-area-prop",
  category: "custom-props",
  display: { name: "Accessible Surface Area" },
  ctor: class extends i8.Handler {
    constructor() {
      super(...arguments);
      this.provider = f5, this.labelProvider = {
        label: (Z) => {
          if (!this.params.showTooltip)
            return;
          return _U1(Z);
        }
      };
    }
    update(Z) {
      let J = this.params.autoAttach !== Z.autoAttach || this.params.showTooltip !== Z.showTooltip;
      return this.params.autoAttach = Z.autoAttach, this.params.showTooltip = Z.showTooltip, this.ctx.customStructureProperties.setDefaultAutoAttach(this.provider.descriptor.name, this.params.autoAttach), J;
    }
    register() {
      WA.addCustomProp(this.provider.descriptor), this.ctx.customStructureProperties.register(this.provider, this.params.autoAttach), this.ctx.representation.structure.themes.colorThemeRegistry.add(q00), this.ctx.managers.lociLabels.addProvider(this.labelProvider), this.ctx.query.structure.registry.add(qT0), this.ctx.query.structure.registry.add(FT0);
    }
    unregister() {
      WA.removeCustomProp(this.provider.descriptor), this.ctx.customStructureProperties.unregister(this.provider.descriptor.name), this.ctx.representation.structure.themes.colorThemeRegistry.remove(q00), this.ctx.managers.lociLabels.removeProvider(this.labelProvider), this.ctx.query.structure.registry.remove(qT0), this.ctx.query.structure.registry.remove(FT0);
    }
  },
  params: () => ({
    autoAttach: j.Boolean(!1),
    showTooltip: j.Boolean(!0)
  })
});
function _U1(Z) {
  if (Z.kind === "element-loci") {
    if (Z.elements.length === 0)
      return;
    let J = f5.get(Z.structure).value;
    if (!J || Z.structure.customPropertyDescriptors.hasReference(f5.descriptor))
      return;
    let { getSerialIndex: $ } = Z.structure.root.serialMapping, { area: X, serialResidueIndex: Y } = J, Q = /* @__PURE__ */ new Set, W = 0;
    for (let { indices: G, unit: H } of Z.elements) {
      let { elements: N } = H;
      f0.forEach(G, (q) => {
        let U = Y[$(H, N[q])];
        if (U !== -1 && !Q.has(U))
          W += X[U], Q.add(U);
      });
    }
    if (Q.size === 0)
      return;
    return `Accessible Surface Area ${`<small>(${Q.size} ${Q.size > 1 ? "Residues sum" : "Residue"})</small>`}: ${W.toFixed(2)} Å<sup>2</sup>`;
  } else if (Z.kind === "structure-loci") {
    let J = f5.get(Z.structure).value;
    if (!J || Z.structure.customPropertyDescriptors.hasReference(f5.descriptor))
      return;
    return `Accessible Surface Area <small>(Whole Structure)</small>: ${Di(J.area).toFixed(2)} Å<sup>2</sup>`;
  }
}
var qT0 = hZ("Buried Protein Residues", L0.struct.modifier.union([
  L0.struct.modifier.wholeResidues([
    L0.struct.modifier.union([
      L0.struct.generator.atomGroups({
        "chain-test": L0.core.rel.eq([L0.ammp("objectPrimitive"), "atomistic"]),
        "residue-test": Vx.isBuried.symbol()
      })
    ])
  ])
]), {
  description: "Select buried protein residues.",
  category: fZ.Residue,
  ensureCustomProperties: (Z, J) => {
    return f5.attach(Z, J);
  }
}), FT0 = hZ("Accessible Protein Residues", L0.struct.modifier.union([
  L0.struct.modifier.wholeResidues([
    L0.struct.modifier.union([
      L0.struct.generator.atomGroups({
        "chain-test": L0.core.rel.eq([L0.ammp("objectPrimitive"), "atomistic"]),
        "residue-test": Vx.isAccessible.symbol()
      })
    ])
  ])
]), {
  description: "Select accessible protein residues.",
  category: fZ.Residue,
  ensureCustomProperties: (Z, J) => {
    return f5.attach(Z, J);
  }
});
// node_modules/molstar/lib/mol-model-props/computed/chemistry/util.js
function j6(Z, J) {
  return Z.model.atomicHierarchy.atoms.type_symbol.value(Z.elements[J]);
}
function Ix(Z, J) {
  return Z.model.atomicHierarchy.atoms.pdbx_formal_charge.value(Z.elements[J]);
}
function JE(Z, J) {
  return Z.model.atomicHierarchy.atoms.label_atom_id.value(Z.elements[J]);
}
function qI(Z, J) {
  return Z.model.atomicHierarchy.atoms.label_alt_id.value(Z.elements[J]);
}
function FI(Z, J) {
  return Z.model.atomicHierarchy.atoms.label_comp_id.value(Z.elements[J]);
}
function VU1(Z, J, $) {
  let X = 0, Y = Z.interUnitBonds.getEdgeIndices($, J.id);
  for (let Q = 0, W = Y.length;Q < W; ++Q) {
    let K = Z.interUnitBonds.edges[Y[Q]];
    if (s1.isCovalent(K.props.flag))
      X += 1;
  }
  return X;
}
function IU1(Z, J) {
  let $ = 0, { offset: X, edgeProps: { flags: Y } } = Z.bonds;
  for (let Q = X[J], W = X[J + 1];Q < W; ++Q)
    if (s1.isCovalent(Y[Q]))
      $ += 1;
  return $;
}
function mW(Z, J, $) {
  return VU1(Z, J, $) + IU1(J, $);
}
function SY(Z, J, $, X) {
  let Y = 0;
  return z$(Z, J, $, (Q, W) => {
    if (j6(Q, W) === X)
      Y += 1;
  }), Y;
}
function PU1(Z, J, $) {
  let { offset: X, b: Y, edgeProps: { flags: Q } } = Z.bonds;
  s1.is;
  for (let W = X[J], K = X[J + 1];W < K; ++W)
    if (Y[W] === $ && s1.isCovalent(Q[W]))
      return !0;
  return !1;
}
function CU1(Z, J, $, X, Y) {
  let Q = Z.interUnitBonds.getEdge($, J.id, Y, X.id);
  return Q && s1.isCovalent(Q.props.flag);
}
function LT0(Z, J, $, X, Y) {
  return J === X ? PU1(J, $, Y) : CU1(Z, J, $, X, Y);
}
function kU1(Z, J, $, X) {
  let Y = Z.interUnitBonds.getEdgeIndices($, J.id);
  for (let Q = 0, W = Y.length;Q < W; ++Q) {
    let K = Z.interUnitBonds.edges[Y[Q]], G = Z.unitMap.get(K.unitB);
    if (s1.isCovalent(K.props.flag))
      X(G, K.indexB);
  }
}
function Px(Z, J, $) {
  let { offset: X, b: Y, edgeProps: { flags: Q } } = Z.bonds;
  for (let W = X[J], K = X[J + 1];W < K; ++W)
    if (s1.isCovalent(Q[W]))
      $(Z, Y[W]);
}
function z$(Z, J, $, X) {
  kU1(Z, J, $, X), Px(J, $, X);
}

// node_modules/molstar/lib/mol-model-props/computed/chemistry/geometry.js
var G7;
(function(Z) {
  Z[Z.Spherical = 0] = "Spherical", Z[Z.Terminal = 1] = "Terminal", Z[Z.Linear = 2] = "Linear", Z[Z.Trigonal = 3] = "Trigonal", Z[Z.Tetrahedral = 4] = "Tetrahedral", Z[Z.TrigonalBiPyramidal = 5] = "TrigonalBiPyramidal", Z[Z.Octahedral = 6] = "Octahedral", Z[Z.SquarePlanar = 7] = "SquarePlanar", Z[Z.Unknown = 8] = "Unknown";
})(G7 || (G7 = {}));
function RT0(Z) {
  switch (Z) {
    case G7.Spherical:
      return "Spherical";
    case G7.Terminal:
      return "Terminal";
    case G7.Linear:
      return "Linear";
    case G7.Trigonal:
      return "Trigonal";
    case G7.Tetrahedral:
      return "Tetrahedral";
    case G7.TrigonalBiPyramidal:
      return "Trigonal Bi-Pyramidal";
    case G7.Octahedral:
      return "Octahedral";
    case G7.SquarePlanar:
      return "Square Planar";
    case G7.Unknown:
      return "Unknown";
  }
}
function uz(Z) {
  switch (Z) {
    case 0:
      return G7.Spherical;
    case 1:
      return G7.Terminal;
    case 2:
      return G7.Linear;
    case 3:
      return G7.Trigonal;
    case 4:
      return G7.Tetrahedral;
    default:
      return G7.Unknown;
  }
}
var F00 = /* @__PURE__ */ new Map([
  [G7.Linear, _8(180)],
  [G7.Trigonal, _8(120)],
  [G7.Tetrahedral, _8(109.4721)],
  [G7.Octahedral, _8(90)]
]), $B = M(), JB = M(), PH = M(), $E = M(), Bq = M();
function XB(Z, J, $, X, Y, Q = !0) {
  let W = [], K = [];
  return J.conformation.position(J.elements[$], PH), X.conformation.position(X.elements[Y], $E), M.sub($B, $E, PH), z$(Z, J, $, (G, H) => {
    if (j6(G, H) !== l1.H)
      G.conformation.position(G.elements[H], Bq), M.sub(JB, Bq, PH), W.push(M.angle($B, JB));
    else if (!Q)
      G.conformation.position(G.elements[H], Bq), M.sub(JB, Bq, PH), K.push(M.angle($B, JB));
  }), [W, K];
}
function U00(Z, J, $, X, Y) {
  J.conformation.position(J.elements[$], PH), X.conformation.position(X.elements[Y], $E), M.sub($B, $E, PH);
  let Q = [M(), M()], W = 0, K, G;
  if (z$(Z, J, $, (H, N) => {
    if (W > 1)
      return;
    if (j6(H, N) !== l1.H)
      K = H, G = N, H.conformation.position(H.elements[N], Bq), M.sub(Q[W++], Bq, PH);
  }), W === 1 && K && G)
    z$(Z, K, G, (H, N) => {
      if (W > 1)
        return;
      if (H === J && N === $)
        return;
      if (j6(H, N) !== l1.H)
        H.conformation.position(H.elements[N], Bq), M.sub(Q[W++], Bq, PH);
    });
  if (W !== 2)
    return;
  return M.cross(JB, Q[0], Q[1]), Math.abs(Math.PI / 2 - M.angle(JB, $B));
}
function ET0(Z, J, $, X, Y) {
  let Q = $;
  J.conformation.position(J.elements[$], PH), X.conformation.position(X.elements[Y], $E), M.sub($B, $E, PH);
  let W = M.squaredDistance(PH, $E);
  return z$(Z, J, $, (K, G) => {
    if (j6(K, G) === l1.H) {
      K.conformation.position(K.elements[G], Bq);
      let H = M.squaredDistance(Bq, $E);
      if (H < W)
        W = H, Q = G;
    }
  }), Q;
}

// node_modules/molstar/lib/mol-model-props/computed/chemistry/valence-model.js
var L00 = new $2.ElementBondIterator, R00 = new $2.ElementBondIterator;
function vU1(Z, J, $) {
  let X = j6(J, $), Y = X === l1.O || X === l1.N;
  if (Y && mW(Z, J, $) === 4)
    return !1;
  L00.setElement(Z, J, $);
  while (L00.hasNext) {
    let Q = L00.move();
    if (Q.order > 1)
      return !0;
    if (Y) {
      let W = j6(Q.otherUnit, Q.otherIndex);
      R00.setElement(Z, Q.otherUnit, Q.otherIndex);
      while (R00.hasNext) {
        let K = R00.move();
        if (K.order > 1) {
          if ((W === l1.P || W === l1.S) && j6(K.otherUnit, K.otherIndex) === l1.O)
            continue;
          return !0;
        }
      }
    }
  }
  return !1;
}
function SU1(Z, J, $) {
  let X = 0, { offset: Y, edgeProps: { flags: Q, order: W } } = J.bonds;
  for (let K = Y[$], G = Y[$ + 1];K < G; ++K)
    if (s1.isCovalent(Q[K]))
      X += W[K];
  return Z.interUnitBonds.getEdgeIndices($, J.id).forEach((K) => {
    let G = Z.interUnitBonds.edges[K];
    if (s1.isCovalent(G.props.flag))
      X += G.props.order;
  }), X;
}
var YB = new $2.ElementBondIterator, E00 = new $2.ElementBondIterator;
function fU1(Z, J, $, X, Y) {
  let Q = SY(Z, J, $, l1.H), W = j6(J, $), K = Ix(J, $), G = X.assignCharge === "always" || X.assignCharge === "auto" && K === 0, H = X.assignH === "always" || X.assignH === "auto" && !Y && Q === 0, N = mW(Z, J, $), q = SU1(Z, J, $), U = vU1(Z, J, $), F = q - N > 0, E = 0, R = G7.Unknown;
  switch (W) {
    case l1.H:
      if (G) {
        if (N === 0)
          K = 1, R = G7.Spherical;
        else if (N === 1)
          K = 0, R = G7.Terminal;
      }
      break;
    case l1.C:
      if (G)
        K = 0;
      if (H)
        E = Math.max(0, 4 - q - Math.abs(K));
      R = uz(N + E + Math.max(0, -K));
      break;
    case l1.N:
      if (G)
        if (!H)
          K = q - 3;
        else if (U && q < 4)
          if (N - Q === 1 && q - Q === 2)
            K = 1;
          else
            K = 0;
        else {
          YB.setElement(Z, J, $);
          while (YB.hasNext) {
            let z = YB.move(), D = j6(z.otherUnit, z.otherIndex);
            if (D === l1.S || tN0(D)) {
              K = 0;
              break;
            } else
              K = 1;
          }
        }
      if (H)
        E = Math.max(0, 3 - q + K);
      if (U && !F)
        R = uz(N + E - K);
      else
        R = uz(N + E + 1 - K);
      break;
    case l1.O:
      if (G) {
        if (!H)
          K = q - 2;
        if (q === 1) {
          YB.setElement(Z, J, $);
          Z:
            while (YB.hasNext) {
              let z = YB.move();
              E00.setElement(Z, z.otherUnit, z.otherIndex);
              while (E00.hasNext) {
                let D = E00.move();
                if (!(D.otherUnit === J && D.otherIndex === $) && j6(D.otherUnit, D.otherIndex) === l1.O && D.order === 2) {
                  K = -1;
                  break Z;
                }
              }
            }
        }
      }
      if (H)
        E = Math.max(0, 2 - q + K);
      if (U && !F)
        R = uz(N + E - K + 1);
      else
        R = uz(N + E - K + 2);
      break;
    case l1.S:
      if (G) {
        if (!H)
          if (q <= 3 && SY(Z, J, $, l1.O) === 0)
            K = q - 2;
          else
            K = 0;
      }
      if (H) {
        if (q < 2)
          E = Math.max(0, 2 - q + K);
      }
      if (q <= 3)
        R = uz(N + E - K + 2);
      break;
    case l1.F:
    case l1.CL:
    case l1.BR:
    case l1.I:
    case l1.AT:
      if (G)
        K = q - 1;
      break;
    case l1.LI:
    case l1.NA:
    case l1.K:
    case l1.RB:
    case l1.CS:
    case l1.FR:
      if (G)
        K = 1 - q;
      break;
    case l1.BE:
    case l1.MG:
    case l1.CA:
    case l1.SR:
    case l1.BA:
    case l1.RA:
      if (G)
        K = 2 - q;
      break;
    default:
      if (y2)
        console.warn("Requested charge, protonation for an unhandled element", W);
  }
  return [K, E, E + Q, R];
}
function hU1(Z, J, $) {
  let X = J.elements.length, Y = new Int8Array(X), Q = new Int8Array(X), W = new Int8Array(X), K = new Int8Array(X), G = !!Z.parent, H;
  if (G) {
    let q = Z.root.unitMap.get(J.id);
    if (H = X1.indicesOf(q.elements, J.elements), H.length !== J.elements.length)
      throw new Error("expected to find an index for every element");
    J = q, Z = Z.root;
  }
  let N = !1;
  for (let q = 0;q < X; ++q) {
    let U = G ? H[q] : q;
    if (j6(J, U) === l1.H) {
      N = !0;
      break;
    }
  }
  for (let q = 0;q < X; ++q) {
    let U = G ? H[q] : q, [F, E, R, z] = fU1(Z, J, U, $, N);
    Y[q] = F, Q[q] = E, W[q] = R, K[q] = z;
  }
  return { charge: Y, implicitH: Q, totalH: W, idealGeometry: K };
}
var O00 = {
  assignCharge: j.Select("auto", [["always", "always"], ["auto", "auto"], ["never", "never"]]),
  assignH: j.Select("auto", [["always", "always"], ["auto", "auto"], ["never", "never"]])
};
async function OT0(Z, J, $) {
  let X = { ...j.getDefaultValues(O00), ...$ }, Y = /* @__PURE__ */ new Map, Q = `valence-model-${JSON.stringify(X)}`;
  for (let W = 0, K = J.units.length;W < K; ++W) {
    let G = J.units[W];
    if (j0.isAtomic(G)) {
      let H;
      if (G.transientCache.has(Q))
        H = G.transientCache.get(Q);
      else
        H = hU1(J, G, X), G.transientCache.set(Q, H);
      Y.set(G.id, H);
    }
  }
  return Y;
}

// node_modules/molstar/lib/mol-model-props/computed/valence-model.js
var z00 = {
  ...O00
}, wq = IW.createProvider({
  label: "Valence Model",
  descriptor: p7({
    name: "molstar_computed_valence_model"
  }),
  type: "local",
  defaultParams: z00,
  getParams: (Z) => z00,
  isApplicable: (Z) => !0,
  obtain: async (Z, J, $) => {
    let X = { ...j.getDefaultValues(z00), ...$ };
    return { value: await OT0(Z.runtime, J, X) };
  }
});

// node_modules/molstar/lib/mol-model-props/computed/interactions/features.js
var D9;
(function(Z) {
  function J(q, U, F, E) {
    return M.set(q, E.x[F], E.y[F], E.z[F]), M.transformMat4(q, q, U.conformation.operator.matrix), q;
  }
  Z.setPosition = J;
  function $(q, U) {
    let F = new Int32Array(U + 1), E = new Int32Array(U), R = new Int32Array(U), { members: z, count: D, offsets: A } = q;
    for (let w = 0, V = A[D];w < V; ++w)
      ++R[z[w]];
    let B = 0;
    for (let w = 0;w < U; w++)
      F[w] = B, B += R[w];
    F[U] = B;
    let T = new Int32Array(B);
    for (let w = 0;w < D; ++w)
      for (let V = A[w], P = A[w + 1];V < P; ++V) {
        let I = z[V], S = F[I] + E[I];
        T[S] = w, ++E[I];
      }
    return { indices: T, offsets: F };
  }
  Z.createElementsIndex = $;
  function X(q, U) {
    let F, E;
    return {
      ...U,
      get lookup3d() {
        if (!F) {
          let R = { x: U.x, y: U.y, z: U.z, indices: f0.ofBounds(0, U.count) };
          F = TW(R, GH(R));
        }
        return F;
      },
      get elementsIndex() {
        return E || (E = $(U, q));
      },
      subset: (R) => Y(U, R)
    };
  }
  Z.create = X;
  function Y(q, U) {
    let F, { count: E, types: R } = q, z = [];
    for (let A = 0;A < E; ++A)
      if (U.has(R[A]))
        z.push(A);
    let D = X1.ofSortedArray(z);
    return {
      indices: D,
      get lookup3d() {
        if (!F) {
          let A = { x: q.x, y: q.y, z: q.z, indices: D };
          F = TW(A, GH(A));
        }
        return F;
      }
    };
  }
  Z.createSubset = Y;
  function Q(q, U, F) {
    let E = wq.get(q).value;
    if (!E || !E.has(U.id))
      throw new Error("valence model required");
    return {
      unit: U,
      types: F.types,
      feature: -1,
      x: F.x,
      y: F.y,
      z: F.z,
      members: F.members,
      offsets: F.offsets,
      idealGeometry: E.get(U.id).idealGeometry
    };
  }
  Z.Info = Q;
  function W(q, U) {
    return M.set(q, U.x[U.feature], U.y[U.feature], U.z[U.feature]), M.transformMat4(q, q, U.unit.conformation.operator.matrix), q;
  }
  Z.position = W;
  let K = M(), G = M();
  function H(q, U) {
    let F = q.members[q.offsets[q.feature]], E = U.members[U.offsets[U.feature]];
    return q.unit.conformation.position(q.unit.elements[F], K), U.unit.conformation.position(U.unit.elements[E], G), M.distance(K, G);
  }
  Z.distance = H;
  function N(q, U) {
    return { types: new Set(q), add: U };
  }
  Z.Provider = N;
})(D9 || (D9 = {}));
var Cx;
(function(Z) {
  function J($ = 2048, X = 1024, Y) {
    let Q = B1.create(Float32Array, 1, X, Y ? Y.x : $), W = B1.create(Float32Array, 1, X, Y ? Y.y : $), K = B1.create(Float32Array, 1, X, Y ? Y.z : $), G = B1.create(Uint8Array, 1, X, Y ? Y.types : $), H = B1.create(Uint8Array, 1, X, Y ? Y.groups : $), N = B1.create(Uint32Array, 1, X, Y ? Y.offsets : $), q = B1.create(Uint32Array, 1, X, Y ? Y.members : $), U = { x: 0, y: 0, z: 0, offset: 0, count: 0 };
    return {
      startState: () => {
        U.x = 0, U.y = 0, U.z = 0, U.offset = q.elementCount, U.count = 0;
      },
      pushMember: (F, E, R, z) => {
        B1.add(q, z), U.x += F, U.y += E, U.z += R, U.count += 1;
      },
      finishState: (F, E) => {
        let { count: R } = U;
        if (R === 0)
          return;
        B1.add(G, F), B1.add(H, E), B1.add(Q, U.x / R), B1.add(W, U.y / R), B1.add(K, U.z / R), B1.add(N, U.offset);
      },
      add: (F, E, R, z, D, A) => {
        B1.add(G, F), B1.add(H, E), B1.add(Q, R), B1.add(W, z), B1.add(K, D), B1.add(N, q.elementCount), B1.add(q, A);
      },
      getFeatures: (F) => {
        B1.add(N, q.elementCount);
        let E = B1.compact(Q, !0), R = B1.compact(W, !0), z = B1.compact(K, !0), D = Q.elementCount;
        return D9.create(F, {
          x: E,
          y: R,
          z,
          count: D,
          types: B1.compact(G, !0),
          groups: B1.compact(H, !0),
          offsets: B1.compact(N, !0),
          members: B1.compact(q, !0)
        });
      }
    };
  }
  Z.create = J;
})(Cx || (Cx = {}));

// node_modules/molstar/lib/mol-model-props/computed/interactions/common.js
var kx;
(function(Z) {
  function J($, X, Y) {
    let Q = new Int32Array(Y + 1), W = new Int32Array(Y), K = new Int32Array(Y), { members: G, offsets: H } = X;
    for (let U = 0, F = $.edgeCount * 2;U < F; ++U) {
      let E = $.a[U], R = $.b[U];
      if (E > R)
        continue;
      for (let z = H[E], D = H[E + 1];z < D; ++z)
        ++K[G[z]];
      for (let z = H[R], D = H[R + 1];z < D; ++z)
        ++K[G[z]];
    }
    let N = 0;
    for (let U = 0;U < Y; U++)
      Q[U] = N, N += K[U];
    Q[Y] = N;
    let q = new Int32Array(N);
    for (let U = 0, F = $.edgeCount * 2;U < F; ++U) {
      let E = $.a[U], R = $.b[U];
      if (E > R)
        continue;
      for (let z = H[E], D = H[E + 1];z < D; ++z) {
        let A = G[z], B = Q[A] + W[A];
        q[B] = U, ++W[A];
      }
      for (let z = H[R], D = H[R + 1];z < D; ++z) {
        let A = G[z], B = Q[A] + W[A];
        q[B] = U, ++W[A];
      }
    }
    return { indices: q, offsets: Q };
  }
  Z.createElementsIndex = J;
})(kx || (kx = {}));
class D00 extends FY {
  getContactIndicesForElement(Z, J) {
    return this.elementKeyIndex.get(this.getElementKey(Z, J.id)) || [];
  }
  getElementKey(Z, J) {
    return `${Z}|${J}`;
  }
  constructor(Z, J) {
    super(Z);
    this.elementKeyIndex = /* @__PURE__ */ new Map;
    for (let $ = 0, X = this.edges.length;$ < X; ++$) {
      let { unitA: Y, indexA: Q } = this.edges[$], { offsets: W, members: K } = J.get(Y);
      for (let G = W[Q], H = W[Q + 1];G < H; ++G) {
        let N = this.getElementKey(K[G], Y), q = this.elementKeyIndex.get(N);
        if (q === void 0)
          this.elementKeyIndex.set(N, [$]);
        else
          q.push($);
      }
    }
  }
}
var dW;
(function(Z) {
  Z[Z.None = 0] = "None", Z[Z.Filtered = 1] = "Filtered";
})(dW || (dW = {}));
var o8;
(function(Z) {
  Z[Z.Unknown = 0] = "Unknown", Z[Z.Ionic = 1] = "Ionic", Z[Z.CationPi = 2] = "CationPi", Z[Z.PiStacking = 3] = "PiStacking", Z[Z.HydrogenBond = 4] = "HydrogenBond", Z[Z.HalogenBond = 5] = "HalogenBond", Z[Z.Hydrophobic = 6] = "Hydrophobic", Z[Z.MetalCoordination = 7] = "MetalCoordination", Z[Z.WeakHydrogenBond = 8] = "WeakHydrogenBond";
})(o8 || (o8 = {}));
function M00(Z) {
  switch (Z) {
    case o8.HydrogenBond:
      return "Hydrogen Bond";
    case o8.Hydrophobic:
      return "Hydrophobic Contact";
    case o8.HalogenBond:
      return "Halogen Bond";
    case o8.Ionic:
      return "Ionic Interaction";
    case o8.MetalCoordination:
      return "Metal Coordination";
    case o8.CationPi:
      return "Cation-Pi Interaction";
    case o8.PiStacking:
      return "Pi Stacking";
    case o8.WeakHydrogenBond:
      return "Weak Hydrogen Bond";
    case o8.Unknown:
      return "Unknown Interaction";
  }
}
var F2;
(function(Z) {
  Z[Z.None = 0] = "None", Z[Z.PositiveCharge = 1] = "PositiveCharge", Z[Z.NegativeCharge = 2] = "NegativeCharge", Z[Z.AromaticRing = 3] = "AromaticRing", Z[Z.HydrogenDonor = 4] = "HydrogenDonor", Z[Z.HydrogenAcceptor = 5] = "HydrogenAcceptor", Z[Z.HalogenDonor = 6] = "HalogenDonor", Z[Z.HalogenAcceptor = 7] = "HalogenAcceptor", Z[Z.HydrophobicAtom = 8] = "HydrophobicAtom", Z[Z.WeakHydrogenDonor = 9] = "WeakHydrogenDonor", Z[Z.IonicTypePartner = 10] = "IonicTypePartner", Z[Z.DativeBondPartner = 11] = "DativeBondPartner", Z[Z.TransitionMetal = 12] = "TransitionMetal", Z[Z.IonicTypeMetal = 13] = "IonicTypeMetal";
})(F2 || (F2 = {}));
var zT0;
(function(Z) {
  Z[Z.None = 0] = "None", Z[Z.PositiveCharge = 1] = "PositiveCharge", Z[Z.NegativeCharge = 2] = "NegativeCharge", Z[Z.AromaticRing = 3] = "AromaticRing", Z[Z.HydrogenDonor = 4] = "HydrogenDonor", Z[Z.HydrogenAcceptor = 5] = "HydrogenAcceptor", Z[Z.HalogenDonor = 6] = "HalogenDonor", Z[Z.HalogenAcceptor = 7] = "HalogenAcceptor", Z[Z.HydrophobicAtom = 8] = "HydrophobicAtom", Z[Z.WeakHydrogenDonor = 9] = "WeakHydrogenDonor", Z[Z.IonicTypePartner = 10] = "IonicTypePartner", Z[Z.DativeBondPartner = 11] = "DativeBondPartner", Z[Z.TransitionMetal = 12] = "TransitionMetal", Z[Z.IonicTypeMetal = 13] = "IonicTypeMetal";
})(zT0 || (zT0 = {}));
function DT0(Z) {
  switch (Z) {
    case F2.None:
      return "None";
    case F2.PositiveCharge:
      return "Positive Charge";
    case F2.NegativeCharge:
      return "Negative Charge";
    case F2.AromaticRing:
      return "Aromatic Ring";
    case F2.HydrogenDonor:
      return "Hydrogen Donor";
    case F2.HydrogenAcceptor:
      return "Hydrogen Acceptor";
    case F2.HalogenDonor:
      return "Halogen Donor";
    case F2.HalogenAcceptor:
      return "Halogen Acceptor";
    case F2.HydrophobicAtom:
      return "HydrophobicAtom";
    case F2.WeakHydrogenDonor:
      return "Weak Hydrogen Donor";
    case F2.IonicTypePartner:
      return "Ionic Type Partner";
    case F2.DativeBondPartner:
      return "Dative Bond Partner";
    case F2.TransitionMetal:
      return "Transition Metal";
    case F2.IonicTypeMetal:
      return "Ionic Type Metal";
  }
}
var IZ;
(function(Z) {
  Z[Z.None = 0] = "None", Z[Z.QuaternaryAmine = 1] = "QuaternaryAmine", Z[Z.TertiaryAmine = 2] = "TertiaryAmine", Z[Z.Sulfonium = 3] = "Sulfonium", Z[Z.SulfonicAcid = 4] = "SulfonicAcid", Z[Z.Sulfate = 5] = "Sulfate", Z[Z.Phosphate = 6] = "Phosphate", Z[Z.Halocarbon = 7] = "Halocarbon", Z[Z.Guanidine = 8] = "Guanidine", Z[Z.Acetamidine = 9] = "Acetamidine", Z[Z.Carboxylate = 10] = "Carboxylate";
})(IZ || (IZ = {}));
function MT0(Z) {
  switch (Z) {
    case IZ.None:
      return "None";
    case IZ.QuaternaryAmine:
      return "Quaternary Amine";
    case IZ.TertiaryAmine:
      return "Tertiary Amine";
    case IZ.Sulfonium:
      return "Sulfonium";
    case IZ.SulfonicAcid:
      return "Sulfonic Acid";
    case IZ.Sulfate:
      return "Sulfate";
    case IZ.Phosphate:
      return "Phosphate";
    case IZ.Halocarbon:
      return "Halocarbon";
    case IZ.Guanidine:
      return "Guanidine";
    case IZ.Acetamidine:
      return "Acetamidine";
    case IZ.Carboxylate:
      return "Carboxylate";
  }
}

// node_modules/molstar/lib/mol-model-props/computed/interactions/contacts-builder.js
var vx;
(function(Z) {
  function J($, X) {
    let Y = [], Q = [], W = [];
    return {
      add(K, G, H) {
        Y[Y.length] = K, Q[Q.length] = G, W[W.length] = H;
      },
      getContacts() {
        let K = new lJ.EdgeBuilder($.count, Y, Q), G = new Int8Array(K.slotCount), H = new Int8Array(K.slotCount);
        for (let F = 0, E = K.edgeCount;F < E; F++)
          K.addNextEdge(), K.assignProperty(G, W[F]);
        let N = K.createGraph({ type: G, flag: H }), q;
        return Object.defineProperty(N, "elementsIndex", {
          get: () => {
            return q || (q = kx.createElementsIndex(N, $, X));
          }
        });
      }
    };
  }
  Z.create = J;
})(vx || (vx = {}));
var Sx;
(function(Z) {
  function J() {
    let $ = new FY.Builder;
    return {
      startUnitPair(X, Y) {
        $.startUnitPair(X.id, Y.id);
      },
      finishUnitPair() {
        $.finishUnitPair();
      },
      add(X, Y, Q) {
        $.add(X, Y, { type: Q, flag: dW.None });
      },
      getContacts(X) {
        return new D00($.getMap(), X);
      }
    };
  }
  Z.create = J;
})(Sx || (Sx = {}));

// node_modules/molstar/lib/mol-model-props/computed/interactions/contacts.js
var wT0 = {
  lineOfSightDistFactor: j.Numeric(1, { min: 0, max: 3, step: 0.1 })
}, bU1 = 3;
function jT0(Z, J, $) {
  let X = J.members[J.offsets[J.feature]], Y = $.members[$.offsets[$.feature]];
  if (X === Y && J.unit === $.unit)
    return !1;
  let Q = qI(J.unit, X), W = qI($.unit, Y);
  if (Q && W && Q !== W)
    return !1;
  if (J.unit === $.unit && J.unit.model.atomicHierarchy.residueAtomSegments.count > 1 && J.unit.residueIndex[J.unit.elements[X]] === $.unit.residueIndex[$.unit.elements[Y]])
    return !1;
  if (LT0(Z, J.unit, X, $.unit, Y))
    return !1;
  return !0;
}
function AT0(Z, J, $, X) {
  let Y = qI(Z, J), Q = qI($, X);
  return Y && Q && Y !== Q;
}
function BT0(Z, J) {
  let { feature: $, offsets: X, members: Y } = J;
  for (let Q = X[$], W = X[$ + 1];Q < W; ++Q)
    if (Y[Q] === Z)
      return !0;
  return !1;
}
var XE = M(), A00 = M(), B00 = M(), xU1 = tM();
function TT0(Z, J, $, X) {
  let Y = J.feature, Q = $.feature, W = J.members[J.offsets[Y]], K = $.members[$.offsets[Q]];
  D9.position(A00, J), D9.position(B00, $), M.scale(XE, M.add(XE, A00, B00), 0.5);
  let G = X * bU1, { count: H, indices: N, units: q, squaredDistances: U } = Z.lookup3d.find(XE[0], XE[1], XE[2], G, xU1);
  if (H === 0)
    return !0;
  for (let F = 0;F < H; ++F) {
    let E = N[F], R = q[F];
    if (!j0.isAtomic(R))
      continue;
    let z = j6(R, E);
    if (z === l1.H)
      continue;
    let D = D5(z);
    if (D * D * X * X <= U[F])
      continue;
    if (AT0(R, E, J.unit, W) || AT0(R, E, $.unit, K))
      continue;
    if (J.unit === R && BT0(E, J) || $.unit === R && BT0(E, $))
      continue;
    if (R.conformation.position(R.elements[E], XE), M.squaredDistance(XE, A00) < 1 || M.squaredDistance(XE, B00) < 1)
      continue;
    return !1;
  }
  return !0;
}
function _T0(Z, J, $, X, Y, Q) {
  for (let W of Y)
    yU1(Z, J, $, X, W, Q);
}
function yU1(Z, J, $, X, Y, Q) {
  let { x: W, y: K, z: G } = $, { lookup3d: H, indices: N } = $.subset(Y.requiredFeatures), q = D9.Info(Z, J, $), U = { ...q }, F = Q.lineOfSightDistFactor;
  for (let E = 0, R = f0.size(N);E < R; ++E) {
    let z = f0.getAt(N, E), { count: D, indices: A, squaredDistances: B } = H.find(W[z], K[z], G[z], Y.maxDistance);
    if (D === 0)
      continue;
    q.feature = z;
    for (let T = 0;T < D; ++T) {
      let w = f0.getAt(N, A[T]);
      if (w <= z)
        continue;
      if (U.feature = w, !jT0(Z, q, U))
        continue;
      let V = Y.getType(Z, q, U, B[T]);
      if (V && TT0(Z, q, U, F))
        X.add(z, w, V);
    }
  }
}
var gU1 = e();
function VT0(Z, J, $, X, Y, Q, W, K) {
  let { count: G, x: H, y: N, z: q } = $, { lookup3d: U } = Y, F = e.mul(gU1, X.conformation.operator.inverse, J.conformation.operator.matrix), E = !e.isIdentity(F), R = M(), z = Math.max(...W.map((P) => P.maxDistance)), { center: D, radius: A } = U.boundary.sphere, B = (A + z) * (A + z), T = K.lineOfSightDistFactor, w = D9.Info(Z, J, $), V = D9.Info(Z, X, Y);
  Q.startUnitPair(J, X);
  for (let P = 0;P < G; ++P) {
    if (M.set(R, H[P], N[P], q[P]), E)
      M.transformMat4(R, R, F);
    if (M.squaredDistance(R, D) > B)
      continue;
    let { indices: I, count: S, squaredDistances: f } = U.find(R[0], R[1], R[2], z);
    if (S === 0)
      continue;
    w.feature = P;
    for (let v = 0;v < S; ++v) {
      let h = I[v];
      if (V.feature = h, !jT0(Z, w, V))
        continue;
      let x = f[v];
      for (let b of W)
        if (x < b.maxDistance * b.maxDistance) {
          let g = b.getType(Z, w, V, x);
          if (g && TT0(Z, w, V, T)) {
            Q.add(P, h, g);
            break;
          }
        }
    }
  }
  Q.finishUnitPair();
}

// node_modules/molstar/lib/mol-model-props/computed/interactions/halogen-bonds.js
var mU1 = {
  distanceMax: j.Numeric(4, { min: 1, max: 5, step: 0.1 }),
  angleMax: j.Numeric(30, { min: 0, max: 60, step: 1 })
}, dU1 = [l1.CL, l1.BR, l1.I, l1.AT];
function pU1(Z, J, $) {
  let { elements: X } = J, { x: Y, y: Q, z: W } = J.model.atomicConformation;
  for (let K = 0, G = X.length;K < G; ++K) {
    let H = j6(J, K);
    if (dU1.includes(H))
      $.add(F2.HalogenDonor, IZ.None, Y[X[K]], Q[X[K]], W[X[K]], K);
  }
}
var uU1 = [l1.N, l1.O, l1.S], cU1 = [l1.C, l1.N, l1.P, l1.S];
function lU1(Z, J, $) {
  let { elements: X } = J, { x: Y, y: Q, z: W } = J.model.atomicConformation;
  for (let K = 0, G = X.length;K < G; ++K) {
    let H = j6(J, K);
    if (uU1.includes(H)) {
      let N = !1;
      if (z$(Z, J, K, (q, U) => {
        if (cU1.includes(j6(q, U)))
          N = !0;
      }), N)
        $.add(F2.HalogenAcceptor, IZ.None, Y[X[K]], Q[X[K]], W[X[K]], K);
    }
  }
}
function nU1(Z, J) {
  return Z === F2.HalogenAcceptor && J === F2.HalogenDonor || Z === F2.HalogenDonor && J === F2.HalogenAcceptor;
}
var iU1 = _8(180), oU1 = _8(120);
function sU1(Z) {
  return {
    angleMax: _8(Z.angleMax)
  };
}
function aU1(Z, J, $, X) {
  let Y = J.types[J.feature], Q = $.types[$.feature];
  if (!nU1(Y, Q))
    return;
  let [W, K] = Y === F2.HalogenDonor ? [J, $] : [$, J], G = W.members[W.offsets[W.feature]], H = K.members[K.offsets[K.feature]], [N] = XB(Z, W.unit, G, K.unit, H);
  if (N.length !== 1)
    return;
  if (iU1 - N[0] > X.angleMax)
    return;
  let [q] = XB(Z, K.unit, H, W.unit, G);
  if (q.length === 0)
    return;
  if (q.some((U) => oU1 - U > X.angleMax))
    return;
  return o8.HalogenBond;
}
var IT0 = D9.Provider([F2.HalogenDonor], pU1), PT0 = D9.Provider([F2.HalogenAcceptor], lU1), CT0 = {
  name: "halogen-bonds",
  params: mU1,
  createTester: (Z) => {
    let J = sU1(Z);
    return {
      maxDistance: Z.distanceMax,
      requiredFeatures: /* @__PURE__ */ new Set([F2.HalogenDonor, F2.HalogenAcceptor]),
      getType: ($, X, Y) => aU1($, X, Y, J)
    };
  }
};

// node_modules/molstar/lib/mol-model-props/computed/interactions/hydrogen-bonds.js
var fT0 = {
  distanceMax: j.Numeric(3.5, { min: 1, max: 5, step: 0.1 }),
  backbone: j.Boolean(!0, { description: "Include backbone-to-backbone hydrogen bonds" }),
  accAngleDevMax: j.Numeric(45, { min: 0, max: 180, step: 1 }, { description: "Max deviation from ideal acceptor angle" }),
  ignoreHydrogens: j.Boolean(!1, { description: "Ignore explicit hydrogens in geometric constraints" }),
  donAngleDevMax: j.Numeric(45, { min: 0, max: 180, step: 1 }, { description: "Max deviation from ideal donor angle" }),
  accOutOfPlaneAngleMax: j.Numeric(90, { min: 0, max: 180, step: 1 }),
  donOutOfPlaneAngleMax: j.Numeric(45, { min: 0, max: 180, step: 1 })
}, rU1 = {
  ...fT0,
  water: j.Boolean(!1, { description: "Include water-to-water hydrogen bonds" }),
  sulfurDistanceMax: j.Numeric(4.1, { min: 1, max: 5, step: 0.1 })
}, tU1 = {
  ...fT0
};
function w00(Z, J) {
  let $ = wq.get(Z).value;
  if (!$)
    throw Error("expected valence model to be available");
  let X = $.get(J.id);
  if (!X)
    throw Error("expected valence model for unit to be available");
  return X;
}
function eU1(Z, J, $) {
  let { totalH: X } = w00(Z, J), { elements: Y } = J, { x: Q, y: W, z: K } = J.model.atomicConformation;
  for (let G = 0, H = Y.length;G < H; ++G) {
    let N = j6(J, G);
    if (hT0(J, G) || X[G] > 0 && (N === l1.N || N === l1.O || N === l1.S))
      $.add(F2.HydrogenDonor, IZ.None, Q[Y[G]], W[Y[G]], K[Y[G]], G);
  }
}
function ZL1(Z, J, $) {
  let { totalH: X } = w00(Z, J), { elements: Y } = J, { x: Q, y: W, z: K } = J.model.atomicConformation;
  for (let G = 0, H = Y.length;G < H; ++G)
    if (j6(J, G) === l1.C && X[G] > 0 && (SY(Z, J, G, l1.N) > 0 || SY(Z, J, G, l1.O) > 0 || JL1(J, G)))
      $.add(F2.WeakHydrogenDonor, IZ.None, Q[Y[G]], W[Y[G]], K[Y[G]], G);
}
function JL1(Z, J) {
  let { elementAromaticRingIndices: $, all: X } = Z.rings, Y = $.get(J);
  if (Y === void 0)
    return !1;
  for (let Q = 0, W = Y.length;Q < W; ++Q) {
    let K = X[Y[Q]];
    for (let G = 0, H = K.length;G < H; ++G) {
      let N = j6(Z, K[G]);
      if (N === l1.N || N === l1.O)
        return !0;
    }
  }
  return !1;
}
function $L1(Z, J, $) {
  let { charge: X, implicitH: Y, idealGeometry: Q } = w00(Z, J), { elements: W } = J, { x: K, y: G, z: H } = J.model.atomicConformation, N = (q) => {
    $.add(F2.HydrogenAcceptor, IZ.None, K[W[q]], G[W[q]], H[W[q]], q);
  };
  for (let q = 0, U = W.length;q < U; ++q) {
    let F = j6(J, q);
    if (F === l1.O)
      N(q);
    else if (F === l1.N) {
      if (hT0(J, q))
        N(q);
      else if (X[q] < 1) {
        let E = mW(Z, J, q) + Y[q], R = Q[q];
        if (R === G7.Tetrahedral && E < 4 || R === G7.Trigonal && E < 3 || R === G7.Linear && E < 2)
          N(q);
      }
    } else if (F === l1.S) {
      let E = FI(J, q);
      if (E === "CYS" || E === "MET" || Ix(J, q) === -1)
        N(q);
    }
  }
}
function kT0(Z, J) {
  return Z.model.atomicHierarchy.derived.residue.moleculeType[Z.residueIndex[Z.elements[J]]] === e2.Water;
}
function vT0(Z, J) {
  return jK.has(JE(Z, J));
}
function XL1(Z, J) {
  return Z.rings.elementRingIndices.has(J);
}
function hT0(Z, J) {
  return FI(Z, J) === "HIS" && j6(Z, J) === l1.N && XL1(Z, J);
}
function YL1(Z, J, $, X) {
  return vT0(Z, J) && vT0($, X);
}
function QL1(Z, J, $, X) {
  return kT0(Z, J) && kT0($, X);
}
function WL1(Z, J) {
  return Z === F2.HydrogenAcceptor && J === F2.HydrogenDonor || Z === F2.HydrogenDonor && J === F2.HydrogenAcceptor;
}
function KL1(Z, J) {
  return Z === F2.WeakHydrogenDonor && J === F2.HydrogenAcceptor || Z === F2.HydrogenAcceptor && J === F2.WeakHydrogenDonor;
}
function bT0(Z) {
  return {
    ignoreHydrogens: Z.ignoreHydrogens,
    includeBackbone: Z.backbone,
    maxAccAngleDev: _8(Z.accAngleDevMax),
    maxDonAngleDev: _8(Z.donAngleDevMax),
    maxAccOutOfPlaneAngle: _8(Z.accOutOfPlaneAngleMax),
    maxDonOutOfPlaneAngle: _8(Z.donOutOfPlaneAngleMax)
  };
}
function GL1(Z) {
  return {
    ...bT0(Z),
    includeWater: Z.water,
    maxSulfurDistSq: Z.sulfurDistanceMax * Z.sulfurDistanceMax,
    maxDistSq: Z.distanceMax * Z.distanceMax
  };
}
var ST0 = _8(120);
function xT0(Z, J, $, X) {
  let Y = J.members[J.offsets[J.feature]], Q = $.members[$.offsets[$.feature]];
  if (!X.includeBackbone && YL1(J.unit, Y, $.unit, Q))
    return;
  let [W, K] = XB(Z, J.unit, Y, $.unit, Q, X.ignoreHydrogens), G = F00.get(J.idealGeometry[Y]) || ST0;
  if (W.some((F) => Math.abs(G - F) > X.maxDonAngleDev))
    return;
  if (K.length && !K.some((F) => F < X.maxDonAngleDev))
    return;
  if (J.idealGeometry[Y] === G7.Trigonal) {
    let F = U00(Z, J.unit, Y, $.unit, Q);
    if (F !== void 0 && F > X.maxDonOutOfPlaneAngle)
      return;
  }
  let H = Y;
  if (!X.ignoreHydrogens && K.length > 0)
    H = ET0(Z, J.unit, Y, $.unit, Q);
  let [N, q] = XB(Z, $.unit, Q, J.unit, H, X.ignoreHydrogens), U = F00.get($.idealGeometry[Q]) || ST0;
  if (N.some((F) => U - F > X.maxAccAngleDev))
    return;
  if (q.some((F) => U - F > X.maxAccAngleDev))
    return;
  if ($.idealGeometry[Q] === G7.Trigonal) {
    let F = U00(Z, $.unit, Q, J.unit, Y);
    if (F !== void 0 && F > X.maxAccOutOfPlaneAngle)
      return;
  }
  return !0;
}
function HL1(Z, J, $, X, Y) {
  let Q = J.types[J.feature], W = $.types[$.feature];
  if (!WL1(Q, W))
    return;
  let [K, G] = W === F2.HydrogenAcceptor ? [J, $] : [$, J], H = K.members[K.offsets[K.feature]], N = G.members[G.offsets[G.feature]], q = j6(K.unit, H) === l1.S || j6(G.unit, N) === l1.S ? Y.maxSulfurDistSq : Y.maxDistSq;
  if (X > q)
    return;
  if (!Y.includeWater && QL1(K.unit, H, G.unit, N))
    return;
  if (!xT0(Z, K, G, Y))
    return;
  return o8.HydrogenBond;
}
function NL1(Z, J, $, X, Y) {
  let Q = J.types[J.feature], W = $.types[$.feature];
  if (!KL1(Q, W))
    return;
  let [K, G] = W === F2.HydrogenAcceptor ? [J, $] : [$, J];
  if (!xT0(Z, K, G, Y))
    return;
  return o8.WeakHydrogenBond;
}
var yT0 = D9.Provider([F2.HydrogenDonor], eU1), gT0 = D9.Provider([F2.WeakHydrogenDonor], ZL1), mT0 = D9.Provider([F2.HydrogenAcceptor], $L1), dT0 = {
  name: "hydrogen-bonds",
  params: rU1,
  createTester: (Z) => {
    let J = Math.max(Z.distanceMax, Z.sulfurDistanceMax), $ = GL1(Z);
    return {
      maxDistance: J,
      requiredFeatures: /* @__PURE__ */ new Set([F2.HydrogenDonor, F2.HydrogenAcceptor]),
      getType: (X, Y, Q, W) => HL1(X, Y, Q, W, $)
    };
  }
}, pT0 = {
  name: "weak-hydrogen-bonds",
  params: tU1,
  createTester: (Z) => {
    let J = bT0(Z);
    return {
      maxDistance: Z.distanceMax,
      requiredFeatures: /* @__PURE__ */ new Set([F2.WeakHydrogenDonor, F2.HydrogenAcceptor]),
      getType: ($, X, Y, Q) => NL1($, X, Y, Q, J)
    };
  }
};

// node_modules/molstar/lib/mol-model-props/computed/chemistry/functional-group.js
function uT0(Z, J, $) {
  return j6(J, $) === l1.S && SY(Z, J, $, l1.O) === 3;
}
function cT0(Z, J, $) {
  return j6(J, $) === l1.S && SY(Z, J, $, l1.O) === 4;
}
function j00(Z, J, $) {
  return j6(J, $) === l1.P && SY(Z, J, $, l1.O) === mW(Z, J, $);
}
function lT0(Z, J, $) {
  let X = 0;
  if (j6(J, $) === l1.C && SY(Z, J, $, l1.O) === 2 && SY(Z, J, $, l1.C) === 1)
    z$(Z, J, $, (Y, Q) => {
      if (j6(Y, Q) === l1.O && mW(Z, Y, Q) - SY(Z, Y, Q, l1.H) === 1)
        X += 1;
    });
  return X === 2;
}
function nT0(Z, J, $) {
  let X = 0;
  if (j6(J, $) === l1.C && mW(Z, J, $) === 3 && SY(Z, J, $, l1.N) === 3)
    z$(Z, J, $, (Y, Q) => {
      if (mW(Z, Y, Q) - SY(Z, Y, Q, l1.H) === 1)
        X += 1;
    });
  return X === 2;
}
function iT0(Z, J, $) {
  let X = 0;
  if (j6(J, $) === l1.C && mW(Z, J, $) === 3 && SY(Z, J, $, l1.N) === 2 && SY(Z, J, $, l1.C) === 1)
    z$(Z, J, $, (Y, Q) => {
      if (mW(Z, Y, Q) - SY(Z, Y, Q, l1.H) === 1)
        X += 1;
    });
  return X === 2;
}
var qL1 = /* @__PURE__ */ new Set(["N", "O", "S", "F", "CL", "BR", "I"]);
function FL1(Z) {
  return qL1.has(Z);
}
function oT0(Z, J, $) {
  let X = !1;
  return z$(Z, J, $, (Y, Q) => {
    if (FL1(j6(Y, Q)))
      X = !0;
  }), X;
}

// node_modules/molstar/lib/mol-model-props/computed/interactions/charged.js
var UL1 = {
  distanceMax: j.Numeric(5, { min: 0, max: 8, step: 0.1 })
}, LL1 = {
  distanceMax: j.Numeric(5.5, { min: 1, max: 8, step: 0.1 }),
  offsetMax: j.Numeric(2, { min: 0, max: 4, step: 0.1 }),
  angleDevMax: j.Numeric(30, { min: 0, max: 180, step: 1 })
}, RL1 = {
  distanceMax: j.Numeric(6, { min: 1, max: 8, step: 0.1 }),
  offsetMax: j.Numeric(2, { min: 0, max: 4, step: 0.1 })
}, EL1 = ["ARG", "HIS", "LYS"], OL1 = ["GLU", "ASP"];
function tT0(Z, J) {
  let $ = wq.get(Z).value;
  if (!$)
    throw Error("expected valence model to be available");
  let X = $.get(J.id);
  if (!X)
    throw Error("expected valence model for unit to be available");
  return X;
}
function zL1(Z, J, $) {
  let { charge: X } = tT0(Z, J), { elements: Y } = J, { x: Q, y: W, z: K } = J.model.atomicConformation, G = /* @__PURE__ */ new Set, { label_comp_id: H } = J.model.atomicHierarchy.atoms, N = b2.transientSegments(J.model.atomicHierarchy.residueAtomSegments, Y);
  while (N.hasNext) {
    let { index: q, start: U, end: F } = N.move(), E = H.value(J.model.atomicHierarchy.residueAtomSegments.offsets[q]);
    if (EL1.includes(E)) {
      $.startState();
      for (let R = U;R < F; ++R)
        if (j6(J, R) === l1.N && !jK.has(JE(J, R)))
          $.pushMember(Q[Y[R]], W[Y[R]], K[Y[R]], R);
      $.finishState(F2.PositiveCharge, IZ.None);
    } else if (!uF.has(E)) {
      G.clear();
      for (let R = U;R < F; ++R) {
        let z = IZ.None;
        if (nT0(Z, J, R))
          z = IZ.Guanidine;
        else if (iT0(Z, J, R))
          z = IZ.Acetamidine;
        if (z)
          $.startState(), z$(Z, J, R, (D, A) => {
            if (j6(J, A) === l1.N)
              G.add(A), $.pushMember(Q[Y[A]], W[Y[A]], K[Y[A]], A);
          }), $.finishState(F2.PositiveCharge, z);
      }
      for (let R = U;R < F; ++R)
        if (X[R] > 0 && !G.has(R))
          $.add(F2.PositiveCharge, IZ.None, Q[Y[R]], W[Y[R]], K[Y[R]], R);
    }
  }
}
function DL1(Z, J, $) {
  let { charge: X } = tT0(Z, J), { elements: Y } = J, { x: Q, y: W, z: K } = J.model.atomicConformation, G = /* @__PURE__ */ new Set, { label_comp_id: H } = J.model.atomicHierarchy.atoms, N = b2.transientSegments(J.model.atomicHierarchy.residueAtomSegments, Y);
  while (N.hasNext) {
    let { index: q, start: U, end: F } = N.move(), E = H.value(J.model.atomicHierarchy.residueAtomSegments.offsets[q]);
    if (OL1.includes(E)) {
      $.startState();
      for (let R = U;R < F; ++R)
        if (j6(J, R) === l1.O && !jK.has(JE(J, R)))
          $.pushMember(Q[Y[R]], W[Y[R]], K[Y[R]], R);
      $.finishState(F2.NegativeCharge, IZ.None);
    } else if (Gz.has(E)) {
      for (let R = U;R < F; ++R)
        if (j00(Z, J, R))
          $.startState(), z$(Z, J, R, (z, D) => {
            if (j6(J, D) === l1.O)
              $.pushMember(Q[Y[D]], W[Y[D]], K[Y[D]], D);
          }), $.finishState(F2.NegativeCharge, IZ.Phosphate);
    } else if (!uF.has(E)) {
      for (let R = U;R < F; ++R) {
        if ($.startState(), j6(J, R) === l1.N && !jK.has(JE(J, R)))
          $.pushMember(Q[Y[R]], W[Y[R]], K[Y[R]], R);
        $.finishState(F2.NegativeCharge, IZ.None);
        let z = IZ.None;
        if (uT0(Z, J, R))
          z = IZ.SulfonicAcid;
        else if (j00(Z, J, R))
          z = IZ.Phosphate;
        else if (cT0(Z, J, R))
          z = IZ.Sulfate;
        else if (lT0(Z, J, R))
          z = IZ.Carboxylate;
        if (z)
          $.startState(), z$(Z, J, R, (D, A) => {
            if (j6(J, A) === l1.O)
              G.add(A), $.pushMember(Q[Y[A]], W[Y[A]], K[Y[A]], A);
          }), $.finishState(F2.NegativeCharge, z);
      }
      for (let R = U;R < F; ++R)
        if (X[R] < 0 && !G.has(R))
          $.add(F2.NegativeCharge, IZ.None, Q[Y[R]], W[Y[R]], K[Y[R]], R);
    }
  }
}
function ML1(Z, J, $) {
  let { elements: X } = J, { x: Y, y: Q, z: W } = J.model.atomicConformation;
  for (let K of J.rings.aromaticRings) {
    let G = J.rings.all[K];
    $.startState();
    for (let H = 0, N = G.length;H < N; ++H) {
      let q = G[H];
      $.pushMember(Y[X[q]], Q[X[q]], W[X[q]], q);
    }
    $.finishState(F2.AromaticRing, IZ.None);
  }
}
function AL1(Z, J) {
  return Z === F2.NegativeCharge && J === F2.PositiveCharge || Z === F2.PositiveCharge && J === F2.NegativeCharge;
}
function BL1(Z, J) {
  return Z === F2.AromaticRing && J === F2.AromaticRing;
}
function wL1(Z, J) {
  return Z === F2.AromaticRing && J === F2.PositiveCharge || Z === F2.PositiveCharge && J === F2.AromaticRing;
}
var sT0 = M(), aT0 = M();
function jL1(Z, J, $) {
  let { feature: X, offsets: Y, members: Q } = Z, { feature: W, offsets: K, members: G } = J;
  for (let H = Y[X], N = Y[X + 1];H < N; ++H) {
    let q = Q[H];
    Z.unit.conformation.position(Z.unit.elements[q], sT0);
    for (let U = K[W], F = K[W + 1];U < F; ++U) {
      let E = G[U];
      if (J.unit.conformation.position(J.unit.elements[E], aT0), M.squaredDistance(sT0, aT0) < $)
        return !0;
    }
  }
  return !1;
}
var hx = M(), QB = M(), bx = M(), fx = M();
function _00(Z, J) {
  let { unit: $, feature: X, offsets: Y, members: Q } = J, { elements: W } = $, K = Y[X];
  return J.unit.conformation.position(W[Q[K]], hx), J.unit.conformation.position(W[Q[K + 1]], QB), J.unit.conformation.position(W[Q[K + 2]], bx), M.triangleNormal(Z, hx, QB, bx);
}
var V00 = function(Z, J, $) {
  return D9.position(hx, Z), D9.position(QB, J), M.sub(bx, hx, QB), M.projectOnPlane(fx, bx, $), M.add(fx, fx, QB), M.distance(fx, QB);
};
function TL1(Z) {
  return {
    distanceMaxSq: Z.distanceMax * Z.distanceMax
  };
}
function _L1(Z) {
  return {
    offsetMax: Z.offsetMax,
    angleDevMax: _8(Z.angleDevMax)
  };
}
function VL1(Z) {
  return {
    offsetMax: Z.offsetMax
  };
}
var IL1 = _8(180), rT0 = _8(90), UI = M(), T00 = M();
function PL1(Z, J, $, X, Y) {
  let Q = J.types[J.feature], W = $.types[$.feature];
  if (AL1(Q, W)) {
    if (jL1(J, $, Y.distanceMaxSq))
      return o8.Ionic;
  }
}
function CL1(Z, J, $, X, Y) {
  let Q = J.types[J.feature], W = $.types[$.feature];
  if (BL1(Q, W)) {
    _00(UI, J), _00(T00, $);
    let K = M.angle(UI, T00);
    if (Math.min(V00(J, $, T00), V00($, J, UI)) <= Y.offsetMax) {
      if (K <= Y.angleDevMax || K >= IL1 - Y.angleDevMax)
        return o8.PiStacking;
      else if (K <= Y.angleDevMax + rT0 && K >= rT0 - Y.angleDevMax)
        return o8.PiStacking;
    }
  }
}
function kL1(Z, J, $, X, Y) {
  let Q = J.types[J.feature], W = $.types[$.feature];
  if (wL1(Q, W)) {
    let [K, G] = Q === F2.AromaticRing ? [J, $] : [$, J];
    if (_00(UI, K), V00(G, K, UI) <= Y.offsetMax)
      return o8.CationPi;
  }
}
var eT0 = D9.Provider([F2.NegativeCharge], DL1), Z_0 = D9.Provider([F2.PositiveCharge], zL1), J_0 = D9.Provider([F2.AromaticRing], ML1), $_0 = {
  name: "ionic",
  params: UL1,
  createTester: (Z) => {
    let J = TL1(Z);
    return {
      maxDistance: Z.distanceMax,
      requiredFeatures: /* @__PURE__ */ new Set([F2.NegativeCharge, F2.PositiveCharge]),
      getType: ($, X, Y, Q) => PL1($, X, Y, Q, J)
    };
  }
}, X_0 = {
  name: "pi-stacking",
  params: LL1,
  createTester: (Z) => {
    let J = _L1(Z);
    return {
      maxDistance: Z.distanceMax,
      requiredFeatures: /* @__PURE__ */ new Set([F2.AromaticRing]),
      getType: ($, X, Y, Q) => CL1($, X, Y, Q, J)
    };
  }
}, Y_0 = {
  name: "cation-pi",
  params: RL1,
  createTester: (Z) => {
    let J = VL1(Z);
    return {
      maxDistance: Z.distanceMax,
      requiredFeatures: /* @__PURE__ */ new Set([F2.AromaticRing, F2.PositiveCharge]),
      getType: ($, X, Y, Q) => kL1($, X, Y, Q, J)
    };
  }
};

// node_modules/molstar/lib/mol-model-props/computed/interactions/hydrophobic.js
var vL1 = {
  distanceMax: j.Numeric(4, { min: 1, max: 5, step: 0.1 })
};
function SL1(Z, J, $) {
  let { elements: X } = J, { x: Y, y: Q, z: W } = J.model.atomicConformation;
  for (let K = 0, G = X.length;K < G; ++K) {
    let H = j6(J, K), N = !1;
    if (H === l1.C)
      N = !0, z$(Z, J, K, (q, U) => {
        let F = j6(q, U);
        if (F !== l1.C && F !== l1.H)
          N = !1;
      });
    else if (H === l1.F)
      N = !0;
    if (N)
      $.add(F2.HydrophobicAtom, IZ.None, Y[X[K]], Q[X[K]], W[X[K]], K);
  }
}
function fL1(Z, J) {
  return Z === F2.HydrophobicAtom && J === F2.HydrophobicAtom;
}
function hL1(Z, J, $, X) {
  let Y = J.types[J.feature], Q = $.types[$.feature];
  if (!fL1(Y, Q))
    return;
  let W = J.members[J.offsets[J.feature]], K = $.members[$.offsets[$.feature]];
  if (j6(J.unit, W) === l1.F && j6($.unit, K) === l1.F)
    return;
  return o8.Hydrophobic;
}
var Q_0 = D9.Provider([F2.HydrophobicAtom], SL1), W_0 = {
  name: "hydrophobic",
  params: vL1,
  createTester: (Z) => {
    return {
      maxDistance: Z.distanceMax,
      requiredFeatures: /* @__PURE__ */ new Set([F2.HydrophobicAtom]),
      getType: (J, $, X, Y) => hL1(J, $, X, Y)
    };
  }
};

// node_modules/molstar/lib/mol-model-props/computed/interactions/metal.js
var bL1 = {
  distanceMax: j.Numeric(3, { min: 1, max: 5, step: 0.1 })
}, xL1 = [
  l1.LI,
  l1.NA,
  l1.K,
  l1.RB,
  l1.CS,
  l1.MG,
  l1.CA,
  l1.SR,
  l1.BA,
  l1.AL,
  l1.GA,
  l1.IN,
  l1.TL,
  l1.SC,
  l1.SN,
  l1.PB,
  l1.BI,
  l1.SB,
  l1.HG
];
function yL1(Z, J, $) {
  let { elements: X } = J, { x: Y, y: Q, z: W } = J.model.atomicConformation;
  for (let K = 0, G = X.length;K < G; ++K) {
    let H = j6(J, K), N = F2.None;
    if (xL1.includes(H))
      N = F2.IonicTypeMetal;
    else if (ho(H) || H === l1.ZN || H === l1.CD)
      N = F2.TransitionMetal;
    if (N)
      $.add(N, IZ.None, Y[X[K]], Q[X[K]], W[X[K]], K);
  }
}
function K_0(Z) {
  return !jK.has(Z);
}
function gL1(Z) {
  return jK.has(Z);
}
function mL1(Z) {
  return gM.has(Z);
}
function dL1(Z, J, $) {
  let { elements: X } = J, { x: Y, y: Q, z: W } = J.model.atomicConformation;
  for (let K = 0, G = X.length;K < G; ++K) {
    let H = j6(J, K), N = FI(J, K), q = JE(J, K), U = !1, F = !1, E = Kz.has(N), R = Gz.has(N);
    if (!E && !R) {
      if (fo(H) || H === l1.O || H === l1.S)
        U = !0, F = !0;
      else if (H === l1.N)
        U = !0;
    } else if (E) {
      if (H === l1.O) {
        if (["ASP", "GLU", "SER", "THR", "TYR", "ASN", "GLN"].includes(N) && K_0(q))
          U = !0, F = !0;
        else if (gL1(q))
          U = !0, F = !0;
      } else if (H === l1.S && (N === "CYS" || N === "MET"))
        U = !0, F = !0;
      else if (H === l1.N) {
        if (N === "HIS" && K_0(q))
          U = !0;
      }
    } else if (R) {
      if (H === l1.O && mL1(q))
        U = !0, F = !0;
      else if (["N3", "N4", "N7"].includes(q))
        U = !0;
      else if (["O2", "O4", "O6"].includes(q))
        U = !0, F = !0;
    }
    if (U)
      $.add(F2.DativeBondPartner, IZ.None, Y[X[K]], Q[X[K]], W[X[K]], K);
    if (F)
      $.add(F2.IonicTypePartner, IZ.None, Y[X[K]], Q[X[K]], W[X[K]], K);
  }
}
function G_0(Z, J) {
  if (Z === F2.TransitionMetal)
    return J === F2.DativeBondPartner || J === F2.TransitionMetal;
  else if (Z === F2.IonicTypeMetal)
    return J === F2.IonicTypePartner;
}
function pL1(Z, J, $, X) {
  let Y = J.types[J.feature], Q = $.types[$.feature];
  if (!G_0(Y, Q) && !G_0(Q, Y))
    return;
  return o8.MetalCoordination;
}
var H_0 = D9.Provider([F2.IonicTypeMetal, F2.TransitionMetal], yL1), N_0 = D9.Provider([F2.IonicTypePartner, F2.DativeBondPartner], dL1), q_0 = {
  name: "metal-coordination",
  params: bL1,
  createTester: (Z) => {
    return {
      maxDistance: Z.distanceMax,
      requiredFeatures: /* @__PURE__ */ new Set([F2.IonicTypeMetal, F2.TransitionMetal, F2.IonicTypePartner, F2.DativeBondPartner]),
      getType: (J, $, X, Y) => pL1(J, $, X, Y)
    };
  }
};

// node_modules/molstar/lib/mol-model-props/computed/interactions/refine.js
function F_0(Z, J) {
  let { contacts: $, unitsContacts: X, unitsFeatures: Y } = J, Q = [
    uL1(Z, J),
    cL1(Z, J),
    lL1(Z, J),
    nL1(Z, J),
    iL1(Z, J)
  ];
  for (let K = 0, G = $.edgeCount;K < G; ++K) {
    let H = $.edges[K], N = Z.unitMap.get(H.unitA), q = Z.unitMap.get(H.unitB), U = D9.Info(Z, N, Y.get(H.unitA));
    U.feature = H.indexA;
    let F = D9.Info(Z, q, Y.get(H.unitB));
    F.feature = H.indexB;
    for (let E of Q)
      if (E.isApplicable(H.props.type))
        E.handleInterContact(K, U, F);
  }
  let W = X.keys();
  while (!0) {
    let { done: K, value: G } = W.next();
    if (K)
      break;
    let H = X.get(G), N = Y.get(G), q = Z.unitMap.get(G);
    if (!j0.isAtomic(q))
      continue;
    let U = D9.Info(Z, q, N), F = D9.Info(Z, q, N);
    for (let E of Q)
      E.startUnit(q, H, N);
    for (let E = 0, R = H.edgeCount * 2;E < R; ++E) {
      U.feature = H.a[E], F.feature = H.b[E];
      for (let z of Q)
        if (z.isApplicable(H.edgeProps.type[E]))
          z.handleIntraContact(E, U, F);
    }
  }
}
function uL1(Z, J) {
  let { contacts: $ } = J, X = function(H, N, q, U, F) {
    let [E, R] = U.get(q) || [1 / 0, -1];
    if (H < E) {
      if (R !== -1)
        F(R);
      U.set(q, [H, N]);
    } else
      F(N);
  };
  function Y(H, N, q, U, F) {
    let E = N.members[N.offsets[N.feature]], R = q.members[q.offsets[q.feature]], z = N.unit.getResidueIndex(E), D = q.unit.getResidueIndex(R), A = `${E}|${N.unit.id}|${D}|${q.unit.id}|A`, B = `${R}|${q.unit.id}|${z}|${N.unit.id}|B`, T = D9.distance(N, q);
    X(T, H, A, U, F), X(T, H, B, U, F);
  }
  let Q = /* @__PURE__ */ new Map, W = (H) => $.edges[H].props.flag = dW.Filtered, K, G;
  return {
    isApplicable: (H) => H === o8.Hydrophobic,
    handleInterContact: (H, N, q) => {
      Y(H, N, q, Q, W);
    },
    startUnit: (H, N, q) => {
      K = /* @__PURE__ */ new Map, G = (U) => N.edgeProps.flag[U] = dW.Filtered;
    },
    handleIntraContact: (H, N, q) => {
      Y(H, N, q, K, G);
    }
  };
}
function cL1(Z, J) {
  let { contacts: $ } = J, X = (Y, Q) => {
    let W = Y.types[Y.feature] === F2.WeakHydrogenDonor ? Q : Y, K = W.members[W.offsets[W.feature]], { edgeProps: { type: G }, elementsIndex: { offsets: H, indices: N } } = J.unitsContacts.get(W.unit.id);
    for (let U = H[K], F = H[K + 1];U < F; ++U)
      if (G[N[U]] === o8.HydrogenBond)
        return !0;
    let q = $.getEdgeIndices(W.feature, W.unit.id);
    for (let U = 0, F = q.length;U < F; ++U)
      if ($.edges[q[U]].props.type === o8.HydrogenBond)
        return !0;
    return !1;
  };
  return {
    isApplicable: (Y) => Y === o8.WeakHydrogenBond,
    handleInterContact: (Y, Q, W) => {
      if (X(Q, W))
        $.edges[Y].props.flag = dW.Filtered;
    },
    startUnit: () => {},
    handleIntraContact: (Y, Q, W) => {
      if (X(Q, W)) {
        let { flag: K } = J.unitsContacts.get(Q.unit.id).edgeProps;
        K[Y] = dW.Filtered;
      }
    }
  };
}
function I00(Z, J, $, X, Y) {
  let { offsets: Q, feature: W } = $, { offsets: K, feature: G } = X;
  for (let H = Q[W], N = Q[W + 1];H < N; ++H) {
    let q = $.members[H], U = Y.getContactIndicesForElement(q, $.unit);
    for (let F = 0, E = U.length;F < E; ++F) {
      let R = U[F];
      if (Z.includes(Y.edges[R].props.type))
        for (let z = K[G], D = K[G + 1];z < D; ++z) {
          let A = X.members[z];
          if (Y.getContactIndicesForElement(A, X.unit).includes(R)) {
            Y.edges[J].props.flag = dW.Filtered;
            return;
          }
        }
    }
  }
}
function P00(Z, J, $, X, Y) {
  let { edgeProps: { type: Q, flag: W }, elementsIndex: { offsets: K, indices: G } } = Y, { offsets: H, feature: N } = $, { offsets: q, feature: U } = X;
  for (let F = H[N], E = H[N + 1];F < E; ++F) {
    let R = $.members[F];
    for (let z = K[R], D = K[R + 1];z < D; ++z) {
      let A = G[z];
      if (Z.includes(Q[A]))
        for (let B = q[U], T = q[U + 1];B < T; ++B) {
          let w = X.members[B];
          for (let V = K[w], P = K[w + 1];V < P; ++V)
            if (A === G[V]) {
              W[J] = dW.Filtered;
              return;
            }
        }
    }
  }
}
function lL1(Z, J) {
  let { contacts: $ } = J;
  return {
    isApplicable: (X) => X === o8.Ionic,
    handleInterContact: (X, Y, Q) => {
      I00([o8.HydrogenBond, o8.WeakHydrogenBond], X, Y, Q, $);
    },
    startUnit: () => {},
    handleIntraContact: (X, Y, Q) => {
      P00([o8.HydrogenBond, o8.WeakHydrogenBond], X, Y, Q, J.unitsContacts.get(Y.unit.id));
    }
  };
}
function nL1(Z, J) {
  let { contacts: $ } = J;
  return {
    isApplicable: (X) => X === o8.Hydrophobic || X === o8.CationPi,
    handleInterContact: (X, Y, Q) => {
      I00([o8.PiStacking], X, Y, Q, $);
    },
    startUnit: () => {},
    handleIntraContact: (X, Y, Q) => {
      P00([o8.PiStacking], X, Y, Q, J.unitsContacts.get(Y.unit.id));
    }
  };
}
function iL1(Z, J) {
  let { contacts: $ } = J;
  return {
    isApplicable: (X) => X === o8.Ionic,
    handleInterContact: (X, Y, Q) => {
      I00([o8.MetalCoordination], X, Y, Q, $);
    },
    startUnit: () => {},
    handleIntraContact: (X, Y, Q) => {
      P00([o8.MetalCoordination], X, Y, Q, J.unitsContacts.get(Y.unit.id));
    }
  };
}

// node_modules/molstar/lib/mol-model-props/computed/interactions/interactions.js
var e3;
(function(Z) {
  function J(N, q, U, F, E, R) {
    return zh("interactions", { structure: q, interactions: N }, { unitA: U, indexA: F, unitB: E, indexB: R });
  }
  Z.Location = J;
  function $(N) {
    return !!N && N.kind === "data-location" && N.tag === "interactions";
  }
  Z.isLocation = $;
  function X(N, q) {
    return N.data.structure === q.data.structure && N.data.interactions === q.data.interactions && N.element.indexA === q.element.indexA && N.element.indexB === q.element.indexB && N.element.unitA === q.element.unitA && N.element.unitB === q.element.unitB;
  }
  Z.areLocationsEqual = X;
  function Y(N, q) {
    let { unitA: U, indexA: F, unitB: E, indexB: R } = q, { contacts: z, unitsContacts: D } = N;
    if (U === E) {
      let A = D.get(U.id), B = A.getDirectedEdgeIndex(F, R);
      return M00(A.edgeProps.type[B]);
    } else {
      let A = z.getEdgeIndex(F, U.id, R, E.id);
      return M00(z.edges[A].props.type);
    }
  }
  function Q(N) {
    return Y(N.data.interactions, N.element);
  }
  Z.locationLabel = Q;
  function W(N, q, U) {
    return PR("interactions", { structure: N, interactions: q }, U, (F) => G(q, U, F), () => H(N, q, U));
  }
  Z.Loci = W;
  function K(N) {
    return !!N && N.kind === "data-loci" && N.tag === "interactions";
  }
  Z.isLoci = K;
  function G(N, q, U) {
    let { unitsFeatures: F } = N;
    return yQ.fromPairProvider(q.length, (E, R, z) => {
      let D = q[E];
      D9.setPosition(R, D.unitA, D.indexA, F.get(D.unitA.id)), D9.setPosition(z, D.unitB, D.indexB, F.get(D.unitB.id));
    }, U);
  }
  Z.getBoundingSphere = G;
  function H(N, q, U) {
    let F = U[0];
    if (F === void 0)
      return "";
    let { unitA: E, indexA: R, unitB: z, indexB: D } = F, { unitsFeatures: A } = q, { members: B, offsets: T } = A.get(E.id), { members: w, offsets: V } = A.get(z.id), P = { granularity: "element" };
    if (T[R + 1] - T[R] > 1 || V[D + 1] - V[D] > 1)
      P.granularity = "residue";
    return [
      Y(q, F),
      gV($2.Location(N, E, B[T[R]], N, z, w[V[D]]), P)
    ].join("</br>");
  }
  Z.getLabel = H;
})(e3 || (e3 = {}));
var oL1 = [
  yT0,
  gT0,
  mT0,
  eT0,
  Z_0,
  J_0,
  IT0,
  PT0,
  Q_0,
  H_0,
  N_0
], xx = {
  ionic: $_0,
  "pi-stacking": X_0,
  "cation-pi": Y_0,
  "halogen-bonds": CT0,
  "hydrogen-bonds": dT0,
  "weak-hydrogen-bonds": pT0,
  hydrophobic: W_0,
  "metal-coordination": q_0
};
function sL1(Z = []) {
  let J = Object.create(null);
  return Object.keys(xx).forEach(($) => {
    J[$] = j.MappedStatic(Z.includes($) ? "on" : "off", {
      on: j.Group(xx[$].params),
      off: j.Group({})
    }, { cycle: !0 });
  }), J;
}
var aL1 = sL1([
  "cation-pi",
  "pi-stacking",
  "hydrogen-bonds",
  "halogen-bonds",
  "metal-coordination"
]), C00 = {
  providers: j.Group(aL1, { isFlat: !0 }),
  contacts: j.Group(wT0, { label: "Advanced Options" })
};
async function U_0(Z, J, $, X) {
  let Y = { ...j.getDefaultValues(C00), ...$ }, Q = JSON.stringify(Y);
  await wq.attach(Z, J);
  let W = [];
  uO(xx).forEach((F) => {
    let { name: E, params: R } = Y.providers[F];
    if (E === "on")
      W.push(xx[F].createTester(R));
  });
  let K = /* @__PURE__ */ new Set;
  W.forEach((F) => uZ.add(K, F.requiredFeatures));
  let G = oL1.filter((F) => uZ.areIntersecting(K, F.types)), H = NY.Mutable(), N = NY.Mutable();
  for (let F = 0, E = J.unitSymmetryGroups.length;F < E; ++F) {
    let R = J.unitSymmetryGroups[F];
    if (Z.runtime.shouldUpdate)
      await Z.runtime.update({ message: "computing interactions", current: F, max: E });
    let z = rL1(J, R.units[0], G, Q);
    for (let A = 0, B = R.units.length;A < B; ++A) {
      let T = R.units[A];
      H.set(T.id, z);
    }
    if (X === null || X === void 0 ? void 0 : X.skipIntraContacts)
      continue;
    let D = tL1(J, R.units[0], z, W, Y.contacts);
    for (let A = 0, B = R.units.length;A < B; ++A) {
      let T = R.units[A];
      N.set(T.id, D);
    }
  }
  let q = eL1(J, H, W, Y.contacts, X), U = { unitsFeatures: H, unitsContacts: N, contacts: q };
  return F_0(J, U), U;
}
function rL1(Z, J, $, X) {
  let Y = `features-${X}`;
  if (J.transientCache.has(Y))
    return J.transientCache.get(Y);
  let Q = J.elements.length, W = Cx.create(Q, Q / 2);
  if (j0.isAtomic(J))
    for (let G of $)
      G.add(Z, J, W);
  let K = W.getFeatures(Q);
  return J.transientCache.set(Y, K), K;
}
function tL1(Z, J, $, X, Y) {
  let Q = vx.create($, J.elements.length);
  if (j0.isAtomic(J))
    _T0(Z, J, $, Q, X, Y);
  return Q.getContacts();
}
function eL1(Z, J, $, X, Y) {
  let Q = Sx.create();
  return s0.eachUnitPair(Z, (W, K) => {
    let G = J.get(W.id), H = J.get(K.id);
    VT0(Z, W, G, K, H, Q, $, X);
  }, {
    maxRadius: Math.max(...$.map((W) => W.maxDistance)),
    validUnit: (W) => j0.isAtomic(W),
    validUnitPair: (W, K) => {
      if (Y === null || Y === void 0 ? void 0 : Y.unitPairTest)
        return Y.unitPairTest(W, K);
      return s0.validUnitPair(Z, W, K);
    }
  }), Q.getContacts(J);
}

// node_modules/molstar/lib/mol-model-props/computed/interactions.js
var k00 = {
  ...C00
}, H7 = IW.createProvider({
  label: "Interactions",
  descriptor: p7({
    name: "molstar_computed_interactions"
  }),
  type: "local",
  defaultParams: k00,
  getParams: (Z) => k00,
  isApplicable: (Z) => !Z.isCoarseGrained,
  obtain: async (Z, J, $) => {
    let X = { ...j.getDefaultValues(k00), ...$ };
    return { value: await U_0(Z, J, X) };
  }
});

// node_modules/molstar/lib/mol-model-props/computed/themes/interaction-type.js
var v00 = i0(13421772), ZR1 = "Assigns colors according the interaction type of a link.", rQ = QQ({
  HydrogenBond: 2851770,
  Hydrophobic: 8421504,
  HalogenBond: 4259775,
  Ionic: 15779860,
  MetalCoordination: 9191577,
  CationPi: 16744448,
  PiStacking: 9220966,
  WeakHydrogenBond: 12967404
}), JR1 = [
  ["Hydrogen Bond", rQ.HydrogenBond],
  ["Hydrophobic", rQ.Hydrophobic],
  ["Halogen Bond", rQ.HalogenBond],
  ["Ionic", rQ.Ionic],
  ["Metal Coordination", rQ.MetalCoordination],
  ["Cation Pi", rQ.CationPi],
  ["Pi Stacking", rQ.PiStacking],
  ["Weak HydrogenBond", rQ.WeakHydrogenBond]
];
function L_0(Z) {
  switch (Z) {
    case o8.HydrogenBond:
      return rQ.HydrogenBond;
    case o8.Hydrophobic:
      return rQ.Hydrophobic;
    case o8.HalogenBond:
      return rQ.HalogenBond;
    case o8.Ionic:
      return rQ.Ionic;
    case o8.MetalCoordination:
      return rQ.MetalCoordination;
    case o8.CationPi:
      return rQ.CationPi;
    case o8.PiStacking:
      return rQ.PiStacking;
    case o8.WeakHydrogenBond:
      return rQ.WeakHydrogenBond;
    case o8.Unknown:
      return v00;
  }
}
var R_0 = {};
function $R1(Z) {
  return R_0;
}
function E_0(Z, J) {
  let $, X = Z.structure ? H7.get(Z.structure) : void 0, Y = X ? SQ(X.id, X.version) : -1;
  if (X && X.value)
    $ = (Q) => {
      if (e3.isLocation(Q)) {
        let { unitsContacts: W, contacts: K } = Q.data.interactions, { unitA: G, unitB: H, indexA: N, indexB: q } = Q.element;
        if (G === H) {
          let U = W.get(G.id), F = U.getDirectedEdgeIndex(N, q);
          return L_0(U.edgeProps.type[F]);
        } else {
          let U = K.getEdgeIndex(N, G.id, q, H.id);
          return L_0(K.edges[U].props.type);
        }
      }
      return v00;
    };
  else
    $ = () => v00;
  return {
    factory: E_0,
    granularity: "group",
    color: $,
    props: J,
    contextHash: Y,
    description: ZR1,
    legend: ZX(JR1)
  };
}
var LI = {
  name: "interaction-type",
  label: "Interaction Type",
  category: $8.Misc,
  factory: E_0,
  getParams: $R1,
  defaultValues: j.getDefaultValues(R_0),
  isApplicable: (Z) => !!Z.structure,
  ensureCustomProperties: {
    attach: (Z, J) => J.structure ? H7.attach(Z, J.structure, void 0, !0) : Promise.resolve(),
    detach: (Z) => Z.structure && H7.ref(Z.structure, !1)
  }
};

// node_modules/molstar/lib/mol-repr/structure/complex-representation.js
function M9(Z, J, $, X) {
  let Y = 0, { webgl: Q } = J, W = new P6, K = new V2.GeometryState, G = bW(), H = [], N = lZ.create(), q, U, F, E, R = Q7.createEmpty();
  function z(I = {}, S) {
    if (S && S !== U) {
      if (F = $(J, S), U = S, !E)
        E = j.getDefaultValues(F);
    }
    return E = Object.assign({}, E, I), n0.create("Creating or updating ComplexRepresentation", async (f) => {
      var v;
      let h = !1;
      if (!q)
        q = X(G, U, E, Q), h = !0;
      else if ((v = q.mustRecreate) === null || v === void 0 ? void 0 : v.call(q, U, E, Q))
        q.destroy(), q = X(G, U, E, Q), h = !0;
      let x = q.createOrUpdate({ webgl: Q, runtime: f }, R, E, S);
      if (x)
        await x;
      if (h)
        w(N);
      if (H.length = 0, q && q.renderObject)
        H.push(q.renderObject), K.add(q.renderObject.id, q.geometryVersion);
      K.snapshot(), Y += 1, W.next(Y);
    });
  }
  function D(I) {
    return q ? q.getLoci(I) : G8;
  }
  function A() {
    var I;
    return [s0.Loci((I = U.child) !== null && I !== void 0 ? I : U)];
  }
  function B(I) {
    q === null || q === void 0 || q.eachLocation(I);
  }
  function T(I, S) {
    if (!U)
      return !1;
    if (!W7.is(N.markerActions, S))
      return !1;
    if (s0.isLoci(I) || W0.Loci.is(I) || $2.isLoci(I)) {
      if (!s0.areRootsEquivalent(I.structure, U))
        return !1;
      if (I = d2.remap(I, U), s0.isLoci(I) || W0.Loci.is(I) && W0.Loci.isWholeStructure(I))
        I = nN;
    } else if (!KJ(I) && !Mz(I))
      return !1;
    if (d2.isEmpty(I))
      return !1;
    return q ? q.mark(I, S) : !1;
  }
  function w(I) {
    if (lZ.update(N, I), I.visible !== void 0 && q)
      q.setVisibility(I.visible && (N.unitTransforms === null || N.unitTransforms.isIdentity));
    if (I.alphaFactor !== void 0 && q)
      q.setAlphaFactor(I.alphaFactor);
    if (I.pickable !== void 0 && q)
      q.setPickable(I.pickable);
    if (I.overpaint !== void 0 && q) {
      let S = rJ.remap(I.overpaint, U);
      q.setOverpaint(S, Q);
    }
    if (I.transparency !== void 0 && q) {
      let S = tJ.remap(I.transparency, U);
      q.setTransparency(S, Q);
    }
    if (I.emissive !== void 0 && q) {
      let S = Z$.remap(I.emissive, U);
      q.setEmissive(S, Q);
    }
    if (I.substance !== void 0 && q) {
      let S = eJ.remap(I.substance, U);
      q.setSubstance(S, Q);
    }
    if (I.clipping !== void 0 && q) {
      let S = $9.remap(I.clipping, U);
      q.setClipping(S);
    }
    if (I.themeStrength !== void 0 && q)
      q.setThemeStrength(I.themeStrength);
    if (I.transform !== void 0 && q)
      q.setTransform(I.transform);
    if (I.unitTransforms !== void 0 && q)
      q.setVisibility(N.visible && (I.unitTransforms === null || I.unitTransforms.isIdentity));
  }
  function V(I) {
    R = I;
  }
  function P() {
    if (q)
      q.destroy();
  }
  return {
    label: Z,
    get groupCount() {
      return q ? q.groupCount : 0;
    },
    get props() {
      return E;
    },
    get params() {
      return F;
    },
    get state() {
      return N;
    },
    get theme() {
      return R;
    },
    get geometryVersion() {
      return K.version;
    },
    renderObjects: H,
    updated: W,
    createOrUpdate: z,
    setState: w,
    setTheme: V,
    getLoci: D,
    getAllLoci: A,
    eachLocation: B,
    mark: T,
    destroy: P
  };
}
// node_modules/molstar/lib/mol-repr/structure/visual/util/common.js
var XR1 = e.toArray, yx = !1;
function WB(Z) {
  if (!Z) {
    if (y2 && !yx)
      console.warn('WebGL required for "sphere impostors". Falling back to "sphere mesh".'), yx = !0;
  } else if (!Z.extensions.fragDepth || !Z.extensions.textureFloat) {
    if (y2 && !yx) {
      let J = [];
      if (!Z.extensions.fragDepth)
        J.push("fragDepth");
      if (!Z.extensions.textureFloat)
        J.push("textureFloat");
      console.warn(`Missing "${J.join('", "')}" extensions required for "sphere impostors". Falling back to "sphere mesh".`), yx = !0;
    }
  } else
    return !0;
  return !1;
}
var gx = !1;
function YE(Z) {
  if (!Z) {
    if (y2 && !gx)
      console.warn('WebGL required for "cylinder impostors". Falling back to "cylinder mesh".'), gx = !0;
  } else if (!Z.extensions.fragDepth) {
    if (y2 && !gx) {
      let J = [];
      if (!Z.extensions.fragDepth)
        J.push("fragDepth");
      console.warn(`Missing "${J.join('", "')}" extensions required for "cylinder impostors". Falling back to "cylinder mesh".`), gx = !0;
    }
  } else
    return !0;
  return !1;
}
function mx(Z, J, $) {
  let { elements: X, model: Y } = J;
  if (f0.indexOf(X, $) !== -1) {
    let { index: Q, offsets: W } = Y.atomicHierarchy.residueAtomSegments, K = Q[$], G = [];
    for (let N = W[K], q = W[K + 1];N < q; ++N) {
      let U = f0.indexOf(X, N);
      if (U !== -1)
        G.push(U);
    }
    let H = f0.ofSortedArray(X1.ofSortedArray(G));
    return W0.Loci(Z, [{ unit: J, indices: H }]);
  }
  return G8;
}
function O_0(Z, J, $) {
  let { elements: X, model: Y } = J, { label_alt_id: Q } = Y.atomicHierarchy.atoms, W = Q.value($);
  if (f0.indexOf(X, $) !== -1) {
    let { index: K } = Y.atomicHierarchy.residueAtomSegments, G = K[$];
    return QE(Z, J, G, W);
  }
  return W0.Loci(Z, []);
}
function QE(Z, J, $, X) {
  let { elements: Y, model: Q } = J, { label_alt_id: W } = Q.atomicHierarchy.atoms, { offsets: K } = Q.atomicHierarchy.residueAtomSegments, G = [];
  for (let N = K[$], q = K[$ + 1];N < q; ++N) {
    let U = f0.indexOf(Y, N);
    if (U !== -1) {
      let F = W.value(N);
      if (X === F || F === "")
        G.push(U);
    }
  }
  let H = f0.ofSortedArray(X1.ofSortedArray(G));
  return W0.Loci(Z, [{ unit: J, indices: H }]);
}
function S00(Z, J, $, X, Y, Q) {
  let { child: W } = Z.structure, K = J && W ? Z.group.units.filter((q) => W.unitMap.has(q.id)) : Z.group.units, G = K.length, H = G * 16, N = Q && Q.aTransform.ref.value.length >= H ? Q.aTransform.ref.value : new Float32Array(H);
  for (let q = 0;q < G; q++)
    XR1(K[q].conformation.operator.matrix, N, q * 16);
  return zz(N, G, $, X, Y, Q);
}
var YR1 = {
  atomic: {},
  spheres: {},
  gaussians: {}
}, z_0 = j.objectToOptions(YR1);
function D_0(Z, J) {
  for (let $ = 0, X = Z.length;$ < X; ++$) {
    if (j0.isAtomic(J) && Z[$] === "atomic")
      return !0;
    if (j0.isSpheres(J) && Z[$] === "spheres")
      return !0;
    if (j0.isGaussians(J) && Z[$] === "gaussians")
      return !0;
  }
  return !1;
}
var M_0 = 500000000;
function f00(Z, J, $ = M_0) {
  let X = t1.size(M(), Z);
  M.ceil(X, X), X.sort((K, G) => G - K);
  let Y = Math.floor(Math.cbrt($) * Math.cbrt($)), Q = X[0] * X[1], W = Math.ceil(Q / (J * J));
  return { area: Q, areaCells: W, maxAreaCells: Y };
}
function jq(Z, J, $ = M_0) {
  let { area: X, areaCells: Y, maxAreaCells: Q } = f00(Z, J.resolution, $), W = Y > Q ? Math.sqrt(X / Q) : J.resolution;
  return { ...J, resolution: W };
}
function QR1(Z) {
  switch (Z.kind) {
    case j0.Kind.Atomic:
      return Z.model.atomicConformation;
    case j0.Kind.Spheres:
      return Z.model.coarseConformation.spheres;
    case j0.Kind.Gaussians:
      return Z.model.coarseConformation.gaussians;
  }
}
var cz = {
  ignoreHydrogens: j.Boolean(!1, { description: "Whether or not to include hydrogen atoms in the surface calculation." }),
  ignoreHydrogensVariant: j.Select("all", j.arrayToOptions(["all", "non-polar"])),
  traceOnly: j.Boolean(!1, { description: "Whether or not to only use trace atoms in the surface calculation." }),
  includeParent: j.Boolean(!1, { description: "Include elements of the parent structure in surface calculation to get a surface patch of the current structure." })
}, J78 = j.getDefaultValues(cz), WR1 = M();
function A_0(Z, J, $, X) {
  return M.squaredDistance(M.set(WR1, Z, J, $), X);
}
function KR1(Z, J, $) {
  let X = 0, Y = J.length;
  for (let Q = 0, W = $.length;Q < W; ++Q) {
    let K = X1.indexOfInRange(J, $[Q], X, Y);
    if (K === -1)
      Z[Q] = -2;
    else
      Z[Q] = K, X = K;
  }
}
function KB(Z, J, $, X) {
  let { ignoreHydrogens: Y, ignoreHydrogensVariant: Q, traceOnly: W, includeParent: K } = X, G = K ? Z.root.unitMap.get(J.id) : J, H = K && G !== J, { x: N, y: q, z: U } = QR1(G), { elements: F } = G, { center: E, radius: R } = J.boundary.sphere, z = 11, D = (R + 11) * (R + 11), A, B;
  if (Y || W || H) {
    let I = [], S = [];
    for (let f = 0, v = F.length;f < v; ++f) {
      let h = F[f];
      if (Y && pW(Z, G, h, Q))
        continue;
      if (W && !dx(G, h))
        continue;
      if (H && A_0(N[h], q[h], U[h], E) > D)
        continue;
      I.push(h), S.push(f);
    }
    A = X1.ofSortedArray(I), B = S;
  } else
    A = F, B = uJ(new Int32Array(A.length));
  if (K && G !== J)
    KR1(B, J.elements, A);
  let T = { indices: A, x: N, y: q, z: U, id: B }, w = H ? GH(T) : J.boundary, V = W0.Location.create(Z, G);
  return { position: T, boundary: w, radius: (I) => {
    return V.element = I, $.size(V);
  } };
}
function GB(Z, J, $) {
  let { ignoreHydrogens: X, ignoreHydrogensVariant: Y, traceOnly: Q, includeParent: W } = $, K = W && !!Z.parent, G = W0.Location.create(Z.root), { center: H, radius: N } = Z.boundary.sphere, q = 11, U = (N + 11) * (N + 11), F, E, R, z, D, A;
  if (X || Q || K) {
    let { getSerialIndex: V } = Z.serialMapping, P = K ? Z.root.units : Z.units, I = [], S = [], f = [], v = [], h = [];
    for (let x = 0, b = P.length;x < b; ++x) {
      let g = P[x], { elements: m, conformation: i } = g, r = Z.unitMap.get(g.id);
      G.unit = g;
      for (let Y0 = 0, c = m.length;Y0 < c; ++Y0) {
        let n = m[Y0];
        if (X && pW(Z, g, n, Y))
          continue;
        if (Q && !dx(g, n))
          continue;
        let l = i.x(n), u = i.y(n), G0 = i.z(n);
        if (K && A_0(l, u, G0, H) > U)
          continue;
        if (I.push(l), S.push(u), f.push(G0), G.element = n, v.push(J.size(G)), K)
          if ((r ? X1.indexOf(r.elements, n) : -1) === -1)
            h.push(-2);
          else
            h.push(V(r, n));
        else
          h.push(V(g, n));
      }
    }
    F = I, E = S, R = f, z = v, D = h, A = f0.ofRange(0, D.length);
  } else {
    let { elementCount: V } = Z, P = new Float32Array(V), I = new Float32Array(V), S = new Float32Array(V), f = new Float32Array(V);
    for (let v = 0, h = 0, x = Z.units.length;v < x; ++v) {
      let b = Z.units[v], { elements: g, conformation: m } = b;
      G.unit = b;
      for (let i = 0, r = g.length;i < r; ++i) {
        let Y0 = g[i], c = h + i;
        P[c] = m.x(Y0), I[c] = m.y(Y0), S[c] = m.z(Y0), G.element = Y0, f[c] = J.size(G);
      }
      h += g.length;
    }
    F = P, E = I, R = S, z = f, D = uJ(new Uint32Array(V)), A = f0.ofRange(0, D.length);
  }
  let B = { indices: A, x: F, y: E, z: R, id: D }, T = K ? GH(B) : Z.boundary;
  return { position: B, boundary: T, radius: (V) => z[V] };
}
var GR1 = g_.H;
function pW(Z, J, $, X) {
  if (j0.isCoarse(J))
    return !1;
  if (J.model.atomicHierarchy.derived.atom.atomicNumber[$] !== GR1)
    return !1;
  if (X === "all")
    return !0;
  let Y = oT0(Z, J, X1.indexOf(J.elements, $));
  if (Y && X === "polar")
    return !0;
  if (!Y && X === "non-polar")
    return !0;
  return !1;
}
function dx(Z, J) {
  if (j0.isCoarse(Z))
    return !0;
  let $ = Z.model.atomicHierarchy.atoms.label_atom_id.value(J);
  if ($ === "CA" || $ === "BB" || $ === "P")
    return !0;
  return !1;
}

// node_modules/molstar/lib/mol-repr/structure/params.js
function zU(Z) {
  return j.MultiSelect(Z, z_0, { description: "For which kinds of units/chains to show the representation visuals." });
}
var WX = {
  unitKinds: zU(["atomic", "spheres"]),
  includeParent: j.Boolean(!1, { isHidden: !0 })
}, px = { ...n1.Params }, ux = { ...R$.Params }, cx = { ...T7.Params }, lx = { ...YX.Params }, nx = { ...f6.Params }, ix = { ...IJ.Params }, ox = { ...gX.Params }, sx = { ...iJ.Params }, ax = { ...VY.Params };

// node_modules/molstar/lib/mol-repr/structure/complex-visual.js
function HR1(Z, J, $, X, Y, Q) {
  let { createValues: W, createRenderableState: K } = n7.getUtils(J), G = Vh(), H = W(J, G, $, X, Y), N = K(Y);
  return v3(J.kind, H, N, Q);
}
function Tq(Z, J) {
  let { defaultProps: $, createGeometry: X, createLocationIterator: Y, getLoci: Q, eachLocation: W, setUpdateState: K, mustRecreate: G, processValues: H, dispose: N } = Z, { updateValues: q, updateBoundingSphere: U, updateRenderableState: F, createPositionIterator: E } = Z.geometryUtils, R = S5.create(), z = { loci: G8, action: x2.None, status: -1 }, D, A, B, T, w = Object.assign({}, $), V = Q7.createEmpty(), P, I, S = -1, f, v;
  function h(r, Y0, c) {
    if (!c && !P)
      throw new Error("missing structure");
    if (A = Object.assign({}, w, Y0), B = r, T = c, S5.reset(R), !D || !P) {
      R.createNew = !0, R.createGeometry = !0;
      return;
    }
    if (K(R, A, w, B, V, T, P), !s0.areEquivalent(T, P))
      R.createGeometry = !0;
    if (!s0.areHierarchiesEqual(T, P))
      R.updateTransform = !0, R.createGeometry = !0;
    if (!oJ.areEqual(r.color, V.color))
      R.updateColor = !0;
    if (!J9.areEqual(r.size, V.size))
      R.updateSize = !0;
    if (!QY(A.unitKinds, w.unitKinds))
      R.createGeometry = !0;
    if (P.child !== T.child)
      R.createGeometry = !0, R.updateTransform = !0;
    if (A.instanceGranularity !== w.instanceGranularity)
      R.updateTransform = !0;
    if (R.updateSize && !("uSize" in D.values))
      R.createGeometry = !0;
    if (R.createGeometry)
      R.updateColor = !0, R.updateSize = !0;
  }
  function x(r) {
    if (R.createNew)
      if (f = Y(T, A), r)
        D = HR1(T, r, f, B, A, J), v = E(r, D.values);
      else
        throw new Error("expected geometry to be given");
    else {
      if (!D)
        throw new Error("expected renderObject to be available");
      if (R.updateColor || R.updateSize || R.updateTransform)
        f = Y(T, A);
      if (R.updateTransform) {
        let { instanceCount: Y0, groupCount: c } = f;
        if (A.instanceGranularity)
          rZ(Y0, "instance", D.values);
        else
          rZ(Y0 * c, "groupInstance", D.values);
      }
      if (R.createGeometry)
        if (r)
          C.updateIfChanged(D.values.drawCount, n7.getDrawCount(r)), C.updateIfChanged(D.values.uVertexCount, n7.getVertexCount(r)), C.updateIfChanged(D.values.uGroupCount, f.groupCount);
        else
          throw new Error("expected geometry to be given");
      if (R.updateTransform || R.createGeometry)
        U(D.values, r || I), v = E(I, D.values);
      if (R.updateSize) {
        if ("uSize" in D.values)
          DY(f, B.size, D.values);
      }
      if (R.updateColor)
        WJ(f, v, B.color, D.values);
      q(D.values, A), F(D.state, A);
    }
    if (w = A, V = B, P = T, r)
      I = r, S += 1;
  }
  function b(r) {
    if (KJ(r))
      return !0;
    if (s0.isLoci(r) && s0.areRootsEquivalent(r.structure, P))
      return !0;
    if (W0.Loci.is(r) && s0.areRootsEquivalent(r.structure, P)) {
      if (W0.Loci.isWholeStructure(r))
        return !0;
    }
    return !1;
  }
  function g(r, Y0, c) {
    let n = !1;
    if (!W0.Loci.is(r) && !$2.isLoci(r))
      return !1;
    if (!s0.areEquivalent(r.structure, Y0))
      return !1;
    if (c(k0.ofSingleton(0)))
      n = !0;
    return n;
  }
  function m(r, Y0, c) {
    if (b(r))
      if (w.instanceGranularity)
        return Y0(k0.ofBounds(0, f.instanceCount));
      else
        return Y0(k0.ofBounds(0, f.groupCount * f.instanceCount));
    else if (w.instanceGranularity)
      return g(r, P, Y0);
    else
      return W(r, P, Y0, c);
  }
  function i(r) {
    if (D)
      H === null || H === void 0 || H(D.values, I, w, V, r.webgl);
  }
  return {
    get groupCount() {
      return f ? f.count : 0;
    },
    get renderObject() {
      return f && f.count ? D : void 0;
    },
    get geometryVersion() {
      return S;
    },
    createOrUpdate(r, Y0, c = {}, n) {
      if (h(Y0, c, n || P), R.createGeometry) {
        let l = X(r, T, B, A, I);
        if (lL(l))
          return l.then((u) => {
            x(u), i(r);
          });
        x(l);
      } else
        x();
      i(r);
    },
    getLoci(r) {
      return D ? Q(r, P, D.id) : G8;
    },
    eachLocation(r) {
      f.reset();
      while (f.hasNext) {
        let { location: Y0, isSecondary: c } = f.move();
        r(Y0, c);
      }
    },
    mark(r, Y0) {
      return m8.mark(D, r, Y0, m, z);
    },
    setVisibility(r) {
      m8.setVisibility(D, r);
    },
    setAlphaFactor(r) {
      m8.setAlphaFactor(D, r);
    },
    setPickable(r) {
      m8.setPickable(D, r);
    },
    setColorOnly(r) {
      m8.setColorOnly(D, r);
    },
    setTransform(r, Y0) {
      m8.setTransform(D, r, Y0);
    },
    setOverpaint(r, Y0) {
      let c = { geometry: I, props: w, webgl: Y0 };
      m8.setOverpaint(D, r, m, !0, c);
    },
    setTransparency(r, Y0) {
      let c = { geometry: I, props: w, webgl: Y0 };
      m8.setTransparency(D, r, m, !0, c);
    },
    setEmissive(r, Y0) {
      let c = { geometry: I, props: w, webgl: Y0 };
      m8.setEmissive(D, r, m, !0, c);
    },
    setSubstance(r, Y0) {
      let c = { geometry: I, props: w, webgl: Y0 };
      m8.setSubstance(D, r, m, !0, c);
    },
    setClipping(r) {
      m8.setClipping(D, r, m, !0);
    },
    setThemeStrength(r) {
      m8.setThemeStrength(D, r);
    },
    destroy() {
      if (N === null || N === void 0 || N(I), D)
        D.state.disposed = !0, D = void 0;
    },
    mustRecreate: G
  };
}
var tQ = { ...px, ...WX };
function D$(Z, J) {
  return Tq({
    ...Z,
    setUpdateState: ($, X, Y, Q, W, K, G) => {
      if (Z.setUpdateState($, X, Y, Q, W, K, G), !J9.areEqual(Q.size, W.size))
        $.createGeometry = !0;
    },
    geometryUtils: n1.Utils
  }, J);
}
var B_0 = { ...ux, ...WX };
function w_0(Z, J) {
  return Tq({
    ...Z,
    setUpdateState: ($, X, Y, Q, W, K, G) => {
      if (Z.setUpdateState($, X, Y, Q, W, K, G), !J9.areEqual(Q.size, W.size))
        $.updateSize = !0;
    },
    geometryUtils: R$.Utils
  }, J);
}
var rx = { ...cx, ...WX };
function tx(Z, J) {
  return Tq({
    ...Z,
    setUpdateState: ($, X, Y, Q, W, K, G) => {
      if (Z.setUpdateState($, X, Y, Q, W, K, G), !J9.areEqual(Q.size, W.size))
        $.updateSize = !0;
    },
    geometryUtils: T7.Utils
  }, J);
}
var j_0 = { ...lx, ...WX };
function T_0(Z, J) {
  return Tq({
    ...Z,
    setUpdateState: ($, X, Y, Q, W, K, G) => {
      if (Z.setUpdateState($, X, Y, Q, W, K, G), !J9.areEqual(Q.size, W.size))
        $.updateSize = !0;
    },
    geometryUtils: YX.Utils
  }, J);
}
var HB = { ...nx, ...WX };
function NB(Z, J) {
  return Tq({
    ...Z,
    setUpdateState: ($, X, Y, Q, W, K, G) => {
      if (Z.setUpdateState($, X, Y, Q, W, K, G), !J9.areEqual(Q.size, W.size))
        $.updateSize = !0;
    },
    geometryUtils: f6.Utils
  }, J);
}
var __0 = { ...ix, ...WX };
function V_0(Z, J) {
  return Tq({
    ...Z,
    setUpdateState: ($, X, Y, Q, W, K, G) => {
      if (Z.setUpdateState($, X, Y, Q, W, K, G), !J9.areEqual(Q.size, W.size))
        $.updateSize = !0;
      if (X.background !== Y.background)
        $.createGeometry = !0;
      if (X.backgroundMargin !== Y.backgroundMargin)
        $.createGeometry = !0;
      if (X.tether !== Y.tether)
        $.createGeometry = !0;
      if (X.tetherLength !== Y.tetherLength)
        $.createGeometry = !0;
      if (X.tetherBaseWidth !== Y.tetherBaseWidth)
        $.createGeometry = !0;
      if (X.attachment !== Y.attachment)
        $.createGeometry = !0;
      if (X.fontFamily !== Y.fontFamily)
        $.createGeometry = !0;
      if (X.fontQuality !== Y.fontQuality)
        $.createGeometry = !0;
      if (X.fontStyle !== Y.fontStyle)
        $.createGeometry = !0;
      if (X.fontVariant !== Y.fontVariant)
        $.createGeometry = !0;
      if (X.fontWeight !== Y.fontWeight)
        $.createGeometry = !0;
    },
    geometryUtils: IJ.Utils
  }, J);
}
var I_0 = { ...ox, ...WX };
function P_0(Z, J) {
  return Tq({
    ...Z,
    setUpdateState: ($, X, Y, Q, W, K, G) => {
      if (Z.setUpdateState($, X, Y, Q, W, K, G), !J9.areEqual(Q.size, W.size))
        $.createGeometry = !0;
    },
    geometryUtils: gX.Utils
  }, J);
}
var C_0 = { ...sx, ...WX };
function k_0(Z, J) {
  return Tq({
    ...Z,
    setUpdateState: ($, X, Y, Q, W, K, G) => {
      if (Z.setUpdateState($, X, Y, Q, W, K, G), !J9.areEqual(Q.size, W.size))
        $.createGeometry = !0;
    },
    geometryUtils: iJ.Utils
  }, J);
}
var v_0 = { ...ax, ...WX };
function S_0(Z, J) {
  return Tq({
    ...Z,
    setUpdateState: ($, X, Y, Q, W, K, G) => {
      if (Z.setUpdateState($, X, Y, Q, W, K, G), !J9.areEqual(Q.size, W.size))
        $.createGeometry = !0;
    },
    geometryUtils: VY.Utils
  }, J);
}
// node_modules/molstar/lib/mol-util/map.js
class h00 {
  set(Z, J) {
    let $ = this.hashCode(Z), X = this.buckets.get($);
    if (!X)
      X = [], this.buckets.set($, X);
    for (let Y = 0;Y < X.length; Y++)
      if (this.areEqual(X[Y].key, Z)) {
        X[Y].value = J;
        return;
      }
    X.push({ key: Z, value: J });
  }
  get(Z) {
    let J = this.hashCode(Z), $ = this.buckets.get(J);
    if (!$)
      return;
    for (let X of $)
      if (this.areEqual(X.key, Z))
        return X.value;
    return;
  }
  delete(Z) {
    let J = this.hashCode(Z), $ = this.buckets.get(J);
    if (!$)
      return !1;
    for (let X = 0;X < $.length; X++)
      if (this.areEqual($[X].key, Z)) {
        if ($.splice(X, 1), $.length === 0)
          this.buckets.delete(J);
        return !0;
      }
    return !1;
  }
  forEach(Z) {
    for (let J of this.buckets.values())
      for (let $ of J)
        Z($.value, $.key);
  }
  clear() {
    this.buckets.clear();
  }
  constructor(Z, J) {
    this.hashCode = Z, this.areEqual = J, this.buckets = /* @__PURE__ */ new Map;
  }
}

// node_modules/molstar/lib/mol-repr/structure/units-representation.js
function f_0() {
  return new h00((Z) => Z.hashCode, j0.SymmetryGroup.areInvariantElementsEqual);
}
function _Z(Z, J, $, X) {
  let Y = 0, { webgl: Q } = J, W = new P6, K = bW(), G = [], H = new V2.GeometryState, N = lZ.create(), q = f_0(), U, F, E, R, z = Q7.createEmpty();
  function D(f = {}, v) {
    if (v && v !== U) {
      if (E = $(J, v), !R)
        R = j.getDefaultValues(E);
    }
    return R = Object.assign({}, R, f), n0.create("Creating or updating UnitsRepresentation", async (h) => {
      var x, b, g;
      if (!U && !v)
        throw new Error("missing structure");
      else if (v && !U) {
        F = v.unitSymmetryGroups;
        for (let m = 0;m < F.length; m++) {
          let i = F[m], r = X(K, v, R, Q), Y0 = r.createOrUpdate({ webgl: Q, runtime: h }, z, R, { group: i, structure: v });
          if (Y0)
            await Y0;
          if (V(r, i, N), q.set(i, { visual: r, group: i }), h.shouldUpdate)
            await h.update({ message: "Creating or updating UnitsVisual", current: m, max: F.length });
        }
      } else if (v && (!s0.areUnitIdsAndIndicesEqual(v, U) || v.child !== U.child)) {
        F = v.unitSymmetryGroups;
        let m = q;
        q = f_0();
        for (let i = 0;i < F.length; i++) {
          let r = F[i], Y0 = m.get(r);
          if (Y0) {
            let { visual: c } = Y0;
            if ((x = c.mustRecreate) === null || x === void 0 ? void 0 : x.call(c, { group: r, structure: v }, R, Q)) {
              c.destroy(), c = X(K, v, R, Q);
              let n = c.createOrUpdate({ webgl: Q, runtime: h }, z, R, { group: r, structure: v });
              if (n)
                await n;
              V(c, r, N);
            } else {
              let n = c.createOrUpdate({ webgl: Q, runtime: h }, z, R, { group: r, structure: v });
              if (n)
                await n;
            }
            if (q.set(r, { visual: c, group: r }), m.delete(r), c.renderObject) {
              let n = c.renderObject.values.tMarker.ref.value.array;
              yR(n, k0.ofBounds(0, n.length), x2.RemoveHighlight);
            }
          } else {
            let c = X(K, v, R, Q), n = c.createOrUpdate({ webgl: Q, runtime: h }, z, R, { group: r, structure: v });
            if (n)
              await n;
            V(c, r, N), q.set(r, { visual: c, group: r });
          }
          if (h.shouldUpdate)
            await h.update({ message: "Creating or updating UnitsVisual", current: i, max: F.length });
        }
        m.forEach(({ visual: i }) => {
          i.destroy();
        });
      } else if (v && v !== U && s0.areUnitIdsAndIndicesEqual(v, U)) {
        F = v.unitSymmetryGroups;
        for (let m = 0;m < F.length; m++) {
          let i = F[m], r = q.get(i);
          if (r) {
            let { visual: Y0 } = r;
            if ((b = Y0.mustRecreate) === null || b === void 0 ? void 0 : b.call(Y0, { group: i, structure: v }, R, J.webgl)) {
              Y0.destroy(), Y0 = X(K, v, R, J.webgl), r.visual = Y0;
              let c = Y0.createOrUpdate({ webgl: Q, runtime: h }, z, R, { group: i, structure: v });
              if (c)
                await c;
              V(Y0, i, N);
            } else {
              let c = Y0.createOrUpdate({ webgl: Q, runtime: h }, z, R, { group: i, structure: v });
              if (c)
                await c;
            }
            r.group = i;
          } else
            throw new Error(`expected to find visual for hashCode ${i.hashCode}`);
          if (h.shouldUpdate)
            await h.update({ message: "Creating or updating UnitsVisual", current: m, max: F.length });
        }
      } else {
        let m = [];
        q.forEach((i) => m.push(i));
        for (let i = 0, r = m.length;i < r; ++i) {
          let { visual: Y0, group: c } = m[i];
          if ((g = Y0.mustRecreate) === null || g === void 0 ? void 0 : g.call(Y0, { group: c, structure: U }, R, J.webgl)) {
            Y0.destroy(), Y0 = X(K, U, R, Q), m[i].visual = Y0;
            let n = Y0.createOrUpdate({ webgl: Q, runtime: h }, z, R, { group: c, structure: U });
            if (n)
              await n;
            V(Y0, c, N);
          } else {
            let n = Y0.createOrUpdate({ webgl: Q, runtime: h }, z, R);
            if (n)
              await n;
          }
          if (h.shouldUpdate)
            await h.update({ message: "Creating or updating UnitsVisual", current: i, max: r });
        }
      }
      if (G.length = 0, q.forEach(({ visual: m }) => {
        if (m.renderObject)
          G.push(m.renderObject), H.add(m.renderObject.id, m.geometryVersion);
      }), H.snapshot(), v)
        U = v;
      W.next(Y++);
    });
  }
  function A(f) {
    let v = G8;
    return q.forEach(({ visual: h }) => {
      let x = h.getLoci(f);
      if (!_7(x))
        v = x;
    }), v;
  }
  function B(f) {
    q.forEach(({ visual: v }) => {
      v.eachLocation(f);
    });
  }
  function T() {
    var f;
    return [s0.Loci((f = U.child) !== null && f !== void 0 ? f : U)];
  }
  function w(f, v) {
    if (!U)
      return !1;
    if (!W7.is(N.markerActions, v))
      return !1;
    if (s0.isLoci(f) || W0.Loci.is(f) || $2.isLoci(f)) {
      if (!s0.areRootsEquivalent(f.structure, U))
        return !1;
      if (f = d2.remap(f, U), s0.isLoci(f) || W0.Loci.is(f) && W0.Loci.isWholeStructure(f))
        f = nN;
    } else if (!KJ(f) && !Mz(f))
      return !1;
    if (d2.isEmpty(f))
      return !1;
    let h = !1;
    return q.forEach(({ visual: x }) => {
      h = x.mark(f, v) || h;
    }), h;
  }
  function V(f, v, h) {
    let { visible: x, alphaFactor: b, pickable: g, overpaint: m, transparency: i, emissive: r, substance: Y0, clipping: c, themeStrength: n, transform: l, unitTransforms: u } = h;
    if (x !== void 0)
      f.setVisibility(x);
    if (b !== void 0)
      f.setAlphaFactor(b);
    if (g !== void 0)
      f.setPickable(g);
    if (m !== void 0)
      f.setOverpaint(m, Q);
    if (i !== void 0)
      f.setTransparency(i, Q);
    if (r !== void 0)
      f.setEmissive(r, Q);
    if (Y0 !== void 0)
      f.setSubstance(Y0, Q);
    if (c !== void 0)
      f.setClipping(c);
    if (n !== void 0)
      f.setThemeStrength(n);
    if (l !== void 0) {
      if (l !== N.transform || !e.areEqual(l, N.transform, u8))
        f.setTransform(l);
    }
    if (u !== void 0) {
      if (u)
        f.setTransform(void 0, u.getSymmetryGroupTransforms(v));
      else if (u !== N.unitTransforms)
        f.setTransform(void 0, null);
    }
  }
  function P(f) {
    let { visible: v, alphaFactor: h, pickable: x, overpaint: b, transparency: g, emissive: m, substance: i, clipping: r, themeStrength: Y0, transform: c, unitTransforms: n, syncManually: l, markerActions: u } = f, G0 = {};
    if (v !== void 0)
      G0.visible = v;
    if (h !== void 0)
      G0.alphaFactor = h;
    if (x !== void 0)
      G0.pickable = x;
    if (b !== void 0 && U)
      G0.overpaint = rJ.remap(b, U);
    if (g !== void 0 && U)
      G0.transparency = tJ.remap(g, U);
    if (m !== void 0 && U)
      G0.emissive = Z$.remap(m, U);
    if (i !== void 0 && U)
      G0.substance = eJ.remap(i, U);
    if (r !== void 0 && U)
      G0.clipping = $9.remap(r, U);
    if (Y0 !== void 0)
      G0.themeStrength = Y0;
    if (c !== void 0 && !e.areEqual(c, N.transform, u8))
      G0.transform = c;
    if (n !== N.unitTransforms || (n === null || n === void 0 ? void 0 : n.version) !== N.unitTransformsVersion)
      G0.unitTransforms = n, N.unitTransformsVersion = n ? n === null || n === void 0 ? void 0 : n.version : -1;
    if (l !== void 0)
      G0.syncManually = l;
    if (u !== void 0)
      G0.markerActions = u;
    q.forEach(({ visual: F0, group: t }) => V(F0, t, G0)), lZ.update(N, G0);
  }
  function I(f) {
    z = f;
  }
  function S() {
    q.forEach(({ visual: f }) => f.destroy()), q.clear();
  }
  return {
    label: Z,
    get groupCount() {
      let f = 0;
      return q.forEach(({ visual: v }) => {
        if (v.renderObject)
          f += v.groupCount;
      }), f;
    },
    get geometryVersion() {
      return H.version;
    },
    get props() {
      return R;
    },
    get params() {
      return E;
    },
    get state() {
      return N;
    },
    get theme() {
      return z;
    },
    renderObjects: G,
    updated: W,
    createOrUpdate: D,
    setState: P,
    setTheme: I,
    getLoci: A,
    getAllLoci: T,
    eachLocation: B,
    mark: w,
    destroy: S
  };
}
// node_modules/molstar/lib/mol-repr/structure/units-visual.js
function NR1(Z, J, $, X, Y, Q) {
  let { createValues: W, createRenderableState: K } = n7.getUtils(J), G = S00(Z, Y.includeParent, J.boundingSphere, Y.cellSize, Y.batchSize), H = W(J, G, $, X, Y), N = K(Y);
  return v3(J.kind, H, N, Q);
}
function WE(Z, J) {
  let { defaultProps: $, createGeometry: X, createLocationIterator: Y, getLoci: Q, eachLocation: W, setUpdateState: K, initUpdateState: G, mustRecreate: H, processValues: N, dispose: q } = Z, { createEmpty: U, updateValues: F, updateBoundingSphere: E, updateRenderableState: R, createPositionIterator: z } = Z.geometryUtils, D = S5.create(), A = { loci: G8, action: x2.None, status: -1 }, B, T = Object.assign({}, $), w = Q7.createEmpty(), V, P, I, S, f, v = -1, h, x;
  function b(n, l, u) {
    if (!u && !S)
      throw new Error("missing structureGroup");
    if (T = l, w = n, V = u, S5.reset(D), !B || !S) {
      G === null || G === void 0 || G(D, T, w, V), D.createNew = !0, D.createGeometry = !0;
      return;
    }
    if (K(D, T, P, w, I, V, S), !s0.areHierarchiesEqual(S.structure, V.structure))
      D.updateTransform = !0, D.updateColor = !0, D.updateSize = !0;
    if (!oJ.areEqual(w.color, I.color))
      D.updateColor = !0;
    if (!J9.areEqual(w.size, I.size))
      D.updateSize = !0;
    if (S.structure.child !== V.structure.child)
      D.createGeometry = !0, D.updateTransform = !0;
    if (T.instanceGranularity !== P.instanceGranularity || T.cellSize !== P.cellSize || T.batchSize !== P.batchSize)
      D.updateTransform = !0;
    if (!QY(T.unitKinds, P.unitKinds))
      D.createGeometry = !0;
    if (V.group.transformHash !== S.group.transformHash)
      if (V.group.units.length !== S.group.units.length || D.updateColor)
        D.updateTransform = !0;
      else
        D.updateMatrix = !0;
    let G0 = V.group.units[0], F0 = S.group.units[0];
    if (!j0.areOperatorsEqual(G0, F0))
      D.updateTransform = !0;
    if (!j0.areConformationsEqual(G0, F0))
      D.createGeometry = !0;
    if (D.updateTransform)
      D.updateMatrix = !0;
    if (D.updateSize && !("uSize" in B.values))
      D.createGeometry = !0;
    if (D.createGeometry || D.updateTransform) {
      if (S.structure.hashCode !== V.structure.hashCode)
        D.updateColor = !0, D.updateSize = !0;
      if (w.color.granularity.startsWith("vertex") || B.values.dColorType.ref.value.startsWith("vertex") || w.color.granularity.startsWith("volume") || B.values.dColorType.ref.value.startsWith("volume"))
        D.updateColor = !0;
    }
  }
  function g(n) {
    if (D.createNew)
      if (h = Y(V, T), n)
        B = NR1(V, n, h, w, T, J), x = z(n, B.values);
      else
        throw new Error("expected geometry to be given");
    else {
      if (!B)
        throw new Error("expected renderObject to be available");
      if (D.updateColor || D.updateSize || D.updateTransform)
        h = Y(V, T);
      if (D.updateTransform) {
        let { instanceCount: l, groupCount: u } = h;
        if (T.instanceGranularity)
          rZ(l, "instance", B.values);
        else
          rZ(l * u, "groupInstance", B.values);
      }
      if (D.updateMatrix) {
        if (S00(V, T.includeParent, (n === null || n === void 0 ? void 0 : n.boundingSphere) || B.values.invariantBoundingSphere.ref.value, T.cellSize, T.batchSize, B.values), "lodLevels" in B.values)
          C.update(B.values.lodLevels, B.values.lodLevels.ref.value);
      }
      if (D.createGeometry)
        if (n)
          C.updateIfChanged(B.values.drawCount, n7.getDrawCount(n)), C.updateIfChanged(B.values.uVertexCount, n7.getVertexCount(n)), C.updateIfChanged(B.values.uGroupCount, h.groupCount);
        else
          throw new Error("expected geometry to be given");
      if (D.updateTransform || D.createGeometry)
        E(B.values, n || f), x = z(n || f, B.values);
      if (D.updateSize) {
        if ("uSize" in B.values)
          DY(h, w.size, B.values);
      }
      if (D.updateColor)
        WJ(h, x, w.color, B.values);
      F(B.values, T), R(B.state, T);
    }
    if (P = T, I = w, S = V, n)
      f = n, v += 1;
  }
  function m(n, l, u, G0, F0, t) {
    return D_0(F0.unitKinds, l) ? X(n, l, u, G0, F0, t) : U(t);
  }
  function i(n) {
    if (KJ(n))
      return !0;
    if (s0.isLoci(n) && s0.areRootsEquivalent(n.structure, S.structure))
      return !0;
    if (W0.Loci.is(n) && s0.areRootsEquivalent(n.structure, S.structure)) {
      if (W0.Loci.isWholeStructure(n))
        return !0;
    }
    return !1;
  }
  function r(n, l, u) {
    let G0 = !1;
    if ($2.isLoci(n)) {
      let { structure: F0, group: t } = l;
      if (!s0.areEquivalent(n.structure, F0))
        return !1;
      for (let Z0 of n.bonds) {
        if (Z0.aUnit !== Z0.bUnit)
          continue;
        let U0 = t.unitIndexMap.get(Z0.aUnit.id);
        if (U0 !== void 0) {
          if (u(k0.ofSingleton(U0)))
            G0 = !0;
        }
      }
    } else if (W0.Loci.is(n)) {
      let { structure: F0, group: t } = l;
      if (!s0.areEquivalent(n.structure, F0))
        return !1;
      for (let Z0 of n.elements) {
        let U0 = t.unitIndexMap.get(Z0.unit.id);
        if (U0 !== void 0) {
          if (u(k0.ofSingleton(U0)))
            G0 = !0;
        }
      }
    }
    return G0;
  }
  function Y0(n, l, u) {
    if (i(n))
      if (P.instanceGranularity)
        return l(k0.ofBounds(0, h.instanceCount));
      else
        return l(k0.ofBounds(0, h.groupCount * h.instanceCount));
    else if (P.instanceGranularity)
      return r(n, S, l);
    else
      return W(n, S, l, u);
  }
  function c(n) {
    if (B)
      N === null || N === void 0 || N(B.values, f, P, I, n.webgl);
  }
  return {
    get groupCount() {
      return h ? h.count : 0;
    },
    get renderObject() {
      return h && h.count ? B : void 0;
    },
    get geometryVersion() {
      return v;
    },
    createOrUpdate(n, l, u, G0) {
      if (b(l, u, G0 || S), D.createGeometry) {
        let F0 = m(n, V.group.units[0], V.structure, w, T, f);
        if (lL(F0))
          return F0.then((t) => {
            g(t), c(n);
          });
        g(F0);
      } else
        g();
      c(n);
    },
    getLoci(n) {
      return B ? Q(n, S, B.id) : G8;
    },
    eachLocation(n) {
      h.reset();
      while (h.hasNext) {
        let { location: l, isSecondary: u } = h.move();
        n(l, u);
      }
    },
    mark(n, l) {
      let u = !0;
      if (W0.Loci.is(n)) {
        u = !1;
        let { invariantId: G0 } = S.group.units[0];
        for (let F0 of n.elements)
          if (F0.unit.invariantId === G0) {
            u = !0;
            break;
          }
      }
      return u ? m8.mark(B, n, l, Y0, A) : !1;
    },
    setVisibility(n) {
      m8.setVisibility(B, n);
    },
    setAlphaFactor(n) {
      m8.setAlphaFactor(B, n);
    },
    setPickable(n) {
      m8.setPickable(B, n);
    },
    setColorOnly(n) {
      m8.setColorOnly(B, n);
    },
    setTransform(n, l) {
      m8.setTransform(B, n, l);
    },
    setOverpaint(n, l) {
      let u = { geometry: f, props: P, webgl: l };
      m8.setOverpaint(B, n, Y0, !0, u);
    },
    setTransparency(n, l) {
      let u = { geometry: f, props: P, webgl: l };
      m8.setTransparency(B, n, Y0, !0, u);
    },
    setEmissive(n, l) {
      let u = { geometry: f, props: P, webgl: l };
      m8.setEmissive(B, n, Y0, !0, u);
    },
    setSubstance(n, l) {
      let u = { geometry: f, props: P, webgl: l };
      m8.setSubstance(B, n, Y0, !0, u);
    },
    setClipping(n) {
      m8.setClipping(B, n, Y0, !0);
    },
    setThemeStrength(n) {
      m8.setThemeStrength(B, n);
    },
    destroy() {
      if (q === null || q === void 0 || q(f), B)
        B.state.disposed = !0, B = void 0;
    },
    mustRecreate: H
  };
}
var nZ = { ...px, ...WX };
function A9(Z, J) {
  return WE({
    ...Z,
    setUpdateState: ($, X, Y, Q, W, K, G) => {
      if (Z.setUpdateState($, X, Y, Q, W, K, G), !J9.areEqual(Q.size, W.size))
        $.createGeometry = !0;
    },
    geometryUtils: n1.Utils
  }, J);
}
var qB = { ...ux, ...WX };
function FB(Z, J) {
  return WE({
    ...Z,
    setUpdateState: ($, X, Y, Q, W, K, G) => {
      if (Z.setUpdateState($, X, Y, Q, W, K, G), !J9.areEqual(Q.size, W.size))
        $.updateSize = !0;
    },
    geometryUtils: R$.Utils
  }, J);
}
var UB = { ...cx, ...WX };
function LB(Z, J) {
  return WE({
    ...Z,
    setUpdateState: ($, X, Y, Q, W, K, G) => {
      if (Z.setUpdateState($, X, Y, Q, W, K, G), !J9.areEqual(Q.size, W.size))
        $.updateSize = !0;
    },
    geometryUtils: T7.Utils
  }, J);
}
var h_0 = { ...lx, ...WX };
function b_0(Z, J) {
  return WE({
    ...Z,
    setUpdateState: ($, X, Y, Q, W, K, G) => {
      if (Z.setUpdateState($, X, Y, Q, W, K, G), !J9.areEqual(Q.size, W.size))
        $.updateSize = !0;
    },
    geometryUtils: YX.Utils
  }, J);
}
var KE = { ...nx, ...WX };
function GE(Z, J) {
  return WE({
    ...Z,
    setUpdateState: ($, X, Y, Q, W, K, G) => {
      if (Z.setUpdateState($, X, Y, Q, W, K, G), !J9.areEqual(Q.size, W.size))
        $.updateSize = !0;
    },
    geometryUtils: f6.Utils
  }, J);
}
var bJ8 = { ...ix, ...WX };
var x_0 = { ...ox, ...WX };
function y_0(Z, J) {
  return WE({
    ...Z,
    setUpdateState: ($, X, Y, Q, W, K, G) => {
      if (Z.setUpdateState($, X, Y, Q, W, K, G), !J9.areEqual(Q.size, W.size))
        $.createGeometry = !0;
    },
    geometryUtils: gX.Utils
  }, J);
}
var g_0 = { ...sx, ...WX };
function m_0(Z, J) {
  return WE({
    ...Z,
    setUpdateState: ($, X, Y, Q, W, K, G) => {
      if (Z.setUpdateState($, X, Y, Q, W, K, G), !J9.areEqual(Q.size, W.size))
        $.createGeometry = !0;
    },
    geometryUtils: iJ.Utils
  }, J);
}
var xJ8 = { ...ax, ...WX };

// node_modules/molstar/lib/mol-repr/structure/representation.js
var lZ = {
  create: () => {
    return {
      ...V2.createState(),
      unitTransforms: null,
      unitTransformsVersion: -1
    };
  },
  update: (Z, J) => {
    if (V2.updateState(Z, J), J.unitTransforms !== void 0)
      Z.unitTransforms = J.unitTransforms;
  }
};
function v9(Z) {
  return Z;
}

// node_modules/molstar/lib/mol-geo/geometry/cylinders/cylinders-builder.js
var DU = M(), RB = M(), RI = M(), ex = B1.add, d_0 = B1.add3, HE;
(function(Z) {
  function J($ = 2048, X = 1024, Y) {
    let Q = B1.create(Float32Array, 1, X, Y ? Y.groupBuffer.ref.value : $), W = B1.create(Float32Array, 3, X, Y ? Y.startBuffer.ref.value : $), K = B1.create(Float32Array, 3, X, Y ? Y.endBuffer.ref.value : $), G = B1.create(Float32Array, 1, X, Y ? Y.scaleBuffer.ref.value : $), H = B1.create(Float32Array, 1, X, Y ? Y.capBuffer.ref.value : $), N = B1.create(Float32Array, 1, X, Y ? Y.colorModeBuffer.ref.value : $), q = (F, E, R, z, D, A, B, T, w, V, P) => {
      for (let I = 0;I < 6; ++I)
        d_0(W, F, E, R), d_0(K, z, D, A), ex(Q, P), ex(G, B), ex(H, (T ? 1 : 0) + (w ? 2 : 0)), ex(N, V);
    }, U = (F, E, R, z, D, A, B, T, w) => {
      let V = M.distance(F, E), P = R % 2 !== 0, I = Math.floor((R + 1) / 2), S = V / (R + 0.5), f = 2;
      M.setMagnitude(RI, M.sub(RI, E, F), S), M.copy(DU, F);
      for (let v = 0;v < I; ++v) {
        if (M.add(DU, DU, RI), P && v === I - 1) {
          if (M.copy(RB, E), !B)
            A = !1;
        } else
          M.add(RB, DU, RI);
        if (T)
          f = M.distance(F, RB) / (V * 2);
        q(DU[0], DU[1], DU[2], RB[0], RB[1], RB[2], z, D, A, f, w), M.add(DU, DU, RI);
      }
    };
    return {
      add: q,
      addFixedCountDashes: U,
      addFixedLengthDashes: (F, E, R, z, D, A, B, T) => {
        let w = M.distance(F, E);
        U(F, E, w / R, z, D, A, !0, B, T);
      },
      getCylinders: () => {
        let F = Q.elementCount / 6, E = B1.compact(Q, !0), R = B1.compact(W, !0), z = B1.compact(K, !0), D = B1.compact(G, !0), A = B1.compact(H, !0), B = B1.compact(N, !0), T = Y && F <= Y.cylinderCount ? Y.mappingBuffer.ref.value : new Float32Array(F * 18), w = Y && F <= Y.cylinderCount ? Y.indexBuffer.ref.value : new Uint32Array(F * 12);
        if (!Y || F > Y.cylinderCount)
          qR1(F, T, w);
        return T7.create(T, w, E, R, z, D, A, B, F, Y);
      }
    };
  }
  Z.create = J;
})(HE || (HE = {}));
function qR1(Z, J, $) {
  for (let X = 0;X < Z; ++X) {
    let Y = X * 18;
    J[Y] = -1, J[Y + 1] = 1, J[Y + 2] = -1, J[Y + 3] = -1, J[Y + 4] = -1, J[Y + 5] = -1, J[Y + 6] = 1, J[Y + 7] = 1, J[Y + 8] = -1, J[Y + 9] = 1, J[Y + 10] = 1, J[Y + 11] = 1, J[Y + 12] = 1, J[Y + 13] = -1, J[Y + 14] = -1, J[Y + 15] = 1, J[Y + 16] = -1, J[Y + 17] = 1;
  }
  for (let X = 0;X < Z; ++X) {
    let Y = X * 6, Q = X * 12;
    $[Q] = Y, $[Q + 1] = Y + 1, $[Q + 2] = Y + 2, $[Q + 3] = Y + 1, $[Q + 4] = Y + 4, $[Q + 5] = Y + 2, $[Q + 6] = Y + 2, $[Q + 7] = Y + 4, $[Q + 8] = Y + 3, $[Q + 9] = Y + 4, $[Q + 10] = Y + 5, $[Q + 11] = Y + 3;
  }
}

// node_modules/molstar/lib/mol-repr/structure/visual/util/link.js
var hK = {
  linkScale: j.Numeric(0.45, { min: 0, max: 1, step: 0.01 }),
  linkSpacing: j.Numeric(1, { min: 0, max: 2, step: 0.01 }),
  linkCap: j.Boolean(!1),
  aromaticScale: j.Numeric(0.3, { min: 0, max: 1, step: 0.01 }),
  aromaticSpacing: j.Numeric(1.5, { min: 0, max: 3, step: 0.01 }),
  aromaticDashCount: j.Numeric(2, { min: 1, max: 6, step: 1 }),
  dashCount: j.Numeric(4, { min: 0, max: 10, step: 1 }),
  dashScale: j.Numeric(0.8, { min: 0, max: 2, step: 0.1 }),
  dashCap: j.Boolean(!0),
  stubCap: j.Boolean(!0),
  radialSegments: j.Numeric(16, { min: 2, max: 56, step: 2 }, q1.CustomQualityParamInfo),
  colorMode: j.Select("default", j.arrayToOptions(["default", "interpolate"]), q1.ShadingCategory)
}, W$8 = j.getDefaultValues(hK), b00 = {
  linkScale: j.Numeric(0.5, { min: 0, max: 1, step: 0.1 }),
  linkSpacing: j.Numeric(0.1, { min: 0, max: 2, step: 0.01 }),
  aromaticDashCount: j.Numeric(2, { min: 1, max: 6, step: 1 }),
  dashCount: j.Numeric(4, { min: 0, max: 10, step: 1 })
}, K$8 = j.getDefaultValues(b00), S9 = M(), NE = M(), ZG = M(), FR1 = M.create(0, 1, 0);
function x00(Z, J, $, X) {
  if (M.normalize(NE, M.sub(NE, J, $)), X !== null)
    M.sub(ZG, J, X);
  else
    M.copy(ZG, J);
  M.normalize(ZG, ZG);
  let Y = M.dot(NE, ZG);
  if (1 - Math.abs(Y) < 0.00001) {
    if (M.set(ZG, 1, 0, 0), Y = M.dot(NE, ZG), 1 - Math.abs(Y) < 0.00001)
      M.set(ZG, 0, 1, 0), Y = M.dot(NE, ZG);
  }
  return M.setMagnitude(NE, NE, Y), M.sub(ZG, ZG, NE), M.normalize(Z, ZG);
}
var Zy = {
  linkCount: 0,
  position: () => {},
  radius: () => 0
}, j2;
(function(Z) {
  Z[Z.Solid = 0] = "Solid", Z[Z.Dashed = 1] = "Dashed", Z[Z.Double = 2] = "Double", Z[Z.OffsetDouble = 3] = "OffsetDouble", Z[Z.Triple = 4] = "Triple", Z[Z.OffsetTriple = 5] = "OffsetTriple", Z[Z.Disk = 6] = "Disk", Z[Z.Aromatic = 7] = "Aromatic", Z[Z.MirroredAromatic = 8] = "MirroredAromatic";
})(j2 || (j2 = {}));
var CH = M.scale, o7 = M.add, $$ = M.sub, fY = M.setMagnitude, UR1 = M.dot;
function uW(Z, J, $, X) {
  let { linkCount: Y, referencePosition: Q, position: W, style: K, radius: G, ignore: H, stub: N } = J;
  if (!Y)
    return { mesh: n1.createEmpty(X) };
  let { radialSegments: q, stubCap: U } = $, F = q * 2 * Y * 2, E = v1.createState(F, F / 4, X), R = M(), z = 0, D = 0, A = {
    builderState: E,
    props: $,
    assignNonAdjustedPosition: (V, P) => {
      W(V, P, D, !1);
    },
    referencePosition: Q ? () => Q(D) : void 0
  }, B = {
    a: M(),
    b: M(),
    group: 0,
    linkStub: !1,
    linkStyle: j2.Solid,
    linkRadius: 0
  };
  for (let V = Y;D < V; ++D) {
    if (H && H(D))
      continue;
    W(B.a, B.b, D, !0), o7(R, R, B.a), o7(R, R, B.b), z += 2, B.group = D, B.linkStub = U && (N ? N(D) : !1), B.linkRadius = G(D), B.linkStyle = K ? K(D) : j2.Solid, RR1(A, B);
  }
  let T = v1.getMesh(E);
  if (z === 0)
    return { mesh: T };
  M.scale(R, R, 1 / z);
  let w = X ? C0.clone(X.boundingSphere) : void 0;
  if (w && M.distance(R, w.center) / w.radius < 0.1)
    return { mesh: T, boundingSphere: w };
  else
    return { mesh: T };
}
var LR1 = {
  cylinderProps: {
    radiusTop: 1,
    radiusBottom: 1,
    radialSegments: 8,
    topCap: !1,
    bottomCap: !1
  },
  vShift: M(),
  va: M(),
  vb: M()
};
function RR1(Z, J) {
  let { builderState: $, props: X, assignNonAdjustedPosition: Y, referencePosition: Q } = Z, { linkRadius: W, linkStub: K, linkStyle: G, a: H, b: N } = J, { linkScale: q, linkSpacing: U, radialSegments: F, linkCap: E, aromaticScale: R, aromaticSpacing: z, aromaticDashCount: D, dashCount: A, dashScale: B, dashCap: T } = X, { cylinderProps: w, vShift: V, va: P, vb: I } = LR1;
  w.radialSegments = F, M.copy(P, H), M.copy(I, N), $$(S9, I, P);
  let S = UR1(S9, FR1) > 0, [f, v] = S ? [K, E] : [E, K];
  if ($.currentGroup = J.group, G === j2.Solid)
    w.radiusTop = w.radiusBottom = W, w.topCap = f, w.bottomCap = v, q6($, P, I, 0.5, w);
  else if (G === j2.Dashed)
    w.radiusTop = w.radiusBottom = W * B, w.topCap = w.bottomCap = T, jz($, P, I, 0.5, A, K, w);
  else if (G === j2.Double || G === j2.OffsetDouble || G === j2.Triple || G === j2.OffsetTriple || G === j2.Aromatic || G === j2.MirroredAromatic) {
    let h = G === j2.Double || G === j2.OffsetDouble ? 2 : G === j2.Triple || G === j2.OffsetTriple ? 3 : 1.5, x = W * (q / (0.5 * h)), b = (W - x) * U;
    if (x00(V, P, I, Q ? Q() : null), w.topCap = f, w.bottomCap = v, G === j2.Aromatic || G === j2.MirroredAromatic) {
      w.radiusTop = w.radiusBottom = W, q6($, P, I, 0.5, w);
      let g = W + R * W + R * W * z;
      if (Y)
        Y(P, I);
      if (fY(S9, $$(S9, I, P), W * 0.5), o7(P, P, S9), $$(I, I, S9), w.radiusTop = w.radiusBottom = W * R, w.topCap = w.bottomCap = T, fY(V, V, g), $$(P, P, V), $$(I, I, V), jz($, P, I, 0.5, D, K, w), G === j2.MirroredAromatic)
        fY(V, V, g * 2), o7(P, P, V), o7(I, I, V), jz($, P, I, 0.5, D, K, w);
    } else if (G === j2.OffsetDouble || G === j2.OffsetTriple) {
      let g = W + x + q * W * U;
      if (fY(V, V, g), w.radiusTop = w.radiusBottom = W, q6($, P, I, 0.5, w), CH(S9, S9, U * q * 0.2), o7(P, P, S9), $$(I, I, S9), w.radiusTop = w.radiusBottom = x, w.topCap = S ? K : T, w.bottomCap = S ? T : K, fY(V, V, g), $$(P, P, V), $$(I, I, V), q6($, P, I, 0.5, w), h === 3)
        fY(V, V, g * 2), o7(P, P, V), o7(I, I, V), q6($, P, I, 0.5, w);
    } else {
      if (fY(V, V, b), w.radiusTop = w.radiusBottom = x, h === 3)
        q6($, P, I, 0.5, w);
      x40($, P, I, 0.5, V, w);
    }
  } else if (G === j2.Disk)
    CH(S9, S9, 0.475), o7(P, P, S9), $$(I, I, S9), w.radiusTop = w.radiusBottom = W, w.topCap = f, w.bottomCap = v, q6($, P, I, 0.5, w);
}
function EI(Z, J, $, X) {
  let { linkCount: Y, referencePosition: Q, position: W, style: K, radius: G, ignore: H, stub: N } = J;
  if (!Y)
    return { cylinders: T7.createEmpty(X) };
  let { linkScale: q, linkSpacing: U, linkCap: F, aromaticScale: E, aromaticSpacing: R, aromaticDashCount: z, dashCount: D, dashScale: A, dashCap: B, stubCap: T, colorMode: w } = $, V = w === "interpolate", P = V === !0 ? 3 : 2, I = Y * 2, S = HE.create(I, I / 4, X), f = M(), v = M(), h = M(), x = M(), b = M(), g = 0;
  for (let r = 0, Y0 = Y;r < Y0; ++r) {
    if (H && H(r))
      continue;
    W(f, v, r, !0), o7(b, b, f), o7(b, b, v), g += 2;
    let c = G(r), n = K ? K(r) : j2.Solid, l = T && (N ? N(r) : !1);
    if (n === j2.Solid)
      CH(h, o7(h, f, v), 0.5), S.add(f[0], f[1], f[2], h[0], h[1], h[2], 1, F, l, P, r);
    else if (n === j2.Dashed)
      CH(h, o7(h, f, v), 0.5), S.addFixedCountDashes(f, h, D, A, B, B, l, V, r);
    else if (n === j2.Double || n === j2.OffsetDouble || n === j2.Triple || n === j2.OffsetTriple || n === j2.Aromatic || n === j2.MirroredAromatic) {
      let u = n === j2.Double || n === j2.OffsetDouble ? 2 : n === j2.Triple || n === j2.OffsetTriple ? 3 : 1.5, G0 = q / (0.5 * u), F0 = (c - G0 * c) * U;
      if (CH(h, o7(h, f, v), 0.5), x00(x, f, v, Q ? Q(r) : null), n === j2.Aromatic || n === j2.MirroredAromatic) {
        S.add(f[0], f[1], f[2], h[0], h[1], h[2], 1, F, l, P, r);
        let t = c + E * c + E * c * R;
        if (W(f, v, r, !1), fY(S9, $$(S9, v, f), c * 0.5), o7(f, f, S9), fY(x, x, t), $$(f, f, x), $$(h, h, x), S.addFixedCountDashes(f, h, z, E, B, B, l, V, r), n === j2.MirroredAromatic)
          fY(x, x, t * 2), o7(f, f, x), o7(h, h, x), S.addFixedCountDashes(f, h, z, E, B, B, l, V, r);
      } else if (n === j2.OffsetDouble || n === j2.OffsetTriple) {
        let t = c + G0 * c + q * c * U;
        if (fY(x, x, t), S.add(f[0], f[1], f[2], h[0], h[1], h[2], 1, F, l, P, r), fY(S9, $$(S9, f, h), c / 1.5), $$(f, f, S9), u === 3)
          S.add(f[0] + x[0], f[1] + x[1], f[2] + x[2], h[0] + x[0], h[1] + x[1], h[2] + x[2], G0, F, l, P, r);
        S.add(f[0] - x[0], f[1] - x[1], f[2] - x[2], h[0] - x[0], h[1] - x[1], h[2] - x[2], G0, B, l, P, r);
      } else {
        if (fY(x, x, F0), u === 3)
          S.add(f[0], f[1], f[2], h[0], h[1], h[2], G0, F, l, P, r);
        S.add(f[0] + x[0], f[1] + x[1], f[2] + x[2], h[0] + x[0], h[1] + x[1], h[2] + x[2], G0, F, l, P, r), S.add(f[0] - x[0], f[1] - x[1], f[2] - x[2], h[0] - x[0], h[1] - x[1], h[2] - x[2], G0, F, l, P, r);
      }
    } else if (n === j2.Disk)
      CH(S9, $$(S9, h, f), 0.475), o7(f, f, S9), $$(h, h, S9), S.add(f[0], f[1], f[2], h[0], h[1], h[2], 1, F, l, P, r);
  }
  let m = S.getCylinders();
  if (g === 0)
    return { cylinders: m };
  M.scale(b, b, 1 / g);
  let i = X ? C0.clone(X.boundingSphere) : void 0;
  if (i && M.distance(b, i.center) / i.radius < 0.1)
    return { cylinders: m, boundingSphere: i };
  else
    return { cylinders: m };
}
function OI(Z, J, $, X) {
  let { linkCount: Y, referencePosition: Q, position: W, style: K, ignore: G } = J;
  if (!Y)
    return { lines: f6.createEmpty(X) };
  let { linkScale: H, linkSpacing: N, aromaticDashCount: q, dashCount: U } = $, F = Y * 2, E = L$.create(F, F / 4, X), R = M(), z = M(), D = M(), A = M(), B = M(), T = 0, w = 4.5, V = 3;
  for (let S = 0, f = Y;S < f; ++S) {
    if (G && G(S))
      continue;
    W(R, z, S, !0), o7(B, B, R), o7(B, B, z), T += 2;
    let v = K ? K(S) : j2.Solid;
    if (v === j2.Solid)
      CH(D, o7(D, R, z), 0.5), E.add(R[0], R[1], R[2], D[0], D[1], D[2], S);
    else if (v === j2.Dashed)
      CH(D, o7(D, R, z), 0.5), E.addFixedCountDashes(R, D, U, S);
    else if (v === j2.Double || v === j2.OffsetDouble || v === j2.Triple || v === j2.OffsetTriple || v === j2.Aromatic || v === j2.MirroredAromatic) {
      let h = v === j2.Double || v === j2.OffsetDouble ? 2 : v === j2.Triple || v === j2.OffsetTriple ? 3 : 1.5, b = (1 - 1 * (H / (0.5 * h))) * N;
      if (CH(D, o7(D, R, z), 0.5), x00(A, R, z, Q ? Q(S) : null), v === j2.Aromatic || v === j2.MirroredAromatic) {
        E.add(R[0], R[1], R[2], D[0], D[1], D[2], S);
        let g = b * w;
        if (fY(S9, $$(S9, z, R), g * 0.5), o7(R, R, S9), fY(A, A, g), $$(R, R, A), $$(D, D, A), E.addFixedCountDashes(R, D, q, S), v === j2.MirroredAromatic)
          fY(A, A, g * 2), o7(R, R, A), o7(D, D, A), E.addFixedCountDashes(R, D, q, S);
      } else if (v === j2.OffsetDouble || v === j2.OffsetTriple) {
        if (fY(A, A, b * V), E.add(R[0], R[1], R[2], D[0], D[1], D[2], S), CH(S9, $$(S9, R, D), N * H), $$(R, R, S9), h === 3)
          E.add(R[0] + A[0], R[1] + A[1], R[2] + A[2], D[0] + A[0], D[1] + A[1], D[2] + A[2], S);
        E.add(R[0] - A[0], R[1] - A[1], R[2] - A[2], D[0] - A[0], D[1] - A[1], D[2] - A[2], S);
      } else {
        if (fY(A, A, b * 1.5), h === 3)
          E.add(R[0], R[1], R[2], D[0], D[1], D[2], S);
        E.add(R[0] + A[0], R[1] + A[1], R[2] + A[2], D[0] + A[0], D[1] + A[1], D[2] + A[2], S), E.add(R[0] - A[0], R[1] - A[1], R[2] - A[2], D[0] - A[0], D[1] - A[1], D[2] - A[2], S);
      }
    } else if (v === j2.Disk)
      CH(S9, $$(S9, D, R), 0.475), o7(R, R, S9), $$(D, D, S9), E.add(R[0], R[1], R[2], D[0], D[1], D[2], S);
  }
  let P = E.getLines();
  if (T === 0)
    return { lines: P };
  M.scale(B, B, 1 / T);
  let I = X ? C0.clone(X.boundingSphere) : void 0;
  if (I && M.distance(B, I.center) / I.radius < 0.1)
    return { lines: P, boundingSphere: I };
  else
    return { lines: P };
}

// node_modules/molstar/lib/mol-model-props/computed/representations/shared.js
var Jy = {
  sizeFactor: j.Numeric(0.3, { min: 0, max: 10, step: 0.01 }),
  dashCount: j.Numeric(6, { min: 1, max: 10, step: 1 }),
  dashScale: j.Numeric(0.4, { min: 0, max: 2, step: 0.1 }),
  ignoreHydrogens: j.Boolean(!1),
  ignoreHydrogensVariant: j.Select("all", j.arrayToOptions(["all", "non-polar"])),
  includeParent: j.Boolean(!1),
  parentDisplay: j.Select("stub", j.arrayToOptions(["stub", "full", "between"]), { description: 'Only has an effect when "includeParent" is enabled. "Stub" shows just the child side of interactions to the parent. "Full" shows both sides of interactions to the parent. "Between" shows only interactions to the parent.' })
};

// node_modules/molstar/lib/mol-model-props/computed/representations/interactions-intra-unit-cylinder.js
async function ER1(Z, J, $, X, Y, Q) {
  if (!j0.isAtomic(J))
    return n1.createEmpty(Q);
  let { child: W } = $, K = W === null || W === void 0 ? void 0 : W.unitMap.get(J.id);
  if (W && !K)
    return n1.createEmpty(Q);
  let G = W0.Location.create($, J), H = H7.get($).value, N = H.unitsFeatures.get(J.id), q = H.unitsContacts.get(J.id), { x: U, y: F, z: E, members: R, offsets: z, types: D } = N, { edgeCount: A, a: B, b: T, edgeProps: { flag: w, type: V } } = q, { sizeFactor: P, ignoreHydrogens: I, ignoreHydrogensVariant: S, parentDisplay: f } = Y;
  if (!A)
    return n1.createEmpty(Q);
  let { elements: v, conformation: h } = J, x = M(), b = M(), g = M(), m = {
    linkCount: A * 2,
    position: (Y0, c, n) => {
      let l = V[n];
      if ((!I || S !== "all") && (l === o8.HydrogenBond || l === o8.WeakHydrogenBond && S !== "non-polar")) {
        let u = R[z[B[n]]], G0 = R[z[T[n]]];
        h.invariantPosition(v[u], b), h.invariantPosition(v[G0], g);
        let F0 = M.distance(b, g), t = F0;
        M.copy(Y0, b), M.copy(c, g);
        let Z0 = l === o8.HydrogenBond ? F2.HydrogenDonor : F2.WeakHydrogenDonor;
        if (D[z[B[n]]] === Z0)
          Px(J, u, (a, Q0) => {
            if (pW($, J, v[Q0], "all")) {
              h.invariantPosition(v[Q0], x);
              let $0 = M.distance(x, g);
              if ($0 < F0)
                F0 = $0, M.copy(Y0, x);
            }
          });
        else
          Px(J, G0, (a, Q0) => {
            if (pW($, J, v[Q0], "all")) {
              h.invariantPosition(v[Q0], x);
              let $0 = M.distance(x, b);
              if ($0 < t)
                t = $0, M.copy(c, x);
            }
          });
      } else
        M.set(Y0, U[B[n]], F[B[n]], E[B[n]]), M.set(c, U[T[n]], F[T[n]], E[T[n]]);
    },
    style: (Y0) => j2.Dashed,
    radius: (Y0) => {
      G.element = v[R[z[B[Y0]]]];
      let c = X.size.size(G);
      G.element = v[R[z[T[Y0]]]];
      let n = X.size.size(G);
      return Math.min(c, n) * P;
    },
    ignore: (Y0) => {
      if (w[Y0] === dW.Filtered)
        return !0;
      if (K)
        if (f === "stub") {
          let c = B[Y0];
          for (let n = z[c], l = z[c + 1];n < l; ++n) {
            let u = v[R[z[n]]];
            if (!X1.has(K.elements, u))
              return !0;
          }
        } else if (f === "full" || f === "between") {
          let c = !1, n = !1, l = B[Y0];
          for (let G0 = z[l], F0 = z[l + 1];G0 < F0; ++G0) {
            let t = v[R[z[G0]]];
            if (!X1.has(K.elements, t))
              c = !0;
          }
          let u = T[Y0];
          for (let G0 = z[u], F0 = z[u + 1];G0 < F0; ++G0) {
            let t = v[R[z[G0]]];
            if (!X1.has(K.elements, t))
              n = !0;
          }
          return f === "full" ? c && n : c === n;
        } else
          T8(f);
      return !1;
    }
  }, { mesh: i, boundingSphere: r } = uW(Z, m, Y, Q);
  if (r)
    i.setBoundingSphere(r);
  else if (i.triangleCount > 0) {
    let Y0 = C0.expand(C0(), (K !== null && K !== void 0 ? K : J).boundary.sphere, 1 * P);
    i.setBoundingSphere(Y0);
  }
  return i;
}
var g00 = {
  ...nZ,
  ...hK,
  ...Jy
};
function p_0(Z) {
  return A9({
    defaultProps: j.getDefaultValues(g00),
    createGeometry: ER1,
    createLocationIterator: DR1,
    getLoci: OR1,
    eachLocation: zR1,
    setUpdateState: (J, $, X, Y, Q, W, K) => {
      J.createGeometry = $.sizeFactor !== X.sizeFactor || $.dashCount !== X.dashCount || $.dashScale !== X.dashScale || $.dashCap !== X.dashCap || $.radialSegments !== X.radialSegments || $.ignoreHydrogens !== X.ignoreHydrogens || $.ignoreHydrogensVariant !== X.ignoreHydrogensVariant || $.parentDisplay !== X.parentDisplay;
      let G = H7.get(W.structure).version;
      if (J.info.interactionsHash !== G)
        J.createGeometry = !0, J.updateTransform = !0, J.updateColor = !0, J.info.interactionsHash = G;
    }
  }, Z);
}
function OR1(Z, J, $) {
  let { objectId: X, instanceId: Y, groupId: Q } = Z;
  if ($ === X) {
    let { structure: W, group: K } = J, G = W.unitMap.get(K.units[Y].id), H = H7.get(W).value, { a: N, b: q } = H.unitsContacts.get(G.id);
    return e3.Loci(W, H, [
      { unitA: G, indexA: N[Q], unitB: G, indexB: q[Q] },
      { unitA: G, indexA: q[Q], unitB: G, indexB: N[Q] }
    ]);
  }
  return G8;
}
var y00 = /* @__PURE__ */ new Set;
function zR1(Z, J, $, X) {
  let Y = !1;
  if (e3.isLoci(Z)) {
    let { structure: Q, group: W } = J;
    if (!s0.areEquivalent(Z.data.structure, Q))
      return !1;
    let K = H7.get(Q).value;
    if (Z.data.interactions !== K)
      return !1;
    let G = W.units[0], H = K.unitsContacts.get(G.id), N = H.edgeCount * 2;
    for (let q of Z.elements) {
      if (q.unitA !== q.unitB)
        continue;
      let U = W.unitIndexMap.get(q.unitA.id);
      if (U !== void 0) {
        let F = H.getDirectedEdgeIndex(q.indexA, q.indexB);
        if (F !== -1) {
          if ($(k0.ofSingleton(U * N + F)))
            Y = !0;
        }
      }
    }
  } else if (W0.Loci.is(Z)) {
    let { structure: Q, group: W } = J;
    if (!s0.areEquivalent(Z.structure, Q))
      return !1;
    let K = H7.get(Q).value;
    if (!K)
      return !1;
    let G = W.units[0], H = K.unitsContacts.get(G.id), N = K.unitsFeatures.get(G.id), q = H.edgeCount * 2, { offset: U } = H, { offsets: F, indices: E } = N.elementsIndex, { members: R, offsets: z } = N;
    for (let D of Z.elements) {
      let A = W.unitIndexMap.get(D.unit.id);
      if (A === void 0)
        continue;
      f0.forEach(D.indices, (B) => {
        for (let T = F[B], w = F[B + 1];T < w; ++T) {
          let V = E[T];
          for (let P = U[V], I = U[V + 1];P < I; ++P)
            y00.add(P);
        }
      }), y00.forEach((B) => {
        if (X) {
          let T = H.a[B];
          for (let V = z[T], P = z[T + 1];V < P; ++V)
            if (!f0.has(D.indices, R[V]))
              return;
          let w = H.b[B];
          for (let V = z[w], P = z[w + 1];V < P; ++V)
            if (!f0.has(D.indices, R[V]))
              return;
        }
        if ($(k0.ofSingleton(A * q + B)))
          Y = !0;
      }), y00.clear();
    }
  }
  return Y;
}
function DR1(Z) {
  let { structure: J, group: $ } = Z, X = $.units[0], Y = H7.get(J).value, Q = Y.unitsContacts.get(X.id), W = Q.edgeCount * 2, K = $.units.length, G = e3.Location(Y, J), { element: H } = G;
  return X6(W, K, 1, (q, U) => {
    let F = $.units[U];
    return H.unitA = F, H.indexA = Q.a[q], H.unitB = F, H.indexB = Q.b[q], G;
  });
}

// node_modules/molstar/lib/mol-model-props/computed/representations/interactions-inter-unit-cylinder.js
function MR1(Z, J, $, X, Y) {
  if (!J.hasAtomic)
    return n1.createEmpty(Y);
  let Q = W0.Location.create(J), W = H7.get(J).value, { contacts: K, unitsFeatures: G } = W, { edgeCount: H, edges: N } = K, { sizeFactor: q, ignoreHydrogens: U, ignoreHydrogensVariant: F, parentDisplay: E } = X;
  if (!H)
    return n1.createEmpty(Y);
  let { child: R } = J, z = M(), D = M(), A = M(), B = {
    linkCount: H,
    position: (V, P, I) => {
      let { unitA: S, indexA: f, unitB: v, indexB: h, props: { type: x } } = N[I], b = G.get(S), g = G.get(v), m = J.unitMap.get(S), i = J.unitMap.get(v);
      if ((!U || F !== "all") && (x === o8.HydrogenBond || x === o8.WeakHydrogenBond && F !== "non-polar")) {
        let r = b.members[b.offsets[f]], Y0 = g.members[g.offsets[h]];
        m.conformation.position(m.elements[r], D), i.conformation.position(i.elements[Y0], A);
        let c = M.distance(D, A), n = c;
        M.copy(V, D), M.copy(P, A);
        let l = x === o8.HydrogenBond ? F2.HydrogenDonor : F2.WeakHydrogenDonor;
        if (b.types[b.offsets[f]] === l)
          z$(J, m, r, (G0, F0) => {
            let t = G0.elements[F0];
            if (pW(J, G0, t, "all")) {
              G0.conformation.position(t, z);
              let Z0 = M.distance(z, A);
              if (Z0 < c)
                c = Z0, M.copy(V, z);
            }
          });
        else
          z$(J, i, Y0, (G0, F0) => {
            let t = G0.elements[F0];
            if (pW(J, G0, t, "all")) {
              G0.conformation.position(t, z);
              let Z0 = M.distance(z, D);
              if (Z0 < n)
                n = Z0, M.copy(P, z);
            }
          });
      } else
        M.set(V, b.x[f], b.y[f], b.z[f]), M.transformMat4(V, V, m.conformation.operator.matrix), M.set(P, g.x[h], g.y[h], g.z[h]), M.transformMat4(P, P, i.conformation.operator.matrix);
    },
    style: (V) => j2.Dashed,
    radius: (V) => {
      let P = N[V], I = G.get(P.unitA);
      Q.unit = J.unitMap.get(P.unitA), Q.element = Q.unit.elements[I.members[I.offsets[P.indexA]]];
      let S = $.size.size(Q), f = G.get(P.unitB);
      Q.unit = J.unitMap.get(P.unitB), Q.element = Q.unit.elements[f.members[f.offsets[P.indexB]]];
      let v = $.size.size(Q);
      return Math.min(S, v) * q;
    },
    ignore: (V) => {
      if (N[V].props.flag === dW.Filtered)
        return !0;
      if (R) {
        let P = N[V];
        if (E === "stub") {
          let I = R.unitMap.get(P.unitA);
          if (!I)
            return !0;
          let S = J.unitMap.get(P.unitA), { offsets: f, members: v } = G.get(P.unitA);
          for (let h = f[P.indexA], x = f[P.indexA + 1];h < x; ++h) {
            let b = S.elements[v[h]];
            if (!X1.has(I.elements, b))
              return !0;
          }
        } else if (E === "full" || E === "between") {
          let I = !1, S = !1, f = R.unitMap.get(P.unitA);
          if (!f)
            I = !0;
          else {
            let h = J.unitMap.get(P.unitA), { offsets: x, members: b } = G.get(P.unitA);
            for (let g = x[P.indexA], m = x[P.indexA + 1];g < m; ++g) {
              let i = h.elements[b[g]];
              if (!X1.has(f.elements, i))
                I = !0;
            }
          }
          let v = R.unitMap.get(P.unitB);
          if (!v)
            S = !0;
          else {
            let h = J.unitMap.get(P.unitB), { offsets: x, members: b } = G.get(P.unitB);
            for (let g = x[P.indexB], m = x[P.indexB + 1];g < m; ++g) {
              let i = h.elements[b[g]];
              if (!X1.has(v.elements, i))
                S = !0;
            }
          }
          return E === "full" ? I && S : I === S;
        } else
          T8(E);
      }
      return !1;
    }
  }, { mesh: T, boundingSphere: w } = uW(Z, B, X, Y);
  if (w)
    T.setBoundingSphere(w);
  else if (T.triangleCount > 0) {
    let { child: V } = J, P = C0.expand(C0(), (V !== null && V !== void 0 ? V : J).boundary.sphere, 1 * q);
    T.setBoundingSphere(P);
  }
  return T;
}
var d00 = {
  ...tQ,
  ...hK,
  ...Jy
};
function u_0(Z) {
  return D$({
    defaultProps: j.getDefaultValues(d00),
    createGeometry: MR1,
    createLocationIterator: wR1,
    getLoci: AR1,
    eachLocation: BR1,
    setUpdateState: (J, $, X, Y, Q, W, K) => {
      J.createGeometry = $.sizeFactor !== X.sizeFactor || $.dashCount !== X.dashCount || $.dashScale !== X.dashScale || $.dashCap !== X.dashCap || $.radialSegments !== X.radialSegments || $.ignoreHydrogens !== X.ignoreHydrogens || $.ignoreHydrogensVariant !== X.ignoreHydrogensVariant || $.parentDisplay !== X.parentDisplay;
      let G = H7.get(W).version;
      if (J.info.interactionsHash !== G)
        J.createGeometry = !0, J.updateTransform = !0, J.updateColor = !0, J.info.interactionsHash = G;
    }
  }, Z);
}
function AR1(Z, J, $) {
  let { objectId: X, groupId: Y } = Z;
  if ($ === X) {
    let Q = H7.get(J).value, W = Q.contacts.edges[Y], K = J.unitMap.get(W.unitA), G = J.unitMap.get(W.unitB);
    return e3.Loci(J, Q, [
      { unitA: K, indexA: W.indexA, unitB: G, indexB: W.indexB },
      { unitA: G, indexA: W.indexB, unitB: K, indexB: W.indexA }
    ]);
  }
  return G8;
}
var $y = /* @__PURE__ */ new Map, m00 = /* @__PURE__ */ new Set;
function BR1(Z, J, $, X) {
  let Y = !1;
  if (e3.isLoci(Z)) {
    if (!s0.areEquivalent(Z.data.structure, J))
      return !1;
    let Q = H7.get(J).value;
    if (Z.data.interactions !== Q)
      return !1;
    let { contacts: W } = Q;
    for (let K of Z.elements) {
      let G = W.getEdgeIndex(K.indexA, K.unitA.id, K.indexB, K.unitB.id);
      if (G !== -1) {
        if ($(k0.ofSingleton(G)))
          Y = !0;
      }
    }
  } else if (W0.Loci.is(Z)) {
    if (!s0.areEquivalent(Z.structure, J))
      return !1;
    if (X && Z.elements.length === 1)
      return !1;
    let Q = H7.get(J).value;
    if (!Q)
      return !1;
    let { contacts: W, unitsFeatures: K } = Q;
    for (let G of Z.elements)
      $y.set(G.unit.id, G.indices);
    for (let G of Z.elements) {
      let { unit: H } = G;
      if (!j0.isAtomic(H))
        continue;
      f0.forEach(G.indices, (N) => {
        for (let q of W.getContactIndicesForElement(N, H))
          m00.add(q);
      });
    }
    m00.forEach((G) => {
      if (X) {
        let { indexA: H, unitA: N, indexB: q, unitB: U } = W.edges[G], F = $y.get(N), E = $y.get(U);
        if (!F || !E)
          return;
        let { offsets: R, members: z } = K.get(N);
        for (let B = R[H], T = R[H + 1];B < T; ++B)
          if (!f0.has(F, z[B]))
            return;
        let { offsets: D, members: A } = K.get(U);
        for (let B = D[q], T = D[q + 1];B < T; ++B)
          if (!f0.has(E, A[B]))
            return;
      }
      if ($(k0.ofSingleton(G)))
        Y = !0;
    }), $y.clear(), m00.clear();
  }
  return Y;
}
function wR1(Z) {
  let J = H7.get(Z).value, { contacts: $ } = J, X = $.edgeCount, Y = 1, Q = e3.Location(J, Z), { element: W } = Q;
  return X6(X, 1, 1, (G) => {
    let H = $.edges[G];
    return W.unitA = Z.unitMap.get(H.unitA), W.indexA = H.indexA, W.unitB = Z.unitMap.get(H.unitB), W.indexB = H.indexB, Q;
  }, !0);
}

// node_modules/molstar/lib/mol-model-props/computed/representations/interactions.js
var c_0 = {
  "intra-unit": (Z, J) => _Z("Intra-unit interactions cylinder", Z, J, p_0),
  "inter-unit": (Z, J) => M9("Inter-unit interactions cylinder", Z, J, u_0)
}, l_0 = {
  ...g00,
  ...d00,
  unitKinds: zU(["atomic"]),
  sizeFactor: j.Numeric(0.2, { min: 0.01, max: 1, step: 0.01 }),
  visuals: j.MultiSelect(["intra-unit", "inter-unit"], j.objectToOptions(c_0))
};
function jR1(Z, J) {
  return j.clone(l_0);
}
function TR1(Z, J) {
  return V2.createMulti("Interactions", Z, J, lZ, c_0);
}
var EB = v9({
  name: "interactions",
  label: "Non-covalent Interactions",
  description: "Displays non-covalent interactions as dashed cylinders.",
  factory: TR1,
  getParams: jR1,
  defaultValues: j.getDefaultValues(l_0),
  defaultColorTheme: { name: "interaction-type" },
  defaultSizeTheme: { name: "uniform" },
  isApplicable: (Z) => Z.elementCount > 0 && H7.isApplicable(Z),
  ensureCustomProperties: {
    attach: (Z, J) => H7.attach(Z, J, void 0, !0),
    detach: (Z) => H7.ref(Z, !1)
  },
  getData: (Z, J) => {
    return J.includeParent ? Z.asParent() : Z;
  },
  mustRecreate: (Z, J) => {
    return Z.includeParent !== J.includeParent;
  }
});

// node_modules/molstar/lib/mol-plugin/behavior/dynamic/custom-props/computed/interactions.js
var n_0 = i8.create({
  name: "computed-interactions-prop",
  category: "custom-props",
  display: { name: "Interactions" },
  ctor: class extends i8.Handler {
    constructor() {
      super(...arguments);
      this.provider = H7, this.labelProvider = {
        label: (Z) => {
          if (!this.params.showTooltip)
            return;
          switch (Z.kind) {
            case "element-loci":
              if (Z.elements.length === 0)
                return;
              let J = [], $ = this.getStructures(Z.structure);
              for (let X of $) {
                let Y = this.provider.get(X).value;
                if (!Y)
                  continue;
                let Q = W0.Loci.remap(Z, X);
                if (Q.elements.length !== 1)
                  continue;
                let W = Q.elements[0];
                if (f0.size(W.indices) !== 1)
                  continue;
                let K = Y.unitsFeatures.get(W.unit.id);
                if (!K)
                  continue;
                let G = [], H = [], N = [], q = f0.start(W.indices), { types: U, groups: F, elementsIndex: { indices: E, offsets: R } } = K;
                for (let z = R[q], D = R[q + 1];z < D; ++z) {
                  let A = E[z], B = U[A], T = F[A];
                  if (B)
                    G.push(DT0(B));
                  if (T)
                    H.push(MT0(T));
                }
                if (G.length)
                  N.push(`<small>Types</small> ${G.join(", ")}`);
                if (H.length)
                  N.push(`<small>Groups</small> ${H.join(", ")}`);
                if (N.length)
                  J.push(`Interaction Feature: ${N.join(" | ")}`);
              }
              return J.length ? J.join("<br/>") : void 0;
            default:
              return;
          }
        }
      };
    }
    getStructures(Z) {
      let J = [], $ = this.ctx.helpers.substructureParent.get(Z);
      if ($) {
        let Y = this.ctx.state.data.select(f2.Generators.ofType(D0.Molecule.Structure, $.transform.ref));
        for (let Q of Y)
          if (Q.obj)
            n9(J, Q.obj.data);
      }
      return J;
    }
    update(Z) {
      let J = this.params.autoAttach !== Z.autoAttach || this.params.showTooltip !== Z.showTooltip;
      return this.params.autoAttach = Z.autoAttach, this.params.showTooltip = Z.showTooltip, this.ctx.customStructureProperties.setDefaultAutoAttach(this.provider.descriptor.name, this.params.autoAttach), J;
    }
    register() {
      this.ctx.customStructureProperties.register(this.provider, this.params.autoAttach), this.ctx.representation.structure.themes.colorThemeRegistry.add(LI), this.ctx.managers.lociLabels.addProvider(this.labelProvider), this.ctx.representation.structure.registry.add(EB);
    }
    unregister() {
      this.ctx.customStructureProperties.unregister(this.provider.descriptor.name), this.ctx.representation.structure.themes.colorThemeRegistry.remove(LI), this.ctx.managers.lociLabels.removeProvider(this.labelProvider), this.ctx.representation.structure.registry.remove(EB);
    }
  },
  params: () => ({
    autoAttach: j.Boolean(!1),
    showTooltip: j.Boolean(!0)
  })
});
// node_modules/molstar/lib/mol-plugin/behavior/dynamic/custom-props/computed/secondary-structure.js
var i_0 = i8.create({
  name: "computed-secondary-structure-prop",
  category: "custom-props",
  display: { name: "Secondary Structure" },
  ctor: class extends i8.Handler {
    constructor() {
      super(...arguments);
      this.provider = $X;
    }
    update(Z) {
      let J = this.params.autoAttach !== Z.autoAttach;
      return this.params.autoAttach = Z.autoAttach, this.ctx.customStructureProperties.setDefaultAutoAttach(this.provider.descriptor.name, this.params.autoAttach), J;
    }
    register() {
      this.ctx.customStructureProperties.register(this.provider, this.params.autoAttach);
    }
    unregister() {
      this.ctx.customStructureProperties.unregister(this.provider.descriptor.name);
    }
  },
  params: () => ({
    autoAttach: j.Boolean(!1)
  })
});
// node_modules/molstar/lib/mol-plugin/behavior/dynamic/custom-props/computed/valence-model.js
var o_0 = i8.create({
  name: "computed-valence-model-prop",
  category: "custom-props",
  display: { name: "Valence Model" },
  ctor: class extends i8.Handler {
    constructor() {
      super(...arguments);
      this.provider = wq, this.labelProvider = {
        label: (Z) => {
          if (!this.params.showTooltip)
            return;
          switch (Z.kind) {
            case "element-loci":
              if (Z.elements.length === 0)
                return;
              let J = [], $ = this.getStructures(Z.structure);
              for (let X of $) {
                let Y = this.provider.get(X).value;
                if (!Y)
                  continue;
                let Q = W0.Loci.remap(Z, X);
                if (Q.elements.length !== 1)
                  continue;
                let W = Q.elements[0];
                if (f0.size(W.indices) !== 1)
                  continue;
                let K = Y.get(W.unit.id);
                if (!K)
                  continue;
                let G = f0.start(W.indices), H = K.charge[G], N = K.idealGeometry[G], q = K.implicitH[G], U = K.totalH[G];
                J.push(`Valence Model: <small>Charge</small> ${H} | <small>Ideal Geometry</small> ${RT0(N)} | <small>Implicit H</small> ${q} | <small>Total H</small> ${U}`);
              }
              return J.length ? J.join("<br/>") : void 0;
            default:
              return;
          }
        }
      };
    }
    getStructures(Z) {
      let J = [], $ = this.ctx.helpers.substructureParent.get(Z);
      if ($) {
        let Y = this.ctx.state.data.select(f2.Generators.ofType(D0.Molecule.Structure, $.transform.ref));
        for (let Q of Y)
          if (Q.obj)
            n9(J, Q.obj.data);
      }
      return J;
    }
    update(Z) {
      let J = this.params.autoAttach !== Z.autoAttach || this.params.showTooltip !== Z.showTooltip;
      return this.params.autoAttach = Z.autoAttach, this.params.showTooltip = Z.showTooltip, this.ctx.customStructureProperties.setDefaultAutoAttach(this.provider.descriptor.name, this.params.autoAttach), J;
    }
    register() {
      this.ctx.customStructureProperties.register(this.provider, this.params.autoAttach), this.ctx.managers.lociLabels.addProvider(this.labelProvider);
    }
    unregister() {
      this.ctx.customStructureProperties.unregister(this.provider.descriptor.name), this.ctx.managers.lociLabels.removeProvider(this.labelProvider);
    }
  },
  params: () => ({
    autoAttach: j.Boolean(!1),
    showTooltip: j.Boolean(!0)
  })
});
// node_modules/molstar/lib/mol-model-props/sequence/themes/sifts-mapping.js
var p00 = i0(16448250), _R1 = "Assigns a color based on SIFTS mapping.", zI = /* @__PURE__ */ new Map, s_0 = {
  ...p9({ type: "colors", colorList: "set-1" })
};
function VR1(Z) {
  return s_0;
}
function a_0(Z, J) {
  let $;
  if (Z.structure) {
    for (let K of Z.structure.models) {
      let G = pQ.Provider.get(K).value;
      if (!G)
        continue;
      for (let H of G.accession) {
        if (!H || zI.has(H))
          continue;
        zI.set(H, zI.size);
      }
    }
    let X = W0.Location.create(Z.structure), Y = a9(zI.size + 1, J, { valueLabel: (K) => `${K}` }), Q = /* @__PURE__ */ new Map, W = (K) => {
      let G = pQ.getKey(K);
      if (!G)
        return p00;
      if (Q.has(G))
        return Q.get(G);
      let H = Y.color(zI.get(G));
      return Q.set(G, H), H;
    };
    $ = (K) => {
      if (W0.Location.is(K) && j0.isAtomic(K.unit))
        return W(K);
      else if ($2.isLocation(K))
        return X.unit = K.aUnit, X.element = K.aUnit.elements[K.aIndex], W(X);
      return p00;
    };
  } else
    $ = () => p00;
  return {
    factory: a_0,
    granularity: "group",
    preferSmoothing: !0,
    color: $,
    props: J,
    description: _R1
  };
}
var u00 = {
  name: "sifts-mapping",
  label: "SIFTS Mapping",
  category: $8.Residue,
  factory: a_0,
  getParams: VR1,
  defaultValues: j.getDefaultValues(s_0),
  isApplicable: (Z) => {
    var J;
    return !!((J = Z.structure) === null || J === void 0 ? void 0 : J.models.some(($) => pQ.Provider.isApplicable($)));
  },
  ensureCustomProperties: {
    attach: async (Z, J) => {
      if (!J.structure)
        return;
      for (let $ of J.structure.models)
        await pQ.Provider.attach(Z, $, void 0, !0);
    },
    detach: (Z) => {
      if (!Z.structure)
        return;
      for (let J of Z.structure.models)
        pQ.Provider.ref(J, !1);
    }
  }
};

// node_modules/molstar/lib/mol-plugin/behavior/dynamic/custom-props/sequence/sifts-mapping.js
var r_0 = i8.create({
  name: "sifts-mapping-prop",
  category: "custom-props",
  display: { name: "SIFTS Mapping" },
  ctor: class extends i8.Handler {
    constructor() {
      super(...arguments);
      this.provider = pQ.Provider, this.labelProvider = {
        label: (Z) => {
          if (!this.params.showTooltip)
            return;
          return IR1(Z);
        }
      };
    }
    update(Z) {
      let J = this.params.autoAttach !== Z.autoAttach || this.params.showTooltip !== Z.showTooltip;
      return this.params.autoAttach = Z.autoAttach, this.params.showTooltip = Z.showTooltip, this.ctx.customStructureProperties.setDefaultAutoAttach(this.provider.descriptor.name, this.params.autoAttach), J;
    }
    register() {
      this.ctx.customModelProperties.register(this.provider, this.params.autoAttach), this.ctx.representation.structure.themes.colorThemeRegistry.add(u00), this.ctx.managers.lociLabels.addProvider(this.labelProvider);
    }
    unregister() {
      this.ctx.customModelProperties.unregister(this.provider.descriptor.name), this.ctx.representation.structure.themes.colorThemeRegistry.remove(u00), this.ctx.managers.lociLabels.removeProvider(this.labelProvider);
    }
  },
  params: () => ({
    autoAttach: j.Boolean(!0),
    showTooltip: j.Boolean(!0)
  })
});
function IR1(Z) {
  if (Z.kind === "element-loci") {
    if (Z.elements.length === 0)
      return;
    let J = Z.elements[0], $ = J.unit, X = W0.Location.create(Z.structure, $, $.elements[f0.getAt(J.indices, 0)]);
    return pQ.getLabel(X);
  }
}
// node_modules/molstar/lib/mol-model-props/integrative/cross-link-restraint/format.js
var kH;
(function(Z) {
  Z.Descriptor = {
    name: "ihm_cross_link_restraint"
  }, Z.Provider = e$.create(Z.Descriptor);
  function J($, X) {
    let Y = {
      entity_id: $.entity_id_1,
      asym_id: $.asym_id_1,
      seq_id: $.seq_id_1,
      atom_id: $.atom_id_1
    }, Q = {
      entity_id: $.entity_id_2,
      asym_id: $.asym_id_2,
      seq_id: $.seq_id_2,
      atom_id: $.atom_id_2
    };
    function W(F, E, R) {
      let z = F.get(E);
      if (z)
        z.push(R);
      else
        F.set(E, [R]);
    }
    function K(F, E) {
      let R = E.entity_id.value(F), z = E.asym_id.value(F), D = E.seq_id.value(F);
      if ($.model_granularity.value(F) === "by-atom") {
        let A = X.atomicHierarchy.index.findAtom({
          auth_seq_id: D,
          label_asym_id: z,
          label_atom_id: E.atom_id.value(F),
          label_entity_id: R
        });
        if (A >= 0)
          W(H, A, F);
      } else if (X.coarseHierarchy.isDefined) {
        let A = X.coarseHierarchy.spheres.findSequenceKey(R, z, D);
        if (A >= 0)
          W(N, A, F);
        else {
          let B = X.coarseHierarchy.gaussians.findSequenceKey(R, z, D);
          if (B >= 0)
            W(q, B, F);
        }
      }
    }
    function G(F) {
      switch (F) {
        case j0.Kind.Atomic:
          return H;
        case j0.Kind.Spheres:
          return N;
        case j0.Kind.Gaussians:
          return q;
      }
    }
    let H = /* @__PURE__ */ new Map, N = /* @__PURE__ */ new Map, q = /* @__PURE__ */ new Map, U = [];
    for (let F = 0;F < $._rowCount; ++F)
      K(F, Y), K(F, Q);
    return {
      getIndicesByElement: (F, E) => {
        let z = G(E).get(F);
        return z !== void 0 ? z : U;
      },
      data: $
    };
  }
  Z.fromTable = J;
})(kH || (kH = {}));

// node_modules/molstar/lib/mol-model-props/integrative/pair-restraints.js
var PR1 = [];
function t_0(Z, J, $, X) {
  return `${Z}|${J.id}|${$}|${X.id}`;
}

class Xy {
  getPairIndices(Z, J, $, X) {
    let Y = t_0(Z, J, $, X);
    return this.pairKeyIndices.get(Y) || PR1;
  }
  getPairs(Z, J, $, X) {
    return this.getPairIndices(Z, J, $, X).map((Q) => this.pairs[Q]);
  }
  constructor(Z) {
    this.pairs = Z;
    let J = /* @__PURE__ */ new Map;
    this.pairs.forEach(($, X) => {
      let Y = t_0($.indexA, $.unitA, $.indexB, $.unitB), Q = J.get(Y);
      if (Q)
        Q.push(X);
      else
        J.set(Y, [X]);
    }), this.count = Z.length, this.pairKeyIndices = J;
  }
}

// node_modules/molstar/lib/mol-model-props/integrative/cross-link-restraint/property.js
var vH = IW.createProvider({
  label: "Cross Link Restraint",
  descriptor: p7({
    name: "integrative-cross-link-restraint"
  }),
  type: "local",
  defaultParams: {},
  getParams: (Z) => ({}),
  isApplicable: (Z) => Z.models.some((J) => !!kH.Provider.get(J)),
  obtain: async (Z, J, $) => {
    return { value: vR1(J) };
  }
});
var bK;
(function(Z) {
  let J;
  (function(R) {
    R.CrossLinkRestraint = "cross-link-restraint";
  })(J = Z.Tag || (Z.Tag = {}));
  function $(R) {
    return R.models.some((z) => !!kH.Provider.get(z));
  }
  Z.isApplicable = $;
  let X = M(), Y = M();
  function Q(R) {
    return R.unitA.conformation.position(R.unitA.elements[R.indexA], X), R.unitB.conformation.position(R.unitB.elements[R.indexB], Y), M.distance(X, Y);
  }
  Z.distance = Q;
  function W(R, z, D) {
    return zh("cross-link-restraints", { structure: z, crossLinkRestraints: R }, D);
  }
  Z.Location = W;
  function K(R) {
    return !!R && R.kind === "data-location" && R.tag === "cross-link-restraints";
  }
  Z.isLocation = K;
  function G(R, z) {
    return R.data.structure === z.data.structure && R.data.crossLinkRestraints === z.data.crossLinkRestraints && R.element === z.element;
  }
  Z.areLocationsEqual = G;
  function H(R, z) {
    let D = R.pairs[z];
    return `Cross Link Restraint | Type: ${D.restraintType} | Threshold: ${D.distanceThreshold} Å | Psi: ${D.psi} | Sigma 1: ${D.sigma1} | Sigma 2: ${D.sigma2} | Distance: ${Q(D).toFixed(2)} Å`;
  }
  function N(R) {
    return H(R.data.crossLinkRestraints, R.element);
  }
  Z.locationLabel = N;
  function q(R, z, D) {
    return PR("cross-link-restraints", { structure: R, crossLinkRestraints: z }, D, (A) => F(z, D, A), () => E(R, z, D));
  }
  Z.Loci = q;
  function U(R) {
    return !!R && R.kind === "data-loci" && R.tag === "interactions";
  }
  Z.isLoci = U;
  function F(R, z, D) {
    return yQ.fromPairProvider(z.length, (A, B, T) => {
      let w = R.pairs[z[A]];
      w.unitA.conformation.position(w.unitA.elements[w.indexA], B), w.unitB.conformation.position(w.unitB.elements[w.indexB], T);
    }, D);
  }
  Z.getBoundingSphere = F;
  function E(R, z, D) {
    let A = D[0];
    if (A === void 0)
      return "";
    let B = z.pairs[A];
    return [
      H(z, A),
      gV($2.Location(R, B.unitA, B.indexA, R, B.unitB, B.indexB))
    ].join("</br>");
  }
  Z.getLabel = E;
})(bK || (bK = {}));
function e_0(Z, J, $) {
  let { elements: X } = J, Y = X.length, Q = J.kind;
  for (let W = 0;W < Y; W++) {
    let K = X[W];
    $.getIndicesByElement(K, Q).forEach((G) => Z.set(G, W));
  }
}
function CR1(Z, J, $) {
  if (J.model !== $.model)
    return;
  if (J.model.sourceData.kind !== "mmCIF")
    return;
  let X = kH.Provider.get(J.model);
  if (!X)
    return;
  let Y = /* @__PURE__ */ new Map, Q = /* @__PURE__ */ new Map;
  e_0(Y, J, X), e_0(Q, $, X), Y.forEach((W, K) => {
    let G = Q.get(K);
    if (G !== void 0)
      Z.push(Yy(J, W, $, G, X, K), Yy($, G, J, W, X, K));
  });
}
function kR1(Z, J) {
  if (J.model.sourceData.kind !== "mmCIF")
    return;
  let $ = kH.Provider.get(J.model);
  if (!$)
    return;
  let { elements: X } = J, Y = X.length, Q = J.kind, W = /* @__PURE__ */ new Map;
  for (let K = 0;K < Y; K++) {
    let G = X[K];
    $.getIndicesByElement(G, Q).forEach((H) => {
      let N = W.get(H);
      if (N)
        N.push(K);
      else
        W.set(H, [K]);
    });
  }
  W.forEach((K, G) => {
    if (K.length < 2)
      return;
    let [H, N] = K;
    Z.push(Yy(J, H, J, N, $, G), Yy(J, N, J, H, $, G));
  });
}
function Yy(Z, J, $, X, Y, Q) {
  return {
    unitA: Z,
    indexA: J,
    unitB: $,
    indexB: X,
    restraintType: Y.data.restraint_type.value(Q),
    distanceThreshold: Y.data.distance_threshold.value(Q),
    psi: Y.data.psi.value(Q),
    sigma1: Y.data.sigma_1.value(Q),
    sigma2: Y.data.sigma_2.value(Q)
  };
}
function vR1(Z) {
  let J = [];
  if (!Z.models.some((X) => kH.Provider.get(X)))
    return new Xy(J);
  let $ = Z.units.length;
  for (let X = 0;X < $; ++X) {
    let Y = Z.units[X];
    kR1(J, Y);
    for (let Q = X + 1;Q < $; ++Q) {
      let W = Z.units[Q];
      if (Y.model === W.model)
        CR1(J, Y, W);
    }
  }
  return new Xy(J);
}

// node_modules/molstar/lib/mol-model-props/integrative/cross-link-restraint/representation.js
function SR1(Z, J, $, X, Y) {
  let Q = vH.get(J).value;
  if (!Q.count)
    return n1.createEmpty(Y);
  let { sizeFactor: W } = X, K = W0.Location.create(J), G = {
    linkCount: Q.count,
    position: (q, U, F) => {
      let E = Q.pairs[F], R = E.unitA, z = E.unitB;
      R.conformation.position(R.elements[E.indexA], q), z.conformation.position(z.elements[E.indexB], U);
    },
    radius: (q) => {
      let U = Q.pairs[q];
      return K.unit = U.unitA, K.element = U.unitA.elements[U.indexA], $.size.size(K) * W;
    }
  }, { mesh: H, boundingSphere: N } = uW(Z, G, X, Y);
  if (N)
    H.setBoundingSphere(N);
  else if (H.triangleCount > 0) {
    let q = C0.expand(C0(), J.boundary.sphere, 1 * W);
    H.setBoundingSphere(q);
  }
  return H;
}
var ZV0 = {
  ...tQ,
  ...hK,
  sizeFactor: j.Numeric(0.5, { min: 0, max: 10, step: 0.1 })
};
function fR1(Z) {
  return D$({
    defaultProps: j.getDefaultValues(ZV0),
    createGeometry: SR1,
    createLocationIterator: hR1,
    getLoci: bR1,
    eachLocation: xR1,
    setUpdateState: (J, $, X) => {
      J.createGeometry = $.sizeFactor !== X.sizeFactor || $.radialSegments !== X.radialSegments || $.linkCap !== X.linkCap;
    }
  }, Z);
}
function hR1(Z) {
  let J = vH.get(Z).value, { pairs: $ } = J, X = $.length, Y = 1, Q = bK.Location(J, Z);
  return X6(X, 1, 1, (K) => {
    return Q.element = K, Q;
  }, !0);
}
function bR1(Z, J, $) {
  let { objectId: X, groupId: Y } = Z;
  if ($ === X) {
    let Q = vH.get(J).value;
    if (Q.pairs[Y])
      return bK.Loci(J, Q, [Y]);
  }
  return G8;
}
function xR1(Z, J, $) {
  let X = !1;
  if (bK.isLoci(Z)) {
    if (!s0.areEquivalent(Z.data.structure, J))
      return !1;
    let Y = vH.get(J).value;
    if (Z.data.crossLinkRestraints !== Y)
      return !1;
    for (let Q of Z.elements)
      if ($(k0.ofSingleton(Q)))
        X = !0;
  }
  return X;
}
var yR1 = {
  "cross-link-restraint": (Z, J) => M9("Cross-link restraint", Z, J, fR1)
}, JV0 = {
  ...ZV0
};
function gR1(Z, J) {
  return j.clone(JV0);
}
function mR1(Z, J) {
  return V2.createMulti("CrossLinkRestraint", Z, J, lZ, yR1);
}
var c00 = v9({
  name: bK.Tag.CrossLinkRestraint,
  label: "Cross Link Restraint",
  description: "Displays cross-link restraints.",
  factory: mR1,
  getParams: gR1,
  defaultValues: j.getDefaultValues(JV0),
  defaultColorTheme: { name: bK.Tag.CrossLinkRestraint },
  defaultSizeTheme: { name: "uniform" },
  isApplicable: (Z) => bK.isApplicable(Z),
  ensureCustomProperties: {
    attach: (Z, J) => vH.attach(Z, J, void 0, !0),
    detach: (Z) => vH.ref(Z, !1)
  }
});

// node_modules/molstar/lib/mol-model-props/integrative/cross-link-restraint/color.js
var $V0 = i0(13421772), dR1 = "Colors cross-links by the deviation of the observed distance versus the modeled distance (e.g. modeled / `ihm_cross_link_restraint.distance_threshold`).", XV0 = {
  domain: j.Interval([0.5, 1.5], { step: 0.01 }),
  list: j.ColorList("red-grey", { presetKind: "scale" })
};
function pR1(Z) {
  return XV0;
}
function YV0(Z, J) {
  let $, X = void 0, Y = Z.structure && vH.get(Z.structure).value;
  if (Y) {
    X = _J.create({
      domain: J.domain,
      listOrName: J.list.colors
    });
    let Q = X.color;
    $ = (W) => {
      if (bK.isLocation(W)) {
        let K = Y.pairs[W.element];
        if (K)
          return Q(bK.distance(K) / K.distanceThreshold);
      }
      return $V0;
    };
  } else
    $ = () => $V0;
  return {
    factory: YV0,
    granularity: "group",
    color: $,
    props: J,
    description: dR1,
    legend: X ? X.legend : void 0
  };
}
var l00 = {
  name: "cross-link",
  label: "Cross Link",
  category: $8.Misc,
  factory: YV0,
  getParams: pR1,
  defaultValues: j.getDefaultValues(XV0),
  isApplicable: (Z) => !!Z.structure && bK.isApplicable(Z.structure),
  ensureCustomProperties: {
    attach: (Z, J) => J.structure ? vH.attach(Z, J.structure, void 0, !0) : Promise.resolve(),
    detach: (Z) => Z.structure && vH.ref(Z.structure, !1)
  }
};

// node_modules/molstar/lib/mol-plugin/behavior/dynamic/custom-props/integrative/cross-link-restraint.js
var QV0 = i8.create({
  name: "integrative-cross-link-restraint",
  category: "custom-props",
  display: { name: "Cross Link Restraint" },
  ctor: class extends i8.Handler {
    constructor() {
      super(...arguments);
      this.provider = kH.Provider;
    }
    register() {
      this.provider.formatRegistry.add("mmCIF", uR1), this.ctx.representation.structure.themes.colorThemeRegistry.add(l00), this.ctx.representation.structure.registry.add(c00);
    }
    unregister() {
      this.provider.formatRegistry.remove("mmCIF"), this.ctx.representation.structure.themes.colorThemeRegistry.remove(l00), this.ctx.representation.structure.registry.remove(c00);
    }
  }
});
function uR1(Z) {
  if (!S6.is(Z.sourceData))
    return;
  let { ihm_cross_link_restraint: J } = Z.sourceData.data.db;
  if (J._rowCount === 0)
    return;
  return kH.fromTable(J, Z);
}
// node_modules/molstar/lib/mol-plugin/behavior.js
var DI = {
  State: ae,
  Representation: te,
  Camera: ee,
  Misc: Z00
}, eQ = {
  Representation: $00,
  Camera: Q00,
  State: W00,
  CustomProps: n00
};

// node_modules/molstar/lib/mol-plugin/state.js
class uX extends Oq {
  get animation() {
    return this.plugin.managers.animation;
  }
  getSnapshot(Z) {
    var J, $, X;
    let Y = { ...this.snapshotParams.value, ...Z };
    return {
      id: R6.create22(),
      data: Y.data ? this.data.getSnapshot() : void 0,
      behaviour: Y.behavior ? this.behaviors.getSnapshot() : void 0,
      animation: Y.animation ? this.animation.getSnapshot() : void 0,
      startAnimation: Y.startAnimation ? !!Y.startAnimation : void 0,
      camera: Y.camera ? {
        current: this.plugin.canvas3d.camera.getSnapshot(),
        transitionStyle: Y.cameraTransition.name,
        transitionDurationInMs: ((J = Y === null || Y === void 0 ? void 0 : Y.cameraTransition) === null || J === void 0 ? void 0 : J.name) === "animate" ? Y.cameraTransition.params.durationInMs : void 0
      } : void 0,
      canvas3dContext: Y.canvas3dContext ? { props: ($ = this.plugin.canvas3dContext) === null || $ === void 0 ? void 0 : $.props } : void 0,
      canvas3d: Y.canvas3d ? { props: (X = this.plugin.canvas3d) === null || X === void 0 ? void 0 : X.props } : void 0,
      interactivity: Y.interactivity ? { props: this.plugin.managers.interactivity.props } : void 0,
      structureFocus: this.plugin.managers.structure.focus.getSnapshot(),
      structureSelection: Y.structureSelection ? this.plugin.managers.structure.selection.getSnapshot() : void 0,
      structureComponentManager: Y.componentManager ? {
        options: this.plugin.managers.structure.component.state.options
      } : void 0,
      durationInMs: Y === null || Y === void 0 ? void 0 : Y.durationInMs
    };
  }
  async setSnapshot(Z) {
    var J, $, X, Y, Q, W, K, G, H, N;
    if (await this.animation.stop(), (J = Z.structureComponentManager) === null || J === void 0 ? void 0 : J.options)
      this.plugin.managers.structure.component._setSnapshotState(($ = Z.structureComponentManager) === null || $ === void 0 ? void 0 : $.options);
    if (Z.behaviour)
      await this.plugin.runTask(this.behaviors.setSnapshot(Z.behaviour));
    if (Z.data)
      await this.plugin.runTask(this.data.setSnapshot(Z.data));
    if ((X = Z.canvas3d) === null || X === void 0 ? void 0 : X.props) {
      let q = j.normalizeParams(J$, Z.canvas3d.props, "children");
      if (((Y = Z.camera) === null || Y === void 0 ? void 0 : Y.current) || ((Q = Z.camera) === null || Q === void 0 ? void 0 : Q.focus))
        q.camera = void 0, q.cameraClipping = void 0, q.cameraFog = void 0;
      await h1.Canvas3D.SetSettings(this.plugin, { settings: q });
    }
    if ((W = Z.canvas3dContext) === null || W === void 0 ? void 0 : W.props) {
      let q = j.normalizeParams(a3.Params, Z.canvas3dContext.props, "children");
      (K = this.plugin.canvas3dContext) === null || K === void 0 || K.setProps(q);
    }
    if (Z.interactivity) {
      if (Z.interactivity.props)
        this.plugin.managers.interactivity.setProps(Z.interactivity.props);
    }
    if (Z.structureFocus)
      this.plugin.managers.structure.focus.setSnapshot(Z.structureFocus);
    if (Z.structureSelection)
      this.plugin.managers.structure.selection.setSnapshot(Z.structureSelection);
    if (Z.animation)
      this.animation.setSnapshot(Z.animation);
    if ((G = Z.camera) === null || G === void 0 ? void 0 : G.current)
      h1.Camera.Reset(this.plugin, {
        snapshot: Z.camera.current,
        durationMs: Z.camera.transitionStyle === "animate" ? Z.camera.transitionDurationInMs : void 0
      });
    else if ((H = Z.camera) === null || H === void 0 ? void 0 : H.focus)
      h1.Camera.FocusObject(this.plugin, {
        ...Z.camera.focus,
        durationMs: Z.camera.transitionStyle === "animate" ? Z.camera.transitionDurationInMs : void 0
      });
    if (typeof (Z === null || Z === void 0 ? void 0 : Z.onLoadMarkdownCommands) === "object" && Object.keys(Z.onLoadMarkdownCommands).length > 0)
      this.plugin.managers.markdownExtensions.tryExecute("click", Z.onLoadMarkdownCommands);
    if (Z.startAnimation) {
      this.animation.start();
      return;
    }
    if ((N = Z.transition) === null || N === void 0 ? void 0 : N.autoplay)
      await rG.immediatePromise(), this.animation.play(qE, {});
  }
  async setAnimationSnapshot(Z, J) {
    var $, X, Y, Q;
    await this.animation.stopStateTransitionAnimation();
    let { transition: W } = Z;
    if (!W)
      return;
    let K = Math.min(J, W.frames.length - 1), G = ($ = W.frames[K]) !== null && $ !== void 0 ? $ : Z.data;
    if (G.data)
      await this.plugin.runTask(this.data.setSnapshot(G.data));
    if ((X = G.canvas3d) === null || X === void 0 ? void 0 : X.props) {
      let H = j.normalizeParams(J$, G.canvas3d.props, "children");
      (Y = this.plugin.canvas3d) === null || Y === void 0 || Y.setProps(H);
    }
    if ((Q = G.camera) === null || Q === void 0 ? void 0 : Q.current)
      h1.Camera.Reset(this.plugin, {
        snapshot: G.camera.current,
        durationMs: G.camera.transitionStyle === "animate" ? G.camera.transitionDurationInMs : void 0
      });
    if (!J && typeof (Z === null || Z === void 0 ? void 0 : Z.onLoadMarkdownCommands) === "object" && Object.keys(Z.onLoadMarkdownCommands).length > 0)
      this.plugin.managers.markdownExtensions.tryExecute("click", Z.onLoadMarkdownCommands);
  }
  updateTransform(Z, J, $, X) {
    let Y = Z.build().to(J).update($);
    return h1.State.Update(this.plugin, { state: Z, tree: Y, options: { canUndo: X } });
  }
  hasBehavior(Z) {
    return this.behaviors.tree.transforms.has(Z.id);
  }
  updateBehavior(Z, J) {
    let $ = this.behaviors.build();
    if (!this.behaviors.tree.transforms.has(Z.id)) {
      let X = Z.createDefaultParams(void 0, this.plugin);
      $.to(i8.getCategoryId(Z)).apply(Z, WQ(X, J), { ref: Z.id });
    } else
      $.to(Z.id).update(J);
    return this.plugin.runTask(this.behaviors.updateTree($));
  }
  dispose() {
    this.behaviors.cells.forEach((Z) => {
      var J, $, X, Y;
      if (i8.Behavior.is(Z.obj))
        ($ = (J = Z.obj.data).unregister) === null || $ === void 0 || $.call(J), (Y = (X = Z.obj.data).dispose) === null || Y === void 0 || Y.call(X);
    }), super.dispose(), this.data.dispose(), this.behaviors.dispose(), this.animation.dispose();
  }
  constructor(Z) {
    super();
    this.plugin = Z, this.data = wK.create(new D0.Root({}), { runTask: this.plugin.runTask, globalContext: this.plugin, historyCapacity: this.plugin.config.get(W8.State.HistoryCapacity) }), this.behaviors = wK.create(new i8.Root({}), { runTask: this.plugin.runTask, globalContext: this.plugin, rootState: { isLocked: !0 } }), this.events = {
      cell: {
        stateUpdated: O5(this.data.events.cell.stateUpdated, this.behaviors.events.cell.stateUpdated),
        created: O5(this.data.events.cell.created, this.behaviors.events.cell.created),
        removed: O5(this.data.events.cell.removed, this.behaviors.events.cell.removed)
      },
      object: {
        created: O5(this.data.events.object.created, this.behaviors.events.object.created),
        removed: O5(this.data.events.object.removed, this.behaviors.events.object.removed),
        updated: O5(this.data.events.object.updated, this.behaviors.events.object.updated)
      }
    }, this.snapshotParams = this.ev.behavior(uX.DefaultSnapshotParams), this.setSnapshotParams = (J) => {
      this.snapshotParams.next({ ...uX.DefaultSnapshotParams, ...J });
    };
  }
}
(function(Z) {
  Z.SnapshotParams = {
    durationInMs: j.Numeric(1500, { min: 100, max: 15000, step: 100 }, { label: "Duration in ms" }),
    data: j.Boolean(!0),
    behavior: j.Boolean(!1),
    structureSelection: j.Boolean(!1),
    componentManager: j.Boolean(!0),
    animation: j.Boolean(!0),
    startAnimation: j.Boolean(!1),
    canvas3d: j.Boolean(!0),
    canvas3dContext: j.Boolean(!0),
    interactivity: j.Boolean(!0),
    camera: j.Boolean(!0),
    cameraTransition: j.MappedStatic("animate", {
      animate: j.Group({
        durationInMs: j.Numeric(250, { min: 100, max: 5000, step: 500 }, { label: "Duration in ms" })
      }),
      instant: j.Group({})
    }, { options: [["animate", "Animate"], ["instant", "Instant"]] }),
    image: j.Boolean(!1)
  }, Z.DefaultSnapshotParams = j.getDefaultValues(Z.SnapshotParams), Z.getMinFrameDuration = cJ(($) => {
    if (!$)
      return 16.666666666666668;
    let { transition: X } = $;
    if (!X)
      return 16.666666666666668;
    let Y = 1 / 0;
    for (let Q of X.frames)
      if (Q.durationInMs > 0 && Q.durationInMs < Y)
        Y = Q.durationInMs;
    if (!Number.isFinite(Y))
      return 16.666666666666668;
    return Y;
  }), Z.getStateTransitionDuration = cJ(($) => {
    if (!$)
      return;
    let { transition: X } = $;
    if (!X)
      return;
    let Y = 0;
    for (let Q = 0;Q < X.frames.length; Q++) {
      let W = X.frames[Q];
      Y += W.durationInMs;
    }
    return Y;
  }), Z.getStateTransitionFrameTime = cJ(($, X) => {
    if (!$ || X === void 0)
      return 0;
    let { transition: Y } = $;
    if (!Y)
      return 0;
    let Q = 0;
    for (let W = 0;W < X; W++) {
      if (Y.frames.length <= W)
        break;
      let K = Y.frames[W];
      Q += K.durationInMs;
    }
    return Q;
  });
  function J($, X) {
    var Y;
    let { transition: Q } = $;
    if (!(Q === null || Q === void 0 ? void 0 : Q.frames.length))
      return;
    let W = X;
    if (Q.loop)
      W %= (Y = Z.getStateTransitionDuration($)) !== null && Y !== void 0 ? Y : 1;
    let K = 0;
    if (W <= Q.frames[0].durationInMs)
      return 0;
    for (let G = 0;G < Q.frames.length; G++) {
      if (K >= W)
        return G;
      let H = Q.frames[G];
      K += H.durationInMs;
    }
    return Q.frames.length - 1;
  }
  Z.getStateTransitionFrameIndex = J;
})(uX || (uX = {}));

// node_modules/molstar/lib/mol-plugin-state/animation/built-in/state-snapshots.js
async function FE(Z, J, $ = !1) {
  var X, Y, Q, W, K, G, H;
  if (J.data)
    await Z.runTask(Z.state.data.setSnapshot(J.data));
  if ((X = J.canvas3d) === null || X === void 0 ? void 0 : X.props) {
    let N = j.normalizeParams(J$, J.canvas3d.props, "children");
    if (((Y = J.camera) === null || Y === void 0 ? void 0 : Y.current) || ((Q = J.camera) === null || Q === void 0 ? void 0 : Q.focus))
      N.camera = void 0, N.cameraClipping = void 0, N.cameraFog = void 0;
    (W = Z.canvas3d) === null || W === void 0 || W.setProps(N);
  }
  if ((K = J.camera) === null || K === void 0 ? void 0 : K.current)
    (G = Z.canvas3d) === null || G === void 0 || G.requestCameraReset({
      snapshot: J.camera.current,
      durationMs: $ || J.camera.transitionStyle === "instant" ? 0 : J.camera.transitionDurationInMs
    });
  else if ((H = J.camera) === null || H === void 0 ? void 0 : H.focus)
    Z.managers.camera.focusObject({
      ...J.camera.focus,
      durationMs: $ || J.camera.transitionStyle === "instant" ? 0 : J.camera.transitionDurationInMs
    });
}
var WV0 = RQ.create({
  name: "built-in.animate-state-snapshots",
  display: { name: "State Snapshots" },
  isExportable: !0,
  params: () => ({}),
  canApply(Z) {
    let J = Z.managers.snapshot.state.entries;
    if (J.size < 1)
      return { canApply: !1, reason: "At least 1 state required." };
    if (J.some(($) => !!($ === null || $ === void 0 ? void 0 : $.snapshot.startAnimation)))
      return { canApply: !1, reason: "Nested animations not supported." };
    return { canApply: Z.managers.snapshot.state.entries.size > 0 };
  },
  setup(Z, J, $) {
    let X = $.managers.snapshot.state.entries.get(0);
    FE($, X.snapshot, !0);
  },
  getDuration: (Z, J) => {
    return {
      kind: "fixed",
      durationMs: J.managers.snapshot.state.entries.toArray().reduce(($, X) => {
        var Y;
        return $ + ((Y = X.snapshot.durationInMs) !== null && Y !== void 0 ? Y : 0);
      }, 0)
    };
  },
  initialState: (Z, J) => {
    let $ = J.managers.snapshot.state.entries.toArray();
    return {
      totalDuration: $.reduce((X, Y) => {
        var Q;
        return X + ((Q = Y.snapshot.durationInMs) !== null && Q !== void 0 ? Q : 0);
      }, 0),
      snapshots: $,
      currentIndex: 0,
      currentTransitionFrame: 0
    };
  },
  async apply(Z, J, $) {
    var X;
    if (J.current >= Z.totalDuration)
      return { kind: "finished" };
    let Y = 0, Q = 0, W = 0;
    for (let q of Z.snapshots) {
      if (W = J.current - Y, Y += (X = q.snapshot.durationInMs) !== null && X !== void 0 ? X : 0, J.current < Y)
        break;
      Q++;
    }
    if (Q >= Z.snapshots.length)
      return { kind: "finished" };
    let { transition: K, camera: G, canvas3d: H } = Z.snapshots[Q].snapshot, N = uX.getStateTransitionFrameIndex(Z.snapshots[Q].snapshot, W);
    if (K && N !== void 0) {
      if (Q === Z.currentIndex && N === Z.currentTransitionFrame)
        return { kind: "skip" };
      if (N === 0 || Q !== Z.currentIndex)
        await FE($.plugin, {
          ...K.frames[N],
          camera: G,
          canvas3d: H
        });
      else
        await FE($.plugin, K.frames[N]);
      return { kind: "next", state: { ...Z, currentIndex: Q, currentAnimationFrame: N } };
    }
    if (Q === Z.currentIndex)
      return { kind: "skip" };
    return await FE($.plugin, Z.snapshots[Q].snapshot), { kind: "next", state: { ...Z, currentIndex: Q, currentAnimationFrame: void 0 } };
  }
}), qE = RQ.create({
  name: "built-in.animate-state-snapshot-transition",
  display: { name: "State Snapshot Transition" },
  isExportable: !0,
  params: () => ({}),
  canApply(Z) {
    let { snapshot: J } = Z.managers, { current: $ } = J;
    if (!($ === null || $ === void 0 ? void 0 : $.snapshot.transition))
      return { canApply: !1, reason: "No transition found" };
    return { canApply: !0 };
  },
  setup(Z, J, $) {
    var X, Y;
    let { current: Q } = $.managers.snapshot;
    if (!Q)
      return;
    FE($, (Y = (X = Q.snapshot.transition) === null || X === void 0 ? void 0 : X.frames[0]) !== null && Y !== void 0 ? Y : Q.snapshot, !0);
  },
  getDuration: (Z, J) => {
    var $, X;
    let { current: Y } = J.managers.snapshot;
    if (!(Y === null || Y === void 0 ? void 0 : Y.snapshot.transition))
      return { kind: "fixed", durationMs: 0 };
    if (($ = Y.snapshot.transition) === null || $ === void 0 ? void 0 : $.loop)
      return { kind: "infinite" };
    return {
      kind: "fixed",
      durationMs: (X = uX.getStateTransitionDuration(Y.snapshot)) !== null && X !== void 0 ? X : 0
    };
  },
  initialState: (Z, J) => {
    var $, X;
    let { current: Y } = J.managers.snapshot;
    if (!Y)
      return;
    return {
      totalDuration: (($ = Y.snapshot.transition) === null || $ === void 0 ? void 0 : $.loop) ? Number.MAX_VALUE : (X = uX.getStateTransitionDuration(Y.snapshot)) !== null && X !== void 0 ? X : 0,
      snapshots: [Y],
      currentIndex: 0,
      currentTransitionFrame: void 0,
      isInitial: !0
    };
  },
  async apply(Z, J, $) {
    var X;
    let Y = (X = Z.snapshots[0]) === null || X === void 0 ? void 0 : X.snapshot;
    if (J.current >= Z.totalDuration) {
      if ((Y === null || Y === void 0 ? void 0 : Y.transition) && Z.isInitial) {
        let H = Y.transition.frames.length - 1;
        $.plugin.managers.snapshot.setSnapshotAnimationFrame(Z.totalDuration, !1), await FE($.plugin, Y.transition.frames[H]);
      }
      return { kind: "finished" };
    }
    if (!Y)
      return { kind: "finished" };
    let { transition: Q, camera: W, canvas3d: K } = Y, G = uX.getStateTransitionFrameIndex(Y, J.current);
    if (!Q || G === void 0)
      return { kind: "finished" };
    if (G === Z.currentTransitionFrame)
      return { kind: "skip" };
    if ($.plugin.managers.snapshot.setSnapshotAnimationFrame(J.current, !1), G === 0)
      await FE($.plugin, {
        ...Q.frames[G],
        camera: W,
        canvas3d: K
      });
    else
      await FE($.plugin, Q.frames[G]);
    return { kind: "next", state: { ...Z, currentAnimationFrame: G, isInitial: !1 } };
  }
});

// node_modules/molstar/lib/mol-plugin-state/helpers/structure-representation-params.js
function UE(Z, J, $ = {}) {
  let X = $;
  if (typeof X.type === "string" || typeof X.color === "string" || typeof X.size === "string")
    return cR1(Z, J || s0.Empty, $);
  return GV0(Z, J || s0.Empty, $);
}
function KV0(Z, J) {
  let { themes: $ } = Z.representation.structure;
  if (!J)
    return $.colorThemeRegistry.types;
  return $.colorThemeRegistry.getApplicableTypes({ structure: J });
}
function MI(Z, J, $, X, Y) {
  let { registry: Q, themes: W } = Z.representation.structure, K = Q.get($ || Q.default.name), G = W.colorThemeRegistry.get(X || K.defaultColorTheme.name), H = j.getDefaultValues(G.getParams({ structure: J || s0.Empty }));
  if (G.name === K.defaultColorTheme.name)
    Object.assign(H, K.defaultColorTheme.props);
  return { name: G.name, params: Object.assign(H, Y) };
}
function i00(Z, J, $, X, Y) {
  let { registry: Q, themes: W } = Z.representation.structure, K = Q.get($ || Q.default.name), G = W.sizeThemeRegistry.get(X || K.defaultSizeTheme.name), H = j.getDefaultValues(G.getParams({ structure: J || s0.Empty }));
  if (G.name === K.defaultSizeTheme.name)
    Object.assign(H, K.defaultSizeTheme.props);
  return { name: G.name, params: Object.assign(H, Y) };
}
function cR1(Z, J, $) {
  let X = $.type && Z.representation.structure.registry.get($.type) || Z.representation.structure.registry.default.provider, Y = $.color && Z.representation.structure.themes.colorThemeRegistry.get($.color) || Z.representation.structure.themes.colorThemeRegistry.get(X.defaultColorTheme.name), Q = $.size && Z.representation.structure.themes.sizeThemeRegistry.get($.size) || Z.representation.structure.themes.sizeThemeRegistry.get(X.defaultSizeTheme.name);
  return GV0(Z, J, {
    type: X,
    typeParams: $.typeParams,
    color: Y,
    colorParams: $.colorParams,
    size: Q,
    sizeParams: $.sizeParams
  });
}
function GV0(Z, J, $ = {}) {
  let { themes: X } = Z.representation.structure, Y = { structure: J }, Q = $.type || Z.representation.structure.registry.default.provider, W = j.getDefaultValues(Q.getParams(X, J)), K = Object.assign(W, $.typeParams), G = $.color || X.colorThemeRegistry.get(Q.defaultColorTheme.name), H = j.getDefaultValues(G.getParams(Y));
  if (G.name === Q.defaultColorTheme.name)
    Object.assign(H, Q.defaultColorTheme.props);
  let N = Object.assign(H, $.colorParams), q = $.size || X.sizeThemeRegistry.get(Q.defaultSizeTheme.name), U = j.getDefaultValues(q.getParams(Y));
  if (q.name === Q.defaultSizeTheme.name)
    Object.assign(U, Q.defaultSizeTheme.props);
  let F = Object.assign(U, $.sizeParams);
  return {
    type: { name: Q.name, params: K },
    colorTheme: { name: G.name, params: N },
    sizeTheme: { name: q.name, params: F }
  };
}

// node_modules/molstar/lib/mol-plugin/behavior/dynamic/selection/structure-focus-representation.js
var lR1 = (Z) => {
  let J = H1.Representation.StructureRepresentation3D.definition.params(void 0, Z);
  return {
    expandRadius: j.Numeric(5, { min: 1, max: 10, step: 1 }),
    targetParams: j.Group(J, {
      label: "Target",
      customDefault: UE(Z, void 0, {
        type: "ball-and-stick",
        size: "physical",
        typeParams: { sizeFactor: 0.22, sizeAspectRatio: 0.73, adjustCylinderLength: !0, xrayShaded: !0, aromaticBonds: !1, multipleBonds: "off", excludeTypes: ["hydrogen-bond", "metal-coordination"] }
      })
    }),
    surroundingsParams: j.Group(J, {
      label: "Surroundings",
      customDefault: UE(Z, void 0, {
        type: "ball-and-stick",
        size: "physical",
        typeParams: { sizeFactor: 0.16, excludeTypes: ["hydrogen-bond", "metal-coordination"] }
      })
    }),
    nciParams: j.Group(J, {
      label: "Non-covalent Int.",
      customDefault: UE(Z, void 0, {
        type: EB,
        color: LI,
        size: J9.BuiltIn.uniform
      })
    }),
    components: j.MultiSelect(HV0, j.arrayToOptions(HV0)),
    excludeTargetFromSurroundings: j.Boolean(!1, { label: "Exclude Target", description: 'Exclude the focus "target" from the surroudings component.' }),
    ignoreHydrogens: j.Boolean(!1),
    ignoreHydrogensVariant: j.Select("all", j.arrayToOptions(["all", "non-polar"])),
    ignoreLight: j.Boolean(!1),
    material: C7.getParam(),
    clip: j.Group(FH.Params),
    interior: I3()
  };
}, HV0 = ["target", "surroundings", "interactions"], e9;
(function(Z) {
  Z.TargetSel = "structure-focus-target-sel", Z.TargetRepr = "structure-focus-target-repr", Z.SurrSel = "structure-focus-surr-sel", Z.SurrRepr = "structure-focus-surr-repr", Z.SurrNciRepr = "structure-focus-surr-nci-repr";
})(e9 || (e9 = {}));
var nR1 = /* @__PURE__ */ new Set([e9.TargetSel, e9.TargetRepr, e9.SurrSel, e9.SurrRepr, e9.SurrNciRepr]);

class NV0 extends i8.WithSubscribers {
  constructor() {
    super(...arguments);
    this.currentSource = void 0;
  }
  get surrLabel() {
    return `[Focus] Surroundings (${this.params.expandRadius} Å)`;
  }
  getReprParams(Z) {
    return {
      ...Z,
      type: {
        name: Z.type.name,
        params: { ...Z.type.params, ignoreHydrogens: this.params.ignoreHydrogens, ignoreHydrogensVariant: this.params.ignoreHydrogensVariant, ignoreLight: this.params.ignoreLight, material: this.params.material, clip: this.params.clip, interior: this.params.interior }
      }
    };
  }
  ensureShape(Z) {
    var J;
    let $ = this.plugin.state.data, X = $.tree, Y = $.build(), Q = f2.findUniqueTagsInSubtree(X, Z.transform.ref, nR1);
    if (!Q[e9.TargetSel])
      Q[e9.TargetSel] = Y.to(Z).apply(H1.Model.StructureSelectionFromBundle, { bundle: W0.Bundle.Empty, label: "[Focus] Target" }, { tags: e9.TargetSel }).ref;
    if (!Q[e9.SurrSel])
      Q[e9.SurrSel] = Y.to(Z).apply(H1.Model.StructureSelectionFromExpression, { expression: L0.struct.generator.empty(), label: this.surrLabel }, { tags: e9.SurrSel }).ref;
    let W = this.params.components;
    if (W.indexOf("target") >= 0 && !Q[e9.TargetRepr])
      Q[e9.TargetRepr] = Y.to(Q[e9.TargetSel]).apply(H1.Representation.StructureRepresentation3D, this.getReprParams(this.params.targetParams), { tags: e9.TargetRepr }).ref;
    if (W.indexOf("surroundings") >= 0 && !Q[e9.SurrRepr])
      Q[e9.SurrRepr] = Y.to(Q[e9.SurrSel]).apply(H1.Representation.StructureRepresentation3D, this.getReprParams(this.params.surroundingsParams), { tags: e9.SurrRepr }).ref;
    if (W.indexOf("interactions") >= 0 && !Q[e9.SurrNciRepr] && Z.obj && EB.isApplicable((J = Z.obj) === null || J === void 0 ? void 0 : J.data))
      Q[e9.SurrNciRepr] = Y.to(Q[e9.SurrSel]).apply(H1.Representation.StructureRepresentation3D, this.getReprParams(this.params.nciParams), { tags: e9.SurrNciRepr }).ref;
    return { state: $, builder: Y, refs: Q };
  }
  clear(Z) {
    let J = this.plugin.state.data;
    this.currentSource = void 0;
    let $ = J.select(f2.Generators.byRef(Z).subtree().withTag(e9.TargetSel)), X = J.select(f2.Generators.byRef(Z).subtree().withTag(e9.SurrSel));
    if ($.length === 0 && X.length === 0)
      return;
    let Y = J.build(), Q = W0.Bundle.Empty;
    for (let K of $)
      Y.to(K).update(H1.Model.StructureSelectionFromBundle, (G) => ({ ...G, bundle: Q }));
    let W = L0.struct.generator.empty();
    for (let K of X)
      Y.to(K).update(H1.Model.StructureSelectionFromExpression, (G) => ({ ...G, expression: W }));
    return h1.State.Update(this.plugin, { state: J, tree: Y, options: { doNotLogTiming: !0, doNotUpdateCurrent: !0 } });
  }
  async focus(Z) {
    let J = this.plugin.helpers.substructureParent.get(Z.structure);
    if (!J || !J.obj)
      return;
    this.currentSource = Z;
    let $ = W0.Loci.remap(Z, J.obj.data), X = W0.Loci.extendToWholeResidues($), Y = W0.Bundle.fromLoci(X), Q = W0.Bundle.toExpression(Y), W = L0.struct.modifier.includeSurroundings({
      0: Q,
      radius: this.params.expandRadius,
      "as-whole-residues": !0
    });
    if (this.params.excludeTargetFromSurroundings)
      W = L0.struct.modifier.exceptBy({
        0: W,
        by: Q
      });
    let { state: K, builder: G, refs: H } = this.ensureShape(J);
    G.to(H[e9.TargetSel]).update(H1.Model.StructureSelectionFromBundle, (N) => ({ ...N, bundle: Y })), G.to(H[e9.SurrSel]).update(H1.Model.StructureSelectionFromExpression, (N) => ({ ...N, expression: W, label: this.surrLabel })), await h1.State.Update(this.plugin, { state: K, tree: G, options: { doNotLogTiming: !0, doNotUpdateCurrent: !0 } });
  }
  register(Z) {
    this.subscribeObservable(this.plugin.managers.structure.focus.behaviors.current, (J) => {
      if (J)
        this.focus(J.loci);
      else
        this.clear(D8.RootRef);
    });
  }
  async update(Z) {
    let J = this.params;
    if (this.params = Z, J.excludeTargetFromSurroundings !== Z.excludeTargetFromSurroundings) {
      if (this.currentSource)
        this.focus(this.currentSource);
      return !0;
    }
    let $ = this.plugin.state.data, X = $.build(), Y = f2.Generators.root.subtree(), Q = this.params.components, W = Q.indexOf("target") >= 0;
    for (let K of $.select(Y.withTag(e9.TargetRepr)))
      if (!W)
        X.delete(K.transform.ref);
      else
        X.to(K).update(this.getReprParams(this.params.targetParams));
    W = Q.indexOf("surroundings") >= 0;
    for (let K of $.select(Y.withTag(e9.SurrRepr)))
      if (!W)
        X.delete(K.transform.ref);
      else
        X.to(K).update(this.getReprParams(this.params.surroundingsParams));
    W = Q.indexOf("interactions") >= 0;
    for (let K of $.select(Y.withTag(e9.SurrNciRepr)))
      if (!W)
        X.delete(K.transform.ref);
      else
        X.to(K).update(this.getReprParams(this.params.nciParams));
    if (await h1.State.Update(this.plugin, { state: $, tree: X, options: { doNotLogTiming: !0, doNotUpdateCurrent: !0 } }), Z.expandRadius !== J.expandRadius) {
      if (this.currentSource)
        this.focus(this.currentSource);
      return !0;
    }
    return !0;
  }
}
var lz = i8.create({
  name: "create-structure-focus-representation",
  display: { name: "Structure Focus Representation" },
  category: "interaction",
  ctor: NV0,
  params: (Z, J) => lR1(J)
});

// node_modules/molstar/lib/mol-plugin-state/actions/structure.js
var a00 = {};
y9(a00, {
  UpdateTrajectory: () => BI,
  PdbDownloadProvider: () => zV0,
  LoadTrajectory: () => VE1,
  EnableStructureCustomProps: () => TE1,
  EnableModelCustomProps: () => jE1,
  DownloadStructure: () => ME1,
  AddTrajectory: () => _E1
});

// node_modules/molstar/lib/mol-plugin-state/builder/structure/representation-preset.js
function KX(Z) {
  return Z;
}
(function(Z) {
  Z.CommonParams = {
    ignoreHydrogens: j.Optional(j.Boolean(!1)),
    ignoreHydrogensVariant: j.Optional(j.Select("all", j.arrayToOptions(["all", "non-polar"]))),
    ignoreLight: j.Optional(j.Boolean(!1)),
    quality: j.Optional(j.Select("auto", UV)),
    theme: j.Optional(j.Group({
      globalName: j.Optional(j.Text("")),
      globalColorParams: j.Optional(j.Value({}, { isHidden: !0 })),
      carbonColor: j.Optional(j.Select("chain-id", j.arrayToOptions(["chain-id", "operator-name", "element-symbol"]))),
      symmetryColor: j.Optional(j.Text("")),
      symmetryColorParams: j.Optional(j.Value({}, { isHidden: !0 })),
      focus: j.Optional(j.Group({
        name: j.Optional(j.Text("")),
        params: j.Optional(j.Value({}))
      }))
    }))
  };
  function J(Q) {
    return Q === "chain-id" ? { name: Q, params: ph.defaultValues } : Q === "operator-name" ? { name: Q, params: MA.defaultValues } : { name: Q, params: {} };
  }
  function $(Q) {
    return Q.units.some((W) => !W.conformation.operator.assembly && W.conformation.operator.spgrOp >= 0);
  }
  function X(Q, W, K) {
    var G, H, N, q, U, F, E, R, z, D, A, B, T, w;
    let V = Q.state.data.build(), P = Q.builders.structure.representation, I = Q.managers.structure.component.state.options.hydrogens, S = {
      quality: Q.managers.structure.component.state.options.visualQuality,
      ignoreHydrogens: I !== "all",
      ignoreHydrogensVariant: I === "only-polar" ? "non-polar" : "all",
      ignoreLight: Q.managers.structure.component.state.options.ignoreLight
    };
    if (W.quality && W.quality !== "auto")
      S.quality = W.quality;
    if (W.ignoreHydrogens !== void 0)
      S.ignoreHydrogens = !!W.ignoreHydrogens;
    if (W.ignoreHydrogensVariant !== void 0)
      S.ignoreHydrogensVariant = W.ignoreHydrogensVariant;
    if (W.ignoreLight !== void 0)
      S.ignoreLight = !!W.ignoreLight;
    let f = ((G = W.theme) === null || G === void 0 ? void 0 : G.globalName) ? (H = W.theme) === null || H === void 0 ? void 0 : H.globalName : void 0, v = ((N = W.theme) === null || N === void 0 ? void 0 : N.carbonColor) !== void 0 ? { carbonColor: J((q = W.theme) === null || q === void 0 ? void 0 : q.carbonColor), ...(U = W.theme) === null || U === void 0 ? void 0 : U.globalColorParams } : { ...(F = W.theme) === null || F === void 0 ? void 0 : F.globalColorParams }, h = K && ((E = W.theme) === null || E === void 0 ? void 0 : E.symmetryColor) ? $(K) ? (R = W.theme) === null || R === void 0 ? void 0 : R.symmetryColor : f : f, x = ((z = W.theme) === null || z === void 0 ? void 0 : z.symmetryColorParams) ? { ...(D = W.theme) === null || D === void 0 ? void 0 : D.globalColorParams, ...(A = W.theme) === null || A === void 0 ? void 0 : A.symmetryColorParams } : { ...(B = W.theme) === null || B === void 0 ? void 0 : B.globalColorParams }, b = ((T = W.theme) === null || T === void 0 ? void 0 : T.globalColorParams) ? { ...(w = W.theme) === null || w === void 0 ? void 0 : w.globalColorParams } : void 0;
    return { update: V, builder: P, color: f, symmetryColor: h, symmetryColorParams: x, globalColorParams: b, typeParams: S, ballAndStickColor: v };
  }
  Z.reprBuilder = X;
  function Y(Q, W, K, G) {
    if (!Q.state.hasBehavior(lz))
      return;
    return Q.state.updateBehavior(lz, (H) => {
      let N = MI(Q, W, "ball-and-stick", K || "element-symbol", G);
      H.surroundingsParams.colorTheme = N, H.targetParams.colorTheme = N;
    });
  }
  Z.updateFocusRepr = Y;
})(KX || (KX = {}));
var { CommonParams: MU, reprBuilder: LE, updateFocusRepr: RE } = KX, iR1 = KX({
  id: "preset-structure-representation-auto",
  display: {
    name: "Automatic",
    description: "Show representations based on the size of the structure. Smaller structures are shown with more detail than larger ones, ranging from atomistic display to coarse surfaces."
  },
  params: () => MU,
  apply(Z, J, $) {
    var X, Y;
    let Q = (Y = (X = X7.resolveAndCheck($.state.data, Z)) === null || X === void 0 ? void 0 : X.obj) === null || Y === void 0 ? void 0 : Y.data;
    if (!Q)
      return {};
    let W = $.config.get(W8.Structure.SizeThresholds) || s0.DefaultSizeThresholds, K = s0.getSize(Q, W), G = Q.polymerResidueCount / Q.polymerGapCount;
    switch (K) {
      case s0.Size.Gigantic:
      case s0.Size.Huge:
        return UV0.apply(Z, J, $);
      case s0.Size.Large:
        return LV0.apply(Z, J, $);
      case s0.Size.Medium:
        if (G > 3)
          return FV0.apply(Z, J, $);
      case s0.Size.Small:
        return RV0.apply(Z, { ...J, showCarbohydrateSymbol: !0 }, $);
      default:
        T8(K);
    }
  }
}), oR1 = KX({
  id: "preset-structure-representation-empty",
  display: { name: "Empty", description: "Removes all existing representations." },
  async apply(Z, J, $) {
    return {};
  }
}), AI = "Basic", FV0 = KX({
  id: "preset-structure-representation-polymer-and-ligand",
  display: {
    name: "Polymer & Ligand",
    group: AI,
    description: "Shows polymers as Cartoon, ligands as Ball & Stick, carbohydrates as 3D-SNFG and water molecules semi-transparent."
  },
  params: () => MU,
  async apply(Z, J, $) {
    var X, Y, Q, W, K, G, H, N, q, U;
    let F = X7.resolveAndCheck($.state.data, Z);
    if (!F)
      return {};
    let E = {
      polymer: await ZW($, F, "polymer"),
      ligand: await ZW($, F, "ligand"),
      nonStandard: await ZW($, F, "non-standard"),
      branched: await ZW($, F, "branched", { label: "Carbohydrate" }),
      water: await ZW($, F, "water"),
      ion: await ZW($, F, "ion"),
      lipid: await ZW($, F, "lipid"),
      coarse: await ZW($, F, "coarse")
    }, R = F.obj.data, z = (((Q = (Y = (X = E.water) === null || X === void 0 ? void 0 : X.obj) === null || Y === void 0 ? void 0 : Y.data) === null || Q === void 0 ? void 0 : Q.elementCount) || 0) > 50000 ? "line" : "ball-and-stick", D = (((G = (K = (W = E.lipid) === null || W === void 0 ? void 0 : W.obj) === null || K === void 0 ? void 0 : K.data) === null || G === void 0 ? void 0 : G.elementCount) || 0) > 20000 ? "line" : "ball-and-stick", { update: A, builder: B, typeParams: T, color: w, symmetryColor: V, symmetryColorParams: P, globalColorParams: I, ballAndStickColor: S } = LE($, J, R), f = {
      polymer: B.buildRepresentation(A, E.polymer, { type: "cartoon", typeParams: T, color: V, colorParams: P }, { tag: "polymer" }),
      ligand: B.buildRepresentation(A, E.ligand, { type: "ball-and-stick", typeParams: T, color: w, colorParams: S }, { tag: "ligand" }),
      nonStandard: B.buildRepresentation(A, E.nonStandard, { type: "ball-and-stick", typeParams: T, color: w, colorParams: S }, { tag: "non-standard" }),
      branchedBallAndStick: B.buildRepresentation(A, E.branched, { type: "ball-and-stick", typeParams: { ...T, alpha: 0.3 }, color: w, colorParams: S }, { tag: "branched-ball-and-stick" }),
      branchedSnfg3d: B.buildRepresentation(A, E.branched, { type: "carbohydrate", typeParams: T, color: w, colorParams: I }, { tag: "branched-snfg-3d" }),
      water: B.buildRepresentation(A, E.water, { type: z, typeParams: { ...T, alpha: 0.6, visuals: z === "line" ? ["intra-bond", "element-point"] : void 0 }, color: w, colorParams: { carbonColor: { name: "element-symbol", params: {} }, ...I } }, { tag: "water" }),
      ion: B.buildRepresentation(A, E.ion, { type: "ball-and-stick", typeParams: T, color: w, colorParams: { carbonColor: { name: "element-symbol", params: {} }, ...I } }, { tag: "ion" }),
      lipid: B.buildRepresentation(A, E.lipid, { type: D, typeParams: { ...T, alpha: 0.6, visuals: D === "line" ? ["intra-bond"] : void 0 }, color: w, colorParams: { carbonColor: { name: "element-symbol", params: {} }, ...I } }, { tag: "lipid" }),
      coarse: B.buildRepresentation(A, E.coarse, { type: "spacefill", typeParams: T, color: w || "chain-id", colorParams: I }, { tag: "coarse" })
    };
    return await A.commit({ revertOnError: !1 }), await RE($, R, (N = (H = J.theme) === null || H === void 0 ? void 0 : H.focus) === null || N === void 0 ? void 0 : N.name, (U = (q = J.theme) === null || q === void 0 ? void 0 : q.focus) === null || U === void 0 ? void 0 : U.params), { components: E, representations: f };
  }
}), sR1 = KX({
  id: "preset-structure-representation-protein-and-nucleic",
  display: {
    name: "Protein & Nucleic",
    group: AI,
    description: "Shows proteins as Cartoon and RNA/DNA as Gaussian Surface."
  },
  params: () => MU,
  async apply(Z, J, $) {
    var X, Y, Q, W;
    let K = X7.resolveAndCheck($.state.data, Z);
    if (!K)
      return {};
    let G = {
      protein: await qV0($, K, "protein"),
      nucleic: await qV0($, K, "nucleic")
    }, H = K.obj.data, N = {
      radiusOffset: H.isCoarseGrained ? 2 : 0,
      smoothness: H.isCoarseGrained ? 1 : 1.5
    }, { update: q, builder: U, typeParams: F, symmetryColor: E, symmetryColorParams: R } = LE($, J, H), z = {
      protein: U.buildRepresentation(q, G.protein, { type: "cartoon", typeParams: F, color: E, colorParams: R }, { tag: "protein" }),
      nucleic: U.buildRepresentation(q, G.nucleic, { type: "gaussian-surface", typeParams: { ...F, ...N }, color: E, colorParams: R }, { tag: "nucleic" })
    };
    return await q.commit({ revertOnError: !0 }), await RE($, H, (Y = (X = J.theme) === null || X === void 0 ? void 0 : X.focus) === null || Y === void 0 ? void 0 : Y.name, (W = (Q = J.theme) === null || Q === void 0 ? void 0 : Q.focus) === null || W === void 0 ? void 0 : W.params), { components: G, representations: z };
  }
}), UV0 = KX({
  id: "preset-structure-representation-coarse-surface",
  display: {
    name: "Coarse Surface",
    group: AI,
    description: "Shows polymers and lipids as coarse Gaussian Surface."
  },
  params: () => MU,
  async apply(Z, J, $) {
    var X, Y, Q, W;
    let K = X7.resolveAndCheck($.state.data, Z);
    if (!K)
      return {};
    let G = {
      polymer: await ZW($, K, "polymer"),
      lipid: await ZW($, K, "lipid")
    }, H = K.obj.data, N = $.config.get(W8.Structure.SizeThresholds) || s0.DefaultSizeThresholds, q = s0.getSize(H, N), U = Object.create(null);
    if (q === s0.Size.Gigantic)
      Object.assign(U, {
        traceOnly: !H.isCoarseGrained,
        radiusOffset: 2,
        smoothness: 1,
        visuals: ["structure-gaussian-surface-mesh"]
      });
    else if (q === s0.Size.Huge)
      Object.assign(U, {
        radiusOffset: H.isCoarseGrained ? 2 : 0,
        smoothness: 1
      });
    else if (H.isCoarseGrained)
      Object.assign(U, {
        radiusOffset: 2,
        smoothness: 1
      });
    let { update: F, builder: E, typeParams: R, symmetryColor: z, symmetryColorParams: D } = LE($, J, H), A = {
      polymer: E.buildRepresentation(F, G.polymer, { type: "gaussian-surface", typeParams: { ...R, ...U }, color: z, colorParams: D }, { tag: "polymer" }),
      lipid: E.buildRepresentation(F, G.lipid, { type: "gaussian-surface", typeParams: { ...R, ...U }, color: z, colorParams: D }, { tag: "lipid" })
    };
    return await F.commit({ revertOnError: !0 }), await RE($, H, (Y = (X = J.theme) === null || X === void 0 ? void 0 : X.focus) === null || Y === void 0 ? void 0 : Y.name, (W = (Q = J.theme) === null || Q === void 0 ? void 0 : Q.focus) === null || W === void 0 ? void 0 : W.params), { components: G, representations: A };
  }
}), LV0 = KX({
  id: "preset-structure-representation-polymer-cartoon",
  display: {
    name: "Polymer Cartoon",
    group: AI,
    description: "Shows polymers as Cartoon."
  },
  params: () => MU,
  async apply(Z, J, $) {
    var X, Y, Q, W;
    let K = X7.resolveAndCheck($.state.data, Z);
    if (!K)
      return {};
    let G = {
      polymer: await ZW($, K, "polymer")
    }, H = K.obj.data, { update: N, builder: q, typeParams: U, symmetryColor: F, symmetryColorParams: E } = LE($, J, H), R = {
      polymer: q.buildRepresentation(N, G.polymer, { type: "cartoon", typeParams: U, color: F, colorParams: E }, { tag: "polymer" })
    };
    return await N.commit({ revertOnError: !0 }), await RE($, H, (Y = (X = J.theme) === null || X === void 0 ? void 0 : X.focus) === null || Y === void 0 ? void 0 : Y.name, (W = (Q = J.theme) === null || Q === void 0 ? void 0 : Q.focus) === null || W === void 0 ? void 0 : W.params), { components: G, representations: R };
  }
}), RV0 = KX({
  id: "preset-structure-representation-atomic-detail",
  display: {
    name: "Atomic Detail",
    group: AI,
    description: "Shows everything in atomic detail."
  },
  params: () => ({
    ...MU,
    showCarbohydrateSymbol: j.Boolean(!1)
  }),
  async apply(Z, J, $) {
    var X, Y, Q, W, K, G;
    let H = X7.resolveAndCheck($.state.data, Z);
    if (!H)
      return {};
    let N = {
      all: await ZW($, H, "all"),
      branched: void 0
    }, q = H.obj.data, U = q.elementCount > 1e5, F = q.elementCount > 1e6, E = q.units.length > 5000, R = q.atomicResidueCount && q.elementCount > 1000 && q.atomicResidueCount / q.elementCount < 3, z = q.models[0], D = !!j9.Provider.get(z) || mQ.isExhaustive(z), A = "ball-and-stick";
    if (q.isCoarseGrained || E)
      A = F ? "point" : "spacefill";
    else if (R && !D)
      A = "spacefill";
    else if (U)
      A = "line";
    let B = J.showCarbohydrateSymbol && !U && !R;
    if (B)
      Object.assign(N, {
        branched: await ZW($, H, "branched", { label: "Carbohydrate" })
      });
    let { update: T, builder: w, typeParams: V, color: P, ballAndStickColor: I, globalColorParams: S } = LE($, J, q), f = R && !D ? { carbonColor: { name: "element-symbol", params: {} }, ...S } : I, v = {
      all: w.buildRepresentation(T, N.all, { type: A, typeParams: V, color: P, colorParams: f }, { tag: "all" })
    };
    if (B)
      Object.assign(v, {
        snfg3d: w.buildRepresentation(T, N.branched, { type: "carbohydrate", typeParams: { ...V, alpha: 0.4, visuals: ["carbohydrate-symbol"] }, color: P, colorParams: S }, { tag: "snfg-3d" })
      });
    return await T.commit({ revertOnError: !0 }), await RE($, q, (Q = (Y = (X = J.theme) === null || X === void 0 ? void 0 : X.focus) === null || Y === void 0 ? void 0 : Y.name) !== null && Q !== void 0 ? Q : P, (G = (K = (W = J.theme) === null || W === void 0 ? void 0 : W.focus) === null || K === void 0 ? void 0 : K.params) !== null && G !== void 0 ? G : f), { components: N, representations: v };
  }
}), aR1 = KX({
  id: "preset-structure-representation-illustrative",
  display: {
    name: "Illustrative",
    group: "Miscellaneous",
    description: "Show everything in spacefill representation with illustrative colors and ignore light."
  },
  params: () => MU,
  async apply(Z, J, $) {
    var X, Y, Q, W, K;
    let G = X7.resolveAndCheck($.state.data, Z);
    if (!G)
      return {};
    let H = {
      all: await ZW($, G, "all"),
      branched: void 0
    }, N = G.obj.data, { update: q, builder: U, typeParams: F, color: E } = LE($, J, N), R = {
      all: U.buildRepresentation(q, H.all, {
        type: "spacefill",
        typeParams: { ...F, ignoreLight: !0 },
        color: "illustrative",
        colorParams: { style: { name: "entity-id", params: { overrideWater: !0 } } }
      }, { tag: "all" })
    };
    return await q.commit({ revertOnError: !0 }), await RE($, N, (Q = (Y = (X = J.theme) === null || X === void 0 ? void 0 : X.focus) === null || Y === void 0 ? void 0 : Y.name) !== null && Q !== void 0 ? Q : E, (K = (W = J.theme) === null || W === void 0 ? void 0 : W.focus) === null || K === void 0 ? void 0 : K.params), { components: H, representations: R };
  }
}), rR1 = KX({
  id: "preset-structure-representation-molecular-surface",
  display: {
    name: "Molecular Surface",
    group: "Miscellaneous",
    description: "Show everything in molecular surface representation with illustrative colors."
  },
  params: () => MU,
  async apply(Z, J, $) {
    var X, Y, Q, W, K;
    let G = X7.resolveAndCheck($.state.data, Z);
    if (!G)
      return {};
    let H = {
      all: await ZW($, G, "all"),
      branched: void 0
    }, N = G.obj.data, { update: q, builder: U, typeParams: F, color: E } = LE($, J, N), R = {
      all: U.buildRepresentation(q, H.all, {
        type: "molecular-surface",
        typeParams: F,
        color: "entity-id",
        colorParams: { overrideWater: !0 }
      }, { tag: "all" })
    };
    return await q.commit({ revertOnError: !0 }), await RE($, N, (Q = (Y = (X = J.theme) === null || X === void 0 ? void 0 : X.focus) === null || Y === void 0 ? void 0 : Y.name) !== null && Q !== void 0 ? Q : E, (K = (W = J.theme) === null || W === void 0 ? void 0 : W.focus) === null || K === void 0 ? void 0 : K.params), { components: H, representations: R };
  }
}), tR1 = KX({
  id: "preset-structure-representation-auto-lod",
  display: {
    name: "Automatic Detail",
    group: "Miscellaneous",
    description: "Shows more (or less) detailed representations automatically based on camera distance."
  },
  params: () => MU,
  async apply(Z, J, $) {
    var X, Y, Q, W;
    let K = X7.resolveAndCheck($.state.data, Z);
    if (!K)
      return {};
    let G = {
      all: await ZW($, K, "all")
    }, H = K.obj.data, { update: N, builder: q, typeParams: U, color: F, symmetryColor: E, symmetryColorParams: R, ballAndStickColor: z } = LE($, J, H), D = {
      gaussianSurface: q.buildRepresentation(N, G.all, { type: "gaussian-surface", typeParams: { ...U, lod: M.create(30, 1e7, 100) }, color: E, colorParams: R }, { tag: "gaussian-surface" }),
      cartoon: q.buildRepresentation(N, G.all, { type: "cartoon", typeParams: { ...U, lod: M.create(-20, 300, 100) }, color: E, colorParams: R }, { tag: "cartoon" }),
      ballAndStick: q.buildRepresentation(N, G.all, { type: "ball-and-stick", typeParams: { ...U, lod: M.create(-20, 40, 20) }, color: F, colorParams: z }, { tag: "ball-and-stick" })
    };
    return await N.commit({ revertOnError: !1 }), await RE($, H, (Y = (X = J.theme) === null || X === void 0 ? void 0 : X.focus) === null || Y === void 0 ? void 0 : Y.name, (W = (Q = J.theme) === null || Q === void 0 ? void 0 : Q.focus) === null || W === void 0 ? void 0 : W.params), { components: G, representations: D };
  }
});
function ZW(Z, J, $, X) {
  return Z.builders.structure.tryCreateComponentStatic(J, $, X);
}
function qV0(Z, J, $, X) {
  return Z.builders.structure.tryCreateComponentFromSelection(J, u9[$], `selection-${$}`, X);
}
var hY = {
  empty: oR1,
  auto: iR1,
  "atomic-detail": RV0,
  "polymer-cartoon": LV0,
  "polymer-and-ligand": FV0,
  "protein-and-nucleic": sR1,
  "coarse-surface": UV0,
  illustrative: aR1,
  "molecular-surface": rR1,
  "auto-lod": tR1
};

// node_modules/molstar/lib/mol-plugin-state/formats/provider.js
function cX(Z) {
  return Z;
}
function OB(Z, J) {
  if (Z.ext === "bcif")
    try {
      let $ = Hh(J);
      if ($.encoder.startsWith("VolumeServer"))
        return "dscif";
      if ($.encoder.startsWith("volseg-volume-server"))
        return "segcif";
      if (s00($, "volume_data_3d_info")) {
        if (s00($, "volume_data_3d"))
          return "dscif";
        if (s00($, "segmentation_data_3d"))
          return "segcif";
      }
    } catch ($) {
      console.error($);
    }
  else if (Z.ext === "cif") {
    let $ = J;
    if ($.startsWith(`data_SERVER
#
_density_server_result`))
      return "dscif";
    if ($.startsWith(`data_SERVER
#
data_SEGMENTATION_DATA`))
      return "segcif";
    if (o00($, "volume_data_3d_info")) {
      if (o00($, "volume_data_3d"))
        return "dscif";
      if (o00($, "segmentation_data_3d"))
        return "segcif";
    }
    if ($.includes("atom_site_fract_x") || $.includes("atom_site.fract_x"))
      return "coreCif";
  }
  return -1;
}
function o00(Z, J) {
  return Z.includes(`_${J}.`);
}
function s00(Z, J) {
  for (let $ of Z.dataBlocks)
    for (let X of $.categories)
      if (X.name === J)
        return !0;
  return !1;
}

// node_modules/molstar/lib/mol-plugin-state/formats/trajectory.js
var h5 = "Trajectory";
function SH(Z, J) {
  return Z.builders.structure.hierarchy.applyPreset(J.trajectory, "default");
}
var eR1 = {
  label: "mmCIF",
  description: "mmCIF",
  category: h5,
  stringExtensions: ["cif", "mmcif", "mcif"],
  binaryExtensions: ["bcif"],
  isApplicable: (Z, J) => {
    if (Z.ext === "mmcif" || Z.ext === "mcif")
      return !0;
    if (Z.ext === "cif" || Z.ext === "bcif")
      return OB(Z, J) === -1;
    return !1;
  },
  parse: async (Z, J, $) => {
    var X, Y;
    let W = Z.state.data.build().to(J).apply(H1.Data.ParseCif, void 0, { state: { isGhost: !0 } }), K = await W.apply(H1.Model.TrajectoryFromMmCif, void 0, { tags: $ === null || $ === void 0 ? void 0 : $.trajectoryTags }).commit({ revertOnError: !0 });
    if ((((Y = (X = W.selector.cell) === null || X === void 0 ? void 0 : X.obj) === null || Y === void 0 ? void 0 : Y.data.blocks.length) || 0) > 1)
      Z.state.data.updateCellState(W.ref, { isGhost: !1 });
    return { trajectory: K };
  },
  visuals: SH
}, ZE1 = {
  label: "cifCore",
  description: "CIF Core",
  category: h5,
  stringExtensions: ["cif"],
  isApplicable: (Z, J) => {
    if (Z.ext === "cif")
      return OB(Z, J) === "coreCif";
    return !1;
  },
  parse: async (Z, J, $) => {
    var X, Y;
    let W = Z.state.data.build().to(J).apply(H1.Data.ParseCif, void 0, { state: { isGhost: !0 } }), K = await W.apply(H1.Model.TrajectoryFromCifCore, void 0, { tags: $ === null || $ === void 0 ? void 0 : $.trajectoryTags }).commit({ revertOnError: !0 });
    if ((((Y = (X = W.selector.cell) === null || X === void 0 ? void 0 : X.obj) === null || Y === void 0 ? void 0 : Y.data.blocks.length) || 0) > 1)
      Z.state.data.updateCellState(W.ref, { isGhost: !1 });
    return { trajectory: K };
  },
  visuals: SH
};
function AU(Z, J) {
  return async ($, X, Y) => {
    return { trajectory: await $.state.data.build().to(X).apply(Z, J, { tags: Y === null || Y === void 0 ? void 0 : Y.trajectoryTags }).commit({ revertOnError: !0 }) };
  };
}
var JE1 = {
  label: "PDB",
  description: "PDB",
  category: h5,
  stringExtensions: ["pdb", "ent"],
  parse: AU(H1.Model.TrajectoryFromPDB),
  visuals: SH
}, $E1 = {
  label: "PDBQT",
  description: "PDBQT",
  category: h5,
  stringExtensions: ["pdbqt"],
  parse: AU(H1.Model.TrajectoryFromPDB, { isPdbqt: !0 }),
  visuals: SH
}, XE1 = {
  label: "XYZ",
  description: "XYZ",
  category: h5,
  stringExtensions: ["xyz"],
  parse: AU(H1.Model.TrajectoryFromXYZ),
  visuals: SH
}, YE1 = {
  label: "Lammps Data",
  description: "Lammps Data",
  category: h5,
  stringExtensions: ["data"],
  parse: AU(H1.Model.TrajectoryFromLammpsData),
  visuals: SH
}, QE1 = {
  label: "Lammps Trajectory Data",
  description: "Lammps Trajectory Data",
  category: h5,
  stringExtensions: ["lammpstrj"],
  parse: AU(H1.Model.TrajectoryFromLammpsTrajData),
  visuals: SH
}, WE1 = {
  label: "GRO",
  description: "GRO",
  category: h5,
  stringExtensions: ["gro"],
  binaryExtensions: [],
  parse: AU(H1.Model.TrajectoryFromGRO),
  visuals: SH
}, KE1 = {
  label: "MOL",
  description: "MOL",
  category: h5,
  stringExtensions: ["mol"],
  parse: AU(H1.Model.TrajectoryFromMOL),
  visuals: SH
}, GE1 = {
  label: "SDF",
  description: "SDF",
  category: h5,
  stringExtensions: ["sdf", "sd"],
  parse: AU(H1.Model.TrajectoryFromSDF),
  visuals: SH
}, HE1 = {
  label: "MOL2",
  description: "MOL2",
  category: h5,
  stringExtensions: ["mol2"],
  parse: AU(H1.Model.TrajectoryFromMOL2),
  visuals: SH
}, Qy = [
  ["mmcif", eR1],
  ["cifCore", ZE1],
  ["pdb", JE1],
  ["pdbqt", $E1],
  ["gro", WE1],
  ["xyz", XE1],
  ["lammps_data", YE1],
  ["lammps_traj_data", QE1],
  ["mol", KE1],
  ["sdf", GE1],
  ["mol2", HE1]
];

// node_modules/molstar/lib/mol-util/file-info.js
var NE1 = ["gz", "zip"];
function BU(Z) {
  let J = Z, $ = "", X = J.lastIndexOf("?"), Y = X !== -1 ? J.substring(X) : "";
  J = J.substring(0, X === -1 ? J.length : X);
  let Q = J.replace(/^.*[\\/]/, ""), W = Q.substring(0, Q.lastIndexOf(".")), K = Q.split("."), G = K.length > 1 ? (K.pop() || "").toLowerCase() : "", H = J.match(/^(.+):\/\/(.+)$/);
  if (H)
    $ = H[1].toLowerCase(), J = H[2] || "";
  let N = J.substring(0, J.lastIndexOf("/") + 1);
  if (NE1.includes(G)) {
    let q = J.length - G.length - 1;
    G = (J.substring(0, q).split(".").pop() || "").toLowerCase();
    let U = W.length - G.length - 1;
    W = W.substring(0, U);
  }
  return { path: J, name: Q, ext: G, base: W, dir: N, protocol: $, query: Y };
}

// node_modules/molstar/lib/mol-plugin-state/formats/topology.js
var zB = "Topology";
var qE1 = cX({
  label: "PSF",
  description: "PSF",
  category: zB,
  stringExtensions: ["psf"],
  parse: async (Z, J) => {
    let $ = Z.state.data.build().to(J).apply(H1.Data.ParsePsf, {}, { state: { isGhost: !0 } }), X = $.apply(H1.Model.TopologyFromPsf);
    return await $.commit(), { format: $.selector, topology: X.selector };
  }
});
var FE1 = cX({
  label: "PRMTOP",
  description: "PRMTOP",
  category: zB,
  stringExtensions: ["prmtop", "parm7"],
  parse: async (Z, J) => {
    let $ = Z.state.data.build().to(J).apply(H1.Data.ParsePrmtop, {}, { state: { isGhost: !0 } }), X = $.apply(H1.Model.TopologyFromPrmtop);
    return await $.commit(), { format: $.selector, topology: X.selector };
  }
});
var UE1 = cX({
  label: "TOP",
  description: "TOP",
  category: zB,
  stringExtensions: ["top"],
  parse: async (Z, J) => {
    let $ = Z.state.data.build().to(J).apply(H1.Data.ParseTop, {}, { state: { isGhost: !0 } }), X = $.apply(H1.Model.TopologyFromTop);
    return await $.commit(), { format: $.selector, topology: X.selector };
  }
}), EV0 = [
  ["psf", qE1],
  ["prmtop", FE1],
  ["top", UE1]
];

// node_modules/molstar/lib/mol-plugin-state/formats/coordinates.js
var EE = "Coordinates";
var LE1 = cX({
  label: "DCD",
  description: "DCD",
  category: EE,
  binaryExtensions: ["dcd"],
  parse: (Z, J) => {
    return Z.state.data.build().to(J).apply(H1.Model.CoordinatesFromDcd).commit();
  }
});
var RE1 = cX({
  label: "XTC",
  description: "XTC",
  category: EE,
  binaryExtensions: ["xtc"],
  parse: (Z, J) => {
    return Z.state.data.build().to(J).apply(H1.Model.CoordinatesFromXtc).commit();
  }
});
var EE1 = cX({
  label: "TRR",
  description: "TRR",
  category: EE,
  binaryExtensions: ["trr"],
  parse: (Z, J) => {
    return Z.state.data.build().to(J).apply(H1.Model.CoordinatesFromTrr).commit();
  }
});
var OE1 = cX({
  label: "NCTRAJ",
  description: "NCTRAJ",
  category: EE,
  binaryExtensions: ["nc", "nctraj"],
  parse: (Z, J) => {
    return Z.state.data.build().to(J).apply(H1.Model.CoordinatesFromNctraj).commit();
  }
});
var zE1 = cX({
  label: "LAMMPSTRAJ",
  description: "LAMMPSTRAJ",
  category: EE,
  stringExtensions: ["lammpstrj"],
  parse: (Z, J) => {
    return Z.state.data.build().to(J).apply(H1.Model.CoordinatesFromLammpstraj).commit();
  }
}), OV0 = [
  ["dcd", LE1],
  ["xtc", RE1],
  ["trr", EE1],
  ["nctraj", OE1],
  ["lammpstrj", zE1]
];

// node_modules/molstar/lib/mol-plugin-state/actions/structure.js
var DE1 = (Z) => {
  let J = Z.config.get(W8.Structure.DefaultRepresentationPreset) || hY.auto.id;
  return j.Group({
    type: Nq.getParams(void 0, "auto").type,
    representation: j.Select(J, Z.builders.structure.representation.getPresets().map(($) => [$.id, $.display.name, $.display.group]), { description: "Which representation preset to use." }),
    representationParams: j.Group(KX.CommonParams, { isHidden: !0 }),
    asTrajectory: j.Optional(j.Boolean(!1, { description: "Load all entries into a single trajectory." }))
  }, { isExpanded: !1 });
}, zV0 = {
  rcsb: j.Group({
    encoding: j.Select("bcif", j.arrayToOptions(["cif", "bcif"]))
  }, { label: "RCSB PDB", isFlat: !0 }),
  pdbe: j.Group({
    variant: j.Select("updated-bcif", [["updated-bcif", "Updated (bcif)"], ["updated", "Updated"], ["archival", "Archival"]])
  }, { label: "PDBe", isFlat: !0 }),
  pdbj: j.EmptyGroup({ label: "PDBj" })
};
var ME1 = a$.build({
  from: D0.Root,
  display: { name: "Download Structure", description: "Load a structure from the provided source and create its representation." },
  params: (Z, J) => {
    let $ = DE1(J), X = J.config.get(W8.Download.DefaultPdbProvider) || "pdbe";
    return {
      source: j.MappedStatic("pdb", {
        pdb: j.Group({
          provider: j.Group({
            id: j.Text("1tqn", { label: "PDB Id(s)", description: "One or more comma/space separated PDB ids." }),
            server: j.MappedStatic(X, zV0)
          }, { pivot: "id" }),
          options: $
        }, { isFlat: !0, label: "PDB" }),
        "pdb-ihm": j.Group({
          provider: j.Group({
            id: j.Text("8zzc", { label: "PDB-IHM Id(s)", description: "One or more comma/space separated ids." }),
            encoding: j.Select("bcif", j.arrayToOptions(["cif", "bcif"]))
          }, { pivot: "id" }),
          options: $
        }, { isFlat: !0, label: "PDB-IHM" }),
        swissmodel: j.Group({
          id: j.Text("Q9Y2I8", { label: "UniProtKB AC(s)", description: "One or more comma/space separated ACs." }),
          options: $
        }, { isFlat: !0, label: "SWISS-MODEL", description: "Loads the best homology model or experimental structure" }),
        alphafolddb: j.Group({
          provider: j.Group({
            id: j.Text("Q8W3K0", { label: "UniProtKB AC(s)", description: "One or more comma/space separated ACs." }),
            encoding: j.Select("bcif", j.arrayToOptions(["cif", "bcif"]))
          }, { pivot: "id" }),
          options: $
        }, { isFlat: !0, label: "AlphaFold DB", description: "Loads the predicted model if available" }),
        modelarchive: j.Group({
          id: j.Text("ma-bak-cepc-0003", { label: "Accession Code(s)", description: "One or more comma/space separated ACs." }),
          options: $
        }, { isFlat: !0, label: "Model Archive" }),
        pubchem: j.Group({
          id: j.Text("2244,2245", { label: "PubChem ID", description: "One or more comma/space separated IDs." }),
          options: $
        }, { isFlat: !0, label: "PubChem", description: "Loads 3D conformer from PubChem." }),
        url: j.Group({
          url: j.Url(""),
          format: j.Select("mmcif", j.arrayToOptions(Qy.map((Y) => Y[0]), (Y) => Y)),
          isBinary: j.Boolean(!1),
          label: j.Optional(j.Text("")),
          options: $
        }, { isFlat: !0, label: "URL" })
      })
    };
  }
})(({ params: Z, state: J }, $) => n0.create("Download Structure", async (X) => {
  $.behaviors.layout.leftPanelTabName.next("data");
  let Y = Z.source, Q, W = !1, K = "mmcif";
  switch (Y.name) {
    case "url":
      Q = [{ url: Y.params.url, isBinary: Y.params.isBinary, label: Y.params.label || void 0 }], K = Y.params.format;
      break;
    case "pdb":
      Q = await (Y.params.provider.server.name === "pdbe" ? AE1(Y) : Y.params.provider.server.name === "pdbj" ? BE1(Y) : Y.params.provider.server.name === "rcsb" ? wE1(Y) : T8(Y)), W = !!Y.params.options.asTrajectory;
      break;
    case "pdb-ihm":
      let q = (U) => U.startsWith("PDBDEV_") ? U : `PDBDEV_${U.padStart(8, "0")}`;
      Q = await fH(Y.params.provider.id, (U) => {
        if (U.match(/^[1-9][A-Z0-9]{3}$/i) !== null)
          return Y.params.provider.encoding === "bcif" ? `https://pdb-ihm.org/bcif/${U.toLowerCase()}.bcif` : `https://pdb-ihm.org/cif/${U.toLowerCase()}.cif`;
        let F = q(U.toUpperCase());
        return Y.params.provider.encoding === "bcif" ? `https://pdb-ihm.org/bcif/${F}.bcif` : `https://pdb-ihm.org/cif/${F}.cif`;
      }, (U) => {
        let F = U.toUpperCase();
        return F.match(/^[1-9][A-Z0-9]{3}$/) ? `PDB-IHM: ${F}` : q(F);
      }, Y.params.provider.encoding === "bcif"), W = !!Y.params.options.asTrajectory;
      break;
    case "swissmodel":
      Q = await fH(Y.params.id, (U) => `https://swissmodel.expasy.org/repository/uniprot/${U.toUpperCase()}.pdb`, (U) => `SWISS-MODEL: ${U}`, !1), W = !!Y.params.options.asTrajectory, K = "pdb";
      break;
    case "alphafolddb":
      Q = await fH(Y.params.provider.id, async (U) => {
        let F = `https://www.alphafold.ebi.ac.uk/api/prediction/${U.toUpperCase()}`, E = await $.runTask($.fetch({ url: F, type: "json" }));
        if (Array.isArray(E) && E.length > 0) {
          let R = Y.params.provider.encoding === "bcif" ? "bcifUrl" : "cifUrl";
          return E[0][R];
        }
        throw new Error(`No AlphaFold DB entry for '${U}'`);
      }, (U) => `AlphaFold DB: ${U}`, Y.params.provider.encoding === "bcif"), W = !!Y.params.options.asTrajectory, K = "mmcif";
      break;
    case "modelarchive":
      Q = await fH(Y.params.id, (U) => `https://www.modelarchive.org/doi/10.5452/${U.toLowerCase()}.cif`, (U) => `Model Archive: ${U}`, !1), W = !!Y.params.options.asTrajectory, K = "mmcif";
      break;
    case "pubchem":
      Q = await fH(Y.params.id, (U) => `https://pubchem.ncbi.nlm.nih.gov/rest/pug/compound/CID/${U.trim()}/record/SDF/?record_type=3d`, (U) => `PubChem: ${U}`, !1), W = !!Y.params.options.asTrajectory, K = "mol";
      break;
    default:
      T8(Y);
  }
  let G = Z.source.params.options.representation || $.config.get(W8.Structure.DefaultRepresentationPreset) || hY.auto.id, H = G !== hY.empty.id, N = Y.params.options.type.name === "auto" ? void 0 : Y.params.options.type;
  await J.transaction(async () => {
    if (Q.length > 0 && W) {
      let q = await $.builders.data.downloadBlob({
        sources: Q.map((F, E) => ({ id: "" + E, url: F.url, isBinary: F.isBinary })),
        maxConcurrency: 6
      }, { state: { isGhost: !0 } }), U = await $.builders.structure.parseTrajectory(q, { formats: Q.map((F, E) => ({ id: "" + E, format: "cif" })) });
      await $.builders.structure.hierarchy.applyPreset(U, "default", {
        structure: N,
        showUnitcell: H,
        representationPreset: G,
        representationPresetParams: Z.source.params.options.representationParams
      });
    } else
      for (let q of Q) {
        let U = await $.builders.data.download(q, { state: { isGhost: !0 } }), F = $.dataFormats.get(K);
        if (!F)
          throw new Error("unknown file format");
        let E = await $.builders.structure.parseTrajectory(U, F);
        await $.builders.structure.hierarchy.applyPreset(E, "default", {
          structure: N,
          showUnitcell: H,
          representationPreset: G,
          representationPresetParams: Z.source.params.options.representationParams
        });
      }
  }).runInContext(X);
}));
async function fH(Z, J, $, X) {
  let Y = Z.split(/[,\s]/).map((W) => W.trim()).filter((W) => !!W && (W.length >= 4 || /^[1-9][0-9]*$/.test(W))), Q = [];
  for (let W of Y)
    Q.push({ url: E6.Url(await J(W)), isBinary: X, label: $(W) });
  return Q;
}
async function AE1(Z) {
  if (Z.name !== "pdb" || Z.params.provider.server.name !== "pdbe")
    throw new Error("expected pdbe");
  return Z.params.provider.server.params.variant === "updated" ? fH(Z.params.provider.id, (J) => `https://www.ebi.ac.uk/pdbe/static/entry/${J.toLowerCase()}_updated.cif`, (J) => `PDBe: ${J} (updated cif)`, !1) : Z.params.provider.server.params.variant === "updated-bcif" ? fH(Z.params.provider.id, (J) => `https://www.ebi.ac.uk/pdbe/entry-files/download/${J.toLowerCase()}.bcif`, (J) => `PDBe: ${J} (updated cif)`, !0) : fH(Z.params.provider.id, (J) => `https://www.ebi.ac.uk/pdbe/static/entry/${J.toLowerCase()}.cif`, (J) => `PDBe: ${J} (cif)`, !1);
}
async function BE1(Z) {
  if (Z.name !== "pdb" || Z.params.provider.server.name !== "pdbj")
    throw new Error("expected pdbj");
  return fH(Z.params.provider.id, (J) => `https://data.pdbjlc1.pdbj.org/pub/pdb/data/structures/divided/mmCIF/${J.toLowerCase().substring(1, 3)}/${J.toLowerCase()}.cif`, (J) => `PDBj: ${J} (cif)`, !1);
}
async function wE1(Z) {
  if (Z.name !== "pdb" || Z.params.provider.server.name !== "rcsb")
    throw new Error("expected rcsb");
  return Z.params.provider.server.params.encoding === "cif" ? fH(Z.params.provider.id, (J) => `https://files.rcsb.org/download/${J.toUpperCase()}.cif`, (J) => `RCSB PDB: ${J} (cif)`, !1) : fH(Z.params.provider.id, (J) => `https://models.rcsb.org/${J.toUpperCase()}.bcif`, (J) => `RCSB PDB: ${J} (bcif)`, !0);
}
var BI = a$.build({
  display: { name: "Update Trajectory" },
  params: {
    action: j.Select("advance", j.arrayToOptions(["advance", "reset"])),
    by: j.Optional(j.Numeric(1, { min: -1, max: 1, step: 1 }))
  }
})(({ params: Z, state: J }) => {
  let $ = J.selectQ((Y) => Y.ofTransformer(H1.Model.ModelFromTrajectory)), X = J.build();
  if (Z.action === "reset")
    for (let Y of $)
      X.to(Y).update({ modelIndex: 0 });
  else
    for (let Y of $) {
      let Q = f2.findAncestorOfType(J.tree, J.cells, Y.transform.ref, D0.Molecule.Trajectory);
      if (!Q || !Q.obj)
        continue;
      let W = Q.obj;
      X.to(Y).update((K) => {
        let G = (K.modelIndex + Z.by) % W.data.frameCount;
        if (G < 0)
          G += W.data.frameCount;
        return { modelIndex: G };
      });
    }
  return J.updateTree(X);
}), jE1 = a$.build({
  display: { name: "Custom Model Properties", description: "Enable parameters for custom properties of the model." },
  from: D0.Molecule.Model,
  params(Z, J) {
    return J.customModelProperties.getParams(Z === null || Z === void 0 ? void 0 : Z.data);
  },
  isApplicable(Z, J, $) {
    return J.transformer !== Lt;
  }
})(({ ref: Z, params: J }, $) => $.builders.structure.insertModelProperties(Z, J)), TE1 = a$.build({
  display: { name: "Custom Structure Properties", description: "Enable parameters for custom properties of the structure." },
  from: D0.Molecule.Structure,
  params(Z, J) {
    return J.customStructureProperties.getParams(Z === null || Z === void 0 ? void 0 : Z.data);
  },
  isApplicable(Z, J, $) {
    return J.transformer !== Rt;
  }
})(({ ref: Z, params: J }, $) => $.builders.structure.insertStructureProperties(Z, J)), _E1 = a$.build({
  display: { name: "Add Trajectory", description: "Add trajectory from existing model/topology and coordinates." },
  from: D0.Root,
  params(Z, J) {
    let $ = J.state.data, Y = [
      ...$.selectQ((K) => K.rootsOfType(D0.Molecule.Model)),
      ...$.selectQ((K) => K.rootsOfType(D0.Molecule.Topology))
    ].map((K) => [K.transform.ref, K.obj.label]), W = $.selectQ((K) => K.rootsOfType(D0.Molecule.Coordinates)).map((K) => [K.transform.ref, K.obj.label]);
    return {
      model: j.Select(Y.length ? Y[0][0] : "", Y),
      coordinates: j.Select(W.length ? W[0][0] : "", W)
    };
  }
})(({ params: Z, state: J }, $) => n0.create("Add Trajectory", (X) => {
  return J.transaction(async () => {
    let Y = [Z.model, Z.coordinates], Q = J.build().toRoot().apply(kb, {
      modelRef: Z.model,
      coordinatesRef: Z.coordinates
    }, { dependsOn: Y }).apply(H1.Model.ModelFromTrajectory, { modelIndex: 0 });
    await J.updateTree(Q).runInContext(X);
    let W = await $.builders.structure.createStructure(Q.selector);
    await $.builders.structure.representation.applyPreset(W, "auto");
  }).runInContext(X);
})), VE1 = a$.build({
  display: { name: "Load Trajectory", description: "Load trajectory of model/topology and coordinates from URL or file." },
  from: D0.Root,
  params(Z, J) {
    let { options: $ } = J.dataFormats, X = $.filter((K) => K[2] === h5 || K[2] === zB), Y = $.filter((K) => K[2] === EE), Q = [], W = [];
    for (let { provider: K } of J.dataFormats.list)
      if (K.category === h5 || K.category === zB) {
        if (K.binaryExtensions)
          Q.push(...K.binaryExtensions);
        if (K.stringExtensions)
          Q.push(...K.stringExtensions);
      } else if (K.category === EE) {
        if (K.binaryExtensions)
          W.push(...K.binaryExtensions);
        if (K.stringExtensions)
          W.push(...K.stringExtensions);
      }
    return {
      source: j.MappedStatic("file", {
        url: j.Group({
          model: j.Group({
            url: j.Url(""),
            format: j.Select(X[0][0], X),
            isBinary: j.Boolean(!1)
          }, { isExpanded: !0 }),
          coordinates: j.Group({
            url: j.Url(""),
            format: j.Select(Y[0][0], Y)
          }, { isExpanded: !0 })
        }, { isFlat: !0 }),
        file: j.Group({
          model: j.File({ accept: Q.map((K) => `.${K}`).join(","), label: "Model" }),
          coordinates: j.File({ accept: W.map((K) => `.${K}`).join(","), label: "Coordinates" })
        }, { isFlat: !0 })
      }, { options: [["url", "URL"], ["file", "File"]] })
    };
  }
})(({ params: Z, state: J }, $) => n0.create("Load Trajectory", (X) => {
  return J.transaction(async () => {
    let Y = Z.source;
    if (Y.name === "file" && (Y.params.model === null || Y.params.coordinates === null)) {
      $.log.error("No file(s) selected");
      return;
    }
    if (Y.name === "url" && (!Y.params.model || !Y.params.coordinates)) {
      $.log.error("No URL(s) given");
      return;
    }
    let Q = async (K, G, H) => {
      let N = await $.builders.data.download({ url: K, isBinary: H }), q = $.dataFormats.get(G);
      if (!q) {
        $.log.warn(`LoadTrajectory: could not find data provider for '${G}'`);
        return;
      }
      return q.parse($, N);
    }, W = async (K) => {
      var G, H, N;
      if (!K)
        throw new Error("No file selected");
      let q = BU((H = (G = K.file) === null || G === void 0 ? void 0 : G.name) !== null && H !== void 0 ? H : ""), U = $.dataFormats.binaryExtensions.has(q.ext), { data: F } = await $.builders.data.readFile({ file: K, isBinary: U }), E = $.dataFormats.auto(q, (N = F.cell) === null || N === void 0 ? void 0 : N.obj);
      if (!E) {
        $.log.warn(`LoadTrajectory: could not find data provider for '${q.ext}'`), await $.state.data.build().delete(F).commit();
        return;
      }
      return E.parse($, F);
    };
    try {
      let K = Y.name === "url" ? await Q(Y.params.model.url, Y.params.model.format, Y.params.model.isBinary) : await W(Y.params.model), G;
      if ("trajectory" in K)
        G = await J.build().to(K.trajectory).apply(Ut, { modelIndex: 0 }).commit();
      else
        G = K.topology;
      let H = Y.name === "url" ? await Q(Y.params.coordinates.url, Y.params.coordinates.format, !0) : await W(Y.params.coordinates), N = [G.ref, H.ref], q = J.build().toRoot().apply(kb, {
        modelRef: G.ref,
        coordinatesRef: H.ref
      }, { dependsOn: N }).apply(H1.Model.ModelFromTrajectory, { modelIndex: 0 });
      await J.updateTree(q).runInContext(X);
      let U = await $.builders.structure.createStructure(q.selector);
      await $.builders.structure.representation.applyPreset(U, "auto");
    } catch (K) {
      console.error(K), $.log.error("Error loading trajectory");
    }
  }).runInContext(X);
}));

// node_modules/molstar/lib/mol-plugin-state/actions/volume.js
var t00 = {};
y9(t00, {
  DownloadDensity: () => IE1,
  AssignColorVolume: () => r00
});
var IE1 = a$.build({
  from: D0.Root,
  display: { name: "Download Density", description: "Load a density from the provided source and create its default visual." },
  params: (Z, J) => {
    let { options: $ } = J.dataFormats;
    return {
      source: j.MappedStatic("pdb-xray", {
        "pdb-xray": j.Group({
          provider: j.Group({
            id: j.Text("1tqn", { label: "Id" }),
            server: j.Select("pdbe", [["pdbe", "PDBe"]])
          }, { pivot: "id" }),
          type: j.Select("2fofc", [["2fofc", "2Fo-Fc"], ["fofc", "Fo-Fc"]])
        }, { isFlat: !0 }),
        "pdb-xray-ds": j.Group({
          provider: j.Group({
            id: j.Text("1tqn", { label: "Id" }),
            server: j.Select("pdbe", [["pdbe", "PDBe"], ["rcsb", "RCSB PDB"]])
          }, { pivot: "id" }),
          detail: j.Numeric(3, { min: 0, max: 6, step: 1 }, { label: "Detail" })
        }, { isFlat: !0 }),
        "pdb-emd-ds": j.Group({
          provider: j.Group({
            id: j.Text("emd-8004", { label: "Id" }),
            server: j.Select("pdbe", [["pdbe", "PDBe"], ["rcsb", "RCSB PDB"]])
          }, { pivot: "id" }),
          detail: j.Numeric(3, { min: 0, max: 6, step: 1 }, { label: "Detail" })
        }, { isFlat: !0 }),
        url: j.Group({
          url: j.Url(""),
          isBinary: j.Boolean(!1),
          format: j.Select("auto", $)
        }, { isFlat: !0 })
      }, {
        options: [
          ["pdb-xray", "PDB X-ray maps"],
          ["pdb-emd-ds", "PDB EMD Density Server"],
          ["pdb-xray-ds", "PDB X-ray Density Server"],
          ["url", "URL"]
        ]
      })
    };
  }
})(({ params: Z }, J) => n0.create("Download Density", async ($) => {
  var X, Y;
  let Q = Z.source, W, K;
  switch (Q.name) {
    case "url":
      W = Q.params;
      break;
    case "pdb-xray":
      W = {
        url: E6.Url(Q.params.type === "2fofc" ? `https://www.ebi.ac.uk/pdbe/coordinates/files/${Q.params.provider.id.toLowerCase()}.ccp4` : `https://www.ebi.ac.uk/pdbe/coordinates/files/${Q.params.provider.id.toLowerCase()}_diff.ccp4`),
        isBinary: !0,
        label: `PDBe X-ray map: ${Q.params.provider.id}`
      };
      break;
    case "pdb-emd-ds":
      W = Q.params.provider.server === "pdbe" ? {
        url: E6.Url(`https://www.ebi.ac.uk/pdbe/densities/emd/${Q.params.provider.id.toLowerCase()}/cell?detail=${Q.params.detail}`),
        isBinary: !0,
        label: `PDBe EMD Density Server: ${Q.params.provider.id}`
      } : {
        url: E6.Url(`https://maps.rcsb.org/em/${Q.params.provider.id.toLowerCase()}/cell?detail=${Q.params.detail}`),
        isBinary: !0,
        label: `RCSB PDB EMD Density Server: ${Q.params.provider.id}`
      };
      break;
    case "pdb-xray-ds":
      W = Q.params.provider.server === "pdbe" ? {
        url: E6.Url(`https://www.ebi.ac.uk/pdbe/densities/x-ray/${Q.params.provider.id.toLowerCase()}/cell?detail=${Q.params.detail}`),
        isBinary: !0,
        label: `PDBe X-ray Density Server: ${Q.params.provider.id}`
      } : {
        url: E6.Url(`https://maps.rcsb.org/x-ray/${Q.params.provider.id.toLowerCase()}/cell?detail=${Q.params.detail}`),
        isBinary: !0,
        label: `RCSB PDB X-ray Density Server: ${Q.params.provider.id}`
      };
      break;
    default:
      T8(Q);
  }
  let G = await J.builders.data.download(W), H = void 0;
  switch (Q.name) {
    case "url":
      W = Q.params, K = Q.params.format === "auto" ? J.dataFormats.auto(BU(E6.getUrl(W.url)), (X = G.cell) === null || X === void 0 ? void 0 : X.obj) : J.dataFormats.get(Q.params.format);
      break;
    case "pdb-xray":
      H = Q.params.provider.id, K = J.dataFormats.get("ccp4");
      break;
    case "pdb-emd-ds":
    case "pdb-xray-ds":
      H = Q.params.provider.id, K = J.dataFormats.get("dscif");
      break;
    default:
      T8(Q);
  }
  if (!K) {
    J.log.warn("DownloadDensity: Format provider not found.");
    return;
  }
  let N = await K.parse(J, G, { entryId: H });
  await ((Y = K.visuals) === null || Y === void 0 ? void 0 : Y.call(K, J, N));
})), r00 = a$.build({
  display: { name: "Assign Volume Colors", description: "Assigns another volume to be available for coloring." },
  from: D0.Volume.Data,
  isApplicable(Z) {
    return !Z.data.colorVolume;
  },
  params(Z, J) {
    let $ = J.state.data.select(f2.Generators.root.subtree().ofType(D0.Volume.Data).filter((X) => {
      var Y;
      return !!X.obj && !((Y = X.obj) === null || Y === void 0 ? void 0 : Y.data.colorVolume) && X.obj !== Z;
    }));
    if ($.length === 0)
      return { ref: j.Text("", { isHidden: !0, label: "Volume" }) };
    return { ref: j.Select($[0].transform.ref, $.map((X) => [X.transform.ref, X.obj.label]), { label: "Volume" }) };
  }
})(({ ref: Z, params: J, state: $ }, X) => {
  return X.build().to(Z).apply(H1.Volume.AssignColorVolume, { ref: J.ref }, { dependsOn: [J.ref] }).commit();
});

// node_modules/molstar/lib/mol-plugin-state/actions/file.js
var e00 = {};
y9(e00, {
  OpenFiles: () => wI,
  DownloadFile: () => PE1
});
async function Wy(Z, J, $, X) {
  var Y, Q, W, K;
  let G = BU((Q = (Y = Z.file) === null || Y === void 0 ? void 0 : Y.name) !== null && Q !== void 0 ? Q : ""), H = J.dataFormats.binaryExtensions.has(G.ext), { data: N } = await J.builders.data.readFile({ file: Z, isBinary: H }), q = $ === "auto" ? J.dataFormats.auto(G, (W = N.cell) === null || W === void 0 ? void 0 : W.obj) : J.dataFormats.get($);
  if (!q) {
    J.log.warn(`OpenFiles: could not find data provider for '${G.ext}'`), await J.state.data.build().delete(N).commit();
    return;
  }
  let U = await q.parse(J, N);
  if (X)
    await ((K = q.visuals) === null || K === void 0 ? void 0 : K.call(q, J, U));
}
var wI = a$.build({
  display: { name: "Open Files", description: "Load one or more files and optionally create default visuals" },
  from: D0.Root,
  params: (Z, J) => {
    let { extensions: $, options: X } = J.dataFormats;
    return {
      files: j.FileList({ accept: Array.from($.values()).map((Y) => `.${Y}`).join(",") + ",.gz,.zip", multiple: !0 }),
      format: j.MappedStatic("auto", {
        auto: j.EmptyGroup(),
        specific: j.Select(X[0][0], X)
      }),
      visuals: j.Boolean(!0, { description: "Add default visuals" })
    };
  }
})(({ params: Z, state: J }, $) => n0.create("Open Files", async (X) => {
  $.behaviors.layout.leftPanelTabName.next("data"), await J.transaction(async () => {
    if (Z.files === null) {
      $.log.error("No file(s) selected");
      return;
    }
    for (let Y of Z.files)
      try {
        if (Y.file && Y.name.toLowerCase().endsWith(".zip")) {
          let Q = await _M(X, await Y.file.arrayBuffer());
          for (let [W, K] of Object.entries(Q)) {
            if (!(K instanceof Uint8Array) || K.length === 0)
              continue;
            let G = E6.File(new File([K], W));
            await Wy(G, $, "auto", Z.visuals);
          }
        } else {
          let Q = Z.format.name === "auto" ? "auto" : Z.format.params;
          await Wy(Y, $, Q, Z.visuals);
        }
      } catch (Q) {
        console.error(Q), $.log.error(`Error opening file '${Y.name}'`);
      }
  }).runInContext(X);
})), PE1 = a$.build({
  display: { name: "Download File", description: "Load one or more file from an URL" },
  from: D0.Root,
  params: (Z, J) => {
    let $ = [...J.dataFormats.options, ["zip", "Zip"], ["gzip", "Gzip"]];
    return {
      url: j.Url(""),
      format: j.Select($[0][0], $),
      isBinary: j.Boolean(!1),
      visuals: j.Boolean(!0, { description: "Add default visuals" })
    };
  }
})(({ params: Z, state: J }, $) => n0.create("Open Files", async (X) => {
  $.behaviors.layout.leftPanelTabName.next("data"), await J.transaction(async () => {
    var Y, Q, W;
    try {
      if (Z.format === "zip" || Z.format === "gzip") {
        let K = await $.builders.data.download({ url: Z.url, isBinary: !0 });
        if (Z.format === "zip") {
          let G = await _M(X, ((Y = K.obj) === null || Y === void 0 ? void 0 : Y.data).buffer);
          for (let [H, N] of Object.entries(G)) {
            if (!(N instanceof Uint8Array) || N.length === 0)
              continue;
            let q = E6.File(new File([N], H));
            await Wy(q, $, "auto", Z.visuals);
          }
        } else {
          let G = E6.getUrl(Z.url), H = BU(G).name;
          await Wy(E6.File(new File([(Q = K.obj) === null || Q === void 0 ? void 0 : Q.data], H)), $, "auto", Z.visuals);
        }
      } else {
        let K = $.dataFormats.get(Z.format);
        if (!K) {
          $.log.warn(`DownloadFile: could not find data provider for '${Z.format}'`);
          return;
        }
        let G = await $.builders.data.download({ url: Z.url, isBinary: Z.isBinary }), H = await K.parse($, G);
        if (Z.visuals)
          await ((W = K.visuals) === null || W === void 0 ? void 0 : W.call(K, $, H));
      }
    } catch (K) {
      console.error(K), $.log.error(`Error downloading '${typeof Z.url === "string" ? Z.url : Z.url.url}'`);
    }
  }).runInContext(X);
}));

// node_modules/molstar/lib/mol-plugin-state/actions.js
var OE = {
  Structure: a00,
  Volume: t00,
  DataFormat: e00
};

// node_modules/molstar/lib/mol-plugin-state/animation/built-in/state-interpolation.js
var DV0 = RQ.create({
  name: "built-in.animate-state-interpolation",
  display: { name: "Animate State (experimental)" },
  params: () => ({
    transtionDurationInMs: j.Numeric(2000, { min: 100, max: 30000, step: 10 })
  }),
  canApply(Z) {
    return { canApply: Z.managers.snapshot.state.entries.size > 1 };
  },
  initialState: () => ({}),
  async apply(Z, J, $) {
    let X = $.plugin.managers.snapshot.state.entries;
    if (X.size < 2)
      return { kind: "finished" };
    let Y = J.current % $.params.transtionDurationInMs / $.params.transtionDurationInMs, Q = Math.floor(J.current / $.params.transtionDurationInMs) % X.size, W = Math.ceil(J.current / $.params.transtionDurationInMs);
    if (W === Q)
      W++;
    W = W % X.size;
    let K = X.get(Q).snapshot, G = X.get(W).snapshot;
    if (!K.data || !G.data)
      return { kind: "skip" };
    let H = K.data.tree.transforms, N = G.data.tree.transforms, q = $.plugin.state.data, U = q.build();
    for (let F of H)
      for (let E of N) {
        if (E.ref !== F.ref)
          continue;
        if (E.version === F.version)
          continue;
        let R = D8.fromJSON(F), z = D8.fromJSON(E), D = q.cells.get(F.ref);
        if (!D)
          continue;
        let A;
        if (!R.transformer.definition.interpolate)
          A = Y <= 0.5 ? R.params : z.params;
        else
          A = R.transformer.definition.interpolate(R.params, z.params, Y, $.plugin);
        if (!xO(D, A))
          U.to(F.ref).update(A);
      }
    return await h1.State.Update($.plugin, { state: q, tree: U, options: { doNotLogTiming: !0 } }), { kind: "next", state: {} };
  }
});

// node_modules/molstar/lib/mol-plugin-state/animation/built-in/spin-structure.js
var MV0 = RQ.create({
  name: "built-in.animate-structure-spin",
  display: { name: "Spin Structure" },
  isExportable: !0,
  params: () => ({
    durationInMs: j.Numeric(3000, { min: 100, max: 1e4, step: 100 })
  }),
  initialState: () => ({ t: 0 }),
  getDuration: (Z) => ({ kind: "fixed", durationMs: Z.durationInMs }),
  async setup(Z, J, $) {
    let X = $.state.data, Y = X.select(f2.Generators.ofType(D0.Molecule.Structure.Representation3D)), Q = X.build(), W = !1;
    for (let K of Y) {
      if (X.select(f2.Generators.ofTransformer(H1.Representation.SpinStructureRepresentation3D, K.transform.ref)).length > 0)
        continue;
      W = !0, Q.to(K.transform.ref).apply(H1.Representation.SpinStructureRepresentation3D, { t: 0 }, { tags: "animate-structure-spin" });
    }
    if (!W)
      return;
    return Q.commit({ doNotUpdateCurrent: !0 });
  },
  teardown(Z, J, $) {
    let X = $.state.data, Y = X.select(f2.Generators.ofType(D0.Molecule.Structure.Representation3DState).withTag("animate-structure-spin"));
    if (Y.length === 0)
      return;
    let Q = X.build();
    for (let W of Y)
      Q.delete(W.transform.ref);
    return Q.commit();
  },
  async apply(Z, J, $) {
    var X;
    let Y = $.plugin.state.data, Q = Y.select(f2.Generators.ofTransformer(H1.Representation.SpinStructureRepresentation3D));
    if (Q.length === 0)
      return { kind: "finished" };
    let W = Y.build(), K = (J.current - J.lastApplied) / $.params.durationInMs, G = (Z.t + K) % 1;
    for (let H of Q)
      W.to(H).update({ ...(X = H.params) === null || X === void 0 ? void 0 : X.values, t: G });
    return await h1.State.Update($.plugin, { state: Y, tree: W, options: { doNotLogTiming: !0 } }), { kind: "next", state: { t: G } };
  }
});

// node_modules/molstar/lib/mol-plugin-state/animation/built-in/camera-rock.js
var Ky = M(), AV0 = M(), BV0 = k8(), wV0 = RQ.create({
  name: "built-in.animate-camera-rock",
  display: { name: "Camera Rock", description: "Rock the 3D scene around the x-axis in view space" },
  isExportable: !0,
  params: () => ({
    durationInMs: j.Numeric(4000, { min: 100, max: 20000, step: 100 }),
    speed: j.Numeric(1, { min: 1, max: 10, step: 1 }, { description: "How many times to rock from side to side." }),
    angle: j.Numeric(10, { min: 0, max: 180, step: 1 }, { description: "How many degrees to rotate in each direction." })
  }),
  initialState: (Z, J) => ({ snapshot: J.canvas3d.camera.getSnapshot() }),
  getDuration: (Z) => ({ kind: "fixed", durationMs: Z.durationInMs }),
  teardown: (Z, J, $) => {
    var X;
    (X = $.canvas3d) === null || X === void 0 || X.requestCameraReset({ snapshot: J.snapshot, durationMs: 0 });
  },
  async apply(Z, J, $) {
    var X, Y;
    if (J.current === 0)
      return { kind: "next", state: Z };
    let Q = Z.snapshot;
    if (Q.radiusMax < 0.0001)
      return { kind: "finished" };
    let W = J.animation ? ((X = J.animation) === null || X === void 0 ? void 0 : X.currentFrame) / (J.animation.frameCount + 1) : x8(J.current / $.params.durationInMs, 0, 1), K = Math.sin(W * $.params.speed * Math.PI * 2) * _8($.params.angle);
    M.sub(Ky, Q.position, Q.target), M.normalize(AV0, Q.up), k8.setAxisAngle(BV0, AV0, K), M.transformQuat(Ky, Ky, BV0);
    let G = M.add(M(), Q.target, Ky);
    if ((Y = $.plugin.canvas3d) === null || Y === void 0 || Y.requestCameraReset({ snapshot: { ...Q, position: G }, durationMs: 0 }), W >= 0.99999)
      return { kind: "finished" };
    return { kind: "next", state: Z };
  }
});

// node_modules/molstar/lib/mol-plugin/spec.js
var f8;
(function(Z) {
  function J(X, Y) {
    return { action: X, customControl: Y && Y.customControl, autoUpdate: Y && Y.autoUpdate };
  }
  Z.Action = J;
  function $(X, Y = {}) {
    return { transformer: X, defaultParams: Y };
  }
  Z.Behavior = $;
})(f8 || (f8 = {}));
var jV0 = () => ({
  actions: [
    f8.Action(OE.Structure.DownloadStructure),
    f8.Action(OE.Volume.DownloadDensity),
    f8.Action(OE.DataFormat.DownloadFile),
    f8.Action(OE.DataFormat.OpenFiles),
    f8.Action(OE.Structure.LoadTrajectory),
    f8.Action(OE.Structure.EnableModelCustomProps),
    f8.Action(OE.Structure.EnableStructureCustomProps),
    f8.Action(iV),
    f8.Action(Jw0),
    f8.Action(oV),
    f8.Action(H1.Data.Download),
    f8.Action(H1.Data.ParseCif),
    f8.Action(H1.Data.ParseCcp4),
    f8.Action(H1.Data.ParseDsn6),
    f8.Action(H1.Model.TrajectoryFromMmCif),
    f8.Action(H1.Model.TrajectoryFromCifCore),
    f8.Action(H1.Model.TrajectoryFromPDB),
    f8.Action(H1.Model.TransformStructureConformation),
    f8.Action(H1.Model.StructureInstances),
    f8.Action(H1.Model.StructureFromModel),
    f8.Action(H1.Model.StructureFromTrajectory),
    f8.Action(H1.Model.ModelFromTrajectory),
    f8.Action(H1.Model.StructureSelectionFromScript),
    f8.Action(H1.Representation.StructureRepresentation3D),
    f8.Action(H1.Representation.StructureSelectionsDistance3D),
    f8.Action(H1.Representation.StructureSelectionsAngle3D),
    f8.Action(H1.Representation.StructureSelectionsDihedral3D),
    f8.Action(H1.Representation.StructureSelectionsLabel3D),
    f8.Action(H1.Representation.StructureSelectionsOrientation3D),
    f8.Action(H1.Representation.ModelUnitcell3D),
    f8.Action(H1.Representation.StructureBoundingBox3D),
    f8.Action(H1.Representation.ExplodeStructureRepresentation3D),
    f8.Action(H1.Representation.SpinStructureRepresentation3D),
    f8.Action(H1.Representation.UnwindStructureAssemblyRepresentation3D),
    f8.Action(H1.Representation.OverpaintStructureRepresentation3DFromScript),
    f8.Action(H1.Representation.TransparencyStructureRepresentation3DFromScript),
    f8.Action(H1.Representation.ClippingStructureRepresentation3DFromScript),
    f8.Action(H1.Representation.SubstanceStructureRepresentation3DFromScript),
    f8.Action(H1.Representation.ThemeStrengthRepresentation3D),
    f8.Action(r00),
    f8.Action(H1.Volume.VolumeFromCcp4),
    f8.Action(H1.Volume.VolumeFromDsn6),
    f8.Action(H1.Volume.VolumeFromCube),
    f8.Action(H1.Volume.VolumeFromDx),
    f8.Action(H1.Representation.VolumeRepresentation3D),
    f8.Action(H1.Volume.VolumeTransform),
    f8.Action(H1.Volume.VolumeInstances)
  ],
  behaviors: [
    f8.Behavior(eQ.Representation.HighlightLoci),
    f8.Behavior(eQ.Representation.SelectLoci),
    f8.Behavior(eQ.Representation.DefaultLociLabelProvider),
    f8.Behavior(eQ.Representation.FocusLoci),
    f8.Behavior(eQ.Camera.FocusLoci),
    f8.Behavior(eQ.Camera.CameraAxisHelper),
    f8.Behavior(eQ.Camera.CameraControls),
    f8.Behavior(eQ.State.SnapshotControls),
    f8.Behavior(lz),
    f8.Behavior(eQ.CustomProps.StructureInfo),
    f8.Behavior(eQ.CustomProps.AccessibleSurfaceArea),
    f8.Behavior(eQ.CustomProps.BestDatabaseSequenceMapping),
    f8.Behavior(eQ.CustomProps.Interactions),
    f8.Behavior(eQ.CustomProps.SecondaryStructure),
    f8.Behavior(eQ.CustomProps.ValenceModel),
    f8.Behavior(eQ.CustomProps.CrossLinkRestraint)
  ],
  animations: [
    Ww0,
    Qw0,
    wV0,
    WV0,
    qE,
    $w0,
    MV0,
    DV0
  ]
});

// node_modules/molstar/lib/mol-plugin-ui/custom/volume.js
var XW = t2(PZ(), 1);

// node_modules/molstar/lib/mol-plugin-ui/base.js
var oz = t2(PZ(), 1), DB = t2(J7(), 1);

// node_modules/molstar/lib/mol-plugin-ui/controls/common.js
var X9 = t2(PZ(), 1), jU = t2(J7(), 1);

// node_modules/molstar/lib/mol-plugin-ui/controls/icons.js
var O1 = t2(PZ(), 1);
function b6(Z) {
  if (!Z.svg)
    return null;
  return O1.jsx("span", { className: `msp-icon msp-material-icon${Z.inline ? " msp-icon-inline" : ""}`, title: Z.title, style: Z.style, children: O1.jsx(Z.svg, {}) });
}
var Gy = O1.jsx("circle", { r: "6px", id: "circle-left", cy: "12px", cx: "8px", strokeWidth: "1px" }), Hy = O1.jsx("circle", { r: "6px", id: "circle-right", cy: "12px", cx: "16px", strokeWidth: "1px" }), kE1 = O1.jsxs("svg", { width: "24px", height: "24px", viewBox: "0 0 24 24", children: [O1.jsxs("defs", { children: [Gy, Hy] }), O1.jsxs("g", { children: [O1.jsx("use", { href: "#circle-left", className: "msp-shape-filled" }), O1.jsx("use", { href: "#circle-right", className: "msp-shape-filled" }), O1.jsx("use", { href: "#circle-left", className: "msp-shape-empty" })] })] });
function jI() {
  return kE1;
}
var vE1 = O1.jsxs("svg", { width: "24px", height: "24px", viewBox: "0 0 24 24", children: [O1.jsxs("defs", { children: [Gy, Hy, O1.jsxs("mask", { id: "mask-left", children: [O1.jsx("use", { href: "#circle-left", fill: "white", stroke: "white" }), O1.jsx("use", { href: "#circle-right", fill: "black", strokeWidth: "0px", stroke: "white" })] })] }), O1.jsxs("g", { children: [O1.jsx("use", { href: "#circle-left", className: "msp-shape-filled", mask: "url(#mask-left)" }), O1.jsx("use", { href: "#circle-right", className: "msp-shape-empty" })] })] });
function TI() {
  return vE1;
}
var SE1 = O1.jsxs("svg", { width: "24px", height: "24px", viewBox: "0 0 24 24", children: [O1.jsxs("defs", { children: [Gy, Hy, O1.jsx("clipPath", { id: "clip-left", children: O1.jsx("use", { href: "#circle-right" }) })] }), O1.jsxs("g", { children: [O1.jsx("use", { href: "#circle-left", className: "msp-shape-filled", clipPath: "url(#clip-left)" }), O1.jsx("use", { href: "#circle-left", className: "msp-shape-empty" }), O1.jsx("use", { href: "#circle-right", className: "msp-shape-empty" })] })] });
function _I() {
  return SE1;
}
var fE1 = O1.jsxs("svg", { width: "24px", height: "24px", viewBox: "0 0 24 24", children: [O1.jsxs("defs", { children: [Gy, Hy] }), O1.jsxs("g", { children: [O1.jsx("use", { href: "#circle-left", className: "msp-shape-empty" }), O1.jsx("use", { href: "#circle-right", className: "msp-shape-filled" })] })] });
function nz() {
  return fE1;
}
var hE1 = O1.jsx("svg", { width: "17px", height: "17px", viewBox: "0 0 299.463 299.463", strokeWidth: "6px", children: O1.jsx("g", { children: O1.jsx("path", { d: "M256.851,173.832v-48.201c22.916-4.918,34.151-30.668,22.556-50.771c-11.547-20.004-39.486-23.251-55.242-5.844 l-41.746-24.106C189.618,22.603,172.861,0,149.734,0c-23.132,0-39.881,22.609-32.685,44.911L75.305,69.016 C59.522,51.586,31.597,54.88,20.061,74.863c-11.63,20.163-0.298,45.862,22.557,50.769v48.2 c-22.821,4.898-34.195,30.591-22.556,50.771c11.529,19.972,39.454,23.285,55.242,5.845l41.746,24.106 c-7.199,22.308,9.559,44.911,32.685,44.911c23.132,0,39.88-22.609,32.685-44.911l41.745-24.106 c15.817,17.469,43.73,14.099,55.242-5.844c0,0,0-0.001,0.001-0.002c4.587-7.953,5.805-17.213,3.431-26.076 C279.392,185.657,269.129,176.461,256.851,173.832z M249.62,72.088c20.568,0,27.428,27.191,10.008,37.239 c-0.003,0.002-0.006,0.003-0.009,0.005c-10.04,5.81-22.85,1.762-27.877-8.475C225.206,87.548,234.938,72.088,249.62,72.088z M149.734,14.4c11.005,0,19.958,8.954,19.958,19.959c0,11.127-9.077,19.958-19.958,19.958c-10.95,0-19.958-8.9-19.958-19.958 C129.776,23.354,138.729,14.4,149.734,14.4z M39.84,109.328c-17.451-10.067-10.534-37.24,10.01-37.24 c15.311,0,24.922,16.653,17.251,29.942C61.681,111.397,49.517,114.925,39.84,109.328z M59.802,224.702 c-9.535,5.503-21.768,2.229-27.268-7.298c-7.639-13.242,1.887-29.945,17.236-29.945c0.013,0,0.027,0,0.04,0 C70.07,187.48,77.49,214.469,59.802,224.702z M149.734,285.062c-11.005,0-19.958-8.954-19.958-19.958 c0-11.127,9.077-19.958,19.958-19.958c10.954,0,19.958,8.903,19.958,19.958C169.693,276.109,160.74,285.062,149.734,285.062z M216.953,217.982l-41.727,24.095c-13.778-15.22-37.459-14.94-50.983,0l-41.728-24.096c6.196-19.289-5.541-39.835-25.498-44.149 V125.63c19.752-4.268,31.762-24.65,25.498-44.149l41.727-24.095c13.629,15.055,37.32,15.093,50.983,0l41.728,24.096 c-6.196,19.29,5.534,39.835,25.498,44.149v48.202C222.61,178.123,210.721,198.581,216.953,217.982z M266.935,217.404 c-5.501,9.528-17.732,12.802-27.261,7.302c-17.682-10.23-10.301-37.247,10.032-37.247 C264.984,187.459,274.602,204.112,266.935,217.404z" }) }) });
function TV0() {
  return hE1;
}
var bE1 = O1.jsx("svg", { width: "24px", height: "24px", viewBox: "0 0 24 24", strokeWidth: "0.1px", children: O1.jsx("path", { d: "M21,16.5C21,16.88 20.79,17.21 20.47,17.38L12.57,21.82C12.41,21.94 12.21,22 12,22C11.79,22 11.59,21.94 11.43,21.82L3.53,17.38C3.21,17.21 3,16.88 3,16.5V7.5C3,7.12 3.21,6.79 3.53,6.62L11.43,2.18C11.59,2.06 11.79,2 12,2C12.21,2 12.41,2.06 12.57,2.18L20.47,6.62C20.79,6.79 21,7.12 21,7.5V16.5M12,4.15L6.04,7.5L12,10.85L17.96,7.5L12,4.15M5,15.91L11,19.29V12.58L5,9.21V15.91M19,15.91V9.21L13,12.58V19.29L19,15.91Z" }) });
function VI() {
  return bE1;
}
var R58 = O1.jsx("svg", { width: "24px", height: "24px", viewBox: "0 0 24 24", strokeWidth: "0.1px", children: O1.jsx("path", { d: "M17,22V20H20V17H22V20.5C22,20.89 21.84,21.24 21.54,21.54C21.24,21.84 20.89,22 20.5,22H17M7,22H3.5C3.11,22 2.76,21.84 2.46,21.54C2.16,21.24 2,20.89 2,20.5V17H4V20H7V22M17,2H20.5C20.89,2 21.24,2.16 21.54,2.46C21.84,2.76 22,3.11 22,3.5V7H20V4H17V2M7,2V4H4V7H2V3.5C2,3.11 2.16,2.76 2.46,2.46C2.76,2.16 3.11,2 3.5,2H7M13,17.25L17,14.95V10.36L13,12.66V17.25M12,10.92L16,8.63L12,6.28L8,8.63L12,10.92M7,14.95L11,17.25V12.66L7,10.36V14.95M18.23,7.59C18.73,7.91 19,8.34 19,8.91V15.23C19,15.8 18.73,16.23 18.23,16.55L12.75,19.73C12.25,20.05 11.75,20.05 11.25,19.73L5.77,16.55C5.27,16.23 5,15.8 5,15.23V8.91C5,8.34 5.27,7.91 5.77,7.59L11.25,4.41C11.5,4.28 11.75,4.22 12,4.22C12.25,4.22 12.5,4.28 12.75,4.41L18.23,7.59Z" }) });
var E58 = O1.jsx("svg", { width: "24px", height: "24px", viewBox: "0 0 24 24", strokeWidth: "0.1px", children: O1.jsx("path", { d: "M16,4L9,8.04V15.96L16,20L23,15.96V8.04M16,6.31L19.8,8.5L16,10.69L12.21,8.5M0,7V9H7V7M11,10.11L15,12.42V17.11L11,14.81M21,10.11V14.81L17,17.11V12.42M2,11V13H7V11M4,15V17H7V15" }) });
var xE1 = O1.jsx("svg", { width: "24px", height: "24px", viewBox: "0 0 24 24", children: O1.jsx("path", { d: "M10.07,14.27C10.57,14.03 11.16,14.25 11.4,14.75L13.7,19.74L15.5,18.89L13.19,13.91C12.95,13.41 13.17,12.81 13.67,12.58L13.95,12.5L16.25,12.05L8,5.12V15.9L9.82,14.43L10.07,14.27M13.64,21.97C13.14,22.21 12.54,22 12.31,21.5L10.13,16.76L7.62,18.78C7.45,18.92 7.24,19 7,19A1,1 0 0,1 6,18V3A1,1 0 0,1 7,2C7.24,2 7.47,2.09 7.64,2.23L7.65,2.22L19.14,11.86C19.57,12.22 19.62,12.85 19.27,13.27C19.12,13.45 18.91,13.57 18.7,13.61L15.54,14.23L17.74,18.96C18,19.46 17.76,20.05 17.26,20.28L13.64,21.97Z" }) });
function yE1() {
  return xE1;
}
var O58 = O1.jsx("svg", { width: "24px", height: "24px", viewBox: "0 0 24 24", strokeWidth: "0.1px", children: O1.jsx("path", { fill: "currentColor", d: "M14,2H6A2,2 0 0,0 4,4V20A2,2 0 0,0 6,22H18A2,2 0 0,0 20,20V8L14,2M18,20H6V4H13V9H18V20Z" }) });
var z58 = O1.jsx("svg", { width: "24px", height: "24px", viewBox: "0 0 24 24", strokeWidth: "0.1px", children: O1.jsx("path", { fill: "currentColor", d: "M20,11H23V13H20V11M1,11H4V13H1V11M13,1V4H11V1H13M4.92,3.5L7.05,5.64L5.63,7.05L3.5,4.93L4.92,3.5M16.95,5.63L19.07,3.5L20.5,4.93L18.37,7.05L16.95,5.63M12,6A6,6 0 0,1 18,12C18,14.22 16.79,16.16 15,17.2V19A1,1 0 0,1 14,20H10A1,1 0 0,1 9,19V17.2C7.21,16.16 6,14.22 6,12A6,6 0 0,1 12,6M14,21V22A1,1 0 0,1 13,23H11A1,1 0 0,1 10,22V21H14M11,18H13V15.87C14.73,15.43 16,13.86 16,12A4,4 0 0,0 12,8A4,4 0 0,0 8,12C8,13.86 9.27,15.43 11,15.87V18Z" }) });
var gE1 = O1.jsx("svg", { width: "24px", height: "24px", viewBox: "0 0 24 24", children: O1.jsx("path", { fill: "currentColor", d: "M7.5,5.6L5,7L6.4,4.5L5,2L7.5,3.4L10,2L8.6,4.5L10,7L7.5,5.6M19.5,15.4L22,14L20.6,16.5L22,19L19.5,17.6L17,19L18.4,16.5L17,14L19.5,15.4M22,2L20.6,4.5L22,7L19.5,5.6L17,7L18.4,4.5L17,2L19.5,3.4L22,2M13.34,12.78L15.78,10.34L13.66,8.22L11.22,10.66L13.34,12.78M14.37,7.29L16.71,9.63C17.1,10 17.1,10.65 16.71,11.04L5.04,22.71C4.65,23.1 4,23.1 3.63,22.71L1.29,20.37C0.9,20 0.9,19.35 1.29,18.96L12.96,7.29C13.35,6.9 14,6.9 14.37,7.29Z" }) });
function _V0() {
  return gE1;
}
var mE1 = O1.jsx("svg", { width: "24px", height: "24px", viewBox: "0 0 24 24", strokeWidth: "0.1px", children: O1.jsx("path", { d: "M3 17.25V21H6.75L17.81 9.93L14.06 6.18L3 17.25M22.61 18.36L18.36 22.61L13.16 17.41L14.93 15.64L15.93 16.64L18.4 14.16L19.82 15.58L18.36 17L19.42 18L20.84 16.6L22.61 18.36M6.61 10.83L1.39 5.64L5.64 1.39L7.4 3.16L4.93 5.64L6 6.7L8.46 4.22L9.88 5.64L8.46 7.05L9.46 8.05L6.61 10.83M20.71 7C21.1 6.61 21.1 6 20.71 5.59L18.37 3.29C18 2.9 17.35 2.9 16.96 3.29L15.12 5.12L18.87 8.87L20.71 7Z" }) });
function VV0() {
  return mE1;
}
var dE1 = O1.jsx("svg", { width: "24px", height: "24px", viewBox: "0 0 24 24", children: O1.jsx("path", { d: "M22 11V3h-7v3H9V3H2v8h7V8h2v10h4v3h7v-8h-7v3h-2V8h2v3h7zM7 9H4V5h3v4zm10 6h3v4h-3v-4zm0-10h3v4h-3V5z" }) });
function J10() {
  return dE1;
}
var pE1 = O1.jsx("svg", { width: "24px", height: "24px", viewBox: "0 0 24 24", children: O1.jsx("path", { d: "M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z" }) });
function hH() {
  return pE1;
}
var uE1 = O1.jsx("svg", { width: "24px", height: "24px", viewBox: "0 0 24 24", children: O1.jsx("path", { d: "M20 12l-1.41-1.41L13 16.17V4h-2v12.17l-5.58-5.59L4 12l8 8 8-8z" }) });
function IV0() {
  return cE1;
}
var cE1 = O1.jsx("svg", { width: "24px", height: "24px", viewBox: "0 0 24 24", children: O1.jsx("path", { d: "M15 2c-2.71 0-5.05 1.54-6.22 3.78-1.28.67-2.34 1.72-3 3C3.54 9.95 2 12.29 2 15c0 3.87 3.13 7 7 7 2.71 0 5.05-1.54 6.22-3.78 1.28-.67 2.34-1.72 3-3C20.46 14.05 22 11.71 22 9c0-3.87-3.13-7-7-7M9 20c-2.76 0-5-2.24-5-5 0-1.12.37-2.16 1-3 0 3.87 3.13 7 7 7-.84.63-1.88 1-3 1m3-3c-2.76 0-5-2.24-5-5 0-1.12.37-2.16 1-3 0 3.86 3.13 6.99 7 7-.84.63-1.88 1-3 1m4.7-3.3c-.53.19-1.1.3-1.7.3-2.76 0-5-2.24-5-5 0-.6.11-1.17.3-1.7.53-.19 1.1-.3 1.7-.3 2.76 0 5 2.24 5 5 0 .6-.11 1.17-.3 1.7M19 12c0-3.86-3.13-6.99-7-7 .84-.63 1.87-1 3-1 2.76 0 5 2.24 5 5 0 1.12-.37 2.16-1 3" }) });
function zE() {
  return uE1;
}
var lE1 = O1.jsx("svg", { width: "24px", height: "24px", viewBox: "0 0 24 24", children: O1.jsx("path", { d: "M7 10l5 5 5-5z" }) });
function JW() {
  return lE1;
}
var nE1 = O1.jsx("svg", { width: "24px", height: "24px", viewBox: "0 0 24 24", children: O1.jsx("path", { d: "M10 17l5-5-5-5v10z" }) });
function $W() {
  return nE1;
}
var iE1 = O1.jsx("svg", { width: "24px", height: "24px", viewBox: "0 0 24 24", children: O1.jsx("path", { d: "M4 12l1.41 1.41L11 7.83V20h2V7.83l5.58 5.59L20 12l-8-8-8 8z" }) });
function DE() {
  return iE1;
}
var oE1 = O1.jsx("svg", { width: "24px", height: "24px", viewBox: "0 0 24 24", children: O1.jsx("path", { d: "M12 6v3l4-4-4-4v3c-4.42 0-8 3.58-8 8 0 1.57.46 3.03 1.24 4.26L6.7 14.8c-.45-.83-.7-1.79-.7-2.8 0-3.31 2.69-6 6-6zm6.76 1.74L17.3 9.2c.44.84.7 1.79.7 2.8 0 3.31-2.69 6-6 6v-3l-4 4 4 4v-3c4.42 0 8-3.58 8-8 0-1.57-.46-3.03-1.24-4.26z" }) });
function PV0() {
  return oE1;
}
var sE1 = O1.jsx("svg", { width: "24px", height: "24px", viewBox: "0 0 24 24", children: O1.jsx("path", { d: "M19 12h-2v3h-3v2h5zM7 9h3V7H5v5h2zm14-6H3c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h18c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2m0 16.01H3V4.99h18z" }) });
function CV0() {
  return sE1;
}
var aE1 = O1.jsx("svg", { width: "24px", height: "24px", viewBox: "0 0 24 24", children: O1.jsx("path", { d: "M6 13c-.55 0-1 .45-1 1s.45 1 1 1 1-.45 1-1-.45-1-1-1zm0 4c-.55 0-1 .45-1 1s.45 1 1 1 1-.45 1-1-.45-1-1-1zm0-8c-.55 0-1 .45-1 1s.45 1 1 1 1-.45 1-1-.45-1-1-1zm-3 .5c-.28 0-.5.22-.5.5s.22.5.5.5.5-.22.5-.5-.22-.5-.5-.5zM6 5c-.55 0-1 .45-1 1s.45 1 1 1 1-.45 1-1-.45-1-1-1zm15 5.5c.28 0 .5-.22.5-.5s-.22-.5-.5-.5-.5.22-.5.5.22.5.5.5zM14 7c.55 0 1-.45 1-1s-.45-1-1-1-1 .45-1 1 .45 1 1 1zm0-3.5c.28 0 .5-.22.5-.5s-.22-.5-.5-.5-.5.22-.5.5.22.5.5.5zm-11 10c-.28 0-.5.22-.5.5s.22.5.5.5.5-.22.5-.5-.22-.5-.5-.5zm7 7c-.28 0-.5.22-.5.5s.22.5.5.5.5-.22.5-.5-.22-.5-.5-.5zm0-17c.28 0 .5-.22.5-.5s-.22-.5-.5-.5-.5.22-.5.5.22.5.5.5zM10 7c.55 0 1-.45 1-1s-.45-1-1-1-1 .45-1 1 .45 1 1 1zm0 5.5c-.83 0-1.5.67-1.5 1.5s.67 1.5 1.5 1.5 1.5-.67 1.5-1.5-.67-1.5-1.5-1.5zm8 .5c-.55 0-1 .45-1 1s.45 1 1 1 1-.45 1-1-.45-1-1-1zm0 4c-.55 0-1 .45-1 1s.45 1 1 1 1-.45 1-1-.45-1-1-1zm0-8c-.55 0-1 .45-1 1s.45 1 1 1 1-.45 1-1-.45-1-1-1zm0-4c-.55 0-1 .45-1 1s.45 1 1 1 1-.45 1-1-.45-1-1-1zm3 8.5c-.28 0-.5.22-.5.5s.22.5.5.5.5-.22.5-.5-.22-.5-.5-.5zM14 17c-.55 0-1 .45-1 1s.45 1 1 1 1-.45 1-1-.45-1-1-1zm0 3.5c-.28 0-.5.22-.5.5s.22.5.5.5.5-.22.5-.5-.22-.5-.5-.5zm-4-12c-.83 0-1.5.67-1.5 1.5s.67 1.5 1.5 1.5 1.5-.67 1.5-1.5-.67-1.5-1.5-1.5zm0 8.5c-.55 0-1 .45-1 1s.45 1 1 1 1-.45 1-1-.45-1-1-1zm4-4.5c-.83 0-1.5.67-1.5 1.5s.67 1.5 1.5 1.5 1.5-.67 1.5-1.5-.67-1.5-1.5-1.5zm0-4c-.83 0-1.5.67-1.5 1.5s.67 1.5 1.5 1.5 1.5-.67 1.5-1.5-.67-1.5-1.5-1.5z" }) });
function $10() {
  return aE1;
}
var rE1 = O1.jsx("svg", { width: "24px", height: "24px", viewBox: "0 0 24 24", children: O1.jsx("path", { d: "M15 7v12.97l-4.21-1.81-.79-.34-.79.34L5 19.97V7h10m4-6H8.99C7.89 1 7 1.9 7 3h10c1.1 0 2 .9 2 2v13l2 1V3c0-1.1-.9-2-2-2zm-4 4H5c-1.1 0-2 .9-2 2v16l7-3 7 3V7c0-1.1-.9-2-2-2z" }) });
function wU() {
  return rE1;
}
var tE1 = O1.jsx("svg", { width: "24px", height: "24px", viewBox: "0 0 24 24", children: O1.jsx("path", { d: "M7 14c-1.66 0-3 1.34-3 3 0 1.31-1.16 2-2 2 .92 1.22 2.49 2 4 2 2.21 0 4-1.79 4-4 0-1.66-1.34-3-3-3zm13.71-9.37l-1.34-1.34a.9959.9959 0 00-1.41 0L9 12.25 11.75 15l8.96-8.96c.39-.39.39-1.02 0-1.41z" }) });
function Ny() {
  return tE1;
}
var eE1 = O1.jsx("svg", { width: "24px", height: "24px", viewBox: "0 0 24 24", children: O1.jsx("path", { d: "M22.61 18.99l-9.08-9.08c.93-2.34.45-5.1-1.44-7C9.79.61 6.21.4 3.66 2.26L7.5 6.11 6.08 7.52 2.25 3.69C.39 6.23.6 9.82 2.9 12.11c1.86 1.86 4.57 2.35 6.89 1.48l9.11 9.11c.39.39 1.02.39 1.41 0l2.3-2.3c.4-.38.4-1.01 0-1.41zm-3 1.6l-9.46-9.46c-.61.45-1.29.72-2 .82-1.36.2-2.79-.21-3.83-1.25C3.37 9.76 2.93 8.5 3 7.26l3.09 3.09 4.24-4.24-3.09-3.09c1.24-.07 2.49.37 3.44 1.31 1.08 1.08 1.49 2.57 1.24 3.96-.12.71-.42 1.37-.88 1.96l9.45 9.45-.88.89z" }) });
function kV0() {
  return eE1;
}
var ZO1 = O1.jsx("svg", { width: "24px", height: "24px", viewBox: "0 0 24 24", children: O1.jsx("path", { d: "M22.7 19l-9.1-9.1c.9-2.3.4-5-1.5-6.9-2-2-5-2.4-7.4-1.3L9 6 6 9 1.6 4.7C.4 7.1.9 10.1 2.9 12.1c1.9 1.9 4.6 2.4 6.9 1.5l9.1 9.1c.4.4 1 .4 1.4 0l2.3-2.3c.5-.4.5-1.1.1-1.4z" }) });
function vV0() {
  return ZO1;
}
var JO1 = O1.jsx("svg", { width: "24px", height: "24px", viewBox: "0 0 24 24", children: O1.jsx("path", { d: "M14.25 2.26l-.08-.04-.01.02C13.46 2.09 12.74 2 12 2 6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10c0-4.75-3.31-8.72-7.75-9.74zM19.41 9h-7.99l2.71-4.7c2.4.66 4.35 2.42 5.28 4.7zM13.1 4.08L10.27 9l-1.15 2L6.4 6.3C7.84 4.88 9.82 4 12 4c.37 0 .74.03 1.1.08zM5.7 7.09L8.54 12l1.15 2H4.26C4.1 13.36 4 12.69 4 12c0-1.85.64-3.55 1.7-4.91zM4.59 15h7.98l-2.71 4.7c-2.4-.67-4.34-2.42-5.27-4.7zm6.31 4.91L14.89 13l2.72 4.7C16.16 19.12 14.18 20 12 20c-.38 0-.74-.04-1.1-.09zm7.4-3l-4-6.91h5.43c.17.64.27 1.31.27 2 0 1.85-.64 3.55-1.7 4.91z" }) });
function SV0() {
  return JO1;
}
var $O1 = O1.jsx("svg", { width: "24px", height: "24px", viewBox: "0 0 24 24", children: O1.jsx("path", { d: "M9.4 10.5l4.77-8.26C13.47 2.09 12.75 2 12 2c-2.4 0-4.6.85-6.32 2.25l3.66 6.35.06-.1zM21.54 9c-.92-2.92-3.15-5.26-6-6.34L11.88 9h9.66zm.26 1h-7.49l.29.5 4.76 8.25C21 16.97 22 14.61 22 12c0-.69-.07-1.35-.2-2zM8.54 12l-3.9-6.75C3.01 7.03 2 9.39 2 12c0 .69.07 1.35.2 2h7.49l-1.15-2zm-6.08 3c.92 2.92 3.15 5.26 6 6.34L12.12 15H2.46zm11.27 0l-3.9 6.76c.7.15 1.42.24 2.17.24 2.4 0 4.6-.85 6.32-2.25l-3.66-6.35-.93 1.6z" }) });
function fV0() {
  return $O1;
}
var XO1 = O1.jsx("svg", { width: "24px", height: "24px", viewBox: "0 0 24 24", children: O1.jsx("path", { d: "M12 2C6.47 2 2 6.47 2 12s4.47 10 10 10 10-4.47 10-10S17.53 2 12 2zm0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8zm3.59-13L12 10.59 8.41 7 7 8.41 10.59 12 7 15.59 8.41 17 12 13.41 15.59 17 17 15.59 13.41 12 17 8.41z" }) });
function II() {
  return XO1;
}
var YO1 = O1.jsx("svg", { width: "24px", height: "24px", viewBox: "0 0 24 24", children: O1.jsx("path", { d: "M12 2C6.47 2 2 6.47 2 12s4.47 10 10 10 10-4.47 10-10S17.53 2 12 2zm5 13.59L15.59 17 12 13.41 8.41 17 7 15.59 10.59 12 7 8.41 8.41 7 12 10.59 15.59 7 17 8.41 13.41 12 17 15.59z" }) });
function qy() {
  return YO1;
}
var QO1 = O1.jsx("svg", { width: "24px", height: "24px", viewBox: "0 0 24 24", children: O1.jsx("path", { d: "M12 8c-2.21 0-4 1.79-4 4s1.79 4 4 4 4-1.79 4-4-1.79-4-4-4zm-7 7H3v4c0 1.1.9 2 2 2h4v-2H5v-4zM5 5h4V3H5c-1.1 0-2 .9-2 2v4h2V5zm14-2h-4v2h4v4h2V5c0-1.1-.9-2-2-2zm0 16h-4v2h4c1.1 0 2-.9 2-2v-4h-2v4z" }) });
function hV0() {
  return QO1;
}
var WO1 = O1.jsx("svg", { width: "24px", height: "24px", viewBox: "0 0 24 24", children: O1.jsx("path", { d: "M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z" }) });
function xK() {
  return WO1;
}
var KO1 = O1.jsx("svg", { width: "24px", height: "24px", viewBox: "0 0 24 24", children: O1.jsx("path", { d: "M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z" }) });
function X10() {
  return KO1;
}
var GO1 = O1.jsx("svg", { width: "24px", height: "24px", viewBox: "0 0 24 24", children: O1.jsx("path", { d: "M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z" }) });
function cW() {
  return GO1;
}
var HO1 = O1.jsx("svg", { width: "24px", height: "24px", viewBox: "0 0 24 24", children: O1.jsx("path", { d: "M19.35 10.04C18.67 6.59 15.64 4 12 4 9.11 4 6.6 5.64 5.35 8.04 2.34 8.36 0 10.91 0 14c0 3.31 2.69 6 6 6h13c2.76 0 5-2.24 5-5 0-2.64-2.05-4.78-4.65-4.96zM14 13v4h-4v-4H7l5-5 5 5h-3z" }) });
function bV0() {
  return HO1;
}
var NO1 = O1.jsx("svg", { width: "24px", height: "24px", viewBox: "0 0 24 24", children: O1.jsx("path", { d: "M9.4 16.6L4.8 12l4.6-4.6L8 6l-6 6 6 6 1.4-1.4zm5.2 0l4.6-4.6-4.6-4.6L16 6l6 6-6 6-1.4-1.4z" }) });
function xV0() {
  return NO1;
}
var qO1 = O1.jsx("svg", { width: "24px", height: "24px", viewBox: "0 0 24 24", children: O1.jsx("path", { d: "M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm-1 4H8c-1.1 0-1.99.9-1.99 2L6 21c0 1.1.89 2 1.99 2H19c1.1 0 2-.9 2-2V11l-6-6zM8 21V7h6v5h5v9H8z" }) });
function yV0() {
  return qO1;
}
var FO1 = O1.jsx("svg", { width: "24px", height: "24px", viewBox: "0 0 24 24", children: O1.jsx("path", { d: "M17 15h2V7c0-1.1-.9-2-2-2H9v2h8v8zM7 17V1H5v4H1v2h4v10c0 1.1.9 2 2 2h10v4h2v-4h4v-2H7z" }) });
function gV0() {
  return FO1;
}
var UO1 = O1.jsx("svg", { width: "24px", height: "24px", viewBox: "0 0 24 24", children: O1.jsx("path", { d: "M3 5v4h2V5h4V3H5c-1.1 0-2 .9-2 2zm2 10H3v4c0 1.1.9 2 2 2h4v-2H5v-4zm14 4h-4v2h4c1.1 0 2-.9 2-2v-4h-2v4zm0-16h-4v2h4v4h2V5c0-1.1-.9-2-2-2z" }) });
function mV0() {
  return UO1;
}
var LO1 = O1.jsx("svg", { width: "24px", height: "24px", viewBox: "0 0 24 24", children: O1.jsx("path", { d: "M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm0 16H5V5h14v14zm-5.04-6.71l-2.75 3.54-1.96-2.36L6.5 17h11l-3.54-4.71z" }) });
function dV0() {
  return LO1;
}
var RO1 = O1.jsx("svg", { width: "24px", height: "24px", viewBox: "0 0 24 24", children: O1.jsx("path", { d: "M16 9v10H8V9h8m-1.5-6h-5l-1 1H5v2h14V4h-3.5l-1-1zM18 7H6v12c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7z" }) });
function GX() {
  return RO1;
}
var D58 = O1.jsx("svg", { width: "24px", height: "24px", viewBox: "0 0 24 24", children: O1.jsx("path", { d: "M6 19c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7H6v12zM19 4h-3.5l-1-1h-5l-1 1H5v2h14V4z" }) });
var EO1 = O1.jsx("svg", { width: "24px", height: "24px", viewBox: "0 0 24 24", children: O1.jsx("path", { d: "M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-2h2v2zm0-4h-2V7h2v6z" }) });
function Y10() {
  return EO1;
}
var M58 = O1.jsx("svg", { width: "24px", height: "24px", viewBox: "0 0 24 24", children: O1.jsx("path", { d: "M20.5 11H19V7c0-1.1-.9-2-2-2h-4V3.5C13 2.12 11.88 1 10.5 1S8 2.12 8 3.5V5H4c-1.1 0-1.99.9-1.99 2v3.8H3.5c1.49 0 2.7 1.21 2.7 2.7s-1.21 2.7-2.7 2.7H2V20c0 1.1.9 2 2 2h3.8v-1.5c0-1.49 1.21-2.7 2.7-2.7 1.49 0 2.7 1.21 2.7 2.7V22H17c1.1 0 2-.9 2-2v-4h1.5c1.38 0 2.5-1.12 2.5-2.5S21.88 11 20.5 11z" }) });
var OO1 = O1.jsx("svg", { width: "24px", height: "24px", viewBox: "0 0 24 24", strokeWidth: "0.1px", children: O1.jsx("path", { d: "M3 13h2v-2H3v2zm0 4h2v-2H3v2zm2 4v-2H3c0 1.1.89 2 2 2zM3 9h2V7H3v2zm12 12h2v-2h-2v2zm4-18H9c-1.11 0-2 .9-2 2v10c0 1.1.89 2 2 2h10c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm0 12H9V5h10v10zm-8 6h2v-2h-2v2zm-4 0h2v-2H7v2z" }) });
function zO1() {
  return OO1;
}
var A58 = O1.jsx("svg", { width: "24px", height: "24px", viewBox: "0 0 24 24", children: O1.jsx("path", { d: "M5 16h3v3h2v-5H5zm3-8H5v2h5V5H8zm6 11h2v-3h3v-2h-5zm2-11V5h-2v5h5V8z" }) });
var DO1 = O1.jsx("svg", { width: "24px", height: "24px", viewBox: "0 0 24 24", children: O1.jsx("path", { d: "M7 14H5v5h5v-2H7v-3zm-2-4h2V7h3V5H5v5zm12 7h-3v2h5v-5h-2v3zM14 5v2h3v3h2V5h-5z" }) });
function pV0() {
  return DO1;
}
var MO1 = O1.jsx("svg", { width: "24px", height: "24px", viewBox: "0 0 24 24", children: O1.jsx("path", { d: "M19 9h-4V3H9v6H5l7 7 7-7zM5 18v2h14v-2H5z" }) });
function PI() {
  return MO1;
}
var AO1 = O1.jsx("svg", { width: "24px", height: "24px", viewBox: "0 0 24 24", children: O1.jsx("path", { d: "M11 18h2v-2h-2v2zm1-16C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8zm0-14c-2.21 0-4 1.79-4 4h2c0-1.1.9-2 2-2s2 .9 2 2c0 2-3 1.75-3 5h2c0-2.25 3-2.5 3-5 0-2.21-1.79-4-4-4z" }) });
function OQ() {
  return AO1;
}
var BO1 = O1.jsx("svg", { width: "24px", height: "24px", viewBox: "0 0 24 24", children: O1.jsx("path", { d: "M12 5.69l5 4.5V18h-2v-6H9v6H7v-7.81l5-4.5M12 3L2 12h3v8h6v-6h2v6h6v-8h3L12 3z" }) });
function CI() {
  return BO1;
}
var B58 = O1.jsx("svg", { width: "24px", height: "24px", viewBox: "0 0 24 24", children: O1.jsx("path", { d: "M19 19H5V5h7V3H5c-1.11 0-2 .9-2 2v14c0 1.1.89 2 2 2h14c1.1 0 2-.9 2-2v-7h-2v7zM14 3v2h3.59l-9.83 9.83 1.41 1.41L19 6.41V10h2V3h-7z" }) });
var wO1 = O1.jsx("svg", { width: "24px", height: "24px", viewBox: "0 0 24 24", children: O1.jsx("path", { d: "M19.5 9.5c-1.03 0-1.9.62-2.29 1.5h-2.92c-.39-.88-1.26-1.5-2.29-1.5s-1.9.62-2.29 1.5H6.79c-.39-.88-1.26-1.5-2.29-1.5C3.12 9.5 2 10.62 2 12s1.12 2.5 2.5 2.5c1.03 0 1.9-.62 2.29-1.5h2.92c.39.88 1.26 1.5 2.29 1.5s1.9-.62 2.29-1.5h2.92c.39.88 1.26 1.5 2.29 1.5 1.38 0 2.5-1.12 2.5-2.5s-1.12-2.5-2.5-2.5z" }) });
function jO1() {
  return wO1;
}
var TO1 = O1.jsx("svg", { width: "24px", height: "24px", viewBox: "0 0 24 24", children: O1.jsx("path", { d: "M6 10c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm12 0c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm-6 0c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2z" }) });
function ME() {
  return TO1;
}
var _O1 = O1.jsx("svg", { width: "24px", height: "24px", viewBox: "0 0 24 24", children: O1.jsx("path", { d: "M15.41 7.41L14 6l-6 6 6 6 1.41-1.41L10.83 12z" }) });
function Q10() {
  return _O1;
}
var VO1 = O1.jsx("svg", { width: "24px", height: "24px", viewBox: "0 0 24 24", children: O1.jsx("path", { d: "M10 6L8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z" }) });
function W10() {
  return VO1;
}
var IO1 = O1.jsx("svg", { width: "24px", height: "24px", viewBox: "0 0 24 24", children: O1.jsx("path", { d: "M19 4H5c-1.11 0-2 .9-2 2v12c0 1.1.89 2 2 2h4v-2H5V8h14v10h-4v2h4c1.1 0 2-.9 2-2V6c0-1.1-.89-2-2-2zm-7 6l-4 4h3v6h2v-6h3l-4-4z" }) });
function uV0() {
  return IO1;
}
var PO1 = O1.jsx("svg", { width: "24px", height: "24px", viewBox: "0 0 24 24", children: O1.jsx("path", { d: "M8 5v14l11-7z" }) });
function Fy() {
  return PO1;
}
var CO1 = O1.jsx("svg", { width: "24px", height: "24px", viewBox: "0 0 24 24", children: O1.jsx("path", { d: "M17.65 6.35C16.2 4.9 14.21 4 12 4c-4.42 0-7.99 3.58-7.99 8s3.57 8 7.99 8c3.73 0 6.84-2.55 7.73-6h-2.08c-.82 2.33-3.04 4-5.65 4-3.31 0-6-2.69-6-6s2.69-6 6-6c1.66 0 3.14.69 4.22 1.78L13 11h7V4l-2.35 2.35z" }) });
function iz() {
  return CO1;
}
var kO1 = O1.jsx("svg", { width: "24px", height: "24px", viewBox: "0 0 24 24", children: O1.jsx("path", { d: "M19 13H5v-2h14v2z" }) });
function kI() {
  return kO1;
}
var vO1 = O1.jsx("svg", { width: "24px", height: "24px", viewBox: "0 0 24 24", children: O1.jsx("path", { d: "M13 3c-4.97 0-9 4.03-9 9H1l3.89 3.89.07.14L9 12H6c0-3.87 3.13-7 7-7s7 3.13 7 7-3.13 7-7 7c-1.93 0-3.68-.79-4.94-2.06l-1.42 1.42C8.27 19.99 10.51 21 13 21c4.97 0 9-4.03 9-9s-4.03-9-9-9zm-1 5v5l4.28 2.54.72-1.21-3.5-2.08V8H12z" }) });
function vI() {
  return vO1;
}
var SO1 = O1.jsx("svg", { width: "24px", height: "24px", viewBox: "0 0 24 24", strokeWidth: "0.1px", children: O1.jsx("path", { d: "M17 3H5c-1.11 0-2 .9-2 2v14c0 1.1.89 2 2 2h14c1.1 0 2-.9 2-2V7l-4-4zm2 16H5V5h11.17L19 7.83V19zm-7-7c-1.66 0-3 1.34-3 3s1.34 3 3 3 3-1.34 3-3-1.34-3-3-3zM6 6h9v4H6z" }) });
function Uy() {
  return SO1;
}
var fO1 = O1.jsxs("svg", { width: "24px", height: "24px", viewBox: "0 0 24 24", children: [O1.jsx("circle", { cx: "7", cy: "14", r: "3" }), O1.jsx("circle", { cx: "11", cy: "6", r: "3" }), O1.jsx("circle", { cx: "16.6", cy: "17.6", r: "3" })] });
function hO1() {
  return fO1;
}
var w58 = O1.jsx("svg", { width: "24px", height: "24px", viewBox: "0 0 24 24", children: O1.jsx("path", { d: "M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z" }) });
var bO1 = O1.jsx("svg", { width: "24px", height: "24px", viewBox: "0 0 24 24", children: O1.jsx("path", { d: "M6 6h2v12H6zm3.5 6l8.5 6V6z" }) });
function cV0() {
  return bO1;
}
var xO1 = O1.jsx("svg", { width: "24px", height: "24px", viewBox: "0 0 24 24", children: O1.jsx("path", { d: "M6 6h12v12H6z" }) });
function Ly() {
  return xO1;
}
var yO1 = O1.jsx("svg", { width: "24px", height: "24px", viewBox: "0 0 24 24", children: O1.jsx("path", { d: "M4 6h16v2H4zm2-4h12v2H6zm14 8H4c-1.1 0-2 .9-2 2v8c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2v-8c0-1.1-.9-2-2-2zm0 10H4v-8h16v8zm-10-7.27v6.53L16 16z" }) });
function lV0() {
  return yO1;
}
var gO1 = O1.jsx("svg", { width: "24px", height: "24px", viewBox: "0 0 24 24", children: O1.jsx("path", { d: "M6.99 11L3 15l3.99 4v-3H14v-2H6.99v-3zM21 9l-3.99-4v3H10v2h7.01v3L21 9z" }) });
function nV0() {
  return gO1;
}
var j58 = O1.jsx("svg", { width: "24px", height: "24px", viewBox: "0 0 24 24", children: O1.jsx("path", { d: "M21 4H7V2H5v20h2v-8h14l-2-5zm-6 5c0 1.1-.9 2-2 2s-2-.9-2-2 .9-2 2-2 2 .9 2 2" }) });
var mO1 = O1.jsx("svg", { width: "24px", height: "24px", viewBox: "0 0 24 24", children: O1.jsx("path", { d: "M3 17v2h6v-2H3zM3 5v2h10V5H3zm10 16v-2h8v-2h-8v-2h-2v6h2zM7 9v2H3v2h4v2h2V9H7zm14 4v-2H11v2h10zm-6-4h2V7h4V5h-4V3h-2v6z" }) });
function lX() {
  return mO1;
}
var dO1 = O1.jsx("svg", { width: "24px", height: "24px", viewBox: "0 0 24 24", children: O1.jsx("path", { d: "M12 6c3.79 0 7.17 2.13 8.82 5.5-.59 1.22-1.42 2.27-2.41 3.12l1.41 1.41c1.39-1.23 2.49-2.77 3.18-4.53C21.27 7.11 17 4 12 4c-1.27 0-2.49.2-3.64.57l1.65 1.65C10.66 6.09 11.32 6 12 6zm-1.07 1.14L13 9.21c.57.25 1.03.71 1.28 1.28l2.07 2.07c.08-.34.14-.7.14-1.07C16.5 9.01 14.48 7 12 7c-.37 0-.72.05-1.07.14zM2.01 3.87l2.68 2.68C3.06 7.83 1.77 9.53 1 11.5 2.73 15.89 7 19 12 19c1.52 0 2.98-.29 4.32-.82l3.42 3.42 1.41-1.41L3.42 2.45 2.01 3.87zm7.5 7.5l2.61 2.61c-.04.01-.08.02-.12.02-1.38 0-2.5-1.12-2.5-2.5 0-.05.01-.08.01-.13zm-3.4-3.4l1.75 1.75c-.23.55-.36 1.15-.36 1.78 0 2.48 2.02 4.5 4.5 4.5.63 0 1.23-.13 1.77-.36l.98.98c-.88.24-1.8.38-2.75.38-3.79 0-7.17-2.13-8.82-5.5.7-1.43 1.72-2.61 2.93-3.53z" }) }), T58 = O1.jsx("svg", { width: "24px", height: "24px", viewBox: "0 0 24 24", children: O1.jsx("path", { d: "M20 2H4c-1.1 0-1.99.9-1.99 2L2 22l4-4h14c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2M6 9h12v2H6zm8 5H6v-2h8zm4-6H6V6h12z" }) });
var _58 = O1.jsx("svg", { width: "24px", height: "24px", viewBox: "0 0 24 24", children: O1.jsx("path", { d: "M4 4h16v12H5.17L4 17.17zm0-2c-1.1 0-1.99.9-1.99 2L2 22l4-4h14c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2zm2 10h8v2H6zm0-3h12v2H6zm0-3h12v2H6z" }) });
var V58 = O1.jsx("svg", { width: "24px", height: "24px", viewBox: "0 0 24 24", children: O1.jsx("path", { d: "M19 3H5c-1.11 0-2 .9-2 2v14c0 1.1.89 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2m-2 10h-4v4h-2v-4H7v-2h4V7h2v4h4z" }) });
var I58 = O1.jsx("svg", { width: "24px", height: "24px", viewBox: "0 0 24 24", children: O1.jsx("path", { d: "M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2m-2 10H7v-2h10z" }) });
function yK() {
  return dO1;
}
var pO1 = O1.jsx("svg", { width: "24px", height: "24px", viewBox: "0 0 24 24", children: O1.jsx("path", { d: "M12 6c3.79 0 7.17 2.13 8.82 5.5C19.17 14.87 15.79 17 12 17s-7.17-2.13-8.82-5.5C4.83 8.13 8.21 6 12 6m0-2C7 4 2.73 7.11 1 11.5 2.73 15.89 7 19 12 19s9.27-3.11 11-7.5C21.27 7.11 17 4 12 4zm0 5c1.38 0 2.5 1.12 2.5 2.5S13.38 14 12 14s-2.5-1.12-2.5-2.5S10.62 9 12 9m0-2c-2.48 0-4.5 2.02-4.5 4.5S9.52 16 12 16s4.5-2.02 4.5-4.5S14.48 7 12 7z" }) });
function b5() {
  return pO1;
}
var uO1 = O1.jsx("svg", { width: "24px", height: "24px", viewBox: "0 0 24 24", children: O1.jsx("path", { d: "M1 21h22L12 2 1 21zm12-3h-2v-2h2v2zm0-4h-2v-4h2v4z" }) });
function Ry() {
  return uO1;
}
var P58 = O1.jsx("svg", { width: "24px", height: "24px", viewBox: "0 0 24 24", children: O1.jsx("path", { d: "M 9.64 7.64 c 0.23 -0.5 0.36 -1.05 0.36 -1.64 c 0 -2.21 -1.79 -4 -4 -4 S 2 3.79 2 6 s 1.79 4 4 4 c 0.59 0 1.14 -0.13 1.64 -0.36 L 10 12 l -2.36 2.36 C 7.14 14.13 6.59 14 6 14 c -2.21 0 -4 1.79 -4 4 s 1.79 4 4 4 s 4 -1.79 4 -4 c 0 -0.59 -0.13 -1.14 -0.36 -1.64 L 12 14 l 7 7 h 3 v -1 L 9.64 7.64 Z M 6 8 c -1.1 0 -2 -0.89 -2 -2 s 0.9 -2 2 -2 s 2 0.89 2 2 s -0.9 2 -2 2 Z m 0 12 c -1.1 0 -2 -0.89 -2 -2 s 0.9 -2 2 -2 s 2 0.89 2 2 s -0.9 2 -2 2 Z m 6 -7.5 c -0.28 0 -0.5 -0.22 -0.5 -0.5 s 0.22 -0.5 0.5 -0.5 s 0.5 0.22 0.5 0.5 s -0.22 0.5 -0.5 0.5 Z M 19 3 l -6 6 l 2 2 l 7 -7 V 3 Z" }) });
var cO1 = O1.jsx("svg", { width: "24px", height: "24px", viewBox: "0 0 24 24", children: O1.jsx("path", { d: "M12,7c-2.76,0-5,2.24-5,5s2.24,5,5,5s5-2.24,5-5S14.76,7,12,7L12,7z M2,13l2,0c0.55,0,1-0.45,1-1s-0.45-1-1-1l-2,0 c-0.55,0-1,0.45-1,1S1.45,13,2,13z M20,13l2,0c0.55,0,1-0.45,1-1s-0.45-1-1-1l-2,0c-0.55,0-1,0.45-1,1S19.45,13,20,13z M11,2v2 c0,0.55,0.45,1,1,1s1-0.45,1-1V2c0-0.55-0.45-1-1-1S11,1.45,11,2z M11,20v2c0,0.55,0.45,1,1,1s1-0.45,1-1v-2c0-0.55-0.45-1-1-1 C11.45,19,11,19.45,11,20z M5.99,4.58c-0.39-0.39-1.03-0.39-1.41,0c-0.39,0.39-0.39,1.03,0,1.41l1.06,1.06 c0.39,0.39,1.03,0.39,1.41,0s0.39-1.03,0-1.41L5.99,4.58z M18.36,16.95c-0.39-0.39-1.03-0.39-1.41,0c-0.39,0.39-0.39,1.03,0,1.41 l1.06,1.06c0.39,0.39,1.03,0.39,1.41,0c0.39-0.39,0.39-1.03,0-1.41L18.36,16.95z M19.42,5.99c0.39-0.39,0.39-1.03,0-1.41 c-0.39-0.39-1.03-0.39-1.41,0l-1.06,1.06c-0.39,0.39-0.39,1.03,0,1.41s1.03,0.39,1.41,0L19.42,5.99z M7.05,18.36 c0.39-0.39,0.39-1.03,0-1.41c-0.39-0.39-1.03-0.39-1.41,0l-1.06,1.06c-0.39,0.39-0.39,1.03,0,1.41s1.03,0.39,1.41,0L7.05,18.36z" }) });
function iV0() {
  return cO1;
}
var lO1 = O1.jsxs("svg", { width: "16px", height: "16px", viewBox: "0 0 16 16", children: [O1.jsx("path", { d: "M8 1.248c1.857 0 3.526.641 4.65 1.794a5 5 0 0 1 2.518 1.09C13.907 1.482 11.295 0 8 0 4.75 0 2.12 1.48.844 4.122a5 5 0 0 1 2.289-1.047C4.236 1.872 5.974 1.248 8 1.248" }), O1.jsx("path", { d: "M12 12a4 4 0 0 1-2.786-1.13l-.002-.002a1.6 1.6 0 0 0-.276-.167A2.2 2.2 0 0 0 8 10.5c-.414 0-.729.103-.935.201a1.6 1.6 0 0 0-.277.167l-.002.002A4 4 0 1 1 4 4h8a4 4 0 0 1 0 8" })] });
function oV0() {
  return lO1;
}
var sV0 = yE1, aV0 = hO1, Ey = jO1, rV0 = zO1;

// node_modules/molstar/lib/mol-plugin-ui/controls/common.js
class zQ extends jU.Component {
  constructor() {
    super(...arguments);
    this.state = { isExpanded: !!this.props.initialExpanded }, this.headerClicked = () => {
      if (this.props.onHeaderClick)
        this.props.onHeaderClick();
      else
        this.setState({ isExpanded: !this.state.isExpanded });
    };
  }
  render() {
    let Z = this.props.hideOffset ? "msp-control-group-children" : "msp-control-group-children msp-control-offset";
    if (this.props.childrenClassName)
      Z += " " + this.props.childrenClassName;
    return X9.jsxs("div", { className: "msp-control-group-wrapper", style: { position: "relative", marginTop: this.props.noTopMargin ? 0 : void 0 }, children: [X9.jsx("div", { className: "msp-control-group-header", style: { marginLeft: this.props.headerLeftMargin }, title: this.props.title, children: X9.jsxs(Z8, { onClick: this.headerClicked, children: [!this.props.hideExpander && X9.jsx(b6, { svg: this.state.isExpanded ? $W : JW }), this.props.topRightIcon && X9.jsx(b6, { svg: this.props.topRightIcon, style: { position: "absolute", right: "2px", top: 0 } }), X9.jsx("b", { children: this.props.header })] }) }), this.state.isExpanded && X9.jsx("div", { className: Z, style: { display: this.state.isExpanded ? "block" : "none", maxHeight: this.props.maxHeight, overflow: "hidden", overflowY: "auto" }, children: this.props.children })] });
  }
}
function tV0(Z) {
  return Z;
}

class x5 extends jU.PureComponent {
  constructor() {
    super(...arguments);
    this.input = jU.createRef(), this.delayHandle = void 0, this.pendingValue = void 0, this.state = { originalValue: "", value: "" }, this.onBlur = () => {
      if (this.setState({ value: "" + this.state.originalValue }), this.props.onBlur)
        this.props.onBlur();
    }, this.raiseOnChange = () => {
      if (this.pendingValue === void 0)
        return;
      this.props.onChange(this.pendingValue), this.pendingValue = void 0;
    }, this.onChange = (Z) => {
      let J = Z.target.value;
      if (this.props.isValid && !this.props.isValid(J) || this.props.numeric && Number.isNaN(+J)) {
        this.clearTimeout(), this.setState({ value: J });
        return;
      }
      if (this.props.numeric)
        this.setState({ value: J }, () => this.triggerChanged(J, +J));
      else {
        let X = (this.props.toValue || tV0)(J), Y = (this.props.fromValue || tV0)(X);
        this.setState({ value: Y }, () => this.triggerChanged(Y, X));
      }
    }, this.onKeyUp = (Z) => {
      if (Z.charCode === 27 || Z.keyCode === 27 || Z.key === "Escape") {
        if (this.props.blurOnEscape && this.input.current)
          this.input.current.blur();
      }
    }, this.onKeyPress = (Z) => {
      if (Z.keyCode === 13 || Z.charCode === 13 || Z.key === "Enter") {
        if (this.isPending)
          this.clearTimeout(), this.raiseOnChange();
        if (this.props.blurOnEnter && this.input.current)
          this.input.current.blur();
        if (this.props.onEnter)
          this.props.onEnter();
      }
      Z.stopPropagation();
    };
  }
  get isPending() {
    return typeof this.delayHandle !== "undefined";
  }
  clearTimeout() {
    if (this.isPending)
      clearTimeout(this.delayHandle), this.delayHandle = void 0;
  }
  triggerChanged(Z, J) {
    if (this.clearTimeout(), Z === this.state.originalValue)
      return;
    if (this.props.delayMs)
      this.pendingValue = J, this.delayHandle = setTimeout(this.raiseOnChange, this.props.delayMs);
    else
      this.props.onChange(J);
  }
  static getDerivedStateFromProps(Z, J) {
    let $ = Z.fromValue ? Z.fromValue(Z.value) : Z.value;
    if ($ === J.originalValue)
      return null;
    return { originalValue: $, value: $ };
  }
  render() {
    return X9.jsx("input", { type: "text", className: this.props.className, style: this.props.style, ref: this.input, onBlur: this.onBlur, value: this.state.value, placeholder: this.props.placeholder, onChange: this.onChange, onKeyPress: this.props.onEnter || this.props.blurOnEnter || this.props.blurOnEscape ? this.onKeyPress : void 0, onKeyDown: this.props.blurOnEscape ? this.onKeyUp : void 0, disabled: !!this.props.isDisabled });
  }
}

class K10 extends jU.Component {
  constructor() {
    super(...arguments);
    this.state = { isExpanded: !1 }, this.toggleExpanded = () => this.setState({ isExpanded: !this.state.isExpanded });
  }
  render() {
    let { label: Z, pivot: J, controls: $ } = this.props;
    return X9.jsxs(X9.Fragment, { children: [X9.jsx(bY, { label: X9.jsxs(X9.Fragment, { children: [Z, X9.jsx("button", { className: "msp-btn-link msp-btn-icon msp-control-group-expander", onClick: this.toggleExpanded, title: `${this.state.isExpanded ? "Less" : "More"} options`, style: { background: "transparent", textAlign: "left", padding: "0" }, children: X9.jsx(b6, { svg: this.state.isExpanded ? kI : hH, style: { display: "inline-block" } }) })] }), control: J, children: this.props.colorStripe && X9.jsx("div", { className: "msp-expandable-group-color-stripe", style: { backgroundColor: i0.toStyle(this.props.colorStripe) } }) }), this.state.isExpanded && X9.jsx("div", { className: "msp-control-offset", children: $ })] });
  }
}
function bH(Z) {
  return X9.jsxs("div", { className: `msp-section-header${Z.accent ? " msp-transform-header-brand-" + Z.accent : ""}`, children: [Z.icon && X9.jsx(b6, { svg: Z.icon }), Z.title, " ", X9.jsx("small", { children: Z.desc })] });
}
function Z8(Z) {
  let J = "msp-btn";
  if (!Z.inline)
    J += " msp-btn-block";
  if (Z.noOverflow)
    J += " msp-no-overflow";
  if (Z.flex)
    J += " msp-flex-item";
  if (Z.commit === "on" || Z.commit)
    J += " msp-btn-commit msp-btn-commit-on";
  if (Z.commit === "off")
    J += " msp-btn-commit msp-btn-commit-off";
  if (!Z.children)
    J += " msp-btn-childless";
  if (Z.className)
    J += " " + Z.className;
  let $ = void 0;
  if (Z.flex) {
    if (typeof Z.flex === "number")
      $ = { flex: `0 0 ${Z.flex}px`, padding: 0, maxWidth: `${Z.flex}px` };
    else if (typeof Z.flex === "string")
      $ = { flex: `0 0 ${Z.flex}`, padding: 0, maxWidth: Z.flex };
  }
  if (Z.style)
    if ($)
      Object.assign($, Z.style);
    else
      $ = Z.style;
  return X9.jsxs("button", { onClick: Z.onClick, title: Z.title, disabled: Z.disabled, style: $, className: J, "data-id": Z["data-id"], "data-color": Z["data-color"], onContextMenu: Z.onContextMenu, onMouseEnter: Z.onMouseEnter, onMouseLeave: Z.onMouseLeave, children: [Z.icon && X9.jsx(b6, { svg: Z.icon }), Z.children] });
}
function o2(Z) {
  let J = `msp-btn msp-btn-icon${Z.small ? "-small" : ""}${Z.className ? " " + Z.className : ""}`;
  if (typeof Z.toggleState !== "undefined")
    J += ` msp-btn-link-toggle-${Z.toggleState ? "on" : "off"}`;
  if (Z.transparent)
    J += " msp-transparent-bg";
  let $ = void 0;
  if (Z.flex)
    if (typeof Z.flex === "boolean")
      $ = { flex: "0 0 32px", padding: 0 };
    else if (typeof Z.flex === "number")
      $ = { flex: `0 0 ${Z.flex}px`, padding: 0, maxWidth: `${Z.flex}px` };
    else
      $ = { flex: `0 0 ${Z.flex}`, padding: 0, maxWidth: Z.flex };
  if (Z.style)
    if ($)
      Object.assign($, Z.style);
    else
      $ = Z.style;
  return X9.jsxs("button", { className: J, onClick: Z.onClick, title: Z.title, disabled: Z.disabled, "data-id": Z["data-id"], style: $, children: [Z.svg && X9.jsx(b6, { svg: Z.svg }), Z.extraContent] });
}

class D7 extends jU.PureComponent {
  constructor() {
    super(...arguments);
    this.onClick = (Z) => {
      Z.currentTarget.blur(), this.props.toggle();
    };
  }
  render() {
    let Z = this.props, J = Z.label, $ = Z.isSelected ? `${Z.className || ""} msp-control-current` : Z.className;
    return X9.jsx(Z8, { icon: this.props.icon, onClick: this.onClick, title: this.props.title, inline: this.props.inline, disabled: Z.disabled, style: Z.style, className: $, children: J && this.props.isSelected ? X9.jsx("b", { children: J }) : J });
  }
}

class g$ extends jU.PureComponent {
  constructor() {
    super(...arguments);
    this.state = { isExpanded: !!this.props.initiallyExpanded }, this.toggleExpanded = () => this.setState({ isExpanded: !this.state.isExpanded });
  }
  render() {
    return X9.jsxs(X9.Fragment, { children: [X9.jsx("div", { className: "msp-control-group-header", style: { marginTop: this.props.marginTop !== void 0 ? this.props.marginTop : "1px", marginLeft: this.props.headerLeftMargin }, children: X9.jsxs("button", { className: "msp-btn msp-form-control msp-btn-block", onClick: this.toggleExpanded, style: this.props.headerStyle, children: [X9.jsx(b6, { svg: this.state.isExpanded ? JW : $W }), this.props.header] }) }), this.state.isExpanded && (this.props.noOffset ? this.props.children : X9.jsx("div", { className: this.props.accent ? "msp-accent-offset" : "msp-control-offset", children: this.props.children }))] });
  }
}
function bY(Z) {
  let J = "msp-control-row";
  if (Z.className)
    J += " " + Z.className;
  return X9.jsxs("div", { className: J, children: [X9.jsx("span", { className: "msp-control-row-label", title: Z.title, children: Z.label }), X9.jsx("div", { className: "msp-control-row-ctrl", children: Z.control }), Z.children] });
}

// node_modules/molstar/lib/mol-plugin-ui/base.js
var DQ = DB.createContext(void 0);

class I8 extends DB.Component {
  subscribe(Z, J) {
    if (typeof this.subs === "undefined")
      this.subs = [];
    this.subs.push(Z.subscribe(J));
  }
  componentWillUnmount() {
    if (!this.subs)
      return;
    for (let Z of this.subs)
      Z.unsubscribe();
    this.subs = void 0;
  }
  constructor(Z, J) {
    super(Z);
    if (this.subs = void 0, this.plugin = J, this.init)
      this.init();
  }
}
I8.contextType = DQ;

class N7 extends DB.PureComponent {
  subscribe(Z, J) {
    if (typeof this.subs === "undefined")
      this.subs = [];
    this.subs.push(Z.subscribe(J));
  }
  componentWillUnmount() {
    if (!this.subs)
      return;
    for (let Z of this.subs)
      Z.unsubscribe();
    this.subs = void 0;
  }
  constructor(Z, J) {
    super(Z, J);
    if (this.subs = void 0, this.plugin = J, this.init)
      this.init();
  }
}
N7.contextType = DQ;

class y5 extends I8 {
  toggleCollapsed() {
    this.setState({ isCollapsed: !this.state.isCollapsed });
  }
  componentDidUpdate(Z) {
    if (this.props.initiallyCollapsed !== void 0 && Z.initiallyCollapsed !== this.props.initiallyCollapsed)
      this.setState({ isCollapsed: this.props.initiallyCollapsed });
  }
  render() {
    var Z;
    if (this.state.isHidden)
      return null;
    let J = this.state.header.toLowerCase().replace(/\s/g, ""), $ = this.state.isCollapsed ? "msp-transform-wrapper msp-transform-wrapper-collapsed" : "msp-transform-wrapper";
    return oz.jsxs("div", { className: $, children: [oz.jsx("div", { id: J, className: "msp-transform-header", children: oz.jsxs(Z8, { icon: this.state.brand ? void 0 : this.state.isCollapsed ? $W : JW, noOverflow: !0, onClick: () => this.toggleCollapsed(), className: this.state.brand ? `msp-transform-header-brand msp-transform-header-brand-${this.state.brand.accent}` : void 0, title: `Click to ${this.state.isCollapsed ? "expand" : "collapse"}`, children: [oz.jsx(b6, { svg: (Z = this.state.brand) === null || Z === void 0 ? void 0 : Z.svg, inline: !0 }), this.state.header, oz.jsx("small", { style: { margin: "0 6px" }, children: this.state.isCollapsed ? "" : this.state.description })] }) }), !this.state.isCollapsed && this.renderControls()] });
  }
  constructor(Z, J) {
    super(Z, J);
    let $ = this.defaultState();
    if (Z.initiallyCollapsed !== void 0)
      $.isCollapsed = Z.initiallyCollapsed;
    if (Z.header !== void 0)
      $.header = Z.header;
    this.state = $;
  }
}

// node_modules/molstar/lib/mol-plugin-ui/controls/parameters.js
var V1 = t2(PZ(), 1), M7 = t2(J7(), 1);

// node_modules/molstar/lib/mol-plugin-ui/controls/action-menu.js
var M$ = t2(PZ(), 1), N10 = t2(J7(), 1);
class w8 extends N10.PureComponent {
  constructor() {
    super(...arguments);
    this.hide = () => this.props.onSelect(void 0);
  }
  render() {
    let Z = this.props, J = M$.jsx(SI, { items: Z.items, onSelect: Z.onSelect, current: Z.current, multiselect: this.props.multiselect, noOffset: this.props.noOffset, noAccent: this.props.noAccent });
    return M$.jsxs("div", { className: `msp-action-menu-options${Z.header ? "" : " msp-action-menu-options-no-header"}`, children: [Z.header && M$.jsx(zQ, { header: Z.header, title: Z.title, initialExpanded: !0, hideExpander: !0, hideOffset: !0, onHeaderClick: this.hide, topRightIcon: cW, children: J }), !Z.header && J] });
  }
}
(function(Z) {
  function J(H, N) {
    return N ? { kind: "header", label: H, ...N } : { kind: "header", label: H };
  }
  Z.Header = J;
  function $(H, N, q) {
    return { kind: "item", label: H, value: N, ...q };
  }
  Z.Item = $;
  function X(H, N) {
    let { label: q, value: U, category: F, selected: E, icon: R, addOn: z, description: D } = N || {}, A = void 0, B = [];
    for (let T = 0;T < H.length; T++) {
      let w = H[T];
      if ((N === null || N === void 0 ? void 0 : N.filter) && !N.filter(w))
        continue;
      let V = F === null || F === void 0 ? void 0 : F(w), P = q ? q(w) : "" + w, I = U ? U(w) : w, S = D ? D(w) : typeof w === "string" ? w : void 0, f;
      if (V) {
        if (!A)
          A = /* @__PURE__ */ new Map;
        if (f = A.get(V), !f)
          f = [Z.Header(V, { description: V })], A.set(V, f), B.push(f);
      } else
        f = B;
      let v = z === null || z === void 0 ? void 0 : z(w);
      f.push({ kind: "item", label: P, value: I, icon: R ? R(w) : void 0, selected: E ? E(w) : void 0, addOn: v, description: S });
    }
    return B;
  }
  Z.createItems = X;
  let Y = { value: (H) => H[0], label: (H) => H[1], category: (H) => H[2] };
  function Q(H, N) {
    return X(H, N ? { ...Y, ...N } : Y);
  }
  Z.createItemsFromSelectOptions = Q;
  function W(H) {
    if (TU(H))
      return !1;
    if (MB(H))
      return !!H.selected;
    for (let N of H)
      if (W(N))
        return !0;
    return !1;
  }
  Z.hasSelectedItem = W;
  function K(H, N) {
    if (TU(H))
      return;
    if (MB(H))
      return H.value === N ? H : void 0;
    for (let q of H) {
      let U = K(q, N);
      if (U)
        return U;
    }
  }
  Z.findItem = K;
  function G(H) {
    if (TU(H))
      return;
    if (MB(H))
      return H;
    for (let N of H) {
      let q = G(N);
      if (q)
        return q;
    }
  }
  Z.getFirstItem = G;
})(w8 || (w8 = {}));

class SI extends N10.PureComponent {
  constructor() {
    super(...arguments);
    this.state = SI.createState(this.props), this.toggleExpanded = (Z) => {
      this.setState({ isExpanded: !this.state.isExpanded }), Z.currentTarget.blur();
    }, this.selectAll = () => {
      let Z = H10(this.props.items, []).filter((J) => !J.selected);
      this.props.onSelect(Z);
    }, this.selectNone = () => {
      let Z = H10(this.props.items, []).filter((J) => !!J.selected);
      this.props.onSelect(Z);
    };
  }
  static createState(Z, J) {
    let $ = G10(Z.items) && TU(Z.items[0]) ? Z.items[0] : void 0, X = ($ === null || $ === void 0 ? void 0 : $.isIndependent) ? !1 : Z.multiselect ? w8.hasSelectedItem(Z.items) : !!Z.current && !!w8.findItem(Z.items, Z.current.value) || w8.hasSelectedItem(Z.items);
    return {
      header: $,
      hasCurrent: X,
      isExpanded: X || (J !== null && J !== void 0 ? J : !!($ === null || $ === void 0 ? void 0 : $.initiallyExpanded))
    };
  }
  componentDidUpdate(Z) {
    if (this.props.items !== Z.items || this.props.current !== Z.current) {
      let J = G10(this.props.items) && G10(Z.items) && TU(this.props.items[0]) && TU(Z.items[0]) && this.props.items[0].label === Z.items[0].label ? this.state.isExpanded : void 0;
      this.setState(SI.createState(this.props, J));
    }
  }
  get multiselectHeader() {
    let { header: Z, hasCurrent: J } = this.state;
    return M$.jsxs("div", { className: "msp-flex-row msp-control-group-header", children: [M$.jsx(Z8, { icon: this.state.isExpanded ? JW : $W, flex: !0, noOverflow: !0, onClick: this.toggleExpanded, title: `Click to ${this.state.isExpanded ? "collapse" : "expand"}.${(Z === null || Z === void 0 ? void 0 : Z.description) ? ` ${Z === null || Z === void 0 ? void 0 : Z.description}` : ""}`, children: J ? M$.jsx("b", { children: Z === null || Z === void 0 ? void 0 : Z.label }) : Z === null || Z === void 0 ? void 0 : Z.label }), M$.jsx(Z8, { icon: xK, flex: !0, onClick: this.selectAll, style: { flex: "0 0 50px", textAlign: "right" }, children: "All" }), M$.jsx(Z8, { icon: cW, flex: !0, onClick: this.selectNone, style: { flex: "0 0 50px", textAlign: "right" }, children: "None" })] });
  }
  get basicHeader() {
    let { header: Z, hasCurrent: J } = this.state;
    return M$.jsx("div", { className: "msp-control-group-header", style: { marginTop: "1px" }, children: M$.jsx(Z8, { noOverflow: !0, icon: this.state.isExpanded ? JW : $W, onClick: this.toggleExpanded, title: `Click to ${this.state.isExpanded ? "collapse" : "expand"}. ${(Z === null || Z === void 0 ? void 0 : Z.description) ? Z === null || Z === void 0 ? void 0 : Z.description : ""}`, children: J ? M$.jsx("b", { children: Z === null || Z === void 0 ? void 0 : Z.label }) : Z === null || Z === void 0 ? void 0 : Z.label }) });
  }
  render() {
    let { items: Z, onSelect: J, current: $ } = this.props;
    if (TU(Z))
      return null;
    if (MB(Z))
      return M$.jsx(eV0, { item: Z, onSelect: J, current: $, multiselect: this.props.multiselect });
    let { header: X } = this.state;
    return M$.jsxs(M$.Fragment, { children: [X && (this.props.multiselect && this.state.isExpanded ? this.multiselectHeader : this.basicHeader), M$.jsx("div", { className: this.props.noOffset ? void 0 : this.props.noAccent ? "msp-control-offset" : "msp-accent-offset", children: (!X || this.state.isExpanded) && Z.map((Y, Q) => {
      if (TU(Y))
        return null;
      if (MB(Y))
        return M$.jsx(eV0, { item: Y, onSelect: J, current: $, multiselect: this.props.multiselect }, Q);
      return M$.jsx(SI, { items: Y, onSelect: J, current: $, multiselect: this.props.multiselect, noAccent: !0 }, Q);
    }) })] });
  }
}
var eV0 = ({ item: Z, onSelect: J, current: $, multiselect: X }) => {
  let Y = $ === Z, Q = Z.addOn ? { position: "relative" } : void 0;
  return M$.jsxs(Z8, { icon: Z.icon, noOverflow: !0, className: "msp-action-menu-button", onClick: (W) => J(X ? [Z] : Z, W), disabled: Z.disabled, style: Q, title: Z.description, children: [Y || Z.selected ? M$.jsx("b", { children: Z.label }) : Z.label, Z.addOn] });
};
function G10(Z) {
  return !!Z && Array.isArray(Z);
}
function MB(Z) {
  let J = Z;
  return J && J.kind === "item";
}
function TU(Z) {
  let J = Z;
  return J && J.kind === "header";
}
function H10(Z, J) {
  if (TU(Z))
    return J;
  if (MB(Z))
    return J.push(Z), J;
  for (let $ of Z)
    H10($, J);
  return J;
}

// node_modules/molstar/lib/mol-plugin-ui/controls/color.js
var m$ = t2(PZ(), 1);
var ZI0 = t2(J7(), 1);

// node_modules/molstar/lib/mol-util/color/swatches.js
var q10 = i50([
  ["black", 0],
  ["gray", 8421504],
  ["white", 16777215],
  ["red", 13840661],
  ["orange", 14840576],
  ["yellow", 16565248],
  ["green", 6863872],
  ["cyan", 1484197],
  ["blue", 40160],
  ["purple", 8086783],
  ["magenta", 16394495],
  ["violet", 8200583]
]);

// node_modules/molstar/lib/mol-plugin-ui/controls/color.js
class fI extends ZI0.PureComponent {
  constructor() {
    super(...arguments);
    this.state = {
      isExpanded: !!this.props.param.isExpanded || !!this.props.hideNameRow,
      lightness: 0
    }, this.toggleExpanded = (Z) => {
      this.setState({ isExpanded: !this.state.isExpanded }), Z.currentTarget.blur();
    }, this.onClickSwatch = (Z) => {
      let J = i0.fromHexString(Z.currentTarget.getAttribute("data-color") || "0");
      if (J !== this.props.value) {
        if (!this.props.param.isExpanded)
          this.setState({ isExpanded: !1 });
        this.update(J);
      }
    }, this.onR = (Z) => {
      let [, J, $] = i0.toRgb(this.props.value), X = i0.fromRgb(Z, J, $);
      if (X !== this.props.value)
        this.update(X);
    }, this.onG = (Z) => {
      let [J, , $] = i0.toRgb(this.props.value), X = i0.fromRgb(J, Z, $);
      if (X !== this.props.value)
        this.update(X);
    }, this.onB = (Z) => {
      let [J, $] = i0.toRgb(this.props.value), X = i0.fromRgb(J, $, Z);
      if (X !== this.props.value)
        this.update(X);
    }, this.onRGB = (Z) => {
      let J = i0.fromHexStyle(Z.currentTarget.value || "0");
      if (J !== this.props.value)
        this.update(J);
    }, this.onLighten = () => {
      this.update(i0.lighten(this.props.value, 0.1));
    }, this.onDarken = () => {
      this.update(i0.darken(this.props.value, 0.1));
    };
  }
  update(Z) {
    this.props.onChange({ param: this.props.param, name: this.props.name, value: Z });
  }
  swatch() {
    return m$.jsx("div", { className: "msp-combined-color-swatch", children: q10.map((Z) => m$.jsx(Z8, { inline: !0, "data-color": Z[1], onClick: this.onClickSwatch, style: { background: i0.toStyle(Z[1]) } }, Z[1])) });
  }
  render() {
    let Z = this.props.param.label || s$(this.props.name), [J, $, X] = i0.toRgb(this.props.value), Y = m$.jsxs(m$.Fragment, { children: [this.swatch(), m$.jsx(bY, { label: "RGB", className: "msp-control-label-short", control: m$.jsxs("div", { style: { display: "flex", textAlignLast: "center", left: "80px" }, children: [m$.jsx(x5, { onChange: this.onR, numeric: !0, value: J, delayMs: 250, style: { order: 1, flex: "1 1 auto", minWidth: 0 }, className: "msp-form-control", onEnter: this.props.onEnter, blurOnEnter: !0, blurOnEscape: !0 }), m$.jsx(x5, { onChange: this.onG, numeric: !0, value: $, delayMs: 250, style: { order: 2, flex: "1 1 auto", minWidth: 0 }, className: "msp-form-control", onEnter: this.props.onEnter, blurOnEnter: !0, blurOnEscape: !0 }), m$.jsx(x5, { onChange: this.onB, numeric: !0, value: X, delayMs: 250, style: { order: 3, flex: "1 1 auto", minWidth: 0 }, className: "msp-form-control", onEnter: this.props.onEnter, blurOnEnter: !0, blurOnEscape: !0 }), m$.jsx("input", { onInput: this.onRGB, type: "color", value: i0.toHexStyle(this.props.value), style: { order: 4, flex: "1 1 auto", minWidth: "32px", width: "32px", height: "32px", padding: "0 2px 0 2px", background: "none", border: "none", cursor: "pointer" } })] }) }), m$.jsxs("div", { style: { display: "flex", textAlignLast: "center" }, children: [m$.jsx(Z8, { onClick: this.onLighten, style: { order: 1, flex: "1 1 auto", minWidth: 0 }, className: "msp-form-control", children: "Lighten" }), m$.jsx(Z8, { onClick: this.onDarken, style: { order: 1, flex: "1 1 auto", minWidth: 0 }, className: "msp-form-control", children: "Darken" })] })] });
    if (this.props.hideNameRow)
      return Y;
    return m$.jsxs(m$.Fragment, { children: [m$.jsx(bY, { title: this.props.param.description, label: Z, control: m$.jsx(Z8, { onClick: this.toggleExpanded, inline: !0, className: "msp-combined-color-button", style: { background: i0.toStyle(this.props.value) } }) }), this.state.isExpanded && m$.jsx("div", { className: "msp-control-offset", children: Y })] });
  }
}
var n58 = function() {
  let Z = /* @__PURE__ */ new Map;
  for (let J of q10)
    Z.set(J[1], J[0]);
  return Z;
}();

// node_modules/molstar/lib/mol-plugin-ui/controls/legend.js
var _q = t2(PZ(), 1);
var F10 = t2(J7(), 1);
function JI0(Z) {
  switch (Z.kind) {
    case "scale-legend":
      return $I0;
    case "table-legend":
      return XI0;
    default:
      console.warn(`${Z} has no associated UI component`);
      return;
  }
}

class $I0 extends F10.PureComponent {
  render() {
    let { legend: Z } = this.props, J = Z.colors.map(($) => Array.isArray($) ? `${i0.toStyle($[0])} ${100 * $[1]}%` : i0.toStyle($)).join(", ");
    return _q.jsx("div", { className: "msp-scale-legend", children: _q.jsxs("div", { style: { background: `linear-gradient(to right, ${J})` }, children: [_q.jsx("span", { style: { float: "left" }, children: Z.minLabel }), _q.jsx("span", { style: { float: "right" }, children: Z.maxLabel })] }) });
  }
}

class XI0 extends F10.PureComponent {
  render() {
    let { legend: Z } = this.props;
    return _q.jsx("div", { className: "msp-table-legend", children: Z.table.map((J, $) => {
      let [X, Y] = J;
      return _q.jsxs("div", { children: [_q.jsx("div", { className: "msp-table-legend-color", style: { backgroundColor: i0.toStyle(Y) } }), _q.jsx("div", { className: "msp-table-legend-text", children: X })] }, $);
    }) });
  }
}

// node_modules/molstar/lib/mol-plugin-ui/controls/line-graph/line-graph-component.js
var Vq = t2(PZ(), 1);

// node_modules/molstar/lib/mol-plugin-ui/controls/line-graph/point-component.js
var YI0 = t2(PZ(), 1), QI0 = t2(J7(), 1);
class U10 extends QI0.Component {
  constructor(Z) {
    super(Z);
    this.state = { show: !1 }, this.handleHover = this.handleHover.bind(this), this.handleHoverOff = this.handleHoverOff.bind(this), this.deletePoint = this.deletePoint.bind(this);
  }
  handleHover() {
    this.setState({ show: !0 });
    let Z = h0.create(this.props.nX, this.props.nY);
    this.props.onmouseover(Z);
  }
  handleHoverOff() {
    this.setState({ show: !1 }), this.props.onmouseover(void 0);
  }
  deletePoint() {
    this.props.delete(this.props.id);
  }
  render() {
    return [
      YI0.jsx("circle", { r: "10", id: `${this.props.id}`, cx: this.props.x, cy: this.props.y, onClick: this.props.onclick, onDoubleClick: this.props.delete(this.props.id), onMouseEnter: this.handleHover, onMouseLeave: this.handleHoverOff, onMouseDown: this.props.onmousedown, fill: "black" }, `${this.props.id}circle`)
    ];
  }
}

// node_modules/molstar/lib/mol-plugin-ui/controls/line-graph/line-graph-component.js
var Oy = t2(J7(), 1);
class L10 extends Oy.Component {
  constructor(Z) {
    super(Z);
    this.handleKeyDown = (J) => {}, this.handleKeyUp = (J) => {}, this.handleClick = (J) => ($) => {}, this.handleMouseDown = (J) => ($) => {
      if (J === 0 || J === this.state.points.length - 1)
        return;
      if (this.state.canSelectMultiple)
        return;
      let X = this.normalizePoint(h0.create(this.state.points[J][0], this.state.points[J][1]));
      this.ghostPoints.push(document.createElementNS(this.namespace, "circle")), this.ghostPoints[0].setAttribute("r", "10"), this.ghostPoints[0].setAttribute("fill", "orange"), this.ghostPoints[0].setAttribute("cx", `${X[0]}`), this.ghostPoints[0].setAttribute("cy", `${X[1]}`), this.ghostPoints[0].setAttribute("style", "display: none"), this.gElement.appendChild(this.ghostPoints[0]), this.updatedX = X[0], this.updatedY = X[1], this.selected = [J];
    }, this.deletePoint = (J) => ($) => {
      if (J === 0 || J === this.state.points.length - 1)
        return;
      let X = this.state.points.filter((Y, Q) => Q !== J);
      X.sort((Y, Q) => {
        if (Y[0] === Q[0]) {
          if (Y[0] === 0)
            return Y[1] - Q[1];
          if (Y[1] === 1)
            return Q[1] - Y[1];
          return Y[1] - Q[1];
        }
        return Y[0] - Q[0];
      }), this.setState({ points: X }), this.change(X), $.stopPropagation();
    }, this.myRef = Oy.createRef(), this.state = {
      points: [
        h0.create(0, 0),
        h0.create(1, 0)
      ],
      copyPoint: void 0,
      canSelectMultiple: !1
    }, this.height = 400, this.width = 600, this.padding = 70, this.selected = void 0, this.ghostPoints = [], this.namespace = "http://www.w3.org/2000/svg";
    for (let J of this.props.data)
      this.state.points.push(J);
    this.state.points.sort((J, $) => {
      if (J[0] === $[0]) {
        if (J[0] === 0)
          return J[1] - $[1];
        if (J[1] === 1)
          return $[1] - J[1];
        return J[1] - $[1];
      }
      return J[0] - $[0];
    }), this.handleDrag = this.handleDrag.bind(this), this.handleMultipleDrag = this.handleMultipleDrag.bind(this), this.handleDoubleClick = this.handleDoubleClick.bind(this), this.refCallBack = this.refCallBack.bind(this), this.handlePointUpdate = this.handlePointUpdate.bind(this), this.change = this.change.bind(this), this.handleKeyUp = this.handleKeyUp.bind(this), this.handleLeave = this.handleLeave.bind(this), this.handleEnter = this.handleEnter.bind(this);
  }
  render() {
    let Z = this.renderPoints(), J = this.renderLines(), $ = this.renderHistogram();
    return [
      Vq.jsx("div", { children: Vq.jsxs("svg", { className: "msp-canvas", ref: this.refCallBack, viewBox: `0 0 ${this.width + this.padding} ${this.height + this.padding}`, onMouseMove: this.handleDrag, onMouseUp: this.handlePointUpdate, onMouseLeave: this.handleLeave, onMouseEnter: this.handleEnter, tabIndex: 0, onKeyDown: this.handleKeyDown, onKeyUp: this.handleKeyUp, onDoubleClick: this.handleDoubleClick, children: [Vq.jsxs("g", { stroke: "black", fill: "black", children: [$, J, Z] }), Vq.jsx("g", { className: "ghost-points", stroke: "black", fill: "black" })] }) }, "LineGraph"),
      Vq.jsx("div", { id: "modal-root" }, "modal")
    ];
  }
  componentDidMount() {
    this.gElement = document.getElementsByClassName("ghost-points")[0];
  }
  change(Z) {
    let J = Z.slice();
    J.shift(), J.pop(), this.props.onChange(J);
  }
  handleDrag(Z) {
    if (this.selected === void 0)
      return;
    let J = this.myRef.createSVGPoint(), $, X = this.padding / 2;
    J.x = Z.clientX, J.y = Z.clientY;
    let Y = J.matrixTransform(this.myRef.getScreenCTM().inverse());
    if ($ = h0.create(Y.x, Y.y), (Y.x < X || Y.x > this.width + X) && (Y.y > this.height + X || Y.y < X))
      $ = h0.create(this.updatedX, this.updatedY);
    else if (Y.x < X)
      $ = h0.create(X, Y.y);
    else if (Y.x > this.width + X)
      $ = h0.create(this.width + X, Y.y);
    else if (Y.y > this.height + X)
      $ = h0.create(Y.x, this.height + X);
    else if (Y.y < X)
      $ = h0.create(Y.x, X);
    else
      $ = h0.create(Y.x, Y.y);
    this.updatedX = $[0], this.updatedY = $[1];
    let Q = this.unNormalizePoint($);
    this.ghostPoints[0].setAttribute("style", "display: visible"), this.ghostPoints[0].setAttribute("cx", `${$[0]}`), this.ghostPoints[0].setAttribute("cy", `${$[1]}`), this.props.onDrag(Q);
  }
  handleMultipleDrag() {}
  handlePointUpdate(Z) {
    let J = this.selected;
    if (this.state.canSelectMultiple)
      return;
    if (J === void 0 || J[0] === 0 || J[0] === this.state.points.length - 1) {
      this.setState({
        copyPoint: void 0
      });
      return;
    }
    this.selected = void 0;
    let $ = this.unNormalizePoint(h0.create(this.updatedX, this.updatedY)), X = this.state.points.filter((Y, Q) => Q !== J[0]);
    X.push($), X.sort((Y, Q) => {
      if (Y[0] === Q[0]) {
        if (Y[0] === 0)
          return Y[1] - Q[1];
        if (Y[1] === 1)
          return Q[1] - Y[1];
        return Y[1] - Q[1];
      }
      return Y[0] - Q[0];
    }), this.setState({
      points: X
    }), this.change(X), this.gElement.innerHTML = "", this.ghostPoints = [], document.removeEventListener("mousemove", this.handleDrag, !0), document.removeEventListener("mouseup", this.handlePointUpdate, !0);
  }
  handleDoubleClick(Z) {
    let J = this.myRef.createSVGPoint();
    J.x = Z.clientX, J.y = Z.clientY;
    let $ = J.matrixTransform(this.myRef.getScreenCTM().inverse()), X = this.state.points, Y = this.padding / 2;
    if ($.x < Y || $.x > this.width + Y || $.y > this.height + Y || $.y < this.padding / 2)
      return;
    let Q = this.unNormalizePoint(h0.create($.x, $.y));
    X.push(Q), X.sort((W, K) => {
      if (W[0] === K[0]) {
        if (W[0] === 0)
          return W[1] - K[1];
        if (W[1] === 1)
          return K[1] - W[1];
        return W[1] - K[1];
      }
      return W[0] - K[0];
    }), this.setState({ points: X }), this.change(X);
  }
  handleLeave() {
    if (this.selected === void 0)
      return;
    document.addEventListener("mousemove", this.handleDrag, !0), document.addEventListener("mouseup", this.handlePointUpdate, !0);
  }
  handleEnter() {
    document.removeEventListener("mousemove", this.handleDrag, !0), document.removeEventListener("mouseup", this.handlePointUpdate, !0);
  }
  normalizePoint(Z) {
    let J = this.padding / 2, $ = this.width + J, X = this.height + J, Y = Z[0] * ($ - J) + J, Q = Z[1] * (X - J) + J, W = this.height + this.padding - Q;
    return h0.create(Y, W);
  }
  unNormalizePoint(Z) {
    let J = this.padding / 2, $ = this.width + J, X = this.height + J, Y = (Z[0] - J) / ($ - J), Q = (this.height + this.padding - Z[1] - J) / (X - J);
    return h0.create(Y, Q);
  }
  refCallBack(Z) {
    if (Z)
      this.myRef = Z;
  }
  renderHistogram() {
    if (!this.props.volume)
      return null;
    let Z = s6.getHistogram(this.props.volume.grid, 40), J = [], $ = Z.counts.length, X = this.width / $, Y = this.padding / 2, Q = yX(Z.counts) || 1;
    for (let W = 0;W < $; W++) {
      let K = this.width * W / ($ - 1) + Y, G = this.height + Y, H = this.height * (1 - Z.counts[W] / Q) + Y;
      J.push(Vq.jsx("line", { x1: K, x2: K, y1: G, y2: H, stroke: "#ded9ca", strokeWidth: X }, `histogram${W}`));
    }
    return J;
  }
  renderPoints() {
    let Z = [], J;
    for (let $ = 0;$ < this.state.points.length; $++)
      if ($ !== 0 && $ !== this.state.points.length - 1)
        J = this.normalizePoint(this.state.points[$]), Z.push(Vq.jsx(U10, { id: $, x: J[0], y: J[1], nX: this.state.points[$][0], nY: this.state.points[$][1], selected: !1, delete: this.deletePoint, onmouseover: this.props.onHover, onmousedown: this.handleMouseDown($), onclick: this.handleClick($) }, $));
    return Z;
  }
  renderLines() {
    let Z = [], J = [], $, X, Y, Q, W, K = this.padding / 2;
    for (let N of this.state.points)
      $ = this.width + K, X = this.height + this.padding, Y = N[0] * ($ - K) + K, Q = N[1] * (X - K) + K, W = this.height + this.padding - Q, Z.push(h0.create(Y, W));
    let G = Z, H = G.length;
    for (let N = 0;N < H - 1; N++) {
      let q = G[N][0], U = G[N][1], F = G[N + 1][0], E = G[N + 1][1];
      J.push(Vq.jsx("line", { x1: q, x2: F, y1: U, y2: E, stroke: "#cec9ba", strokeWidth: "5" }, `lineOf${N}`));
    }
    return J;
  }
}

// node_modules/molstar/lib/mol-plugin-ui/controls/slider.js
var xY = t2(PZ(), 1), Iq = t2(J7(), 1);
class sz extends Iq.Component {
  constructor() {
    super(...arguments);
    this.state = { isChanging: !1, current: 0 }, this.begin = () => {
      this.setState({ isChanging: !0 });
    }, this.end = (Z) => {
      this.setState({ isChanging: !1 }), this.props.onChange(Z);
    }, this.updateCurrent = (Z) => {
      var J, $;
      this.setState({ current: Z }), ($ = (J = this.props).onChangeImmediate) === null || $ === void 0 || $.call(J, Z);
    }, this.updateManually = (Z) => {
      this.setState({ isChanging: !0 });
      let J = Z;
      if (this.props.step === 1)
        J = Math.round(J);
      if (J < this.props.min)
        J = this.props.min;
      if (J > this.props.max)
        J = this.props.max;
      this.setState({ current: J, isChanging: !0 });
    }, this.onManualBlur = () => {
      this.setState({ isChanging: !1 }), this.props.onChange(this.state.current);
    }, this.onMouseWheel = (Z) => {
      let { dx: J, dy: $, dz: X } = Re(Z), Y = (J >= 0 ? 1 : -1) * ($ >= 0 ? 1 : -1) * (X >= 0 ? 1 : -1), Q = Z.getModifierState("Shift"), W = Y * (this.props.max - this.props.min) / (Q ? 100 : 25);
      this.updateCurrent(this.state.current + W);
    };
  }
  static getDerivedStateFromProps(Z, J) {
    if (J.isChanging || Z.value === J.current)
      return null;
    return { current: Z.value };
  }
  render() {
    let Z = this.props.step;
    if (Z === void 0)
      Z = 1;
    return xY.jsxs("div", { className: !this.props.hideInput ? "msp-slider" : "msp-slider msp-slider-no-input", children: [xY.jsx("div", { children: xY.jsx(zy, { min: this.props.min, max: this.props.max, step: Z, value: this.state.current, disabled: this.props.disabled, onBeforeChange: this.begin, onWheel: this.onMouseWheel, onChange: this.updateCurrent, onAfterChange: this.end }) }), xY.jsx("div", { children: xY.jsx(x5, { numeric: !0, delayMs: 50, value: this.state.current, blurOnEnter: !0, onBlur: this.onManualBlur, isDisabled: this.props.disabled, onChange: this.updateManually }) })] });
  }
}

class O10 extends Iq.Component {
  constructor() {
    super(...arguments);
    this.state = { isChanging: !1, current: [0, 1] }, this.begin = () => {
      this.setState({ isChanging: !0 });
    }, this.end = (Z) => {
      this.setState({ isChanging: !1 }), this.props.onChange(Z);
    }, this.updateCurrent = (Z) => {
      this.setState({ current: Z });
    }, this.updateMax = (Z) => {
      let J = Z;
      if (this.props.step === 1)
        J = Math.round(J);
      if (J < this.state.current[0])
        J = this.state.current[0];
      else if (J < this.props.min)
        J = this.props.min;
      if (J > this.props.max)
        J = this.props.max;
      this.props.onChange([this.state.current[0], J]);
    }, this.updateMin = (Z) => {
      let J = Z;
      if (this.props.step === 1)
        J = Math.round(J);
      if (J < this.props.min)
        J = this.props.min;
      if (J > this.state.current[1])
        J = this.state.current[1];
      else if (J > this.props.max)
        J = this.props.max;
      this.props.onChange([J, this.state.current[1]]);
    };
  }
  static getDerivedStateFromProps(Z, J) {
    if (J.isChanging || Z.value[0] === J.current[0] && Z.value[1] === J.current[1])
      return null;
    return { current: Z.value };
  }
  render() {
    let Z = this.props.step;
    if (Z === void 0)
      Z = 1;
    return xY.jsxs("div", { className: "msp-slider2", children: [xY.jsx("div", { children: xY.jsx(x5, { numeric: !0, delayMs: 50, value: this.state.current[0], onEnter: this.props.onEnter, blurOnEnter: !0, isDisabled: this.props.disabled, onChange: this.updateMin }) }), xY.jsx("div", { children: xY.jsx(zy, { min: this.props.min, max: this.props.max, step: Z, value: this.state.current, disabled: this.props.disabled, onBeforeChange: this.begin, onChange: this.updateCurrent, onAfterChange: this.end, range: !0, allowCross: !0 }) }), xY.jsx("div", { children: xY.jsx(x5, { numeric: !0, delayMs: 50, value: this.state.current[1], onEnter: this.props.onEnter, blurOnEnter: !0, isDisabled: this.props.disabled, onChange: this.updateMax }) })] });
  }
}
function E10(Z) {
  let J = [], $ = {}.hasOwnProperty;
  for (let X = 0;X < arguments.length; X++) {
    let Y = arguments[X];
    if (!Y)
      continue;
    let Q = typeof Y;
    if (Q === "string" || Q === "number")
      J.push(Y);
    else if (Array.isArray(Y))
      J.push(E10.apply(null, Y));
    else if (Q === "object") {
      for (let W in Y)
        if ($.call(Y, W) && Y[W])
          J.push(W);
    }
  }
  return J.join(" ");
}
function WI0(Z) {
  return Z.touches.length > 1 || Z.type.toLowerCase() === "touchend" && Z.touches.length > 0;
}
function KI0(Z, J) {
  return Z ? J.touches[0].clientY : J.touches[0].pageX;
}
function GI0(Z, J) {
  return Z ? J.clientY : J.pageX;
}
function HI0(Z, J) {
  let $ = J.getBoundingClientRect();
  return Z ? $.top + $.height * 0.5 : $.left + $.width * 0.5;
}
function R10(Z) {
  Z.stopPropagation(), Z.preventDefault();
}

class NI0 extends Iq.Component {
  render() {
    let { className: Z, tipFormatter: J, vertical: $, offset: X, value: Y, index: Q } = this.props, W = $ ? { bottom: `${X}%` } : { left: `${X}%` };
    return xY.jsx("div", { className: Z, style: W, title: J(Y, Q) });
  }
}

class zy extends Iq.Component {
  constructor(Z) {
    super(Z);
    this.sliderElement = Iq.createRef(), this.handleElements = [], this.dragOffset = 0, this.startPosition = 0, this.startValue = 0, this._getPointsCache = void 0, this.onMouseDown = (H) => {
      if (H.button !== 0)
        return;
      let N = GI0(this.props.vertical, H);
      if (!this.isEventFromHandle(H))
        this.dragOffset = 0;
      else {
        let q = HI0(this.props.vertical, H.target);
        this.dragOffset = N - q, N = q;
      }
      this.onStart(N), this.addDocumentEvents("mouse"), R10(H);
    }, this.onTouchMove = (H) => {
      if (WI0(H)) {
        this.end("touch");
        return;
      }
      let N = KI0(this.props.vertical, H);
      this.onMove(H, N - this.dragOffset);
    }, this.onTouchStart = (H) => {
      if (WI0(H))
        return;
      let N = KI0(this.props.vertical, H);
      if (!this.isEventFromHandle(H))
        this.dragOffset = 0;
      else {
        let q = HI0(this.props.vertical, H.target);
        this.dragOffset = N - q, N = q;
      }
      this.onStart(N), this.addDocumentEvents("touch"), R10(H);
    }, this.eventHandlers = {
      touchmove: (H) => this.onTouchMove(H),
      touchend: (H) => this.end("touch"),
      mousemove: (H) => this.onMouseMove(H),
      mouseup: (H) => this.end("mouse")
    }, this.calcOffset = (H) => {
      let { min: N, max: q } = this.props;
      return (H - N) / (q - N) * 100;
    };
    let { range: J, min: $, max: X } = Z, Y = J ? Array.apply(null, Array(+J + 1)).map(() => $) : $, Q = "defaultValue" in Z ? Z.defaultValue : Y, W = Z.value !== void 0 ? Z.value : Q, K = (J ? W : [$, W]).map((H) => this.trimAlignValue(H)), G;
    if (J && K[0] === K[K.length - 1] && K[0] === X)
      G = 0;
    else
      G = K.length - 1;
    this.state = {
      handle: null,
      recent: G,
      bounds: K
    };
  }
  componentDidUpdate(Z) {
    if (!(("value" in this.props) || ("min" in this.props) || ("max" in this.props)))
      return;
    let { bounds: J } = this.state;
    if (Z.range) {
      let X = (this.props.value || J).map((Y) => this.trimAlignValue(Y, this.props));
      if (X.every((Y, Q) => Y === J[Q]))
        return;
      if (this.setState({ bounds: X }), J.some((Y) => this.isValueOutOfBounds(Y, this.props)))
        this.props.onChange(X);
    } else {
      let $ = this.props.value !== void 0 ? this.props.value : J[1], X = this.trimAlignValue($, this.props);
      if (X === J[1] && J[0] === Z.min)
        return;
      if (this.setState({ bounds: [Z.min, X] }), this.isValueOutOfBounds(J[1], this.props))
        this.props.onChange(X);
    }
  }
  onChange(Z) {
    let J = this.props;
    if (!("value" in J))
      this.setState(Z);
    else if (Z.handle !== void 0)
      this.setState({ handle: Z.handle });
    let X = { ...this.state, ...Z }, Y = J.range ? X.bounds : X.bounds[1];
    J.onChange(Y);
  }
  onMouseMove(Z) {
    let J = GI0(this.props.vertical, Z);
    this.onMove(Z, J - this.dragOffset);
  }
  onMove(Z, J) {
    R10(Z);
    let $ = this.props, X = this.state, Y = J - this.startPosition;
    Y = this.props.vertical ? -Y : Y;
    let Q = Y / this.getSliderLength() * ($.max - $.min), W = this.trimAlignValue(this.startValue + Q), K = X.bounds[X.handle];
    if (W === K)
      return;
    let G = [...X.bounds];
    G[X.handle] = W;
    let H = X.handle;
    if ($.pushable) {
      let N = X.bounds[H];
      this.pushSurroundingHandles(G, H, N);
    } else if ($.allowCross)
      G.sort((N, q) => N - q), H = G.indexOf(W);
    this.onChange({
      handle: H,
      bounds: G
    });
  }
  onStart(Z) {
    this.props.onBeforeChange(this.getValue());
    let $ = this.calcValueByPos(Z);
    this.startValue = $, this.startPosition = Z;
    let X = this.state, { bounds: Y } = X, Q = 1;
    if (this.props.range) {
      let G = 0;
      for (let N = 1;N < Y.length - 1; ++N)
        if ($ > Y[N])
          G = N;
      if (Math.abs(Y[G + 1] - $) < Math.abs(Y[G] - $))
        G = G + 1;
      Q = G;
      let H = Y[G + 1] === Y[G];
      if (H)
        Q = X.recent;
      if (H && $ !== Y[G + 1])
        Q = $ < Y[G + 1] ? G : G + 1;
    }
    this.setState({
      handle: Q,
      recent: Q
    });
    let W = X.bounds[Q];
    if ($ === W)
      return;
    let K = [...X.bounds];
    K[Q] = $, this.onChange({ bounds: K });
  }
  getPoints() {
    let { marks: Z, step: J, min: $, max: X } = this.props, Y = this._getPointsCache;
    if (!Y || Y.marks !== Z || Y.step !== J) {
      let Q = { ...Z };
      if (J !== null)
        for (let K = $;K <= X; K += J)
          Q[K] = K;
      let W = Object.keys(Q).map(parseFloat);
      W.sort((K, G) => K - G), this._getPointsCache = { marks: Z, step: J, points: W };
    }
    return this._getPointsCache.points;
  }
  getPrecision(Z) {
    let J = Z.toString(), $ = 0;
    if (J.indexOf(".") >= 0)
      $ = J.length - J.indexOf(".") - 1;
    return $;
  }
  getSliderLength() {
    let Z = this.sliderElement.current;
    if (!Z)
      return 0;
    return this.props.vertical ? Z.clientHeight : Z.clientWidth;
  }
  getSliderStart() {
    let J = this.sliderElement.current.getBoundingClientRect();
    return this.props.vertical ? J.top : J.left;
  }
  getValue() {
    let { bounds: Z } = this.state;
    return this.props.range ? Z : Z[1];
  }
  addDocumentEvents(Z) {
    if (Z === "touch")
      document.addEventListener("touchmove", this.eventHandlers.touchmove), document.addEventListener("touchend", this.eventHandlers.touchend);
    else if (Z === "mouse")
      document.addEventListener("mousemove", this.eventHandlers.mousemove), document.addEventListener("mouseup", this.eventHandlers.mouseup);
  }
  calcValue(Z) {
    let { vertical: J, min: $, max: X } = this.props, Y = Math.abs(Z / this.getSliderLength());
    return J ? (1 - Y) * (X - $) + $ : Y * (X - $) + $;
  }
  calcValueByPos(Z) {
    let J = Z - this.getSliderStart();
    return this.trimAlignValue(this.calcValue(J));
  }
  end(Z) {
    this.removeEvents(Z), this.props.onAfterChange(this.getValue()), this.setState({ handle: null });
  }
  isEventFromHandle(Z) {
    for (let J of this.handleElements)
      if (J.current === Z.target)
        return !0;
    return !1;
  }
  isValueOutOfBounds(Z, J) {
    return Z < J.min || Z > J.max;
  }
  pushHandle(Z, J, $, X) {
    let Y = Z[J], Q = Z[J];
    while ($ * (Q - Y) < X) {
      if (!this.pushHandleOnePoint(Z, J, $))
        return Z[J] = Y, !1;
      Q = Z[J];
    }
    return !0;
  }
  pushHandleOnePoint(Z, J, $) {
    let X = this.getPoints(), Q = X.indexOf(Z[J]) + $;
    if (Q >= X.length || Q < 0)
      return !1;
    let W = J + $, K = X[Q], { pushable: G } = this.props, H = $ * (Z[W] - K);
    if (!this.pushHandle(Z, W, $, +G - H))
      return !1;
    return Z[J] = K, !0;
  }
  pushSurroundingHandles(Z, J, $) {
    let { pushable: X } = this.props, Y = Z[J], Q = 0;
    if (Z[J + 1] - Y < +X)
      Q = 1;
    else if (Y - Z[J - 1] < +X)
      Q = -1;
    if (Q === 0)
      return;
    let W = J + Q, K = Q * (Z[W] - Y);
    if (!this.pushHandle(Z, W, Q, +X - K))
      Z[J] = $;
  }
  removeEvents(Z) {
    if (Z === "touch")
      document.removeEventListener("touchmove", this.eventHandlers.touchmove), document.removeEventListener("touchend", this.eventHandlers.touchend);
    else if (Z === "mouse")
      document.removeEventListener("mousemove", this.eventHandlers.mousemove), document.removeEventListener("mouseup", this.eventHandlers.mouseup);
  }
  trimAlignValue(Z, J) {
    let { handle: $, bounds: X } = this.state || {}, { marks: Y, step: Q, min: W, max: K, allowCross: G } = { ...this.props, ...J || {} }, H = Z;
    if (H <= W)
      H = W;
    if (H >= K)
      H = K;
    if (!G && $ != null && $ > 0 && H <= X[$ - 1])
      H = X[$ - 1];
    if (!G && $ != null && $ < X.length - 1 && H >= X[$ + 1])
      H = X[$ + 1];
    let N = Object.keys(Y).map(parseFloat);
    if (Q !== null) {
      let F = Math.round((H - W) / Q) * Q + W;
      N.push(F);
    }
    let q = N.map((F) => Math.abs(H - F)), U = N[q.indexOf(Math.min.apply(Math, q))];
    return Q !== null ? parseFloat(U.toFixed(this.getPrecision(Q))) : U;
  }
  render() {
    let { handle: Z, bounds: J } = this.state, { className: $, prefixCls: X, disabled: Y, vertical: Q, range: W, step: K, marks: G, tipFormatter: H } = this.props, N = this.props.handle, q = J.map(this.calcOffset), U = `${X}-handle`, F = J.map((A, B) => E10({
      [U]: !0,
      [`${U}-${B + 1}`]: !0,
      [`${U}-lower`]: B === 0,
      [`${U}-upper`]: B === J.length - 1
    })), R = {
      prefixCls: X,
      noTip: K === null || H === null,
      tipFormatter: H,
      vertical: Q
    };
    if (this.handleElements.length !== J.length) {
      this.handleElements = [];
      for (let A = 0;A < J.length; A++)
        this.handleElements.push(Iq.createRef());
    }
    let z = J.map((A, B) => Iq.cloneElement(N, {
      ...R,
      className: F[B],
      value: A,
      offset: q[B],
      dragging: Z === B,
      index: B,
      key: B,
      ref: this.handleElements[B]
    }));
    if (!W)
      z.shift();
    let D = E10({
      [X]: !0,
      [`${X}-with-marks`]: Object.keys(G).length,
      [`${X}-disabled`]: Y,
      [`${X}-vertical`]: this.props.vertical,
      [$]: !!$
    });
    return xY.jsxs("div", { ref: this.sliderElement, className: D, onTouchStart: Y ? xX : this.onTouchStart, onMouseDown: Y ? xX : this.onMouseDown, onWheel: Y ? xX : this.props.onWheel, children: [xY.jsx("div", { className: `${X}-rail` }), z] });
  }
}
zy.defaultProps = {
  prefixCls: "msp-slider-base",
  className: "",
  min: 0,
  max: 100,
  step: 1,
  marks: {},
  handle: xY.jsx(NI0, { className: "", vertical: !1, offset: 0, tipFormatter: (Z) => Z, value: 0, index: 0 }),
  onBeforeChange: xX,
  onChange: xX,
  onAfterChange: xX,
  tipFormatter: (Z, J) => Z,
  disabled: !1,
  range: !1,
  vertical: !1,
  allowCross: !0,
  pushable: !1
};

// node_modules/molstar/lib/mol-util/color/utils.js
var nO1 = /^#([0-9A-F]{3}){1,2}$/i, iO1 = /^rgb\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*\)$/i;
function qI0(Z) {
  if (Z === void 0 || Z === null)
    return;
  let J;
  if (nO1.test(Z)) {
    if (Z.length === 4)
      Z = `#${Z[1]}${Z[1]}${Z[2]}${Z[2]}${Z[3]}${Z[3]}`;
    if (J = i0.fromHexStyle(Z), J !== void 0 && !isNaN(J))
      return J;
  }
  if (J = c2[Z.toLowerCase()], J !== void 0)
    return J;
  let $ = iO1.exec(Z);
  if ($) {
    let X = parseInt($[1], 10), Y = parseInt($[2], 10), Q = parseInt($[3], 10);
    if (X >= 0 && X <= 255 && Y >= 0 && Y <= 255 && Q >= 0 && Q <= 255)
      return i0.fromRgb(X, Y, Q);
  }
  return;
}
function Dy(Z) {
  let J = Z.length, $ = [];
  if (Z.every((Y) => Array.isArray(Y))) {
    let Y = [...Z];
    if (!Y[0])
      return "linear-gradient(to right, #000 0%, #000 100%)";
    Y.sort((Q, W) => Q[1] - W[1]), $.push(`${i0.toStyle(Y[0][0])} ${(100 * Y[0][1]).toFixed(2)}%`);
    for (let Q = 0, W = Y.length - 1;Q < W; ++Q) {
      let [K, G] = Y[Q], [H, N] = Y[Q + 1], q = G + (N - G) / 2;
      $.push(`${i0.toStyle(K)} ${(100 * q).toFixed(2)}%`, `${i0.toStyle(H)} ${(100 * q).toFixed(2)}%`);
    }
    $.push(`${i0.toStyle(Y[Y.length - 1][0])} ${(100 * Y[Y.length - 1][1]).toFixed(2)}%`);
  } else {
    $.push(`${AB(Z[0])} ${100 * (1 / J)}%`);
    for (let Y = 1, Q = J - 1;Y < Q; ++Y)
      $.push(`${AB(Z[Y])} ${100 * (Y / J)}%`, `${AB(Z[Y])} ${100 * ((Y + 1) / J)}%`);
    $.push(`${AB(Z[J - 1])} ${100 * ((J - 1) / J)}%`);
  }
  return `linear-gradient(to right, ${$.join(", ")})`;
}
function My(Z) {
  if (Z.length === 0)
    return "linear-gradient(to right, #000 0%, #000 100%)";
  let J = Z.every((X) => Array.isArray(X)), $;
  if (J) {
    let X = [...Z];
    X.sort((Y, Q) => Y[1] - Q[1]), $ = X.map((Y) => AB(Y, !0));
  } else
    $ = Z.map((X) => AB(X));
  return `linear-gradient(to right, ${$.join(", ")})`;
}
function AB(Z, J = !1) {
  if (Array.isArray(Z)) {
    if (J)
      return `${i0.toStyle(Z[0])} ${(100 * Z[1]).toFixed(2)}%`;
    return i0.toStyle(Z[0]);
  }
  return i0.toStyle(Z);
}
function FI0(Z, J = /,/) {
  let $ = [], X = Z.replace(/\s+/g, ""), Y = 0, Q = 0;
  for (let W = 0, K = X.length;W < K; ++W) {
    let G = X[W];
    if (G === "(") {
      Q++;
      continue;
    } else if (G === ")") {
      if (Q > 0)
        Q--;
      continue;
    }
    if (Q > 0)
      continue;
    if (!J.test(G))
      continue;
    let H = X.substring(Y, W);
    Y = W + 1;
    let N = qI0(H);
    if (N !== void 0)
      $.push(N);
  }
  if (Y < X.length) {
    let W = X.substring(Y), K = qI0(W);
    if (console.log(W, K), K !== void 0)
      $.push(K);
  }
  return $;
}

// node_modules/molstar/lib/mol-plugin-ui/controls/parameters.js
class iZ extends M7.PureComponent {
  constructor() {
    super(...arguments);
    this.onChange = (Z) => {
      var J, $;
      if (($ = (J = this.props).onChange) === null || $ === void 0 || $.call(J, Z, this.props.values), this.props.onChangeValues) {
        let X = { ...this.props.values, [Z.name]: Z.value };
        this.props.onChangeValues(X, this.props.values);
      }
    }, this.paramGroups = cJ((Z) => oO1(Z));
  }
  renderGroup(Z) {
    var J;
    if (Z.length === 0)
      return null;
    let $ = this.props.values, X = null, Y = void 0;
    for (let [Q, W, K] of Z) {
      if ((J = W.hideIf) === null || J === void 0 ? void 0 : J.call(W, $))
        continue;
      if (!X)
        X = [];
      Y = W.category, X.push(V1.jsx(K, { param: W, onChange: this.onChange, onEnter: this.props.onEnter, isDisabled: this.props.isDisabled, name: Q, value: $[Q] }, Q));
    }
    if (!X)
      return null;
    if (Y)
      return [V1.jsx(g$, { header: Y, children: X }, Y)];
    return X;
  }
  renderPart(Z) {
    let J = null;
    for (let $ of Z) {
      let X = this.renderGroup($);
      if (!X)
        continue;
      if (!J)
        J = [];
      for (let Y of X)
        J.push(Y);
    }
    return J;
  }
  render() {
    let Z = this.paramGroups(this.props.params), J = this.renderPart(Z.essentials), $ = this.renderPart(Z.advanced);
    if (J && $)
      return V1.jsxs(V1.Fragment, { children: [J, V1.jsx(g$, { header: "Advanced Options", children: $ })] });
    else if (J)
      return J;
    else
      return $;
  }
}

class z10 extends I8 {
  constructor() {
    super(...arguments);
    this.state = {
      isDisabled: !1
    }, this.setSettings = (Z, J) => {
      let $ = { ...J, [Z.name]: Z.value }, X = this.props.mapping.update($, this.plugin);
      this.props.mapping.apply(X, this.plugin);
    };
  }
  componentDidMount() {
    this.subscribe(this.plugin.state.data.behaviors.isUpdating, (Z) => {
      this.setState({ isDisabled: Z });
    });
  }
  render() {
    let Z = this.props.mapping.getTarget(this.plugin), J = this.props.mapping.getValues(Z, this.plugin), $ = this.props.mapping.params(this.plugin);
    return V1.jsx(iZ, { params: $, values: J, onChange: this.setSettings, isDisabled: this.state.isDisabled });
  }
}
function oO1(Z) {
  function J(W, K, G) {
    let H = hI(K);
    if (!H)
      return;
    if (!K.category)
      G.params[0].push([W, K, H]);
    else {
      if (!G.map)
        G.map = /* @__PURE__ */ new Map;
      let N = G.map.get(K.category);
      if (!N)
        N = [], G.map.set(K.category, N), G.params.push(N);
      N.push([W, K, H]);
    }
  }
  function $(W, K) {
    let G = W[0], H = K[0];
    if (!G || !G[1].category)
      return -1;
    if (!H || !H[1].category)
      return 1;
    return G[1].category < H[1].category ? -1 : 1;
  }
  let X = Object.keys(Z), Y = { params: [[]], map: void 0 }, Q = { params: [[]], map: void 0 };
  for (let W of X) {
    let K = Z[W];
    if (K.isHidden)
      continue;
    if (K.isEssential)
      J(W, K, Y);
    else
      J(W, K, Q);
  }
  return Y.params.sort($), Q.params.sort($), { essentials: Y.params, advanced: Q.params };
}
function hI(Z) {
  switch (Z.type) {
    case "value":
      return;
    case "boolean":
      return wy;
    case "number":
      return typeof Z.min !== "undefined" && typeof Z.max !== "undefined" ? RI0 : LI0;
    case "converted":
      return CI0;
    case "conditioned":
      return PI0;
    case "multi-select":
      return _I0;
    case "color":
      return fI;
    case "color-list":
      return Z.offsets ? MI0 : DI0;
    case "vec3":
      return AI0;
    case "mat4":
      return BI0;
    case "url":
      return wI0;
    case "file":
      return jI0;
    case "file-list":
      return TI0;
    case "select":
      return bI;
    case "value-ref":
      return A10;
    case "data-ref":
      return;
    case "text":
      return M10;
    case "interval":
      return typeof Z.min !== "undefined" && typeof Z.max !== "undefined" ? OI0 : EI0;
    case "group":
      return w10;
    case "mapped":
      return VI0;
    case "line-graph":
      return UI0;
    case "script":
      return kI0;
    case "object-list":
      return jy;
    default:
      console.warn(`${Z} has no associated UI component`);
      return;
  }
}

class By extends M7.PureComponent {
  render() {
    let { legend: Z, description: J } = this.props, $ = Z && JI0(Z);
    return V1.jsx("div", { className: "msp-help-text", children: V1.jsxs("div", { children: [V1.jsxs("div", { className: "msp-help-description", children: [V1.jsx(b6, { svg: OQ, inline: !0 }), J] }), $ && V1.jsx("div", { className: "msp-help-legend", children: V1.jsx($, { legend: Z }) })] }) });
  }
}
function az(Z) {
  let { props: J, state: $, control: X, toggleHelp: Y, addOn: Q } = Z, W = [];
  if (J.param.shortLabel)
    W.push("msp-control-label-short");
  if (J.param.twoColumns)
    W.push("msp-control-col-2");
  if (J.param.multiline)
    W.push("msp-control-twoline");
  let K = W.join(" "), G = J.param.label || s$(J.name), H = J.param.help ? J.param.help(J.value) : { description: J.param.description, legend: J.param.legend }, N = H.description || H.legend, q = G + (N ? ". Click for help." : "");
  return V1.jsxs(V1.Fragment, { children: [V1.jsx(bY, { className: K, title: q, label: V1.jsxs(V1.Fragment, { children: [G, N && V1.jsx(D10, { show: $.showHelp, toggle: Y, title: q })] }), control: X }), N && $.showHelp && V1.jsx("div", { className: "msp-control-offset", children: V1.jsx(By, { legend: H.legend, description: H.description }) }), Q] });
}
function D10({ show: Z, toggle: J, title: $ }) {
  return V1.jsx("button", { className: "msp-help msp-btn-link msp-btn-icon msp-control-group-expander", onClick: J, title: $ || `${Z ? "Hide" : "Show"} help`, style: { background: "transparent", textAlign: "left", padding: "0" }, children: V1.jsx(b6, { svg: OQ }) });
}

class BB extends M7.PureComponent {
  constructor() {
    super(...arguments);
    this.state = { showHelp: !1 }, this.toggleHelp = () => this.setState({ showHelp: !this.state.showHelp });
  }
  update(Z) {
    this.props.onChange({ param: this.props.param, name: this.props.name, value: Z });
  }
  renderAddOn() {
    return null;
  }
  render() {
    return az({
      props: this.props,
      state: this.state,
      control: this.renderControl(),
      toggleHelp: this.toggleHelp,
      addOn: this.renderAddOn()
    });
  }
}

class wy extends BB {
  constructor() {
    super(...arguments);
    this.onClick = (Z) => {
      this.update(!this.props.value), Z.currentTarget.blur();
    };
  }
  renderControl() {
    return V1.jsxs("button", { onClick: this.onClick, disabled: this.props.isDisabled, children: [V1.jsx(b6, { svg: this.props.value ? xK : X10 }), this.props.value ? "On" : "Off"] });
  }
}

class UI0 extends M7.PureComponent {
  constructor() {
    super(...arguments);
    this.state = {
      isExpanded: !1,
      isOverPoint: !1,
      message: `${this.props.param.defaultValue.length} points`
    }, this.onHover = (Z) => {
      if (this.setState({ isOverPoint: !this.state.isOverPoint }), Z)
        this.setState({ message: this.pointToLabel(Z) });
      else
        this.setState({ message: `${this.props.value.length} points` });
    }, this.onDrag = (Z) => {
      this.setState({ message: this.pointToLabel(Z) });
    }, this.onChange = (Z) => {
      this.props.onChange({ name: this.props.name, param: this.props.param, value: Z });
    }, this.toggleExpanded = (Z) => {
      this.setState({ isExpanded: !this.state.isExpanded }), Z.currentTarget.blur();
    };
  }
  pointToLabel(Z) {
    var J, $;
    if (!Z)
      return "";
    let X = ($ = (J = this.props.param).getVolume) === null || $ === void 0 ? void 0 : $.call(J);
    if (X) {
      let { min: Y, max: Q, mean: W, sigma: K } = X.grid.stats, G = Y + (Q - Y) * Z[0], H = (G - W) / K;
      return `(${G.toFixed(2)} | ${H.toFixed(2)}σ, ${Z[1].toFixed(2)})`;
    } else
      return `(${Z[0].toFixed(2)}, ${Z[1].toFixed(2)})`;
  }
  render() {
    var Z, J;
    let $ = this.props.param.label || s$(this.props.name);
    return V1.jsxs(V1.Fragment, { children: [V1.jsx(bY, { label: $, control: V1.jsx("button", { onClick: this.toggleExpanded, disabled: this.props.isDisabled, children: `${this.state.message}` }) }), V1.jsx("div", { className: "msp-control-offset", style: { display: this.state.isExpanded ? "block" : "none", marginTop: 1 }, children: V1.jsx(L10, { data: this.props.value, volume: (J = (Z = this.props.param).getVolume) === null || J === void 0 ? void 0 : J.call(Z), onChange: this.onChange, onHover: this.onHover, onDrag: this.onDrag }) })] });
  }
}

class LI0 extends M7.PureComponent {
  constructor() {
    super(...arguments);
    this.state = { value: "0" }, this.update = (Z) => {
      let J = Xz(this.props.param.step || 0.01);
      Z = parseFloat(Z.toFixed(J)), this.props.onChange({ param: this.props.param, name: this.props.name, value: Z });
    };
  }
  render() {
    let Z = this.props.param.label || s$(this.props.name), J = this.props.param.label || s$(this.props.name), $ = Xz(this.props.param.step || 0.01);
    return V1.jsx(bY, { title: this.props.param.description, label: J, control: V1.jsx(x5, { numeric: !0, value: parseFloat(this.props.value.toFixed($)), onEnter: this.props.onEnter, placeholder: Z, isDisabled: this.props.isDisabled, onChange: this.update }) });
  }
}

class RI0 extends BB {
  constructor() {
    super(...arguments);
    this.onChange = (Z) => {
      this.update(Z);
    };
  }
  renderControl() {
    let Z = typeof this.props.value === "undefined" ? this.props.param.defaultValue : this.props.value;
    return V1.jsx(sz, { value: Z, min: this.props.param.min, max: this.props.param.max, step: this.props.param.step, onChange: this.onChange, onChangeImmediate: this.props.param.immediateUpdate ? this.onChange : void 0, disabled: this.props.isDisabled, onEnter: this.props.onEnter });
  }
}

class M10 extends BB {
  constructor() {
    super(...arguments);
    this.updateValue = (Z) => {
      if (Z !== this.props.value)
        this.update(Z);
    };
  }
  renderControl() {
    let Z = this.props.param.placeholder || this.props.param.label || s$(this.props.name);
    return V1.jsx(sO1, { props: this.props, placeholder: Z, update: this.updateValue });
  }
}
function sO1({ props: Z, placeholder: J, update: $ }) {
  let [X, Y] = M7.useState(Z.value), [Q, W] = M7.useState(!1);
  M7.useEffect(() => Y(Z.value), [Z.value]);
  let K = (q) => {
    if (Q || Z.param.disableInteractiveUpdates)
      Y(q.target.value);
    else
      $(q.target.value);
  }, G = (q) => {
    W(!1);
    let U = q.target;
    if (Z.param.disableInteractiveUpdates)
      Y(U.value);
    else
      $(U.value);
  }, H = (q) => {
    if (Z.param.disableInteractiveUpdates)
      $(q.target.value);
  }, N = (q) => {
    if (q.key !== "Enter")
      return;
    if (Z.onEnter && !Z.param.multiline)
      q.stopPropagation(), Z.onEnter();
    else if (q.shiftKey || q.ctrlKey || q.metaKey)
      q.currentTarget.blur();
    else if (Z.param.disableInteractiveUpdates && !Z.param.multiline)
      $(X);
  };
  if (Z.param.multiline)
    return V1.jsx("div", { className: "msp-control-text-area-wrapper", children: V1.jsx("textarea", { value: X !== null && X !== void 0 ? X : "", placeholder: J, disabled: Z.isDisabled, onChange: K, onBlur: H, onKeyDown: N, onCompositionStart: () => W(!0), onCompositionEnd: G }) });
  else
    return V1.jsx("input", { type: "text", value: X !== null && X !== void 0 ? X : "", placeholder: J, disabled: Z.isDisabled, onChange: K, onBlur: H, onKeyDown: N, onCompositionStart: () => W(!0), onCompositionEnd: G });
}

class _U extends M7.PureComponent {
  constructor() {
    super(...arguments);
    this.onChange = (Z) => {
      if (typeof this.props.param.defaultValue === "number")
        this.update(parseInt(Z.target.value, 10));
      else
        this.update(Z.target.value);
    };
  }
  update(Z) {
    this.props.onChange({ param: this.props.param, name: this.props.name, value: Z });
  }
  render() {
    let Z = this.props.value !== void 0 && !this.props.param.options.some((J) => J[0] === this.props.value);
    return V1.jsxs("select", { className: "msp-form-control", title: this.props.title, value: this.props.value !== void 0 ? this.props.value : this.props.param.defaultValue, onChange: this.onChange, disabled: this.props.isDisabled, children: [Z && V1.jsx("option", { value: this.props.value, children: `[Invalid] ${this.props.value}` }, this.props.value), this.props.param.options.map(([J, $]) => V1.jsx("option", { value: J, children: $ }, J))] });
  }
}

class bI extends M7.PureComponent {
  constructor() {
    super(...arguments);
    this.state = { showHelp: !1, showOptions: !1 }, this.onSelect = (Z) => {
      if (!Z || Z.value === this.props.value)
        this.setState({ showOptions: !1 });
      else
        this.setState({ showOptions: !1 }, () => {
          this.props.onChange({ param: this.props.param, name: this.props.name, value: Z.value });
        });
    }, this.toggle = () => this.setState({ showOptions: !this.state.showOptions }), this.cycle = () => {
      let { options: Z } = this.props.param, J = Z.findIndex((X) => X[0] === this.props.value), $ = J === Z.length - 1 ? 0 : J + 1;
      this.props.onChange({ param: this.props.param, name: this.props.name, value: Z[$][0] });
    }, this.items = cJ((Z) => w8.createItemsFromSelectOptions(Z.options)), this.toggleHelp = () => this.setState({ showHelp: !this.state.showHelp });
  }
  renderControl() {
    var Z;
    let J = this.items(this.props.param), $ = this.props.value !== void 0 ? w8.findItem(J, this.props.value) : void 0, X = $ ? $.label : typeof this.props.value === "undefined" ? `${((Z = w8.getFirstItem(J)) === null || Z === void 0 ? void 0 : Z.label) || ""} [Default]` : `[Invalid] ${this.props.value}`, Y = this.props.param.cycle ? this.cycle : this.toggle, Q = this.props.param.cycle ? "center" : "left", W = this.props.param.cycle ? this.props.value === "on" ? xK : this.props.value === "off" ? X10 : void 0 : void 0;
    return V1.jsx(D7, { disabled: this.props.isDisabled, style: { textAlign: Q, overflow: "hidden", textOverflow: "ellipsis" }, label: X, title: X, icon: W, toggle: Y, isSelected: this.state.showOptions, className: "msp-select-toggle" });
  }
  renderAddOn() {
    if (!this.state.showOptions)
      return null;
    let Z = this.items(this.props.param), J = w8.findItem(Z, this.props.value);
    return V1.jsx(w8, { items: Z, current: J, onSelect: this.onSelect });
  }
  render() {
    return az({
      props: this.props,
      state: this.state,
      control: this.renderControl(),
      toggleHelp: this.toggleHelp,
      addOn: this.renderAddOn()
    });
  }
}

class A10 extends M7.PureComponent {
  constructor() {
    super(...arguments);
    this.state = { showHelp: !1, showOptions: !1 }, this.onSelect = (Z) => {
      if (!Z || Z.value === this.props.value)
        this.setState({ showOptions: !1 });
      else
        this.setState({ showOptions: !1 }, () => {
          this.props.onChange({ param: this.props.param, name: this.props.name, value: { ref: Z.value } });
        });
    }, this.toggle = () => this.setState({ showOptions: !this.state.showOptions }), this.toggleHelp = () => this.setState({ showHelp: !this.state.showHelp });
  }
  get items() {
    return w8.createItemsFromSelectOptions(this.props.param.getOptions(this.context));
  }
  renderControl() {
    var Z;
    let J = this.items, $ = this.props.value.ref ? w8.findItem(J, this.props.value.ref) : void 0, X = $ ? $.label : `[Ref] ${(Z = this.props.value.ref) !== null && Z !== void 0 ? Z : ""}`;
    return V1.jsx(D7, { disabled: this.props.isDisabled, style: { textAlign: "left", overflow: "hidden", textOverflow: "ellipsis" }, label: X, title: X, toggle: this.toggle, isSelected: this.state.showOptions });
  }
  renderAddOn() {
    if (!this.state.showOptions)
      return null;
    let Z = this.items, J = w8.findItem(Z, this.props.value.ref);
    return V1.jsx(w8, { items: Z, current: J, onSelect: this.onSelect });
  }
  render() {
    return az({
      props: this.props,
      state: this.state,
      control: this.renderControl(),
      toggleHelp: this.toggleHelp,
      addOn: this.renderAddOn()
    });
  }
}
A10.contextType = DQ;

class EI0 extends M7.PureComponent {
  constructor() {
    super(...arguments);
    this.state = { isExpanded: !1 }, this.components = {
      0: j.Numeric(0, { step: this.props.param.step }, { label: "Min" }),
      1: j.Numeric(0, { step: this.props.param.step }, { label: "Max" })
    }, this.componentChange = ({ name: Z, value: J }) => {
      let $ = [...this.props.value];
      $[+Z] = J, this.change($);
    }, this.toggleExpanded = (Z) => {
      this.setState({ isExpanded: !this.state.isExpanded }), Z.currentTarget.blur();
    };
  }
  change(Z) {
    this.props.onChange({ name: this.props.name, param: this.props.param, value: Z });
  }
  render() {
    let Z = this.props.value, J = this.props.param.label || s$(this.props.name), $ = Xz(this.props.param.step || 0.01), X = `[${Z[0].toFixed($)}, ${Z[1].toFixed($)}]`;
    return V1.jsxs(V1.Fragment, { children: [V1.jsx(bY, { label: J, control: V1.jsx("button", { onClick: this.toggleExpanded, disabled: this.props.isDisabled, children: X }) }), this.state.isExpanded && V1.jsx("div", { className: "msp-control-offset", children: V1.jsx(iZ, { params: this.components, values: Z, onChange: this.componentChange, onEnter: this.props.onEnter }) })] });
  }
}

class OI0 extends BB {
  constructor() {
    super(...arguments);
    this.onChange = (Z) => {
      this.update(Z);
    };
  }
  renderControl() {
    return V1.jsx(O10, { value: this.props.value, min: this.props.param.min, max: this.props.param.max, step: this.props.param.step, onChange: this.onChange, disabled: this.props.isDisabled, onEnter: this.props.onEnter });
  }
}
var aO1 = QH(My), rO1 = QH(Dy);
function B10(Z, J = "0") {
  return {
    background: tO1(Z.colors, Z.kind === "set"),
    position: "absolute",
    bottom: "0",
    height: "4px",
    right: J,
    left: "0"
  };
}
function tO1(Z, J) {
  return J ? rO1(Z) : aO1(Z);
}
function eO1() {
  let Z = (J) => {
    let $ = RJ(J[0]);
    return V1.jsx("div", { style: B10({ kind: $.type !== "qualitative" ? "interpolate" : "set", colors: $.list }) });
  };
  return {
    ColorPresets: {
      all: w8.createItemsFromSelectOptions(jS, { addOn: Z, description: (J) => J[3] }),
      scale: w8.createItemsFromSelectOptions(o50, { addOn: Z, description: (J) => J[3] }),
      set: w8.createItemsFromSelectOptions(s50, { addOn: Z, description: (J) => J[3] })
    },
    ColorsParam: j.ObjectList({ color: j.Color(0) }, ({ color: J }) => i0.toHexString(J).toUpperCase()),
    OffsetColorsParam: j.ObjectList({ color: j.Color(0), offset: j.Numeric(0, { min: 0, max: 1, step: 0.01 }) }, ({ color: J, offset: $ }) => `${i0.toHexString(J).toUpperCase()} [${$.toFixed(2)}]`),
    IsInterpolatedParam: j.Boolean(!1, { label: "Interpolated" })
  };
}
var Ay;
function zI0() {
  if (Ay)
    return Ay;
  return Ay = eO1(), Ay;
}

class DI0 extends M7.PureComponent {
  constructor() {
    super(...arguments);
    this.state = { showHelp: !1, show: void 0 }, this.toggleEdit = () => this.setState({ show: this.state.show === "edit" ? void 0 : "edit" }), this.togglePresets = () => this.setState({ show: this.state.show === "presets" ? void 0 : "presets" }), this.selectPreset = (Z) => {
      if (!Z)
        return;
      this.setState({ show: void 0 });
      let J = RJ(Z.value);
      this.update({ kind: J.type !== "qualitative" ? "interpolate" : "set", colors: J.list });
    }, this.colorsChanged = ({ value: Z }) => {
      this.update({
        kind: this.props.value.kind,
        colors: Z.map((J) => J.color)
      });
    }, this.isInterpolatedChanged = ({ value: Z }) => {
      this.update({ kind: Z ? "interpolate" : "set", colors: this.props.value.colors });
    }, this.toggleHelp = () => this.setState({ showHelp: !this.state.showHelp });
  }
  update(Z) {
    this.props.onChange({ param: this.props.param, name: this.props.name, value: Z });
  }
  renderControl() {
    let { value: Z } = this.props;
    return V1.jsxs(V1.Fragment, { children: [V1.jsxs("button", { onClick: this.toggleEdit, style: { position: "relative", paddingRight: "33px" }, children: [Z.colors.length === 1 ? "1 color" : `${Z.colors.length} colors`, V1.jsx("div", { style: B10(Z, "33px") })] }), V1.jsx(o2, { svg: wU, onClick: this.togglePresets, toggleState: this.state.show === "presets", title: "Color Presets", style: { padding: 0, position: "absolute", right: 0, top: 0, width: "32px" } })] });
  }
  renderColors() {
    if (!this.state.show)
      return null;
    let { ColorPresets: Z, ColorsParam: J, IsInterpolatedParam: $ } = zI0(), X = Z[this.props.param.presetKind];
    if (this.state.show === "presets")
      return V1.jsx(w8, { items: X, onSelect: this.selectPreset });
    let Y = this.props.value.colors.map((Q) => ({
      color: Array.isArray(Q) ? Q[0] : Q
    }));
    return V1.jsxs("div", { className: "msp-control-offset", children: [V1.jsx(jy, { name: "colors", param: J, value: Y, onChange: this.colorsChanged, isDisabled: this.props.isDisabled, onEnter: this.props.onEnter }), V1.jsx(wy, { name: "isInterpolated", param: $, value: this.props.value.kind === "interpolate", onChange: this.isInterpolatedChanged, isDisabled: this.props.isDisabled, onEnter: this.props.onEnter })] });
  }
  render() {
    return az({
      props: this.props,
      state: this.state,
      control: this.renderControl(),
      toggleHelp: this.toggleHelp,
      addOn: this.renderColors()
    });
  }
}

class MI0 extends M7.PureComponent {
  constructor() {
    super(...arguments);
    this.state = { showHelp: !1, show: void 0 }, this.toggleEdit = () => this.setState({ show: this.state.show === "edit" ? void 0 : "edit" }), this.togglePresets = () => this.setState({ show: this.state.show === "presets" ? void 0 : "presets" }), this.selectPreset = (Z) => {
      if (!Z)
        return;
      this.setState({ show: void 0 });
      let J = RJ(Z.value);
      this.update({ kind: J.type !== "qualitative" ? "interpolate" : "set", colors: J.list });
    }, this.colorsChanged = ({ value: Z }) => {
      let J = Z.map(($) => [$.color, $.offset]);
      J.sort(($, X) => $[1] - X[1]), this.update({ kind: this.props.value.kind, colors: J });
    }, this.isInterpolatedChanged = ({ value: Z }) => {
      this.update({ kind: Z ? "interpolate" : "set", colors: this.props.value.colors });
    }, this.toggleHelp = () => this.setState({ showHelp: !this.state.showHelp });
  }
  update(Z) {
    this.props.onChange({ param: this.props.param, name: this.props.name, value: Z });
  }
  renderControl() {
    let { value: Z } = this.props;
    return V1.jsxs(V1.Fragment, { children: [V1.jsxs("button", { onClick: this.toggleEdit, style: { position: "relative", paddingRight: "33px" }, children: [Z.colors.length === 1 ? "1 color" : `${Z.colors.length} colors`, V1.jsx("div", { style: B10(Z, "33px") })] }), V1.jsx(o2, { svg: wU, onClick: this.togglePresets, toggleState: this.state.show === "presets", title: "Color Presets", style: { padding: 0, position: "absolute", right: 0, top: 0, width: "32px" } })] });
  }
  renderColors() {
    if (!this.state.show)
      return null;
    let { ColorPresets: Z, OffsetColorsParam: J, IsInterpolatedParam: $ } = zI0(), X = Z[this.props.param.presetKind];
    if (this.state.show === "presets")
      return V1.jsx(w8, { items: X, onSelect: this.selectPreset });
    let Y = this.props.value.colors, Q = Y.map((W, K) => {
      if (Array.isArray(W))
        return { color: W[0], offset: W[1] };
      return { color: W, offset: K / Y.length };
    });
    return Q.sort((W, K) => W.offset - K.offset), V1.jsxs("div", { className: "msp-control-offset", children: [V1.jsx(jy, { name: "colors", param: J, value: Q, onChange: this.colorsChanged, isDisabled: this.props.isDisabled, onEnter: this.props.onEnter }), V1.jsx(wy, { name: "isInterpolated", param: $, value: this.props.value.kind === "interpolate", onChange: this.isInterpolatedChanged, isDisabled: this.props.isDisabled, onEnter: this.props.onEnter })] });
  }
  render() {
    return az({
      props: this.props,
      state: this.state,
      control: this.renderControl(),
      toggleHelp: this.toggleHelp,
      addOn: this.renderColors()
    });
  }
}

class AI0 extends M7.PureComponent {
  constructor() {
    super(...arguments);
    this.state = { isExpanded: !1 }, this.components = {
      0: j.Numeric(0, { step: this.props.param.step }, { label: this.props.param.fieldLabels && this.props.param.fieldLabels.x || "X" }),
      1: j.Numeric(0, { step: this.props.param.step }, { label: this.props.param.fieldLabels && this.props.param.fieldLabels.y || "Y" }),
      2: j.Numeric(0, { step: this.props.param.step }, { label: this.props.param.fieldLabels && this.props.param.fieldLabels.z || "Z" })
    }, this.componentChange = ({ name: Z, value: J }) => {
      let $ = M.copy(M.zero(), this.props.value);
      $[+Z] = J, this.change($);
    }, this.toggleExpanded = (Z) => {
      this.setState({ isExpanded: !this.state.isExpanded }), Z.currentTarget.blur();
    };
  }
  change(Z) {
    this.props.onChange({ name: this.props.name, param: this.props.param, value: Z });
  }
  render() {
    let Z = this.props.value, J = this.props.param.label || s$(this.props.name), $ = Xz(this.props.param.step || 0.01), X = `[${Z[0].toFixed($)}, ${Z[1].toFixed($)}, ${Z[2].toFixed($)}]`;
    return V1.jsxs(V1.Fragment, { children: [V1.jsx(bY, { label: J, control: V1.jsx("button", { onClick: this.toggleExpanded, disabled: this.props.isDisabled, children: V1.jsx("div", { title: X, className: "msp-no-overflow", style: { display: "block" }, children: X }) }) }), this.state.isExpanded && V1.jsx("div", { className: "msp-control-offset", children: V1.jsx(iZ, { params: this.components, values: Z, onChange: this.componentChange, onEnter: this.props.onEnter }) })] });
  }
}

class BI0 extends M7.PureComponent {
  constructor() {
    super(...arguments);
    this.state = { isExpanded: !1 }, this.components = {
      json: j.Text(JSON.stringify(e()), { description: "JSON array with 4x4 matrix in a column major (j * 4 + i indexing) format" })
    }, this.componentChange = ({ name: Z, value: J }) => {
      let $ = e.copy(e(), this.props.value);
      if (Z === "json")
        e.copy($, JSON.parse(J));
      else
        $[+Z] = J;
      this.change($);
    }, this.toggleExpanded = (Z) => {
      this.setState({ isExpanded: !this.state.isExpanded }), Z.currentTarget.blur();
    };
  }
  change(Z) {
    this.props.onChange({ name: this.props.name, param: this.props.param, value: Z });
  }
  changeValue(Z) {
    return (J) => {
      let $ = e.copy(e(), this.props.value);
      $[Z] = J, this.change($);
    };
  }
  get grid() {
    let Z = this.props.value, J = [];
    for (let $ = 0;$ < 4; $++) {
      let X = [];
      for (let Y = 0;Y < 4; Y++)
        X.push(V1.jsx(x5, { numeric: !0, delayMs: 50, value: e.getValue(Z, $, Y), onChange: this.changeValue(4 * Y + $), className: "msp-form-control", blurOnEnter: !0, isDisabled: this.props.isDisabled }, Y));
      J.push(V1.jsx("div", { className: "msp-flex-row", children: X }, $));
    }
    return V1.jsx("div", { className: "msp-parameter-matrix", children: J });
  }
  render() {
    let Z = {
      json: JSON.stringify(this.props.value)
    }, J = this.props.param.label || s$(this.props.name);
    return V1.jsxs(V1.Fragment, { children: [V1.jsx(bY, { label: J, control: V1.jsx("button", { onClick: this.toggleExpanded, disabled: this.props.isDisabled, children: V1.jsx("div", { className: "msp-no-overflow", style: { display: "block" }, children: "4×4 Matrix" }) }) }), this.state.isExpanded && V1.jsxs("div", { className: "msp-control-offset", children: [this.grid, V1.jsx(iZ, { params: this.components, values: Z, onChange: this.componentChange, onEnter: this.props.onEnter })] })] });
  }
}

class wI0 extends BB {
  constructor() {
    super(...arguments);
    this.onChange = (Z) => {
      let J = Z.target.value;
      if (J !== E6.getUrl(this.props.value || ""))
        this.update(E6.Url(J));
    }, this.onKeyPress = (Z) => {
      if (Z.keyCode === 13 || Z.charCode === 13 || Z.key === "Enter") {
        if (this.props.onEnter)
          this.props.onEnter();
      }
      Z.stopPropagation();
    };
  }
  renderControl() {
    let Z = this.props.param.label || s$(this.props.name);
    return V1.jsx("input", { type: "text", value: E6.getUrl(this.props.value || ""), placeholder: Z, onChange: this.onChange, onKeyPress: this.props.onEnter ? this.onKeyPress : void 0, disabled: this.props.isDisabled });
  }
}

class jI0 extends M7.PureComponent {
  constructor() {
    super(...arguments);
    this.state = { showHelp: !1 }, this.onChangeFile = (Z) => {
      this.change(Z.target.files[0]);
    }, this.toggleHelp = () => this.setState({ showHelp: !this.state.showHelp });
  }
  change(Z) {
    this.props.onChange({ name: this.props.name, param: this.props.param, value: E6.File(Z) });
  }
  renderControl() {
    let Z = this.props.value;
    return V1.jsxs("div", { className: "msp-btn msp-btn-block msp-btn-action msp-loader-msp-btn-file", style: { marginTop: "1px" }, children: [Z ? Z.name : "Select a file...", " ", V1.jsx("input", { disabled: this.props.isDisabled, onChange: this.onChangeFile, type: "file", multiple: !1, accept: this.props.param.accept })] });
  }
  render() {
    if (this.props.param.label)
      return az({
        props: this.props,
        state: this.state,
        control: this.renderControl(),
        toggleHelp: this.toggleHelp,
        addOn: null
      });
    else
      return this.renderControl();
  }
}

class TI0 extends M7.PureComponent {
  constructor() {
    super(...arguments);
    this.state = { showHelp: !1 }, this.onChangeFileList = (Z) => {
      this.change(Z.target.files);
    }, this.toggleHelp = () => this.setState({ showHelp: !this.state.showHelp });
  }
  change(Z) {
    let J = [];
    if (Z)
      for (let $ = 0, X = Z.length;$ < X; ++$)
        J.push(E6.File(Z[$]));
    this.props.onChange({ name: this.props.name, param: this.props.param, value: J });
  }
  renderControl() {
    let Z = this.props.value, J = [];
    if (Z)
      for (let X of Z)
        J.push(X.name);
    let $ = J.length === 0 ? "Select files..." : J.length === 1 ? J[0] : `${J.length} files selected`;
    return V1.jsxs("div", { className: "msp-btn msp-btn-block msp-btn-action msp-loader-msp-btn-file", style: { marginTop: "1px" }, children: [$, " ", V1.jsx("input", { disabled: this.props.isDisabled, onChange: this.onChangeFileList, type: "file", multiple: !0, accept: this.props.param.accept })] });
  }
  render() {
    if (this.props.param.label)
      return az({
        props: this.props,
        state: this.state,
        control: this.renderControl(),
        toggleHelp: this.toggleHelp,
        addOn: null
      });
    else
      return this.renderControl();
  }
}

class _I0 extends M7.PureComponent {
  constructor() {
    super(...arguments);
    this.state = { isExpanded: !1 }, this.toggleExpanded = (Z) => {
      this.setState({ isExpanded: !this.state.isExpanded }), Z.currentTarget.blur();
    };
  }
  change(Z) {
    this.props.onChange({ name: this.props.name, param: this.props.param, value: Z });
  }
  toggle(Z) {
    return (J) => {
      if (this.props.value.indexOf(Z) < 0)
        this.change(this.props.value.concat(Z));
      else
        this.change(this.props.value.filter(($) => $ !== Z));
      J.currentTarget.blur();
    };
  }
  render() {
    let Z = this.props.value, J = this.props.param.emptyValue, $ = this.props.param.label || s$(this.props.name);
    return V1.jsxs(V1.Fragment, { children: [V1.jsx(bY, { label: $, control: V1.jsx("button", { onClick: this.toggleExpanded, disabled: this.props.isDisabled, children: Z.length === 0 && J ? J : `${Z.length} of ${this.props.param.options.length}` }) }), this.state.isExpanded && V1.jsx("div", { className: "msp-control-offset", children: this.props.param.options.map(([X, Y]) => {
      let Q = Z.indexOf(X) >= 0;
      return V1.jsx(Z8, { onClick: this.toggle(X), disabled: this.props.isDisabled, style: { marginTop: "1px" }, children: V1.jsx("span", { style: { float: Q ? "left" : "right" }, children: Q ? `✓ ${Y}` : `${Y} ✗` }) }, X);
    }) })] });
  }
}

class w10 extends M7.PureComponent {
  constructor() {
    super(...arguments);
    this.state = { isExpanded: !!this.props.param.isExpanded, showPresets: !1, showHelp: !1 }, this.onChangeParam = (Z) => {
      this.change({ ...this.props.value, [Z.name]: Z.value });
    }, this.toggleExpanded = () => this.setState({ isExpanded: !this.state.isExpanded }), this.toggleShowPresets = () => this.setState({ showPresets: !this.state.showPresets }), this.presetItems = cJ((Z) => {
      var J;
      return w8.createItemsFromSelectOptions((J = Z.presets) !== null && J !== void 0 ? J : []);
    }), this.onSelectPreset = (Z) => {
      this.setState({ showPresets: !1 }), this.change(Z === null || Z === void 0 ? void 0 : Z.value);
    };
  }
  change(Z) {
    this.props.onChange({ name: this.props.name, param: this.props.param, value: Z });
  }
  pivotedPresets() {
    if (!this.props.param.presets)
      return null;
    let Z = this.props.param.label || s$(this.props.name);
    return V1.jsxs("div", { className: "msp-control-group-wrapper", children: [V1.jsx("div", { className: "msp-control-group-header", children: V1.jsxs("button", { className: "msp-btn msp-form-control msp-btn-block", onClick: this.toggleShowPresets, children: [V1.jsx(b6, { svg: wU }), Z, " Presets"] }) }), this.state.showPresets && V1.jsx(w8, { items: this.presetItems(this.props.param), onSelect: this.onSelectPreset })] });
  }
  presets() {
    if (!this.props.param.presets)
      return null;
    return V1.jsxs(V1.Fragment, { children: [V1.jsx("div", { className: "msp-control-group-presets-wrapper", children: V1.jsx("div", { className: "msp-control-group-header", children: V1.jsxs("button", { className: "msp-btn msp-form-control msp-btn-block", onClick: this.toggleShowPresets, children: [V1.jsx(b6, { svg: wU }), "Presets"] }) }) }), this.state.showPresets && V1.jsx(w8, { items: this.presetItems(this.props.param), onSelect: this.onSelectPreset })] });
  }
  pivoted() {
    let Z = this.props.param.pivot, J = this.props.param.params, $ = J[Z], X = hI($), Y = V1.jsx(X, { name: Z, param: $, value: this.props.value[Z], onChange: this.onChangeParam, onEnter: this.props.onEnter, isDisabled: this.props.isDisabled });
    if (!this.state.isExpanded)
      return V1.jsxs("div", { className: "msp-mapped-parameter-group", children: [Y, V1.jsx(o2, { svg: lX, onClick: this.toggleExpanded, toggleState: this.state.isExpanded, title: "More Options", style: { opacity: 0.7 } })] });
    let Q = Object.create(null);
    for (let W of Object.keys(J))
      if (W !== Z)
        Q[W] = J[W];
    return V1.jsxs("div", { className: "msp-mapped-parameter-group", children: [Y, V1.jsx(o2, { svg: lX, onClick: this.toggleExpanded, toggleState: this.state.isExpanded, title: "More Options" }), V1.jsxs("div", { className: "msp-control-offset", children: [this.pivotedPresets(), V1.jsx(iZ, { params: Q, onEnter: this.props.onEnter, values: this.props.value, onChange: this.onChangeParam, isDisabled: this.props.isDisabled })] })] });
  }
  render() {
    let Z = this.props.param.params;
    if (Object.keys(Z).length === 0)
      return null;
    if (this.props.param.pivot)
      return this.pivoted();
    let J = this.props.param.label || s$(this.props.name), $ = V1.jsx(iZ, { params: Z, onChange: this.onChangeParam, values: this.props.value, onEnter: this.props.onEnter, isDisabled: this.props.isDisabled });
    if (this.props.inMapped)
      return V1.jsx("div", { className: "msp-control-offset", children: $ });
    if (this.props.param.isFlat)
      return $;
    return V1.jsxs("div", { className: "msp-control-group-wrapper", style: { position: "relative" }, children: [V1.jsx("div", { className: "msp-control-group-header", children: V1.jsxs("button", { className: "msp-btn msp-form-control msp-btn-block", onClick: this.toggleExpanded, children: [V1.jsx(b6, { svg: this.state.isExpanded ? JW : $W }), J] }) }), this.presets(), this.state.isExpanded && V1.jsx("div", { className: "msp-control-offset", children: $ })] });
  }
}

class VI0 extends M7.PureComponent {
  constructor() {
    super(...arguments);
    this.state = { isExpanded: !1 }, this.valuesCache = {}, this.onChangeName = (Z) => {
      this.change({ name: Z.value, params: this.getValues(Z.value) });
    }, this.onChangeParam = (Z) => {
      this.setValues(this.props.value.name, Z.value), this.change({ name: this.props.value.name, params: Z.value });
    }, this.toggleExpanded = () => this.setState({ isExpanded: !this.state.isExpanded });
  }
  setValues(Z, J) {
    this.valuesCache[Z] = J;
  }
  getValues(Z) {
    if (Z in this.valuesCache)
      return this.valuesCache[Z];
    else
      return this.props.param.map(Z).defaultValue;
  }
  change(Z) {
    this.props.onChange({ name: this.props.name, param: this.props.param, value: Z });
  }
  areParamsEmpty(Z) {
    for (let J of Object.keys(Z))
      if (!Z[J].isHidden)
        return !1;
    return !0;
  }
  render() {
    let Z = this.props.value || this.props.param.defaultValue, J = this.props.param.map(Z.name), $ = this.props.param.label || s$(this.props.name), X = hI(J), Y = this.props.param.help, Q = Y ? {
      ...this.props.param.select,
      help: (K) => Y({ name: K, params: this.getValues(K) })
    } : this.props.param.select, W = V1.jsx(bI, { param: Q, isDisabled: this.props.isDisabled, onChange: this.onChangeName, onEnter: this.props.onEnter, name: $, value: Z.name });
    if (!X)
      return W;
    if (J.type === "group" && !J.isFlat) {
      if (!this.areParamsEmpty(J.params))
        return V1.jsxs("div", { className: "msp-mapped-parameter-group", children: [W, V1.jsx(o2, { svg: lX, onClick: this.toggleExpanded, toggleState: this.state.isExpanded, title: `${$} Properties`, style: { opacity: this.state.isExpanded ? void 0 : 0.7 } }), this.state.isExpanded && V1.jsx(w10, { inMapped: !0, param: J, value: Z.params, name: Z.name, onChange: this.onChangeParam, onEnter: this.props.onEnter, isDisabled: this.props.isDisabled })] });
      return W;
    }
    return V1.jsxs(V1.Fragment, { children: [W, V1.jsx(X, { param: J, value: Z.params, name: Z.name, onChange: this.onChangeParam, onEnter: this.props.onEnter, isDisabled: this.props.isDisabled })] });
  }
}

class j10 extends M7.PureComponent {
  constructor() {
    super(...arguments);
    this.state = { current: this.props.value }, this.onChangeParam = (Z) => {
      this.setState({ current: { ...this.state.current, [Z.name]: Z.value } });
    }, this.apply = () => {
      this.props.apply(this.state.current);
    };
  }
  componentDidUpdate(Z) {
    if (this.props.params !== Z.params || this.props.value !== Z.value)
      this.setState({ current: this.props.value });
  }
  render() {
    return V1.jsxs(V1.Fragment, { children: [V1.jsx(iZ, { params: this.props.params, onChange: this.onChangeParam, values: this.state.current, onEnter: this.apply, isDisabled: this.props.isDisabled }), V1.jsx("button", { className: "msp-btn msp-btn-block msp-form-control msp-control-top-offset", onClick: this.apply, disabled: this.props.isDisabled, children: this.props.isUpdate ? "Update" : "Add" })] });
  }
}

class II0 extends M7.PureComponent {
  constructor() {
    super(...arguments);
    this.state = { isExpanded: !1 }, this.update = (Z) => {
      this.props.actions.update(Z, this.props.index);
    }, this.moveUp = () => {
      this.props.actions.move(this.props.index, -1);
    }, this.moveDown = () => {
      this.props.actions.move(this.props.index, 1);
    }, this.remove = () => {
      this.setState({ isExpanded: !1 }), this.props.actions.remove(this.props.index);
    }, this.toggleExpanded = (Z) => {
      this.setState({ isExpanded: !this.state.isExpanded }), Z.currentTarget.blur();
    };
  }
  render() {
    return V1.jsxs(V1.Fragment, { children: [V1.jsxs("div", { className: "msp-param-object-list-item", children: [V1.jsxs("button", { className: "msp-btn msp-btn-block msp-form-control", onClick: this.toggleExpanded, children: [V1.jsx("span", { children: `${this.props.index + 1}: ` }), this.props.param.getLabel(this.props.value)] }), V1.jsxs("div", { children: [V1.jsx(o2, { svg: zE, title: "Move Up", onClick: this.moveUp, small: !0 }), V1.jsx(o2, { svg: DE, title: "Move Down", onClick: this.moveDown, small: !0 }), V1.jsx(o2, { svg: GX, title: "Remove", onClick: this.remove, small: !0 })] })] }), this.state.isExpanded && V1.jsx("div", { className: "msp-control-offset", children: V1.jsx(j10, { params: this.props.param.element, apply: this.update, value: this.props.value, isUpdate: !0, isDisabled: this.props.isDisabled }) })] });
  }
}

class jy extends M7.PureComponent {
  constructor() {
    super(...arguments);
    this.state = { isExpanded: !1 }, this.add = (Z) => {
      this.change([...this.props.value, Z]);
    }, this.actions = {
      update: (Z, J) => {
        let $ = this.props.value.slice(0);
        $[J] = Z, this.change($);
      },
      move: (Z, J) => {
        let $ = this.props.value;
        if ($.length === 1)
          return;
        let X = (Z + J) % $.length;
        if (X < 0)
          X += $.length;
        $ = $.slice(0);
        let Y = $[Z];
        $[Z] = $[X], $[X] = Y, this.change($);
      },
      remove: (Z) => {
        let J = this.props.value, $ = [];
        for (let X = 0;X < J.length; X++)
          if (Z !== X)
            $.push(J[X]);
        this.change($);
      }
    }, this.toggleExpanded = (Z) => {
      this.setState({ isExpanded: !this.state.isExpanded }), Z.currentTarget.blur();
    };
  }
  change(Z) {
    this.props.onChange({ name: this.props.name, param: this.props.param, value: Z });
  }
  render() {
    let Z = this.props.value, J = this.props.param.label || s$(this.props.name), $ = `${Z.length} item${Z.length !== 1 ? "s" : ""}`;
    return V1.jsxs(V1.Fragment, { children: [V1.jsx(bY, { label: J, control: V1.jsx("button", { onClick: this.toggleExpanded, disabled: this.props.isDisabled, children: $ }) }), this.state.isExpanded && V1.jsxs("div", { className: "msp-control-offset", children: [this.props.value.map((X, Y) => V1.jsx(II0, { param: this.props.param, value: X, index: Y, actions: this.actions, isDisabled: this.props.isDisabled }, Y)), V1.jsx(zQ, { header: "New Item", children: V1.jsx(j10, { params: this.props.param.element, apply: this.add, value: this.props.param.ctor(), isDisabled: this.props.isDisabled }) })] })] });
  }
}

class PI0 extends M7.PureComponent {
  constructor() {
    super(...arguments);
    this.onChangeCondition = (Z) => {
      this.change(this.props.param.conditionedValue(this.props.value, Z.value));
    }, this.onChangeParam = (Z) => {
      this.change(Z.value);
    };
  }
  change(Z) {
    this.props.onChange({ name: this.props.name, param: this.props.param, value: Z });
  }
  render() {
    let Z = this.props.value, J = this.props.param.conditionForValue(Z), $ = this.props.param.conditionParams[J], X = this.props.param.label || s$(this.props.name), Y = hI($), Q = V1.jsx(bI, { param: this.props.param.select, isDisabled: this.props.isDisabled, onChange: this.onChangeCondition, onEnter: this.props.onEnter, name: `${X} Kind`, value: J });
    if (!Y)
      return Q;
    return V1.jsxs(V1.Fragment, { children: [Q, V1.jsx(Y, { param: $, value: Z, name: X, onChange: this.onChangeParam, onEnter: this.props.onEnter, isDisabled: this.props.isDisabled })] });
  }
}

class CI0 extends M7.PureComponent {
  constructor() {
    super(...arguments);
    this.onChange = (Z) => {
      this.props.onChange({
        name: this.props.name,
        param: this.props.param,
        value: this.props.param.toValue(Z.value)
      });
    };
  }
  render() {
    let Z = this.props.param.fromValue(this.props.value), J = hI(this.props.param.converted);
    if (!J)
      return null;
    return V1.jsx(J, { param: this.props.param.converted, value: Z, name: this.props.name, onChange: this.onChange, onEnter: this.props.onEnter, isDisabled: this.props.isDisabled });
  }
}

class kI0 extends M7.PureComponent {
  constructor() {
    super(...arguments);
    this.onChange = ({ name: Z, value: J }) => {
      let $ = Z;
      if (J !== this.props.value[$])
        this.props.onChange({ param: this.props.param, name: this.props.name, value: { ...this.props.value, [$]: J } });
    };
  }
  render() {
    let Z = {
      defaultValue: this.props.value.language,
      options: j.objectToOptions(cZ.Info),
      type: "select"
    }, J = V1.jsx(bI, { param: Z, isDisabled: this.props.isDisabled, onChange: this.onChange, onEnter: this.props.onEnter, name: "language", value: this.props.value.language }), $ = {
      defaultValue: this.props.value.language,
      type: "text"
    }, X = V1.jsx(M10, { param: $, isDisabled: this.props.isDisabled, onChange: this.onChange, name: "expression", value: this.props.value.expression });
    return V1.jsxs(V1.Fragment, { children: [J, this.props.value.language !== "mol-script" && V1.jsxs("div", { className: "msp-help-text", style: { padding: "10px" }, children: [V1.jsx(b6, { svg: Ry }), " Support for PyMOL, VMD, and Jmol selections is an experimental feature and may not always work as intended."] }), X] });
  }
}

// node_modules/molstar/lib/mol-plugin-ui/custom/volume.js
var Zz1 = {
  color: j.Color(c2.black, { description: "Display color of the volume." }),
  wireframe: j.Boolean(!1, { description: "Control display of the volume as a wireframe." }),
  opacity: j.Numeric(0.3, { min: 0, max: 1, step: 0.01 }, { description: "Opacity of the volume." })
}, Jz1 = /* @__PURE__ */ new Map([
  ["em", [-5, 5]],
  ["2fo-fc", [0, 3]],
  ["fo-fc(+ve)", [1, 5]],
  ["fo-fc(-ve)", [-5, -1]]
]);

class xI extends I8 {
  constructor() {
    super(...arguments);
    this.ref = f2.findTagInSubtree(this.plugin.state.data.tree, this.props.bCell.transform.ref, this.props.name), this.getVisible = () => {
      let Z = this.plugin.state.data, J = this.ref;
      if (!J)
        return !1;
      return !Z.cells.get(J).state.isHidden;
    }, this.toggleVisible = () => {
      let Z = this.plugin.state.data, J = this.ref;
      if (!J)
        return;
      _H(Z, J, !Z.cells.get(J).state.isHidden);
    };
  }
  componentDidUpdate() {
    this.ref = f2.findTagInSubtree(this.plugin.state.data.tree, this.props.bCell.transform.ref, this.props.name);
  }
  componentDidMount() {
    this.subscribe(this.plugin.state.data.events.cell.stateUpdated, (Z) => {
      if (this.ref === Z.ref)
        this.forceUpdate();
    });
  }
  render() {
    let Z = this.props, { isRelative: J, stats: $ } = Z, X = Z.channels[Z.name], { min: Y, max: Q, mean: W, sigma: K } = $, G = Math.round(100 * (X.isoValue.kind === "relative" ? X.isoValue.relativeValue : X.isoValue.absoluteValue)) / 100, H = (Y - W) / K, N = (Q - W) / K;
    if (!this.props.isUnbounded) {
      let z = Jz1.get(this.props.name);
      if (this.props.name === "em")
        H = Math.max(z[0], H), N = Math.min(z[1], N);
      else
        H = z[0], N = z[1];
    }
    let q = W + K * H, U = W + K * N, F = b_(J ? Math.round((U - q) / K) / 100 : K / 100, 2), E = J ? H : q, R = J ? N : U;
    return XW.jsx(K10, { label: Z.label + (Z.isRelative ? " σ" : ""), colorStripe: X.color, pivot: XW.jsxs("div", { className: "msp-volume-channel-inline-controls", children: [XW.jsx(sz, { value: G, min: E, max: R, step: F, onChange: (z) => Z.changeIso(Z.name, z, J), onChangeImmediate: (z) => Z.changeIso(Z.name, z, J), disabled: Z.params.isDisabled, onEnter: Z.params.events.onEnter }), XW.jsx(o2, { svg: this.getVisible() ? b5 : yK, onClick: this.toggleVisible, toggleState: !1, disabled: Z.params.isDisabled })] }), controls: XW.jsx(iZ, { onChange: ({ name: z, value: D }) => Z.changeParams(Z.name, z, D), params: Zz1, values: X, onEnter: Z.params.events.onEnter, isDisabled: Z.params.isDisabled }) });
  }
}

class T10 extends I8 {
  constructor() {
    super(...arguments);
    this.changeIso = (Z, J, $) => {
      let X = this.props.params;
      this.newParams({
        ...X,
        entry: {
          name: X.entry.name,
          params: {
            ...X.entry.params,
            channels: {
              ...X.entry.params.channels,
              [Z]: {
                ...X.entry.params.channels[Z],
                isoValue: $ ? Q1.IsoValue.relative(J) : Q1.IsoValue.absolute(J)
              }
            }
          }
        }
      });
    }, this.changeParams = (Z, J, $) => {
      let X = this.props.params;
      this.newParams({
        ...X,
        entry: {
          name: X.entry.name,
          params: {
            ...X.entry.params,
            channels: {
              ...X.entry.params.channels,
              [Z]: {
                ...X.entry.params.channels[Z],
                [J]: $
              }
            }
          }
        }
      });
    }, this.changeOption = ({ name: Z, value: J }) => {
      let $ = this.props.params;
      if (Z === "entry")
        this.newParams({
          ...$,
          entry: {
            name: J,
            params: $.entry.params
          }
        });
      else {
        let X = this.props.b.data, Y = X.info.kind === "em", Q = J.params.isRelative, W = X.info.header.sampling[0], K = $.entry.params.channels, H = { ...$.entry.params.view.name === J.name ? $.entry.params.view.params : this.props.info.params.entry.map($.entry.name).params.view.map(J.name).defaultValue };
        if (J.name === "selection-box")
          H.radius = J.params.radius;
        else if (J.name === "camera-target")
          H.radius = J.params.radius, H.dynamicDetailLevel = J.params.dynamicDetailLevel;
        else if (J.name === "box")
          H.bottomLeft = J.params.bottomLeft, H.topRight = J.params.topRight;
        else if (J.name === "auto")
          H.radius = J.params.radius, H.selectionDetailLevel = J.params.selectionDetailLevel;
        H.isUnbounded = !!J.params.isUnbounded, this.newParams({
          ...$,
          entry: {
            name: $.entry.name,
            params: {
              ...$.entry.params,
              view: {
                name: J.name,
                params: H
              },
              detailLevel: J.params.detailLevel,
              channels: Y ? { em: this.convert(K.em, W.valuesInfo[0], Q) } : {
                "2fo-fc": this.convert(K["2fo-fc"], W.valuesInfo[0], Q),
                "fo-fc(+ve)": this.convert(K["fo-fc(+ve)"], W.valuesInfo[1], Q),
                "fo-fc(-ve)": this.convert(K["fo-fc(-ve)"], W.valuesInfo[1], Q)
              }
            }
          }
        });
      }
    };
  }
  areInitial(Z) {
    return j.areEqual(this.props.info.params, Z, this.props.info.initialValues);
  }
  newParams(Z) {
    this.props.events.onChange(Z, this.areInitial(Z));
  }
  convert(Z, J, $) {
    return {
      ...Z,
      isoValue: $ ? Q1.IsoValue.toRelative(Z.isoValue, J) : Q1.IsoValue.toAbsolute(Z.isoValue, J)
    };
  }
  render() {
    if (!this.props.b)
      return null;
    let Z = this.props.b.data, J = Z.info.kind === "em", $ = J ? "em" : "2fo-fc", X = this.props.params, Y = this.props.info.params.entry.map(X.entry.name), Q = Y.params.detailLevel, W = {
      ...Q,
      label: "Dynamic Detail",
      defaultValue: Y.params.view.map("camera-target").params.dynamicDetailLevel.defaultValue
    }, K = {
      ...Q,
      label: "Selection Detail",
      defaultValue: Y.params.view.map("auto").params.selectionDetailLevel.defaultValue
    }, G = Z.info.header.sampling[0], H = X.entry.params.channels[$].isoValue.kind === "relative", N = j.Boolean(H, { description: "Use normalized or absolute isocontour scale.", label: "Normalized" }), q = !!X.entry.params.view.params.isUnbounded, U = j.Boolean(q, { description: "Show full/limited range of iso-values for more fine-grained control.", label: "Unbounded" }), F = X.entry.params.view.name === "off", E = {
      entry: j.Select(X.entry.name, Z.data.entries.map((z) => [z.dataId, z.dataId]), { isHidden: F, description: "Which entry with volume data to display." }),
      view: j.MappedStatic(X.entry.params.view.name, {
        off: j.Group({
          isRelative: j.Boolean(H, { isHidden: !0 }),
          isUnbounded: j.Boolean(q, { isHidden: !0 })
        }, { description: "Display off." }),
        box: j.Group({
          bottomLeft: j.Vec3(M.zero()),
          topRight: j.Vec3(M.zero()),
          detailLevel: Q,
          isRelative: N,
          isUnbounded: U
        }, { description: "Static box defined by cartesian coords." }),
        "selection-box": j.Group({
          radius: j.Numeric(5, { min: 0, max: 50, step: 0.5 }, { description: "Radius in Å within which the volume is shown." }),
          detailLevel: Q,
          isRelative: N,
          isUnbounded: U
        }, { description: "Box around focused element." }),
        "camera-target": j.Group({
          radius: j.Numeric(0.5, { min: 0, max: 1, step: 0.05 }, { description: "Radius within which the volume is shown (relative to the field of view)." }),
          detailLevel: { ...Q, isHidden: !0 },
          dynamicDetailLevel: W,
          isRelative: N,
          isUnbounded: U
        }, { description: "Box around camera target." }),
        cell: j.Group({
          detailLevel: Q,
          isRelative: N,
          isUnbounded: U
        }, { description: "Box around the structure's bounding box." }),
        auto: j.Group({
          radius: j.Numeric(5, { min: 0, max: 50, step: 0.5 }, { description: "Radius in Å within which the volume is shown." }),
          detailLevel: Q,
          selectionDetailLevel: K,
          isRelative: N,
          isUnbounded: U
        }, { description: "Box around focused element." })
      }, { options: y$.ViewTypeOptions, description: 'Controls what of the volume is displayed. "Off" hides the volume alltogether. "Bounded box" shows the volume inside the given box. "Around Focus" shows the volume around the element/atom last interacted with. "Around Camera" shows the volume around the point the camera is targeting. "Whole Structure" shows the volume for the whole structure.' })
    }, R = {
      entry: X.entry.name,
      view: {
        name: X.entry.params.view.name,
        params: {
          detailLevel: X.entry.params.detailLevel,
          radius: X.entry.params.view.params.radius,
          bottomLeft: X.entry.params.view.params.bottomLeft,
          topRight: X.entry.params.view.params.topRight,
          selectionDetailLevel: X.entry.params.view.params.selectionDetailLevel,
          dynamicDetailLevel: X.entry.params.view.params.dynamicDetailLevel,
          isRelative: H,
          isUnbounded: q
        }
      }
    };
    if (F)
      return XW.jsx(iZ, { onChange: this.changeOption, params: E, values: R, onEnter: this.props.events.onEnter, isDisabled: this.props.isDisabled });
    return XW.jsxs(XW.Fragment, { children: [!J && XW.jsx(xI, { label: "2Fo-Fc", name: "2fo-fc", bCell: this.props.bCell, channels: X.entry.params.channels, changeIso: this.changeIso, changeParams: this.changeParams, isRelative: H, params: this.props, stats: G.valuesInfo[0], isUnbounded: q }), !J && XW.jsx(xI, { label: "Fo-Fc(+ve)", name: "fo-fc(+ve)", bCell: this.props.bCell, channels: X.entry.params.channels, changeIso: this.changeIso, changeParams: this.changeParams, isRelative: H, params: this.props, stats: G.valuesInfo[1], isUnbounded: q }), !J && XW.jsx(xI, { label: "Fo-Fc(-ve)", name: "fo-fc(-ve)", bCell: this.props.bCell, channels: X.entry.params.channels, changeIso: this.changeIso, changeParams: this.changeParams, isRelative: H, params: this.props, stats: G.valuesInfo[1], isUnbounded: q }), J && XW.jsx(xI, { label: "EM", name: "em", bCell: this.props.bCell, channels: X.entry.params.channels, changeIso: this.changeIso, changeParams: this.changeParams, isRelative: H, params: this.props, stats: G.valuesInfo[0], isUnbounded: q }), XW.jsx(iZ, { onChange: this.changeOption, params: E, values: R, onEnter: this.props.events.onEnter, isDisabled: this.props.isDisabled })] });
  }
}

// node_modules/molstar/lib/mol-plugin-ui/spec.js
var Ty = () => ({
  ...jV0(),
  customParamEditors: [
    [oV, T10]
  ]
});

// node_modules/molstar/lib/mol-plugin-ui/index.js
var Ib0 = t2(J7(), 1);

// node_modules/molstar/lib/mol-plugin-ui/plugin.js
var xZ = t2(PZ(), 1), z4 = t2(J7(), 1);

// node_modules/molstar/lib/mol-plugin-ui/controls.js
var T6 = t2(PZ(), 1), cB = t2(J7(), 1);

// node_modules/devlop/lib/development.js
class vI0 extends Error {
  name = "Assertion";
  code = "ERR_ASSERTION";
  constructor(Z, J, $, X, Y) {
    super(Z);
    if (Error.captureStackTrace)
      Error.captureStackTrace(this, this.constructor);
    this.actual = J, this.expected = $, this.generated = Y, this.operator = X;
  }
}
function t0(Z, J) {
  SI0(Boolean(Z), !1, !0, "ok", "Expected value to be truthy", J);
}
function _y(Z) {
  SI0(!1, !1, !0, "ok", "Unreachable", Z);
}
function SI0(Z, J, $, X, Y, Q) {
  if (!Z)
    throw Q instanceof Error ? Q : new vI0(Q || Y, J, $, X, !Q);
}

// node_modules/comma-separated-tokens/index.js
function fI0(Z, J) {
  let $ = J || {};
  return (Z[Z.length - 1] === "" ? [...Z, ""] : Z).join(($.padRight ? " " : "") + "," + ($.padLeft === !1 ? "" : " ")).trim();
}

// node_modules/estree-util-is-identifier-name/lib/index.js
var $z1 = /^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u, Xz1 = /^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u, Yz1 = {};
function Vy(Z, J) {
  return ((J || Yz1).jsx ? Xz1 : $z1).test(Z);
}
// node_modules/hast-util-whitespace/lib/index.js
var Qz1 = /[ \t\n\f\r]/g;
function _10(Z) {
  return typeof Z === "object" ? Z.type === "text" ? hI0(Z.value) : !1 : hI0(Z);
}
function hI0(Z) {
  return Z.replace(Qz1, "") === "";
}
// node_modules/property-information/lib/util/schema.js
class AE {
  constructor(Z, J, $) {
    if (this.property = Z, this.normal = J, $)
      this.space = $;
  }
}
AE.prototype.property = {};
AE.prototype.normal = {};
AE.prototype.space = null;

// node_modules/property-information/lib/util/merge.js
function V10(Z, J) {
  let $ = {}, X = {}, Y = -1;
  while (++Y < Z.length)
    Object.assign($, Z[Y].property), Object.assign(X, Z[Y].normal);
  return new AE($, X, J);
}

// node_modules/property-information/lib/normalize.js
function yI(Z) {
  return Z.toLowerCase();
}

// node_modules/property-information/lib/util/info.js
class lW {
  constructor(Z, J) {
    this.property = Z, this.attribute = J;
  }
}
lW.prototype.space = null;
lW.prototype.boolean = !1;
lW.prototype.booleanish = !1;
lW.prototype.overloadedBoolean = !1;
lW.prototype.number = !1;
lW.prototype.commaSeparated = !1;
lW.prototype.spaceSeparated = !1;
lW.prototype.commaOrSpaceSeparated = !1;
lW.prototype.mustUseProperty = !1;
lW.prototype.defined = !1;

// node_modules/property-information/lib/util/types.js
var gI = {};
y9(gI, {
  spaceSeparated: () => P7,
  overloadedBoolean: () => I10,
  number: () => p2,
  commaSeparated: () => BE,
  commaOrSpaceSeparated: () => g5,
  booleanish: () => A$,
  boolean: () => MZ
});
var Wz1 = 0, MZ = rz(), A$ = rz(), I10 = rz(), p2 = rz(), P7 = rz(), BE = rz(), g5 = rz();
function rz() {
  return 2 ** ++Wz1;
}

// node_modules/property-information/lib/util/defined-info.js
var P10 = Object.keys(gI);

class wB extends lW {
  constructor(Z, J, $, X) {
    let Y = -1;
    super(Z, J);
    if (bI0(this, "space", X), typeof $ === "number")
      while (++Y < P10.length) {
        let Q = P10[Y];
        bI0(this, P10[Y], ($ & gI[Q]) === gI[Q]);
      }
  }
}
wB.prototype.defined = !0;
function bI0(Z, J, $) {
  if ($)
    Z[J] = $;
}

// node_modules/property-information/lib/util/create.js
var Kz1 = {}.hasOwnProperty;
function JG(Z) {
  let J = {}, $ = {}, X;
  for (X in Z.properties)
    if (Kz1.call(Z.properties, X)) {
      let Y = Z.properties[X], Q = new wB(X, Z.transform(Z.attributes || {}, X), Y, Z.space);
      if (Z.mustUseProperty && Z.mustUseProperty.includes(X))
        Q.mustUseProperty = !0;
      J[X] = Q, $[yI(X)] = X, $[yI(Q.attribute)] = X;
    }
  return new AE(J, $, Z.space);
}

// node_modules/property-information/lib/xlink.js
var C10 = JG({
  space: "xlink",
  transform(Z, J) {
    return "xlink:" + J.slice(5).toLowerCase();
  },
  properties: {
    xLinkActuate: null,
    xLinkArcRole: null,
    xLinkHref: null,
    xLinkRole: null,
    xLinkShow: null,
    xLinkTitle: null,
    xLinkType: null
  }
});

// node_modules/property-information/lib/xml.js
var k10 = JG({
  space: "xml",
  transform(Z, J) {
    return "xml:" + J.slice(3).toLowerCase();
  },
  properties: { xmlLang: null, xmlBase: null, xmlSpace: null }
});

// node_modules/property-information/lib/util/case-sensitive-transform.js
function Iy(Z, J) {
  return J in Z ? Z[J] : J;
}

// node_modules/property-information/lib/util/case-insensitive-transform.js
function Py(Z, J) {
  return Iy(Z, J.toLowerCase());
}

// node_modules/property-information/lib/xmlns.js
var v10 = JG({
  space: "xmlns",
  attributes: { xmlnsxlink: "xmlns:xlink" },
  transform: Py,
  properties: { xmlns: null, xmlnsXLink: null }
});

// node_modules/property-information/lib/aria.js
var S10 = JG({
  transform(Z, J) {
    return J === "role" ? J : "aria-" + J.slice(4).toLowerCase();
  },
  properties: {
    ariaActiveDescendant: null,
    ariaAtomic: A$,
    ariaAutoComplete: null,
    ariaBusy: A$,
    ariaChecked: A$,
    ariaColCount: p2,
    ariaColIndex: p2,
    ariaColSpan: p2,
    ariaControls: P7,
    ariaCurrent: null,
    ariaDescribedBy: P7,
    ariaDetails: null,
    ariaDisabled: A$,
    ariaDropEffect: P7,
    ariaErrorMessage: null,
    ariaExpanded: A$,
    ariaFlowTo: P7,
    ariaGrabbed: A$,
    ariaHasPopup: null,
    ariaHidden: A$,
    ariaInvalid: null,
    ariaKeyShortcuts: null,
    ariaLabel: null,
    ariaLabelledBy: P7,
    ariaLevel: p2,
    ariaLive: null,
    ariaModal: A$,
    ariaMultiLine: A$,
    ariaMultiSelectable: A$,
    ariaOrientation: null,
    ariaOwns: P7,
    ariaPlaceholder: null,
    ariaPosInSet: p2,
    ariaPressed: A$,
    ariaReadOnly: A$,
    ariaRelevant: null,
    ariaRequired: A$,
    ariaRoleDescription: P7,
    ariaRowCount: p2,
    ariaRowIndex: p2,
    ariaRowSpan: p2,
    ariaSelected: A$,
    ariaSetSize: p2,
    ariaSort: null,
    ariaValueMax: p2,
    ariaValueMin: p2,
    ariaValueNow: p2,
    ariaValueText: null,
    role: null
  }
});

// node_modules/property-information/lib/html.js
var xI0 = JG({
  space: "html",
  attributes: {
    acceptcharset: "accept-charset",
    classname: "class",
    htmlfor: "for",
    httpequiv: "http-equiv"
  },
  transform: Py,
  mustUseProperty: ["checked", "multiple", "muted", "selected"],
  properties: {
    abbr: null,
    accept: BE,
    acceptCharset: P7,
    accessKey: P7,
    action: null,
    allow: null,
    allowFullScreen: MZ,
    allowPaymentRequest: MZ,
    allowUserMedia: MZ,
    alt: null,
    as: null,
    async: MZ,
    autoCapitalize: null,
    autoComplete: P7,
    autoFocus: MZ,
    autoPlay: MZ,
    blocking: P7,
    capture: null,
    charSet: null,
    checked: MZ,
    cite: null,
    className: P7,
    cols: p2,
    colSpan: null,
    content: null,
    contentEditable: A$,
    controls: MZ,
    controlsList: P7,
    coords: p2 | BE,
    crossOrigin: null,
    data: null,
    dateTime: null,
    decoding: null,
    default: MZ,
    defer: MZ,
    dir: null,
    dirName: null,
    disabled: MZ,
    download: I10,
    draggable: A$,
    encType: null,
    enterKeyHint: null,
    fetchPriority: null,
    form: null,
    formAction: null,
    formEncType: null,
    formMethod: null,
    formNoValidate: MZ,
    formTarget: null,
    headers: P7,
    height: p2,
    hidden: MZ,
    high: p2,
    href: null,
    hrefLang: null,
    htmlFor: P7,
    httpEquiv: P7,
    id: null,
    imageSizes: null,
    imageSrcSet: null,
    inert: MZ,
    inputMode: null,
    integrity: null,
    is: null,
    isMap: MZ,
    itemId: null,
    itemProp: P7,
    itemRef: P7,
    itemScope: MZ,
    itemType: P7,
    kind: null,
    label: null,
    lang: null,
    language: null,
    list: null,
    loading: null,
    loop: MZ,
    low: p2,
    manifest: null,
    max: null,
    maxLength: p2,
    media: null,
    method: null,
    min: null,
    minLength: p2,
    multiple: MZ,
    muted: MZ,
    name: null,
    nonce: null,
    noModule: MZ,
    noValidate: MZ,
    onAbort: null,
    onAfterPrint: null,
    onAuxClick: null,
    onBeforeMatch: null,
    onBeforePrint: null,
    onBeforeToggle: null,
    onBeforeUnload: null,
    onBlur: null,
    onCancel: null,
    onCanPlay: null,
    onCanPlayThrough: null,
    onChange: null,
    onClick: null,
    onClose: null,
    onContextLost: null,
    onContextMenu: null,
    onContextRestored: null,
    onCopy: null,
    onCueChange: null,
    onCut: null,
    onDblClick: null,
    onDrag: null,
    onDragEnd: null,
    onDragEnter: null,
    onDragExit: null,
    onDragLeave: null,
    onDragOver: null,
    onDragStart: null,
    onDrop: null,
    onDurationChange: null,
    onEmptied: null,
    onEnded: null,
    onError: null,
    onFocus: null,
    onFormData: null,
    onHashChange: null,
    onInput: null,
    onInvalid: null,
    onKeyDown: null,
    onKeyPress: null,
    onKeyUp: null,
    onLanguageChange: null,
    onLoad: null,
    onLoadedData: null,
    onLoadedMetadata: null,
    onLoadEnd: null,
    onLoadStart: null,
    onMessage: null,
    onMessageError: null,
    onMouseDown: null,
    onMouseEnter: null,
    onMouseLeave: null,
    onMouseMove: null,
    onMouseOut: null,
    onMouseOver: null,
    onMouseUp: null,
    onOffline: null,
    onOnline: null,
    onPageHide: null,
    onPageShow: null,
    onPaste: null,
    onPause: null,
    onPlay: null,
    onPlaying: null,
    onPopState: null,
    onProgress: null,
    onRateChange: null,
    onRejectionHandled: null,
    onReset: null,
    onResize: null,
    onScroll: null,
    onScrollEnd: null,
    onSecurityPolicyViolation: null,
    onSeeked: null,
    onSeeking: null,
    onSelect: null,
    onSlotChange: null,
    onStalled: null,
    onStorage: null,
    onSubmit: null,
    onSuspend: null,
    onTimeUpdate: null,
    onToggle: null,
    onUnhandledRejection: null,
    onUnload: null,
    onVolumeChange: null,
    onWaiting: null,
    onWheel: null,
    open: MZ,
    optimum: p2,
    pattern: null,
    ping: P7,
    placeholder: null,
    playsInline: MZ,
    popover: null,
    popoverTarget: null,
    popoverTargetAction: null,
    poster: null,
    preload: null,
    readOnly: MZ,
    referrerPolicy: null,
    rel: P7,
    required: MZ,
    reversed: MZ,
    rows: p2,
    rowSpan: p2,
    sandbox: P7,
    scope: null,
    scoped: MZ,
    seamless: MZ,
    selected: MZ,
    shadowRootClonable: MZ,
    shadowRootDelegatesFocus: MZ,
    shadowRootMode: null,
    shape: null,
    size: p2,
    sizes: null,
    slot: null,
    span: p2,
    spellCheck: A$,
    src: null,
    srcDoc: null,
    srcLang: null,
    srcSet: null,
    start: p2,
    step: null,
    style: null,
    tabIndex: p2,
    target: null,
    title: null,
    translate: null,
    type: null,
    typeMustMatch: MZ,
    useMap: null,
    value: A$,
    width: p2,
    wrap: null,
    writingSuggestions: null,
    align: null,
    aLink: null,
    archive: P7,
    axis: null,
    background: null,
    bgColor: null,
    border: p2,
    borderColor: null,
    bottomMargin: p2,
    cellPadding: null,
    cellSpacing: null,
    char: null,
    charOff: null,
    classId: null,
    clear: null,
    code: null,
    codeBase: null,
    codeType: null,
    color: null,
    compact: MZ,
    declare: MZ,
    event: null,
    face: null,
    frame: null,
    frameBorder: null,
    hSpace: p2,
    leftMargin: p2,
    link: null,
    longDesc: null,
    lowSrc: null,
    marginHeight: p2,
    marginWidth: p2,
    noResize: MZ,
    noHref: MZ,
    noShade: MZ,
    noWrap: MZ,
    object: null,
    profile: null,
    prompt: null,
    rev: null,
    rightMargin: p2,
    rules: null,
    scheme: null,
    scrolling: A$,
    standby: null,
    summary: null,
    text: null,
    topMargin: p2,
    valueType: null,
    version: null,
    vAlign: null,
    vLink: null,
    vSpace: p2,
    allowTransparency: null,
    autoCorrect: null,
    autoSave: null,
    disablePictureInPicture: MZ,
    disableRemotePlayback: MZ,
    prefix: null,
    property: null,
    results: p2,
    security: null,
    unselectable: null
  }
});

// node_modules/property-information/lib/svg.js
var yI0 = JG({
  space: "svg",
  attributes: {
    accentHeight: "accent-height",
    alignmentBaseline: "alignment-baseline",
    arabicForm: "arabic-form",
    baselineShift: "baseline-shift",
    capHeight: "cap-height",
    className: "class",
    clipPath: "clip-path",
    clipRule: "clip-rule",
    colorInterpolation: "color-interpolation",
    colorInterpolationFilters: "color-interpolation-filters",
    colorProfile: "color-profile",
    colorRendering: "color-rendering",
    crossOrigin: "crossorigin",
    dataType: "datatype",
    dominantBaseline: "dominant-baseline",
    enableBackground: "enable-background",
    fillOpacity: "fill-opacity",
    fillRule: "fill-rule",
    floodColor: "flood-color",
    floodOpacity: "flood-opacity",
    fontFamily: "font-family",
    fontSize: "font-size",
    fontSizeAdjust: "font-size-adjust",
    fontStretch: "font-stretch",
    fontStyle: "font-style",
    fontVariant: "font-variant",
    fontWeight: "font-weight",
    glyphName: "glyph-name",
    glyphOrientationHorizontal: "glyph-orientation-horizontal",
    glyphOrientationVertical: "glyph-orientation-vertical",
    hrefLang: "hreflang",
    horizAdvX: "horiz-adv-x",
    horizOriginX: "horiz-origin-x",
    horizOriginY: "horiz-origin-y",
    imageRendering: "image-rendering",
    letterSpacing: "letter-spacing",
    lightingColor: "lighting-color",
    markerEnd: "marker-end",
    markerMid: "marker-mid",
    markerStart: "marker-start",
    navDown: "nav-down",
    navDownLeft: "nav-down-left",
    navDownRight: "nav-down-right",
    navLeft: "nav-left",
    navNext: "nav-next",
    navPrev: "nav-prev",
    navRight: "nav-right",
    navUp: "nav-up",
    navUpLeft: "nav-up-left",
    navUpRight: "nav-up-right",
    onAbort: "onabort",
    onActivate: "onactivate",
    onAfterPrint: "onafterprint",
    onBeforePrint: "onbeforeprint",
    onBegin: "onbegin",
    onCancel: "oncancel",
    onCanPlay: "oncanplay",
    onCanPlayThrough: "oncanplaythrough",
    onChange: "onchange",
    onClick: "onclick",
    onClose: "onclose",
    onCopy: "oncopy",
    onCueChange: "oncuechange",
    onCut: "oncut",
    onDblClick: "ondblclick",
    onDrag: "ondrag",
    onDragEnd: "ondragend",
    onDragEnter: "ondragenter",
    onDragExit: "ondragexit",
    onDragLeave: "ondragleave",
    onDragOver: "ondragover",
    onDragStart: "ondragstart",
    onDrop: "ondrop",
    onDurationChange: "ondurationchange",
    onEmptied: "onemptied",
    onEnd: "onend",
    onEnded: "onended",
    onError: "onerror",
    onFocus: "onfocus",
    onFocusIn: "onfocusin",
    onFocusOut: "onfocusout",
    onHashChange: "onhashchange",
    onInput: "oninput",
    onInvalid: "oninvalid",
    onKeyDown: "onkeydown",
    onKeyPress: "onkeypress",
    onKeyUp: "onkeyup",
    onLoad: "onload",
    onLoadedData: "onloadeddata",
    onLoadedMetadata: "onloadedmetadata",
    onLoadStart: "onloadstart",
    onMessage: "onmessage",
    onMouseDown: "onmousedown",
    onMouseEnter: "onmouseenter",
    onMouseLeave: "onmouseleave",
    onMouseMove: "onmousemove",
    onMouseOut: "onmouseout",
    onMouseOver: "onmouseover",
    onMouseUp: "onmouseup",
    onMouseWheel: "onmousewheel",
    onOffline: "onoffline",
    onOnline: "ononline",
    onPageHide: "onpagehide",
    onPageShow: "onpageshow",
    onPaste: "onpaste",
    onPause: "onpause",
    onPlay: "onplay",
    onPlaying: "onplaying",
    onPopState: "onpopstate",
    onProgress: "onprogress",
    onRateChange: "onratechange",
    onRepeat: "onrepeat",
    onReset: "onreset",
    onResize: "onresize",
    onScroll: "onscroll",
    onSeeked: "onseeked",
    onSeeking: "onseeking",
    onSelect: "onselect",
    onShow: "onshow",
    onStalled: "onstalled",
    onStorage: "onstorage",
    onSubmit: "onsubmit",
    onSuspend: "onsuspend",
    onTimeUpdate: "ontimeupdate",
    onToggle: "ontoggle",
    onUnload: "onunload",
    onVolumeChange: "onvolumechange",
    onWaiting: "onwaiting",
    onZoom: "onzoom",
    overlinePosition: "overline-position",
    overlineThickness: "overline-thickness",
    paintOrder: "paint-order",
    panose1: "panose-1",
    pointerEvents: "pointer-events",
    referrerPolicy: "referrerpolicy",
    renderingIntent: "rendering-intent",
    shapeRendering: "shape-rendering",
    stopColor: "stop-color",
    stopOpacity: "stop-opacity",
    strikethroughPosition: "strikethrough-position",
    strikethroughThickness: "strikethrough-thickness",
    strokeDashArray: "stroke-dasharray",
    strokeDashOffset: "stroke-dashoffset",
    strokeLineCap: "stroke-linecap",
    strokeLineJoin: "stroke-linejoin",
    strokeMiterLimit: "stroke-miterlimit",
    strokeOpacity: "stroke-opacity",
    strokeWidth: "stroke-width",
    tabIndex: "tabindex",
    textAnchor: "text-anchor",
    textDecoration: "text-decoration",
    textRendering: "text-rendering",
    transformOrigin: "transform-origin",
    typeOf: "typeof",
    underlinePosition: "underline-position",
    underlineThickness: "underline-thickness",
    unicodeBidi: "unicode-bidi",
    unicodeRange: "unicode-range",
    unitsPerEm: "units-per-em",
    vAlphabetic: "v-alphabetic",
    vHanging: "v-hanging",
    vIdeographic: "v-ideographic",
    vMathematical: "v-mathematical",
    vectorEffect: "vector-effect",
    vertAdvY: "vert-adv-y",
    vertOriginX: "vert-origin-x",
    vertOriginY: "vert-origin-y",
    wordSpacing: "word-spacing",
    writingMode: "writing-mode",
    xHeight: "x-height",
    playbackOrder: "playbackorder",
    timelineBegin: "timelinebegin"
  },
  transform: Iy,
  properties: {
    about: g5,
    accentHeight: p2,
    accumulate: null,
    additive: null,
    alignmentBaseline: null,
    alphabetic: p2,
    amplitude: p2,
    arabicForm: null,
    ascent: p2,
    attributeName: null,
    attributeType: null,
    azimuth: p2,
    bandwidth: null,
    baselineShift: null,
    baseFrequency: null,
    baseProfile: null,
    bbox: null,
    begin: null,
    bias: p2,
    by: null,
    calcMode: null,
    capHeight: p2,
    className: P7,
    clip: null,
    clipPath: null,
    clipPathUnits: null,
    clipRule: null,
    color: null,
    colorInterpolation: null,
    colorInterpolationFilters: null,
    colorProfile: null,
    colorRendering: null,
    content: null,
    contentScriptType: null,
    contentStyleType: null,
    crossOrigin: null,
    cursor: null,
    cx: null,
    cy: null,
    d: null,
    dataType: null,
    defaultAction: null,
    descent: p2,
    diffuseConstant: p2,
    direction: null,
    display: null,
    dur: null,
    divisor: p2,
    dominantBaseline: null,
    download: MZ,
    dx: null,
    dy: null,
    edgeMode: null,
    editable: null,
    elevation: p2,
    enableBackground: null,
    end: null,
    event: null,
    exponent: p2,
    externalResourcesRequired: null,
    fill: null,
    fillOpacity: p2,
    fillRule: null,
    filter: null,
    filterRes: null,
    filterUnits: null,
    floodColor: null,
    floodOpacity: null,
    focusable: null,
    focusHighlight: null,
    fontFamily: null,
    fontSize: null,
    fontSizeAdjust: null,
    fontStretch: null,
    fontStyle: null,
    fontVariant: null,
    fontWeight: null,
    format: null,
    fr: null,
    from: null,
    fx: null,
    fy: null,
    g1: BE,
    g2: BE,
    glyphName: BE,
    glyphOrientationHorizontal: null,
    glyphOrientationVertical: null,
    glyphRef: null,
    gradientTransform: null,
    gradientUnits: null,
    handler: null,
    hanging: p2,
    hatchContentUnits: null,
    hatchUnits: null,
    height: null,
    href: null,
    hrefLang: null,
    horizAdvX: p2,
    horizOriginX: p2,
    horizOriginY: p2,
    id: null,
    ideographic: p2,
    imageRendering: null,
    initialVisibility: null,
    in: null,
    in2: null,
    intercept: p2,
    k: p2,
    k1: p2,
    k2: p2,
    k3: p2,
    k4: p2,
    kernelMatrix: g5,
    kernelUnitLength: null,
    keyPoints: null,
    keySplines: null,
    keyTimes: null,
    kerning: null,
    lang: null,
    lengthAdjust: null,
    letterSpacing: null,
    lightingColor: null,
    limitingConeAngle: p2,
    local: null,
    markerEnd: null,
    markerMid: null,
    markerStart: null,
    markerHeight: null,
    markerUnits: null,
    markerWidth: null,
    mask: null,
    maskContentUnits: null,
    maskUnits: null,
    mathematical: null,
    max: null,
    media: null,
    mediaCharacterEncoding: null,
    mediaContentEncodings: null,
    mediaSize: p2,
    mediaTime: null,
    method: null,
    min: null,
    mode: null,
    name: null,
    navDown: null,
    navDownLeft: null,
    navDownRight: null,
    navLeft: null,
    navNext: null,
    navPrev: null,
    navRight: null,
    navUp: null,
    navUpLeft: null,
    navUpRight: null,
    numOctaves: null,
    observer: null,
    offset: null,
    onAbort: null,
    onActivate: null,
    onAfterPrint: null,
    onBeforePrint: null,
    onBegin: null,
    onCancel: null,
    onCanPlay: null,
    onCanPlayThrough: null,
    onChange: null,
    onClick: null,
    onClose: null,
    onCopy: null,
    onCueChange: null,
    onCut: null,
    onDblClick: null,
    onDrag: null,
    onDragEnd: null,
    onDragEnter: null,
    onDragExit: null,
    onDragLeave: null,
    onDragOver: null,
    onDragStart: null,
    onDrop: null,
    onDurationChange: null,
    onEmptied: null,
    onEnd: null,
    onEnded: null,
    onError: null,
    onFocus: null,
    onFocusIn: null,
    onFocusOut: null,
    onHashChange: null,
    onInput: null,
    onInvalid: null,
    onKeyDown: null,
    onKeyPress: null,
    onKeyUp: null,
    onLoad: null,
    onLoadedData: null,
    onLoadedMetadata: null,
    onLoadStart: null,
    onMessage: null,
    onMouseDown: null,
    onMouseEnter: null,
    onMouseLeave: null,
    onMouseMove: null,
    onMouseOut: null,
    onMouseOver: null,
    onMouseUp: null,
    onMouseWheel: null,
    onOffline: null,
    onOnline: null,
    onPageHide: null,
    onPageShow: null,
    onPaste: null,
    onPause: null,
    onPlay: null,
    onPlaying: null,
    onPopState: null,
    onProgress: null,
    onRateChange: null,
    onRepeat: null,
    onReset: null,
    onResize: null,
    onScroll: null,
    onSeeked: null,
    onSeeking: null,
    onSelect: null,
    onShow: null,
    onStalled: null,
    onStorage: null,
    onSubmit: null,
    onSuspend: null,
    onTimeUpdate: null,
    onToggle: null,
    onUnload: null,
    onVolumeChange: null,
    onWaiting: null,
    onZoom: null,
    opacity: null,
    operator: null,
    order: null,
    orient: null,
    orientation: null,
    origin: null,
    overflow: null,
    overlay: null,
    overlinePosition: p2,
    overlineThickness: p2,
    paintOrder: null,
    panose1: null,
    path: null,
    pathLength: p2,
    patternContentUnits: null,
    patternTransform: null,
    patternUnits: null,
    phase: null,
    ping: P7,
    pitch: null,
    playbackOrder: null,
    pointerEvents: null,
    points: null,
    pointsAtX: p2,
    pointsAtY: p2,
    pointsAtZ: p2,
    preserveAlpha: null,
    preserveAspectRatio: null,
    primitiveUnits: null,
    propagate: null,
    property: g5,
    r: null,
    radius: null,
    referrerPolicy: null,
    refX: null,
    refY: null,
    rel: g5,
    rev: g5,
    renderingIntent: null,
    repeatCount: null,
    repeatDur: null,
    requiredExtensions: g5,
    requiredFeatures: g5,
    requiredFonts: g5,
    requiredFormats: g5,
    resource: null,
    restart: null,
    result: null,
    rotate: null,
    rx: null,
    ry: null,
    scale: null,
    seed: null,
    shapeRendering: null,
    side: null,
    slope: null,
    snapshotTime: null,
    specularConstant: p2,
    specularExponent: p2,
    spreadMethod: null,
    spacing: null,
    startOffset: null,
    stdDeviation: null,
    stemh: null,
    stemv: null,
    stitchTiles: null,
    stopColor: null,
    stopOpacity: null,
    strikethroughPosition: p2,
    strikethroughThickness: p2,
    string: null,
    stroke: null,
    strokeDashArray: g5,
    strokeDashOffset: null,
    strokeLineCap: null,
    strokeLineJoin: null,
    strokeMiterLimit: p2,
    strokeOpacity: p2,
    strokeWidth: null,
    style: null,
    surfaceScale: p2,
    syncBehavior: null,
    syncBehaviorDefault: null,
    syncMaster: null,
    syncTolerance: null,
    syncToleranceDefault: null,
    systemLanguage: g5,
    tabIndex: p2,
    tableValues: null,
    target: null,
    targetX: p2,
    targetY: p2,
    textAnchor: null,
    textDecoration: null,
    textRendering: null,
    textLength: null,
    timelineBegin: null,
    title: null,
    transformBehavior: null,
    type: null,
    typeOf: g5,
    to: null,
    transform: null,
    transformOrigin: null,
    u1: null,
    u2: null,
    underlinePosition: p2,
    underlineThickness: p2,
    unicode: null,
    unicodeBidi: null,
    unicodeRange: null,
    unitsPerEm: p2,
    values: null,
    vAlphabetic: p2,
    vMathematical: p2,
    vectorEffect: null,
    vHanging: p2,
    vIdeographic: p2,
    version: null,
    vertAdvY: p2,
    vertOriginX: p2,
    vertOriginY: p2,
    viewBox: null,
    viewTarget: null,
    visibility: null,
    width: null,
    widths: null,
    wordSpacing: null,
    writingMode: null,
    x: null,
    x1: null,
    x2: null,
    xChannelSelector: null,
    xHeight: p2,
    y: null,
    y1: null,
    y2: null,
    yChannelSelector: null,
    z: null,
    zoomAndPan: null
  }
});

// node_modules/property-information/lib/find.js
var Gz1 = /^data[-\w.:]+$/i, gI0 = /-[a-z]/g, Hz1 = /[A-Z]/g;
function f10(Z, J) {
  let $ = yI(J), X = J, Y = lW;
  if ($ in Z.normal)
    return Z.property[Z.normal[$]];
  if ($.length > 4 && $.slice(0, 4) === "data" && Gz1.test(J)) {
    if (J.charAt(4) === "-") {
      let Q = J.slice(5).replace(gI0, qz1);
      X = "data" + Q.charAt(0).toUpperCase() + Q.slice(1);
    } else {
      let Q = J.slice(4);
      if (!gI0.test(Q)) {
        let W = Q.replace(Hz1, Nz1);
        if (W.charAt(0) !== "-")
          W = "-" + W;
        J = "data" + W;
      }
    }
    Y = wB;
  }
  return new Y(X, J);
}
function Nz1(Z) {
  return "-" + Z.toLowerCase();
}
function qz1(Z) {
  return Z.charAt(1).toUpperCase();
}
// node_modules/property-information/lib/hast-to-react.js
var h10 = {
  classId: "classID",
  dataType: "datatype",
  itemId: "itemID",
  strokeDashArray: "strokeDasharray",
  strokeDashOffset: "strokeDashoffset",
  strokeLineCap: "strokeLinecap",
  strokeLineJoin: "strokeLinejoin",
  strokeMiterLimit: "strokeMiterlimit",
  typeOf: "typeof",
  xLinkActuate: "xlinkActuate",
  xLinkArcRole: "xlinkArcrole",
  xLinkHref: "xlinkHref",
  xLinkRole: "xlinkRole",
  xLinkShow: "xlinkShow",
  xLinkTitle: "xlinkTitle",
  xLinkType: "xlinkType",
  xmlnsXLink: "xmlnsXlink"
};
// node_modules/property-information/index.js
var mI0 = V10([k10, C10, v10, S10, xI0], "html"), Cy = V10([k10, C10, v10, S10, yI0], "svg");

// node_modules/space-separated-tokens/index.js
function dI0(Z) {
  return Z.join(" ").trim();
}

// node_modules/style-to-object/esm/index.mjs
var b10 = t2(oI0(), 1), sI0 = b10.default.default || b10.default;

// node_modules/unist-util-position/lib/index.js
var ky = aI0("end"), jB = aI0("start");
function aI0(Z) {
  return J;
  function J($) {
    let X = $ && $.position && $.position[Z] || {};
    if (typeof X.line === "number" && X.line > 0 && typeof X.column === "number" && X.column > 0)
      return {
        line: X.line,
        column: X.column,
        offset: typeof X.offset === "number" && X.offset > -1 ? X.offset : void 0
      };
  }
}
function x10(Z) {
  let J = jB(Z), $ = ky(Z);
  if (J && $)
    return { start: J, end: $ };
}
// node_modules/unist-util-stringify-position/lib/index.js
function wE(Z) {
  if (!Z || typeof Z !== "object")
    return "";
  if ("position" in Z || "type" in Z)
    return rI0(Z.position);
  if ("start" in Z || "end" in Z)
    return rI0(Z);
  if ("line" in Z || "column" in Z)
    return y10(Z);
  return "";
}
function y10(Z) {
  return tI0(Z && Z.line) + ":" + tI0(Z && Z.column);
}
function rI0(Z) {
  return y10(Z && Z.start) + "-" + y10(Z && Z.end);
}
function tI0(Z) {
  return Z && typeof Z === "number" ? Z : 1;
}
// node_modules/vfile-message/lib/index.js
class HX extends Error {
  constructor(Z, J, $) {
    super();
    if (typeof J === "string")
      $ = J, J = void 0;
    let X = "", Y = {}, Q = !1;
    if (J)
      if ("line" in J && "column" in J)
        Y = { place: J };
      else if ("start" in J && "end" in J)
        Y = { place: J };
      else if ("type" in J)
        Y = {
          ancestors: [J],
          place: J.position
        };
      else
        Y = { ...J };
    if (typeof Z === "string")
      X = Z;
    else if (!Y.cause && Z)
      Q = !0, X = Z.message, Y.cause = Z;
    if (!Y.ruleId && !Y.source && typeof $ === "string") {
      let K = $.indexOf(":");
      if (K === -1)
        Y.ruleId = $;
      else
        Y.source = $.slice(0, K), Y.ruleId = $.slice(K + 1);
    }
    if (!Y.place && Y.ancestors && Y.ancestors) {
      let K = Y.ancestors[Y.ancestors.length - 1];
      if (K)
        Y.place = K.position;
    }
    let W = Y.place && "start" in Y.place ? Y.place.start : Y.place;
    this.ancestors = Y.ancestors || void 0, this.cause = Y.cause || void 0, this.column = W ? W.column : void 0, this.fatal = void 0, this.file, this.message = X, this.line = W ? W.line : void 0, this.name = wE(Y.place) || "1:1", this.place = Y.place || void 0, this.reason = this.message, this.ruleId = Y.ruleId || void 0, this.source = Y.source || void 0, this.stack = Q && Y.cause && typeof Y.cause.stack === "string" ? Y.cause.stack : "", this.actual, this.expected, this.note, this.url;
  }
}
HX.prototype.file = "";
HX.prototype.name = "";
HX.prototype.reason = "";
HX.prototype.message = "";
HX.prototype.stack = "";
HX.prototype.column = void 0;
HX.prototype.line = void 0;
HX.prototype.ancestors = void 0;
HX.prototype.cause = void 0;
HX.prototype.fatal = void 0;
HX.prototype.place = void 0;
HX.prototype.ruleId = void 0;
HX.prototype.source = void 0;
// node_modules/hast-util-to-jsx-runtime/lib/index.js
var g10 = {}.hasOwnProperty, Tz1 = /* @__PURE__ */ new Map, _z1 = /[A-Z]/g, Vz1 = /-([a-z])/g, Iz1 = /* @__PURE__ */ new Set(["table", "tbody", "thead", "tfoot", "tr"]), Pz1 = /* @__PURE__ */ new Set(["td", "th"]), eI0 = "https://github.com/syntax-tree/hast-util-to-jsx-runtime";
function m10(Z, J) {
  if (!J || J.Fragment === void 0)
    throw new TypeError("Expected `Fragment` in options");
  let $ = J.filePath || void 0, X;
  if (J.development) {
    if (typeof J.jsxDEV !== "function")
      throw new TypeError("Expected `jsxDEV` in options when `development: true`");
    X = xz1($, J.jsxDEV);
  } else {
    if (typeof J.jsx !== "function")
      throw new TypeError("Expected `jsx` in production options");
    if (typeof J.jsxs !== "function")
      throw new TypeError("Expected `jsxs` in production options");
    X = bz1($, J.jsx, J.jsxs);
  }
  let Y = {
    Fragment: J.Fragment,
    ancestors: [],
    components: J.components || {},
    create: X,
    elementAttributeNameCase: J.elementAttributeNameCase || "react",
    evaluater: J.createEvaluater ? J.createEvaluater() : void 0,
    filePath: $,
    ignoreInvalidStyle: J.ignoreInvalidStyle || !1,
    passKeys: J.passKeys !== !1,
    passNode: J.passNode || !1,
    schema: J.space === "svg" ? Cy : mI0,
    stylePropertyNameCase: J.stylePropertyNameCase || "dom",
    tableCellAlignToStyle: J.tableCellAlignToStyle !== !1
  }, Q = ZP0(Y, Z, void 0);
  if (Q && typeof Q !== "string")
    return Q;
  return Y.create(Z, Y.Fragment, { children: Q || void 0 }, void 0);
}
function ZP0(Z, J, $) {
  if (J.type === "element")
    return Cz1(Z, J, $);
  if (J.type === "mdxFlowExpression" || J.type === "mdxTextExpression")
    return kz1(Z, J);
  if (J.type === "mdxJsxFlowElement" || J.type === "mdxJsxTextElement")
    return Sz1(Z, J, $);
  if (J.type === "mdxjsEsm")
    return vz1(Z, J);
  if (J.type === "root")
    return fz1(Z, J, $);
  if (J.type === "text")
    return hz1(Z, J);
}
function Cz1(Z, J, $) {
  let X = Z.schema, Y = X;
  if (J.tagName.toLowerCase() === "svg" && X.space === "html")
    Y = Cy, Z.schema = Y;
  Z.ancestors.push(J);
  let Q = $P0(Z, J.tagName, !1), W = yz1(Z, J), K = p10(Z, J);
  if (Iz1.has(J.tagName))
    K = K.filter(function(G) {
      return typeof G === "string" ? !_10(G) : !0;
    });
  return JP0(Z, W, Q, J), d10(W, K), Z.ancestors.pop(), Z.schema = X, Z.create(J, Q, W, $);
}
function kz1(Z, J) {
  if (J.data && J.data.estree && Z.evaluater) {
    let X = J.data.estree.body[0];
    return t0(X.type === "ExpressionStatement"), Z.evaluater.evaluateExpression(X.expression);
  }
  dI(Z, J.position);
}
function vz1(Z, J) {
  if (J.data && J.data.estree && Z.evaluater)
    return Z.evaluater.evaluateProgram(J.data.estree);
  dI(Z, J.position);
}
function Sz1(Z, J, $) {
  let X = Z.schema, Y = X;
  if (J.name === "svg" && X.space === "html")
    Y = Cy, Z.schema = Y;
  Z.ancestors.push(J);
  let Q = J.name === null ? Z.Fragment : $P0(Z, J.name, !0), W = gz1(Z, J), K = p10(Z, J);
  return JP0(Z, W, Q, J), d10(W, K), Z.ancestors.pop(), Z.schema = X, Z.create(J, Q, W, $);
}
function fz1(Z, J, $) {
  let X = {};
  return d10(X, p10(Z, J)), Z.create(J, Z.Fragment, X, $);
}
function hz1(Z, J) {
  return J.value;
}
function JP0(Z, J, $, X) {
  if (typeof $ !== "string" && $ !== Z.Fragment && Z.passNode)
    J.node = X;
}
function d10(Z, J) {
  if (J.length > 0) {
    let $ = J.length > 1 ? J : J[0];
    if ($)
      Z.children = $;
  }
}
function bz1(Z, J, $) {
  return X;
  function X(Y, Q, W, K) {
    let H = Array.isArray(W.children) ? $ : J;
    return K ? H(Q, W, K) : H(Q, W);
  }
}
function xz1(Z, J) {
  return $;
  function $(X, Y, Q, W) {
    let K = Array.isArray(Q.children), G = jB(X);
    return J(Y, Q, W, K, {
      columnNumber: G ? G.column - 1 : void 0,
      fileName: Z,
      lineNumber: G ? G.line : void 0
    }, void 0);
  }
}
function yz1(Z, J) {
  let $ = {}, X, Y;
  for (Y in J.properties)
    if (Y !== "children" && g10.call(J.properties, Y)) {
      let Q = mz1(Z, Y, J.properties[Y]);
      if (Q) {
        let [W, K] = Q;
        if (Z.tableCellAlignToStyle && W === "align" && typeof K === "string" && Pz1.has(J.tagName))
          X = K;
        else
          $[W] = K;
      }
    }
  if (X) {
    let Q = $.style || ($.style = {});
    Q[Z.stylePropertyNameCase === "css" ? "text-align" : "textAlign"] = X;
  }
  return $;
}
function gz1(Z, J) {
  let $ = {};
  for (let X of J.attributes)
    if (X.type === "mdxJsxExpressionAttribute")
      if (X.data && X.data.estree && Z.evaluater) {
        let Q = X.data.estree.body[0];
        t0(Q.type === "ExpressionStatement");
        let W = Q.expression;
        t0(W.type === "ObjectExpression");
        let K = W.properties[0];
        t0(K.type === "SpreadElement"), Object.assign($, Z.evaluater.evaluateExpression(K.argument));
      } else
        dI(Z, J.position);
    else {
      let Y = X.name, Q;
      if (X.value && typeof X.value === "object")
        if (X.value.data && X.value.data.estree && Z.evaluater) {
          let K = X.value.data.estree.body[0];
          t0(K.type === "ExpressionStatement"), Q = Z.evaluater.evaluateExpression(K.expression);
        } else
          dI(Z, J.position);
      else
        Q = X.value === null ? !0 : X.value;
      $[Y] = Q;
    }
  return $;
}
function p10(Z, J) {
  let $ = [], X = -1, Y = Z.passKeys ? /* @__PURE__ */ new Map : Tz1;
  while (++X < J.children.length) {
    let Q = J.children[X], W;
    if (Z.passKeys) {
      let G = Q.type === "element" ? Q.tagName : Q.type === "mdxJsxFlowElement" || Q.type === "mdxJsxTextElement" ? Q.name : void 0;
      if (G) {
        let H = Y.get(G) || 0;
        W = G + "-" + H, Y.set(G, H + 1);
      }
    }
    let K = ZP0(Z, Q, W);
    if (K !== void 0)
      $.push(K);
  }
  return $;
}
function mz1(Z, J, $) {
  let X = f10(Z.schema, J);
  if ($ === null || $ === void 0 || typeof $ === "number" && Number.isNaN($))
    return;
  if (Array.isArray($))
    $ = X.commaSeparated ? fI0($) : dI0($);
  if (X.property === "style") {
    let Y = typeof $ === "object" ? $ : dz1(Z, String($));
    if (Z.stylePropertyNameCase === "css")
      Y = pz1(Y);
    return ["style", Y];
  }
  return [
    Z.elementAttributeNameCase === "react" && X.space ? h10[X.property] || X.property : X.attribute,
    $
  ];
}
function dz1(Z, J) {
  let $ = {};
  try {
    sI0(J, X);
  } catch (Y) {
    if (!Z.ignoreInvalidStyle) {
      let Q = Y, W = new HX("Cannot parse `style` attribute", {
        ancestors: Z.ancestors,
        cause: Q,
        ruleId: "style",
        source: "hast-util-to-jsx-runtime"
      });
      throw W.file = Z.filePath || void 0, W.url = eI0 + "#cannot-parse-style-attribute", W;
    }
  }
  return $;
  function X(Y, Q) {
    let W = Y;
    if (W.slice(0, 2) !== "--") {
      if (W.slice(0, 4) === "-ms-")
        W = "ms-" + W.slice(4);
      W = W.replace(Vz1, cz1);
    }
    $[W] = Q;
  }
}
function $P0(Z, J, $) {
  let X;
  if (!$)
    X = { type: "Literal", value: J };
  else if (J.includes(".")) {
    let Y = J.split("."), Q = -1, W;
    while (++Q < Y.length) {
      let K = Vy(Y[Q]) ? { type: "Identifier", name: Y[Q] } : { type: "Literal", value: Y[Q] };
      W = W ? {
        type: "MemberExpression",
        object: W,
        property: K,
        computed: Boolean(Q && K.type === "Literal"),
        optional: !1
      } : K;
    }
    t0(W, "always a result"), X = W;
  } else
    X = Vy(J) && !/^[a-z]/.test(J) ? { type: "Identifier", name: J } : { type: "Literal", value: J };
  if (X.type === "Literal") {
    let Y = X.value;
    return g10.call(Z.components, Y) ? Z.components[Y] : Y;
  }
  if (Z.evaluater)
    return Z.evaluater.evaluateExpression(X);
  dI(Z);
}
function dI(Z, J) {
  let $ = new HX("Cannot handle MDX estrees without `createEvaluater`", {
    ancestors: Z.ancestors,
    place: J,
    ruleId: "mdx-estree",
    source: "hast-util-to-jsx-runtime"
  });
  throw $.file = Z.filePath || void 0, $.url = eI0 + "#cannot-handle-mdx-estrees-without-createevaluater", $;
}
function pz1(Z) {
  let J = {}, $;
  for ($ in Z)
    if (g10.call(Z, $))
      J[uz1($)] = Z[$];
  return J;
}
function uz1(Z) {
  let J = Z.replace(_z1, lz1);
  if (J.slice(0, 3) === "ms-")
    J = "-" + J;
  return J;
}
function cz1(Z, J) {
  return J.toUpperCase();
}
function lz1(Z) {
  return "-" + Z.toLowerCase();
}
// node_modules/html-url-attributes/lib/index.js
var pI = {
  action: ["form"],
  cite: ["blockquote", "del", "ins", "q"],
  data: ["object"],
  formAction: ["button", "input"],
  href: ["a", "area", "base", "link"],
  icon: ["menuitem"],
  itemId: null,
  manifest: ["html"],
  ping: ["a", "area"],
  poster: ["video"],
  src: [
    "audio",
    "embed",
    "iframe",
    "img",
    "input",
    "script",
    "source",
    "track",
    "video"
  ]
};
// node_modules/react-markdown/lib/index.js
var xB = t2(PZ(), 1), SC0 = t2(J7(), 1);

// node_modules/mdast-util-to-string/lib/index.js
var nz1 = {};
function ez(Z, J) {
  let $ = J || nz1, X = typeof $.includeImageAlt === "boolean" ? $.includeImageAlt : !0, Y = typeof $.includeHtml === "boolean" ? $.includeHtml : !0;
  return YP0(Z, X, Y);
}
function YP0(Z, J, $) {
  if (iz1(Z)) {
    if ("value" in Z)
      return Z.type === "html" && !$ ? "" : Z.value;
    if (J && "alt" in Z && Z.alt)
      return Z.alt;
    if ("children" in Z)
      return XP0(Z.children, J, $);
  }
  if (Array.isArray(Z))
    return XP0(Z, J, $);
  return "";
}
function XP0(Z, J, $) {
  let X = [], Y = -1;
  while (++Y < Z.length)
    X[Y] = YP0(Z[Y], J, $);
  return X.join("");
}
function iz1(Z) {
  return Boolean(Z && typeof Z === "object");
}
// node_modules/decode-named-character-reference/index.dom.js
var QP0 = document.createElement("i");
function TB(Z) {
  let J = "&" + Z + ";";
  QP0.innerHTML = J;
  let $ = QP0.textContent;
  if ($.charCodeAt($.length - 1) === 59 && Z !== "semi")
    return !1;
  return $ === J ? !1 : $;
}

// node_modules/micromark-util-symbol/lib/codes.js
var K0 = {
  carriageReturn: -5,
  lineFeed: -4,
  carriageReturnLineFeed: -3,
  horizontalTab: -2,
  virtualSpace: -1,
  eof: null,
  nul: 0,
  soh: 1,
  stx: 2,
  etx: 3,
  eot: 4,
  enq: 5,
  ack: 6,
  bel: 7,
  bs: 8,
  ht: 9,
  lf: 10,
  vt: 11,
  ff: 12,
  cr: 13,
  so: 14,
  si: 15,
  dle: 16,
  dc1: 17,
  dc2: 18,
  dc3: 19,
  dc4: 20,
  nak: 21,
  syn: 22,
  etb: 23,
  can: 24,
  em: 25,
  sub: 26,
  esc: 27,
  fs: 28,
  gs: 29,
  rs: 30,
  us: 31,
  space: 32,
  exclamationMark: 33,
  quotationMark: 34,
  numberSign: 35,
  dollarSign: 36,
  percentSign: 37,
  ampersand: 38,
  apostrophe: 39,
  leftParenthesis: 40,
  rightParenthesis: 41,
  asterisk: 42,
  plusSign: 43,
  comma: 44,
  dash: 45,
  dot: 46,
  slash: 47,
  digit0: 48,
  digit1: 49,
  digit2: 50,
  digit3: 51,
  digit4: 52,
  digit5: 53,
  digit6: 54,
  digit7: 55,
  digit8: 56,
  digit9: 57,
  colon: 58,
  semicolon: 59,
  lessThan: 60,
  equalsTo: 61,
  greaterThan: 62,
  questionMark: 63,
  atSign: 64,
  uppercaseA: 65,
  uppercaseB: 66,
  uppercaseC: 67,
  uppercaseD: 68,
  uppercaseE: 69,
  uppercaseF: 70,
  uppercaseG: 71,
  uppercaseH: 72,
  uppercaseI: 73,
  uppercaseJ: 74,
  uppercaseK: 75,
  uppercaseL: 76,
  uppercaseM: 77,
  uppercaseN: 78,
  uppercaseO: 79,
  uppercaseP: 80,
  uppercaseQ: 81,
  uppercaseR: 82,
  uppercaseS: 83,
  uppercaseT: 84,
  uppercaseU: 85,
  uppercaseV: 86,
  uppercaseW: 87,
  uppercaseX: 88,
  uppercaseY: 89,
  uppercaseZ: 90,
  leftSquareBracket: 91,
  backslash: 92,
  rightSquareBracket: 93,
  caret: 94,
  underscore: 95,
  graveAccent: 96,
  lowercaseA: 97,
  lowercaseB: 98,
  lowercaseC: 99,
  lowercaseD: 100,
  lowercaseE: 101,
  lowercaseF: 102,
  lowercaseG: 103,
  lowercaseH: 104,
  lowercaseI: 105,
  lowercaseJ: 106,
  lowercaseK: 107,
  lowercaseL: 108,
  lowercaseM: 109,
  lowercaseN: 110,
  lowercaseO: 111,
  lowercaseP: 112,
  lowercaseQ: 113,
  lowercaseR: 114,
  lowercaseS: 115,
  lowercaseT: 116,
  lowercaseU: 117,
  lowercaseV: 118,
  lowercaseW: 119,
  lowercaseX: 120,
  lowercaseY: 121,
  lowercaseZ: 122,
  leftCurlyBrace: 123,
  verticalBar: 124,
  rightCurlyBrace: 125,
  tilde: 126,
  del: 127,
  byteOrderMarker: 65279,
  replacementCharacter: 65533
};
// node_modules/micromark-util-symbol/lib/constants.js
var M2 = {
  attentionSideBefore: 1,
  attentionSideAfter: 2,
  atxHeadingOpeningFenceSizeMax: 6,
  autolinkDomainSizeMax: 63,
  autolinkSchemeSizeMax: 32,
  cdataOpeningString: "CDATA[",
  characterGroupWhitespace: 1,
  characterGroupPunctuation: 2,
  characterReferenceDecimalSizeMax: 7,
  characterReferenceHexadecimalSizeMax: 6,
  characterReferenceNamedSizeMax: 31,
  codeFencedSequenceSizeMin: 3,
  contentTypeDocument: "document",
  contentTypeFlow: "flow",
  contentTypeContent: "content",
  contentTypeString: "string",
  contentTypeText: "text",
  hardBreakPrefixSizeMin: 2,
  htmlRaw: 1,
  htmlComment: 2,
  htmlInstruction: 3,
  htmlDeclaration: 4,
  htmlCdata: 5,
  htmlBasic: 6,
  htmlComplete: 7,
  htmlRawSizeMax: 8,
  linkResourceDestinationBalanceMax: 32,
  linkReferenceSizeMax: 999,
  listItemValueSizeMax: 10,
  numericBaseDecimal: 10,
  numericBaseHexadecimal: 16,
  tabSize: 4,
  thematicBreakMarkerCountMin: 3,
  v8MaxSafeChunkSize: 1e4
};
// node_modules/micromark-util-symbol/lib/types.js
var M0 = {
  data: "data",
  whitespace: "whitespace",
  lineEnding: "lineEnding",
  lineEndingBlank: "lineEndingBlank",
  linePrefix: "linePrefix",
  lineSuffix: "lineSuffix",
  atxHeading: "atxHeading",
  atxHeadingSequence: "atxHeadingSequence",
  atxHeadingText: "atxHeadingText",
  autolink: "autolink",
  autolinkEmail: "autolinkEmail",
  autolinkMarker: "autolinkMarker",
  autolinkProtocol: "autolinkProtocol",
  characterEscape: "characterEscape",
  characterEscapeValue: "characterEscapeValue",
  characterReference: "characterReference",
  characterReferenceMarker: "characterReferenceMarker",
  characterReferenceMarkerNumeric: "characterReferenceMarkerNumeric",
  characterReferenceMarkerHexadecimal: "characterReferenceMarkerHexadecimal",
  characterReferenceValue: "characterReferenceValue",
  codeFenced: "codeFenced",
  codeFencedFence: "codeFencedFence",
  codeFencedFenceSequence: "codeFencedFenceSequence",
  codeFencedFenceInfo: "codeFencedFenceInfo",
  codeFencedFenceMeta: "codeFencedFenceMeta",
  codeFlowValue: "codeFlowValue",
  codeIndented: "codeIndented",
  codeText: "codeText",
  codeTextData: "codeTextData",
  codeTextPadding: "codeTextPadding",
  codeTextSequence: "codeTextSequence",
  content: "content",
  definition: "definition",
  definitionDestination: "definitionDestination",
  definitionDestinationLiteral: "definitionDestinationLiteral",
  definitionDestinationLiteralMarker: "definitionDestinationLiteralMarker",
  definitionDestinationRaw: "definitionDestinationRaw",
  definitionDestinationString: "definitionDestinationString",
  definitionLabel: "definitionLabel",
  definitionLabelMarker: "definitionLabelMarker",
  definitionLabelString: "definitionLabelString",
  definitionMarker: "definitionMarker",
  definitionTitle: "definitionTitle",
  definitionTitleMarker: "definitionTitleMarker",
  definitionTitleString: "definitionTitleString",
  emphasis: "emphasis",
  emphasisSequence: "emphasisSequence",
  emphasisText: "emphasisText",
  escapeMarker: "escapeMarker",
  hardBreakEscape: "hardBreakEscape",
  hardBreakTrailing: "hardBreakTrailing",
  htmlFlow: "htmlFlow",
  htmlFlowData: "htmlFlowData",
  htmlText: "htmlText",
  htmlTextData: "htmlTextData",
  image: "image",
  label: "label",
  labelText: "labelText",
  labelLink: "labelLink",
  labelImage: "labelImage",
  labelMarker: "labelMarker",
  labelImageMarker: "labelImageMarker",
  labelEnd: "labelEnd",
  link: "link",
  paragraph: "paragraph",
  reference: "reference",
  referenceMarker: "referenceMarker",
  referenceString: "referenceString",
  resource: "resource",
  resourceDestination: "resourceDestination",
  resourceDestinationLiteral: "resourceDestinationLiteral",
  resourceDestinationLiteralMarker: "resourceDestinationLiteralMarker",
  resourceDestinationRaw: "resourceDestinationRaw",
  resourceDestinationString: "resourceDestinationString",
  resourceMarker: "resourceMarker",
  resourceTitle: "resourceTitle",
  resourceTitleMarker: "resourceTitleMarker",
  resourceTitleString: "resourceTitleString",
  setextHeading: "setextHeading",
  setextHeadingText: "setextHeadingText",
  setextHeadingLine: "setextHeadingLine",
  setextHeadingLineSequence: "setextHeadingLineSequence",
  strong: "strong",
  strongSequence: "strongSequence",
  strongText: "strongText",
  thematicBreak: "thematicBreak",
  thematicBreakSequence: "thematicBreakSequence",
  blockQuote: "blockQuote",
  blockQuotePrefix: "blockQuotePrefix",
  blockQuoteMarker: "blockQuoteMarker",
  blockQuotePrefixWhitespace: "blockQuotePrefixWhitespace",
  listOrdered: "listOrdered",
  listUnordered: "listUnordered",
  listItemIndent: "listItemIndent",
  listItemMarker: "listItemMarker",
  listItemPrefix: "listItemPrefix",
  listItemPrefixWhitespace: "listItemPrefixWhitespace",
  listItemValue: "listItemValue",
  chunkDocument: "chunkDocument",
  chunkContent: "chunkContent",
  chunkFlow: "chunkFlow",
  chunkText: "chunkText",
  chunkString: "chunkString"
};
// node_modules/micromark-util-symbol/lib/values.js
var nW = {
  ht: "\t",
  lf: `
`,
  cr: "\r",
  space: " ",
  exclamationMark: "!",
  quotationMark: '"',
  numberSign: "#",
  dollarSign: "$",
  percentSign: "%",
  ampersand: "&",
  apostrophe: "'",
  leftParenthesis: "(",
  rightParenthesis: ")",
  asterisk: "*",
  plusSign: "+",
  comma: ",",
  dash: "-",
  dot: ".",
  slash: "/",
  digit0: "0",
  digit1: "1",
  digit2: "2",
  digit3: "3",
  digit4: "4",
  digit5: "5",
  digit6: "6",
  digit7: "7",
  digit8: "8",
  digit9: "9",
  colon: ":",
  semicolon: ";",
  lessThan: "<",
  equalsTo: "=",
  greaterThan: ">",
  questionMark: "?",
  atSign: "@",
  uppercaseA: "A",
  uppercaseB: "B",
  uppercaseC: "C",
  uppercaseD: "D",
  uppercaseE: "E",
  uppercaseF: "F",
  uppercaseG: "G",
  uppercaseH: "H",
  uppercaseI: "I",
  uppercaseJ: "J",
  uppercaseK: "K",
  uppercaseL: "L",
  uppercaseM: "M",
  uppercaseN: "N",
  uppercaseO: "O",
  uppercaseP: "P",
  uppercaseQ: "Q",
  uppercaseR: "R",
  uppercaseS: "S",
  uppercaseT: "T",
  uppercaseU: "U",
  uppercaseV: "V",
  uppercaseW: "W",
  uppercaseX: "X",
  uppercaseY: "Y",
  uppercaseZ: "Z",
  leftSquareBracket: "[",
  backslash: "\\",
  rightSquareBracket: "]",
  caret: "^",
  underscore: "_",
  graveAccent: "`",
  lowercaseA: "a",
  lowercaseB: "b",
  lowercaseC: "c",
  lowercaseD: "d",
  lowercaseE: "e",
  lowercaseF: "f",
  lowercaseG: "g",
  lowercaseH: "h",
  lowercaseI: "i",
  lowercaseJ: "j",
  lowercaseK: "k",
  lowercaseL: "l",
  lowercaseM: "m",
  lowercaseN: "n",
  lowercaseO: "o",
  lowercaseP: "p",
  lowercaseQ: "q",
  lowercaseR: "r",
  lowercaseS: "s",
  lowercaseT: "t",
  lowercaseU: "u",
  lowercaseV: "v",
  lowercaseW: "w",
  lowercaseX: "x",
  lowercaseY: "y",
  lowercaseZ: "z",
  leftCurlyBrace: "{",
  verticalBar: "|",
  rightCurlyBrace: "}",
  tilde: "~",
  replacementCharacter: "�"
};
// node_modules/micromark-util-chunked/dev/index.js
function NX(Z, J, $, X) {
  let Y = Z.length, Q = 0, W;
  if (J < 0)
    J = -J > Y ? 0 : Y + J;
  else
    J = J > Y ? Y : J;
  if ($ = $ > 0 ? $ : 0, X.length < M2.v8MaxSafeChunkSize)
    W = Array.from(X), W.unshift(J, $), Z.splice(...W);
  else {
    if ($)
      Z.splice(J, $);
    while (Q < X.length)
      W = X.slice(Q, Q + M2.v8MaxSafeChunkSize), W.unshift(J, 0), Z.splice(...W), Q += M2.v8MaxSafeChunkSize, J += M2.v8MaxSafeChunkSize;
  }
}
function iW(Z, J) {
  if (Z.length > 0)
    return NX(Z, Z.length, 0, J), Z;
  return J;
}

// node_modules/micromark-util-combine-extensions/index.js
var WP0 = {}.hasOwnProperty;
function vy(Z) {
  let J = {}, $ = -1;
  while (++$ < Z.length)
    oz1(J, Z[$]);
  return J;
}
function oz1(Z, J) {
  let $;
  for ($ in J) {
    let Y = (WP0.call(Z, $) ? Z[$] : void 0) || (Z[$] = {}), Q = J[$], W;
    if (Q)
      for (W in Q) {
        if (!WP0.call(Y, W))
          Y[W] = [];
        let K = Q[W];
        sz1(Y[W], Array.isArray(K) ? K : K ? [K] : []);
      }
  }
}
function sz1(Z, J) {
  let $ = -1, X = [];
  while (++$ < J.length)
    (J[$].add === "after" ? Z : X).push(J[$]);
  NX(Z, 0, 0, X);
}

// node_modules/micromark-util-decode-numeric-character-reference/dev/index.js
function Sy(Z, J) {
  let $ = Number.parseInt(Z, J);
  if ($ < K0.ht || $ === K0.vt || $ > K0.cr && $ < K0.space || $ > K0.tilde && $ < 160 || $ > 55295 && $ < 57344 || $ > 64975 && $ < 65008 || ($ & 65535) === 65535 || ($ & 65535) === 65534 || $ > 1114111)
    return nW.replacementCharacter;
  return String.fromCodePoint($);
}

// node_modules/micromark-util-normalize-identifier/dev/index.js
function YW(Z) {
  return Z.replace(/[\t\n\r ]+/g, nW.space).replace(/^ | $/g, "").toLowerCase().toUpperCase();
}

// node_modules/micromark-util-character/dev/index.js
var nX = jE(/[A-Za-z]/), B$ = jE(/[\dA-Za-z]/), KP0 = jE(/[#-'*+\--9=?A-Z^-~]/);
function Z4(Z) {
  return Z !== null && (Z < K0.space || Z === K0.del);
}
var uI = jE(/\d/), GP0 = jE(/[\dA-Fa-f]/), HP0 = jE(/[!-/:-@[-`{-~]/);
function n2(Z) {
  return Z !== null && Z < K0.horizontalTab;
}
function Y9(Z) {
  return Z !== null && (Z < K0.nul || Z === K0.space);
}
function F6(Z) {
  return Z === K0.horizontalTab || Z === K0.virtualSpace || Z === K0.space;
}
var J4 = jE(/\p{P}|\p{S}/u), Pq = jE(/\s/);
function jE(Z) {
  return J;
  function J($) {
    return $ !== null && $ > -1 && Z.test(String.fromCharCode($));
  }
}

// node_modules/micromark-util-sanitize-uri/dev/index.js
function $G(Z) {
  let J = [], $ = -1, X = 0, Y = 0;
  while (++$ < Z.length) {
    let Q = Z.charCodeAt($), W = "";
    if (Q === K0.percentSign && B$(Z.charCodeAt($ + 1)) && B$(Z.charCodeAt($ + 2)))
      Y = 2;
    else if (Q < 128) {
      if (!/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(Q)))
        W = String.fromCharCode(Q);
    } else if (Q > 55295 && Q < 57344) {
      let K = Z.charCodeAt($ + 1);
      if (Q < 56320 && K > 56319 && K < 57344)
        W = String.fromCharCode(Q, K), Y = 1;
      else
        W = nW.replacementCharacter;
    } else
      W = String.fromCharCode(Q);
    if (W)
      J.push(Z.slice(X, $), encodeURIComponent(W)), X = $ + Y + 1, W = "";
    if (Y)
      $ += Y, Y = 0;
  }
  return J.join("") + Z.slice(X);
}

// node_modules/micromark-factory-space/dev/index.js
function U6(Z, J, $, X) {
  let Y = X ? X - 1 : Number.POSITIVE_INFINITY, Q = 0;
  return W;
  function W(G) {
    if (F6(G))
      return Z.enter($), K(G);
    return J(G);
  }
  function K(G) {
    if (F6(G) && Q++ < Y)
      return Z.consume(G), K;
    return Z.exit($), J(G);
  }
}

// node_modules/micromark/dev/lib/initialize/content.js
var NP0 = { tokenize: az1 };
function az1(Z) {
  let J = Z.attempt(this.parser.constructs.contentInitial, X, Y), $;
  return J;
  function X(K) {
    if (t0(K === K0.eof || n2(K), "expected eol or eof"), K === K0.eof) {
      Z.consume(K);
      return;
    }
    return Z.enter(M0.lineEnding), Z.consume(K), Z.exit(M0.lineEnding), U6(Z, J, M0.linePrefix);
  }
  function Y(K) {
    return t0(K !== K0.eof && !n2(K), "expected anything other than a line ending or EOF"), Z.enter(M0.paragraph), Q(K);
  }
  function Q(K) {
    let G = Z.enter(M0.chunkText, {
      contentType: M2.contentTypeText,
      previous: $
    });
    if ($)
      $.next = G;
    return $ = G, W(K);
  }
  function W(K) {
    if (K === K0.eof) {
      Z.exit(M0.chunkText), Z.exit(M0.paragraph), Z.consume(K);
      return;
    }
    if (n2(K))
      return Z.consume(K), Z.exit(M0.chunkText), Q;
    return Z.consume(K), W;
  }
}

// node_modules/micromark/dev/lib/initialize/document.js
var FP0 = { tokenize: rz1 }, qP0 = { tokenize: tz1 };
function rz1(Z) {
  let J = this, $ = [], X = 0, Y, Q, W;
  return K;
  function K(B) {
    if (X < $.length) {
      let T = $[X];
      return J.containerState = T[1], t0(T[0].continuation, "expected `continuation` to be defined on container construct"), Z.attempt(T[0].continuation, G, H)(B);
    }
    return H(B);
  }
  function G(B) {
    if (t0(J.containerState, "expected `containerState` to be defined after continuation"), X++, J.containerState._closeFlow) {
      if (J.containerState._closeFlow = void 0, Y)
        A();
      let T = J.events.length, w = T, V;
      while (w--)
        if (J.events[w][0] === "exit" && J.events[w][1].type === M0.chunkFlow) {
          V = J.events[w][1].end;
          break;
        }
      t0(V, "could not find previous flow chunk"), D(X);
      let P = T;
      while (P < J.events.length)
        J.events[P][1].end = Object.assign({}, V), P++;
      return NX(J.events, w + 1, 0, J.events.slice(T)), J.events.length = P, H(B);
    }
    return K(B);
  }
  function H(B) {
    if (X === $.length) {
      if (!Y)
        return U(B);
      if (Y.currentConstruct && Y.currentConstruct.concrete)
        return E(B);
      J.interrupt = Boolean(Y.currentConstruct && !Y._gfmTableDynamicInterruptHack);
    }
    return J.containerState = {}, Z.check(qP0, N, q)(B);
  }
  function N(B) {
    if (Y)
      A();
    return D(X), U(B);
  }
  function q(B) {
    return J.parser.lazy[J.now().line] = X !== $.length, W = J.now().offset, E(B);
  }
  function U(B) {
    return J.containerState = {}, Z.attempt(qP0, F, E)(B);
  }
  function F(B) {
    return t0(J.currentConstruct, "expected `currentConstruct` to be defined on tokenizer"), t0(J.containerState, "expected `containerState` to be defined on tokenizer"), X++, $.push([J.currentConstruct, J.containerState]), U(B);
  }
  function E(B) {
    if (B === K0.eof) {
      if (Y)
        A();
      D(0), Z.consume(B);
      return;
    }
    return Y = Y || J.parser.flow(J.now()), Z.enter(M0.chunkFlow, {
      contentType: M2.contentTypeFlow,
      previous: Q,
      _tokenizer: Y
    }), R(B);
  }
  function R(B) {
    if (B === K0.eof) {
      z(Z.exit(M0.chunkFlow), !0), D(0), Z.consume(B);
      return;
    }
    if (n2(B))
      return Z.consume(B), z(Z.exit(M0.chunkFlow)), X = 0, J.interrupt = void 0, K;
    return Z.consume(B), R;
  }
  function z(B, T) {
    t0(Y, "expected `childFlow` to be defined when continuing");
    let w = J.sliceStream(B);
    if (T)
      w.push(null);
    if (B.previous = Q, Q)
      Q.next = B;
    if (Q = B, Y.defineSkip(B.start), Y.write(w), J.parser.lazy[B.start.line]) {
      let V = Y.events.length;
      while (V--)
        if (Y.events[V][1].start.offset < W && (!Y.events[V][1].end || Y.events[V][1].end.offset > W))
          return;
      let P = J.events.length, I = P, S, f;
      while (I--)
        if (J.events[I][0] === "exit" && J.events[I][1].type === M0.chunkFlow) {
          if (S) {
            f = J.events[I][1].end;
            break;
          }
          S = !0;
        }
      t0(f, "could not find previous flow chunk"), D(X), V = P;
      while (V < J.events.length)
        J.events[V][1].end = Object.assign({}, f), V++;
      NX(J.events, I + 1, 0, J.events.slice(P)), J.events.length = V;
    }
  }
  function D(B) {
    let T = $.length;
    while (T-- > B) {
      let w = $[T];
      J.containerState = w[1], t0(w[0].exit, "expected `exit` to be defined on container construct"), w[0].exit.call(J, Z);
    }
    $.length = B;
  }
  function A() {
    t0(J.containerState, "expected `containerState` to be defined when closing flow"), t0(Y, "expected `childFlow` to be defined when closing it"), Y.write([K0.eof]), Q = void 0, Y = void 0, J.containerState._closeFlow = void 0;
  }
}
function tz1(Z, J, $) {
  return t0(this.parser.constructs.disable.null, "expected `disable.null` to be populated"), U6(Z, Z.attempt(this.parser.constructs.document, J, $), M0.linePrefix, this.parser.constructs.disable.null.includes("codeIndented") ? void 0 : M2.tabSize);
}

// node_modules/micromark-util-classify-character/dev/index.js
function _B(Z) {
  if (Z === K0.eof || Y9(Z) || Pq(Z))
    return M2.characterGroupWhitespace;
  if (J4(Z))
    return M2.characterGroupPunctuation;
}

// node_modules/micromark-util-resolve-all/index.js
function TE(Z, J, $) {
  let X = [], Y = -1;
  while (++Y < Z.length) {
    let Q = Z[Y].resolveAll;
    if (Q && !X.includes(Q))
      J = Q(J, $), X.push(Q);
  }
  return J;
}

// node_modules/micromark-core-commonmark/dev/lib/attention.js
var cI = {
  name: "attention",
  tokenize: Z41,
  resolveAll: ez1
};
function ez1(Z, J) {
  let $ = -1, X, Y, Q, W, K, G, H, N;
  while (++$ < Z.length)
    if (Z[$][0] === "enter" && Z[$][1].type === "attentionSequence" && Z[$][1]._close) {
      X = $;
      while (X--)
        if (Z[X][0] === "exit" && Z[X][1].type === "attentionSequence" && Z[X][1]._open && J.sliceSerialize(Z[X][1]).charCodeAt(0) === J.sliceSerialize(Z[$][1]).charCodeAt(0)) {
          if ((Z[X][1]._close || Z[$][1]._open) && (Z[$][1].end.offset - Z[$][1].start.offset) % 3 && !((Z[X][1].end.offset - Z[X][1].start.offset + Z[$][1].end.offset - Z[$][1].start.offset) % 3))
            continue;
          G = Z[X][1].end.offset - Z[X][1].start.offset > 1 && Z[$][1].end.offset - Z[$][1].start.offset > 1 ? 2 : 1;
          let q = Object.assign({}, Z[X][1].end), U = Object.assign({}, Z[$][1].start);
          if (UP0(q, -G), UP0(U, G), W = {
            type: G > 1 ? M0.strongSequence : M0.emphasisSequence,
            start: q,
            end: Object.assign({}, Z[X][1].end)
          }, K = {
            type: G > 1 ? M0.strongSequence : M0.emphasisSequence,
            start: Object.assign({}, Z[$][1].start),
            end: U
          }, Q = {
            type: G > 1 ? M0.strongText : M0.emphasisText,
            start: Object.assign({}, Z[X][1].end),
            end: Object.assign({}, Z[$][1].start)
          }, Y = {
            type: G > 1 ? M0.strong : M0.emphasis,
            start: Object.assign({}, W.start),
            end: Object.assign({}, K.end)
          }, Z[X][1].end = Object.assign({}, W.start), Z[$][1].start = Object.assign({}, K.end), H = [], Z[X][1].end.offset - Z[X][1].start.offset)
            H = iW(H, [
              ["enter", Z[X][1], J],
              ["exit", Z[X][1], J]
            ]);
          if (H = iW(H, [
            ["enter", Y, J],
            ["enter", W, J],
            ["exit", W, J],
            ["enter", Q, J]
          ]), t0(J.parser.constructs.insideSpan.null, "expected `insideSpan` to be populated"), H = iW(H, TE(J.parser.constructs.insideSpan.null, Z.slice(X + 1, $), J)), H = iW(H, [
            ["exit", Q, J],
            ["enter", K, J],
            ["exit", K, J],
            ["exit", Y, J]
          ]), Z[$][1].end.offset - Z[$][1].start.offset)
            N = 2, H = iW(H, [
              ["enter", Z[$][1], J],
              ["exit", Z[$][1], J]
            ]);
          else
            N = 0;
          NX(Z, X - 1, $ - X + 3, H), $ = X + H.length - N - 2;
          break;
        }
    }
  $ = -1;
  while (++$ < Z.length)
    if (Z[$][1].type === "attentionSequence")
      Z[$][1].type = "data";
  return Z;
}
function Z41(Z, J) {
  let $ = this.parser.constructs.attentionMarkers.null, X = this.previous, Y = _B(X), Q;
  return W;
  function W(G) {
    return t0(G === K0.asterisk || G === K0.underscore, "expected asterisk or underscore"), Q = G, Z.enter("attentionSequence"), K(G);
  }
  function K(G) {
    if (G === Q)
      return Z.consume(G), K;
    let H = Z.exit("attentionSequence"), N = _B(G);
    t0($, "expected `attentionMarkers` to be populated");
    let q = !N || N === M2.characterGroupPunctuation && Y || $.includes(G), U = !Y || Y === M2.characterGroupPunctuation && N || $.includes(X);
    return H._open = Boolean(Q === K0.asterisk ? q : q && (Y || !U)), H._close = Boolean(Q === K0.asterisk ? U : U && (N || !q)), J(G);
  }
}
function UP0(Z, J) {
  Z.column += J, Z.offset += J, Z._bufferIndex += J;
}
// node_modules/micromark-core-commonmark/dev/lib/autolink.js
var u10 = { name: "autolink", tokenize: J41 };
function J41(Z, J, $) {
  let X = 0;
  return Y;
  function Y(F) {
    return t0(F === K0.lessThan, "expected `<`"), Z.enter(M0.autolink), Z.enter(M0.autolinkMarker), Z.consume(F), Z.exit(M0.autolinkMarker), Z.enter(M0.autolinkProtocol), Q;
  }
  function Q(F) {
    if (nX(F))
      return Z.consume(F), W;
    if (F === K0.atSign)
      return $(F);
    return H(F);
  }
  function W(F) {
    if (F === K0.plusSign || F === K0.dash || F === K0.dot || B$(F))
      return X = 1, K(F);
    return H(F);
  }
  function K(F) {
    if (F === K0.colon)
      return Z.consume(F), X = 0, G;
    if ((F === K0.plusSign || F === K0.dash || F === K0.dot || B$(F)) && X++ < M2.autolinkSchemeSizeMax)
      return Z.consume(F), K;
    return X = 0, H(F);
  }
  function G(F) {
    if (F === K0.greaterThan)
      return Z.exit(M0.autolinkProtocol), Z.enter(M0.autolinkMarker), Z.consume(F), Z.exit(M0.autolinkMarker), Z.exit(M0.autolink), J;
    if (F === K0.eof || F === K0.space || F === K0.lessThan || Z4(F))
      return $(F);
    return Z.consume(F), G;
  }
  function H(F) {
    if (F === K0.atSign)
      return Z.consume(F), N;
    if (KP0(F))
      return Z.consume(F), H;
    return $(F);
  }
  function N(F) {
    return B$(F) ? q(F) : $(F);
  }
  function q(F) {
    if (F === K0.dot)
      return Z.consume(F), X = 0, N;
    if (F === K0.greaterThan)
      return Z.exit(M0.autolinkProtocol).type = M0.autolinkEmail, Z.enter(M0.autolinkMarker), Z.consume(F), Z.exit(M0.autolinkMarker), Z.exit(M0.autolink), J;
    return U(F);
  }
  function U(F) {
    if ((F === K0.dash || B$(F)) && X++ < M2.autolinkDomainSizeMax) {
      let E = F === K0.dash ? U : q;
      return Z.consume(F), E;
    }
    return $(F);
  }
}
// node_modules/micromark-core-commonmark/dev/lib/blank-line.js
var Cq = { tokenize: $41, partial: !0 };
function $41(Z, J, $) {
  return X;
  function X(Q) {
    return F6(Q) ? U6(Z, Y, M0.linePrefix)(Q) : Y(Q);
  }
  function Y(Q) {
    return Q === K0.eof || n2(Q) ? J(Q) : $(Q);
  }
}
// node_modules/micromark-core-commonmark/dev/lib/block-quote.js
var fy = {
  name: "blockQuote",
  tokenize: X41,
  continuation: { tokenize: Y41 },
  exit: Q41
};
function X41(Z, J, $) {
  let X = this;
  return Y;
  function Y(W) {
    if (W === K0.greaterThan) {
      let K = X.containerState;
      if (t0(K, "expected `containerState` to be defined in container"), !K.open)
        Z.enter(M0.blockQuote, { _container: !0 }), K.open = !0;
      return Z.enter(M0.blockQuotePrefix), Z.enter(M0.blockQuoteMarker), Z.consume(W), Z.exit(M0.blockQuoteMarker), Q;
    }
    return $(W);
  }
  function Q(W) {
    if (F6(W))
      return Z.enter(M0.blockQuotePrefixWhitespace), Z.consume(W), Z.exit(M0.blockQuotePrefixWhitespace), Z.exit(M0.blockQuotePrefix), J;
    return Z.exit(M0.blockQuotePrefix), J(W);
  }
}
function Y41(Z, J, $) {
  let X = this;
  return Y;
  function Y(W) {
    if (F6(W))
      return t0(X.parser.constructs.disable.null, "expected `disable.null` to be populated"), U6(Z, Q, M0.linePrefix, X.parser.constructs.disable.null.includes("codeIndented") ? void 0 : M2.tabSize)(W);
    return Q(W);
  }
  function Q(W) {
    return Z.attempt(fy, J, $)(W);
  }
}
function Q41(Z) {
  Z.exit(M0.blockQuote);
}
// node_modules/micromark-core-commonmark/dev/lib/character-escape.js
var hy = {
  name: "characterEscape",
  tokenize: W41
};
function W41(Z, J, $) {
  return X;
  function X(Q) {
    return t0(Q === K0.backslash, "expected `\\`"), Z.enter(M0.characterEscape), Z.enter(M0.escapeMarker), Z.consume(Q), Z.exit(M0.escapeMarker), Y;
  }
  function Y(Q) {
    if (HP0(Q))
      return Z.enter(M0.characterEscapeValue), Z.consume(Q), Z.exit(M0.characterEscapeValue), Z.exit(M0.characterEscape), J;
    return $(Q);
  }
}
// node_modules/micromark-core-commonmark/dev/lib/character-reference.js
var by = {
  name: "characterReference",
  tokenize: K41
};
function K41(Z, J, $) {
  let X = this, Y = 0, Q, W;
  return K;
  function K(q) {
    return t0(q === K0.ampersand, "expected `&`"), Z.enter(M0.characterReference), Z.enter(M0.characterReferenceMarker), Z.consume(q), Z.exit(M0.characterReferenceMarker), G;
  }
  function G(q) {
    if (q === K0.numberSign)
      return Z.enter(M0.characterReferenceMarkerNumeric), Z.consume(q), Z.exit(M0.characterReferenceMarkerNumeric), H;
    return Z.enter(M0.characterReferenceValue), Q = M2.characterReferenceNamedSizeMax, W = B$, N(q);
  }
  function H(q) {
    if (q === K0.uppercaseX || q === K0.lowercaseX)
      return Z.enter(M0.characterReferenceMarkerHexadecimal), Z.consume(q), Z.exit(M0.characterReferenceMarkerHexadecimal), Z.enter(M0.characterReferenceValue), Q = M2.characterReferenceHexadecimalSizeMax, W = GP0, N;
    return Z.enter(M0.characterReferenceValue), Q = M2.characterReferenceDecimalSizeMax, W = uI, N(q);
  }
  function N(q) {
    if (q === K0.semicolon && Y) {
      let U = Z.exit(M0.characterReferenceValue);
      if (W === B$ && !TB(X.sliceSerialize(U)))
        return $(q);
      return Z.enter(M0.characterReferenceMarker), Z.consume(q), Z.exit(M0.characterReferenceMarker), Z.exit(M0.characterReference), J;
    }
    if (W(q) && Y++ < Q)
      return Z.consume(q), N;
    return $(q);
  }
}
// node_modules/micromark-core-commonmark/dev/lib/code-fenced.js
var LP0 = {
  tokenize: H41,
  partial: !0
}, xy = {
  name: "codeFenced",
  tokenize: G41,
  concrete: !0
};
function G41(Z, J, $) {
  let X = this, Y = { tokenize: w, partial: !0 }, Q = 0, W = 0, K;
  return G;
  function G(V) {
    return H(V);
  }
  function H(V) {
    t0(V === K0.graveAccent || V === K0.tilde, "expected `` ` `` or `~`");
    let P = X.events[X.events.length - 1];
    return Q = P && P[1].type === M0.linePrefix ? P[2].sliceSerialize(P[1], !0).length : 0, K = V, Z.enter(M0.codeFenced), Z.enter(M0.codeFencedFence), Z.enter(M0.codeFencedFenceSequence), N(V);
  }
  function N(V) {
    if (V === K)
      return W++, Z.consume(V), N;
    if (W < M2.codeFencedSequenceSizeMin)
      return $(V);
    return Z.exit(M0.codeFencedFenceSequence), F6(V) ? U6(Z, q, M0.whitespace)(V) : q(V);
  }
  function q(V) {
    if (V === K0.eof || n2(V))
      return Z.exit(M0.codeFencedFence), X.interrupt ? J(V) : Z.check(LP0, R, T)(V);
    return Z.enter(M0.codeFencedFenceInfo), Z.enter(M0.chunkString, { contentType: M2.contentTypeString }), U(V);
  }
  function U(V) {
    if (V === K0.eof || n2(V))
      return Z.exit(M0.chunkString), Z.exit(M0.codeFencedFenceInfo), q(V);
    if (F6(V))
      return Z.exit(M0.chunkString), Z.exit(M0.codeFencedFenceInfo), U6(Z, F, M0.whitespace)(V);
    if (V === K0.graveAccent && V === K)
      return $(V);
    return Z.consume(V), U;
  }
  function F(V) {
    if (V === K0.eof || n2(V))
      return q(V);
    return Z.enter(M0.codeFencedFenceMeta), Z.enter(M0.chunkString, { contentType: M2.contentTypeString }), E(V);
  }
  function E(V) {
    if (V === K0.eof || n2(V))
      return Z.exit(M0.chunkString), Z.exit(M0.codeFencedFenceMeta), q(V);
    if (V === K0.graveAccent && V === K)
      return $(V);
    return Z.consume(V), E;
  }
  function R(V) {
    return t0(n2(V), "expected eol"), Z.attempt(Y, T, z)(V);
  }
  function z(V) {
    return t0(n2(V), "expected eol"), Z.enter(M0.lineEnding), Z.consume(V), Z.exit(M0.lineEnding), D;
  }
  function D(V) {
    return Q > 0 && F6(V) ? U6(Z, A, M0.linePrefix, Q + 1)(V) : A(V);
  }
  function A(V) {
    if (V === K0.eof || n2(V))
      return Z.check(LP0, R, T)(V);
    return Z.enter(M0.codeFlowValue), B(V);
  }
  function B(V) {
    if (V === K0.eof || n2(V))
      return Z.exit(M0.codeFlowValue), A(V);
    return Z.consume(V), B;
  }
  function T(V) {
    return Z.exit(M0.codeFenced), J(V);
  }
  function w(V, P, I) {
    let S = 0;
    return f;
    function f(g) {
      return t0(n2(g), "expected eol"), V.enter(M0.lineEnding), V.consume(g), V.exit(M0.lineEnding), v;
    }
    function v(g) {
      return t0(X.parser.constructs.disable.null, "expected `disable.null` to be populated"), V.enter(M0.codeFencedFence), F6(g) ? U6(V, h, M0.linePrefix, X.parser.constructs.disable.null.includes("codeIndented") ? void 0 : M2.tabSize)(g) : h(g);
    }
    function h(g) {
      if (g === K)
        return V.enter(M0.codeFencedFenceSequence), x(g);
      return I(g);
    }
    function x(g) {
      if (g === K)
        return S++, V.consume(g), x;
      if (S >= W)
        return V.exit(M0.codeFencedFenceSequence), F6(g) ? U6(V, b, M0.whitespace)(g) : b(g);
      return I(g);
    }
    function b(g) {
      if (g === K0.eof || n2(g))
        return V.exit(M0.codeFencedFence), P(g);
      return I(g);
    }
  }
}
function H41(Z, J, $) {
  let X = this;
  return Y;
  function Y(W) {
    if (W === K0.eof)
      return $(W);
    return t0(n2(W), "expected eol"), Z.enter(M0.lineEnding), Z.consume(W), Z.exit(M0.lineEnding), Q;
  }
  function Q(W) {
    return X.parser.lazy[X.now().line] ? $(W) : J(W);
  }
}
// node_modules/micromark-core-commonmark/dev/lib/code-indented.js
var lI = {
  name: "codeIndented",
  tokenize: q41
}, N41 = { tokenize: F41, partial: !0 };
function q41(Z, J, $) {
  let X = this;
  return Y;
  function Y(H) {
    return t0(F6(H)), Z.enter(M0.codeIndented), U6(Z, Q, M0.linePrefix, M2.tabSize + 1)(H);
  }
  function Q(H) {
    let N = X.events[X.events.length - 1];
    return N && N[1].type === M0.linePrefix && N[2].sliceSerialize(N[1], !0).length >= M2.tabSize ? W(H) : $(H);
  }
  function W(H) {
    if (H === K0.eof)
      return G(H);
    if (n2(H))
      return Z.attempt(N41, W, G)(H);
    return Z.enter(M0.codeFlowValue), K(H);
  }
  function K(H) {
    if (H === K0.eof || n2(H))
      return Z.exit(M0.codeFlowValue), W(H);
    return Z.consume(H), K;
  }
  function G(H) {
    return Z.exit(M0.codeIndented), J(H);
  }
}
function F41(Z, J, $) {
  let X = this;
  return Y;
  function Y(W) {
    if (X.parser.lazy[X.now().line])
      return $(W);
    if (n2(W))
      return Z.enter(M0.lineEnding), Z.consume(W), Z.exit(M0.lineEnding), Y;
    return U6(Z, Q, M0.linePrefix, M2.tabSize + 1)(W);
  }
  function Q(W) {
    let K = X.events[X.events.length - 1];
    return K && K[1].type === M0.linePrefix && K[2].sliceSerialize(K[1], !0).length >= M2.tabSize ? J(W) : n2(W) ? Y(W) : $(W);
  }
}
// node_modules/micromark-core-commonmark/dev/lib/code-text.js
var c10 = {
  name: "codeText",
  tokenize: L41,
  resolve: U41,
  previous: RP0
};
function U41(Z) {
  let J = Z.length - 4, $ = 3, X, Y;
  if ((Z[$][1].type === M0.lineEnding || Z[$][1].type === "space") && (Z[J][1].type === M0.lineEnding || Z[J][1].type === "space")) {
    X = $;
    while (++X < J)
      if (Z[X][1].type === M0.codeTextData) {
        Z[$][1].type = M0.codeTextPadding, Z[J][1].type = M0.codeTextPadding, $ += 2, J -= 2;
        break;
      }
  }
  X = $ - 1, J++;
  while (++X <= J)
    if (Y === void 0) {
      if (X !== J && Z[X][1].type !== M0.lineEnding)
        Y = X;
    } else if (X === J || Z[X][1].type === M0.lineEnding) {
      if (Z[Y][1].type = M0.codeTextData, X !== Y + 2)
        Z[Y][1].end = Z[X - 1][1].end, Z.splice(Y + 2, X - Y - 2), J -= X - Y - 2, X = Y + 2;
      Y = void 0;
    }
  return Z;
}
function RP0(Z) {
  return Z !== K0.graveAccent || this.events[this.events.length - 1][1].type === M0.characterEscape;
}
function L41(Z, J, $) {
  let X = this, Y = 0, Q, W;
  return K;
  function K(U) {
    return t0(U === K0.graveAccent, "expected `` ` ``"), t0(RP0.call(X, X.previous), "expected correct previous"), Z.enter(M0.codeText), Z.enter(M0.codeTextSequence), G(U);
  }
  function G(U) {
    if (U === K0.graveAccent)
      return Z.consume(U), Y++, G;
    return Z.exit(M0.codeTextSequence), H(U);
  }
  function H(U) {
    if (U === K0.eof)
      return $(U);
    if (U === K0.space)
      return Z.enter("space"), Z.consume(U), Z.exit("space"), H;
    if (U === K0.graveAccent)
      return W = Z.enter(M0.codeTextSequence), Q = 0, q(U);
    if (n2(U))
      return Z.enter(M0.lineEnding), Z.consume(U), Z.exit(M0.lineEnding), H;
    return Z.enter(M0.codeTextData), N(U);
  }
  function N(U) {
    if (U === K0.eof || U === K0.space || U === K0.graveAccent || n2(U))
      return Z.exit(M0.codeTextData), H(U);
    return Z.consume(U), N;
  }
  function q(U) {
    if (U === K0.graveAccent)
      return Z.consume(U), Q++, q;
    if (Q === Y)
      return Z.exit(M0.codeTextSequence), Z.exit(M0.codeText), J(U);
    return W.type = M0.codeTextData, N(U);
  }
}
// node_modules/micromark-util-subtokenize/dev/lib/splice-buffer.js
class l10 {
  constructor(Z) {
    this.left = Z ? [...Z] : [], this.right = [];
  }
  get(Z) {
    if (Z < 0 || Z >= this.left.length + this.right.length)
      throw new RangeError("Cannot access index `" + Z + "` in a splice buffer of size `" + (this.left.length + this.right.length) + "`");
    if (Z < this.left.length)
      return this.left[Z];
    return this.right[this.right.length - Z + this.left.length - 1];
  }
  get length() {
    return this.left.length + this.right.length;
  }
  shift() {
    return this.setCursor(0), this.right.pop();
  }
  slice(Z, J) {
    let $ = J === null || J === void 0 ? Number.POSITIVE_INFINITY : J;
    if ($ < this.left.length)
      return this.left.slice(Z, $);
    if (Z > this.left.length)
      return this.right.slice(this.right.length - $ + this.left.length, this.right.length - Z + this.left.length).reverse();
    return this.left.slice(Z).concat(this.right.slice(this.right.length - $ + this.left.length).reverse());
  }
  splice(Z, J, $) {
    let X = J || 0;
    this.setCursor(Math.trunc(Z));
    let Y = this.right.splice(this.right.length - X, Number.POSITIVE_INFINITY);
    if ($)
      nI(this.left, $);
    return Y.reverse();
  }
  pop() {
    return this.setCursor(Number.POSITIVE_INFINITY), this.left.pop();
  }
  push(Z) {
    this.setCursor(Number.POSITIVE_INFINITY), this.left.push(Z);
  }
  pushMany(Z) {
    this.setCursor(Number.POSITIVE_INFINITY), nI(this.left, Z);
  }
  unshift(Z) {
    this.setCursor(0), this.right.push(Z);
  }
  unshiftMany(Z) {
    this.setCursor(0), nI(this.right, Z.reverse());
  }
  setCursor(Z) {
    if (Z === this.left.length || Z > this.left.length && this.right.length === 0 || Z < 0 && this.left.length === 0)
      return;
    if (Z < this.left.length) {
      let J = this.left.splice(Z, Number.POSITIVE_INFINITY);
      nI(this.right, J.reverse());
    } else {
      let J = this.right.splice(this.left.length + this.right.length - Z, Number.POSITIVE_INFINITY);
      nI(this.left, J.reverse());
    }
  }
}
function nI(Z, J) {
  let $ = 0;
  if (J.length < M2.v8MaxSafeChunkSize)
    Z.push(...J);
  else
    while ($ < J.length)
      Z.push(...J.slice($, $ + M2.v8MaxSafeChunkSize)), $ += M2.v8MaxSafeChunkSize;
}

// node_modules/micromark-util-subtokenize/dev/index.js
function yy(Z) {
  let J = {}, $ = -1, X, Y, Q, W, K, G, H, N = new l10(Z);
  while (++$ < N.length) {
    while ($ in J)
      $ = J[$];
    if (X = N.get($), $ && X[1].type === M0.chunkFlow && N.get($ - 1)[1].type === M0.listItemPrefix) {
      if (t0(X[1]._tokenizer, "expected `_tokenizer` on subtokens"), G = X[1]._tokenizer.events, Q = 0, Q < G.length && G[Q][1].type === M0.lineEndingBlank)
        Q += 2;
      if (Q < G.length && G[Q][1].type === M0.content)
        while (++Q < G.length) {
          if (G[Q][1].type === M0.content)
            break;
          if (G[Q][1].type === M0.chunkText)
            G[Q][1]._isInFirstContentOfListItem = !0, Q++;
        }
    }
    if (X[0] === "enter") {
      if (X[1].contentType)
        Object.assign(J, R41(N, $)), $ = J[$], H = !0;
    } else if (X[1]._container) {
      Q = $, Y = void 0;
      while (Q--)
        if (W = N.get(Q), W[1].type === M0.lineEnding || W[1].type === M0.lineEndingBlank) {
          if (W[0] === "enter") {
            if (Y)
              N.get(Y)[1].type = M0.lineEndingBlank;
            W[1].type = M0.lineEnding, Y = Q;
          }
        } else
          break;
      if (Y)
        X[1].end = Object.assign({}, N.get(Y)[1].start), K = N.slice(Y, $), K.unshift(X), N.splice(Y, $ - Y + 1, K);
    }
  }
  return NX(Z, 0, Number.POSITIVE_INFINITY, N.slice(0)), !H;
}
function R41(Z, J) {
  let $ = Z.get(J)[1], X = Z.get(J)[2], Y = J - 1, Q = [];
  t0($.contentType, "expected `contentType` on subtokens");
  let W = $._tokenizer || X.parser[$.contentType]($.start), K = W.events, G = [], H = {}, N, q, U = -1, F = $, E = 0, R = 0, z = [R];
  while (F) {
    while (Z.get(++Y)[1] !== F)
      ;
    if (t0(!q || F.previous === q, "expected previous to match"), t0(!q || q.next === F, "expected next to match"), Q.push(Y), !F._tokenizer) {
      if (N = X.sliceStream(F), !F.next)
        N.push(K0.eof);
      if (q)
        W.defineSkip(F.start);
      if (F._isInFirstContentOfListItem)
        W._gfmTasklistFirstContentOfListItem = !0;
      if (W.write(N), F._isInFirstContentOfListItem)
        W._gfmTasklistFirstContentOfListItem = void 0;
    }
    q = F, F = F.next;
  }
  F = $;
  while (++U < K.length)
    if (K[U][0] === "exit" && K[U - 1][0] === "enter" && K[U][1].type === K[U - 1][1].type && K[U][1].start.line !== K[U][1].end.line)
      t0(F, "expected a current token"), R = U + 1, z.push(R), F._tokenizer = void 0, F.previous = void 0, F = F.next;
  if (W.events = [], F)
    F._tokenizer = void 0, F.previous = void 0, t0(!F.next, "expected no next token");
  else
    z.pop();
  U = z.length;
  while (U--) {
    let D = K.slice(z[U], z[U + 1]), A = Q.pop();
    t0(A !== void 0, "expected a start position when splicing"), G.push([A, A + D.length - 1]), Z.splice(A, 2, D);
  }
  G.reverse(), U = -1;
  while (++U < G.length)
    H[E + G[U][0]] = E + G[U][1], E += G[U][1] - G[U][0] - 1;
  return H;
}

// node_modules/micromark-core-commonmark/dev/lib/content.js
var n10 = { tokenize: z41, resolve: O41 }, E41 = { tokenize: D41, partial: !0 };
function O41(Z) {
  return yy(Z), Z;
}
function z41(Z, J) {
  let $;
  return X;
  function X(K) {
    return t0(K !== K0.eof && !n2(K), "expected no eof or eol"), Z.enter(M0.content), $ = Z.enter(M0.chunkContent, {
      contentType: M2.contentTypeContent
    }), Y(K);
  }
  function Y(K) {
    if (K === K0.eof)
      return Q(K);
    if (n2(K))
      return Z.check(E41, W, Q)(K);
    return Z.consume(K), Y;
  }
  function Q(K) {
    return Z.exit(M0.chunkContent), Z.exit(M0.content), J(K);
  }
  function W(K) {
    return t0(n2(K), "expected eol"), Z.consume(K), Z.exit(M0.chunkContent), t0($, "expected previous token"), $.next = Z.enter(M0.chunkContent, {
      contentType: M2.contentTypeContent,
      previous: $
    }), $ = $.next, Y;
  }
}
function D41(Z, J, $) {
  let X = this;
  return Y;
  function Y(W) {
    return t0(n2(W), "expected a line ending"), Z.exit(M0.chunkContent), Z.enter(M0.lineEnding), Z.consume(W), Z.exit(M0.lineEnding), U6(Z, Q, M0.linePrefix);
  }
  function Q(W) {
    if (W === K0.eof || n2(W))
      return $(W);
    t0(X.parser.constructs.disable.null, "expected `disable.null` to be populated");
    let K = X.events[X.events.length - 1];
    if (!X.parser.constructs.disable.null.includes("codeIndented") && K && K[1].type === M0.linePrefix && K[2].sliceSerialize(K[1], !0).length >= M2.tabSize)
      return J(W);
    return Z.interrupt(X.parser.constructs.flow, $, J)(W);
  }
}
// node_modules/micromark-factory-destination/dev/index.js
function gy(Z, J, $, X, Y, Q, W, K, G) {
  let H = G || Number.POSITIVE_INFINITY, N = 0;
  return q;
  function q(D) {
    if (D === K0.lessThan)
      return Z.enter(X), Z.enter(Y), Z.enter(Q), Z.consume(D), Z.exit(Q), U;
    if (D === K0.eof || D === K0.space || D === K0.rightParenthesis || Z4(D))
      return $(D);
    return Z.enter(X), Z.enter(W), Z.enter(K), Z.enter(M0.chunkString, { contentType: M2.contentTypeString }), R(D);
  }
  function U(D) {
    if (D === K0.greaterThan)
      return Z.enter(Q), Z.consume(D), Z.exit(Q), Z.exit(Y), Z.exit(X), J;
    return Z.enter(K), Z.enter(M0.chunkString, { contentType: M2.contentTypeString }), F(D);
  }
  function F(D) {
    if (D === K0.greaterThan)
      return Z.exit(M0.chunkString), Z.exit(K), U(D);
    if (D === K0.eof || D === K0.lessThan || n2(D))
      return $(D);
    return Z.consume(D), D === K0.backslash ? E : F;
  }
  function E(D) {
    if (D === K0.lessThan || D === K0.greaterThan || D === K0.backslash)
      return Z.consume(D), F;
    return F(D);
  }
  function R(D) {
    if (!N && (D === K0.eof || D === K0.rightParenthesis || Y9(D)))
      return Z.exit(M0.chunkString), Z.exit(K), Z.exit(W), Z.exit(X), J(D);
    if (N < H && D === K0.leftParenthesis)
      return Z.consume(D), N++, R;
    if (D === K0.rightParenthesis)
      return Z.consume(D), N--, R;
    if (D === K0.eof || D === K0.space || D === K0.leftParenthesis || Z4(D))
      return $(D);
    return Z.consume(D), D === K0.backslash ? z : R;
  }
  function z(D) {
    if (D === K0.leftParenthesis || D === K0.rightParenthesis || D === K0.backslash)
      return Z.consume(D), R;
    return R(D);
  }
}

// node_modules/micromark-factory-label/dev/index.js
function my(Z, J, $, X, Y, Q) {
  let W = this, K = 0, G;
  return H;
  function H(F) {
    return t0(F === K0.leftSquareBracket, "expected `[`"), Z.enter(X), Z.enter(Y), Z.consume(F), Z.exit(Y), Z.enter(Q), N;
  }
  function N(F) {
    if (K > M2.linkReferenceSizeMax || F === K0.eof || F === K0.leftSquareBracket || F === K0.rightSquareBracket && !G || F === K0.caret && !K && "_hiddenFootnoteSupport" in W.parser.constructs)
      return $(F);
    if (F === K0.rightSquareBracket)
      return Z.exit(Q), Z.enter(Y), Z.consume(F), Z.exit(Y), Z.exit(X), J;
    if (n2(F))
      return Z.enter(M0.lineEnding), Z.consume(F), Z.exit(M0.lineEnding), N;
    return Z.enter(M0.chunkString, { contentType: M2.contentTypeString }), q(F);
  }
  function q(F) {
    if (F === K0.eof || F === K0.leftSquareBracket || F === K0.rightSquareBracket || n2(F) || K++ > M2.linkReferenceSizeMax)
      return Z.exit(M0.chunkString), N(F);
    if (Z.consume(F), !G)
      G = !F6(F);
    return F === K0.backslash ? U : q;
  }
  function U(F) {
    if (F === K0.leftSquareBracket || F === K0.backslash || F === K0.rightSquareBracket)
      return Z.consume(F), K++, q;
    return q(F);
  }
}

// node_modules/micromark-factory-title/dev/index.js
function dy(Z, J, $, X, Y, Q) {
  let W;
  return K;
  function K(U) {
    if (U === K0.quotationMark || U === K0.apostrophe || U === K0.leftParenthesis)
      return Z.enter(X), Z.enter(Y), Z.consume(U), Z.exit(Y), W = U === K0.leftParenthesis ? K0.rightParenthesis : U, G;
    return $(U);
  }
  function G(U) {
    if (U === W)
      return Z.enter(Y), Z.consume(U), Z.exit(Y), Z.exit(X), J;
    return Z.enter(Q), H(U);
  }
  function H(U) {
    if (U === W)
      return Z.exit(Q), G(W);
    if (U === K0.eof)
      return $(U);
    if (n2(U))
      return Z.enter(M0.lineEnding), Z.consume(U), Z.exit(M0.lineEnding), U6(Z, H, M0.linePrefix);
    return Z.enter(M0.chunkString, { contentType: M2.contentTypeString }), N(U);
  }
  function N(U) {
    if (U === W || U === K0.eof || n2(U))
      return Z.exit(M0.chunkString), H(U);
    return Z.consume(U), U === K0.backslash ? q : N;
  }
  function q(U) {
    if (U === W || U === K0.backslash)
      return Z.consume(U), N;
    return N(U);
  }
}

// node_modules/micromark-factory-whitespace/dev/index.js
function $4(Z, J) {
  let $;
  return X;
  function X(Y) {
    if (n2(Y))
      return Z.enter(M0.lineEnding), Z.consume(Y), Z.exit(M0.lineEnding), $ = !0, X;
    if (F6(Y))
      return U6(Z, X, $ ? M0.linePrefix : M0.lineSuffix)(Y);
    return J(Y);
  }
}

// node_modules/micromark-core-commonmark/dev/lib/definition.js
var i10 = { name: "definition", tokenize: A41 }, M41 = { tokenize: B41, partial: !0 };
function A41(Z, J, $) {
  let X = this, Y;
  return Q;
  function Q(F) {
    return Z.enter(M0.definition), W(F);
  }
  function W(F) {
    return t0(F === K0.leftSquareBracket, "expected `[`"), my.call(X, Z, K, $, M0.definitionLabel, M0.definitionLabelMarker, M0.definitionLabelString)(F);
  }
  function K(F) {
    if (Y = YW(X.sliceSerialize(X.events[X.events.length - 1][1]).slice(1, -1)), F === K0.colon)
      return Z.enter(M0.definitionMarker), Z.consume(F), Z.exit(M0.definitionMarker), G;
    return $(F);
  }
  function G(F) {
    return Y9(F) ? $4(Z, H)(F) : H(F);
  }
  function H(F) {
    return gy(Z, N, $, M0.definitionDestination, M0.definitionDestinationLiteral, M0.definitionDestinationLiteralMarker, M0.definitionDestinationRaw, M0.definitionDestinationString)(F);
  }
  function N(F) {
    return Z.attempt(M41, q, q)(F);
  }
  function q(F) {
    return F6(F) ? U6(Z, U, M0.whitespace)(F) : U(F);
  }
  function U(F) {
    if (F === K0.eof || n2(F))
      return Z.exit(M0.definition), X.parser.defined.push(Y), J(F);
    return $(F);
  }
}
function B41(Z, J, $) {
  return X;
  function X(K) {
    return Y9(K) ? $4(Z, Y)(K) : $(K);
  }
  function Y(K) {
    return dy(Z, Q, $, M0.definitionTitle, M0.definitionTitleMarker, M0.definitionTitleString)(K);
  }
  function Q(K) {
    return F6(K) ? U6(Z, W, M0.whitespace)(K) : W(K);
  }
  function W(K) {
    return K === K0.eof || n2(K) ? J(K) : $(K);
  }
}
// node_modules/micromark-core-commonmark/dev/lib/hard-break-escape.js
var o10 = {
  name: "hardBreakEscape",
  tokenize: w41
};
function w41(Z, J, $) {
  return X;
  function X(Q) {
    return t0(Q === K0.backslash, "expected `\\`"), Z.enter(M0.hardBreakEscape), Z.consume(Q), Y;
  }
  function Y(Q) {
    if (n2(Q))
      return Z.exit(M0.hardBreakEscape), J(Q);
    return $(Q);
  }
}
// node_modules/micromark-core-commonmark/dev/lib/heading-atx.js
var s10 = {
  name: "headingAtx",
  tokenize: T41,
  resolve: j41
};
function j41(Z, J) {
  let $ = Z.length - 2, X = 3, Y, Q;
  if (Z[X][1].type === M0.whitespace)
    X += 2;
  if ($ - 2 > X && Z[$][1].type === M0.whitespace)
    $ -= 2;
  if (Z[$][1].type === M0.atxHeadingSequence && (X === $ - 1 || $ - 4 > X && Z[$ - 2][1].type === M0.whitespace))
    $ -= X + 1 === $ ? 2 : 4;
  if ($ > X)
    Y = {
      type: M0.atxHeadingText,
      start: Z[X][1].start,
      end: Z[$][1].end
    }, Q = {
      type: M0.chunkText,
      start: Z[X][1].start,
      end: Z[$][1].end,
      contentType: M2.contentTypeText
    }, NX(Z, X, $ - X + 1, [
      ["enter", Y, J],
      ["enter", Q, J],
      ["exit", Q, J],
      ["exit", Y, J]
    ]);
  return Z;
}
function T41(Z, J, $) {
  let X = 0;
  return Y;
  function Y(N) {
    return Z.enter(M0.atxHeading), Q(N);
  }
  function Q(N) {
    return t0(N === K0.numberSign, "expected `#`"), Z.enter(M0.atxHeadingSequence), W(N);
  }
  function W(N) {
    if (N === K0.numberSign && X++ < M2.atxHeadingOpeningFenceSizeMax)
      return Z.consume(N), W;
    if (N === K0.eof || Y9(N))
      return Z.exit(M0.atxHeadingSequence), K(N);
    return $(N);
  }
  function K(N) {
    if (N === K0.numberSign)
      return Z.enter(M0.atxHeadingSequence), G(N);
    if (N === K0.eof || n2(N))
      return Z.exit(M0.atxHeading), J(N);
    if (F6(N))
      return U6(Z, K, M0.whitespace)(N);
    return Z.enter(M0.atxHeadingText), H(N);
  }
  function G(N) {
    if (N === K0.numberSign)
      return Z.consume(N), G;
    return Z.exit(M0.atxHeadingSequence), K(N);
  }
  function H(N) {
    if (N === K0.eof || N === K0.numberSign || Y9(N))
      return Z.exit(M0.atxHeadingText), K(N);
    return Z.consume(N), H;
  }
}
// node_modules/micromark-util-html-tag-name/index.js
var EP0 = [
  "address",
  "article",
  "aside",
  "base",
  "basefont",
  "blockquote",
  "body",
  "caption",
  "center",
  "col",
  "colgroup",
  "dd",
  "details",
  "dialog",
  "dir",
  "div",
  "dl",
  "dt",
  "fieldset",
  "figcaption",
  "figure",
  "footer",
  "form",
  "frame",
  "frameset",
  "h1",
  "h2",
  "h3",
  "h4",
  "h5",
  "h6",
  "head",
  "header",
  "hr",
  "html",
  "iframe",
  "legend",
  "li",
  "link",
  "main",
  "menu",
  "menuitem",
  "nav",
  "noframes",
  "ol",
  "optgroup",
  "option",
  "p",
  "param",
  "search",
  "section",
  "summary",
  "table",
  "tbody",
  "td",
  "tfoot",
  "th",
  "thead",
  "title",
  "tr",
  "track",
  "ul"
], a10 = ["pre", "script", "style", "textarea"];

// node_modules/micromark-core-commonmark/dev/lib/html-flow.js
var r10 = {
  name: "htmlFlow",
  tokenize: P41,
  resolveTo: I41,
  concrete: !0
}, _41 = { tokenize: k41, partial: !0 }, V41 = {
  tokenize: C41,
  partial: !0
};
function I41(Z) {
  let J = Z.length;
  while (J--)
    if (Z[J][0] === "enter" && Z[J][1].type === M0.htmlFlow)
      break;
  if (J > 1 && Z[J - 2][1].type === M0.linePrefix)
    Z[J][1].start = Z[J - 2][1].start, Z[J + 1][1].start = Z[J - 2][1].start, Z.splice(J - 2, 2);
  return Z;
}
function P41(Z, J, $) {
  let X = this, Y, Q, W, K, G;
  return H;
  function H(u) {
    return N(u);
  }
  function N(u) {
    return t0(u === K0.lessThan, "expected `<`"), Z.enter(M0.htmlFlow), Z.enter(M0.htmlFlowData), Z.consume(u), q;
  }
  function q(u) {
    if (u === K0.exclamationMark)
      return Z.consume(u), U;
    if (u === K0.slash)
      return Z.consume(u), Q = !0, R;
    if (u === K0.questionMark)
      return Z.consume(u), Y = M2.htmlInstruction, X.interrupt ? J : c;
    if (nX(u))
      return Z.consume(u), W = String.fromCharCode(u), z;
    return $(u);
  }
  function U(u) {
    if (u === K0.dash)
      return Z.consume(u), Y = M2.htmlComment, F;
    if (u === K0.leftSquareBracket)
      return Z.consume(u), Y = M2.htmlCdata, K = 0, E;
    if (nX(u))
      return Z.consume(u), Y = M2.htmlDeclaration, X.interrupt ? J : c;
    return $(u);
  }
  function F(u) {
    if (u === K0.dash)
      return Z.consume(u), X.interrupt ? J : c;
    return $(u);
  }
  function E(u) {
    let G0 = M2.cdataOpeningString;
    if (u === G0.charCodeAt(K++)) {
      if (Z.consume(u), K === G0.length)
        return X.interrupt ? J : h;
      return E;
    }
    return $(u);
  }
  function R(u) {
    if (nX(u))
      return Z.consume(u), W = String.fromCharCode(u), z;
    return $(u);
  }
  function z(u) {
    if (u === K0.eof || u === K0.slash || u === K0.greaterThan || Y9(u)) {
      let G0 = u === K0.slash, F0 = W.toLowerCase();
      if (!G0 && !Q && a10.includes(F0))
        return Y = M2.htmlRaw, X.interrupt ? J(u) : h(u);
      if (EP0.includes(W.toLowerCase())) {
        if (Y = M2.htmlBasic, G0)
          return Z.consume(u), D;
        return X.interrupt ? J(u) : h(u);
      }
      return Y = M2.htmlComplete, X.interrupt && !X.parser.lazy[X.now().line] ? $(u) : Q ? A(u) : B(u);
    }
    if (u === K0.dash || B$(u))
      return Z.consume(u), W += String.fromCharCode(u), z;
    return $(u);
  }
  function D(u) {
    if (u === K0.greaterThan)
      return Z.consume(u), X.interrupt ? J : h;
    return $(u);
  }
  function A(u) {
    if (F6(u))
      return Z.consume(u), A;
    return f(u);
  }
  function B(u) {
    if (u === K0.slash)
      return Z.consume(u), f;
    if (u === K0.colon || u === K0.underscore || nX(u))
      return Z.consume(u), T;
    if (F6(u))
      return Z.consume(u), B;
    return f(u);
  }
  function T(u) {
    if (u === K0.dash || u === K0.dot || u === K0.colon || u === K0.underscore || B$(u))
      return Z.consume(u), T;
    return w(u);
  }
  function w(u) {
    if (u === K0.equalsTo)
      return Z.consume(u), V;
    if (F6(u))
      return Z.consume(u), w;
    return B(u);
  }
  function V(u) {
    if (u === K0.eof || u === K0.lessThan || u === K0.equalsTo || u === K0.greaterThan || u === K0.graveAccent)
      return $(u);
    if (u === K0.quotationMark || u === K0.apostrophe)
      return Z.consume(u), G = u, P;
    if (F6(u))
      return Z.consume(u), V;
    return I(u);
  }
  function P(u) {
    if (u === G)
      return Z.consume(u), G = null, S;
    if (u === K0.eof || n2(u))
      return $(u);
    return Z.consume(u), P;
  }
  function I(u) {
    if (u === K0.eof || u === K0.quotationMark || u === K0.apostrophe || u === K0.slash || u === K0.lessThan || u === K0.equalsTo || u === K0.greaterThan || u === K0.graveAccent || Y9(u))
      return w(u);
    return Z.consume(u), I;
  }
  function S(u) {
    if (u === K0.slash || u === K0.greaterThan || F6(u))
      return B(u);
    return $(u);
  }
  function f(u) {
    if (u === K0.greaterThan)
      return Z.consume(u), v;
    return $(u);
  }
  function v(u) {
    if (u === K0.eof || n2(u))
      return h(u);
    if (F6(u))
      return Z.consume(u), v;
    return $(u);
  }
  function h(u) {
    if (u === K0.dash && Y === M2.htmlComment)
      return Z.consume(u), m;
    if (u === K0.lessThan && Y === M2.htmlRaw)
      return Z.consume(u), i;
    if (u === K0.greaterThan && Y === M2.htmlDeclaration)
      return Z.consume(u), n;
    if (u === K0.questionMark && Y === M2.htmlInstruction)
      return Z.consume(u), c;
    if (u === K0.rightSquareBracket && Y === M2.htmlCdata)
      return Z.consume(u), Y0;
    if (n2(u) && (Y === M2.htmlBasic || Y === M2.htmlComplete))
      return Z.exit(M0.htmlFlowData), Z.check(_41, l, x)(u);
    if (u === K0.eof || n2(u))
      return Z.exit(M0.htmlFlowData), x(u);
    return Z.consume(u), h;
  }
  function x(u) {
    return Z.check(V41, b, l)(u);
  }
  function b(u) {
    return t0(n2(u)), Z.enter(M0.lineEnding), Z.consume(u), Z.exit(M0.lineEnding), g;
  }
  function g(u) {
    if (u === K0.eof || n2(u))
      return x(u);
    return Z.enter(M0.htmlFlowData), h(u);
  }
  function m(u) {
    if (u === K0.dash)
      return Z.consume(u), c;
    return h(u);
  }
  function i(u) {
    if (u === K0.slash)
      return Z.consume(u), W = "", r;
    return h(u);
  }
  function r(u) {
    if (u === K0.greaterThan) {
      let G0 = W.toLowerCase();
      if (a10.includes(G0))
        return Z.consume(u), n;
      return h(u);
    }
    if (nX(u) && W.length < M2.htmlRawSizeMax)
      return Z.consume(u), W += String.fromCharCode(u), r;
    return h(u);
  }
  function Y0(u) {
    if (u === K0.rightSquareBracket)
      return Z.consume(u), c;
    return h(u);
  }
  function c(u) {
    if (u === K0.greaterThan)
      return Z.consume(u), n;
    if (u === K0.dash && Y === M2.htmlComment)
      return Z.consume(u), c;
    return h(u);
  }
  function n(u) {
    if (u === K0.eof || n2(u))
      return Z.exit(M0.htmlFlowData), l(u);
    return Z.consume(u), n;
  }
  function l(u) {
    return Z.exit(M0.htmlFlow), J(u);
  }
}
function C41(Z, J, $) {
  let X = this;
  return Y;
  function Y(W) {
    if (n2(W))
      return Z.enter(M0.lineEnding), Z.consume(W), Z.exit(M0.lineEnding), Q;
    return $(W);
  }
  function Q(W) {
    return X.parser.lazy[X.now().line] ? $(W) : J(W);
  }
}
function k41(Z, J, $) {
  return X;
  function X(Y) {
    return t0(n2(Y), "expected a line ending"), Z.enter(M0.lineEnding), Z.consume(Y), Z.exit(M0.lineEnding), Z.attempt(Cq, J, $);
  }
}
// node_modules/micromark-core-commonmark/dev/lib/html-text.js
var t10 = { name: "htmlText", tokenize: v41 };
function v41(Z, J, $) {
  let X = this, Y, Q, W;
  return K;
  function K(c) {
    return t0(c === K0.lessThan, "expected `<`"), Z.enter(M0.htmlText), Z.enter(M0.htmlTextData), Z.consume(c), G;
  }
  function G(c) {
    if (c === K0.exclamationMark)
      return Z.consume(c), H;
    if (c === K0.slash)
      return Z.consume(c), w;
    if (c === K0.questionMark)
      return Z.consume(c), B;
    if (nX(c))
      return Z.consume(c), I;
    return $(c);
  }
  function H(c) {
    if (c === K0.dash)
      return Z.consume(c), N;
    if (c === K0.leftSquareBracket)
      return Z.consume(c), Q = 0, E;
    if (nX(c))
      return Z.consume(c), A;
    return $(c);
  }
  function N(c) {
    if (c === K0.dash)
      return Z.consume(c), F;
    return $(c);
  }
  function q(c) {
    if (c === K0.eof)
      return $(c);
    if (c === K0.dash)
      return Z.consume(c), U;
    if (n2(c))
      return W = q, i(c);
    return Z.consume(c), q;
  }
  function U(c) {
    if (c === K0.dash)
      return Z.consume(c), F;
    return q(c);
  }
  function F(c) {
    return c === K0.greaterThan ? m(c) : c === K0.dash ? U(c) : q(c);
  }
  function E(c) {
    let n = M2.cdataOpeningString;
    if (c === n.charCodeAt(Q++))
      return Z.consume(c), Q === n.length ? R : E;
    return $(c);
  }
  function R(c) {
    if (c === K0.eof)
      return $(c);
    if (c === K0.rightSquareBracket)
      return Z.consume(c), z;
    if (n2(c))
      return W = R, i(c);
    return Z.consume(c), R;
  }
  function z(c) {
    if (c === K0.rightSquareBracket)
      return Z.consume(c), D;
    return R(c);
  }
  function D(c) {
    if (c === K0.greaterThan)
      return m(c);
    if (c === K0.rightSquareBracket)
      return Z.consume(c), D;
    return R(c);
  }
  function A(c) {
    if (c === K0.eof || c === K0.greaterThan)
      return m(c);
    if (n2(c))
      return W = A, i(c);
    return Z.consume(c), A;
  }
  function B(c) {
    if (c === K0.eof)
      return $(c);
    if (c === K0.questionMark)
      return Z.consume(c), T;
    if (n2(c))
      return W = B, i(c);
    return Z.consume(c), B;
  }
  function T(c) {
    return c === K0.greaterThan ? m(c) : B(c);
  }
  function w(c) {
    if (nX(c))
      return Z.consume(c), V;
    return $(c);
  }
  function V(c) {
    if (c === K0.dash || B$(c))
      return Z.consume(c), V;
    return P(c);
  }
  function P(c) {
    if (n2(c))
      return W = P, i(c);
    if (F6(c))
      return Z.consume(c), P;
    return m(c);
  }
  function I(c) {
    if (c === K0.dash || B$(c))
      return Z.consume(c), I;
    if (c === K0.slash || c === K0.greaterThan || Y9(c))
      return S(c);
    return $(c);
  }
  function S(c) {
    if (c === K0.slash)
      return Z.consume(c), m;
    if (c === K0.colon || c === K0.underscore || nX(c))
      return Z.consume(c), f;
    if (n2(c))
      return W = S, i(c);
    if (F6(c))
      return Z.consume(c), S;
    return m(c);
  }
  function f(c) {
    if (c === K0.dash || c === K0.dot || c === K0.colon || c === K0.underscore || B$(c))
      return Z.consume(c), f;
    return v(c);
  }
  function v(c) {
    if (c === K0.equalsTo)
      return Z.consume(c), h;
    if (n2(c))
      return W = v, i(c);
    if (F6(c))
      return Z.consume(c), v;
    return S(c);
  }
  function h(c) {
    if (c === K0.eof || c === K0.lessThan || c === K0.equalsTo || c === K0.greaterThan || c === K0.graveAccent)
      return $(c);
    if (c === K0.quotationMark || c === K0.apostrophe)
      return Z.consume(c), Y = c, x;
    if (n2(c))
      return W = h, i(c);
    if (F6(c))
      return Z.consume(c), h;
    return Z.consume(c), b;
  }
  function x(c) {
    if (c === Y)
      return Z.consume(c), Y = void 0, g;
    if (c === K0.eof)
      return $(c);
    if (n2(c))
      return W = x, i(c);
    return Z.consume(c), x;
  }
  function b(c) {
    if (c === K0.eof || c === K0.quotationMark || c === K0.apostrophe || c === K0.lessThan || c === K0.equalsTo || c === K0.graveAccent)
      return $(c);
    if (c === K0.slash || c === K0.greaterThan || Y9(c))
      return S(c);
    return Z.consume(c), b;
  }
  function g(c) {
    if (c === K0.slash || c === K0.greaterThan || Y9(c))
      return S(c);
    return $(c);
  }
  function m(c) {
    if (c === K0.greaterThan)
      return Z.consume(c), Z.exit(M0.htmlTextData), Z.exit(M0.htmlText), J;
    return $(c);
  }
  function i(c) {
    return t0(W, "expected return state"), t0(n2(c), "expected eol"), Z.exit(M0.htmlTextData), Z.enter(M0.lineEnding), Z.consume(c), Z.exit(M0.lineEnding), r;
  }
  function r(c) {
    return t0(X.parser.constructs.disable.null, "expected `disable.null` to be populated"), F6(c) ? U6(Z, Y0, M0.linePrefix, X.parser.constructs.disable.null.includes("codeIndented") ? void 0 : M2.tabSize)(c) : Y0(c);
  }
  function Y0(c) {
    return Z.enter(M0.htmlTextData), W(c);
  }
}
// node_modules/micromark-core-commonmark/dev/lib/label-end.js
var X4 = {
  name: "labelEnd",
  tokenize: y41,
  resolveTo: x41,
  resolveAll: b41
}, S41 = { tokenize: g41 }, f41 = { tokenize: m41 }, h41 = { tokenize: d41 };
function b41(Z) {
  let J = -1;
  while (++J < Z.length) {
    let $ = Z[J][1];
    if ($.type === M0.labelImage || $.type === M0.labelLink || $.type === M0.labelEnd)
      Z.splice(J + 1, $.type === M0.labelImage ? 4 : 2), $.type = M0.data, J++;
  }
  return Z;
}
function x41(Z, J) {
  let $ = Z.length, X = 0, Y, Q, W, K;
  while ($--)
    if (Y = Z[$][1], Q) {
      if (Y.type === M0.link || Y.type === M0.labelLink && Y._inactive)
        break;
      if (Z[$][0] === "enter" && Y.type === M0.labelLink)
        Y._inactive = !0;
    } else if (W) {
      if (Z[$][0] === "enter" && (Y.type === M0.labelImage || Y.type === M0.labelLink) && !Y._balanced) {
        if (Q = $, Y.type !== M0.labelLink) {
          X = 2;
          break;
        }
      }
    } else if (Y.type === M0.labelEnd)
      W = $;
  t0(Q !== void 0, "`open` is supposed to be found"), t0(W !== void 0, "`close` is supposed to be found");
  let G = {
    type: Z[Q][1].type === M0.labelLink ? M0.link : M0.image,
    start: Object.assign({}, Z[Q][1].start),
    end: Object.assign({}, Z[Z.length - 1][1].end)
  }, H = {
    type: M0.label,
    start: Object.assign({}, Z[Q][1].start),
    end: Object.assign({}, Z[W][1].end)
  }, N = {
    type: M0.labelText,
    start: Object.assign({}, Z[Q + X + 2][1].end),
    end: Object.assign({}, Z[W - 2][1].start)
  };
  return K = [
    ["enter", G, J],
    ["enter", H, J]
  ], K = iW(K, Z.slice(Q + 1, Q + X + 3)), K = iW(K, [["enter", N, J]]), t0(J.parser.constructs.insideSpan.null, "expected `insideSpan.null` to be populated"), K = iW(K, TE(J.parser.constructs.insideSpan.null, Z.slice(Q + X + 4, W - 3), J)), K = iW(K, [
    ["exit", N, J],
    Z[W - 2],
    Z[W - 1],
    ["exit", H, J]
  ]), K = iW(K, Z.slice(W + 1)), K = iW(K, [["exit", G, J]]), NX(Z, Q, Z.length, K), Z;
}
function y41(Z, J, $) {
  let X = this, Y = X.events.length, Q, W;
  while (Y--)
    if ((X.events[Y][1].type === M0.labelImage || X.events[Y][1].type === M0.labelLink) && !X.events[Y][1]._balanced) {
      Q = X.events[Y][1];
      break;
    }
  return K;
  function K(U) {
    if (t0(U === K0.rightSquareBracket, "expected `]`"), !Q)
      return $(U);
    if (Q._inactive)
      return q(U);
    return W = X.parser.defined.includes(YW(X.sliceSerialize({ start: Q.end, end: X.now() }))), Z.enter(M0.labelEnd), Z.enter(M0.labelMarker), Z.consume(U), Z.exit(M0.labelMarker), Z.exit(M0.labelEnd), G;
  }
  function G(U) {
    if (U === K0.leftParenthesis)
      return Z.attempt(S41, N, W ? N : q)(U);
    if (U === K0.leftSquareBracket)
      return Z.attempt(f41, N, W ? H : q)(U);
    return W ? N(U) : q(U);
  }
  function H(U) {
    return Z.attempt(h41, N, q)(U);
  }
  function N(U) {
    return J(U);
  }
  function q(U) {
    return Q._balanced = !0, $(U);
  }
}
function g41(Z, J, $) {
  return X;
  function X(q) {
    return t0(q === K0.leftParenthesis, "expected left paren"), Z.enter(M0.resource), Z.enter(M0.resourceMarker), Z.consume(q), Z.exit(M0.resourceMarker), Y;
  }
  function Y(q) {
    return Y9(q) ? $4(Z, Q)(q) : Q(q);
  }
  function Q(q) {
    if (q === K0.rightParenthesis)
      return N(q);
    return gy(Z, W, K, M0.resourceDestination, M0.resourceDestinationLiteral, M0.resourceDestinationLiteralMarker, M0.resourceDestinationRaw, M0.resourceDestinationString, M2.linkResourceDestinationBalanceMax)(q);
  }
  function W(q) {
    return Y9(q) ? $4(Z, G)(q) : N(q);
  }
  function K(q) {
    return $(q);
  }
  function G(q) {
    if (q === K0.quotationMark || q === K0.apostrophe || q === K0.leftParenthesis)
      return dy(Z, H, $, M0.resourceTitle, M0.resourceTitleMarker, M0.resourceTitleString)(q);
    return N(q);
  }
  function H(q) {
    return Y9(q) ? $4(Z, N)(q) : N(q);
  }
  function N(q) {
    if (q === K0.rightParenthesis)
      return Z.enter(M0.resourceMarker), Z.consume(q), Z.exit(M0.resourceMarker), Z.exit(M0.resource), J;
    return $(q);
  }
}
function m41(Z, J, $) {
  let X = this;
  return Y;
  function Y(K) {
    return t0(K === K0.leftSquareBracket, "expected left bracket"), my.call(X, Z, Q, W, M0.reference, M0.referenceMarker, M0.referenceString)(K);
  }
  function Q(K) {
    return X.parser.defined.includes(YW(X.sliceSerialize(X.events[X.events.length - 1][1]).slice(1, -1))) ? J(K) : $(K);
  }
  function W(K) {
    return $(K);
  }
}
function d41(Z, J, $) {
  return X;
  function X(Q) {
    return t0(Q === K0.leftSquareBracket, "expected left bracket"), Z.enter(M0.reference), Z.enter(M0.referenceMarker), Z.consume(Q), Z.exit(M0.referenceMarker), Y;
  }
  function Y(Q) {
    if (Q === K0.rightSquareBracket)
      return Z.enter(M0.referenceMarker), Z.consume(Q), Z.exit(M0.referenceMarker), Z.exit(M0.reference), J;
    return $(Q);
  }
}
// node_modules/micromark-core-commonmark/dev/lib/label-start-image.js
var e10 = {
  name: "labelStartImage",
  tokenize: p41,
  resolveAll: X4.resolveAll
};
function p41(Z, J, $) {
  let X = this;
  return Y;
  function Y(K) {
    return t0(K === K0.exclamationMark, "expected `!`"), Z.enter(M0.labelImage), Z.enter(M0.labelImageMarker), Z.consume(K), Z.exit(M0.labelImageMarker), Q;
  }
  function Q(K) {
    if (K === K0.leftSquareBracket)
      return Z.enter(M0.labelMarker), Z.consume(K), Z.exit(M0.labelMarker), Z.exit(M0.labelImage), W;
    return $(K);
  }
  function W(K) {
    return K === K0.caret && "_hiddenFootnoteSupport" in X.parser.constructs ? $(K) : J(K);
  }
}
// node_modules/micromark-core-commonmark/dev/lib/label-start-link.js
var Z20 = {
  name: "labelStartLink",
  tokenize: u41,
  resolveAll: X4.resolveAll
};
function u41(Z, J, $) {
  let X = this;
  return Y;
  function Y(W) {
    return t0(W === K0.leftSquareBracket, "expected `[`"), Z.enter(M0.labelLink), Z.enter(M0.labelMarker), Z.consume(W), Z.exit(M0.labelMarker), Z.exit(M0.labelLink), Q;
  }
  function Q(W) {
    return W === K0.caret && "_hiddenFootnoteSupport" in X.parser.constructs ? $(W) : J(W);
  }
}
// node_modules/micromark-core-commonmark/dev/lib/line-ending.js
var iI = { name: "lineEnding", tokenize: c41 };
function c41(Z, J) {
  return $;
  function $(X) {
    return t0(n2(X), "expected eol"), Z.enter(M0.lineEnding), Z.consume(X), Z.exit(M0.lineEnding), U6(Z, J, M0.linePrefix);
  }
}
// node_modules/micromark-core-commonmark/dev/lib/thematic-break.js
var Y4 = {
  name: "thematicBreak",
  tokenize: l41
};
function l41(Z, J, $) {
  let X = 0, Y;
  return Q;
  function Q(H) {
    return Z.enter(M0.thematicBreak), W(H);
  }
  function W(H) {
    return t0(H === K0.asterisk || H === K0.dash || H === K0.underscore, "expected `*`, `-`, or `_`"), Y = H, K(H);
  }
  function K(H) {
    if (H === Y)
      return Z.enter(M0.thematicBreakSequence), G(H);
    if (X >= M2.thematicBreakMarkerCountMin && (H === K0.eof || n2(H)))
      return Z.exit(M0.thematicBreak), J(H);
    return $(H);
  }
  function G(H) {
    if (H === Y)
      return Z.consume(H), X++, G;
    return Z.exit(M0.thematicBreakSequence), F6(H) ? U6(Z, K, M0.whitespace)(H) : K(H);
  }
}

// node_modules/micromark-core-commonmark/dev/lib/list.js
var QW = {
  name: "list",
  tokenize: o41,
  continuation: { tokenize: s41 },
  exit: r41
}, n41 = {
  tokenize: t41,
  partial: !0
}, i41 = { tokenize: a41, partial: !0 };
function o41(Z, J, $) {
  let X = this, Y = X.events[X.events.length - 1], Q = Y && Y[1].type === M0.linePrefix ? Y[2].sliceSerialize(Y[1], !0).length : 0, W = 0;
  return K;
  function K(F) {
    t0(X.containerState, "expected state");
    let E = X.containerState.type || (F === K0.asterisk || F === K0.plusSign || F === K0.dash ? M0.listUnordered : M0.listOrdered);
    if (E === M0.listUnordered ? !X.containerState.marker || F === X.containerState.marker : uI(F)) {
      if (!X.containerState.type)
        X.containerState.type = E, Z.enter(E, { _container: !0 });
      if (E === M0.listUnordered)
        return Z.enter(M0.listItemPrefix), F === K0.asterisk || F === K0.dash ? Z.check(Y4, $, H)(F) : H(F);
      if (!X.interrupt || F === K0.digit1)
        return Z.enter(M0.listItemPrefix), Z.enter(M0.listItemValue), G(F);
    }
    return $(F);
  }
  function G(F) {
    if (t0(X.containerState, "expected state"), uI(F) && ++W < M2.listItemValueSizeMax)
      return Z.consume(F), G;
    if ((!X.interrupt || W < 2) && (X.containerState.marker ? F === X.containerState.marker : F === K0.rightParenthesis || F === K0.dot))
      return Z.exit(M0.listItemValue), H(F);
    return $(F);
  }
  function H(F) {
    return t0(X.containerState, "expected state"), t0(F !== K0.eof, "eof (`null`) is not a marker"), Z.enter(M0.listItemMarker), Z.consume(F), Z.exit(M0.listItemMarker), X.containerState.marker = X.containerState.marker || F, Z.check(Cq, X.interrupt ? $ : N, Z.attempt(n41, U, q));
  }
  function N(F) {
    return t0(X.containerState, "expected state"), X.containerState.initialBlankLine = !0, Q++, U(F);
  }
  function q(F) {
    if (F6(F))
      return Z.enter(M0.listItemPrefixWhitespace), Z.consume(F), Z.exit(M0.listItemPrefixWhitespace), U;
    return $(F);
  }
  function U(F) {
    return t0(X.containerState, "expected state"), X.containerState.size = Q + X.sliceSerialize(Z.exit(M0.listItemPrefix), !0).length, J(F);
  }
}
function s41(Z, J, $) {
  let X = this;
  return t0(X.containerState, "expected state"), X.containerState._closeFlow = void 0, Z.check(Cq, Y, Q);
  function Y(K) {
    return t0(X.containerState, "expected state"), t0(typeof X.containerState.size === "number", "expected size"), X.containerState.furtherBlankLines = X.containerState.furtherBlankLines || X.containerState.initialBlankLine, U6(Z, J, M0.listItemIndent, X.containerState.size + 1)(K);
  }
  function Q(K) {
    if (t0(X.containerState, "expected state"), X.containerState.furtherBlankLines || !F6(K))
      return X.containerState.furtherBlankLines = void 0, X.containerState.initialBlankLine = void 0, W(K);
    return X.containerState.furtherBlankLines = void 0, X.containerState.initialBlankLine = void 0, Z.attempt(i41, J, W)(K);
  }
  function W(K) {
    return t0(X.containerState, "expected state"), X.containerState._closeFlow = !0, X.interrupt = void 0, t0(X.parser.constructs.disable.null, "expected `disable.null` to be populated"), U6(Z, Z.attempt(QW, J, $), M0.linePrefix, X.parser.constructs.disable.null.includes("codeIndented") ? void 0 : M2.tabSize)(K);
  }
}
function a41(Z, J, $) {
  let X = this;
  return t0(X.containerState, "expected state"), t0(typeof X.containerState.size === "number", "expected size"), U6(Z, Y, M0.listItemIndent, X.containerState.size + 1);
  function Y(Q) {
    t0(X.containerState, "expected state");
    let W = X.events[X.events.length - 1];
    return W && W[1].type === M0.listItemIndent && W[2].sliceSerialize(W[1], !0).length === X.containerState.size ? J(Q) : $(Q);
  }
}
function r41(Z) {
  t0(this.containerState, "expected state"), t0(typeof this.containerState.type === "string", "expected type"), Z.exit(this.containerState.type);
}
function t41(Z, J, $) {
  let X = this;
  return t0(X.parser.constructs.disable.null, "expected `disable.null` to be populated"), U6(Z, Y, M0.listItemPrefixWhitespace, X.parser.constructs.disable.null.includes("codeIndented") ? void 0 : M2.tabSize + 1);
  function Y(Q) {
    let W = X.events[X.events.length - 1];
    return !F6(Q) && W && W[1].type === M0.listItemPrefixWhitespace ? J(Q) : $(Q);
  }
}
// node_modules/micromark-core-commonmark/dev/lib/setext-underline.js
var py = {
  name: "setextUnderline",
  tokenize: ZD1,
  resolveTo: e41
};
function e41(Z, J) {
  let $ = Z.length, X, Y, Q;
  while ($--)
    if (Z[$][0] === "enter") {
      if (Z[$][1].type === M0.content) {
        X = $;
        break;
      }
      if (Z[$][1].type === M0.paragraph)
        Y = $;
    } else {
      if (Z[$][1].type === M0.content)
        Z.splice($, 1);
      if (!Q && Z[$][1].type === M0.definition)
        Q = $;
    }
  t0(Y !== void 0, "expected a `text` index to be found"), t0(X !== void 0, "expected a `text` index to be found");
  let W = {
    type: M0.setextHeading,
    start: Object.assign({}, Z[Y][1].start),
    end: Object.assign({}, Z[Z.length - 1][1].end)
  };
  if (Z[Y][1].type = M0.setextHeadingText, Q)
    Z.splice(Y, 0, ["enter", W, J]), Z.splice(Q + 1, 0, ["exit", Z[X][1], J]), Z[X][1].end = Object.assign({}, Z[Q][1].end);
  else
    Z[X][1] = W;
  return Z.push(["exit", W, J]), Z;
}
function ZD1(Z, J, $) {
  let X = this, Y;
  return Q;
  function Q(H) {
    let N = X.events.length, q;
    t0(H === K0.dash || H === K0.equalsTo, "expected `=` or `-`");
    while (N--)
      if (X.events[N][1].type !== M0.lineEnding && X.events[N][1].type !== M0.linePrefix && X.events[N][1].type !== M0.content) {
        q = X.events[N][1].type === M0.paragraph;
        break;
      }
    if (!X.parser.lazy[X.now().line] && (X.interrupt || q))
      return Z.enter(M0.setextHeadingLine), Y = H, W(H);
    return $(H);
  }
  function W(H) {
    return Z.enter(M0.setextHeadingLineSequence), K(H);
  }
  function K(H) {
    if (H === Y)
      return Z.consume(H), K;
    return Z.exit(M0.setextHeadingLineSequence), F6(H) ? U6(Z, G, M0.lineSuffix)(H) : G(H);
  }
  function G(H) {
    if (H === K0.eof || n2(H))
      return Z.exit(M0.setextHeadingLine), J(H);
    return $(H);
  }
}
// node_modules/micromark/dev/lib/initialize/flow.js
var OP0 = { tokenize: JD1 };
function JD1(Z) {
  let J = this, $ = Z.attempt(Cq, X, Z.attempt(this.parser.constructs.flowInitial, Y, U6(Z, Z.attempt(this.parser.constructs.flow, Y, Z.attempt(n10, Y)), M0.linePrefix)));
  return $;
  function X(Q) {
    if (t0(Q === K0.eof || n2(Q), "expected eol or eof"), Q === K0.eof) {
      Z.consume(Q);
      return;
    }
    return Z.enter(M0.lineEndingBlank), Z.consume(Q), Z.exit(M0.lineEndingBlank), J.currentConstruct = void 0, $;
  }
  function Y(Q) {
    if (t0(Q === K0.eof || n2(Q), "expected eol or eof"), Q === K0.eof) {
      Z.consume(Q);
      return;
    }
    return Z.enter(M0.lineEnding), Z.consume(Q), Z.exit(M0.lineEnding), J.currentConstruct = void 0, $;
  }
}

// node_modules/micromark/dev/lib/initialize/text.js
var zP0 = { resolveAll: BP0() }, DP0 = AP0("string"), MP0 = AP0("text");
function AP0(Z) {
  return {
    tokenize: J,
    resolveAll: BP0(Z === "text" ? $D1 : void 0)
  };
  function J($) {
    let X = this, Y = this.parser.constructs[Z], Q = $.attempt(Y, W, K);
    return W;
    function W(N) {
      return H(N) ? Q(N) : K(N);
    }
    function K(N) {
      if (N === K0.eof) {
        $.consume(N);
        return;
      }
      return $.enter(M0.data), $.consume(N), G;
    }
    function G(N) {
      if (H(N))
        return $.exit(M0.data), Q(N);
      return $.consume(N), G;
    }
    function H(N) {
      if (N === K0.eof)
        return !0;
      let q = Y[N], U = -1;
      if (q) {
        t0(Array.isArray(q), "expected `disable.null` to be populated");
        while (++U < q.length) {
          let F = q[U];
          if (!F.previous || F.previous.call(X, X.previous))
            return !0;
        }
      }
      return !1;
    }
  }
}
function BP0(Z) {
  return J;
  function J($, X) {
    let Y = -1, Q;
    while (++Y <= $.length)
      if (Q === void 0) {
        if ($[Y] && $[Y][1].type === M0.data)
          Q = Y, Y++;
      } else if (!$[Y] || $[Y][1].type !== M0.data) {
        if (Y !== Q + 2)
          $[Q][1].end = $[Y - 1][1].end, $.splice(Q + 2, Y - Q - 2), Y = Q + 2;
        Q = void 0;
      }
    return Z ? Z($, X) : $;
  }
}
function $D1(Z, J) {
  let $ = 0;
  while (++$ <= Z.length)
    if (($ === Z.length || Z[$][1].type === M0.lineEnding) && Z[$ - 1][1].type === M0.data) {
      let X = Z[$ - 1][1], Y = J.sliceStream(X), Q = Y.length, W = -1, K = 0, G;
      while (Q--) {
        let H = Y[Q];
        if (typeof H === "string") {
          W = H.length;
          while (H.charCodeAt(W - 1) === K0.space)
            K++, W--;
          if (W)
            break;
          W = -1;
        } else if (H === K0.horizontalTab)
          G = !0, K++;
        else if (H === K0.virtualSpace)
          ;
        else {
          Q++;
          break;
        }
      }
      if (K) {
        let H = {
          type: $ === Z.length || G || K < M2.hardBreakPrefixSizeMin ? M0.lineSuffix : M0.hardBreakTrailing,
          start: {
            line: X.end.line,
            column: X.end.column - K,
            offset: X.end.offset - K,
            _index: X.start._index + Q,
            _bufferIndex: Q ? W : X.start._bufferIndex + W
          },
          end: Object.assign({}, X.end)
        };
        if (X.end = Object.assign({}, H.start), X.start.offset === X.end.offset)
          Object.assign(X, H);
        else
          Z.splice($, 0, ["enter", H, J], ["exit", H, J]), $ += 2;
      }
      $++;
    }
  return Z;
}

// node_modules/micromark/dev/lib/create-tokenizer.js
var PP0 = t2(IP0(), 1);
var W4 = PP0.default("micromark");
function CP0(Z, J, $) {
  let X = Object.assign($ ? Object.assign({}, $) : { line: 1, column: 1, offset: 0 }, { _index: 0, _bufferIndex: -1 }), Y = {}, Q = [], W = [], K = [], G = !0, H = {
    consume: T,
    enter: w,
    exit: V,
    attempt: S(P),
    check: S(I),
    interrupt: S(I, { interrupt: !0 })
  }, N = {
    previous: K0.eof,
    code: K0.eof,
    containerState: {},
    events: [],
    parser: Z,
    sliceStream: R,
    sliceSerialize: E,
    now: z,
    defineSkip: D,
    write: F
  }, q = J.tokenize.call(N, H), U;
  if (J.resolveAll)
    Q.push(J);
  return N;
  function F(x) {
    if (W = iW(W, x), A(), W[W.length - 1] !== K0.eof)
      return [];
    return f(J, 0), N.events = TE(Q, N.events, N), N.events;
  }
  function E(x, b) {
    return wD1(R(x), b);
  }
  function R(x) {
    return BD1(W, x);
  }
  function z() {
    let { line: x, column: b, offset: g, _index: m, _bufferIndex: i } = X;
    return { line: x, column: b, offset: g, _index: m, _bufferIndex: i };
  }
  function D(x) {
    Y[x.line] = x.column, h(), W4("position: define skip: `%j`", X);
  }
  function A() {
    let x;
    while (X._index < W.length) {
      let b = W[X._index];
      if (typeof b === "string") {
        if (x = X._index, X._bufferIndex < 0)
          X._bufferIndex = 0;
        while (X._index === x && X._bufferIndex < b.length)
          B(b.charCodeAt(X._bufferIndex));
      } else
        B(b);
    }
  }
  function B(x) {
    t0(G === !0, "expected character to be consumed"), G = void 0, W4("main: passing `%s` to %s", x, q && q.name), U = x, t0(typeof q === "function", "expected state"), q = q(x);
  }
  function T(x) {
    if (t0(x === U, "expected given code to equal expected code"), W4("consume: `%s`", x), t0(G === void 0, "expected code to not have been consumed: this might be because `return x(code)` instead of `return x` was used"), t0(x === null ? N.events.length === 0 || N.events[N.events.length - 1][0] === "exit" : N.events[N.events.length - 1][0] === "enter", "expected last token to be open"), n2(x))
      X.line++, X.column = 1, X.offset += x === K0.carriageReturnLineFeed ? 2 : 1, h(), W4("position: after eol: `%j`", X);
    else if (x !== K0.virtualSpace)
      X.column++, X.offset++;
    if (X._bufferIndex < 0)
      X._index++;
    else if (X._bufferIndex++, X._bufferIndex === W[X._index].length)
      X._bufferIndex = -1, X._index++;
    N.previous = x, G = !0;
  }
  function w(x, b) {
    let g = b || {};
    return g.type = x, g.start = z(), t0(typeof x === "string", "expected string type"), t0(x.length > 0, "expected non-empty string"), W4("enter: `%s`", x), N.events.push(["enter", g, N]), K.push(g), g;
  }
  function V(x) {
    t0(typeof x === "string", "expected string type"), t0(x.length > 0, "expected non-empty string");
    let b = K.pop();
    return t0(b, "cannot close w/o open tokens"), b.end = z(), t0(x === b.type, "expected exit token to match current token"), t0(!(b.start._index === b.end._index && b.start._bufferIndex === b.end._bufferIndex), "expected non-empty token (`" + x + "`)"), W4("exit: `%s`", b.type), N.events.push(["exit", b, N]), b;
  }
  function P(x, b) {
    f(x, b.from);
  }
  function I(x, b) {
    b.restore();
  }
  function S(x, b) {
    return g;
    function g(m, i, r) {
      let Y0, c, n, l;
      return Array.isArray(m) ? G0(m) : ("tokenize" in m) ? G0([m]) : u(m);
      function u(U0) {
        return a;
        function a(Q0) {
          let $0 = Q0 !== null && U0[Q0], R0 = Q0 !== null && U0.null, X0 = [
            ...Array.isArray($0) ? $0 : $0 ? [$0] : [],
            ...Array.isArray(R0) ? R0 : R0 ? [R0] : []
          ];
          return G0(X0)(Q0);
        }
      }
      function G0(U0) {
        if (Y0 = U0, c = 0, U0.length === 0)
          return t0(r, "expected `bogusState` to be given"), r;
        return F0(U0[c]);
      }
      function F0(U0) {
        return a;
        function a(Q0) {
          if (l = v(), n = U0, !U0.partial)
            N.currentConstruct = U0;
          if (t0(N.parser.constructs.disable.null, "expected `disable.null` to be populated"), U0.name && N.parser.constructs.disable.null.includes(U0.name))
            return Z0(Q0);
          return U0.tokenize.call(b ? Object.assign(Object.create(N), b) : N, H, t, Z0)(Q0);
        }
      }
      function t(U0) {
        return t0(U0 === U, "expected code"), G = !0, x(n, l), i;
      }
      function Z0(U0) {
        if (t0(U0 === U, "expected code"), G = !0, l.restore(), ++c < Y0.length)
          return F0(Y0[c]);
        return r;
      }
    }
  }
  function f(x, b) {
    if (x.resolveAll && !Q.includes(x))
      Q.push(x);
    if (x.resolve)
      NX(N.events, b, N.events.length - b, x.resolve(N.events.slice(b), N));
    if (x.resolveTo)
      N.events = x.resolveTo(N.events, N);
    t0(x.partial || N.events.length === 0 || N.events[N.events.length - 1][0] === "exit", "expected last token to end");
  }
  function v() {
    let x = z(), b = N.previous, g = N.currentConstruct, m = N.events.length, i = Array.from(K);
    return { restore: r, from: m };
    function r() {
      X = x, N.previous = b, N.currentConstruct = g, N.events.length = m, K = i, h(), W4("position: restore: `%j`", X);
    }
  }
  function h() {
    if (X.line in Y && X.column < 2)
      X.column = Y[X.line], X.offset += Y[X.line] - 1;
  }
}
function BD1(Z, J) {
  let $ = J.start._index, X = J.start._bufferIndex, Y = J.end._index, Q = J.end._bufferIndex, W;
  if ($ === Y)
    t0(Q > -1, "expected non-negative end buffer index"), t0(X > -1, "expected non-negative start buffer index"), W = [Z[$].slice(X, Q)];
  else {
    if (W = Z.slice($, Y), X > -1) {
      let K = W[0];
      if (typeof K === "string")
        W[0] = K.slice(X);
      else
        t0(X === 0, "expected `startBufferIndex` to be `0`"), W.shift();
    }
    if (Q > 0)
      W.push(Z[Y].slice(0, Q));
  }
  return W;
}
function wD1(Z, J) {
  let $ = -1, X = [], Y;
  while (++$ < Z.length) {
    let Q = Z[$], W;
    if (typeof Q === "string")
      W = Q;
    else
      switch (Q) {
        case K0.carriageReturn: {
          W = nW.cr;
          break;
        }
        case K0.lineFeed: {
          W = nW.lf;
          break;
        }
        case K0.carriageReturnLineFeed: {
          W = nW.cr + nW.lf;
          break;
        }
        case K0.horizontalTab: {
          W = J ? nW.space : nW.ht;
          break;
        }
        case K0.virtualSpace: {
          if (!J && Y)
            continue;
          W = nW.space;
          break;
        }
        default:
          t0(typeof Q === "number", "expected number"), W = String.fromCharCode(Q);
      }
    Y = Q === K0.horizontalTab, X.push(W);
  }
  return X.join("");
}

// node_modules/micromark/dev/lib/constructs.js
var J20 = {};
y9(J20, {
  text: () => PD1,
  string: () => ID1,
  insideSpan: () => CD1,
  flowInitial: () => _D1,
  flow: () => VD1,
  document: () => jD1,
  disable: () => vD1,
  contentInitial: () => TD1,
  attentionMarkers: () => kD1
});
var jD1 = {
  [K0.asterisk]: QW,
  [K0.plusSign]: QW,
  [K0.dash]: QW,
  [K0.digit0]: QW,
  [K0.digit1]: QW,
  [K0.digit2]: QW,
  [K0.digit3]: QW,
  [K0.digit4]: QW,
  [K0.digit5]: QW,
  [K0.digit6]: QW,
  [K0.digit7]: QW,
  [K0.digit8]: QW,
  [K0.digit9]: QW,
  [K0.greaterThan]: fy
}, TD1 = {
  [K0.leftSquareBracket]: i10
}, _D1 = {
  [K0.horizontalTab]: lI,
  [K0.virtualSpace]: lI,
  [K0.space]: lI
}, VD1 = {
  [K0.numberSign]: s10,
  [K0.asterisk]: Y4,
  [K0.dash]: [py, Y4],
  [K0.lessThan]: r10,
  [K0.equalsTo]: py,
  [K0.underscore]: Y4,
  [K0.graveAccent]: xy,
  [K0.tilde]: xy
}, ID1 = {
  [K0.ampersand]: by,
  [K0.backslash]: hy
}, PD1 = {
  [K0.carriageReturn]: iI,
  [K0.lineFeed]: iI,
  [K0.carriageReturnLineFeed]: iI,
  [K0.exclamationMark]: e10,
  [K0.ampersand]: by,
  [K0.asterisk]: cI,
  [K0.lessThan]: [u10, t10],
  [K0.leftSquareBracket]: Z20,
  [K0.backslash]: [o10, hy],
  [K0.rightSquareBracket]: X4,
  [K0.underscore]: cI,
  [K0.graveAccent]: c10
}, CD1 = { null: [cI, zP0] }, kD1 = { null: [K0.asterisk, K0.underscore] }, vD1 = { null: [] };

// node_modules/micromark/dev/lib/parse.js
function $20(Z) {
  let $ = vy([J20, ...(Z || {}).extensions || []]), X = {
    defined: [],
    lazy: {},
    constructs: $,
    content: Y(NP0),
    document: Y(FP0),
    flow: Y(OP0),
    string: Y(DP0),
    text: Y(MP0)
  };
  return X;
  function Y(Q) {
    return W;
    function W(K) {
      return CP0(X, Q, K);
    }
  }
}

// node_modules/micromark/dev/lib/postprocess.js
function X20(Z) {
  while (!yy(Z))
    ;
  return Z;
}

// node_modules/micromark/dev/lib/preprocess.js
var kP0 = /[\0\t\n\r]/g;
function Y20() {
  let Z = 1, J = "", $ = !0, X;
  return Y;
  function Y(Q, W, K) {
    let G = [], H, N, q, U, F;
    if (Q = J + (typeof Q === "string" ? Q.toString() : new TextDecoder(W || void 0).decode(Q)), q = 0, J = "", $) {
      if (Q.charCodeAt(0) === K0.byteOrderMarker)
        q++;
      $ = void 0;
    }
    while (q < Q.length) {
      if (kP0.lastIndex = q, H = kP0.exec(Q), U = H && H.index !== void 0 ? H.index : Q.length, F = Q.charCodeAt(U), !H) {
        J = Q.slice(q);
        break;
      }
      if (F === K0.lf && q === U && X)
        G.push(K0.carriageReturnLineFeed), X = void 0;
      else {
        if (X)
          G.push(K0.carriageReturn), X = void 0;
        if (q < U)
          G.push(Q.slice(q, U)), Z += U - q;
        switch (F) {
          case K0.nul: {
            G.push(K0.replacementCharacter), Z++;
            break;
          }
          case K0.ht: {
            N = Math.ceil(Z / M2.tabSize) * M2.tabSize, G.push(K0.horizontalTab);
            while (Z++ < N)
              G.push(K0.virtualSpace);
            break;
          }
          case K0.lf: {
            G.push(K0.lineFeed), Z = 1;
            break;
          }
          default:
            X = !0, Z = 1;
        }
      }
      q = U + 1;
    }
    if (K) {
      if (X)
        G.push(K0.carriageReturn);
      if (J)
        G.push(J);
      G.push(K0.eof);
    }
    return G;
  }
}
// node_modules/micromark-util-decode-string/dev/index.js
var SD1 = /\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;
function vP0(Z) {
  return Z.replace(SD1, fD1);
}
function fD1(Z, J, $) {
  if (J)
    return J;
  if ($.charCodeAt(0) === K0.numberSign) {
    let Y = $.charCodeAt(1), Q = Y === K0.lowercaseX || Y === K0.uppercaseX;
    return Sy($.slice(Q ? 2 : 1), Q ? M2.numericBaseHexadecimal : M2.numericBaseDecimal);
  }
  return TB($) || Z;
}

// node_modules/mdast-util-from-markdown/dev/lib/index.js
var fP0 = {}.hasOwnProperty;
function Q20(Z, J, $) {
  if (typeof J !== "string")
    $ = J, J = void 0;
  return hD1($)(X20($20($).document().write(Y20()(Z, J, !0))));
}
function hD1(Z) {
  let J = {
    transforms: [],
    canContainEols: ["emphasis", "fragment", "heading", "paragraph", "strong"],
    enter: {
      autolink: Q(A0),
      autolinkProtocol: S,
      autolinkEmail: S,
      atxHeading: Q(V0),
      blockQuote: Q(Q0),
      characterEscape: S,
      characterReference: S,
      codeFenced: Q($0),
      codeFencedFenceInfo: W,
      codeFencedFenceMeta: W,
      codeIndented: Q($0, W),
      codeText: Q(R0, W),
      codeTextData: S,
      data: S,
      codeFlowValue: S,
      definition: Q(X0),
      definitionDestinationString: W,
      definitionLabelString: W,
      definitionTitleString: W,
      emphasis: Q(E0),
      hardBreakEscape: Q(u0),
      hardBreakTrailing: Q(u0),
      htmlFlow: Q(N0, W),
      htmlFlowData: S,
      htmlText: Q(N0, W),
      htmlTextData: S,
      image: Q(q0),
      label: W,
      link: Q(A0),
      listItem: Q(a0),
      listItemValue: U,
      listOrdered: Q(S0, q),
      listUnordered: Q(S0),
      paragraph: Q(D1),
      reference: u,
      referenceString: W,
      resourceDestinationString: W,
      resourceTitleString: W,
      setextHeading: Q(V0),
      strong: Q(Y1),
      thematicBreak: Q(b0)
    },
    exit: {
      atxHeading: G(),
      atxHeadingSequence: w,
      autolink: G(),
      autolinkEmail: a,
      autolinkProtocol: U0,
      blockQuote: G(),
      characterEscapeValue: f,
      characterReferenceMarkerHexadecimal: F0,
      characterReferenceMarkerNumeric: F0,
      characterReferenceValue: t,
      characterReference: Z0,
      codeFenced: G(z),
      codeFencedFence: R,
      codeFencedFenceInfo: F,
      codeFencedFenceMeta: E,
      codeFlowValue: f,
      codeIndented: G(D),
      codeText: G(g),
      codeTextData: f,
      data: f,
      definition: G(),
      definitionDestinationString: T,
      definitionLabelString: A,
      definitionTitleString: B,
      emphasis: G(),
      hardBreakEscape: G(h),
      hardBreakTrailing: G(h),
      htmlFlow: G(x),
      htmlFlowData: f,
      htmlText: G(b),
      htmlTextData: f,
      image: G(i),
      label: Y0,
      labelText: r,
      lineEnding: v,
      link: G(m),
      listItem: G(),
      listOrdered: G(),
      listUnordered: G(),
      paragraph: G(),
      referenceString: G0,
      resourceDestinationString: c,
      resourceTitleString: n,
      resource: l,
      setextHeading: G(I),
      setextHeadingLineSequence: P,
      setextHeadingText: V,
      strong: G(),
      thematicBreak: G()
    }
  };
  hP0(J, (Z || {}).mdastExtensions || []);
  let $ = {};
  return X;
  function X(x0) {
    let m0 = { type: "root", children: [] }, e0 = {
      stack: [m0],
      tokenStack: [],
      config: J,
      enter: K,
      exit: H,
      buffer: W,
      resume: N,
      data: $
    }, p = [], J0 = -1;
    while (++J0 < x0.length)
      if (x0[J0][1].type === M0.listOrdered || x0[J0][1].type === M0.listUnordered)
        if (x0[J0][0] === "enter")
          p.push(J0);
        else {
          let T0 = p.pop();
          t0(typeof T0 === "number", "expected list ot be open"), J0 = Y(x0, T0, J0);
        }
    J0 = -1;
    while (++J0 < x0.length) {
      let T0 = J[x0[J0][0]];
      if (fP0.call(T0, x0[J0][1].type))
        T0[x0[J0][1].type].call(Object.assign({ sliceSerialize: x0[J0][2].sliceSerialize }, e0), x0[J0][1]);
    }
    if (e0.tokenStack.length > 0) {
      let T0 = e0.tokenStack[e0.tokenStack.length - 1];
      (T0[1] || SP0).call(e0, void 0, T0[0]);
    }
    m0.position = {
      start: _E(x0.length > 0 ? x0[0][1].start : { line: 1, column: 1, offset: 0 }),
      end: _E(x0.length > 0 ? x0[x0.length - 2][1].end : { line: 1, column: 1, offset: 0 })
    }, J0 = -1;
    while (++J0 < J.transforms.length)
      m0 = J.transforms[J0](m0) || m0;
    return m0;
  }
  function Y(x0, m0, e0) {
    let p = m0 - 1, J0 = -1, T0 = !1, o0, y0, $1, F1;
    while (++p <= e0) {
      let A1 = x0[p];
      switch (A1[1].type) {
        case M0.listUnordered:
        case M0.listOrdered:
        case M0.blockQuote: {
          if (A1[0] === "enter")
            J0++;
          else
            J0--;
          F1 = void 0;
          break;
        }
        case M0.lineEndingBlank: {
          if (A1[0] === "enter") {
            if (o0 && !F1 && !J0 && !$1)
              $1 = p;
            F1 = void 0;
          }
          break;
        }
        case M0.linePrefix:
        case M0.listItemValue:
        case M0.listItemMarker:
        case M0.listItemPrefix:
        case M0.listItemPrefixWhitespace:
          break;
        default:
          F1 = void 0;
      }
      if (!J0 && A1[0] === "enter" && A1[1].type === M0.listItemPrefix || J0 === -1 && A1[0] === "exit" && (A1[1].type === M0.listUnordered || A1[1].type === M0.listOrdered)) {
        if (o0) {
          let P1 = p;
          y0 = void 0;
          while (P1--) {
            let S1 = x0[P1];
            if (S1[1].type === M0.lineEnding || S1[1].type === M0.lineEndingBlank) {
              if (S1[0] === "exit")
                continue;
              if (y0)
                x0[y0][1].type = M0.lineEndingBlank, T0 = !0;
              S1[1].type = M0.lineEnding, y0 = P1;
            } else if (S1[1].type === M0.linePrefix || S1[1].type === M0.blockQuotePrefix || S1[1].type === M0.blockQuotePrefixWhitespace || S1[1].type === M0.blockQuoteMarker || S1[1].type === M0.listItemIndent)
              ;
            else
              break;
          }
          if ($1 && (!y0 || $1 < y0))
            o0._spread = !0;
          o0.end = Object.assign({}, y0 ? x0[y0][1].start : A1[1].end), x0.splice(y0 || p, 0, ["exit", o0, A1[2]]), p++, e0++;
        }
        if (A1[1].type === M0.listItemPrefix) {
          let P1 = {
            type: "listItem",
            _spread: !1,
            start: Object.assign({}, A1[1].start),
            end: void 0
          };
          o0 = P1, x0.splice(p, 0, ["enter", P1, A1[2]]), p++, e0++, $1 = void 0, F1 = !0;
        }
      }
    }
    return x0[m0][1]._spread = T0, e0;
  }
  function Q(x0, m0) {
    return e0;
    function e0(p) {
      if (K.call(this, x0(p), p), m0)
        m0.call(this, p);
    }
  }
  function W() {
    this.stack.push({ type: "fragment", children: [] });
  }
  function K(x0, m0, e0) {
    let p = this.stack[this.stack.length - 1];
    t0(p, "expected `parent`"), t0("children" in p, "expected `parent`"), p.children.push(x0), this.stack.push(x0), this.tokenStack.push([m0, e0]), x0.position = {
      start: _E(m0.start),
      end: void 0
    };
  }
  function G(x0) {
    return m0;
    function m0(e0) {
      if (x0)
        x0.call(this, e0);
      H.call(this, e0);
    }
  }
  function H(x0, m0) {
    let e0 = this.stack.pop();
    t0(e0, "expected `node`");
    let p = this.tokenStack.pop();
    if (!p)
      throw new Error("Cannot close `" + x0.type + "` (" + wE({ start: x0.start, end: x0.end }) + "): it’s not open");
    else if (p[0].type !== x0.type)
      if (m0)
        m0.call(this, x0, p[0]);
      else
        (p[1] || SP0).call(this, x0, p[0]);
    t0(e0.type !== "fragment", "unexpected fragment `exit`ed"), t0(e0.position, "expected `position` to be defined"), e0.position.end = _E(x0.end);
  }
  function N() {
    return ez(this.stack.pop());
  }
  function q() {
    this.data.expectingFirstListItemValue = !0;
  }
  function U(x0) {
    if (this.data.expectingFirstListItemValue) {
      let m0 = this.stack[this.stack.length - 2];
      t0(m0, "expected nodes on stack"), t0(m0.type === "list", "expected list on stack"), m0.start = Number.parseInt(this.sliceSerialize(x0), M2.numericBaseDecimal), this.data.expectingFirstListItemValue = void 0;
    }
  }
  function F() {
    let x0 = this.resume(), m0 = this.stack[this.stack.length - 1];
    t0(m0, "expected node on stack"), t0(m0.type === "code", "expected code on stack"), m0.lang = x0;
  }
  function E() {
    let x0 = this.resume(), m0 = this.stack[this.stack.length - 1];
    t0(m0, "expected node on stack"), t0(m0.type === "code", "expected code on stack"), m0.meta = x0;
  }
  function R() {
    if (this.data.flowCodeInside)
      return;
    this.buffer(), this.data.flowCodeInside = !0;
  }
  function z() {
    let x0 = this.resume(), m0 = this.stack[this.stack.length - 1];
    t0(m0, "expected node on stack"), t0(m0.type === "code", "expected code on stack"), m0.value = x0.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g, ""), this.data.flowCodeInside = void 0;
  }
  function D() {
    let x0 = this.resume(), m0 = this.stack[this.stack.length - 1];
    t0(m0, "expected node on stack"), t0(m0.type === "code", "expected code on stack"), m0.value = x0.replace(/(\r?\n|\r)$/g, "");
  }
  function A(x0) {
    let m0 = this.resume(), e0 = this.stack[this.stack.length - 1];
    t0(e0, "expected node on stack"), t0(e0.type === "definition", "expected definition on stack"), e0.label = m0, e0.identifier = YW(this.sliceSerialize(x0)).toLowerCase();
  }
  function B() {
    let x0 = this.resume(), m0 = this.stack[this.stack.length - 1];
    t0(m0, "expected node on stack"), t0(m0.type === "definition", "expected definition on stack"), m0.title = x0;
  }
  function T() {
    let x0 = this.resume(), m0 = this.stack[this.stack.length - 1];
    t0(m0, "expected node on stack"), t0(m0.type === "definition", "expected definition on stack"), m0.url = x0;
  }
  function w(x0) {
    let m0 = this.stack[this.stack.length - 1];
    if (t0(m0, "expected node on stack"), t0(m0.type === "heading", "expected heading on stack"), !m0.depth) {
      let e0 = this.sliceSerialize(x0).length;
      t0(e0 === 1 || e0 === 2 || e0 === 3 || e0 === 4 || e0 === 5 || e0 === 6, "expected `depth` between `1` and `6`"), m0.depth = e0;
    }
  }
  function V() {
    this.data.setextHeadingSlurpLineEnding = !0;
  }
  function P(x0) {
    let m0 = this.stack[this.stack.length - 1];
    t0(m0, "expected node on stack"), t0(m0.type === "heading", "expected heading on stack"), m0.depth = this.sliceSerialize(x0).codePointAt(0) === K0.equalsTo ? 1 : 2;
  }
  function I() {
    this.data.setextHeadingSlurpLineEnding = void 0;
  }
  function S(x0) {
    let m0 = this.stack[this.stack.length - 1];
    t0(m0, "expected node on stack"), t0("children" in m0, "expected parent on stack");
    let e0 = m0.children, p = e0[e0.length - 1];
    if (!p || p.type !== "text")
      p = u1(), p.position = {
        start: _E(x0.start),
        end: void 0
      }, e0.push(p);
    this.stack.push(p);
  }
  function f(x0) {
    let m0 = this.stack.pop();
    t0(m0, "expected a `node` to be on the stack"), t0("value" in m0, "expected a `literal` to be on the stack"), t0(m0.position, "expected `node` to have an open position"), m0.value += this.sliceSerialize(x0), m0.position.end = _E(x0.end);
  }
  function v(x0) {
    let m0 = this.stack[this.stack.length - 1];
    if (t0(m0, "expected `node`"), this.data.atHardBreak) {
      t0("children" in m0, "expected `parent`");
      let e0 = m0.children[m0.children.length - 1];
      t0(e0.position, "expected tail to have a starting position"), e0.position.end = _E(x0.end), this.data.atHardBreak = void 0;
      return;
    }
    if (!this.data.setextHeadingSlurpLineEnding && J.canContainEols.includes(m0.type))
      S.call(this, x0), f.call(this, x0);
  }
  function h() {
    this.data.atHardBreak = !0;
  }
  function x() {
    let x0 = this.resume(), m0 = this.stack[this.stack.length - 1];
    t0(m0, "expected node on stack"), t0(m0.type === "html", "expected html on stack"), m0.value = x0;
  }
  function b() {
    let x0 = this.resume(), m0 = this.stack[this.stack.length - 1];
    t0(m0, "expected node on stack"), t0(m0.type === "html", "expected html on stack"), m0.value = x0;
  }
  function g() {
    let x0 = this.resume(), m0 = this.stack[this.stack.length - 1];
    t0(m0, "expected node on stack"), t0(m0.type === "inlineCode", "expected inline code on stack"), m0.value = x0;
  }
  function m() {
    let x0 = this.stack[this.stack.length - 1];
    if (t0(x0, "expected node on stack"), t0(x0.type === "link", "expected link on stack"), this.data.inReference) {
      let m0 = this.data.referenceType || "shortcut";
      x0.type += "Reference", x0.referenceType = m0, delete x0.url, delete x0.title;
    } else
      delete x0.identifier, delete x0.label;
    this.data.referenceType = void 0;
  }
  function i() {
    let x0 = this.stack[this.stack.length - 1];
    if (t0(x0, "expected node on stack"), t0(x0.type === "image", "expected image on stack"), this.data.inReference) {
      let m0 = this.data.referenceType || "shortcut";
      x0.type += "Reference", x0.referenceType = m0, delete x0.url, delete x0.title;
    } else
      delete x0.identifier, delete x0.label;
    this.data.referenceType = void 0;
  }
  function r(x0) {
    let m0 = this.sliceSerialize(x0), e0 = this.stack[this.stack.length - 2];
    t0(e0, "expected ancestor on stack"), t0(e0.type === "image" || e0.type === "link", "expected image or link on stack"), e0.label = vP0(m0), e0.identifier = YW(m0).toLowerCase();
  }
  function Y0() {
    let x0 = this.stack[this.stack.length - 1];
    t0(x0, "expected node on stack"), t0(x0.type === "fragment", "expected fragment on stack");
    let m0 = this.resume(), e0 = this.stack[this.stack.length - 1];
    if (t0(e0, "expected node on stack"), t0(e0.type === "image" || e0.type === "link", "expected image or link on stack"), this.data.inReference = !0, e0.type === "link") {
      let p = x0.children;
      e0.children = p;
    } else
      e0.alt = m0;
  }
  function c() {
    let x0 = this.resume(), m0 = this.stack[this.stack.length - 1];
    t0(m0, "expected node on stack"), t0(m0.type === "image" || m0.type === "link", "expected image or link on stack"), m0.url = x0;
  }
  function n() {
    let x0 = this.resume(), m0 = this.stack[this.stack.length - 1];
    t0(m0, "expected node on stack"), t0(m0.type === "image" || m0.type === "link", "expected image or link on stack"), m0.title = x0;
  }
  function l() {
    this.data.inReference = void 0;
  }
  function u() {
    this.data.referenceType = "collapsed";
  }
  function G0(x0) {
    let m0 = this.resume(), e0 = this.stack[this.stack.length - 1];
    t0(e0, "expected node on stack"), t0(e0.type === "image" || e0.type === "link", "expected image reference or link reference on stack"), e0.label = m0, e0.identifier = YW(this.sliceSerialize(x0)).toLowerCase(), this.data.referenceType = "full";
  }
  function F0(x0) {
    t0(x0.type === "characterReferenceMarkerNumeric" || x0.type === "characterReferenceMarkerHexadecimal"), this.data.characterReferenceType = x0.type;
  }
  function t(x0) {
    let m0 = this.sliceSerialize(x0), e0 = this.data.characterReferenceType, p;
    if (e0)
      p = Sy(m0, e0 === M0.characterReferenceMarkerNumeric ? M2.numericBaseDecimal : M2.numericBaseHexadecimal), this.data.characterReferenceType = void 0;
    else {
      let T0 = TB(m0);
      t0(T0 !== !1, "expected reference to decode"), p = T0;
    }
    let J0 = this.stack[this.stack.length - 1];
    t0(J0, "expected `node`"), t0("value" in J0, "expected `node.value`"), J0.value += p;
  }
  function Z0(x0) {
    let m0 = this.stack.pop();
    t0(m0, "expected `node`"), t0(m0.position, "expected `node.position`"), m0.position.end = _E(x0.end);
  }
  function U0(x0) {
    f.call(this, x0);
    let m0 = this.stack[this.stack.length - 1];
    t0(m0, "expected node on stack"), t0(m0.type === "link", "expected link on stack"), m0.url = this.sliceSerialize(x0);
  }
  function a(x0) {
    f.call(this, x0);
    let m0 = this.stack[this.stack.length - 1];
    t0(m0, "expected node on stack"), t0(m0.type === "link", "expected link on stack"), m0.url = "mailto:" + this.sliceSerialize(x0);
  }
  function Q0() {
    return { type: "blockquote", children: [] };
  }
  function $0() {
    return { type: "code", lang: null, meta: null, value: "" };
  }
  function R0() {
    return { type: "inlineCode", value: "" };
  }
  function X0() {
    return {
      type: "definition",
      identifier: "",
      label: null,
      title: null,
      url: ""
    };
  }
  function E0() {
    return { type: "emphasis", children: [] };
  }
  function V0() {
    return {
      type: "heading",
      depth: 0,
      children: []
    };
  }
  function u0() {
    return { type: "break" };
  }
  function N0() {
    return { type: "html", value: "" };
  }
  function q0() {
    return { type: "image", title: null, url: "", alt: null };
  }
  function A0() {
    return { type: "link", title: null, url: "", children: [] };
  }
  function S0(x0) {
    return {
      type: "list",
      ordered: x0.type === "listOrdered",
      start: null,
      spread: x0._spread,
      children: []
    };
  }
  function a0(x0) {
    return {
      type: "listItem",
      spread: x0._spread,
      checked: null,
      children: []
    };
  }
  function D1() {
    return { type: "paragraph", children: [] };
  }
  function Y1() {
    return { type: "strong", children: [] };
  }
  function u1() {
    return { type: "text", value: "" };
  }
  function b0() {
    return { type: "thematicBreak" };
  }
}
function _E(Z) {
  return { line: Z.line, column: Z.column, offset: Z.offset };
}
function hP0(Z, J) {
  let $ = -1;
  while (++$ < J.length) {
    let X = J[$];
    if (Array.isArray(X))
      hP0(Z, X);
    else
      bD1(Z, X);
  }
}
function bD1(Z, J) {
  let $;
  for ($ in J)
    if (fP0.call(J, $))
      switch ($) {
        case "canContainEols": {
          let X = J[$];
          if (X)
            Z[$].push(...X);
          break;
        }
        case "transforms": {
          let X = J[$];
          if (X)
            Z[$].push(...X);
          break;
        }
        case "enter":
        case "exit": {
          let X = J[$];
          if (X)
            Object.assign(Z[$], X);
          break;
        }
      }
}
function SP0(Z, J) {
  if (Z)
    throw new Error("Cannot close `" + Z.type + "` (" + wE({ start: Z.start, end: Z.end }) + "): a different token (`" + J.type + "`, " + wE({ start: J.start, end: J.end }) + ") is open");
  else
    throw new Error("Cannot close document, a token (`" + J.type + "`, " + wE({ start: J.start, end: J.end }) + ") is still open");
}
// node_modules/remark-parse/lib/index.js
function ny(Z) {
  let J = this;
  J.parser = $;
  function $(X) {
    return Q20(X, {
      ...J.data("settings"),
      ...Z,
      extensions: J.data("micromarkExtensions") || [],
      mdastExtensions: J.data("fromMarkdownExtensions") || []
    });
  }
}
// node_modules/mdast-util-to-hast/lib/handlers/blockquote.js
function bP0(Z, J) {
  let $ = {
    type: "element",
    tagName: "blockquote",
    properties: {},
    children: Z.wrap(Z.all(J), !0)
  };
  return Z.patch(J, $), Z.applyData(J, $);
}

// node_modules/mdast-util-to-hast/lib/handlers/break.js
function xP0(Z, J) {
  let $ = { type: "element", tagName: "br", properties: {}, children: [] };
  return Z.patch(J, $), [Z.applyData(J, $), { type: "text", value: `
` }];
}

// node_modules/mdast-util-to-hast/lib/handlers/code.js
function yP0(Z, J) {
  let $ = J.value ? J.value + `
` : "", X = {};
  if (J.lang)
    X.className = ["language-" + J.lang];
  let Y = {
    type: "element",
    tagName: "code",
    properties: X,
    children: [{ type: "text", value: $ }]
  };
  if (J.meta)
    Y.data = { meta: J.meta };
  return Z.patch(J, Y), Y = Z.applyData(J, Y), Y = { type: "element", tagName: "pre", properties: {}, children: [Y] }, Z.patch(J, Y), Y;
}

// node_modules/mdast-util-to-hast/lib/handlers/delete.js
function gP0(Z, J) {
  let $ = {
    type: "element",
    tagName: "del",
    properties: {},
    children: Z.all(J)
  };
  return Z.patch(J, $), Z.applyData(J, $);
}

// node_modules/mdast-util-to-hast/lib/handlers/emphasis.js
function mP0(Z, J) {
  let $ = {
    type: "element",
    tagName: "em",
    properties: {},
    children: Z.all(J)
  };
  return Z.patch(J, $), Z.applyData(J, $);
}

// node_modules/mdast-util-to-hast/lib/handlers/footnote-reference.js
function dP0(Z, J) {
  let $ = typeof Z.options.clobberPrefix === "string" ? Z.options.clobberPrefix : "user-content-", X = String(J.identifier).toUpperCase(), Y = $G(X.toLowerCase()), Q = Z.footnoteOrder.indexOf(X), W, K = Z.footnoteCounts.get(X);
  if (K === void 0)
    K = 0, Z.footnoteOrder.push(X), W = Z.footnoteOrder.length;
  else
    W = Q + 1;
  K += 1, Z.footnoteCounts.set(X, K);
  let G = {
    type: "element",
    tagName: "a",
    properties: {
      href: "#" + $ + "fn-" + Y,
      id: $ + "fnref-" + Y + (K > 1 ? "-" + K : ""),
      dataFootnoteRef: !0,
      ariaDescribedBy: ["footnote-label"]
    },
    children: [{ type: "text", value: String(W) }]
  };
  Z.patch(J, G);
  let H = {
    type: "element",
    tagName: "sup",
    properties: {},
    children: [G]
  };
  return Z.patch(J, H), Z.applyData(J, H);
}

// node_modules/mdast-util-to-hast/lib/handlers/heading.js
function pP0(Z, J) {
  let $ = {
    type: "element",
    tagName: "h" + J.depth,
    properties: {},
    children: Z.all(J)
  };
  return Z.patch(J, $), Z.applyData(J, $);
}

// node_modules/mdast-util-to-hast/lib/handlers/html.js
function uP0(Z, J) {
  if (Z.options.allowDangerousHtml) {
    let $ = { type: "raw", value: J.value };
    return Z.patch(J, $), Z.applyData(J, $);
  }
  return;
}

// node_modules/mdast-util-to-hast/lib/revert.js
function iy(Z, J) {
  let $ = J.referenceType, X = "]";
  if ($ === "collapsed")
    X += "[]";
  else if ($ === "full")
    X += "[" + (J.label || J.identifier) + "]";
  if (J.type === "imageReference")
    return [{ type: "text", value: "![" + J.alt + X }];
  let Y = Z.all(J), Q = Y[0];
  if (Q && Q.type === "text")
    Q.value = "[" + Q.value;
  else
    Y.unshift({ type: "text", value: "[" });
  let W = Y[Y.length - 1];
  if (W && W.type === "text")
    W.value += X;
  else
    Y.push({ type: "text", value: X });
  return Y;
}

// node_modules/mdast-util-to-hast/lib/handlers/image-reference.js
function cP0(Z, J) {
  let $ = String(J.identifier).toUpperCase(), X = Z.definitionById.get($);
  if (!X)
    return iy(Z, J);
  let Y = { src: $G(X.url || ""), alt: J.alt };
  if (X.title !== null && X.title !== void 0)
    Y.title = X.title;
  let Q = { type: "element", tagName: "img", properties: Y, children: [] };
  return Z.patch(J, Q), Z.applyData(J, Q);
}

// node_modules/mdast-util-to-hast/lib/handlers/image.js
function lP0(Z, J) {
  let $ = { src: $G(J.url) };
  if (J.alt !== null && J.alt !== void 0)
    $.alt = J.alt;
  if (J.title !== null && J.title !== void 0)
    $.title = J.title;
  let X = { type: "element", tagName: "img", properties: $, children: [] };
  return Z.patch(J, X), Z.applyData(J, X);
}

// node_modules/mdast-util-to-hast/lib/handlers/inline-code.js
function nP0(Z, J) {
  let $ = { type: "text", value: J.value.replace(/\r?\n|\r/g, " ") };
  Z.patch(J, $);
  let X = {
    type: "element",
    tagName: "code",
    properties: {},
    children: [$]
  };
  return Z.patch(J, X), Z.applyData(J, X);
}

// node_modules/mdast-util-to-hast/lib/handlers/link-reference.js
function iP0(Z, J) {
  let $ = String(J.identifier).toUpperCase(), X = Z.definitionById.get($);
  if (!X)
    return iy(Z, J);
  let Y = { href: $G(X.url || "") };
  if (X.title !== null && X.title !== void 0)
    Y.title = X.title;
  let Q = {
    type: "element",
    tagName: "a",
    properties: Y,
    children: Z.all(J)
  };
  return Z.patch(J, Q), Z.applyData(J, Q);
}

// node_modules/mdast-util-to-hast/lib/handlers/link.js
function oP0(Z, J) {
  let $ = { href: $G(J.url) };
  if (J.title !== null && J.title !== void 0)
    $.title = J.title;
  let X = {
    type: "element",
    tagName: "a",
    properties: $,
    children: Z.all(J)
  };
  return Z.patch(J, X), Z.applyData(J, X);
}

// node_modules/mdast-util-to-hast/lib/handlers/list-item.js
function sP0(Z, J, $) {
  let X = Z.all(J), Y = $ ? xD1($) : aP0(J), Q = {}, W = [];
  if (typeof J.checked === "boolean") {
    let N = X[0], q;
    if (N && N.type === "element" && N.tagName === "p")
      q = N;
    else
      q = { type: "element", tagName: "p", properties: {}, children: [] }, X.unshift(q);
    if (q.children.length > 0)
      q.children.unshift({ type: "text", value: " " });
    q.children.unshift({
      type: "element",
      tagName: "input",
      properties: { type: "checkbox", checked: J.checked, disabled: !0 },
      children: []
    }), Q.className = ["task-list-item"];
  }
  let K = -1;
  while (++K < X.length) {
    let N = X[K];
    if (Y || K !== 0 || N.type !== "element" || N.tagName !== "p")
      W.push({ type: "text", value: `
` });
    if (N.type === "element" && N.tagName === "p" && !Y)
      W.push(...N.children);
    else
      W.push(N);
  }
  let G = X[X.length - 1];
  if (G && (Y || G.type !== "element" || G.tagName !== "p"))
    W.push({ type: "text", value: `
` });
  let H = { type: "element", tagName: "li", properties: Q, children: W };
  return Z.patch(J, H), Z.applyData(J, H);
}
function xD1(Z) {
  let J = !1;
  if (Z.type === "list") {
    J = Z.spread || !1;
    let $ = Z.children, X = -1;
    while (!J && ++X < $.length)
      J = aP0($[X]);
  }
  return J;
}
function aP0(Z) {
  let J = Z.spread;
  return J === null || J === void 0 ? Z.children.length > 1 : J;
}

// node_modules/mdast-util-to-hast/lib/handlers/list.js
function rP0(Z, J) {
  let $ = {}, X = Z.all(J), Y = -1;
  if (typeof J.start === "number" && J.start !== 1)
    $.start = J.start;
  while (++Y < X.length) {
    let W = X[Y];
    if (W.type === "element" && W.tagName === "li" && W.properties && Array.isArray(W.properties.className) && W.properties.className.includes("task-list-item")) {
      $.className = ["contains-task-list"];
      break;
    }
  }
  let Q = {
    type: "element",
    tagName: J.ordered ? "ol" : "ul",
    properties: $,
    children: Z.wrap(X, !0)
  };
  return Z.patch(J, Q), Z.applyData(J, Q);
}

// node_modules/mdast-util-to-hast/lib/handlers/paragraph.js
function tP0(Z, J) {
  let $ = {
    type: "element",
    tagName: "p",
    properties: {},
    children: Z.all(J)
  };
  return Z.patch(J, $), Z.applyData(J, $);
}

// node_modules/mdast-util-to-hast/lib/handlers/root.js
function eP0(Z, J) {
  let $ = { type: "root", children: Z.wrap(Z.all(J)) };
  return Z.patch(J, $), Z.applyData(J, $);
}

// node_modules/mdast-util-to-hast/lib/handlers/strong.js
function ZC0(Z, J) {
  let $ = {
    type: "element",
    tagName: "strong",
    properties: {},
    children: Z.all(J)
  };
  return Z.patch(J, $), Z.applyData(J, $);
}

// node_modules/mdast-util-to-hast/lib/handlers/table.js
function JC0(Z, J) {
  let $ = Z.all(J), X = $.shift(), Y = [];
  if (X) {
    let W = {
      type: "element",
      tagName: "thead",
      properties: {},
      children: Z.wrap([X], !0)
    };
    Z.patch(J.children[0], W), Y.push(W);
  }
  if ($.length > 0) {
    let W = {
      type: "element",
      tagName: "tbody",
      properties: {},
      children: Z.wrap($, !0)
    }, K = jB(J.children[1]), G = ky(J.children[J.children.length - 1]);
    if (K && G)
      W.position = { start: K, end: G };
    Y.push(W);
  }
  let Q = {
    type: "element",
    tagName: "table",
    properties: {},
    children: Z.wrap(Y, !0)
  };
  return Z.patch(J, Q), Z.applyData(J, Q);
}

// node_modules/mdast-util-to-hast/lib/handlers/table-row.js
function $C0(Z, J, $) {
  let X = $ ? $.children : void 0, Q = (X ? X.indexOf(J) : 1) === 0 ? "th" : "td", W = $ && $.type === "table" ? $.align : void 0, K = W ? W.length : J.children.length, G = -1, H = [];
  while (++G < K) {
    let q = J.children[G], U = {}, F = W ? W[G] : void 0;
    if (F)
      U.align = F;
    let E = { type: "element", tagName: Q, properties: U, children: [] };
    if (q)
      E.children = Z.all(q), Z.patch(q, E), E = Z.applyData(q, E);
    H.push(E);
  }
  let N = {
    type: "element",
    tagName: "tr",
    properties: {},
    children: Z.wrap(H, !0)
  };
  return Z.patch(J, N), Z.applyData(J, N);
}

// node_modules/mdast-util-to-hast/lib/handlers/table-cell.js
function XC0(Z, J) {
  let $ = {
    type: "element",
    tagName: "td",
    properties: {},
    children: Z.all(J)
  };
  return Z.patch(J, $), Z.applyData(J, $);
}

// node_modules/trim-lines/index.js
function QC0(Z) {
  let J = String(Z), $ = /\r?\n|\r/g, X = $.exec(J), Y = 0, Q = [];
  while (X)
    Q.push(YC0(J.slice(Y, X.index), Y > 0, !0), X[0]), Y = X.index + X[0].length, X = $.exec(J);
  return Q.push(YC0(J.slice(Y), Y > 0, !1)), Q.join("");
}
function YC0(Z, J, $) {
  let X = 0, Y = Z.length;
  if (J) {
    let Q = Z.codePointAt(X);
    while (Q === 9 || Q === 32)
      X++, Q = Z.codePointAt(X);
  }
  if ($) {
    let Q = Z.codePointAt(Y - 1);
    while (Q === 9 || Q === 32)
      Y--, Q = Z.codePointAt(Y - 1);
  }
  return Y > X ? Z.slice(X, Y) : "";
}

// node_modules/mdast-util-to-hast/lib/handlers/text.js
function WC0(Z, J) {
  let $ = { type: "text", value: QC0(String(J.value)) };
  return Z.patch(J, $), Z.applyData(J, $);
}

// node_modules/mdast-util-to-hast/lib/handlers/thematic-break.js
function KC0(Z, J) {
  let $ = {
    type: "element",
    tagName: "hr",
    properties: {},
    children: []
  };
  return Z.patch(J, $), Z.applyData(J, $);
}

// node_modules/mdast-util-to-hast/lib/handlers/index.js
var GC0 = {
  blockquote: bP0,
  break: xP0,
  code: yP0,
  delete: gP0,
  emphasis: mP0,
  footnoteReference: dP0,
  heading: pP0,
  html: uP0,
  imageReference: cP0,
  image: lP0,
  inlineCode: nP0,
  linkReference: iP0,
  link: oP0,
  listItem: sP0,
  list: rP0,
  paragraph: tP0,
  root: eP0,
  strong: ZC0,
  table: JC0,
  tableCell: XC0,
  tableRow: $C0,
  text: WC0,
  thematicBreak: KC0,
  toml: oy,
  yaml: oy,
  definition: oy,
  footnoteDefinition: oy
};
function oy() {
  return;
}

// node_modules/@ungap/structured-clone/esm/types.js
var sy = -1, CB = 0, kB = 1, vB = 2, oI = 3, sI = 4, aI = 5, rI = 6, ay = 7, ry = 8;

// node_modules/@ungap/structured-clone/esm/deserialize.js
var HC0 = typeof self === "object" ? self : globalThis, yD1 = (Z, J) => {
  let $ = (Y, Q) => {
    return Z.set(Q, Y), Y;
  }, X = (Y) => {
    if (Z.has(Y))
      return Z.get(Y);
    let [Q, W] = J[Y];
    switch (Q) {
      case CB:
      case sy:
        return $(W, Y);
      case kB: {
        let K = $([], Y);
        for (let G of W)
          K.push(X(G));
        return K;
      }
      case vB: {
        let K = $({}, Y);
        for (let [G, H] of W)
          K[X(G)] = X(H);
        return K;
      }
      case oI:
        return $(new Date(W), Y);
      case sI: {
        let { source: K, flags: G } = W;
        return $(new RegExp(K, G), Y);
      }
      case aI: {
        let K = $(/* @__PURE__ */ new Map, Y);
        for (let [G, H] of W)
          K.set(X(G), X(H));
        return K;
      }
      case rI: {
        let K = $(/* @__PURE__ */ new Set, Y);
        for (let G of W)
          K.add(X(G));
        return K;
      }
      case ay: {
        let { name: K, message: G } = W;
        return $(new HC0[K](G), Y);
      }
      case ry:
        return $(BigInt(W), Y);
      case "BigInt":
        return $(Object(BigInt(W)), Y);
    }
    return $(new HC0[Q](W), Y);
  };
  return X;
}, W20 = (Z) => yD1(/* @__PURE__ */ new Map, Z)(0);

// node_modules/@ungap/structured-clone/esm/serialize.js
var SB = "", { toString: gD1 } = {}, { keys: mD1 } = Object, tI = (Z) => {
  let J = typeof Z;
  if (J !== "object" || !Z)
    return [CB, J];
  let $ = gD1.call(Z).slice(8, -1);
  switch ($) {
    case "Array":
      return [kB, SB];
    case "Object":
      return [vB, SB];
    case "Date":
      return [oI, SB];
    case "RegExp":
      return [sI, SB];
    case "Map":
      return [aI, SB];
    case "Set":
      return [rI, SB];
  }
  if ($.includes("Array"))
    return [kB, $];
  if ($.includes("Error"))
    return [ay, $];
  return [vB, $];
}, ty = ([Z, J]) => Z === CB && (J === "function" || J === "symbol"), dD1 = (Z, J, $, X) => {
  let Y = (W, K) => {
    let G = X.push(W) - 1;
    return $.set(K, G), G;
  }, Q = (W) => {
    if ($.has(W))
      return $.get(W);
    let [K, G] = tI(W);
    switch (K) {
      case CB: {
        let N = W;
        switch (G) {
          case "bigint":
            K = ry, N = W.toString();
            break;
          case "function":
          case "symbol":
            if (Z)
              throw new TypeError("unable to serialize " + G);
            N = null;
            break;
          case "undefined":
            return Y([sy], W);
        }
        return Y([K, N], W);
      }
      case kB: {
        if (G)
          return Y([G, [...W]], W);
        let N = [], q = Y([K, N], W);
        for (let U of W)
          N.push(Q(U));
        return q;
      }
      case vB: {
        if (G)
          switch (G) {
            case "BigInt":
              return Y([G, W.toString()], W);
            case "Boolean":
            case "Number":
            case "String":
              return Y([G, W.valueOf()], W);
          }
        if (J && "toJSON" in W)
          return Q(W.toJSON());
        let N = [], q = Y([K, N], W);
        for (let U of mD1(W))
          if (Z || !ty(tI(W[U])))
            N.push([Q(U), Q(W[U])]);
        return q;
      }
      case oI:
        return Y([K, W.toISOString()], W);
      case sI: {
        let { source: N, flags: q } = W;
        return Y([K, { source: N, flags: q }], W);
      }
      case aI: {
        let N = [], q = Y([K, N], W);
        for (let [U, F] of W)
          if (Z || !(ty(tI(U)) || ty(tI(F))))
            N.push([Q(U), Q(F)]);
        return q;
      }
      case rI: {
        let N = [], q = Y([K, N], W);
        for (let U of W)
          if (Z || !ty(tI(U)))
            N.push(Q(U));
        return q;
      }
    }
    let { message: H } = W;
    return Y([K, { name: G, message: H }], W);
  };
  return Q;
}, K20 = (Z, { json: J, lossy: $ } = {}) => {
  let X = [];
  return dD1(!(J || $), !!J, /* @__PURE__ */ new Map, X)(Z), X;
};

// node_modules/@ungap/structured-clone/esm/index.js
var fB = typeof structuredClone === "function" ? (Z, J) => J && (("json" in J) || ("lossy" in J)) ? W20(K20(Z, J)) : structuredClone(Z) : (Z, J) => W20(K20(Z, J));

// node_modules/mdast-util-to-hast/lib/footer.js
function pD1(Z, J) {
  let $ = [{ type: "text", value: "↩" }];
  if (J > 1)
    $.push({
      type: "element",
      tagName: "sup",
      properties: {},
      children: [{ type: "text", value: String(J) }]
    });
  return $;
}
function uD1(Z, J) {
  return "Back to reference " + (Z + 1) + (J > 1 ? "-" + J : "");
}
function NC0(Z) {
  let J = typeof Z.options.clobberPrefix === "string" ? Z.options.clobberPrefix : "user-content-", $ = Z.options.footnoteBackContent || pD1, X = Z.options.footnoteBackLabel || uD1, Y = Z.options.footnoteLabel || "Footnotes", Q = Z.options.footnoteLabelTagName || "h2", W = Z.options.footnoteLabelProperties || {
    className: ["sr-only"]
  }, K = [], G = -1;
  while (++G < Z.footnoteOrder.length) {
    let H = Z.footnoteById.get(Z.footnoteOrder[G]);
    if (!H)
      continue;
    let N = Z.all(H), q = String(H.identifier).toUpperCase(), U = $G(q.toLowerCase()), F = 0, E = [], R = Z.footnoteCounts.get(q);
    while (R !== void 0 && ++F <= R) {
      if (E.length > 0)
        E.push({ type: "text", value: " " });
      let A = typeof $ === "string" ? $ : $(G, F);
      if (typeof A === "string")
        A = { type: "text", value: A };
      E.push({
        type: "element",
        tagName: "a",
        properties: {
          href: "#" + J + "fnref-" + U + (F > 1 ? "-" + F : ""),
          dataFootnoteBackref: "",
          ariaLabel: typeof X === "string" ? X : X(G, F),
          className: ["data-footnote-backref"]
        },
        children: Array.isArray(A) ? A : [A]
      });
    }
    let z = N[N.length - 1];
    if (z && z.type === "element" && z.tagName === "p") {
      let A = z.children[z.children.length - 1];
      if (A && A.type === "text")
        A.value += " ";
      else
        z.children.push({ type: "text", value: " " });
      z.children.push(...E);
    } else
      N.push(...E);
    let D = {
      type: "element",
      tagName: "li",
      properties: { id: J + "fn-" + U },
      children: Z.wrap(N, !0)
    };
    Z.patch(H, D), K.push(D);
  }
  if (K.length === 0)
    return;
  return {
    type: "element",
    tagName: "section",
    properties: { dataFootnotes: !0, className: ["footnotes"] },
    children: [
      {
        type: "element",
        tagName: Q,
        properties: {
          ...fB(W),
          id: "footnote-label"
        },
        children: [{ type: "text", value: Y }]
      },
      { type: "text", value: `
` },
      {
        type: "element",
        tagName: "ol",
        properties: {},
        children: Z.wrap(K, !0)
      },
      { type: "text", value: `
` }
    ]
  };
}

// node_modules/unist-util-is/lib/index.js
var VE = function(Z) {
  if (Z === null || Z === void 0)
    return iD1;
  if (typeof Z === "function")
    return ey(Z);
  if (typeof Z === "object")
    return Array.isArray(Z) ? cD1(Z) : lD1(Z);
  if (typeof Z === "string")
    return nD1(Z);
  throw new Error("Expected function, string, or object as test");
};
function cD1(Z) {
  let J = [], $ = -1;
  while (++$ < Z.length)
    J[$] = VE(Z[$]);
  return ey(X);
  function X(...Y) {
    let Q = -1;
    while (++Q < J.length)
      if (J[Q].apply(this, Y))
        return !0;
    return !1;
  }
}
function lD1(Z) {
  let J = Z;
  return ey($);
  function $(X) {
    let Y = X, Q;
    for (Q in Z)
      if (Y[Q] !== J[Q])
        return !1;
    return !0;
  }
}
function nD1(Z) {
  return ey(J);
  function J($) {
    return $ && $.type === Z;
  }
}
function ey(Z) {
  return J;
  function J($, X, Y) {
    return Boolean(oD1($) && Z.call(this, $, typeof X === "number" ? X : void 0, Y || void 0));
  }
}
function iD1() {
  return !0;
}
function oD1(Z) {
  return Z !== null && typeof Z === "object" && "type" in Z;
}
// node_modules/unist-util-visit-parents/lib/color.js
function qC0(Z) {
  return Z;
}

// node_modules/unist-util-visit-parents/lib/index.js
var FC0 = [], Zg = !0, K4 = !1, Jg = "skip";
function eI(Z, J, $, X) {
  let Y;
  if (typeof J === "function" && typeof $ !== "function")
    X = $, $ = J;
  else
    Y = J;
  let Q = VE(Y), W = X ? -1 : 1;
  K(Z, void 0, [])();
  function K(G, H, N) {
    let q = G && typeof G === "object" ? G : {};
    if (typeof q.type === "string") {
      let F = typeof q.tagName === "string" ? q.tagName : typeof q.name === "string" ? q.name : void 0;
      Object.defineProperty(U, "name", {
        value: "node (" + qC0(G.type + (F ? "<" + F + ">" : "")) + ")"
      });
    }
    return U;
    function U() {
      let F = FC0, E, R, z;
      if (!J || Q(G, H, N[N.length - 1] || void 0)) {
        if (F = sD1($(G, N)), F[0] === K4)
          return F;
      }
      if ("children" in G && G.children) {
        let D = G;
        if (D.children && F[0] !== Jg) {
          R = (X ? D.children.length : -1) + W, z = N.concat(D);
          while (R > -1 && R < D.children.length) {
            let A = D.children[R];
            if (E = K(A, R, z)(), E[0] === K4)
              return E;
            R = typeof E[1] === "number" ? E[1] : R + W;
          }
        }
      }
      return F;
    }
  }
}
function sD1(Z) {
  if (Array.isArray(Z))
    return Z;
  if (typeof Z === "number")
    return [Zg, Z];
  return Z === null || Z === void 0 ? FC0 : [Z];
}
// node_modules/unist-util-visit/lib/index.js
function G4(Z, J, $, X) {
  let Y, Q, W;
  if (typeof J === "function" && typeof $ !== "function")
    Q = void 0, W = J, Y = $;
  else
    Q = J, W = $, Y = X;
  eI(Z, Q, K, Y);
  function K(G, H) {
    let N = H[H.length - 1], q = N ? N.children.indexOf(G) : void 0;
    return W(G, q, N);
  }
}
// node_modules/mdast-util-to-hast/lib/state.js
var G20 = {}.hasOwnProperty, aD1 = {};
function LC0(Z, J) {
  let $ = J || aD1, X = /* @__PURE__ */ new Map, Y = /* @__PURE__ */ new Map, Q = /* @__PURE__ */ new Map, W = { ...GC0, ...$.handlers }, K = {
    all: H,
    applyData: tD1,
    definitionById: X,
    footnoteById: Y,
    footnoteCounts: Q,
    footnoteOrder: [],
    handlers: W,
    one: G,
    options: $,
    patch: rD1,
    wrap: ZM1
  };
  return G4(Z, function(N) {
    if (N.type === "definition" || N.type === "footnoteDefinition") {
      let q = N.type === "definition" ? X : Y, U = String(N.identifier).toUpperCase();
      if (!q.has(U))
        q.set(U, N);
    }
  }), K;
  function G(N, q) {
    let U = N.type, F = K.handlers[U];
    if (G20.call(K.handlers, U) && F)
      return F(K, N, q);
    if (K.options.passThrough && K.options.passThrough.includes(U)) {
      if ("children" in N) {
        let { children: R, ...z } = N, D = fB(z);
        return D.children = K.all(N), D;
      }
      return fB(N);
    }
    return (K.options.unknownHandler || eD1)(K, N, q);
  }
  function H(N) {
    let q = [];
    if ("children" in N) {
      let U = N.children, F = -1;
      while (++F < U.length) {
        let E = K.one(U[F], N);
        if (E) {
          if (F && U[F - 1].type === "break") {
            if (!Array.isArray(E) && E.type === "text")
              E.value = UC0(E.value);
            if (!Array.isArray(E) && E.type === "element") {
              let R = E.children[0];
              if (R && R.type === "text")
                R.value = UC0(R.value);
            }
          }
          if (Array.isArray(E))
            q.push(...E);
          else
            q.push(E);
        }
      }
    }
    return q;
  }
}
function rD1(Z, J) {
  if (Z.position)
    J.position = x10(Z);
}
function tD1(Z, J) {
  let $ = J;
  if (Z && Z.data) {
    let X = Z.data.hName, Y = Z.data.hChildren, Q = Z.data.hProperties;
    if (typeof X === "string")
      if ($.type === "element")
        $.tagName = X;
      else {
        let W = "children" in $ ? $.children : [$];
        $ = { type: "element", tagName: X, properties: {}, children: W };
      }
    if ($.type === "element" && Q)
      Object.assign($.properties, fB(Q));
    if ("children" in $ && $.children && Y !== null && Y !== void 0)
      $.children = Y;
  }
  return $;
}
function eD1(Z, J) {
  let $ = J.data || {}, X = "value" in J && !(G20.call($, "hProperties") || G20.call($, "hChildren")) ? { type: "text", value: J.value } : {
    type: "element",
    tagName: "div",
    properties: {},
    children: Z.all(J)
  };
  return Z.patch(J, X), Z.applyData(J, X);
}
function ZM1(Z, J) {
  let $ = [], X = -1;
  if (J)
    $.push({ type: "text", value: `
` });
  while (++X < Z.length) {
    if (X)
      $.push({ type: "text", value: `
` });
    $.push(Z[X]);
  }
  if (J && Z.length > 0)
    $.push({ type: "text", value: `
` });
  return $;
}
function UC0(Z) {
  let J = 0, $ = Z.charCodeAt(J);
  while ($ === 9 || $ === 32)
    J++, $ = Z.charCodeAt(J);
  return Z.slice(J);
}

// node_modules/mdast-util-to-hast/lib/index.js
function $g(Z, J) {
  let $ = LC0(Z, J), X = $.one(Z, void 0), Y = NC0($), Q = Array.isArray(X) ? { type: "root", children: X } : X || { type: "root", children: [] };
  if (Y)
    t0("children" in Q), Q.children.push({ type: "text", value: `
` }, Y);
  return Q;
}
// node_modules/remark-rehype/lib/index.js
function Xg(Z, J) {
  if (Z && "run" in Z)
    return async function($, X) {
      let Y = $g($, { file: X, ...J });
      await Z.run(Y, X);
    };
  return function($, X) {
    return $g($, { file: X, ...Z || J });
  };
}
// node_modules/bail/index.js
function H20(Z) {
  if (Z)
    throw Z;
}

// node_modules/unified/lib/index.js
var Wg = t2(wC0(), 1);

// node_modules/is-plain-obj/index.js
function ZP(Z) {
  if (typeof Z !== "object" || Z === null)
    return !1;
  let J = Object.getPrototypeOf(Z);
  return (J === null || J === Object.prototype || Object.getPrototypeOf(J) === null) && !(Symbol.toStringTag in Z) && !(Symbol.iterator in Z);
}

// node_modules/trough/lib/index.js
function N20() {
  let Z = [], J = { run: $, use: X };
  return J;
  function $(...Y) {
    let Q = -1, W = Y.pop();
    if (typeof W !== "function")
      throw new TypeError("Expected function as last argument, not " + W);
    K(null, ...Y);
    function K(G, ...H) {
      let N = Z[++Q], q = -1;
      if (G) {
        W(G);
        return;
      }
      while (++q < Y.length)
        if (H[q] === null || H[q] === void 0)
          H[q] = Y[q];
      if (Y = H, N)
        jC0(N, K)(...H);
      else
        W(null, ...H);
    }
  }
  function X(Y) {
    if (typeof Y !== "function")
      throw new TypeError("Expected `middelware` to be a function, not " + Y);
    return Z.push(Y), J;
  }
}
function jC0(Z, J) {
  let $;
  return X;
  function X(...W) {
    let K = Z.length > W.length, G;
    if (K)
      W.push(Y);
    try {
      G = Z.apply(this, W);
    } catch (H) {
      let N = H;
      if (K && $)
        throw N;
      return Y(N);
    }
    if (!K)
      if (G && G.then && typeof G.then === "function")
        G.then(Q, Y);
      else if (G instanceof Error)
        Y(G);
      else
        Q(G);
  }
  function Y(W, ...K) {
    if (!$)
      $ = !0, J(W, ...K);
  }
  function Q(W) {
    Y(null, W);
  }
}
// node_modules/vfile/lib/minpath.browser.js
var xH = { basename: JM1, dirname: $M1, extname: XM1, join: YM1, sep: "/" };
function JM1(Z, J) {
  if (J !== void 0 && typeof J !== "string")
    throw new TypeError('"ext" argument must be a string');
  JP(Z);
  let $ = 0, X = -1, Y = Z.length, Q;
  if (J === void 0 || J.length === 0 || J.length > Z.length) {
    while (Y--)
      if (Z.codePointAt(Y) === 47) {
        if (Q) {
          $ = Y + 1;
          break;
        }
      } else if (X < 0)
        Q = !0, X = Y + 1;
    return X < 0 ? "" : Z.slice($, X);
  }
  if (J === Z)
    return "";
  let W = -1, K = J.length - 1;
  while (Y--)
    if (Z.codePointAt(Y) === 47) {
      if (Q) {
        $ = Y + 1;
        break;
      }
    } else {
      if (W < 0)
        Q = !0, W = Y + 1;
      if (K > -1)
        if (Z.codePointAt(Y) === J.codePointAt(K--)) {
          if (K < 0)
            X = Y;
        } else
          K = -1, X = W;
    }
  if ($ === X)
    X = W;
  else if (X < 0)
    X = Z.length;
  return Z.slice($, X);
}
function $M1(Z) {
  if (JP(Z), Z.length === 0)
    return ".";
  let J = -1, $ = Z.length, X;
  while (--$)
    if (Z.codePointAt($) === 47) {
      if (X) {
        J = $;
        break;
      }
    } else if (!X)
      X = !0;
  return J < 0 ? Z.codePointAt(0) === 47 ? "/" : "." : J === 1 && Z.codePointAt(0) === 47 ? "//" : Z.slice(0, J);
}
function XM1(Z) {
  JP(Z);
  let J = Z.length, $ = -1, X = 0, Y = -1, Q = 0, W;
  while (J--) {
    let K = Z.codePointAt(J);
    if (K === 47) {
      if (W) {
        X = J + 1;
        break;
      }
      continue;
    }
    if ($ < 0)
      W = !0, $ = J + 1;
    if (K === 46) {
      if (Y < 0)
        Y = J;
      else if (Q !== 1)
        Q = 1;
    } else if (Y > -1)
      Q = -1;
  }
  if (Y < 0 || $ < 0 || Q === 0 || Q === 1 && Y === $ - 1 && Y === X + 1)
    return "";
  return Z.slice(Y, $);
}
function YM1(...Z) {
  let J = -1, $;
  while (++J < Z.length)
    if (JP(Z[J]), Z[J])
      $ = $ === void 0 ? Z[J] : $ + "/" + Z[J];
  return $ === void 0 ? "." : QM1($);
}
function QM1(Z) {
  JP(Z);
  let J = Z.codePointAt(0) === 47, $ = WM1(Z, !J);
  if ($.length === 0 && !J)
    $ = ".";
  if ($.length > 0 && Z.codePointAt(Z.length - 1) === 47)
    $ += "/";
  return J ? "/" + $ : $;
}
function WM1(Z, J) {
  let $ = "", X = 0, Y = -1, Q = 0, W = -1, K, G;
  while (++W <= Z.length) {
    if (W < Z.length)
      K = Z.codePointAt(W);
    else if (K === 47)
      break;
    else
      K = 47;
    if (K === 47) {
      if (Y === W - 1 || Q === 1)
        ;
      else if (Y !== W - 1 && Q === 2) {
        if ($.length < 2 || X !== 2 || $.codePointAt($.length - 1) !== 46 || $.codePointAt($.length - 2) !== 46) {
          if ($.length > 2) {
            if (G = $.lastIndexOf("/"), G !== $.length - 1) {
              if (G < 0)
                $ = "", X = 0;
              else
                $ = $.slice(0, G), X = $.length - 1 - $.lastIndexOf("/");
              Y = W, Q = 0;
              continue;
            }
          } else if ($.length > 0) {
            $ = "", X = 0, Y = W, Q = 0;
            continue;
          }
        }
        if (J)
          $ = $.length > 0 ? $ + "/.." : "..", X = 2;
      } else {
        if ($.length > 0)
          $ += "/" + Z.slice(Y + 1, W);
        else
          $ = Z.slice(Y + 1, W);
        X = W - Y - 1;
      }
      Y = W, Q = 0;
    } else if (K === 46 && Q > -1)
      Q++;
    else
      Q = -1;
  }
  return $;
}
function JP(Z) {
  if (typeof Z !== "string")
    throw new TypeError("Path must be a string. Received " + JSON.stringify(Z));
}

// node_modules/vfile/lib/minproc.browser.js
var TC0 = { cwd: KM1 };
function KM1() {
  return "/";
}

// node_modules/vfile/lib/minurl.shared.js
function hB(Z) {
  return Boolean(Z !== null && typeof Z === "object" && "href" in Z && Z.href && "protocol" in Z && Z.protocol && Z.auth === void 0);
}

// node_modules/vfile/lib/minurl.browser.js
function _C0(Z) {
  if (typeof Z === "string")
    Z = new URL(Z);
  else if (!hB(Z)) {
    let J = new TypeError('The "path" argument must be of type string or an instance of URL. Received `' + Z + "`");
    throw J.code = "ERR_INVALID_ARG_TYPE", J;
  }
  if (Z.protocol !== "file:") {
    let J = new TypeError("The URL must be of scheme file");
    throw J.code = "ERR_INVALID_URL_SCHEME", J;
  }
  return GM1(Z);
}
function GM1(Z) {
  if (Z.hostname !== "") {
    let X = new TypeError('File URL host must be "localhost" or empty on darwin');
    throw X.code = "ERR_INVALID_FILE_URL_HOST", X;
  }
  let J = Z.pathname, $ = -1;
  while (++$ < J.length)
    if (J.codePointAt($) === 37 && J.codePointAt($ + 1) === 50) {
      let X = J.codePointAt($ + 2);
      if (X === 70 || X === 102) {
        let Y = new TypeError("File URL path must not include encoded / characters");
        throw Y.code = "ERR_INVALID_FILE_URL_PATH", Y;
      }
    }
  return decodeURIComponent(J);
}

// node_modules/vfile/lib/index.js
var q20 = [
  "history",
  "path",
  "basename",
  "stem",
  "extname",
  "dirname"
];

class bB {
  constructor(Z) {
    let J;
    if (!Z)
      J = {};
    else if (hB(Z))
      J = { path: Z };
    else if (typeof Z === "string" || HM1(Z))
      J = { value: Z };
    else
      J = Z;
    this.cwd = "cwd" in J ? "" : TC0.cwd(), this.data = {}, this.history = [], this.messages = [], this.value, this.map, this.result, this.stored;
    let $ = -1;
    while (++$ < q20.length) {
      let Y = q20[$];
      if (Y in J && J[Y] !== void 0 && J[Y] !== null)
        this[Y] = Y === "history" ? [...J[Y]] : J[Y];
    }
    let X;
    for (X in J)
      if (!q20.includes(X))
        this[X] = J[X];
  }
  get basename() {
    return typeof this.path === "string" ? xH.basename(this.path) : void 0;
  }
  set basename(Z) {
    U20(Z, "basename"), F20(Z, "basename"), this.path = xH.join(this.dirname || "", Z);
  }
  get dirname() {
    return typeof this.path === "string" ? xH.dirname(this.path) : void 0;
  }
  set dirname(Z) {
    VC0(this.basename, "dirname"), this.path = xH.join(Z || "", this.basename);
  }
  get extname() {
    return typeof this.path === "string" ? xH.extname(this.path) : void 0;
  }
  set extname(Z) {
    if (F20(Z, "extname"), VC0(this.dirname, "extname"), Z) {
      if (Z.codePointAt(0) !== 46)
        throw new Error("`extname` must start with `.`");
      if (Z.includes(".", 1))
        throw new Error("`extname` cannot contain multiple dots");
    }
    this.path = xH.join(this.dirname, this.stem + (Z || ""));
  }
  get path() {
    return this.history[this.history.length - 1];
  }
  set path(Z) {
    if (hB(Z))
      Z = _C0(Z);
    if (U20(Z, "path"), this.path !== Z)
      this.history.push(Z);
  }
  get stem() {
    return typeof this.path === "string" ? xH.basename(this.path, this.extname) : void 0;
  }
  set stem(Z) {
    U20(Z, "stem"), F20(Z, "stem"), this.path = xH.join(this.dirname || "", Z + (this.extname || ""));
  }
  fail(Z, J, $) {
    let X = this.message(Z, J, $);
    throw X.fatal = !0, X;
  }
  info(Z, J, $) {
    let X = this.message(Z, J, $);
    return X.fatal = void 0, X;
  }
  message(Z, J, $) {
    let X = new HX(Z, J, $);
    if (this.path)
      X.name = this.path + ":" + X.name, X.file = this.path;
    return X.fatal = !1, this.messages.push(X), X;
  }
  toString(Z) {
    if (this.value === void 0)
      return "";
    if (typeof this.value === "string")
      return this.value;
    return new TextDecoder(Z || void 0).decode(this.value);
  }
}
function F20(Z, J) {
  if (Z && Z.includes(xH.sep))
    throw new Error("`" + J + "` cannot be a path: did not expect `" + xH.sep + "`");
}
function U20(Z, J) {
  if (!Z)
    throw new Error("`" + J + "` cannot be empty");
}
function VC0(Z, J) {
  if (!Z)
    throw new Error("Setting `" + J + "` requires `path` to be set too");
}
function HM1(Z) {
  return Boolean(Z && typeof Z === "object" && "byteLength" in Z && "byteOffset" in Z);
}
// node_modules/unified/lib/callable-instance.js
var IC0 = function(Z) {
  let X = this.constructor.prototype, Y = X[Z], Q = function() {
    return Y.apply(Q, arguments);
  };
  return Object.setPrototypeOf(Q, X), Q;
};

// node_modules/unified/lib/index.js
var NM1 = {}.hasOwnProperty;

class O20 extends IC0 {
  constructor() {
    super("copy");
    this.Compiler = void 0, this.Parser = void 0, this.attachers = [], this.compiler = void 0, this.freezeIndex = -1, this.frozen = void 0, this.namespace = {}, this.parser = void 0, this.transformers = N20();
  }
  copy() {
    let Z = new O20, J = -1;
    while (++J < this.attachers.length) {
      let $ = this.attachers[J];
      Z.use(...$);
    }
    return Z.data(Wg.default(!0, {}, this.namespace)), Z;
  }
  data(Z, J) {
    if (typeof Z === "string") {
      if (arguments.length === 2)
        return E20("data", this.frozen), this.namespace[Z] = J, this;
      return NM1.call(this.namespace, Z) && this.namespace[Z] || void 0;
    }
    if (Z)
      return E20("data", this.frozen), this.namespace = Z, this;
    return this.namespace;
  }
  freeze() {
    if (this.frozen)
      return this;
    let Z = this;
    while (++this.freezeIndex < this.attachers.length) {
      let [J, ...$] = this.attachers[this.freezeIndex];
      if ($[0] === !1)
        continue;
      if ($[0] === !0)
        $[0] = void 0;
      let X = J.call(Z, ...$);
      if (typeof X === "function")
        this.transformers.use(X);
    }
    return this.frozen = !0, this.freezeIndex = Number.POSITIVE_INFINITY, this;
  }
  parse(Z) {
    this.freeze();
    let J = Qg(Z), $ = this.parser || this.Parser;
    return L20("parse", $), $(String(J), J);
  }
  process(Z, J) {
    let $ = this;
    return this.freeze(), L20("process", this.parser || this.Parser), R20("process", this.compiler || this.Compiler), J ? X(void 0, J) : new Promise(X);
    function X(Y, Q) {
      let W = Qg(Z), K = $.parse(W);
      $.run(K, W, function(H, N, q) {
        if (H || !N || !q)
          return G(H);
        let U = N, F = $.stringify(U, q);
        if (FM1(F))
          q.value = F;
        else
          q.result = F;
        G(H, q);
      });
      function G(H, N) {
        if (H || !N)
          Q(H);
        else if (Y)
          Y(N);
        else
          t0(J, "`done` is defined if `resolve` is not"), J(void 0, N);
      }
    }
  }
  processSync(Z) {
    let J = !1, $;
    return this.freeze(), L20("processSync", this.parser || this.Parser), R20("processSync", this.compiler || this.Compiler), this.process(Z, X), CC0("processSync", "process", J), t0($, "we either bailed on an error or have a tree"), $;
    function X(Y, Q) {
      J = !0, H20(Y), $ = Q;
    }
  }
  run(Z, J, $) {
    PC0(Z), this.freeze();
    let X = this.transformers;
    if (!$ && typeof J === "function")
      $ = J, J = void 0;
    return $ ? Y(void 0, $) : new Promise(Y);
    function Y(Q, W) {
      t0(typeof J !== "function", "`file` can’t be a `done` anymore, we checked");
      let K = Qg(J);
      X.run(Z, K, G);
      function G(H, N, q) {
        let U = N || Z;
        if (H)
          W(H);
        else if (Q)
          Q(U);
        else
          t0($, "`done` is defined if `resolve` is not"), $(void 0, U, q);
      }
    }
  }
  runSync(Z, J) {
    let $ = !1, X;
    return this.run(Z, J, Y), CC0("runSync", "run", $), t0(X, "we either bailed on an error or have a tree"), X;
    function Y(Q, W) {
      H20(Q), X = W, $ = !0;
    }
  }
  stringify(Z, J) {
    this.freeze();
    let $ = Qg(J), X = this.compiler || this.Compiler;
    return R20("stringify", X), PC0(Z), X(Z, $);
  }
  use(Z, ...J) {
    let $ = this.attachers, X = this.namespace;
    if (E20("use", this.frozen), Z === null || Z === void 0)
      ;
    else if (typeof Z === "function")
      K(Z, J);
    else if (typeof Z === "object")
      if (Array.isArray(Z))
        W(Z);
      else
        Q(Z);
    else
      throw new TypeError("Expected usable value, not `" + Z + "`");
    return this;
    function Y(G) {
      if (typeof G === "function")
        K(G, []);
      else if (typeof G === "object")
        if (Array.isArray(G)) {
          let [H, ...N] = G;
          K(H, N);
        } else
          Q(G);
      else
        throw new TypeError("Expected usable value, not `" + G + "`");
    }
    function Q(G) {
      if (!("plugins" in G) && !("settings" in G))
        throw new Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");
      if (W(G.plugins), G.settings)
        X.settings = Wg.default(!0, X.settings, G.settings);
    }
    function W(G) {
      let H = -1;
      if (G === null || G === void 0)
        ;
      else if (Array.isArray(G))
        while (++H < G.length) {
          let N = G[H];
          Y(N);
        }
      else
        throw new TypeError("Expected a list of plugins, not `" + G + "`");
    }
    function K(G, H) {
      let N = -1, q = -1;
      while (++N < $.length)
        if ($[N][0] === G) {
          q = N;
          break;
        }
      if (q === -1)
        $.push([G, ...H]);
      else if (H.length > 0) {
        let [U, ...F] = H, E = $[q][1];
        if (ZP(E) && ZP(U))
          U = Wg.default(!0, E, U);
        $[q] = [G, U, ...F];
      }
    }
  }
}
var z20 = new O20().freeze();
function L20(Z, J) {
  if (typeof J !== "function")
    throw new TypeError("Cannot `" + Z + "` without `parser`");
}
function R20(Z, J) {
  if (typeof J !== "function")
    throw new TypeError("Cannot `" + Z + "` without `compiler`");
}
function E20(Z, J) {
  if (J)
    throw new Error("Cannot call `" + Z + "` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.");
}
function PC0(Z) {
  if (!ZP(Z) || typeof Z.type !== "string")
    throw new TypeError("Expected node, got `" + Z + "`");
}
function CC0(Z, J, $) {
  if (!$)
    throw new Error("`" + Z + "` finished async. Use `" + J + "` instead");
}
function Qg(Z) {
  return qM1(Z) ? Z : new bB(Z);
}
function qM1(Z) {
  return Boolean(Z && typeof Z === "object" && "message" in Z && "messages" in Z);
}
function FM1(Z) {
  return typeof Z === "string" || UM1(Z);
}
function UM1(Z) {
  return Boolean(Z && typeof Z === "object" && "byteLength" in Z && "byteOffset" in Z);
}
// node_modules/react-markdown/lib/index.js
var LM1 = "https://github.com/remarkjs/react-markdown/blob/main/changelog.md", kC0 = [], vC0 = { allowDangerousHtml: !0 }, RM1 = /^(https?|ircs?|mailto|xmpp)$/i, EM1 = [
  { from: "astPlugins", id: "remove-buggy-html-in-markdown-parser" },
  { from: "allowDangerousHtml", id: "remove-buggy-html-in-markdown-parser" },
  {
    from: "allowNode",
    id: "replace-allownode-allowedtypes-and-disallowedtypes",
    to: "allowElement"
  },
  {
    from: "allowedTypes",
    id: "replace-allownode-allowedtypes-and-disallowedtypes",
    to: "allowedElements"
  },
  { from: "className", id: "remove-classname" },
  {
    from: "disallowedTypes",
    id: "replace-allownode-allowedtypes-and-disallowedtypes",
    to: "disallowedElements"
  },
  { from: "escapeHtml", id: "remove-buggy-html-in-markdown-parser" },
  { from: "includeElementIndex", id: "#remove-includeelementindex" },
  {
    from: "includeNodeIndex",
    id: "change-includenodeindex-to-includeelementindex"
  },
  { from: "linkTarget", id: "remove-linktarget" },
  { from: "plugins", id: "change-plugins-to-remarkplugins", to: "remarkPlugins" },
  { from: "rawSourcePos", id: "#remove-rawsourcepos" },
  { from: "renderers", id: "change-renderers-to-components", to: "components" },
  { from: "source", id: "change-source-to-children", to: "children" },
  { from: "sourcePos", id: "#remove-sourcepos" },
  { from: "transformImageUri", id: "#add-urltransform", to: "urlTransform" },
  { from: "transformLinkUri", id: "#add-urltransform", to: "urlTransform" }
];
function $P(Z) {
  let J = OM1(Z), $ = zM1(Z);
  return DM1(J.runSync(J.parse($), $), Z);
}
function OM1(Z) {
  let J = Z.rehypePlugins || kC0, $ = Z.remarkPlugins || kC0, X = Z.remarkRehypeOptions ? { ...Z.remarkRehypeOptions, ...vC0 } : vC0;
  return z20().use(ny).use($).use(Xg, X).use(J);
}
function zM1(Z) {
  let J = Z.children || "", $ = new bB;
  if (typeof J === "string")
    $.value = J;
  else
    _y("Unexpected value `" + J + "` for `children` prop, expected `string`");
  return $;
}
function DM1(Z, J) {
  let { allowedElements: $, allowElement: X, components: Y, disallowedElements: Q, skipHtml: W, unwrapDisallowed: K } = J, G = J.urlTransform || fC0;
  for (let N of EM1)
    if (Object.hasOwn(J, N.from))
      _y("Unexpected `" + N.from + "` prop, " + (N.to ? "use `" + N.to + "` instead" : "remove it") + " (see <" + LM1 + "#" + N.id + "> for more info)");
  if ($ && Q)
    _y("Unexpected combined `allowedElements` and `disallowedElements`, expected one or the other");
  return G4(Z, H), m10(Z, {
    Fragment: xB.Fragment,
    components: Y,
    ignoreInvalidStyle: !0,
    jsx: xB.jsx,
    jsxs: xB.jsxs,
    passKeys: !0,
    passNode: !0
  });
  function H(N, q, U) {
    if (N.type === "raw" && U && typeof q === "number") {
      if (W)
        U.children.splice(q, 1);
      else
        U.children[q] = { type: "text", value: N.value };
      return q;
    }
    if (N.type === "element") {
      let F;
      for (F in pI)
        if (Object.hasOwn(pI, F) && Object.hasOwn(N.properties, F)) {
          let E = N.properties[F], R = pI[F];
          if (R === null || R.includes(N.tagName))
            N.properties[F] = G(String(E || ""), F, N);
        }
    }
    if (N.type === "element") {
      let F = $ ? !$.includes(N.tagName) : Q ? Q.includes(N.tagName) : !1;
      if (!F && X && typeof q === "number")
        F = !X(N, q, U);
      if (F && U && typeof q === "number") {
        if (K && N.children)
          U.children.splice(q, 1, ...N.children);
        else
          U.children.splice(q, 1);
        return q;
      }
    }
  }
}
function fC0(Z) {
  let J = Z.indexOf(":"), $ = Z.indexOf("?"), X = Z.indexOf("#"), Y = Z.indexOf("/");
  if (J === -1 || Y !== -1 && J > Y || $ !== -1 && J > $ || X !== -1 && J > X || RM1.test(Z.slice(0, J)))
    return Z;
  return "";
}
// node_modules/molstar/lib/mol-plugin-ui/state/animation.js
var VU = t2(PZ(), 1);
class D20 extends I8 {
  constructor() {
    super(...arguments);
    this.updateParams = (Z) => {
      this.plugin.managers.animation.updateParams({ [Z.name]: Z.value });
    }, this.updateCurrentParams = (Z) => {
      this.plugin.managers.animation.updateCurrentParams({ [Z.name]: Z.value });
    }, this.startOrStop = () => {
      let Z = this.plugin.managers.animation;
      if (Z.state.animationState === "playing")
        Z.stop();
      else {
        if (this.props.onStart)
          this.props.onStart();
        Z.start();
      }
    };
  }
  componentDidMount() {
    this.subscribe(this.plugin.managers.animation.events.updated, () => this.forceUpdate());
  }
  render() {
    var Z, J;
    let $ = this.plugin.managers.animation;
    if ($.isEmpty)
      return null;
    let X = $.state.animationState === "playing", Y = (J = (Z = $.current.anim).canApply) === null || J === void 0 ? void 0 : J.call(Z, this.plugin);
    return VU.jsxs(VU.Fragment, { children: [VU.jsx(iZ, { params: $.getParams(), values: $.state.params, onChange: this.updateParams, isDisabled: X }), VU.jsx(iZ, { params: $.current.params, values: $.current.paramValues, onChange: this.updateCurrentParams, isDisabled: X }), VU.jsx("div", { className: "msp-flex-row", children: VU.jsx(Z8, { icon: $.state.animationState !== "playing" ? void 0 : Fy, onClick: this.startOrStop, disabled: Y !== void 0 && Y.canApply === !1, children: $.state.animationState === "playing" ? "Stop" : Y === void 0 || Y.canApply ? "Start" : Y.reason || "Start" }) })] });
  }
}

// node_modules/molstar/lib/mol-plugin-ui/structure/components.js
var x6 = t2(PZ(), 1);

// node_modules/molstar/lib/mol-plugin-state/helpers/structure-overpaint.js
var bC0 = "overpaint-controls";
async function M20(Z, J, $, X, Y) {
  await MM1(Z, J, async (Q, W, K) => {
    if (Y && Y.length > 0 && !Y.includes(W.params.values.type.name))
      return;
    let G = W.obj.data.sourceData, H = await X(G.root);
    if (d2.isEmpty(H) || _7(H))
      return;
    let N = {
      bundle: W0.Bundle.fromLoci(H),
      color: $ === -1 ? i0(0) : $,
      clear: $ === -1
    };
    if (K) {
      let q = [...K.params.values.layers, N], U = hC0(q, G);
      Q.to(K).update(rJ.toBundle(U));
    } else {
      let q = hC0([N], G);
      Q.to(W.transform.ref).apply(H1.Representation.OverpaintStructureRepresentation3DFromBundle, rJ.toBundle(q), { tags: bC0 });
    }
  });
}
async function MM1(Z, J, $) {
  let X = Z.state.data, Y = X.build();
  for (let Q of J)
    for (let W of Q.representations) {
      let K = X.select(f2.Generators.ofTransformer(H1.Representation.OverpaintStructureRepresentation3DFromBundle, W.cell.transform.ref).withTag(bC0));
      await $(Y, W.cell, K[0]);
    }
  return Y.commit({ doNotUpdateCurrent: !0 });
}
function hC0(Z, J) {
  let $ = rJ.ofBundle(Z, J.root), X = rJ.merge($);
  return rJ.filter(X, J);
}

// node_modules/molstar/lib/mol-plugin-state/helpers/structure-clipping.js
var yC0 = "clipping-controls";
async function gC0(Z, J, $, X, Y) {
  await AM1(Z, J, async (Q, W, K) => {
    if (Y && Y.length > 0 && !Y.includes(W.params.values.type.name))
      return;
    let G = W.obj.data.sourceData, H = await X(G.root);
    if (d2.isEmpty(H) || _7(H))
      return;
    let N = {
      bundle: W0.Bundle.fromLoci(H),
      groups: $
    };
    if (K) {
      let q = [...K.params.values.layers, N], U = xC0(q, G);
      Q.to(K).update($9.toBundle(U));
    } else {
      let q = xC0([N], G);
      Q.to(W.transform.ref).apply(H1.Representation.ClippingStructureRepresentation3DFromBundle, $9.toBundle(q), { tags: yC0 });
    }
  });
}
async function AM1(Z, J, $) {
  let X = Z.state.data, Y = X.build();
  for (let Q of J)
    for (let W of Q.representations) {
      let K = X.select(f2.Generators.ofTransformer(H1.Representation.ClippingStructureRepresentation3DFromBundle, W.cell.transform.ref).withTag(yC0));
      await $(Y, W.cell, K[0]);
    }
  return Y.commit({ doNotUpdateCurrent: !0 });
}
function xC0(Z, J) {
  let $ = $9.ofBundle(Z, J.root), X = $9.merge($);
  return $9.filter(X, J);
}

// node_modules/molstar/lib/mol-plugin-state/helpers/structure-transparency.js
var dC0 = "transparency-controls";
async function pC0(Z, J, $, X, Y) {
  await BM1(Z, J, async (Q, W, K) => {
    if (Y && Y.length > 0 && !Y.includes(W.params.values.type.name))
      return;
    let G = W.obj.data.sourceData, H = await X(G.root);
    if (d2.isEmpty(H) || _7(H))
      return;
    let N = {
      bundle: W0.Bundle.fromLoci(H),
      value: $
    };
    if (K) {
      let q = [...K.params.values.layers, N], U = mC0(q, G);
      Q.to(K).update(tJ.toBundle(U));
    } else {
      let q = mC0([N], G);
      Q.to(W.transform.ref).apply(H1.Representation.TransparencyStructureRepresentation3DFromBundle, tJ.toBundle(q), { tags: dC0 });
    }
  });
}
async function BM1(Z, J, $) {
  let X = Z.state.data, Y = X.build();
  for (let Q of J)
    for (let W of Q.representations) {
      let K = X.select(f2.Generators.ofTransformer(H1.Representation.TransparencyStructureRepresentation3DFromBundle, W.cell.transform.ref).withTag(dC0));
      await $(Y, W.cell, K[0]);
    }
  return Y.commit({ doNotUpdateCurrent: !0 });
}
function mC0(Z, J) {
  let $ = tJ.ofBundle(Z, J.root), X = tJ.merge($);
  return tJ.filter(X, J);
}

// node_modules/molstar/lib/mol-plugin-state/helpers/structure-substance.js
var cC0 = "substance-controls";
async function A20(Z, J, $, X, Y) {
  await wM1(Z, J, async (Q, W, K) => {
    if (Y && Y.length > 0 && !Y.includes(W.params.values.type.name))
      return;
    let G = W.obj.data.sourceData, H = await X(G.root);
    if (d2.isEmpty(H) || _7(H))
      return;
    let N = {
      bundle: W0.Bundle.fromLoci(H),
      material: $ !== null && $ !== void 0 ? $ : C7(),
      clear: !$
    };
    if (K) {
      let q = [...K.params.values.layers, N], U = uC0(q, G);
      Q.to(K).update(eJ.toBundle(U));
    } else {
      let q = uC0([N], G);
      Q.to(W.transform.ref).apply(H1.Representation.SubstanceStructureRepresentation3DFromBundle, eJ.toBundle(q), { tags: cC0 });
    }
  });
}
async function wM1(Z, J, $) {
  let X = Z.state.data, Y = X.build();
  for (let Q of J)
    for (let W of Q.representations) {
      let K = X.select(f2.Generators.ofTransformer(H1.Representation.SubstanceStructureRepresentation3DFromBundle, W.cell.transform.ref).withTag(cC0));
      await $(Y, W.cell, K[0]);
    }
  return Y.commit({ doNotUpdateCurrent: !0 });
}
function uC0(Z, J) {
  let $ = eJ.ofBundle(Z, J.root), X = eJ.merge($);
  return eJ.filter(X, J);
}

// node_modules/molstar/lib/mol-plugin-state/helpers/structure-emissive.js
var nC0 = "emissive-controls";
async function iC0(Z, J, $, X, Y) {
  await jM1(Z, J, async (Q, W, K) => {
    if (Y && Y.length > 0 && !Y.includes(W.params.values.type.name))
      return;
    let G = W.obj.data.sourceData, H = await X(G.root);
    if (d2.isEmpty(H) || _7(H))
      return;
    let N = {
      bundle: W0.Bundle.fromLoci(H),
      value: $
    };
    if (K) {
      let q = [...K.params.values.layers, N], U = lC0(q, G);
      Q.to(K).update(Z$.toBundle(U));
    } else {
      let q = lC0([N], G);
      Q.to(W.transform.ref).apply(H1.Representation.EmissiveStructureRepresentation3DFromBundle, Z$.toBundle(q), { tags: nC0 });
    }
  });
}
async function jM1(Z, J, $) {
  let X = Z.state.data, Y = X.build();
  for (let Q of J)
    for (let W of Q.representations) {
      let K = X.select(f2.Generators.ofTransformer(H1.Representation.EmissiveStructureRepresentation3DFromBundle, W.cell.transform.ref).withTag(nC0));
      await $(Y, W.cell, K[0]);
    }
  return Y.commit({ doNotUpdateCurrent: !0 });
}
function lC0(Z, J) {
  let $ = Z$.ofBundle(Z, J.root), X = Z$.merge($);
  return Z$.filter(X, J);
}

// node_modules/molstar/lib/mol-plugin-state/manager/structure/component.js
class XG extends pX {
  get currentStructures() {
    return this.plugin.managers.structure.hierarchy.selection.structures;
  }
  get pivotStructure() {
    return this.currentStructures[0];
  }
  _setSnapshotState(Z) {
    this.updateState({ options: Z }), this.events.optionsUpdated.next(void 0);
  }
  async setOptions(Z) {
    let J = Z.interactions !== this.state.options.interactions;
    this.updateState({ options: Z }), this.events.optionsUpdated.next(void 0);
    let $ = this.dataState.build();
    for (let X of this.currentStructures)
      for (let Y of X.components)
        this.updateReprParams($, Y);
    return this.plugin.dataTransaction(async () => {
      if (await $.commit(), await this.plugin.state.updateBehavior(lz, (X) => {
        X.ignoreHydrogens = Z.hydrogens !== "all", X.ignoreHydrogensVariant = Z.hydrogens === "only-polar" ? "non-polar" : "all", X.ignoreLight = Z.ignoreLight, X.material = Z.materialStyle, X.clip = Z.clipObjects, X.interior = Z.interior;
      }), J)
        await this.updateInterationProps();
    });
  }
  updateReprParams(Z, J) {
    let { hydrogens: $, visualQuality: X, ignoreLight: Y, materialStyle: Q, clipObjects: W, interior: K } = this.state.options, G = $ !== "all", H = $ === "only-polar" ? "non-polar" : "all";
    for (let N of J.representations) {
      if (N.cell.transform.transformer !== lA)
        continue;
      let q = N.cell.transform.params;
      if (!!q.type.params.ignoreHydrogens !== G || q.type.params.ignoreHydrogensVariant !== H || q.type.params.quality !== X || q.type.params.ignoreLight !== Y || !C7.areEqual(q.type.params.material, Q) || !j.areEqual(FH.Params, q.type.params.clip, W) || !AE0(q.type.params.interior, K))
        Z.to(N.cell).update((U) => {
          U.type.params.ignoreHydrogens = G, U.type.params.ignoreHydrogensVariant = H, U.type.params.quality = X, U.type.params.ignoreLight = Y, U.type.params.material = Q, U.type.params.clip = W, U.type.params.interior = K;
        });
    }
  }
  async updateInterationProps() {
    var Z, J, $;
    for (let X of this.currentStructures) {
      let Y = H7.getParams((Z = X.cell.obj) === null || Z === void 0 ? void 0 : Z.data);
      if (X.properties) {
        let Q = (J = X.properties.cell.transform.params) === null || J === void 0 ? void 0 : J.properties[H7.descriptor.name];
        if (j.areEqual(Y, Q, this.state.options.interactions))
          continue;
        await this.dataState.build().to(X.properties.cell).update((W) => {
          W.properties[H7.descriptor.name] = this.state.options.interactions;
        }).commit();
      } else {
        let Q = this.plugin.customStructureProperties.getParams(($ = X.cell.obj) === null || $ === void 0 ? void 0 : $.data), W = j.getDefaultValues(Q);
        if (j.areEqual(Y, W.properties[H7.descriptor.name], this.state.options.interactions))
          continue;
        W.properties[H7.descriptor.name] = this.state.options.interactions, await this.plugin.builders.structure.insertStructureProperties(X.cell, W);
      }
    }
  }
  applyPreset(Z, J, $) {
    return this.plugin.dataTransaction(async () => {
      for (let X of Z) {
        let Y = await this.plugin.builders.structure.representation.applyPreset(X.cell, J, $);
        await this.syncPreset(X, Y);
      }
    }, { canUndo: "Preset" });
  }
  syncPreset(Z, J) {
    if (!J || !J.components)
      return this.clearComponents([Z]);
    let $ = /* @__PURE__ */ new Set;
    if (B7(J.components, (W) => {
      if (W)
        $.add(W.ref);
    }), J.representations)
      B7(J.representations, (W) => {
        if (W)
          $.add(W.ref);
      });
    if ($.size === 0)
      return this.clearComponents([Z]);
    let X = !1, Y = this.dataState.build(), Q = (W) => {
      if (!$.has(W.cell.transform.ref))
        X = !0, Y.delete(W.cell);
    };
    for (let W of Z.components) {
      Q(W);
      for (let K of W.representations)
        Q(K);
      if (W.genericRepresentations)
        for (let K of W.genericRepresentations)
          Q(K);
    }
    if (Z.genericRepresentations)
      for (let W of Z.genericRepresentations)
        Q(W);
    if (X)
      return Y.commit();
  }
  clear(Z) {
    return this.clearComponents(Z);
  }
  selectThis(Z) {
    var J;
    let $ = this.plugin.managers.structure.selection;
    $.clear();
    for (let X of Z) {
      let Y = s0.toSubStructureElementLoci(X.structure.cell.obj.data, (J = X.cell.obj) === null || J === void 0 ? void 0 : J.data);
      $.fromLoci("set", Y);
    }
  }
  canBeModified(Z) {
    return this.plugin.builders.structure.isComponentTransform(Z.cell);
  }
  modifyByCurrentSelection(Z, J) {
    return this.plugin.runTask(n0.create("Modify Component", async ($) => {
      let X = this.dataState.build();
      for (let Y of Z) {
        if (!this.canBeModified(Y))
          continue;
        let Q = this.plugin.managers.structure.selection.getStructure(Y.structure.cell.obj.data);
        if (!Q || Q.elementCount === 0)
          continue;
        this.modifyComponent(X, Y, Q, J);
      }
      await this.dataState.updateTree(X, { canUndo: "Modify Selection" }).runInContext($);
    }));
  }
  toggleVisibility(Z, J) {
    if (Z.length === 0)
      return;
    if (!J) {
      let $ = !Z[0].cell.state.isHidden;
      for (let X of Z)
        _H(this.dataState, X.cell.transform.ref, $);
    } else {
      let $ = Z[0].representations.indexOf(J), X = !J.cell.state.isHidden;
      for (let Y of Z) {
        let Q = Y.representations[$];
        if (!Q)
          continue;
        _H(this.dataState, Q.cell.transform.ref, X);
      }
    }
  }
  removeRepresentations(Z, J) {
    if (Z.length === 0)
      return;
    let $ = [];
    if (J) {
      let X = Z[0].representations.indexOf(J);
      if (X < 0)
        return;
      for (let Y of Z)
        if (Y.representations[X])
          $.push(Y.representations[X]);
    } else
      for (let X of Z)
        for (let Y of X.representations)
          $.push(Y);
    return this.plugin.managers.structure.hierarchy.remove($, !0);
  }
  updateRepresentations(Z, J, $) {
    if (Z.length === 0)
      return Promise.resolve();
    let X = Z[0].representations.indexOf(J);
    if (X < 0)
      return Promise.resolve();
    let Y = this.dataState.build();
    for (let Q of Z) {
      let W = Q.representations[X];
      if (!W)
        continue;
      if (W.cell.transform.transformer !== J.cell.transform.transformer)
        continue;
      Y.to(W.cell).update($);
    }
    return Y.commit({ canUndo: "Update Representation" });
  }
  updateRepresentationsTheme(Z, J) {
    var $, X, Y, Q;
    if (Z.length === 0)
      return;
    let W = this.dataState.build();
    for (let K of Z)
      for (let G of K.representations) {
        let H = G.cell.transform.params, N = typeof J === "function" ? J(K, G) : J, q = N.color === "default" ? MI(this.plugin, ($ = K.structure.cell.obj) === null || $ === void 0 ? void 0 : $.data, H === null || H === void 0 ? void 0 : H.type.name) : N.color ? MI(this.plugin, (X = K.structure.cell.obj) === null || X === void 0 ? void 0 : X.data, H === null || H === void 0 ? void 0 : H.type.name, N.color, N.colorParams) : void 0, U = N.size === "default" ? i00(this.plugin, (Y = K.structure.cell.obj) === null || Y === void 0 ? void 0 : Y.data, H === null || H === void 0 ? void 0 : H.type.name) : N.color ? i00(this.plugin, (Q = K.structure.cell.obj) === null || Q === void 0 ? void 0 : Q.data, H === null || H === void 0 ? void 0 : H.type.name, N.size, N.sizeParams) : void 0;
        if (q || U)
          W.to(G.cell).update((F) => {
            if (q)
              F.colorTheme = q;
            if (U)
              F.sizeTheme = U;
          });
      }
    return W.commit({ canUndo: "Update Theme" });
  }
  addRepresentation(Z, J) {
    if (Z.length === 0)
      return;
    let { hydrogens: $, visualQuality: X, ignoreLight: Y, materialStyle: Q, clipObjects: W, interior: K } = this.state.options, N = { ignoreHydrogens: $ !== "all", ignoreHydrogensVariant: $ === "only-polar" ? "non-polar" : "all", quality: X, ignoreLight: Y, material: Q, clip: W, interior: K };
    return this.plugin.dataTransaction(async () => {
      for (let q of Z)
        await this.plugin.builders.structure.representation.addRepresentation(q.cell, {
          type: this.plugin.representation.structure.registry.get(J),
          typeParams: N
        });
    }, { canUndo: "Add Representation" });
  }
  tryFindComponent(Z, J) {
    if (Z.components.length === 0)
      return;
    return this.plugin.runTask(n0.create("Find Component", async ($) => {
      var X, Y;
      let Q = (X = Z.cell.obj) === null || X === void 0 ? void 0 : X.data;
      if (!Q)
        return;
      let W = f1.unionStructure(await J.getSelection(this.plugin, $, Q));
      for (let K of Z.components) {
        let G = (Y = K.cell.obj) === null || Y === void 0 ? void 0 : Y.data;
        if (!G || !K.cell.parent)
          continue;
        if (qq0(W, G))
          return K.cell;
      }
    }));
  }
  async add(Z, J) {
    return this.plugin.dataTransaction(async () => {
      let $ = J || this.currentStructures;
      if ($.length === 0)
        return;
      let { hydrogens: X, visualQuality: Y, ignoreLight: Q, materialStyle: W, clipObjects: K, interior: G } = this.state.options, q = { ignoreHydrogens: X !== "all", ignoreHydrogensVariant: X === "only-polar" ? "non-polar" : "all", quality: Y, ignoreLight: Q, material: W, clip: K, interior: G }, U = R6.create22();
      for (let F of $) {
        let E = void 0;
        if (Z.options.checkExisting)
          E = await this.tryFindComponent(F, Z.selection);
        if (!E)
          E = await this.plugin.builders.structure.tryCreateComponentFromSelection(F.cell, Z.selection, U, {
            label: Z.options.label || (Z.selection === u9.current ? "Custom Selection" : "")
          });
        if (Z.representation === "none" || !E)
          continue;
        await this.plugin.builders.structure.representation.addRepresentation(E, {
          type: this.plugin.representation.structure.registry.get(Z.representation),
          typeParams: q
        });
      }
    }, { canUndo: "Add Selection" });
  }
  async applyTheme(Z, J) {
    return this.plugin.dataTransaction(async ($) => {
      let X = J || this.currentStructures;
      if (X.length === 0)
        return;
      let Y = async (Q) => f1.toLociWithSourceUnits(await Z.selection.getSelection(this.plugin, $, Q));
      for (let Q of X)
        if (Z.action.name === "color") {
          let W = Z.action.params;
          await M20(this.plugin, Q.components, W.color, Y, Z.representations);
        } else if (Z.action.name === "resetColor")
          await M20(this.plugin, Q.components, -1, Y, Z.representations);
        else if (Z.action.name === "transparency") {
          let W = Z.action.params;
          await pC0(this.plugin, Q.components, W.value, Y, Z.representations);
        } else if (Z.action.name === "emissive") {
          let W = Z.action.params;
          await iC0(this.plugin, Q.components, W.value, Y, Z.representations);
        } else if (Z.action.name === "material") {
          let W = Z.action.params;
          await A20(this.plugin, Q.components, W.material, Y, Z.representations);
        } else if (Z.action.name === "resetMaterial")
          await A20(this.plugin, Q.components, void 0, Y, Z.representations);
        else if (Z.action.name === "clipping") {
          let W = Z.action.params;
          await gC0(this.plugin, Q.components, $9.Groups.fromNames(W.excludeGroups), Y, Z.representations);
        }
    }, { canUndo: "Apply Theme" });
  }
  modifyComponent(Z, J, $, X) {
    var Y, Q, W;
    let K = (Y = J.cell.obj) === null || Y === void 0 ? void 0 : Y.data;
    if (!K)
      return;
    if ((X === "subtract" || X === "intersect") && !eM(K, $))
      return;
    let G = (Q = J.structure.cell.obj) === null || Q === void 0 ? void 0 : Q.data, H = X === "union" ? iF(G, [K, $]) : X === "intersect" ? tf(K, $) : ZA(K, $);
    if (H.elementCount === 0)
      Z.delete(J.cell.transform.ref);
    else {
      let q = {
        type: { name: "bundle", params: W0.Bundle.fromSubStructure(G, H) },
        nullIfEmpty: !0,
        label: (W = J.cell.obj) === null || W === void 0 ? void 0 : W.label
      };
      Z.to(J.cell).update(q);
    }
  }
  updateLabel(Z, J) {
    var $, X;
    let Y = {
      type: ($ = Z.cell.params) === null || $ === void 0 ? void 0 : $.values.type,
      nullIfEmpty: (X = Z.cell.params) === null || X === void 0 ? void 0 : X.values.nullIfEmpty,
      label: J
    };
    this.dataState.build().to(Z.cell).update(Y).commit();
  }
  get dataState() {
    return this.plugin.state.data;
  }
  clearComponents(Z) {
    let J = this.dataState.build();
    for (let $ of Z)
      for (let X of $.components)
        J.delete(X.cell.transform.ref);
    return J.commit({ canUndo: "Clear Selections" });
  }
  constructor(Z) {
    super({ options: j.getDefaultValues(XG.OptionsParams) });
    this.plugin = Z, this.events = {
      optionsUpdated: this.ev()
    };
  }
}
(function(Z) {
  Z.OptionsParams = {
    hydrogens: j.Select("all", [["all", "Show All"], ["hide-all", "Hide All"], ["only-polar", "Only Polar"]], { description: "Determine display of hydrogen atoms in representations" }),
    visualQuality: j.Select("auto", UV, { description: "Control the visual/rendering quality of representations" }),
    ignoreLight: j.Boolean(!1, { description: "Ignore light for stylized rendering of representations" }),
    materialStyle: C7.getParam(),
    clipObjects: j.Group(FH.Params),
    interactions: j.Group(H7.defaultParams, { label: "Non-covalent Interactions" }),
    interior: I3()
  };
  function J(Q, W) {
    let { options: K } = Q.query.structure.registry;
    return W = {
      pivot: Q.managers.structure.component.pivotStructure,
      allowNone: !0,
      hideSelection: !1,
      checkExisting: !1,
      ...W
    }, {
      selection: j.Select(K[1][0], K, { isHidden: W === null || W === void 0 ? void 0 : W.hideSelection }),
      representation: Y(Q, W === null || W === void 0 ? void 0 : W.pivot, (W === null || W === void 0 ? void 0 : W.allowNone) ? [["none", "< Create Later >"]] : []),
      options: j.Group({
        label: j.Text(""),
        checkExisting: j.Boolean(!!(W === null || W === void 0 ? void 0 : W.checkExisting), { help: () => ({ description: "Checks if a selection with the specifield elements already exists to avoid creating duplicate components." }) })
      })
    };
  }
  Z.getAddParams = J;
  function $(Q, W) {
    let { options: K } = Q.query.structure.registry;
    return {
      selection: j.Select(K[1][0], K, { isHidden: !1 }),
      action: j.MappedStatic("color", {
        color: j.Group({
          color: j.Color(c2.blue, { isExpanded: !0 })
        }, { isFlat: !0 }),
        resetColor: j.EmptyGroup({ label: "Reset Color" }),
        transparency: j.Group({
          value: j.Numeric(0.5, { min: 0, max: 1, step: 0.01 })
        }, { isFlat: !0 }),
        emissive: j.Group({
          value: j.Numeric(0.5, { min: 0, max: 1, step: 0.01 })
        }, { isFlat: !0 }),
        material: j.Group({
          material: C7.getParam({ isFlat: !0 })
        }, { isFlat: !0 }),
        resetMaterial: j.EmptyGroup({ label: "Reset Material" }),
        clipping: j.Group({
          excludeGroups: j.MultiSelect([], j.objectToOptions($9.Groups.Names))
        }, { isFlat: !0 })
      }),
      representations: j.MultiSelect([], X(Q, W), { emptyValue: "All" })
    };
  }
  Z.getThemeParams = $;
  function X(Q, W) {
    var K, G;
    return ((K = W === null || W === void 0 ? void 0 : W.cell.obj) === null || K === void 0 ? void 0 : K.data) ? Q.representation.structure.registry.getApplicableTypes((G = W.cell.obj) === null || G === void 0 ? void 0 : G.data) : Q.representation.structure.registry.types;
  }
  Z.getRepresentationTypes = X;
  function Y(Q, W, K, G) {
    let H = [
      ...K,
      ...X(Q, W)
    ];
    return j.Select(H[0][0], H, { label: G });
  }
})(XG || (XG = {}));

// node_modules/molstar/lib/mol-plugin-state/manager/structure/hierarchy-state.js
function tC0(Z, J) {
  let $ = hM1(Z, J || Gg());
  if (gM1(Z.tree, $), J)
    J.refs.forEach(xM1, $);
  return { hierarchy: $.hierarchy, added: $.added, changed: $.changed };
}
function Gg() {
  return { trajectories: [], models: [], structures: [], refs: /* @__PURE__ */ new Map };
}
function TM1(Z) {
  return { kind: "trajectory", cell: Z, version: Z.transform.version, models: [] };
}
function oC0(Z, J) {
  return { kind: "model", cell: Z, version: Z.transform.version, trajectory: J, structures: [] };
}
function _M1(Z, J) {
  return { kind: "model-properties", cell: Z, version: Z.transform.version, model: J };
}
function VM1(Z, J) {
  return { kind: "model-unitcell", cell: Z, version: Z.transform.version, model: J };
}
function sC0(Z, J) {
  return { kind: "structure", cell: Z, version: Z.transform.version, model: J, components: [] };
}
function IM1(Z, J) {
  return { kind: "structure-properties", cell: Z, version: Z.transform.version, structure: J };
}
function PM1(Z, J) {
  return { kind: "structure-transform", cell: Z, version: Z.transform.version, structure: J };
}
function CM1(Z, J) {
  return { kind: "structure-volume-streaming", cell: Z, version: Z.transform.version, structure: J };
}
function kM1(Z) {
  if (!Z.transform.tags)
    return Z.transform.ref;
  return [...Z.transform.tags].sort().join();
}
function vM1(Z, J) {
  return { kind: "structure-component", cell: Z, version: Z.transform.version, structure: J, key: kM1(Z), representations: [] };
}
function SM1(Z, J) {
  return { kind: "structure-representation", cell: Z, version: Z.transform.version, component: J };
}
function fM1(Z, J) {
  return { kind: "generic-representation", cell: Z, version: Z.transform.version, parent: J };
}
function hM1(Z, J) {
  return { state: Z, oldHierarchy: J, hierarchy: Gg(), changed: !1, added: /* @__PURE__ */ new Set };
}
function yB(Z, J, $, X, ...Y) {
  let Q = X(...Y);
  $.push(Q), Z.hierarchy.refs.set(J.transform.ref, Q);
  let W = Z.oldHierarchy.refs.get(J.transform.ref);
  if (W) {
    if (W.version !== J.transform.version)
      Z.changed = !0;
  } else
    Z.added.add(Q.cell.transform.ref), Z.changed = !0;
  return Q;
}
function H4(Z, J, $, ...X) {
  let Y = $(...X);
  Z.hierarchy.refs.set(J.transform.ref, Y);
  let Q = Z.oldHierarchy.refs.get(J.transform.ref);
  if (Q) {
    if (Q.version !== J.transform.version)
      Z.changed = !0;
  } else
    Z.added.add(Y.cell.transform.ref), Z.changed = !0;
  return Y;
}
function aC0(Z) {
  return (J) => Z.is(J.obj);
}
function rC0(Z, J) {
  return ($, X) => !J(X) && Z.is($.obj);
}
function Kg(Z) {
  return (J) => J.transform.transformer === Z;
}
function N4() {}
var bM1 = [
  [aC0(D0.Molecule.Trajectory), (Z, J) => {
    Z.currentTrajectory = yB(Z, J, Z.hierarchy.trajectories, TM1, J);
  }, (Z) => Z.currentTrajectory = void 0],
  [rC0(D0.Molecule.Model, (Z) => Z.currentModel), (Z, J) => {
    if (Z.currentTrajectory)
      Z.currentModel = yB(Z, J, Z.currentTrajectory.models, oC0, J, Z.currentTrajectory);
    else
      Z.currentModel = H4(Z, J, oC0, J);
    Z.hierarchy.models.push(Z.currentModel);
  }, (Z) => Z.currentModel = void 0],
  [Kg(H1.Model.CustomModelProperties), (Z, J) => {
    if (!Z.currentModel)
      return !1;
    Z.currentModel.properties = H4(Z, J, _M1, J, Z.currentModel);
  }, N4],
  [Kg(H1.Representation.ModelUnitcell3D), (Z, J) => {
    if (!Z.currentModel)
      return !1;
    Z.currentModel.unitcell = H4(Z, J, VM1, J, Z.currentModel);
  }, N4],
  [rC0(D0.Molecule.Structure, (Z) => Z.currentStructure), (Z, J) => {
    if (Z.currentModel)
      Z.currentStructure = yB(Z, J, Z.currentModel.structures, sC0, J, Z.currentModel);
    else
      Z.currentStructure = H4(Z, J, sC0, J);
    Z.hierarchy.structures.push(Z.currentStructure);
  }, (Z) => Z.currentStructure = void 0],
  [Kg(H1.Model.CustomStructureProperties), (Z, J) => {
    if (!Z.currentStructure)
      return !1;
    Z.currentStructure.properties = H4(Z, J, IM1, J, Z.currentStructure);
  }, N4],
  [Kg(H1.Model.TransformStructureConformation), (Z, J) => {
    if (!Z.currentStructure)
      return !1;
    Z.currentStructure.transform = H4(Z, J, PM1, J, Z.currentStructure);
  }, N4],
  [aC0(y$), (Z, J) => {
    if (!Z.currentStructure)
      return !1;
    return Z.currentStructure.volumeStreaming = H4(Z, J, CM1, J, Z.currentStructure), !1;
  }, N4],
  [(Z, J) => {
    if (!J.currentStructure || Z.transform.transformer.definition.isDecorator)
      return !1;
    return D0.Molecule.Structure.is(Z.obj);
  }, (Z, J) => {
    if (Z.currentStructure) {
      if (Z.currentComponent) {
        if (!Z.parentComponents)
          Z.parentComponents = [];
        Z.parentComponents.push(Z.currentComponent);
      }
      Z.currentComponent = yB(Z, J, Z.currentStructure.components, vM1, J, Z.currentStructure);
    }
  }, (Z) => {
    if (Z.parentComponents && Z.parentComponents.length > 0)
      Z.currentComponent = Z.parentComponents.pop();
    else
      Z.currentComponent = void 0;
  }],
  [(Z, J) => {
    return !Z.state.isGhost && !!J.currentComponent && D0.Molecule.Structure.Representation3D.is(Z.obj);
  }, (Z, J) => {
    if (Z.currentComponent)
      yB(Z, J, Z.currentComponent.representations, SM1, J, Z.currentComponent);
    return !1;
  }, N4],
  [(Z) => !Z.state.isGhost && D0.isRepresentation3D(Z.obj), (Z, J) => {
    let $ = Z.currentComponent || Z.currentStructure || Z.currentModel;
    if ($) {
      if (!$.genericRepresentations)
        $.genericRepresentations = [];
      yB(Z, J, $.genericRepresentations, fM1, J, $);
    }
  }, N4]
];
function eC0(Z) {
  if (!Z || !(Z === null || Z === void 0 ? void 0 : Z.parent) || !Z.parent.cells.has(Z.transform.ref))
    return !1;
  let { obj: J } = Z;
  if (!J || J === LZ.Null || Z.status !== "ok" && Z.status !== "error")
    return !1;
  return !0;
}
function xM1(Z) {
  let { cell: J } = Z;
  if (eC0(J))
    return;
  this.changed = !0;
}
function yM1(Z) {
  Zk0(this, this.tree.transforms.get(Z));
}
function Zk0(Z, J) {
  let { state: $ } = Z, X = $.state.cells.get(J.ref);
  if (!eC0(X))
    return;
  let Y = void 0, Q = !1;
  for (let [K, G, H] of bM1)
    if (K(X, $)) {
      if (G($, X) === !1) {
        Q = !0;
        break;
      }
      Y = H;
      break;
    }
  if (Q)
    return;
  let W = Z.tree.children.get(J.ref);
  if (W && W.size)
    W.forEach(yM1, Z);
  if (Y)
    Y($);
}
function gM1(Z, J) {
  let $ = { tree: Z, state: J };
  return Zk0($, Z.root), $.state;
}

// node_modules/molstar/lib/mol-plugin-state/manager/structure/hierarchy.js
class kq extends Oq {
  get dataState() {
    return this.plugin.state.data;
  }
  get currentComponentGroups() {
    if (this._currentComponentGroups)
      return this._currentComponentGroups;
    return this._currentComponentGroups = kq.getComponentGroups(this.selection.structures), this._currentComponentGroups;
  }
  get seletionSet() {
    if (this._currentSelectionSet)
      return this._currentSelectionSet;
    this._currentSelectionSet = /* @__PURE__ */ new Set;
    for (let Z of this.selection.trajectories)
      this._currentSelectionSet.add(Z.cell.transform.ref);
    for (let Z of this.selection.models)
      this._currentSelectionSet.add(Z.cell.transform.ref);
    for (let Z of this.selection.structures)
      this._currentSelectionSet.add(Z.cell.transform.ref);
    return this._currentSelectionSet;
  }
  get current() {
    return this.sync(!1), this.state.hierarchy;
  }
  get selection() {
    return this.sync(!1), this.state.selection;
  }
  getStructuresWithSelection() {
    let Z = this.plugin.managers.structure.hierarchy.current.structures, J = [];
    for (let $ of Z)
      if (this.plugin.managers.structure.selection.structureHasSelection($))
        J.push($);
    return J;
  }
  findStructure(Z) {
    if (!Z)
      return;
    let J = this.plugin.helpers.substructureParent.get(Z);
    if (!J)
      return;
    let $ = this.plugin.state.data.selectQ((X) => X.byValue(J).rootOfType(D0.Molecule.Structure))[0];
    if (!$)
      return;
    return this.behaviors.selection.value.structures.find((X) => X.cell === $);
  }
  syncCurrent(Z, J) {
    let $ = this.seletionSet, X = [];
    for (let Y of Z) {
      let Q = Y.cell.transform.ref;
      if ($.has(Q) || J.has(Q))
        X.push(Y);
    }
    if (X.length === 0)
      return Z.length > 0 ? [Z[0]] : [];
    return X;
  }
  sync(Z) {
    if (!Z && this.dataState.inUpdate)
      return;
    if (this.state.syncedTree === this.dataState.tree) {
      if (Z && !this.state.notified)
        this.state.notified = !0, this.behaviors.selection.next({ hierarchy: this.state.hierarchy, ...this.state.selection });
      return;
    }
    this.state.syncedTree = this.dataState.tree;
    let J = tC0(this.plugin.state.data, this.current);
    if (!J.changed)
      return;
    let { hierarchy: $ } = J, X = this.syncCurrent($.trajectories, J.added), Y = this.syncCurrent($.models, J.added), Q = this.syncCurrent($.structures, J.added);
    if (this._currentComponentGroups = void 0, this._currentSelectionSet = void 0, this.state.hierarchy = $, this.state.selection.trajectories = X, this.state.selection.models = Y, this.state.selection.structures = Q, Z)
      this.state.notified = !0, this.behaviors.selection.next({ hierarchy: $, trajectories: X, models: Y, structures: Q });
    else
      this.state.notified = !1;
  }
  updateCurrent(Z, J) {
    let $ = this.current, X = J === "add" ? uZ.union(this.seletionSet, new Set(Z.map((K) => K.cell.transform.ref))) : uZ.difference(this.seletionSet, new Set(Z.map((K) => K.cell.transform.ref))), Y = [], Q = [], W = [];
    for (let K of $.trajectories)
      if (X.has(K.cell.transform.ref))
        Y.push(K);
    for (let K of $.models)
      if (X.has(K.cell.transform.ref))
        Q.push(K);
    for (let K of $.structures)
      if (X.has(K.cell.transform.ref))
        W.push(K);
    this._currentComponentGroups = void 0, this._currentSelectionSet = void 0, this.state.selection.trajectories = Y, this.state.selection.models = Q, this.state.selection.structures = W, this.behaviors.selection.next({ hierarchy: $, trajectories: Y, models: Q, structures: W });
  }
  remove(Z, J) {
    if (Z.length === 0)
      return;
    let $ = this.plugin.state.data.build();
    for (let X of Z)
      $.delete(typeof X === "string" ? X : X.cell.transform.ref);
    return $.commit({ canUndo: J ? "Remove" : !1 });
  }
  toggleVisibility(Z, J) {
    if (Z.length === 0)
      return;
    let $ = J !== void 0 ? J === "show" ? !1 : !0 : !Z[0].cell.state.isHidden;
    for (let X of Z)
      _H(this.dataState, X.cell.transform.ref, $);
  }
  applyPreset(Z, J, $) {
    return this.plugin.dataTransaction(async () => {
      for (let X of Z) {
        if (X.models.length > 0)
          await this.clearTrajectory(X);
        await this.plugin.builders.structure.hierarchy.applyPreset(X.cell, J, $);
      }
    });
  }
  async updateStructure(Z, J) {
    await this.plugin.dataTransaction(async () => {
      let $ = i9.getDecoratorRoot(this.dataState.tree, Z.cell.transform.ref), X = this.dataState.tree.children.get($).toArray();
      await this.remove(X, !1), await this.plugin.state.updateTransform(this.plugin.state.data, Z.cell.transform.ref, J, "Structure Type"), await this.plugin.builders.structure.representation.applyPreset(Z.cell.transform.ref, "auto");
    }, { canUndo: "Structure Type" }), h1.Camera.Reset(this.plugin);
  }
  clearTrajectory(Z) {
    let J = this.dataState.build();
    for (let $ of Z.models)
      J.delete($.cell);
    return J.commit();
  }
  constructor(Z) {
    super();
    this.plugin = Z, this.state = {
      syncedTree: this.dataState.tree,
      notified: !1,
      hierarchy: Gg(),
      selection: {
        trajectories: [],
        models: [],
        structures: []
      }
    }, this.behaviors = {
      selection: this.ev.behavior({
        hierarchy: this.current,
        trajectories: this.selection.trajectories,
        models: this.selection.models,
        structures: this.selection.structures
      })
    }, this._currentComponentGroups = void 0, this._currentSelectionSet = void 0, this.subscribe(Z.state.data.events.changed, (J) => {
      if (J.inTransaction || Z.behaviors.state.isAnimating.value)
        return;
      this.sync(!0);
    }), this.subscribe(Z.behaviors.state.isAnimating, (J) => {
      if (!J && !Z.behaviors.state.isUpdating.value)
        this.sync(!0);
    });
  }
}
(function(Z) {
  function J(X) {
    if (!X.length)
      return [];
    if (X.length === 1)
      return X[0].components.map((W) => [W]);
    let Y = [], Q = /* @__PURE__ */ new Map;
    for (let W of X)
      for (let K of W.components) {
        let G = K.key;
        if (!G)
          continue;
        let H = Q.get(G);
        if (!H)
          H = [], Q.set(G, H), Y.push(H);
        H.push(K);
      }
    return Y;
  }
  Z.getComponentGroups = J;
  function $(X) {
    var Y, Q, W, K, G, H, N, q, U;
    let { structures: F } = X.managers.structure.hierarchy.selection;
    if (F.length === 0)
      return "";
    if (F.length === 1) {
      let D = F[0], A = (Y = D.cell.obj) === null || Y === void 0 ? void 0 : Y.data;
      if (!A)
        return ((Q = D.cell.obj) === null || Q === void 0 ? void 0 : Q.label) || "Structure";
      let B = A.models[0] || A.representativeModel || A.masterModel;
      if (!B)
        return ((W = D.cell.obj) === null || W === void 0 ? void 0 : W.label) || "Structure";
      let T = B.entryId;
      if (((G = (K = D.model) === null || K === void 0 ? void 0 : K.trajectory) === null || G === void 0 ? void 0 : G.models) && D.model.trajectory.models.length === 1)
        return T;
      if (D.model)
        return `${(H = D.model.cell.obj) === null || H === void 0 ? void 0 : H.label} | ${T}`;
      return T;
    }
    let E = F[0], R = (N = E === null || E === void 0 ? void 0 : E.model) === null || N === void 0 ? void 0 : N.trajectory, z = !0;
    for (let D of F)
      if (((q = D === null || D === void 0 ? void 0 : D.model) === null || q === void 0 ? void 0 : q.trajectory) !== R) {
        z = !1;
        break;
      }
    return z && R ? `${(U = R.cell.obj) === null || U === void 0 ? void 0 : U.label} | ${F.length} structures` : `${F.length} structures`;
  }
  Z.getSelectedStructuresDescription = $;
})(kq || (kq = {}));

// node_modules/molstar/lib/mol-plugin-ui/state/update-transform.js
var mM1 = t2(PZ(), 1);

// node_modules/molstar/lib/mol-plugin-ui/state/common.js
var w$ = t2(PZ(), 1);
class vq extends N7 {
  constructor() {
    super(...arguments);
    this.onChange = ({ name: Z, value: J }) => {
      let $ = { ...this.props.params, [Z]: J };
      this.props.events.onChange($, this.areInitial($), this.validate($));
    };
  }
  validate(Z) {
    return;
  }
  areInitial(Z) {
    return j.areEqual(this.props.info.params, Z, this.props.info.initialValues);
  }
  render() {
    return w$.jsx(iZ, { params: this.props.info.params, values: this.props.params, onChange: this.onChange, onEnter: this.props.events.onEnter, isDisabled: this.props.isDisabled });
  }
}
(function(Z) {
  function J(Y) {
    let Q = Object.keys(Y);
    for (let W of Q)
      if (!Y[W].isHidden)
        return !1;
    return !0;
  }
  function $(Y, Q, W, K) {
    let G = Q.cells.get(K).obj, H = W.definition.params ? W.definition.params(G, Y) : {};
    return {
      initialValues: j.getDefaultValues(H),
      params: H,
      isEmpty: J(H)
    };
  }
  Z.infoFromAction = $;
  function X(Y, Q, W) {
    let K = Q.cells.get(W.ref), G = K.params && K.params.definition || {};
    return {
      initialValues: K.params && K.params.values || {},
      params: G,
      isEmpty: J(G)
    };
  }
  Z.infoFromTransform = X;
})(vq || (vq = {}));

class XP extends N7 {
  constructor() {
    super(...arguments);
    this.busy = new G$(!1), this.onEnter = () => {
      if (this.state.error)
        return;
      this.apply();
    }, this.autoApplyHandle = void 0, this.events = {
      onEnter: this.onEnter,
      onChange: (Z, J, $) => {
        this.clearAutoApply(), this.setState({ params: Z, isInitial: J, error: $ && $[0] }, () => {
          if (!J && !this.state.error && this.canAutoApply(Z))
            this.clearAutoApply(), this.autoApplyHandle = setTimeout(this.apply, 50);
        });
      }
    }, this.apply = async () => {
      var Z, J;
      this.clearAutoApply(), this.setState({ busy: !0 });
      try {
        await this.applyAction();
      } catch ($) {
        console.error($);
      } finally {
        (J = (Z = this.props).onApply) === null || J === void 0 || J.call(Z), this.busy.next(!1);
      }
    }, this.refresh = () => {
      this.setState({ params: this.getInfo().initialValues, isInitial: !0, error: void 0 });
    }, this.setDefault = () => {
      let Z = this.getInfo(), J = j.getDefaultValues(Z.params);
      this.setState({ params: J, isInitial: j.areEqual(Z.params, J, Z.initialValues), error: void 0 });
    }, this.toggleExpanded = () => {
      this.setState({ isCollapsed: !this.state.isCollapsed });
    };
  }
  clearAutoApply() {
    if (this.autoApplyHandle !== void 0)
      clearTimeout(this.autoApplyHandle), this.autoApplyHandle = void 0;
  }
  componentDidMount() {
    this.subscribe(this.plugin.behaviors.state.isBusy, (Z) => {
      if (this.busy.value !== Z)
        this.busy.next(Z);
    }), this.subscribe(this.busy.pipe(j_(1)), (Z) => {
      this.setState({ busy: Z });
    });
  }
  renderApply() {
    let Z = this.canApply();
    if (this.props.autoHideApply && (!Z || this.canAutoApply(this.state.params)))
      return null;
    return w$.jsxs("div", { className: "msp-transform-apply-wrap", children: [w$.jsx(o2, { svg: iz, className: "msp-transform-default-params", onClick: this.setDefault, disabled: this.state.busy, title: "Set default params" }), w$.jsx("div", { className: "msp-transform-apply-wider", children: w$.jsx(Z8, { icon: Z ? xK : void 0, className: `msp-btn-commit msp-btn-commit-${Z ? "on" : "off"}`, onClick: this.apply, disabled: !Z, children: this.props.applyLabel || this.applyText() }) })] });
  }
  renderDefault() {
    let Z = this.getInfo(), J = Z.isEmpty && this.isUpdate(), $ = this.getHeader(), X = this.getTransformerId(), Y = this.plugin.customParamEditors.has(X) ? this.plugin.customParamEditors.get(X) : vq, Q = this.state.isCollapsed ? "msp-transform-wrapper msp-transform-wrapper-collapsed" : "msp-transform-wrapper", W = null;
    if (!J && !this.state.isCollapsed) {
      let { a: G, b: H, bCell: N } = this.getSourceAndTarget(), q = this.renderApply();
      W = w$.jsxs(w$.Fragment, { children: [w$.jsx(Y, { info: Z, a: G, b: H, bCell: N, events: this.events, params: this.state.params, isDisabled: this.state.busy }), q] });
    }
    let K = w$.jsxs("div", { className: Q, style: { marginBottom: this.props.noMargin ? 0 : void 0 }, children: [$ !== "none" && !this.props.wrapInExpander && w$.jsx("div", { className: "msp-transform-header", children: w$.jsxs(Z8, { onClick: this.toggleExpanded, title: $.description, children: [!J && w$.jsx(b6, { svg: this.state.isCollapsed ? $W : JW }), $.name] }) }), W] });
    if (J || !this.props.wrapInExpander)
      return K;
    return w$.jsx(g$, { header: this.isUpdate() ? `Update ${$ === "none" ? "" : $.name}` : `Apply ${$ === "none" ? "" : $.name}`, headerLeftMargin: this.props.expanderHeaderLeftMargin, children: K });
  }
  renderSimple() {
    var Z, J, $;
    let X = this.getInfo(), Y = this.canApply(), Q = w$.jsxs("div", { className: "msp-flex-row", children: [w$.jsx(Z8, { icon: (Z = this.props.simpleApply) === null || Z === void 0 ? void 0 : Z.icon, title: (J = this.props.simpleApply) === null || J === void 0 ? void 0 : J.title, disabled: this.state.busy || !Y, onClick: this.apply, className: "msp-btn-apply-simple", children: ($ = this.props.simpleApply) === null || $ === void 0 ? void 0 : $.header }), !X.isEmpty && w$.jsx(D7, { icon: lX, label: "", title: "Options", toggle: this.toggleExpanded, isSelected: !this.state.isCollapsed, disabled: this.state.busy, style: { flex: "0 0 40px", padding: 0 } })] });
    if (this.state.isCollapsed)
      return Q;
    let W = this.getTransformerId(), K = this.plugin.customParamEditors.has(W) ? this.plugin.customParamEditors.get(W) : vq, { a: G, b: H, bCell: N } = this.getSourceAndTarget();
    return w$.jsxs(w$.Fragment, { children: [Q, w$.jsx(K, { info: X, a: G, b: H, bCell: N, events: this.events, params: this.state.params, isDisabled: this.state.busy })] });
  }
  render() {
    return this.props.simpleApply ? this.renderSimple() : this.renderDefault();
  }
}

// node_modules/molstar/lib/mol-plugin-ui/state/update-transform.js
class oW extends XP {
  constructor() {
    super(...arguments);
    this._getInfo = cJ((Z) => vq.infoFromTransform(this.plugin, this.props.state, Z)), this.state = { error: void 0, isInitial: !0, params: this.getInfo().initialValues, busy: !1, isCollapsed: this.props.initiallyCollapsed };
  }
  applyAction() {
    if (this.props.customUpdate)
      return this.props.customUpdate(this.state.params);
    return this.plugin.state.updateTransform(this.props.state, this.props.transform.ref, this.state.params);
  }
  getInfo() {
    return this._getInfo(this.props.transform);
  }
  getTransformerId() {
    return this.props.transform.transformer.id;
  }
  getHeader() {
    return this.props.customHeader || this.props.transform.transformer.definition.display;
  }
  canApply() {
    let { state: Z } = this.props, J = Z.cells.get(this.props.transform.ref);
    if (!J)
      return !1;
    if (J.status === "error") {
      let $ = Z.cells.get(this.props.transform.parent);
      if (!$)
        return !1;
      return $.status === "ok";
    }
    return !this.state.error && !this.state.busy && !this.state.isInitial;
  }
  applyText() {
    return this.canApply() ? "Update" : "Nothing to Update";
  }
  isUpdate() {
    return !0;
  }
  getSourceAndTarget() {
    let Z = this.props.state.cells.get(this.props.transform.ref);
    return {
      a: this.props.state.cells.get(this.props.transform.parent).obj,
      b: Z === null || Z === void 0 ? void 0 : Z.obj,
      bCell: Z
    };
  }
  canAutoApply(Z) {
    let J = this.props.transform.transformer.definition.canAutoUpdate;
    if (!J)
      return !1;
    let { state: $ } = this.props, X = $.cells.get(this.props.transform.ref);
    if (!X || !X.sourceRef || X.status !== "ok")
      return !1;
    let Y = $.cells.get(X.sourceRef);
    return J({ a: Y.obj, b: X.obj, oldParams: this.getInfo().initialValues, newParams: Z }, this.plugin);
  }
  componentDidMount() {
    if (super.componentDidMount(), this.props.toggleCollapsed)
      this.subscribe(this.props.toggleCollapsed, () => this.setState({ isCollapsed: !this.state.isCollapsed }));
    this.subscribe(this.plugin.state.events.object.updated, ({ ref: Z, state: J }) => {
      if (this.props.transform.ref !== Z || this.props.state !== J)
        return;
      if (this.state.params !== this.props.transform.params)
        this._getInfo = cJ(($) => vq.infoFromTransform(this.plugin, this.props.state, $)), this.setState({ params: this.props.transform.params, isInitial: !0 });
    });
  }
  componentDidUpdate(Z) {
    var J;
    if (this.props.transform !== Z.transform) {
      let $ = this.props.state.cells.get(this.props.transform.ref);
      this.setState({
        params: ((J = $.params) === null || J === void 0 ? void 0 : J.values) || {},
        isInitial: !0,
        error: void 0,
        simpleOnly: this.state.simpleOnly
      });
    }
  }
}

// node_modules/molstar/lib/mol-plugin-ui/structure/generic.js
var qX = t2(PZ(), 1);
class w20 extends N7 {
  get current() {
    return this.plugin.managers.structure.hierarchy.behaviors.selection;
  }
  componentDidMount() {
    this.subscribe(this.current, () => this.forceUpdate());
  }
  get unitcell() {
    var Z;
    let { selection: J } = this.plugin.managers.structure.hierarchy;
    if (J.structures.length === 0)
      return null;
    let $ = [];
    for (let X of J.structures) {
      let Y = X.model;
      if ((Y === null || Y === void 0 ? void 0 : Y.unitcell) && ((Z = Y.unitcell) === null || Z === void 0 ? void 0 : Z.cell.obj))
        $.push(Y.unitcell);
    }
    if ($.length === 0)
      return null;
    return qX.jsx(B20, { refs: $, labelMultiple: "Unit Cells" });
  }
  get customControls() {
    let Z = [];
    return this.plugin.genericRepresentationControls.forEach((J, $) => {
      let [X, Y] = J(this.plugin.managers.structure.hierarchy.selection);
      if (X.length > 0)
        Z.push(qX.jsx("div", { children: qX.jsx(B20, { refs: X, labelMultiple: Y }) }, $));
    }), Z.length > 0 ? Z : null;
  }
  render() {
    return qX.jsx(qX.Fragment, { children: qX.jsxs("div", { style: { marginTop: "6px" }, children: [this.unitcell, this.customControls] }) });
  }
}

class B20 extends N7 {
  constructor() {
    super(...arguments);
    this.state = { showOptions: !1 }, this.toggleVisibility = (Z) => {
      Z.preventDefault(), this.plugin.managers.structure.hierarchy.toggleVisibility(this.props.refs), Z.currentTarget.blur();
    }, this.highlight = (Z) => {
      if (Z.preventDefault(), !this.pivot.cell.parent)
        return;
      h1.Interactivity.Object.Highlight(this.plugin, {
        state: this.pivot.cell.parent,
        ref: this.props.refs.map((J) => J.cell.transform.ref)
      });
    }, this.clearHighlight = (Z) => {
      Z.preventDefault(), h1.Interactivity.ClearHighlights(this.plugin);
    }, this.focus = (Z) => {
      var J;
      Z.preventDefault();
      let $ = !0;
      for (let Y of this.props.refs)
        if (!Y.cell.state.isHidden) {
          $ = !1;
          break;
        }
      if ($)
        this.plugin.managers.structure.hierarchy.toggleVisibility(this.props.refs, "show");
      let X = [];
      for (let Y of this.props.refs) {
        if (Y.cell.state.isHidden)
          continue;
        let Q = (J = Y.cell.obj) === null || J === void 0 ? void 0 : J.data.repr.getLoci();
        if (Q)
          X.push(Q);
      }
      this.plugin.managers.camera.focusLoci(X);
    }, this.toggleOptions = () => this.setState({ showOptions: !this.state.showOptions });
  }
  componentDidMount() {
    this.subscribe(this.plugin.state.events.cell.stateUpdated, (Z) => {
      var J;
      if (wK.ObjectEvent.isCell(Z, (J = this.pivot) === null || J === void 0 ? void 0 : J.cell))
        this.forceUpdate();
    });
  }
  get pivot() {
    return this.props.refs[0];
  }
  render() {
    let { refs: Z, labelMultiple: J } = this.props;
    if (Z.length === 0)
      return null;
    let $ = Z[0], X, Y;
    if (Z.length === 1) {
      let { obj: Q } = $.cell;
      if (!Q)
        return null;
      X = Q === null || Q === void 0 ? void 0 : Q.label, Y = Q === null || Q === void 0 ? void 0 : Q.description;
    } else
      X = `${Z.length} ${J || "Objects"}`;
    return qX.jsxs(qX.Fragment, { children: [qX.jsxs("div", { className: "msp-flex-row", children: [qX.jsxs("button", { className: "msp-form-control msp-control-button-label", title: `${X}. Click to focus.`, onClick: this.focus, onMouseEnter: this.highlight, onMouseLeave: this.clearHighlight, style: { textAlign: "left" }, children: [X, " ", qX.jsx("small", { children: Y })] }), qX.jsx(o2, { svg: $.cell.state.isHidden ? yK : b5, toggleState: !1, className: "msp-form-control", onClick: this.toggleVisibility, title: `${$.cell.state.isHidden ? "Show" : "Hide"}`, small: !0, flex: !0 }), Z.length === 1 && qX.jsx(o2, { svg: ME, className: "msp-form-control", onClick: this.toggleOptions, title: "Options", toggleState: this.state.showOptions, flex: !0 })] }), Z.length === 1 && this.state.showOptions && $.cell.parent && qX.jsx(qX.Fragment, { children: qX.jsx("div", { className: "msp-control-offset", children: qX.jsx(oW, { state: $.cell.parent, transform: $.cell.transform, customHeader: "none", autoHideApply: !0 }) }) })] });
  }
}

// node_modules/molstar/lib/mol-plugin-ui/structure/components.js
class j20 extends y5 {
  defaultState() {
    return {
      header: "Components",
      isCollapsed: !1,
      isDisabled: !1,
      brand: { accent: "blue", svg: VI }
    };
  }
  componentDidMount() {
    this.subscribe(this.plugin.managers.structure.hierarchy.behaviors.selection, (Z) => this.setState({
      description: kq.getSelectedStructuresDescription(this.plugin)
    }));
  }
  renderControls() {
    return x6.jsxs(x6.Fragment, { children: [x6.jsx(Jk0, {}), x6.jsx(Xk0, {}), x6.jsx(w20, {})] });
  }
}

class Jk0 extends N7 {
  constructor() {
    super(...arguments);
    this.state = {
      isEmpty: !0,
      isBusy: !1,
      canUndo: !1
    }, this.togglePreset = this.toggleAction("preset"), this.toggleAdd = this.toggleAction("add"), this.toggleOptions = this.toggleAction("options"), this.hideAction = () => this.setState({ action: void 0 }), this.applyPreset = (Z) => {
      if (this.hideAction(), !Z)
        return;
      let J = this.plugin.managers.structure, { structures: $ } = J.hierarchy.selection;
      if (Z.value === null)
        J.component.clear($);
      else
        J.component.applyPreset($, Z.value);
    }, this.undo = () => {
      let Z = this.plugin.state.data.undo();
      if (Z)
        this.plugin.runTask(Z);
    };
  }
  get isDisabled() {
    return this.state.isBusy || this.state.isEmpty;
  }
  componentDidMount() {
    this.subscribe(this.plugin.managers.structure.hierarchy.behaviors.selection, (Z) => this.setState({
      action: this.state.action !== "options" || Z.structures.length === 0 ? void 0 : "options",
      isEmpty: Z.structures.length === 0
    })), this.subscribe(this.plugin.behaviors.state.isBusy, (Z) => {
      this.setState({ isBusy: Z, action: this.state.action !== "options" ? void 0 : "options" });
    }), this.subscribe(this.plugin.state.data.events.historyUpdated, ({ state: Z }) => {
      this.setState({ canUndo: Z.canUndo });
    });
  }
  toggleAction(Z) {
    return () => this.setState({ action: this.state.action === Z ? void 0 : Z });
  }
  get presetControls() {
    return x6.jsx(w8, { items: this.presetActions, onSelect: this.applyPreset });
  }
  get presetActions() {
    let Z = this.plugin.managers.structure.component.pivotStructure, J = this.plugin.builders.structure.representation.getPresets(Z === null || Z === void 0 ? void 0 : Z.cell.obj);
    return w8.createItems(J, { label: ($) => $.display.name, category: ($) => $.display.group, description: ($) => $.display.description });
  }
  render() {
    let Z = this.state.canUndo ? `Undo ${this.plugin.state.data.latestUndoLabel}` : "Some mistakes of the past can be undone.";
    return x6.jsxs(x6.Fragment, { children: [x6.jsxs("div", { className: "msp-flex-row", children: [x6.jsx(D7, { icon: wU, label: "Preset", title: "Apply a representation preset for the current structure(s).", toggle: this.togglePreset, isSelected: this.state.action === "preset", disabled: this.isDisabled }), x6.jsx(D7, { icon: hH, label: "Add", title: "Add a new representation component for a selection.", toggle: this.toggleAdd, isSelected: this.state.action === "add", disabled: this.isDisabled }), x6.jsx(D7, { icon: lX, label: "", title: "Options that are applied to all applicable representations.", style: { flex: "0 0 40px", padding: 0 }, toggle: this.toggleOptions, isSelected: this.state.action === "options", disabled: this.isDisabled }), x6.jsx(o2, { svg: vI, className: "msp-flex-item", flex: "40px", onClick: this.undo, disabled: !this.state.canUndo || this.isDisabled, title: Z })] }), this.state.action === "preset" && this.presetControls, this.state.action === "add" && x6.jsx("div", { className: "msp-control-offset", children: x6.jsx(Hg, { onApply: this.hideAction }) }), this.state.action === "options" && x6.jsx("div", { className: "msp-control-offset", children: x6.jsx($k0, { isDisabled: this.isDisabled }) })] });
  }
}

class Hg extends N7 {
  constructor() {
    super(...arguments);
    this.state = this.createState(), this.apply = () => {
      let Z = this.props.forSelection ? this.currentStructures : this.selectedStructures;
      this.props.onApply(), this.plugin.managers.structure.component.add(this.state.values, Z);
    }, this.paramsChanged = (Z) => this.setState({ values: Z });
  }
  createState() {
    let Z = XG.getAddParams(this.plugin);
    return { params: Z, values: j.getDefaultValues(Z) };
  }
  get selectedStructures() {
    return this.plugin.managers.structure.component.currentStructures;
  }
  get currentStructures() {
    return this.plugin.managers.structure.hierarchy.current.structures;
  }
  render() {
    return x6.jsxs(x6.Fragment, { children: [x6.jsx(iZ, { params: this.state.params, values: this.state.values, onChangeValues: this.paramsChanged }), x6.jsx(Z8, { icon: hH, title: "Use Selection and optional Representation to create a new Component.", className: "msp-btn-commit msp-btn-commit-on", onClick: this.apply, style: { marginTop: "1px" }, children: "Create Component" })] });
  }
}

class $k0 extends N7 {
  constructor() {
    super(...arguments);
    this.update = (Z) => this.plugin.managers.structure.component.setOptions(Z);
  }
  componentDidMount() {
    this.subscribe(this.plugin.managers.structure.component.events.optionsUpdated, () => this.forceUpdate());
  }
  render() {
    return x6.jsx(iZ, { params: XG.OptionsParams, values: this.plugin.managers.structure.component.state.options, onChangeValues: this.update, isDisabled: this.props.isDisabled });
  }
}

class Xk0 extends N7 {
  componentDidMount() {
    this.subscribe(this.plugin.managers.structure.hierarchy.behaviors.selection, () => {
      this.forceUpdate();
    });
  }
  render() {
    let Z = this.plugin.managers.structure.hierarchy.currentComponentGroups;
    if (Z.length === 0)
      return null;
    return x6.jsx("div", { style: { marginTop: "6px" }, children: Z.map((J) => x6.jsx(Yk0, { group: J }, J[0].cell.transform.ref)) });
  }
}

class Yk0 extends N7 {
  constructor() {
    super(...arguments);
    this.state = { action: void 0 }, this.toggleVisible = (Z) => {
      Z.preventDefault(), Z.currentTarget.blur(), this.plugin.managers.structure.component.toggleVisibility(this.props.group);
    }, this.selectAction = (Z) => {
      if (!Z)
        return;
      (Z === null || Z === void 0 ? void 0 : Z.value)();
    }, this.remove = () => this.plugin.managers.structure.hierarchy.remove(this.props.group, !0), this.toggleAction = () => this.setState({ action: this.state.action === "action" ? void 0 : "action" }), this.toggleLabel = () => this.setState({ action: this.state.action === "label" ? void 0 : "label" }), this.highlight = (Z) => {
      if (Z.preventDefault(), !this.props.group[0].cell.parent)
        return;
      h1.Interactivity.Object.Highlight(this.plugin, { state: this.props.group[0].cell.parent, ref: this.props.group.map((J) => J.cell.transform.ref) });
    }, this.clearHighlight = (Z) => {
      Z.preventDefault(), h1.Interactivity.ClearHighlights(this.plugin);
    }, this.focus = () => {
      let Z = !0;
      for (let J of this.props.group)
        if (!J.cell.state.isHidden) {
          Z = !1;
          break;
        }
      if (Z)
        this.plugin.managers.structure.hierarchy.toggleVisibility(this.props.group, "show");
      this.plugin.managers.camera.focusSpheres(this.props.group, (J) => {
        var $;
        if (J.cell.state.isHidden)
          return;
        return ($ = J.cell.obj) === null || $ === void 0 ? void 0 : $.data.boundary.sphere;
      });
    }, this.updateLabel = (Z) => {
      this.plugin.managers.structure.component.updateLabel(this.pivot, Z);
    };
  }
  get pivot() {
    return this.props.group[0];
  }
  componentDidMount() {
    this.subscribe(this.plugin.state.events.cell.stateUpdated, (Z) => {
      if (wK.ObjectEvent.isCell(Z, this.pivot.cell))
        this.forceUpdate();
    });
  }
  get colorByActions() {
    var Z, J;
    let $ = this.plugin.managers.structure.component, Y = (Z = this.pivot.representations[0].cell.transform.params) === null || Z === void 0 ? void 0 : Z.colorTheme.name, Q = KV0(this.plugin, (J = this.pivot.cell.obj) === null || J === void 0 ? void 0 : J.data);
    return w8.createItemsFromSelectOptions(Q, {
      value: (W) => () => $.updateRepresentationsTheme(this.props.group, { color: W[0] }),
      selected: (W) => W[0] === Y
    });
  }
  get actions() {
    let Z = this.plugin.managers.structure.component, J = [
      [
        w8.Header("Add Representation"),
        ...XG.getRepresentationTypes(this.plugin, this.props.group[0]).map(($) => w8.Item($[1], () => Z.addRepresentation(this.props.group, $[0])))
      ]
    ];
    if (this.pivot.representations.length > 0)
      J.push([
        w8.Header("Set Coloring", { isIndependent: !0 }),
        ...this.colorByActions
      ]);
    if (Z.canBeModified(this.props.group[0]))
      J.push([
        w8.Header("Modify by Selection"),
        w8.Item("Include", () => Z.modifyByCurrentSelection(this.props.group, "union"), { icon: jI }),
        w8.Item("Subtract", () => Z.modifyByCurrentSelection(this.props.group, "subtract"), { icon: TI }),
        w8.Item("Intersect", () => Z.modifyByCurrentSelection(this.props.group, "intersect"), { icon: _I })
      ]);
    if (J.push(w8.Item("Select This", () => Z.selectThis(this.props.group), { icon: nz })), Z.canBeModified(this.props.group[0]))
      J.push(w8.Item("Edit Label", this.toggleLabel));
    return J;
  }
  get reprLabel() {
    var Z;
    let J = this.pivot;
    if (J.representations.length === 0)
      return "No repr.";
    if (J.representations.length === 1)
      return (Z = J.representations[0].cell.obj) === null || Z === void 0 ? void 0 : Z.label;
    return `${J.representations.length} reprs`;
  }
  render() {
    var Z;
    let J = this.pivot, $ = J.cell, X = (Z = $.obj) === null || Z === void 0 ? void 0 : Z.label, Y = this.reprLabel;
    return x6.jsxs(x6.Fragment, { children: [x6.jsxs("div", { className: "msp-flex-row", children: [x6.jsxs(Z8, { noOverflow: !0, className: "msp-control-button-label", title: `${X}. Click to focus.`, onClick: this.focus, onMouseEnter: this.highlight, onMouseLeave: this.clearHighlight, style: { textAlign: "left" }, children: [X, x6.jsx("small", { className: "msp-25-lower-contrast-text", style: { float: "right" }, children: Y })] }), x6.jsx(o2, { svg: $.state.isHidden ? yK : b5, toggleState: !1, onClick: this.toggleVisible, title: `${$.state.isHidden ? "Show" : "Hide"} component`, small: !0, className: "msp-form-control", flex: !0 }), x6.jsx(o2, { svg: GX, toggleState: !1, onClick: this.remove, title: "Remove", small: !0, className: "msp-form-control", flex: !0 }), x6.jsx(o2, { svg: ME, onClick: this.toggleAction, title: "Actions", toggleState: this.state.action === "action", className: "msp-form-control", flex: !0 })] }), this.state.action === "label" && x6.jsx("div", { className: "msp-control-offset", style: { marginBottom: "6px" }, children: x6.jsx(bY, { label: "Label", control: x6.jsxs("div", { style: { display: "flex", textAlignLast: "center" }, children: [x6.jsx(x5, { onChange: this.updateLabel, value: X, style: { flex: "1 1 auto", minWidth: 0 }, className: "msp-form-control", blurOnEnter: !0, blurOnEscape: !0 }), x6.jsx(o2, { svg: xK, onClick: this.toggleLabel, className: "msp-form-control msp-control-button-label", flex: !0 })] }) }) }), this.state.action === "action" && x6.jsxs("div", { className: "msp-accent-offset", children: [x6.jsx("div", { style: { marginBottom: "6px" }, children: x6.jsx(w8, { items: this.actions, onSelect: this.selectAction, noOffset: !0 }) }), x6.jsx("div", { style: { marginBottom: "6px" }, children: J.representations.map((Q) => x6.jsx(Qk0, { group: this.props.group, representation: Q }, Q.cell.transform.ref)) })] })] });
  }
}

class Qk0 extends N7 {
  constructor() {
    super(...arguments);
    this.remove = () => this.plugin.managers.structure.component.removeRepresentations(this.props.group, this.props.representation), this.toggleVisible = (Z) => {
      Z.preventDefault(), Z.currentTarget.blur(), this.plugin.managers.structure.component.toggleVisibility(this.props.group, this.props.representation);
    }, this.update = (Z) => this.plugin.managers.structure.component.updateRepresentations(this.props.group, this.props.representation, Z);
  }
  componentDidMount() {
    this.subscribe(this.plugin.state.events.cell.stateUpdated, (Z) => {
      if (wK.ObjectEvent.isCell(Z, this.props.representation.cell))
        this.forceUpdate();
    });
  }
  render() {
    var Z;
    let J = this.props.representation.cell;
    return x6.jsxs("div", { className: "msp-representation-entry", children: [J.parent && x6.jsx(g$, { header: `${((Z = J.obj) === null || Z === void 0 ? void 0 : Z.label) || ""} Representation`, noOffset: !0, children: x6.jsx(oW, { state: J.parent, transform: J.transform, customHeader: "none", customUpdate: this.update, noMargin: !0 }) }), x6.jsx(o2, { svg: GX, onClick: this.remove, title: "Remove", small: !0, className: "msp-default-bg", toggleState: !1, style: {
      position: "absolute",
      top: 0,
      right: "32px",
      lineHeight: "24px",
      height: "24px",
      textAlign: "right",
      width: "44px",
      paddingRight: "6px",
      background: "none"
    } }), x6.jsx(o2, { svg: this.props.representation.cell.state.isHidden ? yK : b5, toggleState: !1, onClick: this.toggleVisible, title: "Toggle Visibility", small: !0, className: "msp-default-bg", style: {
      position: "absolute",
      top: 0,
      right: 0,
      lineHeight: "24px",
      height: "24px",
      textAlign: "right",
      width: "32px",
      paddingRight: "6px",
      background: "none"
    } })] });
  }
}

// node_modules/molstar/lib/mol-plugin-ui/structure/measurements.js
var r6 = t2(PZ(), 1);

// node_modules/molstar/lib/mol-plugin-state/manager/structure/measurement.js
var T20 = "measurement-group", Ng = "measurement-order-label", _20 = {
  distanceUnitLabel: j.Text("Å", { isEssential: !0 }),
  textColor: mt.textColor
}, dM1 = j.getDefaultValues(_20);
function gK(Z) {
  return { bundle: W0.Bundle.fromLoci(Z) };
}

class V20 extends pX {
  stateUpdated() {
    this.behaviors.state.next(this.state);
  }
  getGroup() {
    let Z = this.plugin.state.data, J = f2.findTagInSubtree(Z.tree, D8.RootRef, T20), $ = this.plugin.state.data.build();
    if (J)
      return $.to(J);
    return $.toRoot().group(H1.Misc.CreateGroup, { label: "Measurements" }, { tags: T20 });
  }
  async setOptions(Z) {
    if (this.updateState({ options: Z }))
      this.stateUpdated();
    let J = this.plugin.state.data.build();
    for (let $ of this.state.distances)
      J.to($).update((X) => {
        X.unitLabel = Z.distanceUnitLabel, X.textColor = Z.textColor;
      });
    for (let $ of this.state.labels)
      J.to($).update((X) => {
        X.textColor = Z.textColor;
      });
    for (let $ of this.state.angles)
      J.to($).update((X) => {
        X.textColor = Z.textColor;
      });
    for (let $ of this.state.dihedrals)
      J.to($).update((X) => {
        X.textColor = Z.textColor;
      });
    if (J.editInfo.count === 0)
      return;
    await h1.State.Update(this.plugin, { state: this.plugin.state.data, tree: J, options: { doNotLogTiming: !0 } });
  }
  async addDistance(Z, J, $) {
    let X = this.plugin.helpers.substructureParent.get(Z.structure), Y = this.plugin.helpers.substructureParent.get(J.structure);
    if (!X || !Y)
      return;
    let Q = [X.transform.ref];
    n9(Q, Y.transform.ref);
    let K = this.getGroup().apply(H1.Model.MultiStructureSelectionFromBundle, {
      selections: [
        { key: "a", groupId: "a", ref: X.transform.ref, ...gK(Z) },
        { key: "b", groupId: "b", ref: Y.transform.ref, ...gK(J) }
      ],
      isTransitive: !0,
      label: "Distance"
    }, { dependsOn: Q, tags: $ === null || $ === void 0 ? void 0 : $.selectionTags }), G = K.apply(H1.Representation.StructureSelectionsDistance3D, {
      customText: ($ === null || $ === void 0 ? void 0 : $.customText) || "",
      unitLabel: this.state.options.distanceUnitLabel,
      textColor: this.state.options.textColor,
      ...$ === null || $ === void 0 ? void 0 : $.lineParams,
      ...$ === null || $ === void 0 ? void 0 : $.labelParams,
      ...$ === null || $ === void 0 ? void 0 : $.visualParams
    }, { tags: $ === null || $ === void 0 ? void 0 : $.reprTags }), H = this.plugin.state.data;
    return await h1.State.Update(this.plugin, { state: H, tree: G, options: { doNotLogTiming: !0 } }), { selection: K.selector, representation: G.selector };
  }
  async addAngle(Z, J, $, X) {
    let Y = this.plugin.helpers.substructureParent.get(Z.structure), Q = this.plugin.helpers.substructureParent.get(J.structure), W = this.plugin.helpers.substructureParent.get($.structure);
    if (!Y || !Q || !W)
      return;
    let K = [Y.transform.ref];
    n9(K, Q.transform.ref), n9(K, W.transform.ref);
    let H = this.getGroup().apply(H1.Model.MultiStructureSelectionFromBundle, {
      selections: [
        { key: "a", ref: Y.transform.ref, ...gK(Z) },
        { key: "b", ref: Q.transform.ref, ...gK(J) },
        { key: "c", ref: W.transform.ref, ...gK($) }
      ],
      isTransitive: !0,
      label: "Angle"
    }, { dependsOn: K, tags: X === null || X === void 0 ? void 0 : X.selectionTags }), N = H.apply(H1.Representation.StructureSelectionsAngle3D, {
      customText: (X === null || X === void 0 ? void 0 : X.customText) || "",
      textColor: this.state.options.textColor,
      ...X === null || X === void 0 ? void 0 : X.lineParams,
      ...X === null || X === void 0 ? void 0 : X.labelParams,
      ...X === null || X === void 0 ? void 0 : X.visualParams
    }, { tags: X === null || X === void 0 ? void 0 : X.reprTags }), q = this.plugin.state.data;
    return await h1.State.Update(this.plugin, { state: q, tree: N, options: { doNotLogTiming: !0 } }), { selection: H.selector, representation: N.selector };
  }
  async addDihedral(Z, J, $, X, Y) {
    let Q = this.plugin.helpers.substructureParent.get(Z.structure), W = this.plugin.helpers.substructureParent.get(J.structure), K = this.plugin.helpers.substructureParent.get($.structure), G = this.plugin.helpers.substructureParent.get(X.structure);
    if (!Q || !W || !K || !G)
      return;
    let H = [Q.transform.ref];
    n9(H, W.transform.ref), n9(H, K.transform.ref), n9(H, G.transform.ref);
    let q = this.getGroup().apply(H1.Model.MultiStructureSelectionFromBundle, {
      selections: [
        { key: "a", ref: Q.transform.ref, ...gK(Z) },
        { key: "b", ref: W.transform.ref, ...gK(J) },
        { key: "c", ref: K.transform.ref, ...gK($) },
        { key: "d", ref: G.transform.ref, ...gK(X) }
      ],
      isTransitive: !0,
      label: "Dihedral"
    }, { dependsOn: H, tags: Y === null || Y === void 0 ? void 0 : Y.selectionTags }), U = q.apply(H1.Representation.StructureSelectionsDihedral3D, {
      customText: (Y === null || Y === void 0 ? void 0 : Y.customText) || "",
      textColor: this.state.options.textColor,
      ...Y === null || Y === void 0 ? void 0 : Y.lineParams,
      ...Y === null || Y === void 0 ? void 0 : Y.labelParams,
      ...Y === null || Y === void 0 ? void 0 : Y.visualParams
    }, { tags: Y === null || Y === void 0 ? void 0 : Y.reprTags }), F = this.plugin.state.data;
    return await h1.State.Update(this.plugin, { state: F, tree: U, options: { doNotLogTiming: !0 } }), { selection: q.selector, representation: U.selector };
  }
  async addLabel(Z, J) {
    let $ = this.plugin.helpers.substructureParent.get(Z.structure);
    if (!$)
      return;
    let X = [$.transform.ref], Q = this.getGroup().apply(H1.Model.MultiStructureSelectionFromBundle, {
      selections: [
        { key: "a", ref: $.transform.ref, ...gK(Z) }
      ],
      isTransitive: !0,
      label: "Label"
    }, { dependsOn: X, tags: J === null || J === void 0 ? void 0 : J.selectionTags }), W = Q.apply(H1.Representation.StructureSelectionsLabel3D, {
      textColor: this.state.options.textColor,
      ...J === null || J === void 0 ? void 0 : J.labelParams,
      ...J === null || J === void 0 ? void 0 : J.visualParams
    }, { tags: J === null || J === void 0 ? void 0 : J.reprTags }), K = this.plugin.state.data;
    return await h1.State.Update(this.plugin, { state: K, tree: W, options: { doNotLogTiming: !0 } }), { selection: Q.selector, representation: W.selector };
  }
  async addOrientation(Z) {
    let J = [], $ = [];
    for (let K = 0, G = Z.length;K < G; ++K) {
      let H = Z[K], N = this.plugin.helpers.substructureParent.get(H.structure);
      if (!N)
        continue;
      n9($, N.transform.ref), J.push({ key: `l${K}`, ref: N.transform.ref, ...gK(H) });
    }
    if (J.length === 0)
      return;
    let Y = this.getGroup().apply(H1.Model.MultiStructureSelectionFromBundle, {
      selections: J,
      isTransitive: !0,
      label: "Orientation"
    }, { dependsOn: $ }), Q = Y.apply(H1.Representation.StructureSelectionsOrientation3D), W = this.plugin.state.data;
    return await h1.State.Update(this.plugin, { state: W, tree: Q, options: { doNotLogTiming: !0 } }), { selection: Y.selector, representation: Q.selector };
  }
  async addPlane(Z) {
    let J = [], $ = [];
    for (let K = 0, G = Z.length;K < G; ++K) {
      let H = Z[K], N = this.plugin.helpers.substructureParent.get(H.structure);
      if (!N)
        continue;
      n9($, N.transform.ref), J.push({ key: `l${K}`, ref: N.transform.ref, ...gK(H) });
    }
    if (J.length === 0)
      return;
    let X = this.getGroup(), Y = X.apply(H1.Model.MultiStructureSelectionFromBundle, {
      selections: J,
      isTransitive: !0,
      label: "Plane"
    }, { dependsOn: $ }), Q = Y.apply(H1.Representation.StructureSelectionsPlane3D), W = this.plugin.state.data;
    return await h1.State.Update(this.plugin, { state: W, tree: X, options: { doNotLogTiming: !0 } }), { selection: Y.selector, representation: Q.selector };
  }
  async addOrderLabels(Z) {
    let J = this.getGroup(), $ = this.plugin.state.data.select(f2.Generators.ofType(D0.Molecule.Structure.Selections).withTag(Ng));
    for (let Q of $)
      J.delete(Q);
    let X = 1;
    for (let Q of Z) {
      let W = this.plugin.helpers.substructureParent.get(Q.structure);
      if (!W)
        continue;
      let K = [W.transform.ref];
      J.apply(H1.Model.MultiStructureSelectionFromBundle, {
        selections: [
          { key: "a", ref: W.transform.ref, ...gK(Q) }
        ],
        isTransitive: !0,
        label: "Order"
      }, { dependsOn: K, tags: Ng }).apply(H1.Representation.StructureSelectionsLabel3D, {
        textColor: i0.fromRgb(255, 255, 255),
        borderColor: i0.fromRgb(0, 0, 0),
        textSize: 0.33,
        borderWidth: 0.3,
        offsetZ: 0.75,
        customText: `${X++}`
      }, { tags: Ng });
    }
    let Y = this.plugin.state.data;
    return await h1.State.Update(this.plugin, { state: Y, tree: J, options: { doNotLogTiming: !0 } }), { representation: J.selector };
  }
  getTransforms(Z) {
    let J = this.plugin.state.data, $ = f2.findTagInSubtree(J.tree, D8.RootRef, T20), X = $ ? J.select(f2.Generators.ofTransformer(Z, $)) : this._empty;
    if (X.length === 0)
      return this._empty;
    return X;
  }
  sync() {
    let Z = [];
    for (let $ of this.getTransforms(H1.Representation.StructureSelectionsLabel3D)) {
      let X = $.obj.tags;
      if (!X || !X.includes(Ng))
        Z.push($);
    }
    if (this.updateState({
      labels: Z,
      distances: this.getTransforms(H1.Representation.StructureSelectionsDistance3D),
      angles: this.getTransforms(H1.Representation.StructureSelectionsAngle3D),
      dihedrals: this.getTransforms(H1.Representation.StructureSelectionsDihedral3D),
      orientations: this.getTransforms(H1.Representation.StructureSelectionsOrientation3D),
      planes: this.getTransforms(H1.Representation.StructureSelectionsPlane3D)
    }))
      this.stateUpdated();
  }
  constructor(Z) {
    super({ labels: [], distances: [], angles: [], dihedrals: [], orientations: [], planes: [], options: dM1 });
    this.plugin = Z, this.behaviors = {
      state: this.ev.behavior(this.state)
    }, this._empty = [], Z.state.data.events.changed.subscribe((J) => {
      if (J.inTransaction || Z.behaviors.state.isAnimating.value)
        return;
      this.sync();
    }), Z.behaviors.state.isAnimating.subscribe((J) => {
      if (!J && !Z.behaviors.state.isUpdating.value)
        this.sync();
    });
  }
}

// node_modules/molstar/lib/mol-plugin-ui/structure/selection.js
var s8 = t2(PZ(), 1), Gk0 = t2(J7(), 1);

// node_modules/molstar/lib/mol-plugin-state/manager/interactivity.js
class yH extends pX {
  get props() {
    return { ...this.state.props };
  }
  setProps(Z) {
    let J = this.props, $ = { ...this.state.props, ...Z };
    if (iL(J, $))
      return;
    this.updateState({ props: $ }), this.lociSelects.setProps($), this.lociHighlights.setProps($), this.events.propsUpdated.next(void 0);
  }
  dispose() {
    super.dispose(), this.lociSelects.dispose(), this.lociHighlights.dispose();
  }
  constructor(Z, J = {}) {
    super({ props: { ...j.getDefaultValues(yH.Params), ...J } });
    this.plugin = Z, this._props = j.getDefaultValues(yH.Params), this.events = {
      propsUpdated: this.ev()
    }, this.lociSelects = new yH.LociSelectManager(Z, this._props), this.lociHighlights = new yH.LociHighlightManager(Z, this._props);
  }
}
(function(Z) {
  Z.Params = {
    granularity: j.Select("residue", d2.GranularityOptions, { label: "Picking Level", description: "Controls if selections are expanded upon picking to whole residues, chains, structures, instances, or left as atoms and coarse elements" })
  };

  class J {
    setProps(Y) {
      Object.assign(this.props, Y);
    }
    addProvider(Y) {
      this.providers.push(Y);
    }
    removeProvider(Y) {
      this.providers = this.providers.filter((Q) => Q !== Y);
    }
    normalizedLoci(Y, Q, W = !1) {
      let { loci: K, repr: G } = Y, H = Q ? this.props.granularity : void 0;
      return { loci: d2.normalize(K, H, W), repr: G };
    }
    mark(Y, Q, W = !1) {
      if (!d2.isEmpty(Y.loci))
        for (let K of this.providers)
          K(Y, Q, W);
    }
    dispose() {
      this.providers.length = 0, this.sel.dispose();
    }
    constructor(Y, Q = {}) {
      this.ctx = Y, this.providers = [], this.props = j.getDefaultValues(Z.Params), this.sel = Y.managers.structure.selection, this.setProps(Q);
    }
  }
  Z.LociMarkManager = J;

  class $ extends J {
    constructor() {
      super(...arguments);
      this.prev = [], this.clearHighlights = (Y = !1) => {
        for (let Q of this.prev)
          this.mark(Q, x2.RemoveHighlight, Y);
        this.prev.length = 0;
      };
    }
    isHighlighted(Y) {
      for (let Q of this.prev)
        if (V2.Loci.areEqual(Q, Y))
          return !0;
      return !1;
    }
    addHighlight(Y) {
      this.mark(Y, x2.Highlight), this.prev.push(Y);
    }
    highlight(Y, Q = !0) {
      let W = this.normalizedLoci(Y, Q);
      if (!this.isHighlighted(W))
        this.addHighlight(W);
    }
    highlightOnly(Y, Q = !0) {
      let W = this.normalizedLoci(Y, Q);
      if (!this.isHighlighted(W))
        if (d2.isEmpty(W.loci))
          this.clearHighlights();
        else
          this.clearHighlights(!0), this.addHighlight(W);
    }
    highlightOnlyExtend(Y, Q = !0) {
      let W = this.normalizedLoci(Y, Q);
      if (W0.Loci.is(W.loci)) {
        let K = this.ctx.selectionMode ? this.sel.tryGetRange(W.loci) : this.ctx.managers.structure.focus.tryGetRange(W.loci), G = {
          loci: K !== null && K !== void 0 ? K : W.loci,
          repr: W.repr
        };
        if (!this.isHighlighted(G))
          if (d2.isEmpty(G.loci))
            this.clearHighlights();
          else
            this.clearHighlights(!0), this.addHighlight(G);
      }
    }
    dispose() {
      super.dispose(), this.prev.length = 0;
    }
  }
  Z.LociHighlightManager = $;

  class X extends J {
    toggle(Y, Q = !0) {
      if (d2.isEmpty(Y.loci))
        return;
      let W = this.normalizedLoci(Y, Q, !0);
      if (W0.Loci.is(W.loci))
        this.toggleSel(W);
      else
        super.mark(W, x2.Toggle);
    }
    toggleExtend(Y, Q = !0) {
      if (d2.isEmpty(Y.loci))
        return;
      let W = this.normalizedLoci(Y, Q, !0);
      if (W0.Loci.is(W.loci)) {
        let K = this.sel.tryGetRange(W.loci) || W.loci;
        this.toggleSel({ loci: K, repr: W.repr });
      }
    }
    select(Y, Q = !0) {
      let W = this.normalizedLoci(Y, Q, !0);
      if (W0.Loci.is(W.loci))
        this.sel.modify("add", W.loci);
      this.mark(W, x2.Select);
    }
    selectJoin(Y, Q = !0) {
      let W = this.normalizedLoci(Y, Q, !0);
      if (W0.Loci.is(W.loci))
        this.sel.modify("intersect", W.loci);
      this.mark(W, x2.Select);
    }
    selectOnly(Y, Q = !0) {
      let W = this.normalizedLoci(Y, Q, !0);
      if (W0.Loci.is(W.loci))
        this.mark({ loci: s0.Loci(W.loci.structure), repr: W.repr }, x2.Deselect), this.sel.modify("set", W.loci);
      this.mark(W, x2.Select);
    }
    deselect(Y, Q = !0) {
      let W = this.normalizedLoci(Y, Q, !0);
      if (W0.Loci.is(W.loci))
        this.sel.modify("remove", W.loci);
      this.mark(W, x2.Deselect);
    }
    deselectAll() {
      this.sel.clear(), this.mark({ loci: nN }, x2.Deselect);
    }
    deselectAllOnEmpty(Y) {
      if (_7(Y.loci))
        this.deselectAll();
    }
    mark(Y, Q) {
      let { loci: W } = Y;
      if (!d2.isEmpty(W))
        if (W0.Loci.is(W)) {
          let K = this.sel.getLoci(W.structure);
          super.mark({ loci: s0.Loci(W.structure) }, x2.Deselect, !d2.isEmpty(K)), super.mark({ loci: K }, x2.Select);
        } else
          super.mark(Y, Q);
    }
    toggleSel(Y) {
      if (this.sel.has(Y.loci))
        this.sel.modify("remove", Y.loci), this.mark(Y, x2.Deselect);
      else
        this.sel.modify("add", Y.loci), this.mark(Y, x2.Select);
    }
  }
  Z.LociSelectManager = X;
})(yH || (yH = {}));

// node_modules/molstar/lib/mol-script/util/id-list.js
function pM1(Z, J) {
  var $;
  let X = [], Y = J === "auth" ? "auth_asym_id" : "label_asym_id", Q = J === "auth" ? "auth_seq_id" : "label_seq_id";
  for (let K of Z)
    if (K.kind === "range")
      X.push(L0.struct.generator.atomGroups({
        "chain-test": L0.core.rel.eq([L0.ammp(Y), K.asym_id]),
        "residue-test": L0.core.rel.inRange([L0.ammp(Q), K.seq_id_beg, K.seq_id_end])
      }));
    else {
      let G = (($ = K.ins_code) !== null && $ !== void 0 ? $ : "").trim();
      X.push(L0.struct.generator.atomGroups({
        "chain-test": L0.core.rel.eq([L0.ammp(Y), K.asym_id]),
        "residue-test": L0.core.logic.and([
          L0.core.rel.eq([L0.ammp(Q), K.seq_id]),
          L0.core.rel.eq([L0.ammp("pdbx_PDB_ins_code"), G])
        ])
      }));
    }
  let W = L0.struct.combinator.merge(X);
  return PW(W);
}
function uM1(Z) {
  let J = o6.create();
  for (let [X, Y] of Z)
    for (let Q = X;Q <= Y; Q++)
      o6.add(J, Q, Q);
  let $ = L0.struct.generator.atomGroups({
    "atom-test": L0.core.set.has([L0.set(...J.array), L0.ammp("id")])
  });
  return PW($);
}
function cM1(Z) {
  let J = o6.create();
  for (let [X, Y] of Z)
    for (let Q = X;Q <= Y; Q++)
      o6.add(J, Q.toString(), Q.toString());
  let $ = L0.struct.generator.atomGroups({
    "atom-test": L0.core.set.has([L0.set(...J.array), L0.acp("elementSymbol")])
  });
  return PW($);
}
function lM1(Z) {
  let J = L0.struct.generator.atomGroups({
    "atom-test": L0.core.set.has([L0.set(...Z), L0.acp("elementSymbol")])
  });
  return PW(J);
}
function nM1(Z, J, $) {
  if (!Z || J.length === 0 || Number.isNaN(+J[0]))
    return;
  if (Number.isNaN($))
    return { kind: "single", asym_id: Z, seq_id: +J[0], ins_code: J[1] };
  return { kind: "range", asym_id: Z, seq_id_beg: +J[0], seq_id_end: $ };
}
function iM1(Z) {
  if (!Z)
    return [];
  return Z.split(":");
}
function oM1(Z) {
  return Z.split(",").map((J) => J.trim().split(/\s+|[-]/g).filter(($) => !!$)).map((J) => nM1(J[0], iM1(J[1]), +J[2])).filter((J) => !!J);
}
function Wk0(Z) {
  return Z.split(",").map((J) => J.trim().split(/\s+|[-]/g).filter(($) => !!$)).filter((J) => J.length === 1 || J.length === 2).map((J) => J.length === 1 ? [+J[0], +J[0]] : [+J[0], +J[1]]);
}
function Kk0(Z, J) {
  if (J === "atom-id") {
    let $ = Wk0(Z);
    return uM1($);
  } else if (J === "element-symbol")
    if (/[a-zA-Z]/.test(Z))
      return lM1(Z.split(",").map((X) => X.trim()));
    else {
      let X = Wk0(Z);
      return cM1(X);
    }
  else {
    let $ = oM1(Z);
    return pM1($, J);
  }
}

// node_modules/molstar/lib/mol-plugin-ui/viewport/help.js
var S8 = t2(PZ(), 1), qg = t2(J7(), 1);
function sM1(Z) {
  return Object.keys(Z).map((J) => [J, Z[J]]).filter((J) => e1.isBinding(J[1]));
}

class YP extends qg.PureComponent {
  getBindingComponents() {
    let Z = sM1(this.props.bindings);
    return S8.jsx(S8.Fragment, { children: Z.map((J) => {
      let [$, X] = J;
      return !e1.isEmpty(X) ? S8.jsxs("div", { style: { marginBottom: "6px" }, children: [S8.jsx("b", { children: X.action }), S8.jsx("br", {}), S8.jsx("span", { dangerouslySetInnerHTML: { __html: e1.format(X, $) } })] }, $) : null;
    }) });
  }
  render() {
    return S8.jsx(YG, { children: this.getBindingComponents() });
  }
}

class YG extends qg.PureComponent {
  render() {
    return S8.jsx("div", { className: "msp-help-text", children: S8.jsx("div", { children: this.props.children }) });
  }
}

class QG extends qg.PureComponent {
  constructor() {
    super(...arguments);
    this.state = {
      header: this.props.header,
      isExpanded: !!this.props.initiallyExpanded
    }, this.toggleExpanded = () => this.setState({ isExpanded: !this.state.isExpanded });
  }
  render() {
    return S8.jsxs("div", { className: "msp-control-group-wrapper", children: [S8.jsx("div", { className: "msp-control-group-header", children: S8.jsxs(Z8, { onClick: this.toggleExpanded, children: [S8.jsx(b6, { svg: this.state.isExpanded ? JW : $W }), this.props.header] }) }), this.state.isExpanded && S8.jsx("div", { className: "msp-control-offset", style: { display: this.state.isExpanded ? "block" : "none" }, children: this.props.children })] });
  }
}
function I20(Z) {
  return S8.jsx("div", { className: "msp-simple-help-section", children: Z.header });
}

class gB extends I8 {
  constructor() {
    super(...arguments);
    this.getInteractionBindings = cJ((Z) => {
      let J = void 0;
      return Z.forEach(($) => {
        var X;
        let Y = (X = $.params) === null || X === void 0 ? void 0 : X.values;
        if ((Y === null || Y === void 0 ? void 0 : Y.bindings) && Object.keys(Y.bindings).length > 0) {
          if (!J)
            J = {};
          Object.assign(J, Y.bindings);
        }
      }), J;
    });
  }
  componentDidMount() {
    this.subscribe(this.plugin.events.canvas3d.settingsUpdated, () => this.forceUpdate());
  }
  render() {
    let Z = this.getInteractionBindings(this.plugin.state.behaviors.cells);
    return S8.jsxs(S8.Fragment, { children: [!this.props.selectOnly && this.plugin.canvas3d && S8.jsx(QG, { header: "Moving in 3D", children: S8.jsx(YP, { bindings: this.plugin.canvas3d.attribs.trackball.bindings }) }, "trackball"), !!Z && S8.jsx(QG, { header: "Mouse & Key Controls", children: S8.jsx(YP, { bindings: Z }) }, "interactions")] });
  }
}

class P20 extends I8 {
  componentDidMount() {
    this.subscribe(this.plugin.events.canvas3d.settingsUpdated, () => this.forceUpdate());
  }
  formatTriggers(Z) {
    return Z.triggers.map((J) => e1.Trigger.format(J)).join(" or ");
  }
  getTriggerFor(Z, J) {
    let X = this.plugin.state.behaviors.select(f2.Generators.ofTransformer(Z)), Y = X.length === 1 ? X[0].params : void 0, Q = Y ? Y.values.bindings : {}, W = J in Q ? Q[J] : e1.Empty;
    return this.formatTriggers(W);
  }
  render() {
    let Z = this.getTriggerFor(J00, "clickSelectToggle"), J = this.getTriggerFor(pz, "clickFocus");
    return S8.jsxs("div", { children: [S8.jsx(I20, { header: "Interface Controls" }), S8.jsxs(QG, { header: "Inline Help", children: [S8.jsx(YG, { children: "Many user interface elements show a little questionmark icon when hovered over. Clicking the icon toggles the display of an inline help text." }), S8.jsx(YG, { children: "Tooltips may provide additional information on a user interface element and are shown when hovering over it with the mouse." })] }), S8.jsx(QG, { header: "Selections", children: S8.jsxs(YG, { children: ["The viewer allows changing colors and representations for selections of atoms, residues or chains. Selections can be created by", S8.jsxs("ul", { style: { paddingLeft: "20px" }, children: [S8.jsxs("li", { children: ["picking elements on the 3D canvas or the sequence view using the mouse, e.g. toggle selection using ", Z, " (for more see help section on ", S8.jsx("i", { children: "Mouse Controls" }), ")"] }), S8.jsxs("li", { children: ["using the ", S8.jsx("i", { children: "Add" }), ", ", S8.jsx("i", { children: "Remove" }), " and ", S8.jsx("i", { children: "Only" }), " dropdown buttons in the ", S8.jsx("i", { children: "Manage Selection" }), " panel which allow modifing the current selection by predefined sets"] })] })] }) }), S8.jsx(QG, { header: "Coloring", children: S8.jsxs(YG, { children: ["There are two ways to color structures. Every representation (e.g. cartoon or spacefill) has a color theme which can be changed using the dropdown for each representation in the ", S8.jsx("i", { children: "Structure Settings" }), " panel. Additionally any selection atoms, residues or chains can by given a custom color. For that, first select the parts of the structure to be colored (see help section on ", S8.jsx("i", { children: "Selections" }), ") and, second, choose a color from the color dropdown botton in the ", S8.jsx("i", { children: "Selection" }), " row of the ", S8.jsx("i", { children: "Change Representation" }), " panel. The theme color can be seen as a base color that is overpainted by the custom color. Custom colors can be removed for a selection with the 'Clear' option in the color dropdown."] }) }), S8.jsx(QG, { header: "Representations", children: S8.jsxs(YG, { children: ["Structures can be shown with many different representations (e.g. cartoon or spacefill). The ", S8.jsx("i", { children: "Change Representation" }), " panel offers a collection of predefined styles which can be applied using the ", S8.jsx("i", { children: "Preset" }), " dropdown button. Additionally any selection atoms, residues or chains can by shown with a custom representation. For that, first select the parts of the structure to be mofified (see help section on ", S8.jsx("i", { children: "Selections" }), ") and, second, choose a representation to hide or show from the ", S8.jsx("i", { children: "Show" }), " and ", S8.jsx("i", { children: "Hide" }), " dropdown bottons in the ", S8.jsx("i", { children: "Selection" }), " row of the ", S8.jsx("i", { children: "Change Representation" }), " panel. The ", S8.jsx("i", { children: "Everything" }), " row applies the action to the whole structure instead of the current selection."] }) }), S8.jsx(QG, { header: "Surroundings", children: S8.jsxs(YG, { children: ["To show the surroundings of a residue or ligand, click it in the 3D scene or in the sequence widget using ", J, "."] }) }), S8.jsx(I20, { header: "How-to Guides" }), S8.jsx(QG, { header: "Create an Image", children: S8.jsxs(YG, { children: [S8.jsxs("p", { children: ["Use the ", S8.jsx(b6, { svg: fV0 }), " icon in the viewport to bring up the screenshot controls."] }), S8.jsxs("p", { children: ["To adjust the size of the image, use the ", S8.jsx("i", { children: "Resolution" }), " dropdown."] })] }) }), S8.jsx(I20, { header: "Mouse Controls" }), S8.jsx(gB, {})] });
  }
}

// node_modules/molstar/lib/mol-plugin-ui/structure/selection.js
class q4 extends N7 {
  constructor() {
    super(...arguments);
    this._toggleSelMode = () => {
      this.plugin.selectionMode = !this.plugin.selectionMode;
    };
  }
  componentDidMount() {
    this.subscribe(this.plugin.events.canvas3d.settingsUpdated, () => this.forceUpdate()), this.subscribe(this.plugin.layout.events.updated, () => this.forceUpdate()), this.subscribe(this.plugin.behaviors.interaction.selectionMode, () => this.forceUpdate());
  }
  render() {
    let Z = this.props.inline ? { background: "transparent", width: "auto", height: "auto", lineHeight: "unset" } : { background: "transparent" };
    return s8.jsx(o2, { svg: sV0, onClick: this._toggleSelMode, title: "Toggle Selection Mode", style: Z, toggleState: this.plugin.selectionMode });
  }
}
var Fg = {
  granularity: yH.Params.granularity
}, mB = /* @__PURE__ */ new Map([
  ["add", "Add/Union Selection"],
  ["remove", "Remove/Subtract Selection"],
  ["intersect", "Intersect Selection"],
  ["set", "Set Selection"]
]);

class C20 extends I8 {
  constructor() {
    super(...arguments);
    this.state = {
      action: void 0,
      helper: void 0,
      isEmpty: !0,
      isBusy: !1,
      canUndo: !1,
      structureSelectionParams: Fg
    }, this.set = (Z, J) => {
      this.plugin.managers.structure.selection.fromSelectionQuery(Z, J, !1);
    }, this.selectQuery = (Z, J) => {
      if (!Z || !this.state.action) {
        this.setState({ action: void 0 });
        return;
      }
      let $ = this.state.action;
      if (J === null || J === void 0 ? void 0 : J.shiftKey)
        this.set($, Z.value);
      else
        this.setState({ action: void 0 }, () => {
          this.set($, Z.value);
        });
    }, this.selectHelper = (Z, J) => {
      if (console.log(Z), !Z || !this.state.action) {
        this.setState({ action: void 0, helper: void 0 });
        return;
      }
      this.setState({ helper: Z.value.kind });
    }, this.queriesItems = [], this.queriesVersion = -1, this.helpersItems = void 0, this.toggleAdd = this.showAction("add"), this.toggleRemove = this.showAction("remove"), this.toggleIntersect = this.showAction("intersect"), this.toggleSet = this.showAction("set"), this.toggleTheme = this.showAction("theme"), this.toggleAddComponent = this.showAction("add-component"), this.toggleHelp = this.showAction("help"), this.setGranuality = ({ value: Z }) => {
      this.plugin.managers.interactivity.setProps({ granularity: Z });
    }, this.turnOff = () => this.plugin.selectionMode = !1, this.undo = () => {
      let Z = this.plugin.state.data.undo();
      if (Z)
        this.plugin.runTask(Z);
    }, this.subtract = () => {
      let Z = this.plugin.managers.structure.hierarchy.getStructuresWithSelection(), J = [];
      for (let $ of Z)
        J.push(...$.components);
      if (J.length === 0)
        return;
      this.plugin.managers.structure.component.modifyByCurrentSelection(J, "subtract");
    };
  }
  componentDidMount() {
    var Z, J;
    this.subscribe(this.plugin.managers.structure.hierarchy.behaviors.selection, (X) => {
      let Y = X.hierarchy.structures.length === 0;
      if (this.state.isEmpty !== Y)
        this.setState({ isEmpty: Y });
      this.queriesVersion = -1, this.forceUpdate();
    }), this.subscribe(this.plugin.behaviors.state.isBusy, (X) => {
      this.setState({ isBusy: X, action: void 0 });
    }), this.subscribe(this.plugin.managers.interactivity.events.propsUpdated, () => {
      this.forceUpdate();
    }), this.subscribe(this.plugin.state.data.events.historyUpdated, ({ state: X }) => {
      this.setState({ canUndo: X.canUndo });
    });
    let $ = (J = (Z = this.plugin.spec.components) === null || Z === void 0 ? void 0 : Z.selectionTools) === null || J === void 0 ? void 0 : J.granularityOptions;
    if ($) {
      let X = new Set($), Y = {
        ...Fg,
        granularity: {
          ...Fg.granularity,
          options: Fg.granularity.options.filter(([Q]) => X.has(Q))
        }
      };
      this.setState({ structureSelectionParams: Y });
    }
  }
  get isDisabled() {
    return this.state.isBusy || this.state.isEmpty;
  }
  get structures() {
    var Z;
    let J = [];
    for (let $ of this.plugin.managers.structure.hierarchy.selection.structures) {
      let X = (Z = $.cell.obj) === null || Z === void 0 ? void 0 : Z.data;
      if (X)
        J.push(X);
    }
    return J;
  }
  get queries() {
    let { registry: Z } = this.plugin.query.structure;
    if (Z.version !== this.queriesVersion) {
      let J = this.structures, $ = [
        ...Z.list,
        ...gM0(J),
        ...yM0(J),
        ...xM0(J)
      ].sort((X, Y) => Y.priority - X.priority);
      this.queriesItems = w8.createItems($, {
        filter: (X) => X !== u9.current && !X.isHidden,
        label: (X) => X.label,
        category: (X) => X.category,
        description: (X) => X.description
      }), this.queriesVersion = Z.version;
    }
    return this.queriesItems;
  }
  get helpers() {
    if (this.helpersItems)
      return this.helpersItems;
    let Z = [
      { kind: "residue-list", category: "Helpers", label: "Atom/Residue Identifier List", description: "Create a selection from a list of atom/residue ranges." }
    ];
    return this.helpersItems = w8.createItems(Z, {
      label: (J) => J.label,
      category: (J) => J.category,
      description: (J) => J.description
    }), this.helpersItems;
  }
  showAction(Z) {
    return () => this.setState({ action: this.state.action === Z ? void 0 : Z, helper: void 0 });
  }
  render() {
    var Z, J;
    let $ = this.plugin.managers.interactivity.props.granularity, X = (J = (Z = this.plugin.spec.components) === null || Z === void 0 ? void 0 : Z.selectionTools) === null || J === void 0 ? void 0 : J.hide, Y = this.state.canUndo ? `Undo ${this.plugin.state.data.latestUndoLabel}` : "Some mistakes of the past can be undone.", Q = void 0;
    if (this.state.action && !this.state.helper)
      Q = s8.jsxs(s8.Fragment, { children: [this.state.action && this.state.action !== "theme" && this.state.action !== "add-component" && this.state.action !== "help" && s8.jsxs("div", { className: "msp-selection-viewport-controls-actions", children: [s8.jsx(w8, { header: mB.get(this.state.action), title: "Click to close.", items: this.queries, onSelect: this.selectQuery, noOffset: !0 }), s8.jsx(w8, { items: this.helpers, onSelect: this.selectHelper, noOffset: !0 })] }), this.state.action === "theme" && s8.jsx("div", { className: "msp-selection-viewport-controls-actions", children: s8.jsx(zQ, { header: "Theme", title: "Click to close.", initialExpanded: !0, hideExpander: !0, hideOffset: !0, onHeaderClick: this.toggleTheme, topRightIcon: cW, children: s8.jsx(Hk0, { onApply: this.toggleTheme }) }) }), this.state.action === "add-component" && s8.jsx("div", { className: "msp-selection-viewport-controls-actions", children: s8.jsx(zQ, { header: "Add Component", title: "Click to close.", initialExpanded: !0, hideExpander: !0, hideOffset: !0, onHeaderClick: this.toggleAddComponent, topRightIcon: cW, children: s8.jsx(Hg, { onApply: this.toggleAddComponent, forSelection: !0 }) }) }), this.state.action === "help" && s8.jsx("div", { className: "msp-selection-viewport-controls-actions", children: s8.jsxs(zQ, { header: "Help", title: "Click to close.", initialExpanded: !0, hideExpander: !0, hideOffset: !0, onHeaderClick: this.toggleHelp, topRightIcon: cW, maxHeight: "300px", children: [s8.jsx(QG, { header: "Selection Operations", children: s8.jsxs(YG, { children: ["Use ", s8.jsx(b6, { svg: jI, inline: !0 }), " ", s8.jsx(b6, { svg: TI, inline: !0 }), " ", s8.jsx(b6, { svg: _I, inline: !0 }), " ", s8.jsx(b6, { svg: nz, inline: !0 }), " to modify the selection."] }) }), s8.jsx(QG, { header: "Representation Operations", children: s8.jsxs(YG, { children: ["Use ", s8.jsx(b6, { svg: Ny, inline: !0 }), " ", s8.jsx(b6, { svg: VI, inline: !0 }), " ", s8.jsx(b6, { svg: kI, inline: !0 }), " ", s8.jsx(b6, { svg: vI, inline: !0 }), " to color, create components, remove from components, or undo actions."] }) }), s8.jsx(gB, { selectOnly: !0 })] }) })] });
    else if (mB.has(this.state.action) && this.state.helper === "residue-list") {
      let W = () => this.setState({ action: void 0, helper: void 0 });
      Q = s8.jsx("div", { className: "msp-selection-viewport-controls-actions", children: s8.jsx(zQ, { header: "Atom/Residue Identifier List", title: "Click to close.", initialExpanded: !0, hideExpander: !0, hideOffset: !0, onHeaderClick: W, topRightIcon: cW, children: s8.jsx(rM1, { modifier: this.state.action, plugin: this.plugin, close: W }) }) });
    }
    return s8.jsxs(s8.Fragment, { children: [s8.jsxs("div", { className: "msp-flex-row", style: { background: "none" }, children: [!(X === null || X === void 0 ? void 0 : X.granularity) && s8.jsx(_U, { title: "Picking Level for selecting and highlighting", param: this.state.structureSelectionParams.granularity, name: "granularity", value: $, onChange: this.setGranuality, isDisabled: this.isDisabled }), !(X === null || X === void 0 ? void 0 : X.union) && s8.jsx(D7, { icon: jI, title: `${mB.get("add")}. Hold shift key to keep menu open.`, toggle: this.toggleAdd, isSelected: this.state.action === "add", disabled: this.isDisabled }), !(X === null || X === void 0 ? void 0 : X.subtract) && s8.jsx(D7, { icon: TI, title: `${mB.get("remove")}. Hold shift key to keep menu open.`, toggle: this.toggleRemove, isSelected: this.state.action === "remove", disabled: this.isDisabled }), !(X === null || X === void 0 ? void 0 : X.intersect) && s8.jsx(D7, { icon: _I, title: `${mB.get("intersect")}. Hold shift key to keep menu open.`, toggle: this.toggleIntersect, isSelected: this.state.action === "intersect", disabled: this.isDisabled }), !(X === null || X === void 0 ? void 0 : X.set) && s8.jsx(D7, { icon: nz, title: `${mB.get("set")}. Hold shift key to keep menu open.`, toggle: this.toggleSet, isSelected: this.state.action === "set", disabled: this.isDisabled }), !(X === null || X === void 0 ? void 0 : X.theme) && s8.jsx(D7, { icon: Ny, title: "Apply Theme to Selection", toggle: this.toggleTheme, isSelected: this.state.action === "theme", disabled: this.isDisabled, style: { marginLeft: "10px" } }), !(X === null || X === void 0 ? void 0 : X.componentAdd) && s8.jsx(D7, { icon: VI, title: "Create Component of Selection with Representation", toggle: this.toggleAddComponent, isSelected: this.state.action === "add-component", disabled: this.isDisabled }), !(X === null || X === void 0 ? void 0 : X.componentRemove) && s8.jsx(o2, { svg: kI, title: "Remove/subtract Selection from all Components", onClick: this.subtract, disabled: this.isDisabled }), !(X === null || X === void 0 ? void 0 : X.undo) && s8.jsx(o2, { svg: vI, onClick: this.undo, disabled: !this.state.canUndo || this.isDisabled, title: Y }), !(X === null || X === void 0 ? void 0 : X.help) && s8.jsx(D7, { icon: OQ, title: "Show/hide help", toggle: this.toggleHelp, style: { marginLeft: "10px" }, isSelected: this.state.action === "help" }), !(X === null || X === void 0 ? void 0 : X.cancel) && this.plugin.config.get(W8.Viewport.ShowSelectionMode) && s8.jsx(o2, { svg: II, title: "Turn selection mode off", onClick: this.turnOff })] }), Q] });
  }
}

class k20 extends I8 {
  constructor() {
    super(...arguments);
    this.state = {
      isEmpty: !0,
      isBusy: !1
    }, this.clear = () => this.plugin.managers.interactivity.lociSelects.deselectAll(), this.focus = () => {
      if (this.plugin.managers.structure.selection.stats.elementCount === 0)
        return;
      let { sphere: Z } = this.plugin.managers.structure.selection.getBoundary();
      this.plugin.managers.camera.focusSphere(Z);
    }, this.highlight = (Z) => {
      this.plugin.managers.interactivity.lociHighlights.clearHighlights(), this.plugin.managers.structure.selection.entries.forEach((J) => {
        this.plugin.managers.interactivity.lociHighlights.highlight({ loci: J.selection }, !1);
      });
    }, this.clearHighlight = () => {
      this.plugin.managers.interactivity.lociHighlights.clearHighlights();
    };
  }
  componentDidMount() {
    this.subscribe(this.plugin.managers.structure.selection.events.changed, () => {
      this.forceUpdate();
    }), this.subscribe(this.plugin.managers.structure.hierarchy.behaviors.selection, (Z) => {
      let J = Z.structures.length === 0;
      if (this.state.isEmpty !== J)
        this.setState({ isEmpty: J });
    }), this.subscribe(this.plugin.behaviors.state.isBusy, (Z) => {
      this.setState({ isBusy: Z });
    });
  }
  get isDisabled() {
    return this.state.isBusy || this.state.isEmpty;
  }
  get stats() {
    let Z = this.plugin.managers.structure.selection.stats;
    if (Z.structureCount === 0 || Z.elementCount === 0)
      return "Nothing Selected";
    else
      return `${MK(Z.label)} Selected`;
  }
  render() {
    let Z = this.plugin.managers.structure.selection.stats, J = Z.structureCount === 0 || Z.elementCount === 0;
    if (J && this.props.hideOnEmpty)
      return null;
    return s8.jsx(s8.Fragment, { children: s8.jsxs("div", { className: "msp-flex-row", children: [s8.jsx(Z8, { noOverflow: !0, onClick: this.focus, title: "Click to Focus Selection", disabled: J, onMouseEnter: this.highlight, onMouseLeave: this.clearHighlight, style: { textAlignLast: !J ? "left" : void 0 }, children: this.stats }), !J && s8.jsx(o2, { svg: II, onClick: this.clear, title: "Clear", className: "msp-form-control", flex: !0 })] }) });
  }
}

class Hk0 extends N7 {
  constructor() {
    super(...arguments);
    this._params = cJ((Z) => XG.getThemeParams(this.plugin, Z)), this.state = { values: j.getDefaultValues(this.params) }, this.apply = () => {
      var Z, J;
      this.plugin.managers.structure.component.applyTheme(this.state.values, this.plugin.managers.structure.hierarchy.current.structures), (J = (Z = this.props).onApply) === null || J === void 0 || J.call(Z);
    }, this.paramsChanged = (Z) => this.setState({ values: Z });
  }
  get params() {
    return this._params(this.plugin.managers.structure.component.pivotStructure);
  }
  render() {
    return s8.jsxs(s8.Fragment, { children: [s8.jsx(iZ, { params: this.params, values: this.state.values, onChangeValues: this.paramsChanged }), s8.jsx(Z8, { icon: Ny, className: "msp-btn-commit msp-btn-commit-on", onClick: this.apply, style: { marginTop: "1px" }, children: "Apply Theme" })] });
  }
}
var Nk0 = {
  idType: j.Select("auth", j.arrayToOptions(["auth", "label", "atom-id", "element-symbol"])),
  identifiers: j.Text("", { description: "A comma separated list of atom identifiers (e.g. 10, 15-25), element symbols (e.g. N, C or 20-200) or residue ranges in given chain (e.g. A 10-15, B 25, C 30:i)" })
}, aM1 = j.getDefaultValues(Nk0);
function rM1({ modifier: Z, plugin: J, close: $ }) {
  let [X, Y] = Gk0.useState(aM1), Q = () => {
    if (X.identifiers.trim().length === 0)
      return;
    try {
      $();
      let W = Kk0(X.identifiers, X.idType);
      J.managers.structure.selection.fromCompiledQuery(Z, W, !1);
    } catch (W) {
      console.error(W), J.log.error("Failed to create selection");
    }
  };
  return s8.jsxs(s8.Fragment, { children: [s8.jsx(iZ, { params: Nk0, values: X, onChangeValues: Y, onEnter: Q }), s8.jsxs(Z8, { className: "msp-btn-commit msp-btn-commit-on", disabled: X.identifiers.trim().length === 0, onClick: Q, style: { marginTop: "1px" }, children: [TN(Z), " Selection"] })] });
}

// node_modules/molstar/lib/mol-plugin-ui/structure/measurements.js
class v20 extends y5 {
  defaultState() {
    return {
      isCollapsed: !1,
      header: "Measurements",
      brand: { accent: "gray", svg: VV0 }
    };
  }
  renderControls() {
    return r6.jsxs(r6.Fragment, { children: [r6.jsx(Fk0, {}), r6.jsx(qk0, {})] });
  }
}

class qk0 extends N7 {
  componentDidMount() {
    this.subscribe(this.plugin.managers.structure.measurement.behaviors.state, () => {
      this.forceUpdate();
    });
  }
  renderGroup(Z, J) {
    let $ = [];
    for (let X of Z)
      if (X.obj)
        $.push(r6.jsx(Lk0, { cell: X }, X.obj.id));
    return $.length ? r6.jsx(g$, { header: J, initiallyExpanded: !0, children: $ }) : null;
  }
  render() {
    let Z = this.plugin.managers.structure.measurement.state;
    return r6.jsxs("div", { style: { marginTop: "6px" }, children: [this.renderGroup(Z.labels, "Labels"), this.renderGroup(Z.distances, "Distances"), this.renderGroup(Z.angles, "Angles"), this.renderGroup(Z.dihedrals, "Dihedrals"), this.renderGroup(Z.orientations, "Orientations"), this.renderGroup(Z.planes, "Planes")] });
  }
}

class Fk0 extends N7 {
  constructor() {
    super(...arguments);
    this.state = { isBusy: !1, action: void 0 }, this.measureDistance = () => {
      let Z = this.plugin.managers.structure.selection.additionsHistory;
      this.plugin.managers.structure.measurement.addDistance(Z[0].loci, Z[1].loci);
    }, this.measureAngle = () => {
      let Z = this.plugin.managers.structure.selection.additionsHistory;
      this.plugin.managers.structure.measurement.addAngle(Z[0].loci, Z[1].loci, Z[2].loci);
    }, this.measureDihedral = () => {
      let Z = this.plugin.managers.structure.selection.additionsHistory;
      this.plugin.managers.structure.measurement.addDihedral(Z[0].loci, Z[1].loci, Z[2].loci, Z[3].loci);
    }, this.addLabel = () => {
      let Z = this.plugin.managers.structure.selection.additionsHistory;
      this.plugin.managers.structure.measurement.addLabel(Z[0].loci);
    }, this.addOrientation = () => {
      let Z = [];
      this.plugin.managers.structure.selection.entries.forEach((J) => {
        Z.push(J.selection);
      }), this.plugin.managers.structure.measurement.addOrientation(Z);
    }, this.addPlane = () => {
      let Z = [];
      this.plugin.managers.structure.selection.entries.forEach((J) => {
        Z.push(J.selection);
      }), this.plugin.managers.structure.measurement.addPlane(Z);
    }, this.selectAction = (Z) => {
      if (this.toggleAdd(), !Z)
        return;
      (Z === null || Z === void 0 ? void 0 : Z.value)();
    }, this.toggleAdd = () => this.setState({ action: this.state.action === "add" ? void 0 : "add" }), this.toggleOptions = () => this.setState({ action: this.state.action === "options" ? void 0 : "options" });
  }
  componentDidMount() {
    this.subscribe(this.selection.events.additionsHistoryUpdated, () => {
      this.forceUpdate(), this.updateOrderLabels();
    }), this.subscribe(this.plugin.behaviors.state.isBusy, (Z) => {
      this.setState({ isBusy: Z });
    });
  }
  componentWillUnmount() {
    this.clearOrderLabels(), super.componentWillUnmount();
  }
  componentDidUpdate(Z, J) {
    if (this.state.action !== J.action)
      this.updateOrderLabels();
  }
  clearOrderLabels() {
    this.plugin.managers.structure.measurement.addOrderLabels([]);
  }
  updateOrderLabels() {
    if (this.state.action !== "add") {
      this.clearOrderLabels();
      return;
    }
    let Z = [], J = this.selection.additionsHistory;
    for (let $ = 0;$ < J.length && $ < 4; $++)
      Z.push(J[$].loci);
    this.plugin.managers.structure.measurement.addOrderLabels(Z);
  }
  get selection() {
    return this.plugin.managers.structure.selection;
  }
  get actions() {
    let Z = this.selection.additionsHistory;
    return [
      { kind: "item", label: `Label ${Z.length === 0 ? " (1 selection item required)" : " (1st selection item)"}`, value: this.addLabel, disabled: Z.length === 0 },
      { kind: "item", label: `Distance ${Z.length < 2 ? " (2 selection items required)" : " (top 2 selection items)"}`, value: this.measureDistance, disabled: Z.length < 2 },
      { kind: "item", label: `Angle ${Z.length < 3 ? " (3 selection items required)" : " (top 3 items)"}`, value: this.measureAngle, disabled: Z.length < 3 },
      { kind: "item", label: `Dihedral ${Z.length < 4 ? " (4 selection items required)" : " (top 4 selection items)"}`, value: this.measureDihedral, disabled: Z.length < 4 },
      { kind: "item", label: `Orientation ${Z.length === 0 ? " (selection required)" : " (current selection)"}`, value: this.addOrientation, disabled: Z.length === 0 },
      { kind: "item", label: `Plane ${Z.length === 0 ? " (selection required)" : " (current selection)"}`, value: this.addPlane, disabled: Z.length === 0 }
    ];
  }
  highlight(Z) {
    this.plugin.managers.interactivity.lociHighlights.highlightOnly({ loci: Z }, !1);
  }
  moveHistory(Z, J) {
    this.plugin.managers.structure.selection.modifyHistory(Z, J, 4);
  }
  focusLoci(Z) {
    this.plugin.managers.camera.focusLoci(Z);
  }
  historyEntry(Z, J) {
    let $ = this.plugin.managers.structure.selection.additionsHistory;
    return r6.jsxs("div", { className: "msp-flex-row", onMouseEnter: () => this.highlight(Z.loci), onMouseLeave: () => this.plugin.managers.interactivity.lociHighlights.clearHighlights(), children: [r6.jsxs(Z8, { noOverflow: !0, title: "Click to focus. Hover to highlight.", onClick: () => this.focusLoci(Z.loci), style: { width: "auto", textAlign: "left" }, children: [J, ". ", r6.jsx("span", { dangerouslySetInnerHTML: { __html: Z.label } })] }), $.length > 1 && r6.jsx(o2, { svg: DE, small: !0, className: "msp-form-control", onClick: () => this.moveHistory(Z, "up"), flex: "20px", title: "Move up" }), $.length > 1 && r6.jsx(o2, { svg: zE, small: !0, className: "msp-form-control", onClick: () => this.moveHistory(Z, "down"), flex: "20px", title: "Move down" }), r6.jsx(o2, { svg: GX, small: !0, className: "msp-form-control", onClick: () => this.plugin.managers.structure.selection.modifyHistory(Z, "remove"), flex: !0, title: "Remove" })] }, Z.id);
  }
  add() {
    let Z = this.plugin.managers.structure.selection.additionsHistory, J = [];
    for (let Y = 0, Q = Math.min(Z.length, 4);Y < Q; Y++)
      J.push(this.historyEntry(Z[Y], Y + 1));
    let X = this.plugin.config.get(W8.Viewport.ShowSelectionMode) ? r6.jsxs(r6.Fragment, { children: [" ", "(toggle ", r6.jsx(q4, { inline: !0 }), " mode)"] }) : null;
    return r6.jsxs(r6.Fragment, { children: [r6.jsx(w8, { items: this.actions, onSelect: this.selectAction }), J.length > 0 && r6.jsx("div", { className: "msp-control-offset", children: J }), J.length === 0 && r6.jsx("div", { className: "msp-control-offset msp-help-text", children: r6.jsxs("div", { className: "msp-help-description", children: [r6.jsx(b6, { svg: OQ, inline: !0 }), "Add one or more selections", X] }) })] });
  }
  render() {
    return r6.jsxs(r6.Fragment, { children: [r6.jsxs("div", { className: "msp-flex-row", children: [r6.jsx(D7, { icon: hH, label: "Add", toggle: this.toggleAdd, isSelected: this.state.action === "add", disabled: this.state.isBusy, className: "msp-btn-apply-simple" }), r6.jsx(D7, { icon: lX, label: "", title: "Options", toggle: this.toggleOptions, isSelected: this.state.action === "options", disabled: this.state.isBusy, style: { flex: "0 0 40px", padding: 0 } })] }), this.state.action === "add" && this.add(), this.state.action === "options" && r6.jsx(Uk0, {})] });
  }
}

class Uk0 extends N7 {
  constructor() {
    super(...arguments);
    this.state = { isDisabled: !1 }, this.changed = (Z) => {
      this.plugin.managers.structure.measurement.setOptions(Z);
    };
  }
  componentDidMount() {
    this.subscribe(this.plugin.managers.structure.measurement.behaviors.state, () => {
      this.forceUpdate();
    }), this.subscribe(this.plugin.behaviors.state.isBusy, (Z) => {
      this.setState({ isDisabled: Z });
    });
  }
  render() {
    let Z = this.plugin.managers.structure.measurement.state;
    return r6.jsx("div", { className: "msp-control-offset", children: r6.jsx(iZ, { params: _20, values: Z.options, onChangeValues: this.changed, isDisabled: this.state.isDisabled }) });
  }
}

class Lk0 extends N7 {
  constructor() {
    super(...arguments);
    this.state = { showUpdate: !1 }, this.delete = () => {
      h1.State.RemoveObject(this.plugin, { state: this.props.cell.parent, ref: this.props.cell.transform.parent, removeParentGhosts: !0 });
    }, this.toggleVisibility = (Z) => {
      Z.preventDefault(), h1.State.ToggleVisibility(this.plugin, { state: this.props.cell.parent, ref: this.props.cell.transform.parent }), Z.currentTarget.blur();
    }, this.highlight = () => {
      var Z;
      if (!this.selections)
        return;
      this.plugin.managers.interactivity.lociHighlights.clearHighlights();
      for (let X of this.lociArray)
        this.plugin.managers.interactivity.lociHighlights.highlight({ loci: X }, !1);
      let $ = (Z = this.props.cell.obj) === null || Z === void 0 ? void 0 : Z.data.repr.getAllLoci();
      if ($)
        for (let X of $)
          this.plugin.managers.interactivity.lociHighlights.highlight({ loci: X }, !1);
    }, this.clearHighlight = () => {
      this.plugin.managers.interactivity.lociHighlights.clearHighlights();
    }, this.toggleUpdate = () => this.setState({ showUpdate: !this.state.showUpdate }), this.focus = () => {
      if (!this.selections)
        return;
      let J = d2.getBundleBoundingSphere({ loci: this.lociArray });
      if (J)
        this.plugin.managers.camera.focusSphere(J);
    }, this.selectAction = (Z) => {
      if (!Z)
        return;
      this.setState({ showUpdate: !1 }), (Z === null || Z === void 0 ? void 0 : Z.value)();
    };
  }
  componentDidMount() {
    this.subscribe(this.plugin.state.events.cell.stateUpdated, (Z) => {
      this.forceUpdate();
    });
  }
  get selections() {
    var Z;
    return (Z = this.props.cell.obj) === null || Z === void 0 ? void 0 : Z.data.sourceData;
  }
  get lociArray() {
    let Z = this.selections;
    if (!Z)
      return [];
    if (Z.infos)
      return [Z.infos[0].loci];
    if (Z.pairs)
      return Z.pairs[0].loci;
    if (Z.triples)
      return Z.triples[0].loci;
    if (Z.quads)
      return Z.quads[0].loci;
    if (Z.locis)
      return Z.locis;
    return [];
  }
  get label() {
    let Z = this.selections;
    if (!Z)
      return "<empty>";
    if (Z.infos)
      return c3(Z.infos[0].loci, { condensed: !0 });
    if (Z.pairs)
      return pA(Z.pairs[0], { condensed: !0, unitLabel: this.plugin.managers.structure.measurement.state.options.distanceUnitLabel });
    if (Z.triples)
      return uA(Z.triples[0], { condensed: !0 });
    if (Z.quads)
      return cA(Z.quads[0], { condensed: !0 });
    if (Z.locis)
      return mR(Z.locis, { countsOnly: !0 });
    return "<empty>";
  }
  get actions() {
    return this.props.cell.sourceRef, [w8.Item("Select This", () => this.plugin.managers.structure.selection.fromSelections(this.props.cell.sourceRef), { icon: nz })];
  }
  render() {
    let { cell: Z } = this.props, { obj: J } = Z;
    if (!J)
      return null;
    return r6.jsxs(r6.Fragment, { children: [r6.jsxs("div", { className: "msp-flex-row", onMouseEnter: this.highlight, onMouseLeave: this.clearHighlight, children: [r6.jsx("button", { className: "msp-form-control msp-control-button-label msp-no-overflow", title: "Click to focus. Hover to highlight.", onClick: this.focus, style: { width: "auto", textAlign: "left" }, children: r6.jsx("span", { dangerouslySetInnerHTML: { __html: this.label } }) }), r6.jsx(o2, { svg: Z.state.isHidden ? yK : b5, toggleState: !1, small: !0, className: "msp-form-control", onClick: this.toggleVisibility, flex: !0, title: Z.state.isHidden ? "Show" : "Hide" }), r6.jsx(o2, { svg: GX, small: !0, className: "msp-form-control", onClick: this.delete, flex: !0, title: "Delete", toggleState: !1 }), r6.jsx(o2, { svg: ME, className: "msp-form-control", onClick: this.toggleUpdate, flex: !0, title: "Actions", toggleState: this.state.showUpdate })] }, J.id), this.state.showUpdate && Z.parent && r6.jsx(r6.Fragment, { children: r6.jsxs("div", { className: "msp-accent-offset", children: [r6.jsx(w8, { items: this.actions, onSelect: this.selectAction, noOffset: !0 }), r6.jsx(g$, { header: "Options", noOffset: !0, children: r6.jsx(oW, { state: Z.parent, transform: Z.transform, customHeader: "none", autoHideApply: !0 }) })] }) })] });
  }
}

// node_modules/molstar/lib/mol-plugin-ui/structure/source.js
var MQ = t2(PZ(), 1);

// node_modules/molstar/lib/mol-plugin-ui/structure/focus.js
var Sq = t2(PZ(), 1);
function S20(Z, J, $, X) {
  let Y = X1.indexOf(J.unit.elements, J.element), Q = W0.Loci(J.structure, [
    { unit: J.unit, indices: f0.ofSingleton(Y) }
  ]), W = X === "residue" ? W0.Loci.extendToWholeResidues(Q) : W0.Loci.extendToWholeChains(Q), K = w1.entity.pdbx_description(J).join(", ");
  for (let G of $.units) {
    let H = W0.Loci(W.structure, [
      { unit: G, indices: W.elements[0].indices }
    ]), N = c3(H, { reverse: !0, hidePrefix: !0, htmlStyling: !1, granularity: X });
    if (!N)
      N = c3(H, { hidePrefix: !1, htmlStyling: !1 });
    if ($.units.length > 1)
      N += ` | ${H.elements[0].unit.conformation.operator.name}`;
    let q = { label: N, category: K, loci: H };
    if (Z.has(K))
      Z.get(K).push(q);
    else
      Z.set(K, [q]);
  }
}
function tM1(Z) {
  let J = /* @__PURE__ */ new Map, $ = W0.Location.create(Z);
  for (let Y of Z.unitSymmetryGroups) {
    if (!j0.isAtomic(Y.units[0]))
      continue;
    $.unit = Y.units[0], $.element = Y.elements[0];
    let Q = j0.Traits.is($.unit.traits, j0.Trait.MultiChain), W = w1.entity.type($), K = W === "non-polymer", G = W === "branched";
    if (!!w1.entity.prd_id($))
      S20(J, $, Y, "chain");
    else if (K && !Q)
      S20(J, $, Y, "residue");
    else if (G || K && Q) {
      let N = $.unit, { index: q } = N.model.atomicHierarchy.residueAtomSegments, U = -1;
      for (let F = 0, E = N.elements.length;F < E; ++F) {
        let R = N.elements[F], z = q[R];
        if (z !== U)
          $.element = R, S20(J, $, Y, "residue"), U = z;
      }
    }
  }
  let X = [];
  return J.forEach((Y, Q) => {
    if (Y.length === 1)
      X.push({ label: `${Q}: ${Y[0].label}`, loci: Y[0].loci });
    else if (Y.length < 2000)
      X.push(...Y);
  }), X;
}

class f20 extends I8 {
  constructor() {
    super(...arguments);
    this.state = { isBusy: !1, showAction: !1 }, this.getSelectionItems = cJ((Z) => {
      var J;
      let $ = [];
      for (let X of Z) {
        let Y = (J = X.cell.obj) === null || J === void 0 ? void 0 : J.data;
        if (Y) {
          let Q = tM1(Y);
          if (Q.length > 0)
            $.push([
              w8.Header(Y.label, { description: Y.label }),
              ...w8.createItems(Q, {
                label: (W) => W.label,
                category: (W) => W.category,
                description: (W) => W.label
              })
            ]);
        }
      }
      return $;
    }), this.selectAction = (Z, J) => {
      if (!Z || !this.state.showAction) {
        this.setState({ showAction: !1 });
        return;
      }
      let $ = Z.value;
      if (J === null || J === void 0 ? void 0 : J.shiftKey)
        this.plugin.managers.structure.focus.addFromLoci($.loci);
      else
        this.plugin.managers.structure.focus.set($);
      this.focusCamera();
    }, this.toggleAction = () => this.setState({ showAction: !this.state.showAction }), this.focusCamera = () => {
      let { current: Z } = this.plugin.managers.structure.focus;
      if (Z)
        this.plugin.managers.camera.focusLoci(Z.loci);
    }, this.clear = () => {
      this.plugin.managers.structure.focus.clear(), this.plugin.managers.camera.reset();
    }, this.highlightCurrent = () => {
      let { current: Z } = this.plugin.managers.structure.focus;
      if (Z)
        this.plugin.managers.interactivity.lociHighlights.highlightOnly({ loci: Z.loci }, !1);
    }, this.clearHighlights = () => {
      this.plugin.managers.interactivity.lociHighlights.clearHighlights();
    };
  }
  componentDidMount() {
    this.subscribe(this.plugin.managers.structure.focus.behaviors.current, (Z) => {
      this.getSelectionItems([]), this.forceUpdate();
    }), this.subscribe(this.plugin.managers.structure.focus.events.historyUpdated, (Z) => {
      this.forceUpdate();
    }), this.subscribe(this.plugin.behaviors.state.isBusy, (Z) => {
      this.setState({ isBusy: Z, showAction: !1 });
    });
  }
  get isDisabled() {
    return this.state.isBusy || this.plugin.managers.structure.hierarchy.selection.structures.length === 0;
  }
  get actionItems() {
    let Z = [], { history: J } = this.plugin.managers.structure.focus;
    if (J.length > 0)
      Z.push([
        w8.Header("History", { description: "Previously focused on items." }),
        ...w8.createItems(J, {
          label: (Y) => Y.label,
          description: (Y) => {
            return Y.category && Y.label !== Y.category ? `${Y.category} | ${Y.label}` : Y.label;
          }
        })
      ]);
    let $ = this.getSelectionItems(this.plugin.managers.structure.hierarchy.selection.structures);
    if ($.length === 1) {
      let Q = $[0][0];
      Q.initiallyExpanded = !0;
    }
    let X = [];
    if ($.length > 0)
      X.push(...$);
    if (Z.length > 0)
      X.push(...Z);
    return X;
  }
  getToggleBindingLabel() {
    var Z;
    let J = this.plugin.state.behaviors.transforms.get(pz.id);
    if (!J)
      return "";
    let $ = (Z = J.params) === null || Z === void 0 ? void 0 : Z.bindings.clickFocus;
    if (!$ || e1.isEmpty($))
      return "";
    return e1.formatTriggers($);
  }
  render() {
    let { current: Z } = this.plugin.managers.structure.focus, J = (Z === null || Z === void 0 ? void 0 : Z.label) || "Nothing Focused", $ = "Click to Center Camera";
    if (!Z) {
      $ = "Select focus using the menu";
      let X = this.getToggleBindingLabel();
      if (X)
        $ += `
or use '${X}' on element`;
    }
    return Sq.jsxs(Sq.Fragment, { children: [Sq.jsxs("div", { className: "msp-flex-row", children: [Sq.jsx(Z8, { noOverflow: !0, onClick: this.focusCamera, title: $, onMouseEnter: this.highlightCurrent, onMouseLeave: this.clearHighlights, disabled: this.isDisabled || !Z, style: { textAlignLast: Z ? "left" : void 0 }, children: J }), Z && Sq.jsx(o2, { svg: II, onClick: this.clear, title: "Clear", className: "msp-form-control", flex: !0, disabled: this.isDisabled }), Sq.jsx(D7, { icon: hV0, title: "Select a focus target to center on an show its surroundings. Hold shift to focus on multiple targets.", toggle: this.toggleAction, isSelected: this.state.showAction, disabled: this.isDisabled, style: { flex: "0 0 40px", padding: 0 } })] }), this.state.showAction && Sq.jsx(w8, { items: this.actionItems, onSelect: this.selectAction })] });
  }
}

// node_modules/molstar/lib/mol-plugin-ui/structure/source.js
class h20 extends y5 {
  constructor() {
    super(...arguments);
    this.item = (Z) => {
      var J, $, X, Y, Q, W, K, G, H;
      let N = this.plugin.managers.structure.hierarchy.seletionSet, q;
      switch (Z.kind) {
        case "model": {
          let F = (J = Z.cell.obj) === null || J === void 0 ? void 0 : J.data;
          if (F && O2.TrajectoryInfo.get(F).size > 1)
            q = `${($ = Z.cell.obj) === null || $ === void 0 ? void 0 : $.data.entryId} | Model ${O2.TrajectoryInfo.get(F).index + 1} of ${O2.TrajectoryInfo.get(F).size}`;
          q = `${(X = Z.cell.obj) === null || X === void 0 ? void 0 : X.data.entryId} | ${(Y = Z.cell.obj) === null || Y === void 0 ? void 0 : Y.label}`;
          break;
        }
        case "structure": {
          let F = (Q = Z.cell.obj) === null || Q === void 0 ? void 0 : Q.data.models[0];
          if (F && O2.TrajectoryInfo.get(F).size > 1) {
            q = `${F.entryId} | ${(W = Z.cell.obj) === null || W === void 0 ? void 0 : W.label} (Model ${O2.TrajectoryInfo.get(F).index + 1} of ${O2.TrajectoryInfo.get(F).size})`;
            break;
          } else if (F) {
            q = `${F.entryId} | ${(K = Z.cell.obj) === null || K === void 0 ? void 0 : K.label}`;
            break;
          } else {
            q = `${(G = Z.cell.obj) === null || G === void 0 ? void 0 : G.label}`;
            break;
          }
        }
        default:
          q = (H = Z.cell.obj) === null || H === void 0 ? void 0 : H.label;
          break;
      }
      return { kind: "item", label: q || Z.kind, selected: N.has(Z.cell.transform.ref), value: [Z] };
    }, this.getTrajectoryItems = (Z) => {
      var J;
      if (Z.models.length === 0)
        return this.item(Z);
      return [w8.Header((J = Z.cell.obj) === null || J === void 0 ? void 0 : J.label), ...Z.models.map(this.getModelItems)];
    }, this.getModelItems = (Z) => {
      var J, $, X;
      if (Z.structures.length === 0)
        return this.item(Z);
      if (Z.structures.length === 1) {
        let Y = this.plugin.managers.structure.hierarchy.seletionSet, Q = Z.structures[0];
        return { label: `${(J = Z.cell.obj) === null || J === void 0 ? void 0 : J.label} | ${($ = Q.cell.obj) === null || $ === void 0 ? void 0 : $.label}`, selected: Y.has(Q.cell.transform.ref), value: [Z, Q] };
      }
      return [w8.Header((X = Z.cell.obj) === null || X === void 0 ? void 0 : X.label), ...Z.structures.map(this.item)];
    }, this.selectHierarchy = (Z) => {
      if (!Z || Z.length === 0)
        return;
      let J = [];
      for (let $ of Z)
        for (let X of $.value)
          J.push(X);
      this.plugin.managers.structure.hierarchy.updateCurrent(J, Z[0].selected ? "remove" : "add");
    }, this.toggleHierarchy = () => this.setState({ show: this.state.show !== "hierarchy" ? "hierarchy" : void 0 }), this.togglePreset = () => this.setState({ show: this.state.show !== "presets" ? "presets" : void 0 }), this.applyPreset = (Z) => {
      if (this.setState({ show: void 0 }), !Z)
        return;
      let J = this.plugin.managers.structure, { trajectories: $ } = J.hierarchy.selection;
      J.hierarchy.applyPreset($, Z.value);
    }, this.updateModelQueueParams = void 0, this.isUpdatingModel = !1, this.updateStructureModel = (Z) => {
      this.updateModelQueueParams = Z, this._updateStructureModel();
    }, this.updateStructure = (Z) => {
      let { selection: J } = this.plugin.managers.structure.hierarchy, $ = J.structures[0];
      return this.plugin.managers.structure.hierarchy.updateStructure($, Z);
    };
  }
  defaultState() {
    return {
      header: "Structure",
      isCollapsed: !1,
      isBusy: !1,
      brand: { accent: "purple", svg: TV0 }
    };
  }
  componentDidMount() {
    this.subscribe(this.plugin.managers.structure.hierarchy.behaviors.selection, () => this.forceUpdate()), this.subscribe(this.plugin.behaviors.state.isBusy, (Z) => {
      this.setState({ isBusy: Z });
    });
  }
  get hierarchyItems() {
    let Z = this.plugin.managers.structure.hierarchy, { current: J } = Z, $ = [];
    if (J.trajectories.length > 1)
      $.push([
        w8.Header("Trajectories"),
        ...J.trajectories.map(this.item)
      ]);
    if (J.models.length > 1 || J.trajectories.length > 1)
      $.push([
        w8.Header("Models"),
        ...J.models.map(this.item)
      ]);
    if (J.trajectories.length === 1 && J.models.length === 1)
      $.push(...J.structures.map(this.item));
    else if (J.structures.length > 0)
      $.push([
        w8.Header("Structures"),
        ...J.structures.map(this.item)
      ]);
    return $;
  }
  get isEmpty() {
    let { structures: Z, models: J, trajectories: $ } = this.plugin.managers.structure.hierarchy.current;
    return $.length === 0 && J.length === 0 && Z.length === 0;
  }
  get label() {
    var Z, J, $, X, Y, Q, W, K, G, H, N, q, U, F;
    let { structures: E, models: R, trajectories: z } = this.plugin.managers.structure.hierarchy.selection;
    if (E.length === 1) {
      let D = E[0];
      if (((J = (Z = D.model) === null || Z === void 0 ? void 0 : Z.trajectory) === null || J === void 0 ? void 0 : J.models) && D.model.trajectory.models.length === 1)
        return ($ = D.cell.obj) === null || $ === void 0 ? void 0 : $.data.label;
      if (D.model)
        return `${(X = D.model.cell.obj) === null || X === void 0 ? void 0 : X.label} | ${(Y = D.cell.obj) === null || Y === void 0 ? void 0 : Y.data.label}`;
      return (Q = D.cell.obj) === null || Q === void 0 ? void 0 : Q.data.label;
    }
    if (E.length > 1) {
      let D = E[0], A = (W = D === null || D === void 0 ? void 0 : D.model) === null || W === void 0 ? void 0 : W.trajectory, B = !0;
      for (let T of E)
        if (((K = T === null || T === void 0 ? void 0 : T.model) === null || K === void 0 ? void 0 : K.trajectory) !== A) {
          B = !1;
          break;
        }
      return B && A ? `${(G = A.cell.obj) === null || G === void 0 ? void 0 : G.label} | ${E.length} structures` : `${E.length} structures`;
    }
    if (R.length > 0) {
      let D = R[0].trajectory;
      if (R.length === 1) {
        let B = (H = R[0].cell.obj) === null || H === void 0 ? void 0 : H.data;
        if (B && O2.TrajectoryInfo.get(B).size > 1)
          return `${(N = D === null || D === void 0 ? void 0 : D.cell.obj) === null || N === void 0 ? void 0 : N.label} | Model ${O2.TrajectoryInfo.get(B).index + 1} of ${O2.TrajectoryInfo.get(B).size}`;
        else
          return `${(q = D === null || D === void 0 ? void 0 : D.cell.obj) === null || q === void 0 ? void 0 : q.label} | Model`;
      }
      let A = !0;
      for (let B of R)
        if (B.trajectory !== D) {
          A = !1;
          break;
        }
      return A ? `${(U = D === null || D === void 0 ? void 0 : D.cell.obj) === null || U === void 0 ? void 0 : U.label} | ${R.length} models` : `${R.length} models`;
    }
    if (z.length > 0)
      return z.length === 1 ? `${(F = z[0].cell.obj) === null || F === void 0 ? void 0 : F.label} trajectory` : `${z.length} trajectories`;
    if (z.length === 0 && R.length === 0 && E.length === 0)
      return "Nothing Loaded";
    return "Nothing Selected";
  }
  get presetActions() {
    let Z = [], { trajectories: J } = this.plugin.managers.structure.hierarchy.selection;
    if (J.length === 0)
      return Z;
    let $ = this.plugin.builders.structure.hierarchy.getPresets(J[0].cell.obj);
    if (J.length > 1) {
      let X = new Set($);
      for (let Y = 1;Y < J.length; Y++) {
        let Q = this.plugin.builders.structure.hierarchy.getPresets(J[Y].cell.obj), W = new Set(Q);
        for (let K of Q)
          if (!W.has(K))
            X.delete(K);
      }
      $ = $.filter((Y) => X.has(Y));
    }
    for (let X of $)
      Z.push(w8.Item(X.display.name, X, { description: X.display.description }));
    return Z;
  }
  async _updateStructureModel() {
    if (!this.updateModelQueueParams || this.isUpdatingModel)
      return;
    let Z = this.updateModelQueueParams;
    this.updateModelQueueParams = void 0;
    try {
      this.isUpdatingModel = !0;
      let { selection: J } = this.plugin.managers.structure.hierarchy, $ = J.structures[0].model;
      await this.plugin.state.updateTransform(this.plugin.state.data, $.cell.transform.ref, Z, "Model Index");
    } finally {
      this.isUpdatingModel = !1, this._updateStructureModel();
    }
  }
  get modelIndex() {
    var Z, J;
    let { selection: $ } = this.plugin.managers.structure.hierarchy;
    if ($.structures.length !== 1)
      return null;
    let X = $.structures[0].model;
    if (!X || X.cell.transform.transformer !== H1.Model.ModelFromTrajectory)
      return null;
    if (!X.cell.obj || O2.TrajectoryInfo.get(X.cell.obj.data).size <= 1)
      return null;
    let Y = (Z = X.cell.params) === null || Z === void 0 ? void 0 : Z.definition;
    if (!Y)
      return null;
    return MQ.jsx(iZ, { params: Y, values: (J = X.cell.params) === null || J === void 0 ? void 0 : J.values, onChangeValues: this.updateStructureModel, isDisabled: this.state.isBusy });
  }
  get structureType() {
    var Z;
    let { selection: J } = this.plugin.managers.structure.hierarchy;
    if (J.structures.length !== 1)
      return null;
    let $ = J.structures[0];
    if (!((Z = $.cell.params) === null || Z === void 0 ? void 0 : Z.definition) || !$.cell.parent)
      return null;
    return MQ.jsx(oW, { state: $.cell.parent, transform: $.cell.transform, customHeader: "none", customUpdate: this.updateStructure, noMargin: !0, autoHideApply: !0 });
  }
  get transform() {
    let { selection: Z } = this.plugin.managers.structure.hierarchy;
    if (Z.structures.length !== 1)
      return null;
    let J = Z.structures[0];
    if (!J.cell.parent)
      return null;
    let $ = f2.tryFindDecorator(this.plugin.state.data, J.cell.transform.ref, H1.Model.TransformStructureConformation);
    if (!$)
      return;
    return MQ.jsx(g$, { header: "Conformation Transform", children: MQ.jsx(oW, { state: $.parent, transform: $.transform, customHeader: "none", noMargin: !0, autoHideApply: !0 }) });
  }
  renderControls() {
    let Z = this.state.isBusy || this.isEmpty, J = this.presetActions, $ = this.label;
    return MQ.jsxs(MQ.Fragment, { children: [MQ.jsxs("div", { className: "msp-flex-row", style: { marginTop: "1px" }, children: [MQ.jsx(Z8, { noOverflow: !0, flex: !0, onClick: this.toggleHierarchy, disabled: Z, title: $, children: $ }), J.length > 0 && MQ.jsx(o2, { svg: wU, className: "msp-form-control", flex: "40px", onClick: this.togglePreset, title: "Apply a structure presets to the current hierarchy.", toggleState: this.state.show === "presets", disabled: Z })] }), this.state.show === "hierarchy" && MQ.jsx(w8, { items: this.hierarchyItems, onSelect: this.selectHierarchy, multiselect: !0 }), this.state.show === "presets" && MQ.jsx(w8, { items: J, onSelect: this.applyPreset }), this.modelIndex, this.structureType, this.transform, MQ.jsxs("div", { style: { marginTop: "6px" }, children: [MQ.jsx(f20, {}), MQ.jsx(k20, { hideOnEmpty: !0 })] })] });
  }
}

// node_modules/molstar/lib/mol-plugin-ui/structure/volume.js
var CZ = t2(PZ(), 1);

// node_modules/molstar/lib/mol-plugin-state/helpers/volume-representation-params.js
function IU(Z, J, $ = {}) {
  let X = $;
  if (typeof X.type === "string" || typeof X.color === "string" || typeof X.size === "string")
    return eM1(Z, J || Q1.One, $);
  return Rk0(Z, J || Q1.One, $);
}
function eM1(Z, J, $) {
  let X = $.type && Z.representation.volume.registry.get($.type) || Z.representation.volume.registry.default.provider, Y = $.color && Z.representation.volume.themes.colorThemeRegistry.get($.color) || Z.representation.volume.themes.colorThemeRegistry.get(X.defaultColorTheme.name), Q = $.size && Z.representation.volume.themes.sizeThemeRegistry.get($.size) || Z.representation.volume.themes.sizeThemeRegistry.get(X.defaultSizeTheme.name);
  return Rk0(Z, J, {
    type: X,
    typeParams: $.typeParams,
    color: Y,
    colorParams: $.colorParams,
    size: Q,
    sizeParams: $.sizeParams
  });
}
function Rk0(Z, J, $ = {}) {
  let { themes: X } = Z.representation.volume, Y = { volume: J }, Q = $.type || Z.representation.volume.registry.default.provider, W = j.getDefaultValues(Q.getParams(X, J)), K = Object.assign(W, $.typeParams), G = $.color || X.colorThemeRegistry.get(Q.defaultColorTheme.name), H = j.getDefaultValues(G.getParams(Y));
  if (G.name === Q.defaultColorTheme.name)
    Object.assign(H, Q.defaultColorTheme.props);
  let N = Object.assign(H, $.colorParams), q = $.size || X.sizeThemeRegistry.get(Q.defaultSizeTheme.name), U = j.getDefaultValues(q.getParams(Y));
  if (q.name === Q.defaultSizeTheme.name)
    Object.assign(U, Q.defaultSizeTheme.props);
  let F = Object.assign(U, $.sizeParams);
  return {
    type: { name: Q.name, params: K },
    colorTheme: { name: G.name, params: N },
    sizeTheme: { name: q.name, params: F }
  };
}

// node_modules/molstar/lib/mol-plugin-state/manager/volume/hierarchy-state.js
function Ok0(Z, J) {
  let $ = XA1(Z, J || Ug());
  if (GA1(Z.tree, $), J)
    J.refs.forEach(WA1, $);
  return { hierarchy: $.hierarchy, added: $.added, changed: $.changed };
}
function Ug() {
  return { volumes: [], lazyVolumes: [], refs: /* @__PURE__ */ new Map };
}
function ZA1(Z) {
  return { kind: "volume", cell: Z, version: Z.transform.version, representations: [] };
}
function JA1(Z) {
  return { kind: "lazy-volume", cell: Z, version: Z.transform.version };
}
function $A1(Z, J) {
  return { kind: "volume-representation", cell: Z, version: Z.transform.version, volume: J };
}
function XA1(Z, J) {
  return { state: Z, oldHierarchy: J, hierarchy: Ug(), changed: !1, added: /* @__PURE__ */ new Set };
}
function b20(Z, J, $, X, ...Y) {
  let Q = X(...Y);
  $.push(Q), Z.hierarchy.refs.set(J.transform.ref, Q);
  let W = Z.oldHierarchy.refs.get(J.transform.ref);
  if (W) {
    if (W.version !== J.transform.version)
      Z.changed = !0;
  } else
    Z.added.add(Q.cell.transform.ref), Z.changed = !0;
  return Q;
}
function YA1(Z, J) {
  return ($, X) => !J(X) && Z.is($.obj);
}
function Ek0() {}
var QA1 = [
  [YA1(D0.Volume.Data, (Z) => Z.currentVolume), (Z, J) => {
    Z.currentVolume = b20(Z, J, Z.hierarchy.volumes, ZA1, J);
  }, (Z) => Z.currentVolume = void 0],
  [(Z) => D0.Volume.Lazy.is(Z.obj), (Z, J) => {
    b20(Z, J, Z.hierarchy.lazyVolumes, JA1, J);
  }, Ek0],
  [(Z, J) => {
    return !Z.state.isGhost && !!J.currentVolume && D0.Volume.Representation3D.is(Z.obj);
  }, (Z, J) => {
    if (Z.currentVolume)
      b20(Z, J, Z.currentVolume.representations, $A1, J, Z.currentVolume);
    return !1;
  }, Ek0]
];
function zk0(Z) {
  if (!Z || !(Z === null || Z === void 0 ? void 0 : Z.parent) || !Z.parent.cells.has(Z.transform.ref))
    return !1;
  let { obj: J } = Z;
  if (!J || J === LZ.Null || Z.status !== "ok" && Z.status !== "error")
    return !1;
  return !0;
}
function WA1(Z) {
  let { cell: J } = Z;
  if (zk0(J))
    return;
  this.changed = !0;
}
function KA1(Z) {
  Dk0(this, this.tree.transforms.get(Z));
}
function Dk0(Z, J) {
  let { state: $ } = Z, X = $.state.cells.get(J.ref);
  if (!zk0(X))
    return;
  let Y = void 0, Q = !1;
  for (let [K, G, H] of QA1)
    if (K(X, $)) {
      if (G($, X) === !1) {
        Q = !0;
        break;
      }
      Y = H;
      break;
    }
  if (Q)
    return;
  let W = Z.tree.children.get(J.ref);
  if (W && W.size)
    W.forEach(KA1, Z);
  if (Y)
    Y($);
}
function GA1(Z, J) {
  let $ = { tree: Z, state: J };
  return Dk0($, Z.root), $.state;
}

// node_modules/molstar/lib/mol-plugin-state/manager/volume/hierarchy.js
class F4 extends Oq {
  get dataState() {
    return this.plugin.state.data;
  }
  get current() {
    return this.sync(!1), this.state.hierarchy;
  }
  get selection() {
    return this.sync(!1), this.state.selection;
  }
  sync(Z) {
    if (!Z && this.dataState.inUpdate)
      return;
    if (this.state.syncedTree === this.dataState.tree) {
      if (Z && !this.state.notified)
        this.state.notified = !0, this.behaviors.selection.next({ hierarchy: this.state.hierarchy, volume: this.state.selection });
      return;
    }
    this.state.syncedTree = this.dataState.tree;
    let J = Ok0(this.plugin.state.data, this.current);
    if (!J.changed)
      return;
    let { hierarchy: $ } = J;
    if (this.state.hierarchy = $, !this.state.selection)
      this.state.selection = $.volumes[0];
    else
      this.state.selection = $.refs.has(this.state.selection.cell.transform.ref) ? $.refs.get(this.state.selection.cell.transform.ref) : $.volumes[0];
    if (Z)
      this.state.notified = !0, this.behaviors.selection.next({ hierarchy: $, volume: this.state.selection });
    else
      this.state.notified = !1;
  }
  setCurrent(Z) {
    this.state.selection = Z || this.state.hierarchy.volumes[0], this.behaviors.selection.next({ hierarchy: this.state.hierarchy, volume: Z || this.state.hierarchy.volumes[0] });
  }
  remove(Z, J) {
    if (Z.length === 0)
      return;
    let $ = this.plugin.state.data.build();
    for (let X of Z)
      $.delete(typeof X === "string" ? X : X.cell.transform.ref);
    return $.commit({ canUndo: J ? "Remove" : !1 });
  }
  toggleVisibility(Z, J) {
    if (Z.length === 0)
      return;
    let $ = J !== void 0 ? J === "show" ? !1 : !0 : !Z[0].cell.state.isHidden;
    for (let X of Z)
      _H(this.dataState, X.cell.transform.ref, $);
  }
  addRepresentation(Z, J) {
    var $;
    return this.dataState.build().to(Z.cell).apply(H1.Representation.VolumeRepresentation3D, IU(this.plugin, ($ = Z.cell.obj) === null || $ === void 0 ? void 0 : $.data, {
      type: J
    })).commit({ canUndo: "Add Representation" });
  }
  constructor(Z) {
    super();
    this.plugin = Z, this.state = {
      syncedTree: this.dataState.tree,
      notified: !1,
      hierarchy: Ug(),
      selection: void 0
    }, this.behaviors = {
      selection: this.ev.behavior({
        hierarchy: this.current,
        volume: this.selection
      })
    }, this.subscribe(Z.state.data.events.changed, (J) => {
      if (J.inTransaction || Z.behaviors.state.isAnimating.value)
        return;
      this.sync(!0);
    }), this.subscribe(Z.behaviors.state.isAnimating, (J) => {
      if (!J && !Z.behaviors.state.isUpdating.value)
        this.sync(!0);
    });
  }
}
(function(Z) {
  function J($, X) {
    var Y, Q;
    return ((Y = X === null || X === void 0 ? void 0 : X.cell.obj) === null || Y === void 0 ? void 0 : Y.data) ? $.representation.volume.registry.getApplicableTypes((Q = X.cell.obj) === null || Q === void 0 ? void 0 : Q.data) : $.representation.volume.registry.types;
  }
  Z.getRepresentationTypes = J;
})(F4 || (F4 = {}));

// node_modules/molstar/lib/mol-plugin-ui/state/apply-action.js
class U4 extends XP {
  constructor() {
    super(...arguments);
    this._getInfo = cJ((Z, J, $) => vq.infoFromAction(this.plugin, this.props.state, this.props.action, this.props.nodeRef)), this.state = { plugin: this.plugin, ref: this.props.nodeRef, version: this.props.state.transforms.get(this.props.nodeRef).version, error: void 0, isInitial: !0, params: this.getInfo().initialValues, busy: !1, isCollapsed: this.props.initiallyCollapsed };
  }
  applyAction() {
    return h1.State.ApplyAction(this.plugin, {
      state: this.props.state,
      action: this.props.action.create(this.state.params),
      ref: this.props.nodeRef
    });
  }
  getInfo() {
    var Z;
    return this._getInfo(this.props.nodeRef, this.props.state.transforms.get(this.props.nodeRef).version, (Z = this.state) === null || Z === void 0 ? void 0 : Z.isCollapsed);
  }
  getTransformerId() {
    return this.props.state.transforms.get(this.props.nodeRef).transformer.id;
  }
  getHeader() {
    return this.props.hideHeader ? "none" : this.props.action.definition.display;
  }
  canApply() {
    return !this.state.error && !this.state.busy;
  }
  canAutoApply() {
    return !1;
  }
  applyText() {
    return "Apply";
  }
  isUpdate() {
    return !1;
  }
  getSourceAndTarget() {
    return { a: this.props.state.cells.get(this.props.nodeRef).obj };
  }
  static getDerivedStateFromProps(Z, J) {
    let $ = Z.state.transforms.get(Z.nodeRef).version;
    if (Z.nodeRef === J.ref && $ === J.version)
      return null;
    let X = Z.state.cells.get(Z.nodeRef).obj, Y = Z.action.definition.params ? j.getDefaultValues(Z.action.definition.params(X, J.plugin)) : {};
    return {
      plugin: J.plugin,
      ref: Z.nodeRef,
      version: $,
      params: Y,
      isInitial: !0,
      error: void 0
    };
  }
}

// node_modules/molstar/lib/mol-plugin-ui/structure/volume.js
class x20 extends y5 {
  defaultState() {
    return {
      header: "Volume Streaming",
      isCollapsed: !1,
      isBusy: !1,
      isHidden: !0,
      brand: { accent: "cyan", svg: $10 }
    };
  }
  componentDidMount() {
    this.subscribe(this.plugin.managers.structure.hierarchy.behaviors.selection, () => {
      this.setState({
        isHidden: !this.canEnable(),
        description: kq.getSelectedStructuresDescription(this.plugin)
      });
    }), this.subscribe(this.plugin.state.events.cell.stateUpdated, (Z) => {
      if (D8.hasTag(Z.cell.transform, y$.RootTag))
        this.forceUpdate();
    }), this.subscribe(this.plugin.behaviors.state.isBusy, (Z) => {
      this.setState({ isBusy: Z });
    });
  }
  get pivot() {
    return this.plugin.managers.structure.hierarchy.selection.structures[0];
  }
  canEnable() {
    var Z, J;
    let { selection: $ } = this.plugin.managers.structure.hierarchy;
    if ($.structures.length !== 1)
      return !1;
    let X = this.pivot.cell;
    if (!X.obj)
      return !1;
    return !!((J = (Z = iV.definition).isApplicable) === null || J === void 0 ? void 0 : J.call(Z, X.obj, X.transform, this.plugin));
  }
  renderEnable() {
    var Z, J;
    let $ = this.pivot;
    if (!$.cell.parent)
      return null;
    let X = f2.findTagInSubtree($.cell.parent.tree, this.pivot.cell.transform.ref, y$.RootTag), Y = X && $.cell.parent.cells.get(X), Q = Y && Y.status === "error" ? { header: !!Y.errorText && ((Z = Y.errorText) === null || Z === void 0 ? void 0 : Z.includes("404")) ? "No Density Data Available" : "Error Enabling", icon: Y10, title: Y.errorText } : Y && ((J = Y.obj) === null || J === void 0 ? void 0 : J.data.entries.length) === 0 ? { header: "Error Enabling", icon: Y10, title: "No Entry for Streaming Found" } : { header: "Enable", icon: xK, title: "Enable" };
    return CZ.jsx(U4, { state: $.cell.parent, action: iV, initiallyCollapsed: !0, nodeRef: $.cell.transform.ref, simpleApply: Q });
  }
  renderParams() {
    var Z, J, $, X, Y;
    let Q = this.pivot;
    if (!Q.cell.parent)
      return null;
    let W = ((J = (Z = Q.volumeStreaming) === null || Z === void 0 ? void 0 : Z.cell.transform.params) === null || J === void 0 ? void 0 : J.entry.params.view.name) === "selection-box" && ((Y = (X = ($ = this.plugin.state.behaviors.cells.get(pz.id)) === null || $ === void 0 ? void 0 : $.params) === null || X === void 0 ? void 0 : X.values) === null || Y === void 0 ? void 0 : Y.bindings);
    return CZ.jsxs(CZ.Fragment, { children: [CZ.jsx(oW, { state: Q.cell.parent, transform: Q.volumeStreaming.cell.transform, customHeader: "none", noMargin: !0 }), W && CZ.jsx(g$, { header: "Controls Help", children: CZ.jsx(YP, { bindings: W }) })] });
  }
  renderControls() {
    let Z = this.pivot;
    if (!Z)
      return null;
    if (!Z.volumeStreaming)
      return this.renderEnable();
    return this.renderParams();
  }
}

class y20 extends y5 {
  constructor() {
    super(...arguments);
    this.item = (Z) => {
      var J;
      let $ = this.plugin.managers.volume.hierarchy.selection, X = ((J = Z.cell.obj) === null || J === void 0 ? void 0 : J.label) || "Volume";
      return {
        kind: "item",
        label: (Z.kind === "lazy-volume" ? "Load " : "") + (X || Z.kind),
        selected: $ === Z,
        value: Z
      };
    }, this.selectCurrent = (Z) => {
      if (this.toggleHierarchy(), !Z)
        return;
      let J = Z.value;
      if (J.kind === "volume")
        this.plugin.managers.volume.hierarchy.setCurrent(J);
      else
        this.lazyLoad(J.cell);
    }, this.selectAdd = (Z) => {
      if (!Z)
        return;
      this.setState({ show: void 0 }), Z.value();
    }, this.toggleHierarchy = () => this.setState({ show: this.state.show !== "hierarchy" ? "hierarchy" : void 0 }), this.toggleAddRepr = () => this.setState({ show: this.state.show !== "add-repr" ? "add-repr" : void 0 }), this.toggleVisibility = () => {
      var Z, J;
      let $ = this.plugin.managers.volume.hierarchy, { current: X } = $, Y = !((J = (Z = X.volumes[0]) === null || Z === void 0 ? void 0 : Z.representations[0]) === null || J === void 0 ? void 0 : J.cell.state.isHidden);
      this.plugin.managers.volume.hierarchy.toggleVisibility(X.volumes.flatMap((Q) => Q.representations), Y ? "hide" : "show");
    };
  }
  defaultState() {
    return {
      header: "Volume",
      isCollapsed: !1,
      isBusy: !1,
      isHidden: !0,
      brand: { accent: "purple", svg: $10 }
    };
  }
  componentDidMount() {
    this.subscribe(this.plugin.managers.volume.hierarchy.behaviors.selection, (Z) => {
      this.setState({ isHidden: Z.hierarchy.volumes.length === 0 && Z.hierarchy.lazyVolumes.length === 0 });
    }), this.subscribe(this.plugin.behaviors.state.isBusy, (Z) => {
      this.setState({ isBusy: Z });
    });
  }
  get hierarchyItems() {
    let Z = this.plugin.managers.volume.hierarchy, { current: J } = Z, $ = [];
    for (let X of J.volumes)
      $.push(this.item(X));
    for (let X of J.lazyVolumes)
      $.push(this.item(X));
    return $;
  }
  get addActions() {
    let Z = this.plugin.managers.volume.hierarchy, J = Z.selection;
    return [
      ...F4.getRepresentationTypes(this.plugin, J).map((X) => w8.Item(X[1], () => Z.addRepresentation(J, X[0])))
    ];
  }
  get isEmpty() {
    let { volumes: Z, lazyVolumes: J } = this.plugin.managers.volume.hierarchy.current;
    return Z.length === 0 && J.length === 0;
  }
  get label() {
    var Z;
    if (this.state.loadingLabel)
      return `Loading ${this.state.loadingLabel}...`;
    let J = this.plugin.managers.volume.hierarchy.selection;
    if (!J)
      return "Nothing Selected";
    return ((Z = J === null || J === void 0 ? void 0 : J.cell.obj) === null || Z === void 0 ? void 0 : Z.label) || "Volume";
  }
  async lazyLoad(Z) {
    let { url: J, isBinary: $, format: X, entryId: Y, isovalues: Q } = Z.obj.data;
    this.setState({ isBusy: !0, loadingLabel: Z.obj.label });
    try {
      let W = this.plugin;
      await W.dataTransaction(async () => {
        var K, G, H, N;
        let q = await W.builders.data.download({ url: J, isBinary: $ }, { state: { isGhost: !0 } }), U = await W.dataFormats.get(X).parse(W, q, { entryId: Y }), F = U.volume || U.volumes[0];
        if (!(F === null || F === void 0 ? void 0 : F.isOk))
          throw new Error("Failed to parse any volume.");
        let E = W.build();
        for (let R of Q)
          E.to((H = (K = U.volumes) === null || K === void 0 ? void 0 : K[(G = R.volumeIndex) !== null && G !== void 0 ? G : 0]) !== null && H !== void 0 ? H : U.volume).apply(H1.Representation.VolumeRepresentation3D, IU(this.plugin, F.data, {
            type: "isosurface",
            typeParams: { alpha: (N = R.alpha) !== null && N !== void 0 ? N : 1, isoValue: R.type === "absolute" ? { kind: "absolute", absoluteValue: R.value } : { kind: "relative", relativeValue: R.value } },
            color: "uniform",
            colorParams: { value: R.color }
          }));
        await E.commit(), await W.build().delete(Z).commit();
      });
    } finally {
      this.setState({ isBusy: !1, loadingLabel: void 0 });
    }
  }
  renderControls() {
    let Z = this.state.isBusy || this.isEmpty, J = this.label, $ = this.plugin.managers.volume.hierarchy.selection, X = this.plugin.managers.volume.hierarchy, { current: Y } = X;
    return CZ.jsxs(CZ.Fragment, { children: [CZ.jsxs("div", { className: "msp-flex-row", style: { marginTop: "1px" }, children: [CZ.jsx(Z8, { noOverflow: !0, flex: !0, onClick: this.toggleHierarchy, disabled: Z, title: J, children: J }), !this.isEmpty && $ && CZ.jsx(o2, { svg: hH, onClick: this.toggleAddRepr, title: "Apply a structure presets to the current hierarchy.", toggleState: this.state.show === "add-repr", disabled: Z }), !this.isEmpty && CZ.jsx(o2, { svg: b5, onClick: this.toggleVisibility, toggleState: !1, title: "Toggle visibility of all volumes.", disabled: Z })] }), this.state.show === "hierarchy" && CZ.jsx(w8, { items: this.hierarchyItems, onSelect: this.selectCurrent }), this.state.show === "add-repr" && CZ.jsx(w8, { items: this.addActions, onSelect: this.selectAdd }), Y.volumes.length > 0 && CZ.jsx("div", { style: { marginTop: "6px" }, children: Y.volumes.map((Q) => CZ.jsx(HA1, { volume: Q }, Q.cell.transform.ref)) })] });
  }
}
function HA1({ volume: Z }) {
  var J, $;
  return CZ.jsxs(CZ.Fragment, { children: [CZ.jsx("div", { className: "msp-control-group-header", style: { marginTop: "1px" }, children: CZ.jsx("div", { children: CZ.jsx("b", { children: ($ = (J = Z.cell.obj) === null || J === void 0 ? void 0 : J.label) !== null && $ !== void 0 ? $ : "n/a" }) }) }), Z.representations.map((X) => CZ.jsx(Mk0, { volume: Z, representation: X }, X.cell.transform.ref))] });
}

class Mk0 extends N7 {
  constructor() {
    super(...arguments);
    this.state = { action: void 0 }, this.updateIsoValueEvent = new P6, this.remove = () => this.plugin.managers.volume.hierarchy.remove([this.props.representation], !0), this.toggleVisible = (Z) => {
      Z.preventDefault(), Z.currentTarget.blur(), this.plugin.managers.volume.hierarchy.toggleVisibility([this.props.representation]);
    }, this.toggleColor = () => {
      this.setState({ action: this.state.action === "select-color" ? void 0 : "select-color" });
    }, this.toggleUpdate = () => this.setState({ action: this.state.action === "update" ? void 0 : "update" }), this.highlight = (Z) => {
      if (Z.preventDefault(), !this.props.representation.cell.parent)
        return;
      h1.Interactivity.Object.Highlight(this.plugin, { state: this.props.representation.cell.parent, ref: this.props.representation.cell.transform.ref });
    }, this.clearHighlight = (Z) => {
      Z.preventDefault(), h1.Interactivity.ClearHighlights(this.plugin);
    }, this.focus = () => {
      var Z;
      let J = this.props.representation, $ = (Z = J.cell.obj) === null || Z === void 0 ? void 0 : Z.data.repr.getAllLoci();
      if (J.cell.state.isHidden)
        this.plugin.managers.volume.hierarchy.toggleVisibility([this.props.representation], "show");
      if ($)
        this.plugin.managers.camera.focusLoci($, { extraRadius: 1 });
    }, this.updateColor = ({ value: Z }) => {
      let J = this.props.representation.cell.transform;
      return this.plugin.build().to(J.ref).update({
        ...J.params,
        colorTheme: {
          name: "uniform",
          params: { value: Z }
        }
      }).commit();
    }, this.requestIsoValueUpdate = (Z) => {
      this.updateIsoValueEvent.next(Z);
    }, this.updateIsoValue = (Z) => {
      var J, $;
      let X = this.props.representation.cell.transform;
      return this.plugin.build().to(X.ref).update({
        ...X.params,
        type: {
          ...(J = X.params) === null || J === void 0 ? void 0 : J.type,
          params: {
            ...($ = X.params) === null || $ === void 0 ? void 0 : $.type.params,
            isoValue: Z.isoValue
          }
        }
      }).commit();
    }, this.isoValueParams = cJ((Z, J) => {
      var $, X;
      let Q = this.props.representation.cell.transform.params;
      if ((Q === null || Q === void 0 ? void 0 : Q.type.name) !== "isosurface")
        return;
      return { isoValue: Q1.createIsoValueParam(Q.type.params.isoValue, (X = ($ = this.props.volume.cell.obj) === null || $ === void 0 ? void 0 : $.data.grid) === null || X === void 0 ? void 0 : X.stats) };
    });
  }
  componentDidMount() {
    this.subscribe(this.plugin.state.events.cell.stateUpdated, (Z) => {
      if (wK.ObjectEvent.isCell(Z, this.props.representation.cell))
        this.forceUpdate();
    }), this.subscribe(this.updateIsoValueEvent.pipe(bQ(100, void 0, { leading: !1, trailing: !0 })), this.updateIsoValue);
  }
  get color() {
    var Z, J;
    let $ = this.props.representation.cell;
    if (((Z = $.transform.params) === null || Z === void 0 ? void 0 : Z.colorTheme.name) !== "uniform")
      return;
    return (J = $.transform.params) === null || J === void 0 ? void 0 : J.colorTheme.params.value;
  }
  get isIsoSurface() {
    var Z;
    return ((Z = this.props.representation.cell.transform.params) === null || Z === void 0 ? void 0 : Z.type.name) === "isosurface";
  }
  render() {
    var Z, J, $;
    let X = this.props.representation.cell, Y = X.transform.params, Q = this.color, W = this.isoValueParams(X.transform.ref, Y === null || Y === void 0 ? void 0 : Y.type.name);
    return CZ.jsxs(CZ.Fragment, { children: [CZ.jsxs("div", { className: "msp-flex-row", children: [Q !== void 0 && CZ.jsx(Z8, { style: { backgroundColor: i0.toStyle(Q), minWidth: 32, width: 32 }, onClick: this.toggleColor }), CZ.jsxs(Z8, { noOverflow: !0, className: "msp-control-button-label", title: `${(Z = X.obj) === null || Z === void 0 ? void 0 : Z.label}. Click to focus.`, onClick: this.focus, onMouseEnter: this.highlight, onMouseLeave: this.clearHighlight, style: { textAlign: "left" }, children: [(J = X.obj) === null || J === void 0 ? void 0 : J.label, CZ.jsx("small", { className: "msp-25-lower-contrast-text", style: { float: "right" }, children: ($ = X.obj) === null || $ === void 0 ? void 0 : $.description })] }), CZ.jsx(o2, { svg: X.state.isHidden ? yK : b5, toggleState: !1, onClick: this.toggleVisible, title: `${X.state.isHidden ? "Show" : "Hide"} component`, small: !0, className: "msp-form-control", flex: !0 }), CZ.jsx(o2, { svg: GX, onClick: this.remove, title: "Remove", small: !0 }), CZ.jsx(o2, { svg: ME, onClick: this.toggleUpdate, title: "Actions", toggleState: this.state.action === "update" })] }), this.state.action === "update" && !!X.parent && CZ.jsx("div", { style: { marginBottom: "6px" }, className: "msp-accent-offset", children: CZ.jsxs("div", { children: [!!W && CZ.jsx("div", { style: { marginBottom: "1px" }, children: CZ.jsx(iZ, { params: W, values: { isoValue: Y === null || Y === void 0 ? void 0 : Y.type.params.isoValue }, onChangeValues: this.requestIsoValueUpdate }) }), CZ.jsx(oW, { state: X.parent, transform: X.transform, customHeader: "none", noMargin: !0 })] }) }), this.state.action === "select-color" && Q !== void 0 && CZ.jsx("div", { style: { marginBottom: "6px", marginTop: 1 }, className: "msp-accent-offset", children: CZ.jsx(zQ, { header: "Select Color", initialExpanded: !0, hideExpander: !0, hideOffset: !0, onHeaderClick: this.toggleColor, topRightIcon: cW, noTopMargin: !0, childrenClassName: "msp-viewport-controls-panel-controls", children: CZ.jsx(fI, { param: NA1, value: this.color, onChange: this.updateColor, name: "color", hideNameRow: !0 }) }) })] });
  }
}
var NA1 = j.Color(i0(1184274));

// node_modules/molstar/lib/mol-plugin-ui/structure/superposition.js
var H6 = t2(PZ(), 1);

// node_modules/molstar/lib/mol-math/linear-algebra/matrix/evd.js
var QP;
(function(Z) {
  function J(X) {
    return {
      size: X,
      matrix: ZZ.create(X, X),
      eigenValues: new Float64Array(X),
      D: new Float64Array(X),
      E: new Float64Array(X)
    };
  }
  Z.createCache = J;
  function $(X) {
    qA1(X.size, X.matrix.data, X.eigenValues, X.D, X.E);
  }
  Z.compute = $;
})(QP || (QP = {}));
function qA1(Z, J, $, X, Y) {
  for (let W = 0;W < Z; W++)
    Y[W] = 0;
  let Q = Z - 1;
  for (let W = 0;W < Z; W++)
    X[W] = J[W * Z + Q];
  FA1(J, X, Y, Z), UA1(J, X, Y, Z);
  for (let W = 0;W < Z; W++)
    $[W] = X[W];
}
function FA1(Z, J, $, X) {
  for (let Y = X - 1;Y > 0; Y--) {
    let Q = 0, W = 0;
    for (let K = 0;K < Y; K++)
      Q = Q + Math.abs(J[K]);
    if (Q === 0) {
      $[Y] = J[Y - 1];
      for (let K = 0;K < Y; K++)
        J[K] = Z[K * X + Y - 1], Z[K * X + Y] = 0, Z[Y * X + K] = 0;
    } else {
      for (let N = 0;N < Y; N++)
        J[N] /= Q, W += J[N] * J[N];
      let K = J[Y - 1], G = Math.sqrt(W);
      if (K > 0)
        G = -G;
      $[Y] = Q * G, W = W - K * G, J[Y - 1] = K - G;
      for (let N = 0;N < Y; N++)
        $[N] = 0;
      for (let N = 0;N < Y; N++) {
        K = J[N], Z[Y * X + N] = K, G = $[N] + Z[N * X + N] * K;
        for (let q = N + 1;q <= Y - 1; q++)
          G += Z[N * X + q] * J[q], $[q] += Z[N * X + q] * K;
        $[N] = G;
      }
      K = 0;
      for (let N = 0;N < Y; N++)
        $[N] /= W, K += $[N] * J[N];
      let H = K / (W + W);
      for (let N = 0;N < Y; N++)
        $[N] -= H * J[N];
      for (let N = 0;N < Y; N++) {
        K = J[N], G = $[N];
        for (let q = N;q <= Y - 1; q++)
          Z[N * X + q] -= K * $[q] + G * J[q];
        J[N] = Z[N * X + Y - 1], Z[N * X + Y] = 0;
      }
    }
    J[Y] = W;
  }
  for (let Y = 0;Y < X - 1; Y++) {
    Z[Y * X + X - 1] = Z[Y * X + Y], Z[Y * X + Y] = 1;
    let Q = J[Y + 1];
    if (Q !== 0) {
      for (let W = 0;W <= Y; W++)
        J[W] = Z[(Y + 1) * X + W] / Q;
      for (let W = 0;W <= Y; W++) {
        let K = 0;
        for (let G = 0;G <= Y; G++)
          K += Z[(Y + 1) * X + G] * Z[W * X + G];
        for (let G = 0;G <= Y; G++)
          Z[W * X + G] -= K * J[G];
      }
    }
    for (let W = 0;W <= Y; W++)
      Z[(Y + 1) * X + W] = 0;
  }
  for (let Y = 0;Y < X; Y++)
    J[Y] = Z[Y * X + X - 1], Z[Y * X + X - 1] = 0;
  Z[X * X - 1] = 1, $[0] = 0;
}
function UA1(Z, J, $, X) {
  for (let G = 1;G < X; G++)
    $[G - 1] = $[G];
  $[X - 1] = 0;
  let Q = 0, W = 0, K = Math.pow(2, -53);
  for (let G = 0;G < X; G++) {
    W = Math.max(W, Math.abs(J[G]) + Math.abs($[G]));
    let H = G;
    while (H < X) {
      if (Math.abs($[H]) <= K * W)
        break;
      H++;
    }
    if (H > G) {
      let N = 0;
      do {
        N = N + 1;
        let q = J[G], U = (J[G + 1] - q) / (2 * $[G]), F = Ak0(U, 1);
        if (U < 0)
          F = -F;
        J[G] = $[G] / (U + F), J[G + 1] = $[G] * (U + F);
        let E = J[G + 1], R = q - J[G];
        for (let V = G + 2;V < X; V++)
          J[V] -= R;
        Q = Q + R, U = J[H];
        let z = 1, D = z, A = z, B = $[G + 1], T = 0, w = 0;
        for (let V = H - 1;V >= G; V--) {
          A = D, D = z, w = T, q = z * $[V], R = z * U, F = Ak0(U, $[V]), $[V + 1] = T * F, T = $[V] / F, z = U / F, U = z * J[V] - T * q, J[V + 1] = R + T * (z * q + T * J[V]);
          for (let P = 0;P < X; P++)
            R = Z[(V + 1) * X + P], Z[(V + 1) * X + P] = T * Z[V * X + P] + z * R, Z[V * X + P] = z * Z[V * X + P] - T * R;
        }
        if (U = -T * w * A * B * $[G] / E, $[G] = T * U, J[G] = z * U, N >= 1000)
          throw new Error("SVD: Not converging.");
      } while (Math.abs($[G]) > K * W);
    }
    J[G] = J[G] + Q, $[G] = 0;
  }
  for (let G = 0;G < X - 1; G++) {
    let H = G, N = J[G];
    for (let q = G + 1;q < X; q++)
      if (J[q] < N)
        H = q, N = J[q];
    if (H !== G) {
      J[H] = J[G], J[G] = N;
      for (let q = 0;q < X; q++)
        N = Z[G * X + q], Z[G * X + q] = Z[H * X + q], Z[H * X + q] = N;
    }
  }
}
function Ak0(Z, J) {
  if (Math.abs(Z) > Math.abs(J)) {
    let $ = J / Z;
    return Math.abs(Z) * Math.sqrt(1 + $ * $);
  }
  if (J !== 0) {
    let $ = Z / J;
    return Math.abs(J) * Math.sqrt(1 + $ * $);
  }
  return 0;
}

// node_modules/molstar/lib/mol-math/linear-algebra/3d/minimize-rmsd.js
var WW;
(function(Z) {
  let J;
  (function(X) {
    function Y(Q) {
      return { x: new Float64Array(Q), y: new Float64Array(Q), z: new Float64Array(Q) };
    }
    X.empty = Y;
  })(J = Z.Positions || (Z.Positions = {}));
  function $(X, Y) {
    return Y !== null && Y !== void 0 || (Y = { bTransform: e.zero(), rmsd: 0, nAlignedElements: 0 }), EA1(new Bk0(X, Y)), Y;
  }
  Z.compute = $;
})(WW || (WW = {}));

class Bk0 {
  constructor(Z, J) {
    if (this.evdCache = QP.createCache(4), this.translateB = e.identity(), this.rotateB = e.identity(), this.tempMatrix = e.identity(), this.a = Z.a, this.b = Z.b, Z.centerA)
      this.centerA = Z.centerA;
    else
      this.centerA = Z.centerA = yQ.fromArrays(Z.a, C0()).center;
    if (Z.centerB)
      this.centerB = Z.centerB;
    else
      this.centerB = Z.centerB = yQ.fromArrays(Z.b, C0()).center;
    this.result = J;
  }
}
function LA1(Z) {
  let J = Z.evdCache.matrix;
  ZZ.makeZero(J);
  let $ = Z.a.x, X = Z.a.y, Y = Z.a.z, Q = Z.b.x, W = Z.b.y, K = Z.b.z, G = Z.centerA, H = Z.centerB, N = 0, q = Math.min(Z.a.x.length, Z.b.x.length);
  for (let U = 0;U < q; U++) {
    let F = $[U] - G[0], E = X[U] - G[1], R = Y[U] - G[2], z = Q[U] - H[0], D = W[U] - H[1], A = K[U] - H[2];
    N += F * F + E * E + R * R + z * z + D * D + A * A, ZZ.add(J, 0, 0, F * z + E * D + R * A), ZZ.add(J, 0, 1, -(R * D) + E * A), ZZ.add(J, 0, 2, R * z - F * A), ZZ.add(J, 0, 3, -(E * z) + F * D), ZZ.add(J, 1, 0, -(R * D) + E * A), ZZ.add(J, 1, 1, F * z - E * D - R * A), ZZ.add(J, 1, 2, E * z + F * D), ZZ.add(J, 1, 3, R * z + F * A), ZZ.add(J, 2, 0, R * z - F * A), ZZ.add(J, 2, 1, E * z + F * D), ZZ.add(J, 2, 2, -(F * z) + E * D - R * A), ZZ.add(J, 2, 3, R * D + E * A), ZZ.add(J, 3, 0, -(E * z) + F * D), ZZ.add(J, 3, 1, R * z + F * A), ZZ.add(J, 3, 2, R * D + E * A), ZZ.add(J, 3, 3, -(F * z) - E * D + R * A);
  }
  return N;
}
function RA1(Z) {
  let J = Z.evdCache.matrix, $ = ZZ.get(J, 1, 3), X = ZZ.get(J, 2, 3), Y = ZZ.get(J, 3, 3), Q = ZZ.get(J, 0, 3), W = 2 * X * X, K = 2 * Y * Y, G = 2 * $ * $, H = 2 * $ * X, N = 2 * Q * Y, q = 2 * $ * Y, U = 2 * Q * X, F = 2 * X * Y, E = 2 * Q * $, R = Z.translateB;
  e.setValue(R, 0, 3, -Z.centerB[0]), e.setValue(R, 1, 3, -Z.centerB[1]), e.setValue(R, 2, 3, -Z.centerB[2]), R = Z.rotateB, e.setValue(R, 0, 0, 1 - W - K), e.setValue(R, 0, 1, H + N), e.setValue(R, 0, 2, q - U), e.setValue(R, 1, 0, H - N), e.setValue(R, 1, 1, 1 - G - K), e.setValue(R, 1, 2, F + E), e.setValue(R, 2, 0, q + U), e.setValue(R, 2, 1, F - E), e.setValue(R, 2, 2, 1 - G - W), e.setValue(R, 3, 3, 1), e.mul(Z.tempMatrix, Z.rotateB, Z.translateB), R = Z.translateB, e.setValue(R, 0, 3, Z.centerA[0]), e.setValue(R, 1, 3, Z.centerA[1]), e.setValue(R, 2, 3, Z.centerA[2]), e.mul(Z.result.bTransform, Z.translateB, Z.tempMatrix);
}
function EA1(Z) {
  let J = LA1(Z);
  QP.compute(Z.evdCache);
  let $ = J - 2 * Z.evdCache.eigenValues[3];
  $ = $ < 0 ? 0 : Math.sqrt($ / Z.a.x.length), RA1(Z), Z.result.rmsd = $, Z.result.nAlignedElements = Z.a.x.length;
}

// node_modules/molstar/lib/mol-model/sequence/alignment/substitution-matrix.js
var OA1 = [
  [4, 0, -2, -1, -2, 0, -2, -1, -1, -1, -1, -2, -1, -1, -1, 1, 0, 0, -3, -2],
  [0, 9, -3, -4, -2, -3, -3, -1, -3, -1, -1, -3, -3, -3, -3, -1, -1, -1, -2, -2],
  [-2, -3, 6, 2, -3, -1, -1, -3, -1, -4, -3, 1, -1, 0, -2, 0, -1, -3, -4, -3],
  [-1, -4, 2, 5, -3, -2, 0, -3, 1, -3, -2, 0, -1, 2, 0, 0, -1, -2, -3, -2],
  [-2, -2, -3, -3, 6, -3, -1, 0, -3, 0, 0, -3, -4, -3, -3, -2, -2, -1, 1, 3],
  [0, -3, -1, -2, -3, 6, -2, -4, -2, -4, -3, 0, -2, -2, -2, 0, -2, -3, -2, -3],
  [-2, -3, -1, 0, -1, -2, 8, -3, -1, -3, -2, 1, -2, 0, 0, -1, -2, -3, -2, 2],
  [-1, -1, -3, -3, 0, -4, -3, 4, -3, 2, 1, -3, -3, -3, -3, -2, -1, 3, -3, -1],
  [-1, -3, -1, 1, -3, -2, -1, -3, 5, -2, -1, 0, -1, 1, 2, 0, -1, -2, -3, -2],
  [-1, -1, -4, -3, 0, -4, -3, 2, -2, 4, 2, -3, -3, -2, -2, -2, -1, 1, -2, -1],
  [-1, -1, -3, -2, 0, -3, -2, 1, -1, 2, 5, -2, -2, 0, -1, -1, -1, 1, -1, -1],
  [-2, -3, 1, 0, -3, 0, 1, -3, 0, -3, -2, 6, -2, 0, 0, 1, 0, -3, -4, -2],
  [-1, -3, -1, -1, -4, -2, -2, -3, -1, -3, -2, -2, 7, -1, -2, -1, -1, -2, -4, -3],
  [-1, -3, 0, 2, -3, -2, 0, -3, 1, -2, 0, 0, -1, 5, 1, 0, -1, -2, -2, -1],
  [-1, -3, -2, 0, -3, -2, 0, -3, 2, -2, -1, 0, -2, 1, 5, -1, -1, -3, -3, -2],
  [1, -1, 0, 0, -2, 0, -1, -2, 0, -2, -1, 1, -1, 0, -1, 4, 1, -2, -3, -2],
  [0, -1, -1, -1, -2, -2, -2, -1, -1, -1, -1, 0, -1, -1, -1, 1, 5, 0, -2, -2],
  [0, -1, -3, -2, -1, -3, -3, 3, -2, 1, 1, -3, -2, -2, -3, -2, 0, 4, -3, -1],
  [-3, -2, -4, -3, 1, -2, -2, -3, -3, -2, -1, -4, -4, -2, -3, -3, -2, -3, 11, 2],
  [-2, -2, -3, -2, 3, -3, 2, -1, -2, -1, -1, -2, -3, -1, -2, -2, -2, -1, 2, 7]
], zA1 = [
  [4, -1, -2, -2, 0, -1, -1, 0, -2, -1, -1, -1, -1, -2, -1, 1, 0, -3, -2, 0, -2, -1, 0],
  [-1, 5, 0, -2, -3, 1, 0, -2, 0, -3, -2, 2, -1, -3, -2, -1, -1, -3, -2, -3, -1, 0, -1],
  [-2, 0, 6, 1, -3, 0, 0, 0, 1, -3, -3, 0, -2, -3, -2, 1, 0, -4, -2, -3, 3, 0, -1],
  [-2, -2, 1, 6, -3, 0, 2, -1, -1, -3, -4, -1, -3, -3, -1, 0, -1, -4, -3, -3, 4, 1, -1],
  [0, -3, -3, -3, 9, -3, -4, -3, -3, -1, -1, -3, -1, -2, -3, -1, -1, -2, -2, -1, -3, -3, -2],
  [-1, 1, 0, 0, -3, 5, 2, -2, 0, -3, -2, 1, 0, -3, -1, 0, -1, -2, -1, -2, 0, 3, -1],
  [-1, 0, 0, 2, -4, 2, 5, -2, 0, -3, -3, 1, -2, -3, -1, 0, -1, -3, -2, -2, 1, 4, -1],
  [0, -2, 0, -1, -3, -2, -2, 6, -2, -4, -4, -2, -3, -3, -2, 0, -2, -2, -3, -3, -1, -2, -1],
  [-2, 0, 1, -1, -3, 0, 0, -2, 8, -3, -3, -1, -2, -1, -2, -1, -2, -2, 2, -3, 0, 0, -1],
  [-1, -3, -3, -3, -1, -3, -3, -4, -3, 4, 2, -3, 1, 0, -3, -2, -1, -3, -1, 3, -3, -3, -1],
  [-1, -2, -3, -4, -1, -2, -3, -4, -3, 2, 4, -2, 2, 0, -3, -2, -1, -2, -1, 1, -4, -3, -1],
  [-1, 2, 0, -1, -3, 1, 1, -2, -1, -3, -2, 5, -1, -3, -1, 0, -1, -3, -2, -2, 0, 1, -1],
  [-1, -1, -2, -3, -1, 0, -2, -3, -2, 1, 2, -1, 5, 0, -2, -1, -1, -1, -1, 1, -3, -1, -1],
  [-2, -3, -3, -3, -2, -3, -3, -3, -1, 0, 0, -3, 0, 6, -4, -2, -2, 1, 3, -1, -3, -3, -1],
  [-1, -2, -2, -1, -3, -1, -1, -2, -2, -3, -3, -1, -2, -4, 7, -1, -1, -4, -3, -2, -2, -1, -2],
  [1, -1, 1, 0, -1, 0, 0, 0, -1, -2, -2, 0, -1, -2, -1, 4, 1, -3, -2, -2, 0, 0, 0],
  [0, -1, 0, -1, -1, -1, -1, -2, -2, -1, -1, -1, -1, -2, -1, 1, 5, -2, -2, 0, -1, -1, 0],
  [-3, -3, -4, -4, -2, -2, -3, -2, -2, -3, -2, -3, -1, 1, -4, -3, -2, 11, 2, -3, -4, -3, -2],
  [-2, -2, -2, -3, -2, -1, -2, -3, 2, -1, -1, -2, -1, 3, -3, -2, -2, 2, 7, -1, -3, -2, -1],
  [0, -3, -3, -3, -1, -2, -2, -3, -3, 3, 1, -2, 1, -1, -2, -2, 0, -3, -1, 4, -3, -2, -1],
  [-2, -1, 3, 4, -3, 0, 1, -1, 0, -3, -4, 0, -3, -3, -2, 0, -1, -4, -3, -3, 4, 1, -1],
  [-1, 0, 0, 1, -3, 3, 4, -2, 0, -3, -3, 1, -1, -3, -1, 0, -1, -3, -2, -2, 1, 4, -1],
  [0, -1, -1, -1, -2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -2, 0, 0, -2, -1, -1, -1, -1, -1]
];
function wk0(Z, J) {
  let $, X = 0, Y = {};
  return J.forEach((Q) => {
    $ = 0;
    let W = {};
    Q.forEach((K) => W[Z[$++]] = K), Y[Z[X++]] = W;
  }), Y;
}
var jk0 = (() => ({
  blosum62: wk0("ARNDCQEGHILKMFPSTWYVBZX", zA1),
  blosum62x: wk0("ACDEFGHIKLMNPQRSTVWY", OA1)
}))();

// node_modules/molstar/lib/mol-model/sequence/alignment/alignment.js
var DA1 = {
  gapPenalty: -11,
  gapExtensionPenalty: -1,
  substMatrix: "default"
};
function Tk0(Z, J, $ = {}) {
  let X = { ...DA1, ...$ }, Y = new _k0(Z, J, X);
  return Y.calculate(), Y.trace();
}

class _k0 {
  constructor(Z, J, $) {
    this.seqA = Z, this.seqB = J, this.S = [], this.V = [], this.H = [], this.gapPenalty = $.gapPenalty, this.gapExtensionPenalty = $.gapExtensionPenalty, this.substMatrix = $.substMatrix === "default" ? void 0 : jk0[$.substMatrix], this.n = this.seqA.length, this.m = this.seqB.length;
  }
  initMatrices() {
    let { n: Z, m: J, gapPenalty: $, S: X, V: Y, H: Q } = this;
    for (let W = 0;W <= Z; ++W) {
      X[W] = [], Y[W] = [], Q[W] = [];
      for (let K = 0;K <= J; ++K)
        X[W][K] = 0, Y[W][K] = 0, Q[W][K] = 0;
    }
    for (let W = 0;W <= Z; ++W)
      X[W][0] = $, Q[W][0] = -1 / 0;
    for (let W = 0;W <= J; ++W)
      X[0][W] = $, Y[0][W] = -1 / 0;
    X[0][0] = 0;
  }
  makeScoreFn() {
    let { seqA: Z, seqB: J, substMatrix: $ } = this;
    if ($)
      return function X(Y, Q) {
        var W, K;
        let G = Z[Y], H = J[Q];
        return (K = (W = $[G]) === null || W === void 0 ? void 0 : W[H]) !== null && K !== void 0 ? K : -4;
      };
    else
      return function X(Y, Q) {
        let W = Z[Y], K = J[Q];
        return W === K ? 5 : -3;
      };
  }
  calculate() {
    this.initMatrices();
    let Z = this.makeScoreFn(), { V: J, H: $, S: X, n: Y, m: Q, gapExtensionPenalty: W, gapPenalty: K } = this, G, H, N, q, U;
    for (let F = 1;F <= Y; ++F) {
      H = X[F - 1], G = J[F - 1], N = J[F], q = $[F], U = X[F];
      for (let E = 1;E <= Q; ++E)
        N[E] = Math.max(H[E] + K, G[E] + W), q[E] = Math.max(U[E - 1] + K, q[E - 1] + W), U[E] = Math.max(H[E - 1] + Z(F - 1, E - 1), N[E], q[E]);
    }
  }
  trace() {
    let Z = this.makeScoreFn(), { V: J, H: $, S: X, seqA: Y, seqB: Q, gapExtensionPenalty: W, gapPenalty: K } = this, G = this.n, H = this.m, N, q, U = "", F = "";
    if (X[G][H] >= J[G][H])
      N = "S", q = X[G][H];
    else if (J[G][H] >= $[G][H])
      N = "V", q = J[G][H];
    else
      N = "H", q = $[G][H];
    while (G > 0 && H > 0)
      if (N === "S")
        if (X[G][H] === X[G - 1][H - 1] + Z(G - 1, H - 1))
          U = Y[G - 1] + U, F = Q[H - 1] + F, --G, --H, N = "S";
        else if (X[G][H] === J[G][H])
          N = "V";
        else if (X[G][H] === $[G][H])
          N = "H";
        else
          --G, --H;
      else if (N === "V")
        if (J[G][H] === J[G - 1][H] + W)
          U = Y[G - 1] + U, F = "-" + F, --G, N = "V";
        else if (J[G][H] === X[G - 1][H] + K)
          U = Y[G - 1] + U, F = "-" + F, --G, N = "S";
        else
          --G;
      else if (N === "H")
        if ($[G][H] === $[G][H - 1] + W)
          U = "-" + U, F = Q[H - 1] + F, --H, N = "H";
        else if ($[G][H] === X[G][H - 1] + K)
          U = "-" + U, F = Q[H - 1] + F, --H, N = "S";
        else
          --H;
    while (G > 0)
      U = Y[G - 1] + U, F = "-" + F, --G;
    while (H > 0)
      U = "-" + U, F = Q[H - 1] + F, --H;
    return { aliA: U, aliB: F, score: q };
  }
}

// node_modules/molstar/lib/mol-model/sequence/alignment/sequence.js
var Lg;
(function(Z) {
  function J(X) {
    let Y = /* @__PURE__ */ new Map;
    if (j0.isAtomic(X.unit)) {
      let { label_seq_id: Q } = X.unit.model.atomicHierarchy.residues, { residueIndex: W } = X.unit;
      for (let K = 0, G = f0.size(X.indices);K < G; ++K) {
        let H = f0.getAt(X.indices, K), N = X.unit.elements[H], q = Q.value(W[N]);
        if (Y.has(q))
          Y.get(q).push(H);
        else
          Y.set(q, [H]);
      }
    } else if (j0.isCoarse(X.unit)) {
      let { seq_id_begin: Q } = j0.isSpheres(X.unit) ? X.unit.model.coarseHierarchy.spheres : X.unit.model.coarseHierarchy.gaussians;
      for (let W = 0, K = f0.size(X.indices);W < K; ++W) {
        let G = f0.getAt(X.indices, W), H = X.unit.elements[G], N = Q.value(H);
        Y.set(N, [G]);
      }
    }
    return Y;
  }
  Z.createSeqIdIndicesMap = J;
  function $(X, Y = {}) {
    let Q = Vk0(X.a.unit), W = Vk0(X.b.unit), K = J(X.a), G = J(X.b), H = [], N = [], { aliA: q, aliB: U, score: F } = Tk0(Q.code.toArray(), W.code.toArray(), Y), E = 0, R = 0;
    for (let A = 0, B = q.length;A < B; ++A) {
      if (q[A] === "-" || U[A] === "-") {
        if (q[A] !== "-")
          E += 1;
        if (U[A] !== "-")
          R += 1;
        continue;
      }
      let T = Q.seqId.value(E), w = W.seqId.value(R);
      if (K.has(T) && G.has(w)) {
        let V = K.get(T), P = G.get(w);
        for (let I = 0, S = Math.min(V.length, P.length);I < S; ++I)
          H.push(V[I]), N.push(P[I]);
      }
      E += 1, R += 1;
    }
    let z = f0.intersect(f0.ofSortedArray(H), X.a.indices), D = f0.intersect(f0.ofSortedArray(N), X.b.indices);
    return {
      a: { unit: X.a.unit, indices: z },
      b: { unit: X.b.unit, indices: D },
      score: F
    };
  }
  Z.compute = $;
})(Lg || (Lg = {}));
function MA1(Z) {
  switch (Z.kind) {
    case j0.Kind.Atomic:
      return Z.model.atomicHierarchy.index.getEntityFromChain(Z.chainIndex[Z.elements[0]]);
    case j0.Kind.Spheres:
      return Z.model.coarseHierarchy.spheres.entityKey[Z.elements[0]];
    case j0.Kind.Gaussians:
      return Z.model.coarseHierarchy.gaussians.entityKey[Z.elements[0]];
  }
}
function Vk0(Z) {
  return Z.model.sequence.byEntityKey[MA1(Z)].sequence;
}

// node_modules/molstar/lib/mol-model/structure/structure/util/superposition.js
function g20(Z) {
  let J = [];
  if (Z.length <= 0)
    return J;
  let $ = BA1(Z), X = {
    a: IE(Z[0], $),
    b: IE(Z[1], $)
  };
  J[0] = WW.compute(X);
  for (let Y = 2;Y < Z.length; Y++)
    X.b = IE(Z[Y], $), X.centerB = void 0, J.push(WW.compute(X));
  return J;
}
var AA1 = /(polypeptide|cyclic-pseudo-peptide)/i;
function Ik0(Z) {
  let J = [];
  if (Z.length <= 0)
    return J;
  let $ = W0.Loci.getFirstLocation(Z[0]), Y = w1.entity.subtype($).match(AA1) ? "blosum62" : "default";
  for (let Q = 1;Q < Z.length; Q++) {
    let { a: W, b: K, score: G } = Lg.compute({
      a: Z[0].elements[0],
      b: Z[Q].elements[0]
    }, { substMatrix: Y }), H = W0.Loci(Z[0].structure, [W]), N = W0.Loci(Z[Q].structure, [K]), q = f0.size(W.indices);
    J.push({
      ...WW.compute({
        a: IE(H, q),
        b: IE(N, q)
      }),
      alignmentScore: G
    });
  }
  return J;
}
function IE(Z, J) {
  let $ = WW.Positions.empty(J), X = 0;
  for (let Y of Z.elements) {
    let { unit: Q, indices: W } = Y, { elements: K, conformation: G } = Q;
    for (let H = 0, N = f0.size(W);H < N; H++) {
      let q = K[f0.getAt(W, H)];
      if ($.x[X] = G.x(q), $.y[X] = G.y(q), $.z[X] = G.z(q), X++, X >= J)
        break;
    }
    if (X >= J)
      break;
  }
  return $;
}
function BA1(Z) {
  if (Z.length === 0)
    return 0;
  let J = W0.Loci.size(Z[0]);
  for (let $ = 1;$ < Z.length; $++) {
    let X = W0.Loci.size(Z[$]);
    if (X < J)
      J = X;
  }
  return J;
}

// node_modules/molstar/lib/mol-model/structure/structure/util/superposition-sifts-mapping.js
function Pk0(Z, J) {
  var $, X;
  let Y = /* @__PURE__ */ new Map;
  for (let N = 0;N < Z.length; N++)
    _A1(Z[N], Y, N, ($ = J === null || J === void 0 ? void 0 : J.traceOnly) !== null && $ !== void 0 ? $ : !0, (X = J === null || J === void 0 ? void 0 : J.includeResidueTest) !== null && X !== void 0 ? X : TA1);
  let Q = Array.from(Y.values()), W = jA1(Z.length, Q), K = [], G = [], H = [];
  for (let N of W)
    if (N.count === 0)
      K.push([N.i, N.j]);
    else {
      let [q, U] = wA1(Q, N.i, N.j, N.count), F = WW.compute({ a: q, b: U });
      if (Number.isNaN(F.rmsd))
        G.push([N.i, N.j]);
      else
        H.push({ transform: F, pivot: N.i, other: N.j });
    }
  return { entries: H, zeroOverlapPairs: K, failedPairs: G };
}
function wA1(Z, J, $, X) {
  let Y = WW.Positions.empty(X), Q = WW.Positions.empty(X), W = 0;
  for (let { pivots: K } of Z) {
    let G = K[J], H = K[$];
    if (!G || !H)
      continue;
    let N = Math.min(G[2] - G[1], H[2] - H[1]);
    for (let q = 0;q < N; q++) {
      let U = G[1] + q;
      Y.x[W] = G[0].conformation.x(U), Y.y[W] = G[0].conformation.y(U), Y.z[W] = G[0].conformation.z(U), U = H[1] + q, Q.x[W] = H[0].conformation.x(U), Q.y[W] = H[0].conformation.y(U), Q.z[W] = H[0].conformation.z(U), W++;
    }
  }
  return [Y, Q];
}
function jA1(Z, J) {
  let $ = [];
  for (let Y = 0;Y < Z; Y++) {
    $[Y] = [];
    for (let Q = 0;Q < Z; Q++)
      $[Y][Q] = 0;
  }
  for (let { pivots: Y } of J)
    for (let Q = 0;Q < Z; Q++) {
      if (!Y[Q])
        continue;
      let W = Y[Q][2] - Y[Q][1];
      for (let K = Q + 1;K < Z; K++) {
        if (!Y[K])
          continue;
        let G = Y[K][2] - Y[K][1];
        $[Q][K] = $[Q][K] + Math.min(W, G);
      }
    }
  let X = [];
  for (let Y = 1;Y < Z; Y++)
    X[Y - 1] = { i: 0, j: Y, count: $[0][Y] };
  return X;
}
function TA1() {
  return !0;
}
function _A1(Z, J, $, X, Y) {
  let Q = W0.Location.create(Z);
  for (let W of Z.units) {
    if (W.kind !== j0.Kind.Atomic)
      continue;
    let { elements: K, model: G } = W;
    Q.unit = W;
    let H = pQ.Provider.get(G).value;
    if (!H)
      return;
    let { dbName: N, accession: q, num: U } = H, F = b2.transientSegments(W.model.atomicHierarchy.chainAtomSegments, K), E = b2.transientSegments(W.model.atomicHierarchy.residueAtomSegments, K), R = W.model.atomicHierarchy.derived.residue.traceElementIndex;
    while (F.hasNext) {
      let z = F.move();
      E.setSegment(z);
      while (E.hasNext) {
        let D = E.move(), A = D.index;
        if (!N[A])
          continue;
        let B = R[A], T, w;
        if (X) {
          if (T = B, T === -1)
            continue;
          w = T + 1;
        } else
          T = K[D.start], w = K[D.end - 1] + 1;
        if (Q.element = B >= 0 ? B : T, !Y(Q, A, T, w))
          continue;
        let V = `${N[A]}-${q[A]}-${U[A]}`;
        if (!J.has(V))
          J.set(V, { key: V, pivots: { [$]: [W, T, w] } });
        else {
          let P = J.get(V);
          if (!P.pivots[$])
            P.pivots[$] = [W, T, w];
        }
      }
    }
  }
}

// node_modules/molstar/lib/mol-math/linear-algebra/3d/tm-align.js
var Rg;
(function(Z) {
  Z.Positions = WW.Positions;
  function J(W) {
    let { a: K, b: G } = W, H = K.x.length, N = G.x.length;
    if (H === 0 || N === 0)
      return {
        bTransform: e.identity(),
        tmScoreA: 0,
        tmScoreB: 0,
        rmsd: 0,
        alignedLength: 0,
        sequenceIdentity: 0,
        alignmentA: [],
        alignmentB: []
      };
    let q = Q(K), U = Q(G), F = $(H), E = $(N), R = Math.min(H, N), z = Math.min(Math.max(Math.min(F, E), 4.5), 8), D = 1.5 * Math.pow(R, 0.3) + 3.5, A = new Ck0(q, U, H, N, F, z, D);
    A.align();
    let { alignmentA: B, alignmentB: T, transform: w } = A.getBestAlignment(), V = X(q, U, B, T, w, F, H), P = X(q, U, B, T, w, E, N), I = Y(q, U, B, T, w), S = 0;
    if (W.seqA && W.seqB) {
      let f = 0;
      for (let v = 0;v < B.length; v++)
        if (W.seqA[B[v]] === W.seqB[T[v]])
          f++;
      S = B.length > 0 ? f / B.length : 0;
    }
    return {
      bTransform: w,
      tmScoreA: V,
      tmScoreB: P,
      rmsd: I,
      alignedLength: B.length,
      sequenceIdentity: S,
      alignmentA: B,
      alignmentB: T
    };
  }
  Z.compute = J;
  function $(W) {
    if (W <= 21)
      return 0.5;
    let K = 1.24 * Math.pow(W - 15, 0.3333333333333333) - 1.8;
    return Math.max(K, 0.5);
  }
  Z.calculateD0 = $;
  function X(W, K, G, H, N, q, U) {
    if (G.length === 0)
      return 0;
    let F = q * q, E = 0, R = M(), z = M();
    for (let D = 0;D < G.length; D++) {
      let A = G[D], B = H[D];
      M.set(R, W[A][0], W[A][1], W[A][2]), M.set(z, K[B][0], K[B][1], K[B][2]), M.transformMat4(z, z, N);
      let T = M.squaredDistance(R, z);
      E += 1 / (1 + T / F);
    }
    return E / U;
  }
  function Y(W, K, G, H, N) {
    if (G.length === 0)
      return 0;
    let q = 0, U = M(), F = M();
    for (let E = 0;E < G.length; E++)
      M.set(U, W[G[E]][0], W[G[E]][1], W[G[E]][2]), M.set(F, K[H[E]][0], K[H[E]][1], K[H[E]][2]), M.transformMat4(F, F, N), q += M.squaredDistance(U, F);
    return Math.sqrt(q / G.length);
  }
  function Q(W) {
    let K = W.x.length, G = new Array(K);
    for (let H = 0;H < K; H++)
      G[H] = [W.x[H], W.y[H], W.z[H]];
    return G;
  }
})(Rg || (Rg = {}));

class Ck0 {
  constructor(Z, J, $, X, Y, Q, W) {
    this.bestScore = -1, this.bestAlignmentA = [], this.bestAlignmentB = [], this.bestTransform = e.identity(), this.xa = Z, this.ya = J, this.lenA = $, this.lenB = X, this.d0A = Y, this.d0Search = Q, this.scoreD8 = W, this.dpPath = new Array($ + 1), this.dpVal = new Array($ + 1);
    for (let K = 0;K <= $; K++)
      this.dpPath[K] = new Array(X + 1).fill(!1), this.dpVal[K] = new Array(X + 1).fill(0);
    this.j2i = new Array(X).fill(-1);
  }
  align() {
    let { lenA: Z, lenB: J } = this, $ = Math.min(Z, J);
    this.getInitialAlignment(), this.refineAlignment(), this.tryGaplessThreading();
    for (let Y = 5;Y <= Math.min(12, $); Y++)
      this.tryFragmentInitializationMedium(Y);
    for (let Y = 16;Y <= Math.min(30, $); Y += 2)
      this.tryFragmentInitializationMedium(Y);
    let X = [
      Math.floor($ * 0.15),
      Math.floor($ * 0.25),
      Math.floor($ * 0.4),
      Math.floor($ * 0.6)
    ].filter((Y) => Y > 30);
    for (let Y of X)
      this.tryFragmentInitializationFast(Y);
    this.refineAlignment();
    for (let Y = Math.max(1, this.d0A - 3);Y <= this.d0A + 3; Y++)
      this.refineWithCutoff(Y);
    this.refineWithCutoff(this.d0A * 0.8), this.optimizeFinalAlignment();
  }
  optimizeFinalAlignment() {
    let { xa: Z, ya: J, d0A: $, lenA: X } = this, Y = [8, 7, 6, 5.5, 5, 4.5, 4];
    for (let Q of Y) {
      let W = Q * Q, K = [], G = [];
      for (let F = 0;F < this.bestAlignmentA.length; F++) {
        let E = this.bestAlignmentA[F], R = this.bestAlignmentB[F], z = M.create(J[R][0], J[R][1], J[R][2]);
        M.transformMat4(z, z, this.bestTransform);
        let D = z[0] - Z[E][0], A = z[1] - Z[E][1], B = z[2] - Z[E][2];
        if (D * D + A * A + B * B <= W)
          K.push(E), G.push(R);
      }
      if (K.length < 3)
        continue;
      let H = K.map((F) => Z[F]), N = G.map((F) => J[F]), q = this.kabsch(H, N), U = this.scoreTM(this.bestAlignmentA, this.bestAlignmentB, q, $, X);
      if (U > this.bestScore)
        this.bestScore = U, this.bestTransform = e.clone(q);
    }
    this.bestScore = this.scoreTM(this.bestAlignmentA, this.bestAlignmentB, this.bestTransform, $, X);
  }
  scoreTM(Z, J, $, X, Y) {
    let { xa: Q, ya: W } = this, K = X * X, G = 0;
    for (let H = 0;H < Z.length; H++) {
      let N = Z[H], q = J[H], U = M.create(W[q][0], W[q][1], W[q][2]);
      M.transformMat4(U, U, $);
      let F = U[0] - Q[N][0], E = U[1] - Q[N][1], R = U[2] - Q[N][2], z = F * F + E * E + R * R;
      G += 1 / (1 + z / K);
    }
    return G / Y;
  }
  refineWithCutoff(Z) {
    if (Z < 1)
      return;
    let { xa: J, ya: $, lenA: X, d0A: Y, d0Search: Q, scoreD8: W } = this, K = Z * Z;
    for (let G = 0;G < 10; G++) {
      if (this.bestAlignmentA.length < 3)
        break;
      let H = [], N = [];
      for (let A = 0;A < this.bestAlignmentA.length; A++) {
        let B = this.bestAlignmentA[A], T = this.bestAlignmentB[A], w = M.create($[T][0], $[T][1], $[T][2]);
        M.transformMat4(w, w, this.bestTransform);
        let V = w[0] - J[B][0], P = w[1] - J[B][1], I = w[2] - J[B][2];
        if (V * V + P * P + I * I <= K)
          H.push(J[B]), N.push($[T]);
      }
      if (H.length < 3)
        break;
      let q = this.kabsch(H, N), U = new Array(this.lenB);
      for (let A = 0;A < this.lenB; A++) {
        let B = M.create($[A][0], $[A][1], $[A][2]);
        M.transformMat4(B, B, q), U[A] = [B[0], B[1], B[2]];
      }
      let F = Q + 1;
      this.nwdpStructure(J, U, F * F, -0.6);
      let E = [], R = [];
      for (let A = 0;A < this.lenB; A++)
        if (this.j2i[A] >= 0)
          E.push(this.j2i[A]), R.push(A);
      if (E.length < 3)
        break;
      let z = this.trimmedKabsch(E, R, q, W), D = this.scoreTMWithCutoff(E, R, z, Y, X, W);
      if (D > this.bestScore)
        this.bestScore = D, this.bestAlignmentA = E, this.bestAlignmentB = R, this.bestTransform = z;
      else
        break;
    }
  }
  tryGaplessThreading() {
    let { xa: Z, ya: J, lenA: $, lenB: X, d0A: Y, scoreD8: Q } = this;
    for (let W = -X + 4;W <= $ - 4; W++) {
      let K = [], G = [];
      for (let F = 0;F < $; F++) {
        let E = F - W;
        if (E >= 0 && E < X)
          K.push(F), G.push(E);
      }
      if (K.length < 4)
        continue;
      let H = K.map((F) => Z[F]), N = G.map((F) => J[F]), q = this.kabsch(H, N);
      if (this.scoreTMWithCutoff(K, G, q, Y, $, Q) > this.bestScore * 0.8)
        this.extendFromSeed(q);
    }
  }
  tryFragmentInitializationMedium(Z) {
    let { xa: J, ya: $, lenA: X, lenB: Y, d0A: Q, scoreD8: W } = this, K = X - Z, G = Y - Z, H = Math.max(2, Math.floor(Z / 2));
    for (let N = 0;N <= K; N += H)
      for (let q = 0;q <= G; q += H) {
        let U = [], F = [];
        for (let A = 0;A < Z; A++)
          U.push(J[N + A]), F.push($[q + A]);
        let E = this.kabsch(U, F), R = [], z = [];
        for (let A = 0;A < Z; A++)
          R.push(N + A), z.push(q + A);
        if (this.scoreTMWithCutoff(R, z, E, Q, X, W) > this.bestScore * 0.3)
          this.extendFromSeed(E);
      }
  }
  tryFragmentInitializationFast(Z) {
    let { xa: J, ya: $, lenA: X, lenB: Y, d0A: Q, scoreD8: W } = this, K = X - Z, G = Y - Z, H = Math.max(Z, 10);
    for (let N = 0;N <= K; N += H)
      for (let q = 0;q <= G; q += H) {
        let U = [], F = [];
        for (let A = 0;A < Z; A++)
          U.push(J[N + A]), F.push($[q + A]);
        let E = this.kabsch(U, F), R = [], z = [];
        for (let A = 0;A < Z; A++)
          R.push(N + A), z.push(q + A);
        if (this.scoreTMWithCutoff(R, z, E, Q, X, W) > this.bestScore * 0.5)
          this.extendFromSeed(E);
      }
  }
  getInitialAlignment() {
    let { xa: Z, ya: J, lenA: $, lenB: X, d0Search: Y } = this, Q = Y * Y, W = new Array($ + 1);
    for (let K = 0;K <= $; K++)
      W[K] = new Array(X + 1).fill(0);
    for (let K = 1;K <= $; K++)
      for (let G = 1;G <= X; G++) {
        let H = Z[K - 1][0] - J[G - 1][0], N = Z[K - 1][1] - J[G - 1][1], q = Z[K - 1][2] - J[G - 1][2], U = H * H + N * N + q * q;
        W[K][G] = 1 / (1 + U / Q);
      }
    this.nwdpScore(W, -0.6);
  }
  extendFromSeed(Z) {
    let { xa: J, ya: $, lenA: X, lenB: Y, d0A: Q, d0Search: W, scoreD8: K } = this, G = Z, H = [], N = [], q = -1;
    for (let U = 0;U < 20; U++) {
      let F = new Array(Y);
      for (let B = 0;B < Y; B++) {
        let T = M.create($[B][0], $[B][1], $[B][2]);
        M.transformMat4(T, T, G), F[B] = [T[0], T[1], T[2]];
      }
      let E = W + 1;
      this.nwdpStructure(J, F, E * E, -0.6);
      let R = [], z = [];
      for (let B = 0;B < Y; B++)
        if (this.j2i[B] >= 0)
          R.push(this.j2i[B]), z.push(B);
      if (R.length < 3)
        break;
      if (this.alignmentsEqual(R, z, H, N))
        break;
      let D = this.trimmedKabsch(R, z, G, K), A = this.scoreTMWithCutoff(R, z, D, Q, X, K);
      if (H = R, N = z, G = D, A <= q)
        break;
      if (q = A, A > this.bestScore)
        this.bestScore = A, this.bestAlignmentA = R.slice(), this.bestAlignmentB = z.slice(), this.bestTransform = e.clone(D);
    }
  }
  trimmedKabsch(Z, J, $, X) {
    let { xa: Y, ya: Q } = this, W = X * X, K = [], G = [];
    for (let H = 0;H < Z.length; H++) {
      let N = Z[H], q = J[H], U = M.create(Q[q][0], Q[q][1], Q[q][2]);
      M.transformMat4(U, U, $);
      let F = U[0] - Y[N][0], E = U[1] - Y[N][1], R = U[2] - Y[N][2];
      if (F * F + E * E + R * R <= W)
        K.push(Y[N]), G.push(Q[q]);
    }
    if (K.length < 3) {
      let H = Z.map((q) => Y[q]), N = J.map((q) => Q[q]);
      return this.kabsch(H, N);
    }
    return this.kabsch(K, G);
  }
  refineAlignment() {
    let { xa: Z, ya: J, lenA: $, d0A: X, d0Search: Y, scoreD8: Q } = this, W = 20;
    for (let K = 0;K < 20; K++) {
      if (this.bestAlignmentA.length < 3)
        break;
      let G = this.trimmedKabsch(this.bestAlignmentA, this.bestAlignmentB, this.bestTransform, Q), H = new Array(this.lenB);
      for (let D = 0;D < this.lenB; D++) {
        let A = M.create(J[D][0], J[D][1], J[D][2]);
        M.transformMat4(A, A, G), H[D] = [A[0], A[1], A[2]];
      }
      let N = Y + 1;
      this.nwdpStructure(Z, H, N * N, -0.6);
      let q = [], U = [];
      for (let D = 0;D < this.lenB; D++)
        if (this.j2i[D] >= 0)
          q.push(this.j2i[D]), U.push(D);
      if (q.length < 3)
        break;
      if (this.alignmentsEqual(q, U, this.bestAlignmentA, this.bestAlignmentB))
        break;
      let F = q.map((D) => Z[D]), E = U.map((D) => J[D]), R = this.kabsch(F, E), z = this.scoreTMWithCutoff(q, U, R, X, $, Q);
      if (z > this.bestScore)
        this.bestScore = z, this.bestAlignmentA = q, this.bestAlignmentB = U, this.bestTransform = R;
    }
  }
  alignmentsEqual(Z, J, $, X) {
    if (Z.length !== $.length)
      return !1;
    for (let Y = 0;Y < Z.length; Y++)
      if (Z[Y] !== $[Y] || J[Y] !== X[Y])
        return !1;
    return !0;
  }
  scoreTMWithCutoff(Z, J, $, X, Y, Q) {
    let { xa: W, ya: K } = this, G = X * X, H = Q * Q, N = 0;
    for (let q = 0;q < Z.length; q++) {
      let U = Z[q], F = J[q], E = M.create(K[F][0], K[F][1], K[F][2]);
      M.transformMat4(E, E, $);
      let R = E[0] - W[U][0], z = E[1] - W[U][1], D = E[2] - W[U][2], A = R * R + z * z + D * D;
      if (A <= H)
        N += 1 / (1 + A / G);
    }
    return N / Y;
  }
  nwdpScore(Z, J) {
    let { lenA: $, lenB: X, dpPath: Y, dpVal: Q, j2i: W } = this;
    for (let H = 0;H <= $; H++)
      Q[H][0] = 0, Y[H][0] = !1;
    for (let H = 0;H <= X; H++)
      Q[0][H] = 0, Y[0][H] = !1, W[H] = -1;
    for (let H = 1;H <= $; H++)
      for (let N = 1;N <= X; N++) {
        let q = Q[H - 1][N - 1] + Z[H][N], U = Q[H - 1][N];
        if (Y[H - 1][N])
          U += J;
        let F = Q[H][N - 1];
        if (Y[H][N - 1])
          F += J;
        if (q >= U && q >= F)
          Y[H][N] = !0, Q[H][N] = q;
        else
          Y[H][N] = !1, Q[H][N] = F >= U ? F : U;
      }
    let K = $, G = X;
    while (K > 0 && G > 0)
      if (Y[K][G])
        W[G - 1] = K - 1, K--, G--;
      else {
        let H = Q[K - 1][G];
        if (Y[K - 1][G])
          H += J;
        let N = Q[K][G - 1];
        if (Y[K][G - 1])
          N += J;
        if (N >= H)
          G--;
        else
          K--;
      }
    this.bestAlignmentA = [], this.bestAlignmentB = [];
    for (let H = 0;H < X; H++)
      if (W[H] >= 0)
        this.bestAlignmentA.push(W[H]), this.bestAlignmentB.push(H);
    if (this.bestAlignmentA.length >= 3) {
      let H = this.bestAlignmentA.map((q) => this.xa[q]), N = this.bestAlignmentB.map((q) => this.ya[q]);
      this.bestTransform = this.kabsch(H, N), this.bestScore = this.scoreTMWithCutoff(this.bestAlignmentA, this.bestAlignmentB, this.bestTransform, this.d0A, this.lenA, this.scoreD8);
    }
  }
  nwdpStructure(Z, J, $, X) {
    let { lenA: Y, lenB: Q, dpPath: W, dpVal: K, j2i: G } = this;
    for (let q = 0;q <= Y; q++)
      K[q][0] = 0, W[q][0] = !1;
    for (let q = 0;q <= Q; q++)
      K[0][q] = 0, W[0][q] = !1, G[q] = -1;
    for (let q = 1;q <= Y; q++)
      for (let U = 1;U <= Q; U++) {
        let F = Z[q - 1][0] - J[U - 1][0], E = Z[q - 1][1] - J[U - 1][1], R = Z[q - 1][2] - J[U - 1][2], z = F * F + E * E + R * R, D = K[q - 1][U - 1] + 1 / (1 + z / $), A = K[q - 1][U];
        if (W[q - 1][U])
          A += X;
        let B = K[q][U - 1];
        if (W[q][U - 1])
          B += X;
        if (D >= A && D >= B)
          W[q][U] = !0, K[q][U] = D;
        else
          W[q][U] = !1, K[q][U] = B >= A ? B : A;
      }
    let H = Y, N = Q;
    while (H > 0 && N > 0)
      if (W[H][N])
        G[N - 1] = H - 1, H--, N--;
      else {
        let q = K[H - 1][N];
        if (W[H - 1][N])
          q += X;
        let U = K[H][N - 1];
        if (W[H][N - 1])
          U += X;
        if (U >= q)
          N--;
        else
          H--;
      }
  }
  kabsch(Z, J) {
    let $ = Z.length;
    if ($ < 3)
      return e.identity();
    let X = WW.Positions.empty($), Y = WW.Positions.empty($);
    for (let W = 0;W < $; W++)
      X.x[W] = Z[W][0], X.y[W] = Z[W][1], X.z[W] = Z[W][2], Y.x[W] = J[W][0], Y.y[W] = J[W][1], Y.z[W] = J[W][2];
    return WW.compute({ a: X, b: Y }).bTransform;
  }
  getBestAlignment() {
    return {
      alignmentA: this.bestAlignmentA,
      alignmentB: this.bestAlignmentB,
      transform: this.bestTransform
    };
  }
}

// node_modules/molstar/lib/mol-model/structure/structure/util/tm-align.js
function kk0(Z, J) {
  let $ = W0.Loci.size(Z), X = W0.Loci.size(J);
  if ($ === 0 || X === 0)
    return {
      bTransform: e.identity(),
      tmScoreA: 0,
      tmScoreB: 0,
      rmsd: 0,
      alignedLength: 0,
      sequenceIdentity: 0,
      alignmentA: [],
      alignmentB: []
    };
  let Y = IE(Z, $), Q = IE(J, X);
  return Rg.compute({ a: Y, b: Q });
}

// node_modules/molstar/lib/mol-plugin-ui/structure/superposition.js
class m20 extends y5 {
  defaultState() {
    return {
      isCollapsed: !1,
      header: "Superposition",
      brand: { accent: "gray", svg: rV0 },
      isHidden: !0
    };
  }
  componentDidMount() {
    this.subscribe(this.plugin.managers.structure.hierarchy.behaviors.selection, (Z) => {
      this.setState({ isHidden: Z.structures.length < 2 });
    });
  }
  renderControls() {
    return H6.jsx(H6.Fragment, { children: H6.jsx(Sk0, {}) });
  }
}
var vk0 = {
  alignSequences: j.Boolean(!0, { isEssential: !0, description: "For Chain-based 3D superposition, perform a sequence alignment and use the aligned residue pairs to guide the 3D superposition." }),
  traceOnly: j.Boolean(!0, { description: "For Chain- and Uniprot-based 3D superposition, base superposition only on CA (and equivalent) atoms." })
}, VA1 = j.getDefaultValues(vk0), IA1 = "SuperpositionTransform";

class Sk0 extends N7 {
  constructor() {
    super(...arguments);
    this.state = {
      isBusy: !1,
      canUseDb: !1,
      action: void 0,
      options: VA1
    }, this.superposeChains = async () => {
      var Z, J, $;
      let { query: X } = this.state.options.traceOnly ? u9.trace : u9.polymer, Y = this.chainEntries, Q = Y.map((N) => {
        let q = W0.Loci.toStructure(N.loci), U = f1.toLociWithSourceUnits(X(new C9(q)));
        return W0.Loci.remap(U, this.getRootStructure(N.loci.structure));
      }), W = this.plugin.managers.structure.hierarchy.findStructure((Z = Q[0]) === null || Z === void 0 ? void 0 : Z.structure), K = ($ = (J = W === null || W === void 0 ? void 0 : W.transform) === null || J === void 0 ? void 0 : J.cell.obj) === null || $ === void 0 ? void 0 : $.data.coordinateSystem, G = this.state.options.alignSequences ? Ik0(Q) : g20(Q), H = Y[0];
      for (let N = 1, q = Q.length;N < q; ++N) {
        let U = Y[N], { bTransform: F, rmsd: E } = G[N - 1];
        await this.transform(U.cell, F, K);
        let R = MK(H.label), z = MK(U.label);
        this.plugin.log.info(`Superposed [${R}] and [${z}] with RMSD ${E.toFixed(2)}.`);
      }
      await this.cameraReset();
    }, this.superposeAtoms = async () => {
      var Z, J, $;
      let X = this.atomEntries, Y = X.map((H) => {
        return W0.Loci.remap(H.loci, this.getRootStructure(H.loci.structure));
      }), Q = g20(Y), W = this.plugin.managers.structure.hierarchy.findStructure((Z = Y[0]) === null || Z === void 0 ? void 0 : Z.structure), K = ($ = (J = W === null || W === void 0 ? void 0 : W.transform) === null || J === void 0 ? void 0 : J.cell.obj) === null || $ === void 0 ? void 0 : $.data.coordinateSystem, G = X[0];
      for (let H = 1, N = Y.length;H < N; ++H) {
        let q = X[H], { bTransform: U, rmsd: F } = Q[H - 1];
        await this.transform(q.cell, U, K);
        let E = MK(G.label), R = MK(q.label), z = X[H].atoms.length;
        this.plugin.log.info(`Superposed ${z} ${z === 1 ? "atom" : "atoms"} of [${E}] and [${R}] with RMSD ${F.toFixed(2)}.`);
      }
      await this.cameraReset();
    }, this.superposeDb = async () => {
      var Z, J, $;
      let X = this.plugin.managers.structure.hierarchy.behaviors.selection.value.structures, Y = this.state.options.traceOnly, Q = X.map((U) => {
        var F;
        return (F = U.cell.obj) === null || F === void 0 ? void 0 : F.data;
      }), { entries: W, failedPairs: K, zeroOverlapPairs: G } = Pk0(Q, { traceOnly: Y }), H = ($ = (J = (Z = X[0]) === null || Z === void 0 ? void 0 : Z.transform) === null || J === void 0 ? void 0 : J.cell.obj) === null || $ === void 0 ? void 0 : $.data.coordinateSystem, N = 0;
      for (let U of W)
        await this.transform(X[U.other].cell, U.transform.bTransform, H), N += U.transform.rmsd;
      N /= Math.max(W.length - 1, 1);
      let q = (U) => {
        return `[${U.map(([F, E]) => `(${Q[F].models[0].entryId}, ${Q[E].models[0].entryId})`).join(", ")}]`;
      };
      if (G.length)
        this.plugin.log.warn(`Superposition: No UNIPROT mapping overlap between structures ${q(G)}.`);
      if (K.length)
        this.plugin.log.error(`Superposition: Failed to superpose structures ${q(K)}.`);
      if (W.length)
        this.plugin.log.info(`Superposed ${W.length + 1} structures with avg. RMSD ${N.toFixed(2)} Å.`), await this.cameraReset();
    }, this.superposeTMAlign = async () => {
      var Z, J, $;
      let { query: X } = this.state.options.traceOnly ? u9.trace : u9.polymer, Y = this.chainEntries, Q = Y.map((H) => {
        let N = W0.Loci.toStructure(H.loci), q = f1.toLociWithSourceUnits(X(new C9(N)));
        return W0.Loci.remap(q, this.getRootStructure(H.loci.structure));
      }), W = this.plugin.managers.structure.hierarchy.findStructure((Z = Q[0]) === null || Z === void 0 ? void 0 : Z.structure), K = ($ = (J = W === null || W === void 0 ? void 0 : W.transform) === null || J === void 0 ? void 0 : J.cell.obj) === null || $ === void 0 ? void 0 : $.data.coordinateSystem, G = Y[0];
      for (let H = 1, N = Q.length;H < N; ++H) {
        let q = Y[H], U = kk0(Q[0], Q[H]), { bTransform: F, tmScoreA: E, tmScoreB: R, rmsd: z, alignedLength: D } = U;
        await this.transform(q.cell, F, K);
        let A = MK(G.label), B = MK(q.label);
        this.plugin.log.info(`TM-align [${A}] and [${B}]: TM-score=${E.toFixed(4)}/${R.toFixed(4)}, RMSD=${z.toFixed(2)} Å, aligned ${D} residues.`);
      }
      await this.cameraReset();
    }, this.toggleByChains = () => this.setState({ action: this.state.action === "byChains" ? void 0 : "byChains" }), this.toggleByAtoms = () => this.setState({ action: this.state.action === "byAtoms" ? void 0 : "byAtoms" }), this.toggleByTMAlign = () => this.setState({ action: this.state.action === "byTMAlign" ? void 0 : "byTMAlign" }), this.toggleOptions = () => this.setState({ action: this.state.action === "options" ? void 0 : "options" }), this.setOptions = (Z) => {
      this.setState({ options: Z });
    };
  }
  componentDidMount() {
    this.subscribe(this.selection.events.changed, () => {
      this.forceUpdate();
    }), this.subscribe(this.selection.events.additionsHistoryUpdated, () => {
      this.forceUpdate();
    }), this.subscribe(this.plugin.behaviors.state.isBusy, (Z) => {
      this.setState({ isBusy: Z });
    }), this.subscribe(this.plugin.managers.structure.hierarchy.behaviors.selection, (Z) => {
      this.setState({ canUseDb: Z.structures.every((J) => {
        var $;
        return !!(($ = J.cell.obj) === null || $ === void 0 ? void 0 : $.data) && J.cell.obj.data.models.some((X) => pQ.Provider.isApplicable(X));
      }) });
    });
  }
  get selection() {
    return this.plugin.managers.structure.selection;
  }
  async transform(Z, J, $) {
    let X = X7.resolveAndCheck(this.plugin.state.data, Z);
    if (!X)
      return;
    let Y = this.plugin.state.data.selectQ((G) => G.byRef(X.transform.ref).subtree().withTransformer(H1.Model.TransformStructureConformation))[0], W = {
      transform: {
        name: "matrix",
        params: { data: $ && !e.isIdentity($.matrix) ? e.mul(e(), $.matrix, J) : J, transpose: !1 }
      }
    }, K = Y ? this.plugin.state.data.build().to(Y).update(W) : this.plugin.state.data.build().to(Z).insert(H1.Model.TransformStructureConformation, W, { tags: IA1 });
    await this.plugin.runTask(this.plugin.state.data.updateTree(K));
  }
  getRootStructure(Z) {
    var J;
    let $ = this.plugin.helpers.substructureParent.get(Z);
    return (J = this.plugin.state.data.selectQ((X) => X.byValue($).rootOfType(D0.Molecule.Structure))[0].obj) === null || J === void 0 ? void 0 : J.data;
  }
  async cameraReset() {
    await new Promise((Z) => requestAnimationFrame(Z)), h1.Camera.Reset(this.plugin);
  }
  highlight(Z) {
    this.plugin.managers.interactivity.lociHighlights.highlightOnly({ loci: Z }, !1);
  }
  moveHistory(Z, J) {
    this.plugin.managers.structure.selection.modifyHistory(Z, J, void 0, !0);
  }
  focusLoci(Z) {
    this.plugin.managers.camera.focusLoci(Z);
  }
  lociEntry(Z, J) {
    return H6.jsx("div", { className: "msp-flex-row", children: H6.jsx(Z8, { noOverflow: !0, title: "Click to focus. Hover to highlight.", onClick: () => this.focusLoci(Z.loci), style: { width: "auto", textAlign: "left" }, onMouseEnter: () => this.highlight(Z.loci), onMouseLeave: () => this.plugin.managers.interactivity.lociHighlights.clearHighlights(), children: H6.jsx("span", { dangerouslySetInnerHTML: { __html: Z.label } }) }) }, J);
  }
  historyEntry(Z, J) {
    let $ = this.plugin.managers.structure.selection.additionsHistory;
    return H6.jsxs("div", { className: "msp-flex-row", children: [H6.jsxs(Z8, { noOverflow: !0, title: "Click to focus. Hover to highlight.", onClick: () => this.focusLoci(Z.loci), style: { width: "auto", textAlign: "left" }, onMouseEnter: () => this.highlight(Z.loci), onMouseLeave: () => this.plugin.managers.interactivity.lociHighlights.clearHighlights(), children: [J, ". ", H6.jsx("span", { dangerouslySetInnerHTML: { __html: Z.label } })] }), $.length > 1 && H6.jsx(o2, { svg: DE, small: !0, className: "msp-form-control", onClick: () => this.moveHistory(Z, "up"), flex: "20px", title: "Move up" }), $.length > 1 && H6.jsx(o2, { svg: zE, small: !0, className: "msp-form-control", onClick: () => this.moveHistory(Z, "down"), flex: "20px", title: "Move down" }), H6.jsx(o2, { svg: GX, small: !0, className: "msp-form-control", onClick: () => this.plugin.managers.structure.selection.modifyHistory(Z, "remove"), flex: !0, title: "Remove" })] }, Z.id);
  }
  atomsLociEntry(Z, J) {
    return H6.jsxs("div", { children: [H6.jsx("div", { className: "msp-control-group-header", children: H6.jsx("div", { className: "msp-no-overflow", title: Z.label, children: Z.label }) }), H6.jsx("div", { className: "msp-control-offset", children: Z.atoms.map(($, X) => this.historyEntry($, X)) })] }, J);
  }
  get chainEntries() {
    let Z = W0.Location.create(), J = [];
    return this.plugin.managers.structure.selection.entries.forEach(({ selection: $ }, X) => {
      let Y = X7.resolveAndCheck(this.plugin.state.data, X);
      if (!Y || W0.Loci.isEmpty($))
        return;
      let Q = W0.Loci.getFirstLocation($, Z);
      if ($.elements.length > 1 || w1.entity.type(Q) !== "polymer")
        return;
      let W = W0.Stats.ofLoci($), K = kz(W, { countsOnly: !0 }), G = SK(Q, { reverse: !0, granularity: "chain" }).split("|"), H = `${K} | ${G[0]} | ${G[G.length - 1]}`;
      J.push({ loci: $, label: H, cell: Y });
    }), J;
  }
  get atomEntries() {
    let Z = /* @__PURE__ */ new Map, J = this.plugin.managers.structure.selection.additionsHistory;
    for (let X = 0, Y = J.length;X < Y; ++X) {
      let Q = J[X];
      if (W0.Loci.size(Q.loci) !== 1)
        continue;
      let W = Q.loci.structure;
      if (Z.has(W))
        Z.get(W).push(Q);
      else
        Z.set(W, [Q]);
    }
    let $ = [];
    return Z.forEach((X, Y) => {
      let Q = this.plugin.helpers.substructureParent.get(Y), W = [];
      for (let H = 0, N = X.length;H < N; ++H)
        W.push(X[H].loci.elements[0]);
      let K = W0.Loci(X[0].loci.structure, W), G = K.structure.label.split(" | ")[0];
      $.push({ loci: K, label: G, cell: Q, atoms: X });
    }), $;
  }
  toggleHint() {
    return this.plugin.config.get(W8.Viewport.ShowSelectionMode) ? H6.jsxs(H6.Fragment, { children: [" ", "(toggle ", H6.jsx(q4, { inline: !0 }), " mode)"] }) : null;
  }
  addByChains() {
    let Z = this.chainEntries;
    return H6.jsxs(H6.Fragment, { children: [Z.length > 0 && H6.jsx("div", { className: "msp-control-offset", children: Z.map((J, $) => this.lociEntry(J, $)) }), Z.length < 2 && H6.jsx("div", { className: "msp-control-offset msp-help-text", children: H6.jsxs("div", { className: "msp-help-description", children: [H6.jsx(b6, { svg: OQ, inline: !0 }), "Add 2 or more selections", this.toggleHint(), " from separate structures. Selections must be limited to single polymer chains or residues therein."] }) }), Z.length > 1 && H6.jsx(Z8, { title: "Superpose structures by selected chains.", className: "msp-btn-commit msp-btn-commit-on", onClick: this.superposeChains, style: { marginTop: "1px" }, children: "Superpose" })] });
  }
  addByAtoms() {
    let Z = this.atomEntries;
    return H6.jsxs(H6.Fragment, { children: [Z.length > 0 && H6.jsx("div", { className: "msp-control-offset", children: Z.map((J, $) => this.atomsLociEntry(J, $)) }), Z.length < 2 && H6.jsx("div", { className: "msp-control-offset msp-help-text", children: H6.jsxs("div", { className: "msp-help-description", children: [H6.jsx(b6, { svg: OQ, inline: !0 }), "Add 1 or more selections", this.toggleHint(), " from separate structures. Selections must be limited to single atoms."] }) }), Z.length > 1 && H6.jsx(Z8, { title: "Superpose structures by selected atoms.", className: "msp-btn-commit msp-btn-commit-on", onClick: this.superposeAtoms, style: { marginTop: "1px" }, children: "Superpose" })] });
  }
  addByTMAlign() {
    let Z = this.chainEntries;
    return H6.jsxs(H6.Fragment, { children: [Z.length > 0 && H6.jsx("div", { className: "msp-control-offset", children: Z.map((J, $) => this.lociEntry(J, $)) }), Z.length < 2 && H6.jsx("div", { className: "msp-control-offset msp-help-text", children: H6.jsxs("div", { className: "msp-help-description", children: [H6.jsx(b6, { svg: OQ, inline: !0 }), "Add 2 or more selections", this.toggleHint(), " from separate structures. Selections must be limited to single polymer chains. TM-align performs structure-based alignment independent of sequence."] }) }), Z.length > 1 && H6.jsx(Z8, { title: "Superpose structures using TM-align (structure-based alignment).", className: "msp-btn-commit msp-btn-commit-on", onClick: this.superposeTMAlign, style: { marginTop: "1px" }, children: "TM-align Superpose" })] });
  }
  superposeByDbMapping() {
    return H6.jsx(H6.Fragment, { children: H6.jsx(Z8, { icon: Ey, title: "Superpose structures using intersection of residues from SIFTS UNIPROT mapping.", className: "msp-btn msp-btn-block", onClick: this.superposeDb, style: { marginTop: "1px" }, disabled: this.state.isBusy, children: "Uniprot" }) });
  }
  render() {
    return H6.jsxs(H6.Fragment, { children: [H6.jsxs("div", { className: "msp-flex-row", children: [H6.jsx(D7, { icon: Ey, label: "Chains", toggle: this.toggleByChains, isSelected: this.state.action === "byChains", disabled: this.state.isBusy }), H6.jsx(D7, { icon: aV0, label: "Atoms", toggle: this.toggleByAtoms, isSelected: this.state.action === "byAtoms", disabled: this.state.isBusy }), H6.jsx(D7, { icon: Ey, label: "TM-align", toggle: this.toggleByTMAlign, isSelected: this.state.action === "byTMAlign", disabled: this.state.isBusy }), this.state.canUseDb && this.superposeByDbMapping(), H6.jsx(D7, { icon: lX, label: "", title: "Options", toggle: this.toggleOptions, isSelected: this.state.action === "options", disabled: this.state.isBusy, style: { flex: "0 0 40px", padding: 0 } })] }), this.state.action === "byChains" && this.addByChains(), this.state.action === "byAtoms" && this.addByAtoms(), this.state.action === "byTMAlign" && this.addByTMAlign(), this.state.action === "options" && H6.jsx("div", { className: "msp-control-offset", children: H6.jsx(iZ, { params: vk0, values: this.state.options, onChangeValues: this.setOptions, isDisabled: this.state.isBusy }) })] });
  }
}

// node_modules/molstar/lib/mol-plugin-ui/structure/quick-styles.js
var j$ = t2(PZ(), 1);
class d20 extends y5 {
  defaultState() {
    return {
      isCollapsed: !1,
      header: "Quick Styles",
      brand: { accent: "gray", svg: _V0 }
    };
  }
  renderControls() {
    return j$.jsx(j$.Fragment, { children: j$.jsx(bk0, {}) });
  }
}

class bk0 extends N7 {
  constructor() {
    super(...arguments);
    this.state = { busy: !1, style: "default" };
  }
  async applyRepresentation(Z) {
    this.setState({ busy: !0 }), await PA1(this.plugin, Z), await hk0(this.plugin, this.state.style), this.setState({ busy: !1 });
  }
  async applyStyle(Z) {
    this.setState({ busy: !0 }), await hk0(this.plugin, Z), this.setState({ busy: !1, style: Z });
  }
  render() {
    return j$.jsxs(j$.Fragment, { children: [j$.jsx(fk0, { title: "Apply Representation", children: j$.jsxs("div", { className: "msp-flex-row", children: [j$.jsx(Z8, { title: "Applies default representation preset (depends on structure size)", onClick: () => this.applyRepresentation("default"), disabled: this.state.busy, children: "Default" }), j$.jsx(Z8, { title: "Applies cartoon polymer and ball-and-stick ligand representation preset", onClick: () => this.applyRepresentation("cartoon"), disabled: this.state.busy, children: "Cartoon" }), j$.jsx(Z8, { title: "Applies spacefill representation preset", onClick: () => this.applyRepresentation("spacefill"), disabled: this.state.busy, children: "Spacefill" }), j$.jsx(Z8, { title: "Applies molecular surface representation preset", onClick: () => this.applyRepresentation("surface"), disabled: this.state.busy, children: "Surface" })] }) }), j$.jsx(fk0, { title: "Apply Style", children: j$.jsxs("div", { className: "msp-flex-row", children: [j$.jsx(Z8, { title: "Applies default appearance (no outline, no ignore-light)", onClick: () => this.applyStyle("default"), disabled: this.state.busy, children: "Default" }), j$.jsx(Z8, { title: "Applies illustrative appearance (outline, ignore-light)", onClick: () => this.applyStyle("illustrative"), disabled: this.state.busy, children: "Illustrative" })] }) })] });
  }
}
function fk0(Z) {
  return j$.jsxs("div", { className: "msp-control-group-wrapper", children: [j$.jsx("div", { className: "msp-control-group-header", children: j$.jsx("div", { children: j$.jsx("b", { children: Z.title }) }) }), Z.children] });
}
async function PA1(Z, J) {
  let { structures: $ } = Z.managers.structure.hierarchy.selection;
  switch (J) {
    case "default":
      let X = Z.config.get(W8.Structure.DefaultRepresentationPreset) || hY.auto.id, Y = Z.builders.structure.representation.resolveProvider(X);
      await Z.managers.structure.component.applyPreset($, Y);
      break;
    case "spacefill":
      await Z.managers.structure.component.applyPreset($, hY.illustrative);
      break;
    case "cartoon":
      await Z.managers.structure.component.applyPreset($, hY["polymer-and-ligand"]);
      break;
    case "surface":
      await Z.managers.structure.component.applyPreset($, hY["molecular-surface"]);
      break;
  }
}
async function hk0(Z, J) {
  if (J === "default") {
    if (await Z.managers.structure.component.setOptions({ ...Z.managers.structure.component.state.options, ignoreLight: !1 }), Z.canvas3d) {
      let $ = j.getDefaultValues(rA);
      Z.canvas3d.setProps({
        postprocessing: { outline: $.outline, occlusion: $.occlusion, shadow: $.shadow }
      });
    }
  }
  if (J === "illustrative") {
    if (await Z.managers.structure.component.setOptions({ ...Z.managers.structure.component.state.options, ignoreLight: !0 }), Z.canvas3d) {
      let $ = Z.canvas3d.props.postprocessing;
      Z.canvas3d.setProps({
        postprocessing: {
          outline: {
            name: "on",
            params: $.outline.name === "on" ? $.outline.params : {
              scale: 1,
              color: i0(0),
              threshold: 0.33,
              includeTransparent: !0
            }
          },
          occlusion: {
            name: "on",
            params: $.occlusion.name === "on" ? $.occlusion.params : {
              multiScale: { name: "off", params: {} },
              radius: 5,
              bias: 0.8,
              blurKernelSize: 15,
              blurDepthBias: 0.5,
              samples: 32,
              resolutionScale: 1,
              color: i0(0),
              transparentThreshold: 0.4
            }
          },
          shadow: { name: "off", params: {} }
        }
      });
    }
  }
}

// node_modules/molstar/lib/mol-plugin-ui/controls/markdown.js
var aW = t2(PZ(), 1), gH = t2(J7(), 1);

// node_modules/ccount/index.js
function p20(Z, J) {
  let $ = String(Z);
  if (typeof J !== "string")
    throw new TypeError("Expected character");
  let X = 0, Y = $.indexOf(J);
  while (Y !== -1)
    X++, Y = $.indexOf(J, Y + J.length);
  return X;
}

// node_modules/mdast-util-find-and-replace/node_modules/escape-string-regexp/index.js
function u20(Z) {
  if (typeof Z !== "string")
    throw new TypeError("Expected a string");
  return Z.replace(/[|\\{}()[\]^$+*?.]/g, "\\$&").replace(/-/g, "\\x2d");
}

// node_modules/mdast-util-find-and-replace/lib/index.js
function c20(Z, J, $) {
  let Y = VE(($ || {}).ignore || []), Q = CA1(J), W = -1;
  while (++W < Q.length)
    eI(Z, "text", K);
  function K(H, N) {
    let q = -1, U;
    while (++q < N.length) {
      let F = N[q], E = U ? U.children : void 0;
      if (Y(F, E ? E.indexOf(F) : void 0, U))
        return;
      U = F;
    }
    if (U)
      return G(H, N);
  }
  function G(H, N) {
    let q = N[N.length - 1], U = Q[W][0], F = Q[W][1], E = 0, z = q.children.indexOf(H), D = !1, A = [];
    U.lastIndex = 0;
    let B = U.exec(H.value);
    while (B) {
      let T = B.index, w = {
        index: B.index,
        input: B.input,
        stack: [...N, H]
      }, V = F(...B, w);
      if (typeof V === "string")
        V = V.length > 0 ? { type: "text", value: V } : void 0;
      if (V === !1)
        U.lastIndex = T + 1;
      else {
        if (E !== T)
          A.push({
            type: "text",
            value: H.value.slice(E, T)
          });
        if (Array.isArray(V))
          A.push(...V);
        else if (V)
          A.push(V);
        E = T + B[0].length, D = !0;
      }
      if (!U.global)
        break;
      B = U.exec(H.value);
    }
    if (D) {
      if (E < H.value.length)
        A.push({ type: "text", value: H.value.slice(E) });
      q.children.splice(z, 1, ...A);
    } else
      A = [H];
    return z + A.length;
  }
}
function CA1(Z) {
  let J = [];
  if (!Array.isArray(Z))
    throw new TypeError("Expected find and replace tuple or list of tuples");
  let $ = !Z[0] || Array.isArray(Z[0]) ? Z : [Z], X = -1;
  while (++X < $.length) {
    let Y = $[X];
    J.push([kA1(Y[0]), vA1(Y[1])]);
  }
  return J;
}
function kA1(Z) {
  return typeof Z === "string" ? new RegExp(u20(Z), "g") : Z;
}
function vA1(Z) {
  return typeof Z === "function" ? Z : function() {
    return Z;
  };
}
// node_modules/mdast-util-gfm-autolink-literal/lib/index.js
var l20 = "phrasing", n20 = ["autolink", "link", "image", "label"];
function o20() {
  return {
    transforms: [yA1],
    enter: {
      literalAutolink: SA1,
      literalAutolinkEmail: i20,
      literalAutolinkHttp: i20,
      literalAutolinkWww: i20
    },
    exit: {
      literalAutolink: xA1,
      literalAutolinkEmail: bA1,
      literalAutolinkHttp: fA1,
      literalAutolinkWww: hA1
    }
  };
}
function s20() {
  return {
    unsafe: [
      {
        character: "@",
        before: "[+\\-.\\w]",
        after: "[\\-.\\w]",
        inConstruct: l20,
        notInConstruct: n20
      },
      {
        character: ".",
        before: "[Ww]",
        after: "[\\-.\\w]",
        inConstruct: l20,
        notInConstruct: n20
      },
      {
        character: ":",
        before: "[ps]",
        after: "\\/",
        inConstruct: l20,
        notInConstruct: n20
      }
    ]
  };
}
function SA1(Z) {
  this.enter({ type: "link", title: null, url: "", children: [] }, Z);
}
function i20(Z) {
  this.config.enter.autolinkProtocol.call(this, Z);
}
function fA1(Z) {
  this.config.exit.autolinkProtocol.call(this, Z);
}
function hA1(Z) {
  this.config.exit.data.call(this, Z);
  let J = this.stack[this.stack.length - 1];
  t0(J.type === "link"), J.url = "http://" + this.sliceSerialize(Z);
}
function bA1(Z) {
  this.config.exit.autolinkEmail.call(this, Z);
}
function xA1(Z) {
  this.exit(Z);
}
function yA1(Z) {
  c20(Z, [
    [/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi, gA1],
    [/(?<=^|\s|\p{P}|\p{S})([-.\w+]+)@([-\w]+(?:\.[-\w]+)+)/gu, mA1]
  ], { ignore: ["link", "linkReference"] });
}
function gA1(Z, J, $, X, Y) {
  let Q = "";
  if (!xk0(Y))
    return !1;
  if (/^w/i.test(J))
    $ = J + $, J = "", Q = "http://";
  if (!dA1($))
    return !1;
  let W = pA1($ + X);
  if (!W[0])
    return !1;
  let K = {
    type: "link",
    title: null,
    url: Q + J + W[0],
    children: [{ type: "text", value: J + W[0] }]
  };
  if (W[1])
    return [K, { type: "text", value: W[1] }];
  return K;
}
function mA1(Z, J, $, X) {
  if (!xk0(X, !0) || /[-\d_]$/.test($))
    return !1;
  return {
    type: "link",
    title: null,
    url: "mailto:" + J + "@" + $,
    children: [{ type: "text", value: J + "@" + $ }]
  };
}
function dA1(Z) {
  let J = Z.split(".");
  if (J.length < 2 || J[J.length - 1] && (/_/.test(J[J.length - 1]) || !/[a-zA-Z\d]/.test(J[J.length - 1])) || J[J.length - 2] && (/_/.test(J[J.length - 2]) || !/[a-zA-Z\d]/.test(J[J.length - 2])))
    return !1;
  return !0;
}
function pA1(Z) {
  let J = /[!"&'),.:;<>?\]}]+$/.exec(Z);
  if (!J)
    return [Z, void 0];
  Z = Z.slice(0, J.index);
  let $ = J[0], X = $.indexOf(")"), Y = p20(Z, "("), Q = p20(Z, ")");
  while (X !== -1 && Y > Q)
    Z += $.slice(0, X + 1), $ = $.slice(X + 1), X = $.indexOf(")"), Q++;
  return [Z, $];
}
function xk0(Z, J) {
  let $ = Z.input.charCodeAt(Z.index - 1);
  return (Z.index === 0 || Pq($) || J4($)) && (!J || $ !== 47);
}
// node_modules/mdast-util-gfm-footnote/lib/index.js
yk0.peek = rA1;
function uA1() {
  this.buffer();
}
function cA1(Z) {
  this.enter({ type: "footnoteReference", identifier: "", label: "" }, Z);
}
function lA1() {
  this.buffer();
}
function nA1(Z) {
  this.enter({ type: "footnoteDefinition", identifier: "", label: "", children: [] }, Z);
}
function iA1(Z) {
  let J = this.resume(), $ = this.stack[this.stack.length - 1];
  t0($.type === "footnoteReference"), $.identifier = YW(this.sliceSerialize(Z)).toLowerCase(), $.label = J;
}
function oA1(Z) {
  this.exit(Z);
}
function sA1(Z) {
  let J = this.resume(), $ = this.stack[this.stack.length - 1];
  t0($.type === "footnoteDefinition"), $.identifier = YW(this.sliceSerialize(Z)).toLowerCase(), $.label = J;
}
function aA1(Z) {
  this.exit(Z);
}
function rA1() {
  return "[";
}
function yk0(Z, J, $, X) {
  let Y = $.createTracker(X), Q = Y.move("[^"), W = $.enter("footnoteReference"), K = $.enter("reference");
  return Q += Y.move($.safe($.associationId(Z), { after: "]", before: Q })), K(), W(), Q += Y.move("]"), Q;
}
function a20() {
  return {
    enter: {
      gfmFootnoteCallString: uA1,
      gfmFootnoteCall: cA1,
      gfmFootnoteDefinitionLabelString: lA1,
      gfmFootnoteDefinition: nA1
    },
    exit: {
      gfmFootnoteCallString: iA1,
      gfmFootnoteCall: oA1,
      gfmFootnoteDefinitionLabelString: sA1,
      gfmFootnoteDefinition: aA1
    }
  };
}
function r20(Z) {
  let J = !1;
  if (Z && Z.firstLineBlank)
    J = !0;
  return {
    handlers: { footnoteDefinition: $, footnoteReference: yk0 },
    unsafe: [{ character: "[", inConstruct: ["label", "phrasing", "reference"] }]
  };
  function $(X, Y, Q, W) {
    let K = Q.createTracker(W), G = K.move("[^"), H = Q.enter("footnoteDefinition"), N = Q.enter("label");
    if (G += K.move(Q.safe(Q.associationId(X), { before: G, after: "]" })), N(), G += K.move("]:"), X.children && X.children.length > 0)
      K.shift(4), G += K.move((J ? `
` : " ") + Q.indentLines(Q.containerFlow(X, K.current()), J ? gk0 : tA1));
    return H(), G;
  }
}
function tA1(Z, J, $) {
  return J === 0 ? Z : gk0(Z, J, $);
}
function gk0(Z, J, $) {
  return ($ ? "" : "    ") + Z;
}
// node_modules/mdast-util-gfm-strikethrough/lib/index.js
var eA1 = [
  "autolink",
  "destinationLiteral",
  "destinationRaw",
  "reference",
  "titleQuote",
  "titleApostrophe"
];
mk0.peek = $B1;
function t20() {
  return {
    canContainEols: ["delete"],
    enter: { strikethrough: ZB1 },
    exit: { strikethrough: JB1 }
  };
}
function e20() {
  return {
    unsafe: [
      {
        character: "~",
        inConstruct: "phrasing",
        notInConstruct: eA1
      }
    ],
    handlers: { delete: mk0 }
  };
}
function ZB1(Z) {
  this.enter({ type: "delete", children: [] }, Z);
}
function JB1(Z) {
  this.exit(Z);
}
function mk0(Z, J, $, X) {
  let Y = $.createTracker(X), Q = $.enter("strikethrough"), W = Y.move("~~");
  return W += $.containerPhrasing(Z, {
    ...Y.current(),
    before: W,
    after: "~"
  }), W += Y.move("~~"), Q(), W;
}
function $B1() {
  return "~";
}
// node_modules/markdown-table/index.js
function XB1(Z) {
  return Z.length;
}
function pk0(Z, J) {
  let $ = J || {}, X = ($.align || []).concat(), Y = $.stringLength || XB1, Q = [], W = [], K = [], G = [], H = 0, N = -1;
  while (++N < Z.length) {
    let R = [], z = [], D = -1;
    if (Z[N].length > H)
      H = Z[N].length;
    while (++D < Z[N].length) {
      let A = YB1(Z[N][D]);
      if ($.alignDelimiters !== !1) {
        let B = Y(A);
        if (z[D] = B, G[D] === void 0 || B > G[D])
          G[D] = B;
      }
      R.push(A);
    }
    W[N] = R, K[N] = z;
  }
  let q = -1;
  if (typeof X === "object" && "length" in X)
    while (++q < H)
      Q[q] = dk0(X[q]);
  else {
    let R = dk0(X);
    while (++q < H)
      Q[q] = R;
  }
  q = -1;
  let U = [], F = [];
  while (++q < H) {
    let R = Q[q], z = "", D = "";
    if (R === 99)
      z = ":", D = ":";
    else if (R === 108)
      z = ":";
    else if (R === 114)
      D = ":";
    let A = $.alignDelimiters === !1 ? 1 : Math.max(1, G[q] - z.length - D.length), B = z + "-".repeat(A) + D;
    if ($.alignDelimiters !== !1) {
      if (A = z.length + A + D.length, A > G[q])
        G[q] = A;
      F[q] = A;
    }
    U[q] = B;
  }
  W.splice(1, 0, U), K.splice(1, 0, F), N = -1;
  let E = [];
  while (++N < W.length) {
    let R = W[N], z = K[N];
    q = -1;
    let D = [];
    while (++q < H) {
      let A = R[q] || "", B = "", T = "";
      if ($.alignDelimiters !== !1) {
        let w = G[q] - (z[q] || 0), V = Q[q];
        if (V === 114)
          B = " ".repeat(w);
        else if (V === 99)
          if (w % 2)
            B = " ".repeat(w / 2 + 0.5), T = " ".repeat(w / 2 - 0.5);
          else
            B = " ".repeat(w / 2), T = B;
        else
          T = " ".repeat(w);
      }
      if ($.delimiterStart !== !1 && !q)
        D.push("|");
      if ($.padding !== !1 && !($.alignDelimiters === !1 && A === "") && ($.delimiterStart !== !1 || q))
        D.push(" ");
      if ($.alignDelimiters !== !1)
        D.push(B);
      if (D.push(A), $.alignDelimiters !== !1)
        D.push(T);
      if ($.padding !== !1)
        D.push(" ");
      if ($.delimiterEnd !== !1 || q !== H - 1)
        D.push("|");
    }
    E.push($.delimiterEnd === !1 ? D.join("").replace(/ +$/, "") : D.join(""));
  }
  return E.join(`
`);
}
function YB1(Z) {
  return Z === null || Z === void 0 ? "" : String(Z);
}
function dk0(Z) {
  let J = typeof Z === "string" ? Z.codePointAt(0) : 0;
  return J === 67 || J === 99 ? 99 : J === 76 || J === 108 ? 108 : J === 82 || J === 114 ? 114 : 0;
}

// node_modules/mdast-util-to-markdown/lib/handle/blockquote.js
function uk0(Z, J, $, X) {
  let Y = $.enter("blockquote"), Q = $.createTracker(X);
  Q.move("> "), Q.shift(2);
  let W = $.indentLines($.containerFlow(Z, Q.current()), QB1);
  return Y(), W;
}
function QB1(Z, J, $) {
  return ">" + ($ ? "" : " ") + Z;
}

// node_modules/mdast-util-to-markdown/lib/util/pattern-in-scope.js
function lk0(Z, J) {
  return ck0(Z, J.inConstruct, !0) && !ck0(Z, J.notInConstruct, !1);
}
function ck0(Z, J, $) {
  if (typeof J === "string")
    J = [J];
  if (!J || J.length === 0)
    return $;
  let X = -1;
  while (++X < J.length)
    if (Z.includes(J[X]))
      return !0;
  return !1;
}

// node_modules/mdast-util-to-markdown/lib/handle/break.js
function Z80(Z, J, $, X) {
  let Y = -1;
  while (++Y < $.unsafe.length)
    if ($.unsafe[Y].character === `
` && lk0($.stack, $.unsafe[Y]))
      return /[ \t]/.test(X.before) ? "" : " ";
  return "\\\n";
}

// node_modules/longest-streak/index.js
function nk0(Z, J) {
  let $ = String(Z), X = $.indexOf(J), Y = X, Q = 0, W = 0;
  if (typeof J !== "string")
    throw new TypeError("Expected substring");
  while (X !== -1) {
    if (X === Y) {
      if (++Q > W)
        W = Q;
    } else
      Q = 1;
    Y = X + J.length, X = $.indexOf(J, Y);
  }
  return W;
}

// node_modules/mdast-util-to-markdown/lib/util/format-code-as-indented.js
function ik0(Z, J) {
  return Boolean(J.options.fences === !1 && Z.value && !Z.lang && /[^ \r\n]/.test(Z.value) && !/^[\t ]*(?:[\r\n]|$)|(?:^|[\r\n])[\t ]*$/.test(Z.value));
}

// node_modules/mdast-util-to-markdown/lib/util/check-fence.js
function ok0(Z) {
  let J = Z.options.fence || "`";
  if (J !== "`" && J !== "~")
    throw new Error("Cannot serialize code with `" + J + "` for `options.fence`, expected `` ` `` or `~`");
  return J;
}

// node_modules/mdast-util-to-markdown/lib/handle/code.js
function sk0(Z, J, $, X) {
  let Y = ok0($), Q = Z.value || "", W = Y === "`" ? "GraveAccent" : "Tilde";
  if (ik0(Z, $)) {
    let q = $.enter("codeIndented"), U = $.indentLines(Q, WB1);
    return q(), U;
  }
  let K = $.createTracker(X), G = Y.repeat(Math.max(nk0(Q, Y) + 1, 3)), H = $.enter("codeFenced"), N = K.move(G);
  if (Z.lang) {
    let q = $.enter(`codeFencedLang${W}`);
    N += K.move($.safe(Z.lang, {
      before: N,
      after: " ",
      encode: ["`"],
      ...K.current()
    })), q();
  }
  if (Z.lang && Z.meta) {
    let q = $.enter(`codeFencedMeta${W}`);
    N += K.move(" "), N += K.move($.safe(Z.meta, {
      before: N,
      after: `
`,
      encode: ["`"],
      ...K.current()
    })), q();
  }
  if (N += K.move(`
`), Q)
    N += K.move(Q + `
`);
  return N += K.move(G), H(), N;
}
function WB1(Z, J, $) {
  return ($ ? "" : "    ") + Z;
}

// node_modules/mdast-util-to-markdown/lib/util/check-quote.js
function dB(Z) {
  let J = Z.options.quote || '"';
  if (J !== '"' && J !== "'")
    throw new Error("Cannot serialize title with `" + J + "` for `options.quote`, expected `\"`, or `'`");
  return J;
}

// node_modules/mdast-util-to-markdown/lib/handle/definition.js
function ak0(Z, J, $, X) {
  let Y = dB($), Q = Y === '"' ? "Quote" : "Apostrophe", W = $.enter("definition"), K = $.enter("label"), G = $.createTracker(X), H = G.move("[");
  if (H += G.move($.safe($.associationId(Z), {
    before: H,
    after: "]",
    ...G.current()
  })), H += G.move("]: "), K(), !Z.url || /[\0- \u007F]/.test(Z.url))
    K = $.enter("destinationLiteral"), H += G.move("<"), H += G.move($.safe(Z.url, { before: H, after: ">", ...G.current() })), H += G.move(">");
  else
    K = $.enter("destinationRaw"), H += G.move($.safe(Z.url, {
      before: H,
      after: Z.title ? " " : `
`,
      ...G.current()
    }));
  if (K(), Z.title)
    K = $.enter(`title${Q}`), H += G.move(" " + Y), H += G.move($.safe(Z.title, {
      before: H,
      after: Y,
      ...G.current()
    })), H += G.move(Y), K();
  return W(), H;
}

// node_modules/mdast-util-to-markdown/lib/util/check-emphasis.js
function rk0(Z) {
  let J = Z.options.emphasis || "*";
  if (J !== "*" && J !== "_")
    throw new Error("Cannot serialize emphasis with `" + J + "` for `options.emphasis`, expected `*`, or `_`");
  return J;
}

// node_modules/mdast-util-to-markdown/lib/handle/emphasis.js
J80.peek = KB1;
function J80(Z, J, $, X) {
  let Y = rk0($), Q = $.enter("emphasis"), W = $.createTracker(X), K = W.move(Y);
  return K += W.move($.containerPhrasing(Z, {
    before: K,
    after: Y,
    ...W.current()
  })), K += W.move(Y), Q(), K;
}
function KB1(Z, J, $) {
  return $.options.emphasis || "*";
}

// node_modules/mdast-util-to-markdown/lib/util/format-heading-as-setext.js
function tk0(Z, J) {
  let $ = !1;
  return G4(Z, function(X) {
    if ("value" in X && /\r?\n|\r/.test(X.value) || X.type === "break")
      return $ = !0, K4;
  }), Boolean((!Z.depth || Z.depth < 3) && ez(Z) && (J.options.setext || $));
}

// node_modules/mdast-util-to-markdown/lib/handle/heading.js
function ek0(Z, J, $, X) {
  let Y = Math.max(Math.min(6, Z.depth || 1), 1), Q = $.createTracker(X);
  if (tk0(Z, $)) {
    let N = $.enter("headingSetext"), q = $.enter("phrasing"), U = $.containerPhrasing(Z, {
      ...Q.current(),
      before: `
`,
      after: `
`
    });
    return q(), N(), U + `
` + (Y === 1 ? "=" : "-").repeat(U.length - (Math.max(U.lastIndexOf("\r"), U.lastIndexOf(`
`)) + 1));
  }
  let W = "#".repeat(Y), K = $.enter("headingAtx"), G = $.enter("phrasing");
  Q.move(W + " ");
  let H = $.containerPhrasing(Z, {
    before: "# ",
    after: `
`,
    ...Q.current()
  });
  if (/^[\t ]/.test(H))
    H = "&#x" + H.charCodeAt(0).toString(16).toUpperCase() + ";" + H.slice(1);
  if (H = H ? W + " " + H : W, $.options.closeAtx)
    H += " " + W;
  return G(), K(), H;
}

// node_modules/mdast-util-to-markdown/lib/handle/html.js
$80.peek = GB1;
function $80(Z) {
  return Z.value || "";
}
function GB1() {
  return "<";
}

// node_modules/mdast-util-to-markdown/lib/handle/image.js
X80.peek = HB1;
function X80(Z, J, $, X) {
  let Y = dB($), Q = Y === '"' ? "Quote" : "Apostrophe", W = $.enter("image"), K = $.enter("label"), G = $.createTracker(X), H = G.move("![");
  if (H += G.move($.safe(Z.alt, { before: H, after: "]", ...G.current() })), H += G.move("]("), K(), !Z.url && Z.title || /[\0- \u007F]/.test(Z.url))
    K = $.enter("destinationLiteral"), H += G.move("<"), H += G.move($.safe(Z.url, { before: H, after: ">", ...G.current() })), H += G.move(">");
  else
    K = $.enter("destinationRaw"), H += G.move($.safe(Z.url, {
      before: H,
      after: Z.title ? " " : ")",
      ...G.current()
    }));
  if (K(), Z.title)
    K = $.enter(`title${Q}`), H += G.move(" " + Y), H += G.move($.safe(Z.title, {
      before: H,
      after: Y,
      ...G.current()
    })), H += G.move(Y), K();
  return H += G.move(")"), W(), H;
}
function HB1() {
  return "!";
}

// node_modules/mdast-util-to-markdown/lib/handle/image-reference.js
Y80.peek = NB1;
function Y80(Z, J, $, X) {
  let Y = Z.referenceType, Q = $.enter("imageReference"), W = $.enter("label"), K = $.createTracker(X), G = K.move("!["), H = $.safe(Z.alt, {
    before: G,
    after: "]",
    ...K.current()
  });
  G += K.move(H + "]["), W();
  let N = $.stack;
  $.stack = [], W = $.enter("reference");
  let q = $.safe($.associationId(Z), {
    before: G,
    after: "]",
    ...K.current()
  });
  if (W(), $.stack = N, Q(), Y === "full" || !H || H !== q)
    G += K.move(q + "]");
  else if (Y === "shortcut")
    G = G.slice(0, -1);
  else
    G += K.move("]");
  return G;
}
function NB1() {
  return "!";
}

// node_modules/mdast-util-to-markdown/lib/handle/inline-code.js
Q80.peek = qB1;
function Q80(Z, J, $) {
  let X = Z.value || "", Y = "`", Q = -1;
  while (new RegExp("(^|[^`])" + Y + "([^`]|$)").test(X))
    Y += "`";
  if (/[^ \r\n]/.test(X) && (/^[ \r\n]/.test(X) && /[ \r\n]$/.test(X) || /^`|`$/.test(X)))
    X = " " + X + " ";
  while (++Q < $.unsafe.length) {
    let W = $.unsafe[Q], K = $.compilePattern(W), G;
    if (!W.atBreak)
      continue;
    while (G = K.exec(X)) {
      let H = G.index;
      if (X.charCodeAt(H) === 10 && X.charCodeAt(H - 1) === 13)
        H--;
      X = X.slice(0, H) + " " + X.slice(G.index + 1);
    }
  }
  return Y + X + Y;
}
function qB1() {
  return "`";
}

// node_modules/mdast-util-to-markdown/lib/util/format-link-as-autolink.js
function W80(Z, J) {
  let $ = ez(Z);
  return Boolean(!J.options.resourceLink && Z.url && !Z.title && Z.children && Z.children.length === 1 && Z.children[0].type === "text" && ($ === Z.url || "mailto:" + $ === Z.url) && /^[a-z][a-z+.-]+:/i.test(Z.url) && !/[\0- <>\u007F]/.test(Z.url));
}

// node_modules/mdast-util-to-markdown/lib/handle/link.js
K80.peek = FB1;
function K80(Z, J, $, X) {
  let Y = dB($), Q = Y === '"' ? "Quote" : "Apostrophe", W = $.createTracker(X), K, G;
  if (W80(Z, $)) {
    let N = $.stack;
    $.stack = [], K = $.enter("autolink");
    let q = W.move("<");
    return q += W.move($.containerPhrasing(Z, {
      before: q,
      after: ">",
      ...W.current()
    })), q += W.move(">"), K(), $.stack = N, q;
  }
  K = $.enter("link"), G = $.enter("label");
  let H = W.move("[");
  if (H += W.move($.containerPhrasing(Z, {
    before: H,
    after: "](",
    ...W.current()
  })), H += W.move("]("), G(), !Z.url && Z.title || /[\0- \u007F]/.test(Z.url))
    G = $.enter("destinationLiteral"), H += W.move("<"), H += W.move($.safe(Z.url, { before: H, after: ">", ...W.current() })), H += W.move(">");
  else
    G = $.enter("destinationRaw"), H += W.move($.safe(Z.url, {
      before: H,
      after: Z.title ? " " : ")",
      ...W.current()
    }));
  if (G(), Z.title)
    G = $.enter(`title${Q}`), H += W.move(" " + Y), H += W.move($.safe(Z.title, {
      before: H,
      after: Y,
      ...W.current()
    })), H += W.move(Y), G();
  return H += W.move(")"), K(), H;
}
function FB1(Z, J, $) {
  return W80(Z, $) ? "<" : "[";
}

// node_modules/mdast-util-to-markdown/lib/handle/link-reference.js
G80.peek = UB1;
function G80(Z, J, $, X) {
  let Y = Z.referenceType, Q = $.enter("linkReference"), W = $.enter("label"), K = $.createTracker(X), G = K.move("["), H = $.containerPhrasing(Z, {
    before: G,
    after: "]",
    ...K.current()
  });
  G += K.move(H + "]["), W();
  let N = $.stack;
  $.stack = [], W = $.enter("reference");
  let q = $.safe($.associationId(Z), {
    before: G,
    after: "]",
    ...K.current()
  });
  if (W(), $.stack = N, Q(), Y === "full" || !H || H !== q)
    G += K.move(q + "]");
  else if (Y === "shortcut")
    G = G.slice(0, -1);
  else
    G += K.move("]");
  return G;
}
function UB1() {
  return "[";
}

// node_modules/mdast-util-to-markdown/lib/util/check-bullet.js
function pB(Z) {
  let J = Z.options.bullet || "*";
  if (J !== "*" && J !== "+" && J !== "-")
    throw new Error("Cannot serialize items with `" + J + "` for `options.bullet`, expected `*`, `+`, or `-`");
  return J;
}

// node_modules/mdast-util-to-markdown/lib/util/check-bullet-other.js
function Zv0(Z) {
  let J = pB(Z), $ = Z.options.bulletOther;
  if (!$)
    return J === "*" ? "-" : "*";
  if ($ !== "*" && $ !== "+" && $ !== "-")
    throw new Error("Cannot serialize items with `" + $ + "` for `options.bulletOther`, expected `*`, `+`, or `-`");
  if ($ === J)
    throw new Error("Expected `bullet` (`" + J + "`) and `bulletOther` (`" + $ + "`) to be different");
  return $;
}

// node_modules/mdast-util-to-markdown/lib/util/check-bullet-ordered.js
function Jv0(Z) {
  let J = Z.options.bulletOrdered || ".";
  if (J !== "." && J !== ")")
    throw new Error("Cannot serialize items with `" + J + "` for `options.bulletOrdered`, expected `.` or `)`");
  return J;
}

// node_modules/mdast-util-to-markdown/lib/util/check-rule.js
function Eg(Z) {
  let J = Z.options.rule || "*";
  if (J !== "*" && J !== "-" && J !== "_")
    throw new Error("Cannot serialize rules with `" + J + "` for `options.rule`, expected `*`, `-`, or `_`");
  return J;
}

// node_modules/mdast-util-to-markdown/lib/handle/list.js
function $v0(Z, J, $, X) {
  let Y = $.enter("list"), Q = $.bulletCurrent, W = Z.ordered ? Jv0($) : pB($), K = Z.ordered ? W === "." ? ")" : "." : Zv0($), G = J && $.bulletLastUsed ? W === $.bulletLastUsed : !1;
  if (!Z.ordered) {
    let N = Z.children ? Z.children[0] : void 0;
    if ((W === "*" || W === "-") && N && (!N.children || !N.children[0]) && $.stack[$.stack.length - 1] === "list" && $.stack[$.stack.length - 2] === "listItem" && $.stack[$.stack.length - 3] === "list" && $.stack[$.stack.length - 4] === "listItem" && $.indexStack[$.indexStack.length - 1] === 0 && $.indexStack[$.indexStack.length - 2] === 0 && $.indexStack[$.indexStack.length - 3] === 0)
      G = !0;
    if (Eg($) === W && N) {
      let q = -1;
      while (++q < Z.children.length) {
        let U = Z.children[q];
        if (U && U.type === "listItem" && U.children && U.children[0] && U.children[0].type === "thematicBreak") {
          G = !0;
          break;
        }
      }
    }
  }
  if (G)
    W = K;
  $.bulletCurrent = W;
  let H = $.containerFlow(Z, X);
  return $.bulletLastUsed = W, $.bulletCurrent = Q, Y(), H;
}

// node_modules/mdast-util-to-markdown/lib/util/check-list-item-indent.js
function Xv0(Z) {
  let J = Z.options.listItemIndent || "one";
  if (J !== "tab" && J !== "one" && J !== "mixed")
    throw new Error("Cannot serialize items with `" + J + "` for `options.listItemIndent`, expected `tab`, `one`, or `mixed`");
  return J;
}

// node_modules/mdast-util-to-markdown/lib/handle/list-item.js
function Yv0(Z, J, $, X) {
  let Y = Xv0($), Q = $.bulletCurrent || pB($);
  if (J && J.type === "list" && J.ordered)
    Q = (typeof J.start === "number" && J.start > -1 ? J.start : 1) + ($.options.incrementListMarker === !1 ? 0 : J.children.indexOf(Z)) + Q;
  let W = Q.length + 1;
  if (Y === "tab" || Y === "mixed" && (J && J.type === "list" && J.spread || Z.spread))
    W = Math.ceil(W / 4) * 4;
  let K = $.createTracker(X);
  K.move(Q + " ".repeat(W - Q.length)), K.shift(W);
  let G = $.enter("listItem"), H = $.indentLines($.containerFlow(Z, K.current()), N);
  return G(), H;
  function N(q, U, F) {
    if (U)
      return (F ? "" : " ".repeat(W)) + q;
    return (F ? Q : Q + " ".repeat(W - Q.length)) + q;
  }
}

// node_modules/mdast-util-to-markdown/lib/handle/paragraph.js
function Qv0(Z, J, $, X) {
  let Y = $.enter("paragraph"), Q = $.enter("phrasing"), W = $.containerPhrasing(Z, X);
  return Q(), Y(), W;
}

// node_modules/mdast-util-phrasing/lib/index.js
var H80 = VE([
  "break",
  "delete",
  "emphasis",
  "footnote",
  "footnoteReference",
  "image",
  "imageReference",
  "inlineCode",
  "inlineMath",
  "link",
  "linkReference",
  "mdxJsxTextElement",
  "mdxTextExpression",
  "strong",
  "text",
  "textDirective"
]);
// node_modules/mdast-util-to-markdown/lib/handle/root.js
function Wv0(Z, J, $, X) {
  return (Z.children.some(function(W) {
    return H80(W);
  }) ? $.containerPhrasing : $.containerFlow).call($, Z, X);
}

// node_modules/mdast-util-to-markdown/lib/util/check-strong.js
function Kv0(Z) {
  let J = Z.options.strong || "*";
  if (J !== "*" && J !== "_")
    throw new Error("Cannot serialize strong with `" + J + "` for `options.strong`, expected `*`, or `_`");
  return J;
}

// node_modules/mdast-util-to-markdown/lib/handle/strong.js
N80.peek = LB1;
function N80(Z, J, $, X) {
  let Y = Kv0($), Q = $.enter("strong"), W = $.createTracker(X), K = W.move(Y + Y);
  return K += W.move($.containerPhrasing(Z, {
    before: K,
    after: Y,
    ...W.current()
  })), K += W.move(Y + Y), Q(), K;
}
function LB1(Z, J, $) {
  return $.options.strong || "*";
}

// node_modules/mdast-util-to-markdown/lib/handle/text.js
function Gv0(Z, J, $, X) {
  return $.safe(Z.value, X);
}

// node_modules/mdast-util-to-markdown/lib/util/check-rule-repetition.js
function Hv0(Z) {
  let J = Z.options.ruleRepetition || 3;
  if (J < 3)
    throw new Error("Cannot serialize rules with repetition `" + J + "` for `options.ruleRepetition`, expected `3` or more");
  return J;
}

// node_modules/mdast-util-to-markdown/lib/handle/thematic-break.js
function Nv0(Z, J, $) {
  let X = (Eg($) + ($.options.ruleSpaces ? " " : "")).repeat(Hv0($));
  return $.options.ruleSpaces ? X.slice(0, -1) : X;
}

// node_modules/mdast-util-to-markdown/lib/handle/index.js
var WP = {
  blockquote: uk0,
  break: Z80,
  code: sk0,
  definition: ak0,
  emphasis: J80,
  hardBreak: Z80,
  heading: ek0,
  html: $80,
  image: X80,
  imageReference: Y80,
  inlineCode: Q80,
  link: K80,
  linkReference: G80,
  list: $v0,
  listItem: Yv0,
  paragraph: Qv0,
  root: Wv0,
  strong: N80,
  text: Gv0,
  thematicBreak: Nv0
};
// node_modules/mdast-util-gfm-table/lib/index.js
function F80() {
  return {
    enter: {
      table: RB1,
      tableData: qv0,
      tableHeader: qv0,
      tableRow: OB1
    },
    exit: {
      codeText: zB1,
      table: EB1,
      tableData: q80,
      tableHeader: q80,
      tableRow: q80
    }
  };
}
function RB1(Z) {
  let J = Z._align;
  t0(J, "expected `_align` on table"), this.enter({
    type: "table",
    align: J.map(function($) {
      return $ === "none" ? null : $;
    }),
    children: []
  }, Z), this.data.inTable = !0;
}
function EB1(Z) {
  this.exit(Z), this.data.inTable = void 0;
}
function OB1(Z) {
  this.enter({ type: "tableRow", children: [] }, Z);
}
function q80(Z) {
  this.exit(Z);
}
function qv0(Z) {
  this.enter({ type: "tableCell", children: [] }, Z);
}
function zB1(Z) {
  let J = this.resume();
  if (this.data.inTable)
    J = J.replace(/\\([\\|])/g, DB1);
  let $ = this.stack[this.stack.length - 1];
  t0($.type === "inlineCode"), $.value = J, this.exit(Z);
}
function DB1(Z, J) {
  return J === "|" ? J : Z;
}
function U80(Z) {
  let J = Z || {}, $ = J.tableCellPadding, X = J.tablePipeAlign, Y = J.stringLength, Q = $ ? " " : "|";
  return {
    unsafe: [
      { character: "\r", inConstruct: "tableCell" },
      { character: `
`, inConstruct: "tableCell" },
      { atBreak: !0, character: "|", after: "[	 :-]" },
      { character: "|", inConstruct: "tableCell" },
      { atBreak: !0, character: ":", after: "-" },
      { atBreak: !0, character: "-", after: "[:|-]" }
    ],
    handlers: {
      inlineCode: U,
      table: W,
      tableCell: G,
      tableRow: K
    }
  };
  function W(F, E, R, z) {
    return H(N(F, R, z), F.align);
  }
  function K(F, E, R, z) {
    let D = q(F, R, z), A = H([D]);
    return A.slice(0, A.indexOf(`
`));
  }
  function G(F, E, R, z) {
    let D = R.enter("tableCell"), A = R.enter("phrasing"), B = R.containerPhrasing(F, {
      ...z,
      before: Q,
      after: Q
    });
    return A(), D(), B;
  }
  function H(F, E) {
    return pk0(F, {
      align: E,
      alignDelimiters: X,
      padding: $,
      stringLength: Y
    });
  }
  function N(F, E, R) {
    let z = F.children, D = -1, A = [], B = E.enter("table");
    while (++D < z.length)
      A[D] = q(z[D], E, R);
    return B(), A;
  }
  function q(F, E, R) {
    let z = F.children, D = -1, A = [], B = E.enter("tableRow");
    while (++D < z.length)
      A[D] = G(z[D], F, E, R);
    return B(), A;
  }
  function U(F, E, R) {
    let z = WP.inlineCode(F, E, R);
    if (R.stack.includes("tableCell"))
      z = z.replace(/\|/g, "\\$&");
    return z;
  }
}
// node_modules/mdast-util-gfm-task-list-item/lib/index.js
function L80() {
  return {
    exit: {
      taskListCheckValueChecked: Fv0,
      taskListCheckValueUnchecked: Fv0,
      paragraph: MB1
    }
  };
}
function R80() {
  return {
    unsafe: [{ atBreak: !0, character: "-", after: "[:|-]" }],
    handlers: { listItem: AB1 }
  };
}
function Fv0(Z) {
  let J = this.stack[this.stack.length - 2];
  t0(J.type === "listItem"), J.checked = Z.type === "taskListCheckValueChecked";
}
function MB1(Z) {
  let J = this.stack[this.stack.length - 2];
  if (J && J.type === "listItem" && typeof J.checked === "boolean") {
    let $ = this.stack[this.stack.length - 1];
    t0($.type === "paragraph");
    let X = $.children[0];
    if (X && X.type === "text") {
      let Y = J.children, Q = -1, W;
      while (++Q < Y.length) {
        let K = Y[Q];
        if (K.type === "paragraph") {
          W = K;
          break;
        }
      }
      if (W === $) {
        if (X.value = X.value.slice(1), X.value.length === 0)
          $.children.shift();
        else if ($.position && X.position && typeof X.position.start.offset === "number")
          X.position.start.column++, X.position.start.offset++, $.position.start = Object.assign({}, X.position.start);
      }
    }
  }
  this.exit(Z);
}
function AB1(Z, J, $, X) {
  let Y = Z.children[0], Q = typeof Z.checked === "boolean" && Y && Y.type === "paragraph", W = "[" + (Z.checked ? "x" : " ") + "] ", K = $.createTracker(X);
  if (Q)
    K.move(W);
  let G = WP.listItem(Z, J, $, {
    ...X,
    ...K.current()
  });
  if (Q)
    G = G.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/, H);
  return G;
  function H(N) {
    return N + W;
  }
}
// node_modules/mdast-util-gfm/lib/index.js
function E80() {
  return [
    o20(),
    a20(),
    t20(),
    F80(),
    L80()
  ];
}
function O80(Z) {
  return {
    extensions: [
      s20(),
      r20(Z),
      e20(),
      U80(Z),
      R80()
    ]
  };
}
// node_modules/micromark-extension-gfm-autolink-literal/dev/lib/syntax.js
var BB1 = { tokenize: VB1, partial: !0 }, Uv0 = { tokenize: IB1, partial: !0 }, Lv0 = { tokenize: PB1, partial: !0 }, Rv0 = { tokenize: CB1, partial: !0 }, wB1 = {
  tokenize: kB1,
  partial: !0
}, Ev0 = {
  name: "wwwAutolink",
  tokenize: TB1,
  previous: zv0
}, Ov0 = {
  name: "protocolAutolink",
  tokenize: _B1,
  previous: Dv0
}, PU = {
  name: "emailAutolink",
  tokenize: jB1,
  previous: Mv0
}, fq = {};
function D80() {
  return { text: fq };
}
var L4 = K0.digit0;
while (L4 < K0.leftCurlyBrace)
  if (fq[L4] = PU, L4++, L4 === K0.colon)
    L4 = K0.uppercaseA;
  else if (L4 === K0.leftSquareBracket)
    L4 = K0.lowercaseA;
fq[K0.plusSign] = PU;
fq[K0.dash] = PU;
fq[K0.dot] = PU;
fq[K0.underscore] = PU;
fq[K0.uppercaseH] = [PU, Ov0];
fq[K0.lowercaseH] = [PU, Ov0];
fq[K0.uppercaseW] = [PU, Ev0];
fq[K0.lowercaseW] = [PU, Ev0];
function jB1(Z, J, $) {
  let X = this, Y, Q;
  return W;
  function W(q) {
    if (!z80(q) || !Mv0.call(X, X.previous) || M80(X.events))
      return $(q);
    return Z.enter("literalAutolink"), Z.enter("literalAutolinkEmail"), K(q);
  }
  function K(q) {
    if (z80(q))
      return Z.consume(q), K;
    if (q === K0.atSign)
      return Z.consume(q), G;
    return $(q);
  }
  function G(q) {
    if (q === K0.dot)
      return Z.check(wB1, N, H)(q);
    if (q === K0.dash || q === K0.underscore || B$(q))
      return Q = !0, Z.consume(q), G;
    return N(q);
  }
  function H(q) {
    return Z.consume(q), Y = !0, G;
  }
  function N(q) {
    if (Q && Y && nX(X.previous))
      return Z.exit("literalAutolinkEmail"), Z.exit("literalAutolink"), J(q);
    return $(q);
  }
}
function TB1(Z, J, $) {
  let X = this;
  return Y;
  function Y(W) {
    if (W !== K0.uppercaseW && W !== K0.lowercaseW || !zv0.call(X, X.previous) || M80(X.events))
      return $(W);
    return Z.enter("literalAutolink"), Z.enter("literalAutolinkWww"), Z.check(BB1, Z.attempt(Uv0, Z.attempt(Lv0, Q), $), $)(W);
  }
  function Q(W) {
    return Z.exit("literalAutolinkWww"), Z.exit("literalAutolink"), J(W);
  }
}
function _B1(Z, J, $) {
  let X = this, Y = "", Q = !1;
  return W;
  function W(q) {
    if ((q === K0.uppercaseH || q === K0.lowercaseH) && Dv0.call(X, X.previous) && !M80(X.events))
      return Z.enter("literalAutolink"), Z.enter("literalAutolinkHttp"), Y += String.fromCodePoint(q), Z.consume(q), K;
    return $(q);
  }
  function K(q) {
    if (nX(q) && Y.length < 5)
      return Y += String.fromCodePoint(q), Z.consume(q), K;
    if (q === K0.colon) {
      let U = Y.toLowerCase();
      if (U === "http" || U === "https")
        return Z.consume(q), G;
    }
    return $(q);
  }
  function G(q) {
    if (q === K0.slash) {
      if (Z.consume(q), Q)
        return H;
      return Q = !0, G;
    }
    return $(q);
  }
  function H(q) {
    return q === K0.eof || Z4(q) || Y9(q) || Pq(q) || J4(q) ? $(q) : Z.attempt(Uv0, Z.attempt(Lv0, N), $)(q);
  }
  function N(q) {
    return Z.exit("literalAutolinkHttp"), Z.exit("literalAutolink"), J(q);
  }
}
function VB1(Z, J, $) {
  let X = 0;
  return Y;
  function Y(W) {
    if ((W === K0.uppercaseW || W === K0.lowercaseW) && X < 3)
      return X++, Z.consume(W), Y;
    if (W === K0.dot && X === 3)
      return Z.consume(W), Q;
    return $(W);
  }
  function Q(W) {
    return W === K0.eof ? $(W) : J(W);
  }
}
function IB1(Z, J, $) {
  let X, Y, Q;
  return W;
  function W(H) {
    if (H === K0.dot || H === K0.underscore)
      return Z.check(Rv0, G, K)(H);
    if (H === K0.eof || Y9(H) || Pq(H) || H !== K0.dash && J4(H))
      return G(H);
    return Q = !0, Z.consume(H), W;
  }
  function K(H) {
    if (H === K0.underscore)
      X = !0;
    else
      Y = X, X = void 0;
    return Z.consume(H), W;
  }
  function G(H) {
    if (Y || X || !Q)
      return $(H);
    return J(H);
  }
}
function PB1(Z, J) {
  let $ = 0, X = 0;
  return Y;
  function Y(W) {
    if (W === K0.leftParenthesis)
      return $++, Z.consume(W), Y;
    if (W === K0.rightParenthesis && X < $)
      return Q(W);
    if (W === K0.exclamationMark || W === K0.quotationMark || W === K0.ampersand || W === K0.apostrophe || W === K0.rightParenthesis || W === K0.asterisk || W === K0.comma || W === K0.dot || W === K0.colon || W === K0.semicolon || W === K0.lessThan || W === K0.questionMark || W === K0.rightSquareBracket || W === K0.underscore || W === K0.tilde)
      return Z.check(Rv0, J, Q)(W);
    if (W === K0.eof || Y9(W) || Pq(W))
      return J(W);
    return Z.consume(W), Y;
  }
  function Q(W) {
    if (W === K0.rightParenthesis)
      X++;
    return Z.consume(W), Y;
  }
}
function CB1(Z, J, $) {
  return X;
  function X(K) {
    if (K === K0.exclamationMark || K === K0.quotationMark || K === K0.apostrophe || K === K0.rightParenthesis || K === K0.asterisk || K === K0.comma || K === K0.dot || K === K0.colon || K === K0.semicolon || K === K0.questionMark || K === K0.underscore || K === K0.tilde)
      return Z.consume(K), X;
    if (K === K0.ampersand)
      return Z.consume(K), Q;
    if (K === K0.rightSquareBracket)
      return Z.consume(K), Y;
    if (K === K0.lessThan || K === K0.eof || Y9(K) || Pq(K))
      return J(K);
    return $(K);
  }
  function Y(K) {
    if (K === K0.eof || K === K0.leftParenthesis || K === K0.leftSquareBracket || Y9(K) || Pq(K))
      return J(K);
    return X(K);
  }
  function Q(K) {
    return nX(K) ? W(K) : $(K);
  }
  function W(K) {
    if (K === K0.semicolon)
      return Z.consume(K), X;
    if (nX(K))
      return Z.consume(K), W;
    return $(K);
  }
}
function kB1(Z, J, $) {
  return X;
  function X(Q) {
    return Z.consume(Q), Y;
  }
  function Y(Q) {
    return B$(Q) ? $(Q) : J(Q);
  }
}
function zv0(Z) {
  return Z === K0.eof || Z === K0.leftParenthesis || Z === K0.asterisk || Z === K0.underscore || Z === K0.leftSquareBracket || Z === K0.rightSquareBracket || Z === K0.tilde || Y9(Z);
}
function Dv0(Z) {
  return !nX(Z);
}
function Mv0(Z) {
  return !(Z === K0.slash || z80(Z));
}
function z80(Z) {
  return Z === K0.plusSign || Z === K0.dash || Z === K0.dot || Z === K0.underscore || B$(Z);
}
function M80(Z) {
  let J = Z.length, $ = !1;
  while (J--) {
    let X = Z[J][1];
    if ((X.type === "labelLink" || X.type === "labelImage") && !X._balanced) {
      $ = !0;
      break;
    }
    if (X._gfmAutolinkLiteralWalkedInto) {
      $ = !1;
      break;
    }
  }
  if (Z.length > 0 && !$)
    Z[Z.length - 1][1]._gfmAutolinkLiteralWalkedInto = !0;
  return $;
}
// node_modules/micromark-extension-gfm-footnote/dev/lib/syntax.js
var vB1 = { tokenize: gB1, partial: !0 };
function A80() {
  return {
    document: {
      [K0.leftSquareBracket]: {
        name: "gfmFootnoteDefinition",
        tokenize: bB1,
        continuation: { tokenize: xB1 },
        exit: yB1
      }
    },
    text: {
      [K0.leftSquareBracket]: {
        name: "gfmFootnoteCall",
        tokenize: hB1
      },
      [K0.rightSquareBracket]: {
        name: "gfmPotentialFootnoteCall",
        add: "after",
        tokenize: SB1,
        resolveTo: fB1
      }
    }
  };
}
function SB1(Z, J, $) {
  let X = this, Y = X.events.length, Q = X.parser.gfmFootnotes || (X.parser.gfmFootnotes = []), W;
  while (Y--) {
    let G = X.events[Y][1];
    if (G.type === M0.labelImage) {
      W = G;
      break;
    }
    if (G.type === "gfmFootnoteCall" || G.type === M0.labelLink || G.type === M0.label || G.type === M0.image || G.type === M0.link)
      break;
  }
  return K;
  function K(G) {
    if (t0(G === K0.rightSquareBracket, "expected `]`"), !W || !W._balanced)
      return $(G);
    let H = YW(X.sliceSerialize({ start: W.end, end: X.now() }));
    if (H.codePointAt(0) !== K0.caret || !Q.includes(H.slice(1)))
      return $(G);
    return Z.enter("gfmFootnoteCallLabelMarker"), Z.consume(G), Z.exit("gfmFootnoteCallLabelMarker"), J(G);
  }
}
function fB1(Z, J) {
  let $ = Z.length, X;
  while ($--)
    if (Z[$][1].type === M0.labelImage && Z[$][0] === "enter") {
      X = Z[$][1];
      break;
    }
  t0(X, "expected `labelStart` to resolve"), Z[$ + 1][1].type = M0.data, Z[$ + 3][1].type = "gfmFootnoteCallLabelMarker";
  let Y = {
    type: "gfmFootnoteCall",
    start: Object.assign({}, Z[$ + 3][1].start),
    end: Object.assign({}, Z[Z.length - 1][1].end)
  }, Q = {
    type: "gfmFootnoteCallMarker",
    start: Object.assign({}, Z[$ + 3][1].end),
    end: Object.assign({}, Z[$ + 3][1].end)
  };
  Q.end.column++, Q.end.offset++, Q.end._bufferIndex++;
  let W = {
    type: "gfmFootnoteCallString",
    start: Object.assign({}, Q.end),
    end: Object.assign({}, Z[Z.length - 1][1].start)
  }, K = {
    type: M0.chunkString,
    contentType: "string",
    start: Object.assign({}, W.start),
    end: Object.assign({}, W.end)
  }, G = [
    Z[$ + 1],
    Z[$ + 2],
    ["enter", Y, J],
    Z[$ + 3],
    Z[$ + 4],
    ["enter", Q, J],
    ["exit", Q, J],
    ["enter", W, J],
    ["enter", K, J],
    ["exit", K, J],
    ["exit", W, J],
    Z[Z.length - 2],
    Z[Z.length - 1],
    ["exit", Y, J]
  ];
  return Z.splice($, Z.length - $ + 1, ...G), Z;
}
function hB1(Z, J, $) {
  let X = this, Y = X.parser.gfmFootnotes || (X.parser.gfmFootnotes = []), Q = 0, W;
  return K;
  function K(q) {
    return t0(q === K0.leftSquareBracket, "expected `[`"), Z.enter("gfmFootnoteCall"), Z.enter("gfmFootnoteCallLabelMarker"), Z.consume(q), Z.exit("gfmFootnoteCallLabelMarker"), G;
  }
  function G(q) {
    if (q !== K0.caret)
      return $(q);
    return Z.enter("gfmFootnoteCallMarker"), Z.consume(q), Z.exit("gfmFootnoteCallMarker"), Z.enter("gfmFootnoteCallString"), Z.enter("chunkString").contentType = "string", H;
  }
  function H(q) {
    if (Q > M2.linkReferenceSizeMax || q === K0.rightSquareBracket && !W || q === K0.eof || q === K0.leftSquareBracket || Y9(q))
      return $(q);
    if (q === K0.rightSquareBracket) {
      Z.exit("chunkString");
      let U = Z.exit("gfmFootnoteCallString");
      if (!Y.includes(YW(X.sliceSerialize(U))))
        return $(q);
      return Z.enter("gfmFootnoteCallLabelMarker"), Z.consume(q), Z.exit("gfmFootnoteCallLabelMarker"), Z.exit("gfmFootnoteCall"), J;
    }
    if (!Y9(q))
      W = !0;
    return Q++, Z.consume(q), q === K0.backslash ? N : H;
  }
  function N(q) {
    if (q === K0.leftSquareBracket || q === K0.backslash || q === K0.rightSquareBracket)
      return Z.consume(q), Q++, H;
    return H(q);
  }
}
function bB1(Z, J, $) {
  let X = this, Y = X.parser.gfmFootnotes || (X.parser.gfmFootnotes = []), Q, W = 0, K;
  return G;
  function G(E) {
    return t0(E === K0.leftSquareBracket, "expected `[`"), Z.enter("gfmFootnoteDefinition")._container = !0, Z.enter("gfmFootnoteDefinitionLabel"), Z.enter("gfmFootnoteDefinitionLabelMarker"), Z.consume(E), Z.exit("gfmFootnoteDefinitionLabelMarker"), H;
  }
  function H(E) {
    if (E === K0.caret)
      return Z.enter("gfmFootnoteDefinitionMarker"), Z.consume(E), Z.exit("gfmFootnoteDefinitionMarker"), Z.enter("gfmFootnoteDefinitionLabelString"), Z.enter("chunkString").contentType = "string", N;
    return $(E);
  }
  function N(E) {
    if (W > M2.linkReferenceSizeMax || E === K0.rightSquareBracket && !K || E === K0.eof || E === K0.leftSquareBracket || Y9(E))
      return $(E);
    if (E === K0.rightSquareBracket) {
      Z.exit("chunkString");
      let R = Z.exit("gfmFootnoteDefinitionLabelString");
      return Q = YW(X.sliceSerialize(R)), Z.enter("gfmFootnoteDefinitionLabelMarker"), Z.consume(E), Z.exit("gfmFootnoteDefinitionLabelMarker"), Z.exit("gfmFootnoteDefinitionLabel"), U;
    }
    if (!Y9(E))
      K = !0;
    return W++, Z.consume(E), E === K0.backslash ? q : N;
  }
  function q(E) {
    if (E === K0.leftSquareBracket || E === K0.backslash || E === K0.rightSquareBracket)
      return Z.consume(E), W++, N;
    return N(E);
  }
  function U(E) {
    if (E === K0.colon) {
      if (Z.enter("definitionMarker"), Z.consume(E), Z.exit("definitionMarker"), !Y.includes(Q))
        Y.push(Q);
      return U6(Z, F, "gfmFootnoteDefinitionWhitespace");
    }
    return $(E);
  }
  function F(E) {
    return J(E);
  }
}
function xB1(Z, J, $) {
  return Z.check(Cq, J, Z.attempt(vB1, J, $));
}
function yB1(Z) {
  Z.exit("gfmFootnoteDefinition");
}
function gB1(Z, J, $) {
  let X = this;
  return U6(Z, Y, "gfmFootnoteDefinitionIndent", M2.tabSize + 1);
  function Y(Q) {
    let W = X.events[X.events.length - 1];
    return W && W[1].type === "gfmFootnoteDefinitionIndent" && W[2].sliceSerialize(W[1], !0).length === M2.tabSize ? J(Q) : $(Q);
  }
}
// node_modules/micromark-extension-gfm-strikethrough/dev/lib/syntax.js
function B80(Z) {
  let $ = (Z || {}).singleTilde, X = {
    name: "strikethrough",
    tokenize: Q,
    resolveAll: Y
  };
  if ($ === null || $ === void 0)
    $ = !0;
  return {
    text: { [K0.tilde]: X },
    insideSpan: { null: [X] },
    attentionMarkers: { null: [K0.tilde] }
  };
  function Y(W, K) {
    let G = -1;
    while (++G < W.length)
      if (W[G][0] === "enter" && W[G][1].type === "strikethroughSequenceTemporary" && W[G][1]._close) {
        let H = G;
        while (H--)
          if (W[H][0] === "exit" && W[H][1].type === "strikethroughSequenceTemporary" && W[H][1]._open && W[G][1].end.offset - W[G][1].start.offset === W[H][1].end.offset - W[H][1].start.offset) {
            W[G][1].type = "strikethroughSequence", W[H][1].type = "strikethroughSequence";
            let N = {
              type: "strikethrough",
              start: Object.assign({}, W[H][1].start),
              end: Object.assign({}, W[G][1].end)
            }, q = {
              type: "strikethroughText",
              start: Object.assign({}, W[H][1].end),
              end: Object.assign({}, W[G][1].start)
            }, U = [
              ["enter", N, K],
              ["enter", W[H][1], K],
              ["exit", W[H][1], K],
              ["enter", q, K]
            ], F = K.parser.constructs.insideSpan.null;
            if (F)
              NX(U, U.length, 0, TE(F, W.slice(H + 1, G), K));
            NX(U, U.length, 0, [
              ["exit", q, K],
              ["enter", W[G][1], K],
              ["exit", W[G][1], K],
              ["exit", N, K]
            ]), NX(W, H - 1, G - H + 3, U), G = H + U.length - 2;
            break;
          }
      }
    G = -1;
    while (++G < W.length)
      if (W[G][1].type === "strikethroughSequenceTemporary")
        W[G][1].type = M0.data;
    return W;
  }
  function Q(W, K, G) {
    let H = this.previous, N = this.events, q = 0;
    return U;
    function U(E) {
      if (t0(E === K0.tilde, "expected `~`"), H === K0.tilde && N[N.length - 1][1].type !== M0.characterEscape)
        return G(E);
      return W.enter("strikethroughSequenceTemporary"), F(E);
    }
    function F(E) {
      let R = _B(H);
      if (E === K0.tilde) {
        if (q > 1)
          return G(E);
        return W.consume(E), q++, F;
      }
      if (q < 2 && !$)
        return G(E);
      let z = W.exit("strikethroughSequenceTemporary"), D = _B(E);
      return z._open = !D || D === M2.attentionSideAfter && Boolean(R), z._close = !R || R === M2.attentionSideAfter && Boolean(D), K(E);
    }
  }
}
// node_modules/micromark-extension-gfm-table/dev/lib/edit-map.js
class w80 {
  constructor() {
    this.map = [];
  }
  add(Z, J, $) {
    mB1(this, Z, J, $);
  }
  consume(Z) {
    if (this.map.sort(function(Y, Q) {
      return Y[0] - Q[0];
    }), this.map.length === 0)
      return;
    let J = this.map.length, $ = [];
    while (J > 0)
      J -= 1, $.push(Z.slice(this.map[J][0] + this.map[J][1]), this.map[J][2]), Z.length = this.map[J][0];
    $.push(Z.slice()), Z.length = 0;
    let X = $.pop();
    while (X) {
      for (let Y of X)
        Z.push(Y);
      X = $.pop();
    }
    this.map.length = 0;
  }
}
function mB1(Z, J, $, X) {
  let Y = 0;
  if ($ === 0 && X.length === 0)
    return;
  while (Y < Z.map.length) {
    if (Z.map[Y][0] === J) {
      Z.map[Y][1] += $, Z.map[Y][2].push(...X);
      return;
    }
    Y += 1;
  }
  Z.map.push([J, $, X]);
}

// node_modules/micromark-extension-gfm-table/dev/lib/infer.js
function Av0(Z, J) {
  t0(Z[J][1].type === "table", "expected table");
  let $ = !1, X = [];
  while (J < Z.length) {
    let Y = Z[J];
    if ($) {
      if (Y[0] === "enter") {
        if (Y[1].type === "tableContent")
          X.push(Z[J + 1][1].type === "tableDelimiterMarker" ? "left" : "none");
      } else if (Y[1].type === "tableContent") {
        if (Z[J - 1][1].type === "tableDelimiterMarker") {
          let Q = X.length - 1;
          X[Q] = X[Q] === "left" ? "center" : "right";
        }
      } else if (Y[1].type === "tableDelimiterRow")
        break;
    } else if (Y[0] === "enter" && Y[1].type === "tableDelimiterRow")
      $ = !0;
    J += 1;
  }
  return X;
}

// node_modules/micromark-extension-gfm-table/dev/lib/syntax.js
function j80() {
  return {
    flow: {
      null: { name: "table", tokenize: dB1, resolveAll: pB1 }
    }
  };
}
function dB1(Z, J, $) {
  let X = this, Y = 0, Q = 0, W;
  return K;
  function K(f) {
    let v = X.events.length - 1;
    while (v > -1) {
      let b = X.events[v][1].type;
      if (b === M0.lineEnding || b === M0.linePrefix)
        v--;
      else
        break;
    }
    let h = v > -1 ? X.events[v][1].type : null, x = h === "tableHead" || h === "tableRow" ? V : G;
    if (x === V && X.parser.lazy[X.now().line])
      return $(f);
    return x(f);
  }
  function G(f) {
    return Z.enter("tableHead"), Z.enter("tableRow"), H(f);
  }
  function H(f) {
    if (f === K0.verticalBar)
      return N(f);
    return W = !0, Q += 1, N(f);
  }
  function N(f) {
    if (f === K0.eof)
      return $(f);
    if (n2(f)) {
      if (Q > 1)
        return Q = 0, X.interrupt = !0, Z.exit("tableRow"), Z.enter(M0.lineEnding), Z.consume(f), Z.exit(M0.lineEnding), F;
      return $(f);
    }
    if (F6(f))
      return U6(Z, N, M0.whitespace)(f);
    if (Q += 1, W)
      W = !1, Y += 1;
    if (f === K0.verticalBar)
      return Z.enter("tableCellDivider"), Z.consume(f), Z.exit("tableCellDivider"), W = !0, N;
    return Z.enter(M0.data), q(f);
  }
  function q(f) {
    if (f === K0.eof || f === K0.verticalBar || Y9(f))
      return Z.exit(M0.data), N(f);
    return Z.consume(f), f === K0.backslash ? U : q;
  }
  function U(f) {
    if (f === K0.backslash || f === K0.verticalBar)
      return Z.consume(f), q;
    return q(f);
  }
  function F(f) {
    if (X.interrupt = !1, X.parser.lazy[X.now().line])
      return $(f);
    if (Z.enter("tableDelimiterRow"), W = !1, F6(f))
      return t0(X.parser.constructs.disable.null, "expected `disabled.null`"), U6(Z, E, M0.linePrefix, X.parser.constructs.disable.null.includes("codeIndented") ? void 0 : M2.tabSize)(f);
    return E(f);
  }
  function E(f) {
    if (f === K0.dash || f === K0.colon)
      return z(f);
    if (f === K0.verticalBar)
      return W = !0, Z.enter("tableCellDivider"), Z.consume(f), Z.exit("tableCellDivider"), R;
    return w(f);
  }
  function R(f) {
    if (F6(f))
      return U6(Z, z, M0.whitespace)(f);
    return z(f);
  }
  function z(f) {
    if (f === K0.colon)
      return Q += 1, W = !0, Z.enter("tableDelimiterMarker"), Z.consume(f), Z.exit("tableDelimiterMarker"), D;
    if (f === K0.dash)
      return Q += 1, D(f);
    if (f === K0.eof || n2(f))
      return T(f);
    return w(f);
  }
  function D(f) {
    if (f === K0.dash)
      return Z.enter("tableDelimiterFiller"), A(f);
    return w(f);
  }
  function A(f) {
    if (f === K0.dash)
      return Z.consume(f), A;
    if (f === K0.colon)
      return W = !0, Z.exit("tableDelimiterFiller"), Z.enter("tableDelimiterMarker"), Z.consume(f), Z.exit("tableDelimiterMarker"), B;
    return Z.exit("tableDelimiterFiller"), B(f);
  }
  function B(f) {
    if (F6(f))
      return U6(Z, T, M0.whitespace)(f);
    return T(f);
  }
  function T(f) {
    if (f === K0.verticalBar)
      return E(f);
    if (f === K0.eof || n2(f)) {
      if (!W || Y !== Q)
        return w(f);
      return Z.exit("tableDelimiterRow"), Z.exit("tableHead"), J(f);
    }
    return w(f);
  }
  function w(f) {
    return $(f);
  }
  function V(f) {
    return Z.enter("tableRow"), P(f);
  }
  function P(f) {
    if (f === K0.verticalBar)
      return Z.enter("tableCellDivider"), Z.consume(f), Z.exit("tableCellDivider"), P;
    if (f === K0.eof || n2(f))
      return Z.exit("tableRow"), J(f);
    if (F6(f))
      return U6(Z, P, M0.whitespace)(f);
    return Z.enter(M0.data), I(f);
  }
  function I(f) {
    if (f === K0.eof || f === K0.verticalBar || Y9(f))
      return Z.exit(M0.data), P(f);
    return Z.consume(f), f === K0.backslash ? S : I;
  }
  function S(f) {
    if (f === K0.backslash || f === K0.verticalBar)
      return Z.consume(f), I;
    return I(f);
  }
}
function pB1(Z, J) {
  let $ = -1, X = !0, Y = 0, Q = [0, 0, 0, 0], W = [0, 0, 0, 0], K = !1, G = 0, H, N, q, U = new w80;
  while (++$ < Z.length) {
    let F = Z[$], E = F[1];
    if (F[0] === "enter") {
      if (E.type === "tableHead") {
        if (K = !1, G !== 0)
          t0(H, "there should be a table opening"), Bv0(U, J, G, H, N), N = void 0, G = 0;
        H = {
          type: "table",
          start: Object.assign({}, E.start),
          end: Object.assign({}, E.end)
        }, U.add($, 0, [["enter", H, J]]);
      } else if (E.type === "tableRow" || E.type === "tableDelimiterRow") {
        if (X = !0, q = void 0, Q = [0, 0, 0, 0], W = [0, $ + 1, 0, 0], K)
          K = !1, N = {
            type: "tableBody",
            start: Object.assign({}, E.start),
            end: Object.assign({}, E.end)
          }, U.add($, 0, [["enter", N, J]]);
        Y = E.type === "tableDelimiterRow" ? 2 : N ? 3 : 1;
      } else if (Y && (E.type === M0.data || E.type === "tableDelimiterMarker" || E.type === "tableDelimiterFiller")) {
        if (X = !1, W[2] === 0) {
          if (Q[1] !== 0)
            W[0] = W[1], q = Og(U, J, Q, Y, void 0, q), Q = [0, 0, 0, 0];
          W[2] = $;
        }
      } else if (E.type === "tableCellDivider")
        if (X)
          X = !1;
        else {
          if (Q[1] !== 0)
            W[0] = W[1], q = Og(U, J, Q, Y, void 0, q);
          Q = W, W = [Q[1], $, 0, 0];
        }
    } else if (E.type === "tableHead")
      K = !0, G = $;
    else if (E.type === "tableRow" || E.type === "tableDelimiterRow") {
      if (G = $, Q[1] !== 0)
        W[0] = W[1], q = Og(U, J, Q, Y, $, q);
      else if (W[1] !== 0)
        q = Og(U, J, W, Y, $, q);
      Y = 0;
    } else if (Y && (E.type === M0.data || E.type === "tableDelimiterMarker" || E.type === "tableDelimiterFiller"))
      W[3] = $;
  }
  if (G !== 0)
    t0(H, "expected table opening"), Bv0(U, J, G, H, N);
  U.consume(J.events), $ = -1;
  while (++$ < J.events.length) {
    let F = J.events[$];
    if (F[0] === "enter" && F[1].type === "table")
      F[1]._align = Av0(J.events, $);
  }
  return Z;
}
function Og(Z, J, $, X, Y, Q) {
  let W = X === 1 ? "tableHeader" : X === 2 ? "tableDelimiter" : "tableData", K = "tableContent";
  if ($[0] !== 0)
    t0(Q, "expected previous cell enter"), Q.end = Object.assign({}, uB(J.events, $[0])), Z.add($[0], 0, [["exit", Q, J]]);
  let G = uB(J.events, $[1]);
  if (Q = {
    type: W,
    start: Object.assign({}, G),
    end: Object.assign({}, G)
  }, Z.add($[1], 0, [["enter", Q, J]]), $[2] !== 0) {
    let H = uB(J.events, $[2]), N = uB(J.events, $[3]), q = {
      type: "tableContent",
      start: Object.assign({}, H),
      end: Object.assign({}, N)
    };
    if (Z.add($[2], 0, [["enter", q, J]]), t0($[3] !== 0), X !== 2) {
      let U = J.events[$[2]], F = J.events[$[3]];
      if (U[1].end = Object.assign({}, F[1].end), U[1].type = M0.chunkText, U[1].contentType = M2.contentTypeText, $[3] > $[2] + 1) {
        let E = $[2] + 1, R = $[3] - $[2] - 1;
        Z.add(E, R, []);
      }
    }
    Z.add($[3] + 1, 0, [["exit", q, J]]);
  }
  if (Y !== void 0)
    Q.end = Object.assign({}, uB(J.events, Y)), Z.add(Y, 0, [["exit", Q, J]]), Q = void 0;
  return Q;
}
function Bv0(Z, J, $, X, Y) {
  let Q = [], W = uB(J.events, $);
  if (Y)
    Y.end = Object.assign({}, W), Q.push(["exit", Y, J]);
  X.end = Object.assign({}, W), Q.push(["exit", X, J]), Z.add($ + 1, 0, Q);
}
function uB(Z, J) {
  let $ = Z[J], X = $[0] === "enter" ? "start" : "end";
  return $[1][X];
}
// node_modules/micromark-extension-gfm-task-list-item/dev/lib/syntax.js
var uB1 = { name: "tasklistCheck", tokenize: cB1 };
function T80() {
  return {
    text: { [K0.leftSquareBracket]: uB1 }
  };
}
function cB1(Z, J, $) {
  let X = this;
  return Y;
  function Y(G) {
    if (t0(G === K0.leftSquareBracket, "expected `[`"), X.previous !== K0.eof || !X._gfmTasklistFirstContentOfListItem)
      return $(G);
    return Z.enter("taskListCheck"), Z.enter("taskListCheckMarker"), Z.consume(G), Z.exit("taskListCheckMarker"), Q;
  }
  function Q(G) {
    if (Y9(G))
      return Z.enter("taskListCheckValueUnchecked"), Z.consume(G), Z.exit("taskListCheckValueUnchecked"), W;
    if (G === K0.uppercaseX || G === K0.lowercaseX)
      return Z.enter("taskListCheckValueChecked"), Z.consume(G), Z.exit("taskListCheckValueChecked"), W;
    return $(G);
  }
  function W(G) {
    if (G === K0.rightSquareBracket)
      return Z.enter("taskListCheckMarker"), Z.consume(G), Z.exit("taskListCheckMarker"), Z.exit("taskListCheck"), K;
    return $(G);
  }
  function K(G) {
    if (n2(G))
      return J(G);
    if (F6(G))
      return Z.check({ tokenize: lB1 }, J, $)(G);
    return $(G);
  }
}
function lB1(Z, J, $) {
  return U6(Z, X, M0.whitespace);
  function X(Y) {
    return Y === K0.eof ? $(Y) : J(Y);
  }
}
// node_modules/micromark-extension-gfm/index.js
function wv0(Z) {
  return vy([
    D80(),
    A80(),
    B80(Z),
    j80(),
    T80()
  ]);
}

// node_modules/remark-gfm/lib/index.js
var nB1 = {};
function zg(Z) {
  let J = this, $ = Z || nB1, X = J.data(), Y = X.micromarkExtensions || (X.micromarkExtensions = []), Q = X.fromMarkdownExtensions || (X.fromMarkdownExtensions = []), W = X.toMarkdownExtensions || (X.toMarkdownExtensions = []);
  Y.push(wv0($)), Q.push(E80()), W.push(O80($));
}
// node_modules/molstar/lib/mol-plugin-ui/hooks/use-behavior.js
var PE = t2(J7(), 1);
function iB1(Z) {
  let [, J] = PE.default.useState({}), $ = PE.default.useRef();
  return $.current = Z === null || Z === void 0 ? void 0 : Z.value, PE.default.useEffect(() => {
    if (!Z)
      return;
    let X = Z.subscribe((Y) => {
      if ($.current !== Y)
        J({});
    });
    return () => X.unsubscribe();
  }, [Z]), Z === null || Z === void 0 ? void 0 : Z.value;
}
function oB1(Z) {
  return PE.default.useSyncExternalStore(PE.default.useCallback((J) => {
    let $ = Z === null || Z === void 0 ? void 0 : Z.pipe(j_(1)).subscribe(J);
    return () => $ === null || $ === void 0 ? void 0 : $.unsubscribe();
  }, [Z]), PE.default.useCallback(() => Z === null || Z === void 0 ? void 0 : Z.value, [Z]));
}
var sB1 = PE.default.useSyncExternalStore ? oB1 : iB1;
function sW(Z) {
  return sB1(Z);
}

// node_modules/molstar/lib/mol-plugin-ui/controls/markdown.js
function jv0({ children: Z, components: J }) {
  return aW.jsxs("div", { className: "msp-markdown", children: [aW.jsx(aB1, {}), aW.jsx($P, { skipHtml: !0, components: { a: Zw1, img: rB1, ...J }, remarkPlugins: [zg], children: Z })] });
}
function aB1() {
  let Z = gH.useRef(null), J = gH.useContext(DQ), $ = sW(J === null || J === void 0 ? void 0 : J.managers.markdownExtensions.state.audioPlayer);
  if (gH.useEffect(() => {
    if (!Z.current)
      return;
    return Z.current.appendChild($), () => {
      $ === null || $ === void 0 || $.remove();
    };
  }, [$]), !$)
    return null;
  return aW.jsx("div", { className: "msp-markdown-audio-player", ref: Z });
}
function rB1({ src: Z, element: J, alt: $ }) {
  let X = gH.useContext(DQ);
  if (!Z)
    return J;
  _80(X);
  let Y = X === null || X === void 0 ? void 0 : X.managers.markdownExtensions.parseArgs(Z);
  if (Y) {
    let Q = X === null || X === void 0 ? void 0 : X.managers.markdownExtensions.tryRender(Y, eB1);
    return Q !== null && Q !== void 0 ? Q : J;
  } else {
    let Q = X === null || X === void 0 ? void 0 : X.managers.markdownExtensions.tryResolveUri(Z);
    if (typeof (Q === null || Q === void 0 ? void 0 : Q.then) === "function")
      return aW.jsx(tB1, { alt: $, data: Q });
    else if (typeof Q === "string" && Q)
      return aW.jsx("img", { src: Q, alt: $ });
  }
  return aW.jsx("img", { src: Z, alt: $ });
}
function tB1({ alt: Z, data: J }) {
  let [$, X] = gH.useState(void 0);
  if (gH.useEffect(() => {
    let Y = !0;
    return J.then((Q) => {
      if (Y)
        X(Q);
    }).catch((Q) => {
      if (console.error("Failed to load static image", Q), Y)
        X(void 0);
    }), () => {
      Y = !1;
    };
  }, [J]), !$)
    return null;
  return aW.jsx("img", { src: $, alt: Z });
}
var eB1 = [
  {
    name: "color-swatch",
    reactRenderFn: ({ args: Z }) => {
      let J = Z["color-swatch"];
      if (!J)
        return null;
      return aW.jsx("span", { style: { display: "inline-block", width: "0.75em", height: "0.75em", backgroundColor: J, borderRadius: "25%" } });
    }
  },
  {
    name: "color-palette",
    reactRenderFn: ({ args: Z }) => {
      var J, $, X;
      let Y = Z["color-palette-name"], Q = Z["color-palette-colors"], W = (J = Z["color-palette-width"]) !== null && J !== void 0 ? J : "150px", K = ($ = Z["color-palette-height"]) !== null && $ !== void 0 ? $ : "0.5em", G = "color-palette-discrete" in Z;
      if (!Y && !Q)
        return null;
      let H = Q ? FI0(Q) : (X = g7[Y.toLowerCase()]) === null || X === void 0 ? void 0 : X.list;
      if (!(H === null || H === void 0 ? void 0 : H.length))
        return console.warn("Color palette could not be resolved.", Z), null;
      return aW.jsx("span", { style: {
        display: "inline-block",
        minWidth: W,
        height: K,
        background: (G ? Dy : My)(H),
        borderRadius: "2px"
      } });
    }
  }
];
function Zw1({ href: Z, children: J, element: $ }) {
  let X = gH.useContext(DQ);
  if (!Z)
    return $;
  _80(X);
  let Y = X === null || X === void 0 ? void 0 : X.managers.markdownExtensions.parseArgs(Z);
  if (Y)
    return aW.jsx("a", { href: "#", onClick: (Q) => {
      Q.preventDefault(), X === null || X === void 0 || X.managers.markdownExtensions.tryExecute("click", Y);
    }, onMouseEnter: () => X === null || X === void 0 ? void 0 : X.managers.markdownExtensions.tryExecute("mouse-enter", Y), onMouseLeave: () => X === null || X === void 0 ? void 0 : X.managers.markdownExtensions.tryExecute("mouse-leave", Y), children: J });
  else if (Z[0] === "#")
    return _80(X), aW.jsx("a", { href: "#", onClick: (Q) => {
      Q.preventDefault(), X === null || X === void 0 || X.managers.snapshot.applyKey(Z.substring(1));
    }, children: J });
  else if (Z)
    return aW.jsxs("a", { href: Z, target: "_blank", rel: "noopener noreferrer", children: [J, "⤴"] });
  return J;
}
function _80(Z) {
  if (Z)
    return;
  console.warn("Markdown component requires a PluginReactContext to be set.");
}

// node_modules/molstar/lib/mol-plugin-ui/controls.js
class V80 extends I8 {
  constructor() {
    super(...arguments);
    this.state = { show: !1, label: "" }, this.update = () => {
      let Z = this.plugin.state.data, J = Z.selectQ((Q) => Q.ofTransformer(H1.Model.ModelFromTrajectory));
      if (J.length === 0) {
        this.setState({ show: !1 });
        return;
      }
      let $ = "", X = 0, Y = /* @__PURE__ */ new Set;
      for (let Q of J) {
        if (!Q.sourceRef)
          continue;
        let W = Z.cells.get(Q.sourceRef).obj;
        if (!W)
          continue;
        if (W.data.frameCount > 1) {
          if (Y.has(Q.sourceRef)) {
            this.setState({ show: !1 });
            return;
          }
          if (Y.add(Q.sourceRef), X++, !$) {
            let K = Q.transform.params.modelIndex;
            $ = `Model ${Math.round(K + 1)} / ${W.data.frameCount}`;
          }
        }
      }
      if (X > 1)
        $ = "";
      this.setState({ show: X > 0, label: $ });
    }, this.reset = () => h1.State.ApplyAction(this.plugin, {
      state: this.plugin.state.data,
      action: BI.create({ action: "reset" })
    }), this.prev = () => h1.State.ApplyAction(this.plugin, {
      state: this.plugin.state.data,
      action: BI.create({ action: "advance", by: -1 })
    }), this.next = () => h1.State.ApplyAction(this.plugin, {
      state: this.plugin.state.data,
      action: BI.create({ action: "advance", by: 1 })
    });
  }
  componentDidMount() {
    this.subscribe(this.plugin.state.data.events.changed, this.update), this.subscribe(this.plugin.behaviors.state.isAnimating, this.update);
  }
  render() {
    let Z = this.plugin.behaviors.state.isAnimating.value;
    if (!this.state.show || Z && !this.state.label || !this.plugin.config.get(W8.Viewport.ShowTrajectoryControls))
      return null;
    return T6.jsxs("div", { className: "msp-traj-controls", children: [!Z && T6.jsx(o2, { svg: cV0, title: "First Model", onClick: this.reset, disabled: Z }), !Z && T6.jsx(o2, { svg: Q10, title: "Previous Model", onClick: this.prev, disabled: Z }), !Z && T6.jsx(o2, { svg: W10, title: "Next Model", onClick: this.next, disabled: Z }), !!this.state.label && T6.jsx("span", { children: this.state.label })] });
  }
}

class I80 extends I8 {
  constructor() {
    super(...arguments);
    this.state = { isBusy: !1, show: !0, showAnimation: !1 }, this.change = (Z) => {
      if (Z.target.value === "none")
        return;
      this.update(Z.target.value);
    }, this.prev = () => {
      let Z = this.plugin.managers.snapshot, J = Z.getNextId(Z.state.current, -1);
      if (J)
        this.update(J);
    }, this.next = () => {
      let Z = this.plugin.managers.snapshot, J = Z.getNextId(Z.state.current, 1);
      if (J)
        this.update(J);
    }, this.togglePlay = () => {
      this.plugin.managers.snapshot.togglePlay();
    }, this.toggleShowAnimation = () => {
      this.setState({ showAnimation: !this.state.showAnimation });
    }, this.toggleStateAnimation = () => {
      if (this.state.isBusy)
        this.plugin.managers.animation.stop(), this.plugin.managers.markdownExtensions.audio.pause();
      else
        this.plugin.managers.animation.play(qE, {});
    };
  }
  componentDidMount() {
    this.subscribe(this.plugin.managers.snapshot.events.changed, () => this.forceUpdate()), this.subscribe(this.plugin.behaviors.state.isBusy, (Z) => this.setState({ isBusy: Z })), this.subscribe(this.plugin.behaviors.state.isAnimating, (Z) => this.setState({ isBusy: Z }));
  }
  componentWillUnmount() {
    super.componentWillUnmount();
  }
  async update(Z) {
    this.setState({ isBusy: !0 }), await h1.State.Snapshots.Apply(this.plugin, { id: Z }), this.setState({ isBusy: !1 });
  }
  get isStateTransitionPlaying() {
    return this.plugin.managers.animation.isAnimatingStateTransition;
  }
  render() {
    var Z, J;
    let $ = this.plugin.managers.snapshot, X = $.state.entries.size;
    if (!X || !this.state.show)
      return null;
    let Y = $.state.current, Q = $.state.isPlaying, W = $.getEntry(Y), K = !!(W === null || W === void 0 ? void 0 : W.snapshot.transition), G = Q || this.state.isBusy && !this.isStateTransitionPlaying;
    return T6.jsxs("div", { className: "msp-state-snapshot-viewport-controls", children: [T6.jsxs("select", { className: "msp-form-control", value: Y || "none", onChange: this.change, disabled: G, children: [!Y && T6.jsx("option", { value: "none" }, "none"), $.state.entries.valueSeq().map((H, N) => T6.jsxs("option", { value: H.snapshot.id, children: [`[${N + 1}/${X}]`, " ", H.name || new Date(H.timestamp).toLocaleString()] }, H.snapshot.id))] }), T6.jsx(o2, { svg: Q ? Ly : Fy, title: Q ? "Pause" : "Cycle States", onClick: this.togglePlay, disabled: Q ? !1 : this.state.isBusy && !this.isStateTransitionPlaying }), !Q && T6.jsxs(T6.Fragment, { children: [X > 1 && T6.jsx(o2, { svg: Q10, title: "Previous State", onClick: this.prev, disabled: G }), X > 1 && T6.jsx(o2, { svg: W10, title: "Next State", onClick: this.next, disabled: G }), K && T6.jsx(o2, { svg: IV0, className: "msp-state-snapshot-animation-button", title: "Snapshot Transition", onClick: this.toggleShowAnimation, disabled: !K, toggleState: this.state.showAnimation })] }), K && this.state.showAnimation && !Q && T6.jsxs(T6.Fragment, { children: [T6.jsxs("div", { className: "msp-state-snapshot-animation-slider msp-form-control", children: [T6.jsx(sz, { value: Math.round(100 * ((Z = $.state.currentAnimationTimeMs) !== null && Z !== void 0 ? Z : 0)) / 100, min: 0, step: uX.getMinFrameDuration(W === null || W === void 0 ? void 0 : W.snapshot), max: (J = uX.getStateTransitionDuration(W === null || W === void 0 ? void 0 : W.snapshot)) !== null && J !== void 0 ? J : 1000, onChange: () => {}, onChangeImmediate: (H) => $.setSnapshotAnimationFrame(H, !0), hideInput: !0, disabled: this.state.isBusy }), " "] }), T6.jsx(o2, { svg: this.state.isBusy ? Ly : iz, title: this.state.isBusy ? "Stop" : "Replay", onClick: this.toggleStateAnimation, toggleState: !1 })] })] });
  }
}
function Tv0() {
  var Z;
  let J = cB.useContext(DQ), [$, X] = cB.useState(0);
  cB.useEffect(() => {
    let W = J.managers.snapshot.events.changed.subscribe(() => X((K) => K + 1));
    return () => W.unsubscribe();
  }, [J]);
  let Y = J.managers.snapshot.state.current;
  if (!Y)
    return null;
  let Q = J.managers.snapshot.getEntry(Y);
  if (!((Z = Q === null || Q === void 0 ? void 0 : Q.description) === null || Z === void 0 ? void 0 : Z.trim()))
    return null;
  return T6.jsx("div", { id: "snapinfo", className: "msp-snapshot-description-wrapper", children: Q.descriptionFormat === "plaintext" && Q.description || T6.jsx(jv0, { children: Q.description }) });
}

class P80 extends I8 {
  constructor() {
    super(...arguments);
    this.state = { isEmpty: !0, isExpanded: !1, isBusy: !1, isAnimating: !1, isPlaying: !1 }, this.toggleExpanded = () => this.setState({ isExpanded: !this.state.isExpanded }), this.stop = () => {
      this.plugin.managers.animation.stop(), this.plugin.managers.snapshot.stop();
    };
  }
  componentDidMount() {
    this.subscribe(this.plugin.managers.snapshot.events.changed, () => {
      if (this.plugin.managers.snapshot.state.isPlaying)
        this.setState({ isPlaying: !0, isExpanded: !1 });
      else
        this.setState({ isPlaying: !1 });
    }), this.subscribe(this.plugin.behaviors.state.isBusy, (Z) => {
      if (Z)
        this.setState({ isBusy: !0, isExpanded: !1, isEmpty: this.plugin.state.data.tree.transforms.size < 2 });
      else
        this.setState({ isBusy: !1, isEmpty: this.plugin.state.data.tree.transforms.size < 2 });
    }), this.subscribe(this.plugin.behaviors.state.isAnimating, (Z) => {
      if (Z)
        this.setState({ isAnimating: !0, isExpanded: !1 });
      else
        this.setState({ isAnimating: !1 });
    });
  }
  render() {
    let Z = this.plugin.managers.snapshot.state.isPlaying;
    if (Z || this.state.isEmpty || this.plugin.managers.animation.isEmpty || !this.plugin.config.get(W8.Viewport.ShowAnimation))
      return null;
    let J = this.state.isAnimating;
    return T6.jsxs("div", { className: "msp-animation-viewport-controls", children: [T6.jsxs("div", { children: [T6.jsx("div", { className: "msp-semi-transparent-background" }), T6.jsx(o2, { svg: J || Z ? Ly : lV0, transparent: !0, title: J ? "Stop" : "Select Animation", onClick: J || Z ? this.stop : this.toggleExpanded, toggleState: this.state.isExpanded, disabled: J || Z ? !1 : this.state.isBusy || this.state.isPlaying || this.state.isEmpty })] }), this.state.isExpanded && !this.state.isBusy && T6.jsx("div", { className: "msp-animation-viewport-controls-select", children: T6.jsx(D20, { onStart: this.toggleExpanded }) })] });
  }
}

class C80 extends I8 {
  componentDidMount() {
    this.subscribe(this.plugin.behaviors.interaction.selectionMode, () => this.forceUpdate());
  }
  render() {
    if (!this.plugin.selectionMode)
      return null;
    return T6.jsx("div", { className: "msp-selection-viewport-controls", children: T6.jsx(C20, {}) });
  }
}

class k80 extends I8 {
  constructor() {
    super(...arguments);
    this.state = { labels: [] };
  }
  componentDidMount() {
    this.subscribe(this.plugin.behaviors.labels.highlight, (Z) => this.setState({ labels: Z.labels }));
  }
  render() {
    if (this.state.labels.length === 0)
      return null;
    return T6.jsx("div", { className: "msp-highlight-info", children: this.state.labels.map((Z, J) => {
      if (Z.indexOf(`
`) >= 0)
        return T6.jsx("div", { className: "msp-highlight-markdown-row", children: T6.jsx($P, { skipHtml: !0, children: Z }) }, "" + J);
      return T6.jsx("div", { className: "msp-highlight-simple-row", dangerouslySetInnerHTML: { __html: Z } }, "" + J);
    }) });
  }
}

class _v0 extends I8 {
  componentDidMount() {
    this.subscribe(this.plugin.state.behaviors.events.changed, () => this.forceUpdate());
  }
  render() {
    let Z = [];
    return this.plugin.customStructureControls.forEach((J, $) => {
      Z.push(T6.jsx(J, { initiallyCollapsed: this.props.initiallyCollapsed }, $));
    }), Z.length > 0 ? T6.jsx(T6.Fragment, { children: Z }) : null;
  }
}

class v80 extends I8 {
  render() {
    return T6.jsxs(T6.Fragment, { children: [T6.jsxs("div", { className: "msp-section-header", children: [T6.jsx(b6, { svg: vV0 }), "Structure Tools"] }), T6.jsx(h20, {}), T6.jsx(v20, {}), T6.jsx(m20, {}), T6.jsx(d20, {}), T6.jsx(j20, {}), this.plugin.config.get(W8.VolumeStreaming.Enabled) && T6.jsx(x20, {}), T6.jsx(y20, {}), T6.jsx(_v0, {})] });
  }
}

// node_modules/molstar/lib/mol-plugin-ui/left-panel.js
var k6 = t2(PZ(), 1);

// node_modules/molstar/lib/mol-plugin-ui/state/actions.js
var lB = t2(PZ(), 1);
class S80 extends I8 {
  get current() {
    return this.props.state.behaviors.currentObject.value;
  }
  componentDidMount() {
    this.subscribe(this.plugin.state.events.object.updated, ({ ref: Z, state: J }) => {
      let $ = this.current;
      if ($.ref !== Z || $.state !== J)
        return;
      this.forceUpdate();
    }), this.subscribe(this.plugin.state.data.actions.events.added, () => this.forceUpdate()), this.subscribe(this.plugin.state.data.actions.events.removed, () => this.forceUpdate());
  }
  render() {
    let { state: Z, nodeRef: J } = this.props, $ = Z.cells.get(J), X = Z.actions.fromCell($, this.plugin);
    if (X.length === 0)
      return null;
    let Y = $.transform.transformer.definition, Q = $.obj ? $.obj.label : Y.display && Y.display.name || Y.name;
    return lB.jsxs("div", { className: "msp-state-actions", children: [!this.props.hideHeader && lB.jsxs("div", { className: "msp-section-header", children: [lB.jsx(b6, { svg: xV0 }), " ", `Actions (${Q})`] }), X.map((W, K) => lB.jsx(U4, { state: Z, action: W, nodeRef: J, initiallyCollapsed: K === 0 ? !this.props.alwaysExpandFirst && this.props.initiallyCollapsed : this.props.initiallyCollapsed }, `${W.id}`))] });
  }
}

// node_modules/molstar/lib/mol-plugin-ui/state/snapshots.js
var a2 = t2(PZ(), 1);
var R4 = t2(J7(), 1);
class f80 extends I8 {
  render() {
    var Z;
    return a2.jsxs("div", { children: [a2.jsx(bH, { icon: Uy, title: "Plugin State" }), a2.jsx("div", { style: { marginBottom: "10px" }, children: a2.jsx(g$, { header: "Save Options", initiallyExpanded: !1, children: a2.jsx(Mg, {}) }) }), a2.jsx(Ag, {}), a2.jsx(Iv0, {}), a2.jsx(bH, { title: "Save as File", accent: "blue" }), a2.jsx(Dg, {}), ((Z = this.plugin.spec.components) === null || Z === void 0 ? void 0 : Z.remoteState) !== "none" && a2.jsx(Bg, {})] });
  }
}

class Dg extends I8 {
  constructor() {
    super(...arguments);
    this.downloadToFileJson = () => {
      var Z, J;
      (J = (Z = this.props).onAction) === null || J === void 0 || J.call(Z), h1.State.Snapshots.DownloadToFile(this.plugin, { type: "json" });
    }, this.downloadToFileZip = () => {
      var Z, J;
      (J = (Z = this.props).onAction) === null || J === void 0 || J.call(Z), h1.State.Snapshots.DownloadToFile(this.plugin, { type: "zip" });
    }, this.open = (Z) => {
      var J, $;
      if (!Z.target.files || !Z.target.files[0]) {
        this.plugin.log.error("No state file selected");
        return;
      }
      ($ = (J = this.props).onAction) === null || $ === void 0 || $.call(J), h1.State.Snapshots.OpenFile(this.plugin, { file: Z.target.files[0] });
    };
  }
  render() {
    return a2.jsxs(a2.Fragment, { children: [a2.jsxs("div", { className: "msp-flex-row", children: [a2.jsx(Z8, { icon: PI, onClick: this.downloadToFileJson, title: "Save the state description. Input data are loaded using the provided sources. Does not work if local files are used as input.", children: "State" }), a2.jsx(Z8, { icon: PI, onClick: this.downloadToFileZip, title: "Save the state including the input data.", children: "Session" }), a2.jsxs("div", { className: "msp-btn msp-btn-block msp-btn-action msp-loader-msp-btn-file", children: [a2.jsx(b6, { svg: uV0, inline: !0 }), " Open ", a2.jsx("input", { onChange: this.open, type: "file", multiple: !1, accept: ".molx,.molj" })] })] }), a2.jsxs("div", { className: "msp-help-text", style: { padding: "10px" }, children: [a2.jsx(b6, { svg: Ry }), " This is an experimental feature and stored states/sessions might not be openable in a future version."] })] });
  }
}

class Mg extends I8 {
  componentDidMount() {
    this.subscribe(this.plugin.state.snapshotParams, () => this.forceUpdate());
  }
  render() {
    return a2.jsx(iZ, { params: uX.SnapshotParams, values: this.plugin.state.snapshotParams.value, onChangeValues: this.plugin.state.setSnapshotParams });
  }
}

class Ag extends I8 {
  constructor() {
    super(...arguments);
    this.state = { params: j.getDefaultValues(Ag.Params) }, this.add = () => {
      h1.State.Snapshots.Add(this.plugin, {
        name: this.state.params.name,
        description: this.state.params.description
      });
    }, this.updateParams = (Z) => this.setState({ params: Z }), this.clear = () => {
      h1.State.Snapshots.Clear(this.plugin, {});
    };
  }
  shouldComponentUpdate(Z, J) {
    return !zN(this.props, Z) || !zN(this.state, J);
  }
  render() {
    return a2.jsx("div", { children: a2.jsx(Jw1, { parent: this }) });
  }
}
Ag.Params = {
  name: j.Text(),
  description: j.Text()
};
function Vv0(Z, J, $) {
  if (!J)
    return !1;
  return Z.managers.snapshot.state.entries.some((X) => (!$ || X.snapshot.id !== $) && X.key === J);
}
function Jw1({ parent: Z }) {
  let [J, $] = R4.useState({ key: "", name: "", description: "" }), X = () => {
    h1.State.Snapshots.Add(Z.plugin, {
      key: J.key,
      name: J.name,
      description: J.description
    }), $({ key: "", name: "", description: "" });
  }, Y = Vv0(Z.plugin, J.key);
  return a2.jsxs(a2.Fragment, { children: [a2.jsx(Pv0, { state: J, setState: $, apply: X }), a2.jsxs("div", { className: "msp-flex-row", children: [a2.jsx(o2, { onClick: Z.clear, svg: GX, title: "Remove All" }), a2.jsx(Z8, { onClick: X, icon: Y ? void 0 : hH, style: { textAlign: "right" }, commit: Y ? "off" : "on", disabled: Y, children: Y ? "Key must be unique" : "Add" })] })] });
}

class Iv0 extends I8 {
  constructor() {
    super(...arguments);
    this.state = { editingId: void 0 }, this.edit = (Z) => {
      let J = Z.currentTarget.getAttribute("data-id");
      if (!J)
        return;
      let $ = this.state.editingId;
      this.setState({ editingId: J === $ ? void 0 : J });
    }, this.doneEdit = () => this.setState({ editingId: void 0 }), this.apply = (Z) => {
      let J = Z.currentTarget.getAttribute("data-id");
      if (!J)
        return;
      h1.State.Snapshots.Apply(this.plugin, { id: J });
    }, this.remove = (Z) => {
      let J = Z.currentTarget.getAttribute("data-id");
      if (!J)
        return;
      h1.State.Snapshots.Remove(this.plugin, { id: J });
    }, this.moveUp = (Z) => {
      let J = Z.currentTarget.getAttribute("data-id");
      if (!J)
        return;
      h1.State.Snapshots.Move(this.plugin, { id: J, dir: -1 });
    }, this.moveDown = (Z) => {
      let J = Z.currentTarget.getAttribute("data-id");
      if (!J)
        return;
      h1.State.Snapshots.Move(this.plugin, { id: J, dir: 1 });
    }, this.replace = (Z) => {
      let J = Z.currentTarget.getAttribute("data-id");
      if (!J)
        return;
      h1.State.Snapshots.Replace(this.plugin, { id: J });
    };
  }
  componentDidMount() {
    this.subscribe(this.plugin.managers.snapshot.events.changed, () => this.forceUpdate());
  }
  render() {
    let Z = this.plugin.managers.snapshot.state.current, J = [];
    return this.plugin.managers.snapshot.state.entries.forEach(($) => {
      var X;
      if (J.push(a2.jsxs("li", { className: "msp-flex-row", children: [a2.jsxs(Z8, { "data-id": $.snapshot.id, onClick: this.apply, className: "msp-no-overflow", children: [a2.jsxs("span", { style: { fontWeight: $.snapshot.id === Z ? "bold" : void 0 }, children: [!!$.key && `[${$.key}] `, $.name || new Date($.timestamp).toLocaleString()] }), " ", a2.jsx("small", { children: `${$.snapshot.durationInMs ? XM($.snapshot.durationInMs, !1) : ""}` })] }), a2.jsx(o2, { svg: lX, "data-id": $.snapshot.id, title: "Edit", onClick: this.edit, flex: "28px" }), a2.jsx(o2, { svg: DE, "data-id": $.snapshot.id, title: "Move Up", onClick: this.moveUp, flex: "20px" }), a2.jsx(o2, { svg: zE, "data-id": $.snapshot.id, title: "Move Down", onClick: this.moveDown, flex: "20px" }), a2.jsx(o2, { svg: nV0, "data-id": $.snapshot.id, title: "Replace", onClick: this.replace, flex: "20px" }), a2.jsx(o2, { svg: GX, "data-id": $.snapshot.id, title: "Remove", onClick: this.remove, flex: "20px" })] }, $.snapshot.id)), this.state.editingId === $.snapshot.id)
        J.push(a2.jsx($w1, { entry: $, plugin: this.plugin, done: this.doneEdit }, `${$.snapshot.id}-edit`));
      let Y = $.image && ((X = this.plugin.managers.asset.get($.image)) === null || X === void 0 ? void 0 : X.file);
      if (Y)
        J.push(a2.jsx("li", { className: "msp-state-image-row", children: a2.jsx(Z8, { "data-id": $.snapshot.id, onClick: this.apply, children: a2.jsx("img", { draggable: !1, src: URL.createObjectURL(Y) }) }) }, `${$.snapshot.id}-image`));
    }), a2.jsx(a2.Fragment, { children: a2.jsx("ul", { style: { listStyle: "none", marginTop: "10px" }, className: "msp-state-list", children: J }) });
  }
}
function Pv0({ state: Z, setState: J, apply: $ }) {
  let X = R4.useRef(), Y = R4.useRef(), [Q, W] = R4.useState(!1);
  return a2.jsxs(a2.Fragment, { children: [a2.jsx(bY, { label: "Name", control: a2.jsx("input", { type: "text", value: Z.name, placeholder: "Name", onChange: (K) => J({ ...Z, name: K.target.value }), onKeyUp: (K) => {
    var G;
    if (K.key === "Enter")
      (G = X.current) === null || G === void 0 || G.focus();
  } }) }), a2.jsx(bY, { label: a2.jsxs(a2.Fragment, { children: ["Key", a2.jsx(D10, { show: Q, toggle: () => W((K) => !K) })] }), control: a2.jsx("input", { type: "text", ref: X, value: Z.key, placeholder: "Key (optional)", onChange: (K) => J({ ...Z, key: K.target.value }), onKeyUp: (K) => {
    var G;
    if (K.key === "Enter")
      (G = Y.current) === null || G === void 0 || G.focus();
  } }) }), Q && a2.jsx("div", { className: "msp-control-offset", children: a2.jsx(By, { description: "Optional snapshot key used to activate snapshots from descriptions, labels, etc." }) }), a2.jsx("div", { className: "msp-flex-row msp-text-area-wrapper", style: { marginBottom: 1 }, children: a2.jsx("textarea", {
    ref: Y,
    placeholder: `Markdown Description

- Use [title](#key) to link to a snapshot`,
    className: "msp-form-control",
    value: Z.description,
    onChange: (K) => J({ ...Z, description: K.target.value }),
    onKeyUp: (K) => {
      if (K.key === "Enter" && K.ctrlKey)
        $(Z);
    }
  }) })] });
}
function $w1({ entry: Z, plugin: J, done: $ }) {
  var X, Y, Q;
  let [W, K] = R4.useState({ key: (X = Z.key) !== null && X !== void 0 ? X : "", name: (Y = Z.name) !== null && Y !== void 0 ? Y : "", description: (Q = Z.description) !== null && Q !== void 0 ? Q : "", descriptionFormat: Z.descriptionFormat }), G = () => {
    J.managers.snapshot.update(Z, W), $();
  }, H = Vv0(J, W.key, Z.snapshot.id);
  return a2.jsxs(a2.Fragment, { children: [a2.jsx(Pv0, { state: W, setState: K, apply: G }), a2.jsx("div", { className: "msp-flex-row", style: { marginBottom: 1 }, children: a2.jsx(Z8, { onClick: G, icon: H ? void 0 : xK, style: { textAlign: "right" }, commit: H ? "off" : "on", disabled: H, children: H ? "Key must be unique" : "Apply" }) })] });
}

class Bg extends I8 {
  constructor() {
    super(...arguments);
    this.Params = {
      name: j.Text(),
      options: j.Group({
        description: j.Text(),
        playOnLoad: j.Boolean(!1),
        serverUrl: j.Text(this.plugin.config.get(W8.State.CurrentServer))
      })
    }, this.state = { params: j.getDefaultValues(this.Params), entries: o$(), isBusy: !1 }, this.ListOnlyParams = {
      options: j.Group({
        serverUrl: j.Text(this.plugin.config.get(W8.State.CurrentServer))
      }, { isFlat: !0 })
    }, this._mounted = !1, this.refresh = async () => {
      try {
        this.setState({ isBusy: !0 }), this.plugin.config.set(W8.State.CurrentServer, this.state.params.options.serverUrl);
        let Z = await this.plugin.runTask(this.plugin.fetch({ url: this.serverUrl("list"), type: "json" })) || [];
        Z.sort(($, X) => {
          if ($.isSticky === X.isSticky)
            return $.timestamp - X.timestamp;
          return $.isSticky ? -1 : 1;
        });
        let J = o$().asMutable();
        for (let $ of Z)
          J.set($.id, {
            ...$,
            url: this.serverUrl(`get/${$.id}`),
            removeUrl: this.serverUrl(`remove/${$.id}`)
          });
        if (this._mounted)
          this.setState({ entries: J.asImmutable(), isBusy: !1 });
      } catch (Z) {
        if (console.error(Z), this.plugin.log.error("Error fetching remote snapshots"), this._mounted)
          this.setState({ entries: o$(), isBusy: !1 });
      }
    }, this.upload = async () => {
      if (this.setState({ isBusy: !0 }), this.plugin.config.set(W8.State.CurrentServer, this.state.params.options.serverUrl), await h1.State.Snapshots.Upload(this.plugin, {
        name: this.state.params.name,
        description: this.state.params.options.description,
        playOnLoad: this.state.params.options.playOnLoad,
        serverUrl: this.state.params.options.serverUrl
      }), this.plugin.log.message("Snapshot uploaded."), this._mounted)
        this.setState({ isBusy: !1 }), this.refresh();
    }, this.fetch = async (Z) => {
      let J = Z.currentTarget.getAttribute("data-id");
      if (!J)
        return;
      let $ = this.state.entries.get(J);
      if (!$)
        return;
      this.setState({ isBusy: !0 });
      try {
        await h1.State.Snapshots.Fetch(this.plugin, { url: $.url });
      } finally {
        if (this._mounted)
          this.setState({ isBusy: !1 });
      }
    }, this.remove = async (Z) => {
      let J = Z.currentTarget.getAttribute("data-id");
      if (!J)
        return;
      let $ = this.state.entries.get(J);
      if (!$)
        return;
      this.setState({ entries: this.state.entries.remove(J) });
      try {
        await fetch($.removeUrl);
      } catch (X) {
        console.error(X);
      }
    };
  }
  componentDidMount() {
    this.refresh(), this._mounted = !0;
  }
  componentWillUnmount() {
    super.componentWillUnmount(), this._mounted = !1;
  }
  serverUrl(Z) {
    if (!Z)
      return this.state.params.options.serverUrl;
    return HR(this.state.params.options.serverUrl, Z);
  }
  render() {
    return a2.jsxs(a2.Fragment, { children: [a2.jsx(bH, { title: "Remote States", accent: "blue" }), !this.props.listOnly && a2.jsxs(a2.Fragment, { children: [a2.jsx(iZ, { params: this.Params, values: this.state.params, onEnter: this.upload, onChange: (Z) => {
      this.setState({ params: { ...this.state.params, [Z.name]: Z.value } });
    }, isDisabled: this.state.isBusy }), a2.jsxs("div", { className: "msp-flex-row", children: [a2.jsx(o2, { onClick: this.refresh, disabled: this.state.isBusy, svg: iz }), a2.jsx(Z8, { icon: bV0, onClick: this.upload, disabled: this.state.isBusy, commit: !0, children: "Upload" })] })] }), a2.jsx(Cv0, { entries: this.state.entries, isBusy: this.state.isBusy, serverUrl: this.state.params.options.serverUrl, fetch: this.fetch, remove: this.props.listOnly ? void 0 : this.remove }), this.props.listOnly && a2.jsxs("div", { style: { marginTop: "10px" }, children: [a2.jsx(iZ, { params: this.ListOnlyParams, values: this.state.params, onEnter: this.upload, onChange: (Z) => {
      this.setState({ params: { ...this.state.params, [Z.name]: Z.value } });
    }, isDisabled: this.state.isBusy }), a2.jsx("div", { className: "msp-flex-row", children: a2.jsx(Z8, { onClick: this.refresh, disabled: this.state.isBusy, icon: iz, children: "Refresh" }) })] })] });
  }
}

class Cv0 extends N7 {
  constructor() {
    super(...arguments);
    this.open = async (Z) => {
      let J = Z.currentTarget.getAttribute("data-id");
      if (!J)
        return;
      let $ = this.props.entries.get(J);
      if (!$)
        return;
      Z.preventDefault();
      let X = `${window.location}`, Y = X.indexOf("?");
      if (Y > 0)
        X = X.substr(0, Y);
      window.open(`${X}?snapshot-url=${encodeURIComponent($.url)}`, "_blank");
    };
  }
  render() {
    return a2.jsx("ul", { style: { listStyle: "none", marginTop: "10px" }, className: "msp-state-list", children: this.props.entries.valueSeq().map((Z) => a2.jsxs("li", { className: "msp-flex-row", children: [a2.jsxs(Z8, { "data-id": Z.id, onClick: this.props.fetch, disabled: this.props.isBusy, onContextMenu: this.open, title: "Click to download, right-click to open in a new tab.", children: [Z.name || new Date(Z.timestamp).toLocaleString(), " ", a2.jsx("small", { children: Z.description })] }), !Z.isSticky && this.props.remove && a2.jsx(o2, { svg: GX, "data-id": Z.id, title: "Remove", onClick: this.props.remove, disabled: this.props.isBusy, small: !0 })] }, Z.id)) });
  }
}

// node_modules/molstar/lib/mol-plugin-ui/state/tree.js
var f9 = t2(PZ(), 1);
class wg extends I8 {
  constructor() {
    super(...arguments);
    this.state = { showActions: !0 };
  }
  componentDidMount() {
    this.subscribe(this.plugin.state.events.cell.created, (Z) => {
      if (Z.cell.transform.parent === D8.RootRef)
        this.forceUpdate();
    }), this.subscribe(this.plugin.state.events.cell.removed, (Z) => {
      if (Z.parent === D8.RootRef)
        this.forceUpdate();
    });
  }
  static getDerivedStateFromProps(Z, J) {
    let $ = Z.state.tree.root.ref, Y = Z.state.tree.children.get($).size === 0;
    if (J.showActions === Y)
      return null;
    return { showActions: Y };
  }
  render() {
    let Z = this.props.state.tree.root.ref;
    if (this.state.showActions)
      return f9.jsxs("div", { style: { margin: "10px", cursor: "default" }, children: [f9.jsx("p", { children: "Nothing to see here yet." }), f9.jsxs("p", { children: ["Structures and Volumes can be loaded from the ", f9.jsx(b6, { svg: CI }), " tab."] })] });
    return f9.jsx(mH, { cell: this.props.state.cells.get(Z), depth: 0 });
  }
}

class mH extends I8 {
  constructor() {
    super(...arguments);
    this.state = {
      isCollapsed: !!this.props.cell.state.isCollapsed,
      isNull: mH.isNull(this.props.cell),
      showLabel: mH.showLabel(this.props.cell)
    };
  }
  is(Z) {
    return Z.ref === this.ref && Z.state === this.props.cell.parent;
  }
  get ref() {
    return this.props.cell.transform.ref;
  }
  componentDidMount() {
    this.subscribe(this.plugin.state.events.cell.stateUpdated, (Z) => {
      if (this.props.cell === Z.cell && this.is(Z) && Z.state.cells.has(this.ref)) {
        if (this.state.isCollapsed !== !!Z.cell.state.isCollapsed || this.state.isNull !== mH.isNull(Z.cell) || this.state.showLabel !== mH.showLabel(Z.cell))
          this.forceUpdate();
      }
    }), this.subscribe(this.plugin.state.events.cell.created, (Z) => {
      if (this.props.cell.parent === Z.state && this.ref === Z.cell.transform.parent)
        this.forceUpdate();
    }), this.subscribe(this.plugin.state.events.cell.removed, (Z) => {
      if (this.props.cell.parent === Z.state && this.ref === Z.parent)
        this.forceUpdate();
    });
  }
  static getDerivedStateFromProps(Z, J) {
    let $ = mH.isNull(Z.cell), X = mH.showLabel(Z.cell);
    if (!!Z.cell.state.isCollapsed === J.isCollapsed && J.isNull === $ && J.showLabel === X)
      return null;
    return { isCollapsed: !!Z.cell.state.isCollapsed, isNull: $, showLabel: X };
  }
  static hasDecorator(Z) {
    var J;
    let $ = Z.parent.tree.children.get(Z.transform.ref);
    if ($.size !== 1)
      return !1;
    let X = $.first();
    return !!X && !!((J = Z.parent) === null || J === void 0 ? void 0 : J.tree.transforms.get(X).transformer.definition.isDecorator);
  }
  static isNull(Z) {
    return !Z || !Z.parent || Z.obj === LZ.Null || !Z.parent.tree.transforms.has(Z.transform.ref);
  }
  static showLabel(Z) {
    return Z.transform.ref !== D8.RootRef && (Z.status !== "ok" || !Z.state.isGhost && !mH.hasDecorator(Z));
  }
  render() {
    if (this.state.isNull)
      return null;
    let Z = this.props.cell, J = Z.parent.tree.children.get(this.ref);
    if (!this.state.showLabel) {
      if (J.size === 0)
        return null;
      return f9.jsx(f9.Fragment, { children: J.map((X) => f9.jsx(mH, { cell: Z.parent.cells.get(X), depth: this.props.depth }, X)) });
    }
    let $ = this.props.depth + 1;
    return f9.jsxs(f9.Fragment, { children: [f9.jsx(kv0, { cell: Z, depth: this.props.depth }), J.size === 0 ? void 0 : f9.jsx("div", { style: { display: this.state.isCollapsed ? "none" : "block" }, children: J.map((X) => f9.jsx(mH, { cell: Z.parent.cells.get(X), depth: $ }, X)) })] });
  }
}

class kv0 extends I8 {
  constructor() {
    super(...arguments);
    this.state = {
      isCurrent: this.props.cell.parent.current === this.ref,
      isCollapsed: !!this.props.cell.state.isCollapsed,
      action: void 0,
      currentAction: void 0
    }, this.setCurrent = (Z) => {
      Z === null || Z === void 0 || Z.preventDefault(), Z === null || Z === void 0 || Z.currentTarget.blur(), h1.State.SetCurrentObject(this.plugin, { state: this.props.cell.parent, ref: this.ref });
    }, this.setCurrentRoot = (Z) => {
      if (Z === null || Z === void 0 || Z.preventDefault(), Z === null || Z === void 0 || Z.currentTarget.blur(), !this.props.cell.parent)
        return;
      h1.State.SetCurrentObject(this.plugin, { state: this.props.cell.parent, ref: D8.RootRef });
    }, this.remove = (Z) => {
      Z === null || Z === void 0 || Z.preventDefault(), h1.State.RemoveObject(this.plugin, { state: this.props.cell.parent, ref: this.ref, removeParentGhosts: !0 });
    }, this.toggleVisible = (Z) => {
      Z.preventDefault(), h1.State.ToggleVisibility(this.plugin, { state: this.props.cell.parent, ref: this.ref }), Z.currentTarget.blur();
    }, this.toggleExpanded = (Z) => {
      Z.preventDefault(), h1.State.ToggleExpanded(this.plugin, { state: this.props.cell.parent, ref: this.ref }), Z.currentTarget.blur();
    }, this.highlight = (Z) => {
      Z.preventDefault(), h1.Interactivity.Object.Highlight(this.plugin, { state: this.props.cell.parent, ref: this.ref }), Z.currentTarget.blur();
    }, this.clearHighlight = (Z) => {
      Z.preventDefault(), h1.Interactivity.ClearHighlights(this.plugin), Z.currentTarget.blur();
    }, this.hideApply = () => {
      this.setCurrentRoot();
    }, this.selectAction = (Z) => {
      if (!Z)
        return;
      (Z === null || Z === void 0 ? void 0 : Z.value)();
    };
  }
  is(Z) {
    return Z.ref === this.ref && Z.state === this.props.cell.parent;
  }
  get ref() {
    return this.props.cell.transform.ref;
  }
  componentDidMount() {
    this.subscribe(this.plugin.state.events.cell.stateUpdated.pipe(fN((Z) => this.is(Z)), QR(33)), (Z) => {
      this.forceUpdate();
    }), this.subscribe(this.props.cell.parent.behaviors.currentObject, (Z) => {
      if (!this.is(Z)) {
        if (this.state.isCurrent && Z.state.transforms.has(this.ref))
          this._setCurrent(this.props.cell.parent.current === this.ref, this.state.isCollapsed);
        return;
      }
      if (Z.state.transforms.has(this.ref))
        this._setCurrent(this.props.cell.parent.current === this.ref, !!this.props.cell.state.isCollapsed);
    });
  }
  _setCurrent(Z, J) {
    if (Z)
      this.setState({ isCurrent: Z, action: "options", currentAction: void 0, isCollapsed: J });
    else
      this.setState({ isCurrent: Z, action: void 0, currentAction: void 0, isCollapsed: J });
  }
  static getDerivedStateFromProps(Z, J) {
    let $ = Z.cell.parent.current === Z.cell.transform.ref, X = !!Z.cell.state.isCollapsed;
    if (J.isCollapsed === X && J.isCurrent === $)
      return null;
    return { isCurrent: $, isCollapsed: X, action: void 0, currentAction: void 0 };
  }
  get actions() {
    let Z = this.props.cell, J = [...Z.parent.actions.fromCell(Z, this.plugin)];
    if (J.length === 0)
      return;
    return J.sort(($, X) => $.definition.display.name < X.definition.display.name ? -1 : $.definition.display.name === X.definition.display.name ? 0 : 1), [
      w8.Header("Apply Action"),
      ...J.map(($) => w8.Item($.definition.display.name, () => this.setState({ action: "apply", currentAction: $ })))
    ];
  }
  updates(Z) {
    let J = this.props.cell, $ = GR.getDecoratorChain(J.parent, J.transform.ref), X = [];
    for (let Y = $.length - 1;Y >= 0; Y--) {
      let Q = $[Y];
      X.push(f9.jsx(oW, { state: J.parent, transform: Q.transform, noMargin: !0, wrapInExpander: !0, expanderHeaderLeftMargin: Z }, `${Q.transform.transformer.id}-${Y}`));
    }
    return f9.jsx("div", { className: "msp-tree-updates-wrapper", children: X });
  }
  render() {
    let Z = this.props.cell, J = Z.transform;
    if (!Z)
      return null;
    let $ = this.is(Z.parent.behaviors.currentObject.value), X = Z.status !== "error" && Z.status !== "ok", Y;
    if (Z.status === "error" || !Z.obj) {
      let U = Z.status === "error" ? Z.errorText : J.transformer.definition.display.name;
      Y = f9.jsxs(Z8, { className: "msp-btn-tree-label msp-no-hover-outline", noOverflow: !0, title: U, onClick: this.state.isCurrent ? this.setCurrentRoot : this.setCurrent, disabled: X, children: [Z.status === "error" && f9.jsxs("b", { children: ["[", Z.status, "]"] }), " ", f9.jsx("span", { children: U })] });
    } else {
      let U = Z.obj, F = `${U.label} ${U.description ? U.description : ""}`;
      Y = f9.jsxs(Z8, { className: `msp-btn-tree-label msp-type-class-${U.type.typeClass}`, noOverflow: !0, disabled: X, title: F, onClick: this.state.isCurrent ? this.setCurrentRoot : this.setCurrent, children: [f9.jsx("span", { children: U.label }), " ", U.description ? f9.jsx("small", { children: U.description }) : void 0] });
    }
    let Q = Z.parent.tree.children.get(this.ref), W = Z.state, K = f9.jsx(o2, { svg: W.isCollapsed ? $W : JW, flex: "20px", disabled: X, onClick: this.toggleExpanded, transparent: !0, className: "msp-no-hover-outline", style: { visibility: Q.size > 0 ? "visible" : "hidden" } }), G = !Z.state.isLocked ? f9.jsx(o2, { svg: GX, onClick: this.remove, disabled: X, small: !0, toggleState: !1 }) : void 0, H = f9.jsx(o2, { svg: W.isHidden ? yK : b5, toggleState: !1, disabled: X, small: !0, onClick: this.toggleVisible }), N = {
      marginLeft: `${this.props.depth * 8}px`
    }, q = f9.jsxs("div", { className: `msp-flex-row msp-tree-row${$ ? " msp-tree-row-current" : ""}`, onMouseEnter: this.highlight, onMouseLeave: this.clearHighlight, style: N, children: [K, Y, G, H] });
    if (!$)
      return q;
    if (this.state.action === "apply" && this.state.currentAction)
      return f9.jsxs("div", { style: { marginBottom: "1px" }, children: [q, f9.jsx(zQ, { header: `Apply ${this.state.currentAction.definition.display.name}`, initialExpanded: !0, hideExpander: !0, hideOffset: !1, onHeaderClick: this.hideApply, topRightIcon: cW, headerLeftMargin: `${this.props.depth * 8 + 21}px`, children: f9.jsx(U4, { onApply: this.hideApply, state: this.props.cell.parent, action: this.state.currentAction, nodeRef: this.props.cell.transform.ref, hideHeader: !0, noMargin: !0 }) })] });
    if (this.state.action === "options") {
      let U = this.actions, F = this.updates(`${this.props.depth * 8 + 21}px`);
      return f9.jsxs("div", { style: { marginBottom: "1px" }, children: [q, F, U && f9.jsx("div", { style: { marginLeft: `${this.props.depth * 8 + 21}px`, marginTop: "-1px" }, children: f9.jsx(w8, { items: U, onSelect: this.selectAction }) })] });
    }
    return q;
  }
}

// node_modules/molstar/lib/mol-plugin-ui/left-panel.js
class vv0 extends I8 {
  componentDidMount() {
    this.subscribe(this.plugin.state.behaviors.events.changed, () => this.forceUpdate());
  }
  render() {
    let Z = [];
    return this.plugin.customImportControls.forEach((J, $) => {
      Z.push(k6.jsx(J, { initiallyCollapsed: this.props.initiallyCollapsed }, $));
    }), Z.length > 0 ? k6.jsx(k6.Fragment, { children: Z }) : null;
  }
}

class h80 extends I8 {
  constructor() {
    var Z;
    super(...arguments);
    this.state = { tab: this.plugin.behaviors.layout.leftPanelTabName.value }, this.set = (J) => {
      if (this.state.tab === J) {
        this.setState({ tab: "none" }, () => this.plugin.behaviors.layout.leftPanelTabName.next("none")), h1.Layout.Update(this.plugin, { state: { regionState: { ...this.plugin.layout.state.regionState, left: "collapsed" } } });
        return;
      }
      if (this.setState({ tab: J }, () => this.plugin.behaviors.layout.leftPanelTabName.next(J)), this.plugin.layout.state.regionState.left !== "full")
        h1.Layout.Update(this.plugin, { state: { regionState: { ...this.plugin.layout.state.regionState, left: "full" } } });
    }, this.tabs = {
      none: k6.jsx(k6.Fragment, {}),
      root: k6.jsxs(k6.Fragment, { children: [k6.jsx(bH, { icon: CI, title: "Home" }), k6.jsx(S80, { state: this.plugin.state.data, nodeRef: D8.RootRef, hideHeader: !0, initiallyCollapsed: !0, alwaysExpandFirst: !0 }), k6.jsx(vv0, {}), ((Z = this.plugin.spec.components) === null || Z === void 0 ? void 0 : Z.remoteState) !== "none" && k6.jsx(Bg, { listOnly: !0 })] }),
      data: k6.jsxs(k6.Fragment, { children: [k6.jsx(bH, { icon: J10, title: k6.jsxs(k6.Fragment, { children: [k6.jsx(hv0, {}), " State Tree"] }) }), k6.jsx(wg, { state: this.plugin.state.data })] }),
      states: k6.jsx(f80, {}),
      settings: k6.jsxs(k6.Fragment, { children: [k6.jsx(bH, { icon: lX, title: "Plugin Settings" }), k6.jsx(fv0, {})] }),
      help: k6.jsxs(k6.Fragment, { children: [k6.jsx(bH, { icon: OQ, title: "Help" }), k6.jsx(P20, {})] })
    };
  }
  componentDidMount() {
    this.subscribe(this.plugin.behaviors.layout.leftPanelTabName, (Z) => {
      if (this.state.tab !== Z)
        this.setState({ tab: Z });
      if (Z === "none" && this.plugin.layout.state.regionState.left !== "collapsed")
        h1.Layout.Update(this.plugin, { state: { regionState: { ...this.plugin.layout.state.regionState, left: "collapsed" } } });
    }), this.subscribe(this.plugin.state.data.events.changed, ({ state: Z }) => {
      if (this.state.tab !== "data")
        return;
      if (Z.cells.size === 1)
        this.set("root");
    });
  }
  render() {
    let Z = this.state.tab;
    return k6.jsxs("div", { className: "msp-left-panel-controls", children: [k6.jsxs("div", { className: "msp-left-panel-controls-buttons", children: [k6.jsx(o2, { svg: CI, toggleState: Z === "root", transparent: !0, onClick: () => this.set("root"), title: "Home" }), k6.jsx(Sv0, { set: this.set }), k6.jsx(o2, { svg: Uy, toggleState: Z === "states", transparent: !0, onClick: () => this.set("states"), title: "Plugin State" }), k6.jsx(o2, { svg: OQ, toggleState: Z === "help", transparent: !0, onClick: () => this.set("help"), title: "Help" }), k6.jsx("div", { className: "msp-left-panel-controls-buttons-bottom", children: k6.jsx(o2, { svg: lX, toggleState: Z === "settings", transparent: !0, onClick: () => this.set("settings"), title: "Settings" }) })] }), k6.jsx("div", { className: "msp-scrollable-container", children: this.tabs[Z] })] });
  }
}

class Sv0 extends I8 {
  constructor() {
    super(...arguments);
    this.state = { changed: !1 };
  }
  get tab() {
    return this.plugin.behaviors.layout.leftPanelTabName.value;
  }
  componentDidMount() {
    this.subscribe(this.plugin.behaviors.layout.leftPanelTabName, (Z) => {
      if (this.tab === "data")
        this.setState({ changed: !1 });
      else
        this.forceUpdate();
    }), this.subscribe(this.plugin.state.data.events.changed, (Z) => {
      if (this.tab !== "data")
        this.setState({ changed: !0 });
    });
  }
  render() {
    return k6.jsx(o2, { svg: J10, toggleState: this.tab === "data", transparent: !0, onClick: () => this.props.set("data"), title: "State Tree", style: { position: "relative" }, extraContent: this.state.changed ? k6.jsx("div", { className: "msp-left-panel-controls-button-data-dirty" }) : void 0 });
  }
}

class fv0 extends I8 {
  constructor() {
    super(...arguments);
    this.setSettings = (Z) => {
      h1.Canvas3D.SetSettings(this.plugin, { settings: { [Z.name]: Z.value } });
    }, this.setCanvas3DContextProps = (Z) => {
      var J;
      (J = this.plugin.canvas3dContext) === null || J === void 0 || J.setProps({ [Z.name]: Z.value }), this.plugin.events.canvas3d.settingsUpdated.next(void 0);
    };
  }
  componentDidMount() {
    if (this.subscribe(this.plugin.events.canvas3d.settingsUpdated, () => this.forceUpdate()), this.subscribe(this.plugin.layout.events.updated, () => this.forceUpdate()), this.plugin.canvas3d)
      this.subscribe(this.plugin.canvas3d.camera.stateChanged.pipe(bQ(500, void 0, { leading: !0, trailing: !0 })), (Z) => {
        if (Z.radiusMax !== void 0 || Z.radius !== void 0)
          this.forceUpdate();
      });
  }
  render() {
    return k6.jsxs(k6.Fragment, { children: [this.plugin.canvas3d && this.plugin.canvas3dContext && k6.jsxs(k6.Fragment, { children: [k6.jsx(bH, { title: "Viewport" }), k6.jsx(iZ, { params: J$, values: this.plugin.canvas3d.props, onChange: this.setSettings }), k6.jsx(iZ, { params: a3.Params, values: this.plugin.canvas3dContext.props, onChange: this.setCanvas3DContextProps })] }), k6.jsx(bH, { title: "Behavior" }), k6.jsx(wg, { state: this.plugin.state.behaviors })] });
  }
}

class hv0 extends I8 {
  constructor() {
    super(...arguments);
    this.remove = (Z) => {
      Z.preventDefault(), h1.State.RemoveObject(this.plugin, { state: this.plugin.state.data, ref: D8.RootRef });
    };
  }
  componentDidMount() {
    this.subscribe(this.plugin.state.events.cell.created, (Z) => {
      if (Z.cell.transform.parent === D8.RootRef)
        this.forceUpdate();
    }), this.subscribe(this.plugin.state.events.cell.removed, (Z) => {
      if (Z.parent === D8.RootRef)
        this.forceUpdate();
    });
  }
  render() {
    if (this.plugin.state.data.tree.children.get(D8.RootRef).size === 0)
      return null;
    return k6.jsx(o2, { svg: GX, onClick: this.remove, title: "Remove All", style: { display: "inline-block" }, small: !0, className: "msp-no-hover-outline", transparent: !0 });
  }
}

// node_modules/molstar/lib/mol-plugin-ui/sequence.js
var zJ = t2(PZ(), 1), mv0 = t2(J7(), 1);

// node_modules/molstar/lib/mol-plugin-ui/sequence/sequence.js
var jg = t2(PZ(), 1), xv0 = t2(J7(), 1);
var bv0 = 5, b80 = {
  selected: "rgb(51, 255, 25)",
  highlighted: "rgb(255, 102, 153)",
  focused: ""
};

class x80 extends I8 {
  constructor() {
    super(...arguments);
    this.parentDiv = xv0.createRef(), this.lastMouseOverSeqIdx = -1, this.highlightQueue = new P6, this.markerColors = { ...b80 }, this.customColorThemeWrapper = void 0, this.customColorFunction = void 0, this.lociHighlightProvider = (Z, J) => {
      if (this.props.sequenceWrapper.markResidue(Z.loci, J))
        this.updateMarker();
    }, this.lociSelectionProvider = (Z, J) => {
      if (this.props.sequenceWrapper.markResidue(Z.loci, J))
        this.updateMarker();
    }, this.contextMenu = (Z) => {
      Z.preventDefault();
    }, this.mouseDownLoci = void 0, this.mouseDown = (Z) => {
      Z.stopPropagation();
      let J = this.getSeqIdx(Z), $ = this.getLoci(J);
      this.mouseDownLoci = $;
    }, this.mouseUp = (Z) => {
      if (Z.stopPropagation(), this.mouseDownLoci === void 0)
        return;
      let J = this.getSeqIdx(Z), $ = this.getLoci(J);
      if ($) {
        let X = gz(Z.nativeEvent), Y = oA(Z.nativeEvent), Q = Yx(Z.nativeEvent), W = $;
        if (!W0.Loci.areEqual(this.mouseDownLoci, $)) {
          let K = this.mouseDownLoci.elements[0], G = $.elements[0], H = Math.min(f0.min(K.indices), f0.min(G.indices)), N = Math.max(f0.max(K.indices), f0.max(G.indices));
          W = W0.Loci($.structure, [{
            unit: K.unit,
            indices: f0.ofRange(H, N)
          }]);
        }
        this.click(W, X, Y, Q);
      }
      this.mouseDownLoci = void 0;
    }, this.location = W0.Location.create(void 0), this.mouseMove = (Z) => {
      Z.stopPropagation();
      let J = gz(Z.nativeEvent), $ = oA(Z.nativeEvent), X = Yx(Z.nativeEvent), Y = Z.target;
      if (!Y || !Y.getAttribute) {
        if (this.lastMouseOverSeqIdx === -1)
          return;
        this.lastMouseOverSeqIdx = -1, this.highlightQueue.next({ seqIdx: -1, buttons: J, button: $, modifiers: X });
        return;
      }
      let Q = Y.hasAttribute("data-seqid") ? +Y.getAttribute("data-seqid") : -1;
      if (this.lastMouseOverSeqIdx === Q)
        return;
      else if (this.lastMouseOverSeqIdx = Q, this.mouseDownLoci !== void 0) {
        let W = this.getLoci(Q);
        this.hover(W, V8.Flag.None, V8.Flag.None, X);
      } else
        this.highlightQueue.next({ seqIdx: Q, buttons: J, button: $, modifiers: X });
    }, this.mouseLeave = (Z) => {
      if (Z.stopPropagation(), this.mouseDownLoci = void 0, this.lastMouseOverSeqIdx === -1)
        return;
      this.lastMouseOverSeqIdx = -1;
      let J = gz(Z.nativeEvent), $ = oA(Z.nativeEvent), X = Yx(Z.nativeEvent);
      this.highlightQueue.next({ seqIdx: -1, buttons: J, button: $, modifiers: X });
    };
  }
  get sequenceNumberPeriod() {
    if (this.props.sequenceNumberPeriod !== void 0)
      return this.props.sequenceNumberPeriod;
    if (this.props.sequenceWrapper.length > 10)
      return 10;
    if (this.getSequenceNumber(this.props.sequenceWrapper.length - 1).length > 1)
      return 5;
    return 1;
  }
  componentDidMount() {
    this.plugin.managers.interactivity.lociHighlights.addProvider(this.lociHighlightProvider), this.plugin.managers.interactivity.lociSelects.addProvider(this.lociSelectionProvider), this.subscribe(this.highlightQueue.pipe(bQ(49.998000000000005, void 0, { leading: !0, trailing: !0 })), (J) => {
      let $ = this.getLoci(J.seqIdx < 0 ? void 0 : J.seqIdx);
      this.hover($, J.buttons, J.button, J.modifiers);
    }), this.subscribe(this.plugin.managers.structure.focus.behaviors.current, (J) => {
      this.updateFocus(J === null || J === void 0 ? void 0 : J.loci), this.updateMarker();
    }), this.updateColors(), h1.Canvas3D.SetSettings.subscribe(this.plugin, () => {
      this.updateColors(), this.updateMarker();
    });
    let Z = this.plugin.customUIState.experimentalSequenceColorTheme;
    if (Z)
      this.subscribe(Z, (J) => {
        if (!J && !this.customColorThemeWrapper)
          return;
        this.customColorThemeWrapper = Xw1(this.plugin, J, () => this.forceUpdate()), this.forceUpdate();
      });
  }
  updateColors() {
    if (this.plugin.canvas3d)
      this.markerColors.highlighted = i0.toHexStyle(this.plugin.canvas3d.props.renderer.highlightColor), this.markerColors.selected = i0.toHexStyle(this.plugin.canvas3d.props.renderer.selectColor);
    else
      this.markerColors.highlighted = b80.highlighted, this.markerColors.selected = b80.selected;
  }
  updateFocus(Z) {
    if (this.props.sequenceWrapper.markResidue(nN, "unfocus"), Z)
      this.props.sequenceWrapper.markResidue(Z, "focus");
  }
  componentWillUnmount() {
    super.componentWillUnmount(), this.plugin.managers.interactivity.lociHighlights.removeProvider(this.lociHighlightProvider), this.plugin.managers.interactivity.lociSelects.removeProvider(this.lociSelectionProvider);
  }
  getLoci(Z) {
    if (Z !== void 0) {
      let J = this.props.sequenceWrapper.getLoci(Z);
      if (!W0.Loci.isEmpty(J))
        return J;
    }
  }
  getSeqIdx(Z) {
    let J = void 0, $ = Z.target;
    if ($ && $.getAttribute)
      J = $.hasAttribute("data-seqid") ? +$.getAttribute("data-seqid") : void 0;
    return J;
  }
  hover(Z, J, $, X) {
    let Y = { current: V2.Loci.Empty, buttons: J, button: $, modifiers: X };
    if (Z !== void 0 && !W0.Loci.isEmpty(Z)) {
      if (Y.current = { loci: Z }, this.mouseDownLoci) {
        let Q = this.mouseDownLoci.elements[0], W = Z.elements[0], K = Math.min(f0.min(Q.indices), f0.min(W.indices)), G = Math.max(f0.max(Q.indices), f0.max(W.indices)), H = W0.Loci(Z.structure, [{
          unit: Q.unit,
          indices: f0.ofRange(K, G)
        }]);
        Y.current = { loci: H };
      }
    }
    this.plugin.behaviors.interaction.hover.next(Y);
  }
  click(Z, J, $, X) {
    let Y = { current: V2.Loci.Empty, buttons: J, button: $, modifiers: X };
    if (Z !== void 0 && !W0.Loci.isEmpty(Z))
      Y.current = { loci: Z };
    this.plugin.behaviors.interaction.click.next(Y);
  }
  getBackgroundColor(Z) {
    let J = this.props.sequenceWrapper;
    if (J.isHighlighted(Z) && this.markerColors.highlighted)
      return this.markerColors.highlighted;
    if (J.isSelected(Z) && this.markerColors.selected)
      return this.markerColors.selected;
    if (J.isFocused(Z) && this.markerColors.focused)
      return this.markerColors.focused;
    if (this.customColorFunction)
      return this.customColorFunction(Z);
    return "";
  }
  getResidueClass(Z, J) {
    let $ = this.props.sequenceWrapper, X = [$.residueClass(Z)];
    if (J.length > 1)
      X.push(Z === 0 ? "msp-sequence-residue-long-begin" : "msp-sequence-residue-long");
    if ($.isHighlighted(Z))
      X.push("msp-sequence-residue-highlighted");
    if ($.isSelected(Z))
      X.push("msp-sequence-residue-selected");
    if ($.isFocused(Z))
      X.push("msp-sequence-residue-focused");
    return X.join(" ");
  }
  residue(Z, J) {
    return jg.jsx("span", { "data-seqid": Z, style: { backgroundColor: this.getBackgroundColor(Z) }, className: this.getResidueClass(Z, J), children: `​${J}​` }, Z);
  }
  getSequenceNumberClass(Z, J, $) {
    let X = ["msp-sequence-number"];
    if (J.startsWith("-"))
      if ($.length > 1 && Z > 0)
        X.push("msp-sequence-number-long-negative");
      else
        X.push("msp-sequence-number-negative");
    else if ($.length > 1 && Z > 0)
      X.push("msp-sequence-number-long");
    return X.join(" ");
  }
  getSequenceNumber(Z) {
    let J = "", $ = this.props.sequenceWrapper.getLoci(Z), X = W0.Loci.getFirstLocation($, this.location);
    if (X) {
      if (j0.isAtomic(X.unit)) {
        let Y = w1.residue.auth_seq_id(X), Q = w1.residue.pdbx_PDB_ins_code(X);
        J = `${Y}${Q ? Q : ""}`;
      } else if (j0.isCoarse(X.unit))
        J = `${Z + 1}`;
    }
    return J;
  }
  padSeqNum(Z) {
    if (Z.length < bv0)
      return Z + new Array(bv0 - Z.length + 1).join(" ");
    return Z;
  }
  getSequenceNumberSpan(Z, J) {
    let $ = this.getSequenceNumber(Z);
    return jg.jsx("span", { className: this.getSequenceNumberClass(Z, $, J), children: this.padSeqNum($) }, `marker-${Z}`);
  }
  updateMarker() {
    if (!this.parentDiv.current)
      return;
    let Z = this.parentDiv.current.children, J = !this.props.hideSequenceNumbers, $ = this.sequenceNumberPeriod, X = this.props.sequenceWrapper, Y = X.length, Q = 0;
    for (let W = 0;W < Y; W++) {
      if (J && W % $ === 0 && W < Y)
        Q++;
      let K = Z[Q];
      if (!K)
        return;
      Q++;
      let G = this.getResidueClass(W, X.residueLabel(W));
      if (K.className !== G)
        K.className = G;
      let H = this.getBackgroundColor(W);
      if (K.style.backgroundColor !== H)
        K.style.backgroundColor = H;
    }
  }
  render() {
    var Z;
    let J = this.props.sequenceWrapper, $ = [];
    if (this.customColorThemeWrapper)
      this.customColorFunction = this.customColorThemeWrapper.getColorFunction(J);
    let X = !this.props.hideSequenceNumbers, Y = this.sequenceNumberPeriod;
    for (let Q = 0, W = J.length;Q < W; ++Q) {
      let K = J.residueLabel(Q);
      if (X && Q % Y === 0 && Q < W)
        $[$.length] = this.getSequenceNumberSpan(Q, K);
      $[$.length] = this.residue(Q, K);
    }
    return this.updateFocus((Z = this.plugin.managers.structure.focus.behaviors.current.value) === null || Z === void 0 ? void 0 : Z.loci), this.updateMarker(), jg.jsx("div", { className: "msp-sequence-wrapper", onContextMenu: this.contextMenu, onMouseDown: this.mouseDown, onMouseUp: this.mouseUp, onMouseMove: this.mouseMove, onMouseLeave: this.mouseLeave, ref: this.parentDiv, children: $ });
  }
}
function Xw1(Z, J, $) {
  let X = W0.Location.create();
  function Y(W, K, G) {
    let H = W.getLoci(K);
    if (!H || W0.Loci.isEmpty(H))
      return "";
    W0.Loci.getFirstLocation(H, X);
    let N = G(X, !1);
    if (N < 0)
      return "";
    return i0.toHexStyle(N);
  }
  let Q = cJ((W) => {
    var K, G, H;
    if (!J)
      return;
    let N = (K = W.getLoci(0)) === null || K === void 0 ? void 0 : K.structure;
    if (!N)
      return;
    let q = void 0, U = (H = (G = J.getProps) === null || G === void 0 ? void 0 : G.call(J, { structure: N })) !== null && H !== void 0 ? H : J.provider.defaultValues;
    if (J.provider.ensureCustomProperties)
      Z.runTask(n0.create("Attach custom properties for coloring theme", async (E) => {
        var R;
        try {
          await ((R = J.provider.ensureCustomProperties) === null || R === void 0 ? void 0 : R.attach({ assetManager: Z.managers.asset, runtime: E }, { structure: N }));
        } catch (z) {
          console.warn(`Failed to attach custom properties needed for coloring theme ${J.provider.name}:`, z);
        } finally {
          q = J.provider.factory({ structure: N }, U).color, $();
        }
      }));
    else
      q = J.provider.factory({ structure: N }, U).color;
    let F = {};
    return (E) => {
      var R;
      if (q)
        return (R = F[E]) !== null && R !== void 0 ? R : F[E] = Y(W, E, q);
      else
        return "";
    };
  });
  return {
    themeName: J === null || J === void 0 ? void 0 : J.provider.name,
    getColorFunction: Q
  };
}

// node_modules/molstar/lib/mol-plugin-ui/sequence/wrapper.js
class CU {
  mark(Z, J) {
    let $ = this.getSeqIndices(Z);
    if (f0.size($) === 0)
      return !1;
    return yR(this.markerArray, $, J);
  }
  markResidue(Z, J) {
    if (J === "focus")
      return this.markResidueFocus(Z, !0);
    if (J === "unfocus")
      return this.markResidueFocus(Z, !1);
    if (KJ(Z))
      return yR(this.markerArray, k0.ofLength(this.length), J);
    else
      return this.mark(Z, J);
  }
  markResidueFocus(Z, J) {
    let $ = J ? 1 : 0;
    if (KJ(Z))
      return this.focusMarkerArray.fill($, 0, this.length), !0;
    else {
      let X = this.getSeqIndices(Z);
      return f0.forEach(X, (Y) => this.focusMarkerArray[Y] = $), f0.size(X) > 0;
    }
  }
  isHighlighted(Z) {
    return !!(this.markerArray[Z] & 1);
  }
  isSelected(Z) {
    return !!(this.markerArray[Z] & 2);
  }
  isFocused(Z) {
    return !!this.focusMarkerArray[Z];
  }
  constructor(Z, J) {
    this.data = Z, this.length = J, this.markerArray = new Uint8Array(J), this.focusMarkerArray = new Uint8Array(J);
  }
}

// node_modules/molstar/lib/mol-plugin-ui/sequence/polymer.js
class y80 extends CU {
  seqId(Z) {
    return this.sequence.seqId.value(Z);
  }
  residueLabel(Z) {
    return this.sequence.label.value(Z) || this.sequence.code.value(Z);
  }
  residueColor(Z) {
    return this.missing.has(this.modelNum, this.asymId, this.seqId(Z)) ? c2.grey : c2.black;
  }
  residueClass(Z) {
    return this.missing.has(this.modelNum, this.asymId, this.seqId(Z)) ? "msp-sequence-missing" : "msp-sequence-present";
  }
  getSeqIndices(Z) {
    let { structure: J } = this.data, $ = (X) => this.sequence.index(X);
    if (W0.Loci.is(Z)) {
      if (!s0.areRootsEquivalent(Z.structure, J))
        return k0.Empty;
      Z = W0.Loci.remap(Z, J);
      let X = [];
      for (let Y of Z.elements) {
        if (!this.unitMap.has(Y.unit.id))
          continue;
        if (j0.isAtomic(Y.unit))
          Qw1(X, Y, $);
        else
          Ww1(X, Y, $);
      }
      return X1.deduplicate(X1.ofSortedArray(X));
    } else if (s0.isLoci(Z)) {
      if (!s0.areRootsEquivalent(Z.structure, J))
        return k0.Empty;
      return this.observed;
    }
    return k0.Empty;
  }
  getLoci(Z) {
    let J = Yw1(this.data.units[0].chainGroupId, this.data.units[0].conformation.operator.name, this.seqId(Z));
    return f1.toLociWithSourceUnits(s_.run(J, this.data.structure));
  }
  constructor(Z) {
    let J = W0.Location.create(Z.structure, Z.units[0], Z.units[0].elements[0]), $ = Z.units[0].model.sequence.byEntityKey[w1.entity.key(J)], X = $.sequence.length;
    super(Z, X);
    this.unitMap = /* @__PURE__ */ new Map;
    for (let Q of Z.units)
      this.unitMap.set(Q.id, Q);
    this.sequence = $.sequence, this.missing = Z.units[0].model.properties.missingResidues, this.modelNum = Z.units[0].model.modelNum, this.asymId = j0.isAtomic(Z.units[0]) ? w1.chain.label_asym_id(J) : w1.coarse.asym_id(J);
    let Y = [];
    for (let Q = 0;Q < X; ++Q)
      if (this.missing.has(this.modelNum, this.asymId, this.seqId(Q)))
        Y.push(Q);
    this.observed = f0.subtract(k0.ofBounds(0, X), X1.ofSortedArray(Y));
  }
}
function Yw1(Z, J, $) {
  return OZ.generators.atoms({
    unitTest: (X) => {
      return w1.unit.chainGroupId(X.element) === Z && w1.unit.operator_name(X.element) === J;
    },
    residueTest: (X) => {
      if (X.element.unit.kind === j0.Kind.Atomic)
        return w1.residue.label_seq_id(X.element) === $;
      else
        return w1.coarse.seq_id_begin(X.element) <= $ && w1.coarse.seq_id_end(X.element) >= $;
    }
  });
}
function Qw1(Z, J, $) {
  let { model: X, elements: Y } = J.unit, { index: Q } = X.atomicHierarchy.residueAtomSegments, { label_seq_id: W } = X.atomicHierarchy.residues;
  return f0.forEachSegment(J.indices, (K) => Q[Y[K]], (K) => {
    let G = W.value(K), H = $(G);
    Z.push(H);
  }), !0;
}
function Ww1(Z, J, $) {
  let { model: X, elements: Y } = J.unit, Q = j0.isSpheres(J.unit) ? X.coarseHierarchy.spheres.seq_id_begin : X.coarseHierarchy.gaussians.seq_id_begin, W = j0.isSpheres(J.unit) ? X.coarseHierarchy.spheres.seq_id_end : X.coarseHierarchy.gaussians.seq_id_end;
  return f0.forEach(J.indices, (K) => {
    let G = Y[K];
    for (let H = $(Q.value(G)), N = $(W.value(G));H <= N; H++)
      Z.push(H);
  }), !0;
}

// node_modules/molstar/lib/mol-plugin-ui/sequence/hetero.js
class g80 extends CU {
  residueLabel(Z) {
    return this.sequence[Z];
  }
  residueColor(Z) {
    return c2.black;
  }
  residueClass(Z) {
    return "msp-sequence-present";
  }
  getSeqIndices(Z) {
    let { structure: J } = this.data;
    if (W0.Loci.is(Z)) {
      if (!s0.areRootsEquivalent(Z.structure, J))
        return k0.Empty;
      Z = W0.Loci.remap(Z, J);
      let $ = [];
      for (let X of Z.elements) {
        let Y = this.unitMap.get(X.unit.id);
        if (Y) {
          let { index: Q } = X.unit.model.atomicHierarchy.residueAtomSegments;
          f0.forEach(X.indices, (W) => {
            let K = this.sequenceIndices.get(Q[Y.elements[W]]);
            if (K !== void 0)
              $.push(K);
          });
        }
      }
      return X1.deduplicate(X1.ofSortedArray($));
    } else if (s0.isLoci(Z)) {
      if (!s0.areRootsEquivalent(Z.structure, J))
        return k0.Empty;
      return k0.ofBounds(0, this.length);
    }
    return k0.Empty;
  }
  getLoci(Z) {
    let J = [], $ = this.residueIndices.get(Z);
    if ($ !== void 0) {
      let X = this.seqToUnit.get(Z), { offsets: Y } = X.model.atomicHierarchy.residueAtomSegments, Q = X1.findPredecessorIndex(X.elements, Y[$]), W = X1.findPredecessorIndex(X.elements, Y[$ + 1]);
      J.push({ unit: X, indices: k0.ofBounds(Q, W) });
    }
    return W0.Loci(this.data.structure, J);
  }
  constructor(Z) {
    let J = [], $ = /* @__PURE__ */ new Map, X = /* @__PURE__ */ new Map, Y = /* @__PURE__ */ new Map;
    for (let W = 0, K = Z.units.length;W < K; ++W) {
      let G = Z.units[W], { residueAtomSegments: H, atoms: N } = G.model.atomicHierarchy, q = b2.transientSegments(H, G.elements);
      while (q.hasNext) {
        let { index: U } = q.move();
        $.set(U, J.length), X.set(J.length, U), Y.set(J.length, G), J.push(N.label_comp_id.value(H.offsets[U]));
      }
    }
    let Q = J.length;
    super(Z, Q);
    this.unitMap = /* @__PURE__ */ new Map;
    for (let W of Z.units)
      this.unitMap.set(W.id, W);
    this.sequence = J, this.sequenceIndices = $, this.residueIndices = X, this.seqToUnit = Y;
  }
}

// node_modules/molstar/lib/mol-plugin-ui/sequence/chain.js
class KP extends CU {
  residueLabel(Z) {
    return this.label;
  }
  residueColor(Z) {
    return c2.black;
  }
  residueClass(Z) {
    return "msp-sequence-present";
  }
  getSeqIndices(Z) {
    let { structure: J } = this.data;
    if (W0.Loci.is(Z)) {
      if (!s0.areRootsEquivalent(Z.structure, J))
        return k0.Empty;
      Z = W0.Loci.remap(Z, J);
      for (let $ of Z.elements) {
        let X = this.unitIndices.get($.unit.id);
        if (X) {
          if (f0.isSubset(X, $.indices))
            return k0.ofSingleton(0);
        }
      }
    } else if (s0.isLoci(Z)) {
      if (!s0.areRootsEquivalent(Z.structure, J))
        return k0.Empty;
      return k0.ofSingleton(0);
    }
    return k0.Empty;
  }
  getLoci(Z) {
    return this.loci;
  }
  constructor(Z) {
    let J = 0, $ = 0, X = [], Y = W0.Location.create(Z.structure), Q = /* @__PURE__ */ new Map, W = [];
    for (let G = 0, H = Z.units.length;G < H; ++G) {
      let N = Z.units[G];
      W0.Location.set(Y, Z.structure, N, N.elements[0]);
      let q = N.model.sequence.byEntityKey[w1.entity.key(Y)];
      if (q)
        J += q.sequence.length;
      $ += N.elements.length;
      let U = k0.ofBounds(0, N.elements.length);
      Q.set(N.id, U), W.push({ unit: N, indices: U });
    }
    if (J > 0)
      X.push(`${J} residues`);
    X.push(`${$} elements`);
    let K = 1;
    super(Z, K);
    this.label = `Whole Chain (${X.join(", ")})`, this.unitIndices = Q, this.loci = W0.Loci(this.data.structure, W);
  }
}

// node_modules/molstar/lib/mol-plugin-ui/sequence/element.js
class m80 extends CU {
  residueLabel(Z) {
    return "X";
  }
  residueColor(Z) {
    return c2.black;
  }
  residueClass(Z) {
    return "msp-sequence-present";
  }
  getSeqIndices(Z) {
    let { structure: J, units: $ } = this.data;
    if (W0.Loci.is(Z)) {
      if (!s0.areRootsEquivalent(Z.structure, J))
        return k0.Empty;
      Z = W0.Loci.remap(Z, J);
      for (let X of Z.elements) {
        let Y = this.unitIndices.get(X.unit.id);
        if (Y) {
          if (f0.isSubset(Y, X.indices))
            return X.indices;
        }
      }
    } else if (s0.isLoci(Z)) {
      if (!s0.areRootsEquivalent(Z.structure, J))
        return k0.Empty;
      for (let X = 0, Y = $.length;X < Y; ++X)
        return this.unitIndices.get($[X].id);
    }
    return k0.Empty;
  }
  getLoci(Z) {
    let { units: J } = this.data, $ = [], X = 0;
    for (let Y = 0, Q = J.length;Y < Q; ++Y) {
      let W = J[Y];
      if (Z < X + W.elements.length) {
        $.push({ unit: W, indices: k0.ofSingleton(Z - X) });
        break;
      }
      X += W.elements.length;
    }
    return W0.Loci(this.data.structure, $);
  }
  constructor(Z) {
    let J = 0, $ = /* @__PURE__ */ new Map, X = [];
    for (let Y = 0, Q = Z.units.length;Y < Q; ++Y) {
      let W = Z.units[Y];
      J += W.elements.length;
      let K = k0.ofBounds(0, W.elements.length);
      $.set(W.id, K), X.push({ unit: W, indices: K });
    }
    super(Z, J);
    this.unitIndices = $;
  }
}

// node_modules/molstar/lib/mol-plugin-ui/sequence.js
var d80 = 5000, u80 = 1000, Kw1 = 30;
function dv0(Z) {
  let J = w1.unit.pdbx_struct_oper_list_ids(Z), $ = w1.unit.struct_ncs_oper_id(Z), X = w1.unit.hkl(Z), Y = w1.unit.spgrOp(Z);
  return `${J.sort().join(",")}|${$}|${X}|${Y}`;
}
function c80(Z) {
  let [J, $] = Z.split("|");
  return [parseInt(J), $];
}
function yv0(Z, J) {
  let { structure: $, modelEntityId: X, chainGroupId: Y, operatorKey: Q } = Z, W = W0.Location.create($), [K, G] = c80(X), H = [];
  for (let N of $.units) {
    if (W0.Location.set(W, $, N, N.elements[0]), $.getModelIndex(N.model) !== K)
      continue;
    if (w1.entity.id(W) !== G)
      continue;
    if (N.chainGroupId !== Y)
      continue;
    if (dv0(W) !== Q)
      continue;
    H.push(N);
  }
  if (H.length > 0) {
    let N = { structure: $, units: H }, q = H[0], U;
    if (q.polymerElements.length) {
      let F = W0.Location.create($, q, q.elements[0]), E = q.model.sequence.byEntityKey[w1.entity.key(F)];
      if (E && E.sequence.length <= d80)
        U = new y80(N);
      else {
        let R = H.reduce((z, D) => z + D.polymerElements.length, 0);
        if (j0.isAtomic(q) || R > d80)
          U = new KP(N);
        else
          U = new m80(N);
      }
    } else if (j0.isAtomic(q))
      if (H.reduce((E, R) => E + R.residueCount, 0) > d80)
        U = new KP(N);
      else
        U = new g80(N);
    else
      console.warn("should not happen, expecting coarse units to be polymeric"), U = new KP(N);
    return U.markResidue(J.getLoci($), x2.Select), U;
  } else
    return "No sequence available";
}
function Tg(Z, J = !1) {
  let $ = [], X = W0.Location.create(Z), Y = /* @__PURE__ */ new Set;
  for (let Q of Z.units) {
    W0.Location.set(X, Z, Q, Q.elements[0]);
    let W = w1.entity.id(X), K = Z.getModelIndex(Q.model), G = `${K}|${W}`;
    if (Y.has(G))
      continue;
    if (J && w1.entity.type(X) !== "polymer")
      continue;
    let H = w1.entity.pdbx_description(X).join(", ");
    if (Z.models.length) {
      if (Z.representativeModel)
        H += ` (Model ${Z.models[K].modelNum})`;
      else if (H.startsWith("Polymer "))
        H += ` (${Z.models[K].entry})`;
    }
    let N = `${W}: ${H}`;
    if ($.push([G, N]), Y.add(G), $.length > u80)
      return [["", "Too many entities"]];
  }
  if ($.length === 0)
    $.push(["", "No entities"]);
  return $;
}
function GP(Z, J) {
  let $ = [], X = W0.Location.create(Z), Y = /* @__PURE__ */ new Set, [Q, W] = c80(J);
  for (let K of Z.units) {
    if (W0.Location.set(X, Z, K, K.elements[0]), Z.getModelIndex(K.model) !== Q)
      continue;
    if (w1.entity.id(X) !== W)
      continue;
    let G = K.chainGroupId;
    if (Y.has(G))
      continue;
    let H = SK(X, { granularity: "chain", hidePrefix: !0, htmlStyling: !1 });
    if ($.push([G, H]), Y.add(G), $.length > u80)
      return [[-1, "Too many chains"]];
  }
  if ($.length === 0)
    $.push([-1, "No chains"]);
  return $;
}
function nB(Z, J, $) {
  let X = [], Y = W0.Location.create(Z), Q = /* @__PURE__ */ new Set, [W, K] = c80(J);
  for (let G of Z.units) {
    if (W0.Location.set(Y, Z, G, G.elements[0]), Z.getModelIndex(G.model) !== W)
      continue;
    if (w1.entity.id(Y) !== K)
      continue;
    if (G.chainGroupId !== $)
      continue;
    let H = dv0(Y);
    if (Q.has(H))
      continue;
    let N = G.conformation.operator.name;
    if (X.push([H, N]), Q.add(H), X.length > u80)
      return [["", "Too many operators"]];
  }
  if (X.length === 0)
    X.push(["", "No operators"]);
  return X;
}
function gv0(Z) {
  var J;
  let $ = [], X = [], Y = Z.select(f2.Generators.rootsOfType(D0.Molecule.Structure));
  for (let Q of Y) {
    if (!((J = Q.obj) === null || J === void 0 ? void 0 : J.data))
      continue;
    X.push(Q.obj.data), $.push([Q.transform.ref, Q.obj.data.label]);
  }
  if ($.length === 0)
    $.push(["", "No structure"]);
  return { options: $, all: X };
}
var p80 = j.Select("single", [["single", "Chain"], ["polymers", "Polymers"], ["all", "Everything"]]);

class l80 extends I8 {
  constructor() {
    super(...arguments);
    this.state = { structureOptions: { options: [], all: [] }, structure: s0.Empty, structureRef: "", modelEntityId: "", chainGroupId: -1, operatorKey: "", mode: "single", sequenceViewModeParam: p80 }, this.setParamProps = (Z) => {
      let J = { ...this.state };
      switch (Z.name) {
        case "mode":
          if (J.mode = Z.value, this.state.mode === J.mode)
            return;
          if (J.mode === "all" || J.mode === "polymers")
            break;
        case "structure":
          if (Z.name === "structure")
            J.structureRef = Z.value;
          J.structure = this.getStructure(J.structureRef), J.modelEntityId = Tg(J.structure)[0][0], J.chainGroupId = GP(J.structure, J.modelEntityId)[0][0], J.operatorKey = nB(J.structure, J.modelEntityId, J.chainGroupId)[0][0];
          break;
        case "entity":
          J.modelEntityId = Z.value, J.chainGroupId = GP(J.structure, J.modelEntityId)[0][0], J.operatorKey = nB(J.structure, J.modelEntityId, J.chainGroupId)[0][0];
          break;
        case "chain":
          J.chainGroupId = Z.value, J.operatorKey = nB(J.structure, J.modelEntityId, J.chainGroupId)[0][0];
          break;
        case "operator":
          J.operatorKey = Z.value;
          break;
      }
      this.setState(J);
    };
  }
  componentDidMount() {
    var Z, J;
    if (this.plugin.state.data.select(f2.Generators.rootsOfType(D0.Molecule.Structure)).length > 0)
      this.setState(this.getInitialState());
    this.subscribe(this.plugin.state.events.object.updated, ({ ref: X, obj: Y }) => {
      if (X === this.state.structureRef && Y && Y.type === D0.Molecule.Structure.type && Y.data !== this.state.structure)
        this.sync();
    }), this.subscribe(this.plugin.state.events.object.created, ({ obj: X }) => {
      if (X && X.type === D0.Molecule.Structure.type)
        this.sync();
    }), this.subscribe(this.plugin.state.events.object.removed, ({ obj: X }) => {
      if (X && X.type === D0.Molecule.Structure.type)
        this.sync();
    });
    let $ = (J = (Z = this.plugin.spec.components) === null || Z === void 0 ? void 0 : Z.sequenceViewer) === null || J === void 0 ? void 0 : J.modeOptions;
    if ($) {
      let X = new Set($), Y = {
        ...p80,
        options: p80.options.filter(([Q]) => X.has(Q))
      };
      this.setState({ sequenceViewModeParam: Y });
    }
  }
  sync() {
    let Z = gv0(this.plugin.state.data);
    if (oO(Z.all, this.state.structureOptions.all))
      return;
    this.setState(this.getInitialState());
  }
  getStructure(Z) {
    let $ = this.plugin.state.data.select(Z)[0];
    if (!Z || !$ || !$.obj)
      return s0.Empty;
    return $.obj.data;
  }
  getSequenceWrapper(Z) {
    return {
      wrapper: yv0(this.state, this.plugin.managers.structure.selection),
      label: `${j.optionLabel(Z.chain, this.state.chainGroupId)} | ${j.optionLabel(Z.entity, this.state.modelEntityId)}`
    };
  }
  getSequenceWrappers(Z) {
    if (this.state.mode === "single")
      return [this.getSequenceWrapper(Z)];
    let J = this.getStructure(this.state.structureRef), $ = [];
    for (let [X, Y] of Tg(J, this.state.mode === "polymers"))
      for (let [Q, W] of GP(J, X))
        for (let [K] of nB(J, X, Q))
          if ($.push({
            wrapper: yv0({
              structure: J,
              modelEntityId: X,
              chainGroupId: Q,
              operatorKey: K
            }, this.plugin.managers.structure.selection),
            label: `${W} | ${Y}`
          }), $.length > Kw1)
            return [];
    return $;
  }
  getInitialState() {
    var Z, J, $, X;
    let Y = gv0(this.plugin.state.data), Q = Y.options[0][0], W = this.getStructure(Q), K = Tg(W)[0][0], G = GP(W, K)[0][0], H = nB(W, K, G)[0][0];
    if (this.state.structure && this.state.structure === W)
      K = this.state.modelEntityId, G = this.state.chainGroupId, H = this.state.operatorKey;
    let N = (J = (Z = this.plugin.spec.components) === null || Z === void 0 ? void 0 : Z.sequenceViewer) === null || J === void 0 ? void 0 : J.defaultMode, q = (X = ($ = this.props.defaultMode) !== null && $ !== void 0 ? $ : N) !== null && X !== void 0 ? X : "single";
    return { structureOptions: Y, structure: W, structureRef: Q, modelEntityId: K, chainGroupId: G, operatorKey: H, mode: q, sequenceViewModeParam: this.state.sequenceViewModeParam };
  }
  get params() {
    let { structureOptions: Z, structure: J, modelEntityId: $, chainGroupId: X } = this.state, Y = Tg(J), Q = GP(J, $), W = nB(J, $, X);
    return {
      structure: j.Select(Z.options[0][0], Z.options, { shortLabel: !0 }),
      entity: j.Select(Y[0][0], Y, { shortLabel: !0 }),
      chain: j.Select(Q[0][0], Q, { shortLabel: !0, twoColumns: !0, label: "Chain" }),
      operator: j.Select(W[0][0], W, { shortLabel: !0, twoColumns: !0 }),
      mode: this.state.sequenceViewModeParam
    };
  }
  get values() {
    return {
      structure: this.state.structureRef,
      entity: this.state.modelEntityId,
      chain: this.state.chainGroupId,
      operator: this.state.operatorKey,
      mode: this.state.mode
    };
  }
  render() {
    if (this.getStructure(this.state.structureRef) === s0.Empty)
      return zJ.jsx("div", { className: "msp-sequence", children: zJ.jsxs("div", { className: "msp-sequence-select", children: [zJ.jsx(b6, { svg: OQ, style: { cursor: "help", position: "absolute", right: 0, top: 0 }, title: "Shows a sequence of one or more chains. Use the controls to alter selection." }), zJ.jsx("span", { children: "Sequence" }), zJ.jsx("span", { style: { fontWeight: "normal" }, children: "No structure available" })] }) });
    let Z = this.params, J = this.values, $ = this.getSequenceWrappers(Z);
    return zJ.jsxs("div", { className: "msp-sequence", children: [zJ.jsxs("div", { className: "msp-sequence-select", children: [zJ.jsx(b6, { svg: OQ, style: { cursor: "help", position: "absolute", right: 0, top: 0 }, title: `This shows a single sequence. Use the controls to show a different sequence. 
Use Ctrl or Cmd key to add a sequence range to focus; use Shift key to extend last focused/selected range.` }), zJ.jsx("span", { children: "Sequence of" }), zJ.jsx(_U, { title: `[Structure] ${j.optionLabel(Z.structure, J.structure)}`, param: Z.structure, name: "structure", value: J.structure, onChange: this.setParamProps }), zJ.jsx(_U, { title: "[Mode]", param: this.state.sequenceViewModeParam, name: "mode", value: J.mode, onChange: this.setParamProps }), J.mode === "single" && zJ.jsx(_U, { title: `[Entity] ${j.optionLabel(Z.entity, J.entity)}`, param: Z.entity, name: "entity", value: J.entity, onChange: this.setParamProps }), J.mode === "single" && zJ.jsx(_U, { title: `[Chain] ${j.optionLabel(Z.chain, J.chain)}`, param: Z.chain, name: "chain", value: J.chain, onChange: this.setParamProps }), Z.operator.options.length > 1 && zJ.jsx(zJ.Fragment, { children: zJ.jsx(_U, { title: `[Instance] ${j.optionLabel(Z.operator, J.operator)}`, param: Z.operator, name: "operator", value: J.operator, onChange: this.setParamProps }) })] }), zJ.jsx(Gw1, { children: $.map((X, Y) => {
      let Q = typeof X.wrapper === "string" ? zJ.jsx("div", { className: "msp-sequence-wrapper", children: X.wrapper }, Y) : zJ.jsx(x80, { sequenceWrapper: X.wrapper }, Y);
      if (J.mode === "single")
        return Q;
      return zJ.jsxs(mv0.Fragment, { children: [zJ.jsx("div", { className: "msp-sequence-chain-label", children: X.label }), Q] }, Y);
    }) })] });
  }
}
function Gw1({ children: Z }) {
  return zJ.jsx("div", { className: "msp-sequence-wrapper-non-empty", children: Z });
}

// node_modules/molstar/lib/mol-plugin-ui/task.js
var iX = t2(PZ(), 1);
var hq = t2(J7(), 1);
function pv0() {
  let Z = hq.useContext(DQ), [J, $] = hq.useState(o$());
  return hq.useEffect(() => {
    let X = Z.events.task.progress.subscribe((Q) => {
      var W;
      let K = !!((W = Z.spec.components) === null || W === void 0 ? void 0 : W.hideTaskOverlay);
      if (Q.level === "background" && (K || !Q.useOverlay))
        $((G) => G.set(Q.id, Q));
    }), Y = Z.events.task.finished.subscribe(({ id: Q }) => {
      $((W) => W.delete(Q));
    });
    return () => {
      X.unsubscribe(), Y.unsubscribe();
    };
  }, [Z]), iX.jsxs("div", { className: "msp-background-tasks", children: [J.valueSeq().map((X) => iX.jsx(n80, { event: X }, X.id)), iX.jsx(Hw1, {})] });
}
function Hw1() {
  var Z;
  let J = hq.useContext(DQ), $ = sW((Z = J.canvas3d) === null || Z === void 0 ? void 0 : Z.commitQueueSize);
  if (!$)
    return null;
  return iX.jsx("div", { className: "msp-task-state", children: iX.jsx("div", { children: iX.jsxs("div", { children: ["Commiting renderables... ", $, " remaining"] }) }) });
}

class n80 extends I8 {
  constructor() {
    super(...arguments);
    this.abort = () => {
      this.plugin.managers.task.requestAbort(this.props.event.progress.root.progress.taskId, "User Request");
    };
  }
  render() {
    let Z = this.props.event.progress.root, J = uv0(this.props.event.progress.root) - 1, $ = Z.progress.isIndeterminate ? void 0 : iX.jsxs(iX.Fragment, { children: ["[", Z.progress.current, "/", Z.progress.max, "]"] }), X = J > 0 ? iX.jsxs(iX.Fragment, { children: ["[", J, " subtask(s)]"] }) : void 0;
    return iX.jsx("div", { className: "msp-task-state", children: iX.jsxs("div", { children: [Z.progress.canAbort && iX.jsx(o2, { svg: qy, onClick: this.abort, title: "Abort" }), iX.jsxs("div", { children: [Z.progress.message, " ", $, " ", X] })] }) });
  }
}
function uv0(Z) {
  if (Z.children.length === 0)
    return 1;
  let J = 0;
  for (let $ of Z.children)
    J += uv0($);
  return J;
}
function cv0() {
  let Z = hq.useContext(DQ), [J, $] = hq.useState(o$());
  if (hq.useEffect(() => {
    let X = Z.events.task.progress.subscribe((Q) => {
      if (Q.useOverlay)
        $((W) => W.set(Q.id, Q));
    }), Y = Z.events.task.finished.subscribe(({ id: Q }) => {
      $((W) => W.delete(Q));
    });
    return () => {
      X.unsubscribe(), Y.unsubscribe();
    };
  }, [Z]), J.size === 0)
    return null;
  return iX.jsx("div", { className: "msp-overlay-tasks", children: J.valueSeq().map((X) => iX.jsx(n80, { event: X }, X.id)) });
}

// node_modules/molstar/lib/mol-plugin-ui/toast.js
var mK = t2(PZ(), 1);
class lv0 extends I8 {
  constructor() {
    super(...arguments);
    this.hide = () => {
      (this.props.entry.hide || function() {}).call(null);
    };
  }
  render() {
    let Z = this.props.entry, J = typeof Z.message === "string" ? mK.jsx("div", { dangerouslySetInnerHTML: { __html: Z.message } }) : mK.jsx("div", { children: mK.jsx(Z.message, {}) });
    return mK.jsxs("div", { className: "msp-toast-entry", children: [mK.jsx("div", { className: "msp-toast-title", onClick: () => this.hide(), children: Z.title }), mK.jsx("div", { className: "msp-toast-message", children: J }), mK.jsx("div", { className: "msp-toast-clear" }), mK.jsx("div", { className: "msp-toast-hide", children: mK.jsx(o2, { svg: qy, onClick: this.hide, title: "Hide", className: "msp-no-hover-outline" }) })] });
  }
}

class i80 extends I8 {
  componentDidMount() {
    this.subscribe(this.plugin.managers.toast.events.changed, () => this.forceUpdate());
  }
  render() {
    let Z = this.plugin.managers.toast.state;
    if (!Z.entries.count())
      return null;
    let J = [];
    return Z.entries.forEach(($, X) => J.push($)), J.sort(function($, X) {
      return $.serialNumber - X.serialNumber;
    }), mK.jsx("div", { className: "msp-toast-container", children: J.map(($) => mK.jsx(lv0, { entry: $ }, $.serialNumber)) });
  }
}

// node_modules/molstar/lib/mol-plugin-ui/viewport.js
var q9 = t2(PZ(), 1);

// node_modules/molstar/lib/mol-plugin-ui/viewport/canvas.js
var WG = t2(PZ(), 1), nv0 = t2(J7(), 1);
class o80 extends I8 {
  constructor() {
    super(...arguments);
    this.container = nv0.createRef(), this.mounted = !1, this.state = {
      noWebGl: !1,
      showLogo: !0
    }, this.handleLogo = () => {
      var Z;
      this.setState({ showLogo: !((Z = this.plugin.canvas3d) === null || Z === void 0 ? void 0 : Z.reprCount.value) });
    };
  }
  async applyMount() {
    try {
      let Z = await this.plugin.mountAsync(this.container.current, { checkeredCanvasBackground: !0 });
      if (!this.mounted)
        return;
      if (!Z)
        this.setState({ noWebGl: !0 });
      this.handleLogo(), this.subscribe(this.plugin.canvas3d.reprCount, this.handleLogo);
    } catch (Z) {
      console.error(Z), this.setState({ noWebGl: !0 });
    }
  }
  componentDidMount() {
    if (this.mounted = !0, !this.container.current) {
      this.setState({ noWebGl: !0 });
      return;
    }
    this.applyMount();
  }
  componentWillUnmount() {
    this.mounted = !1, super.componentWillUnmount(), this.plugin.unmount();
  }
  renderMissing() {
    if (this.props.noWebGl) {
      let Z = this.props.noWebGl;
      return WG.jsx(Z, {});
    }
    return WG.jsx("div", { className: "msp-no-webgl", children: WG.jsxs("div", { children: [WG.jsx("p", { children: WG.jsx("b", { children: "WebGL does not seem to be available." }) }), WG.jsx("p", { children: "This can be caused by an outdated browser, graphics card driver issue, or bad weather. Sometimes, just restarting the browser helps. Also, make sure hardware acceleration is enabled in your browser." }), WG.jsxs("p", { children: ["For a list of supported browsers, refer to ", WG.jsx("a", { href: "http://caniuse.com/#feat=webgl", target: "_blank", children: "http://caniuse.com/#feat=webgl" }), "."] })] }) });
  }
  render() {
    if (this.state.noWebGl)
      return this.renderMissing();
    let Z = this.props.logo;
    return WG.jsx("div", { className: this.props.parentClassName || "msp-viewport", style: this.props.parentStyle, ref: this.container, children: this.state.showLogo && Z && WG.jsx(Z, {}) });
  }
}

// node_modules/molstar/lib/mol-plugin-ui/viewport/screenshot.js
var N9 = t2(PZ(), 1);

// node_modules/molstar/lib/mol-plugin-ui/controls/screenshot.js
var oX = t2(PZ(), 1), _g = t2(J7(), 1), m5 = t2(J7(), 1);
var Nw1 = (Z) => {
  let { plugin: J, cropFrameColor: $ } = Z, X = J.helpers.viewportScreenshot, [Y, Q] = m5.useState(null), W = m5.useRef(null), K = m5.useRef(Z);
  return m5.useEffect(() => {
    K.current = Z;
  }, Object.values(Z)), m5.useEffect(() => {
    if (Y !== W.current)
      Q(W.current);
  }), m5.useEffect(() => {
    var G;
    let H = !1, N = [];
    function q(z, D) {
      if (!z)
        return;
      N.push(z.subscribe(D));
    }
    function U() {
      let z = K.current;
      if (!z.suspend && W.current)
        iv0(J, X, W.current, z.customBackground, z.borderColor, z.borderWidth);
      if (!W.current)
        H = !0;
    }
    let F = setInterval(() => {
      if (H)
        H = !1, U();
    }, 125);
    q(J.events.canvas3d.settingsUpdated, () => H = !0), q((G = J.canvas3d) === null || G === void 0 ? void 0 : G.didDraw, () => H = !0), q(J.state.data.behaviors.isUpdating, (z) => {
      if (!z)
        H = !0;
    }), q(X === null || X === void 0 ? void 0 : X.behaviors.values, () => H = !0), q(X === null || X === void 0 ? void 0 : X.behaviors.cropParams, () => H = !0);
    let E = void 0;
    if (typeof ResizeObserver !== "undefined")
      E = new ResizeObserver(() => H = !0);
    let R = W.current;
    return E === null || E === void 0 || E.observe(R), U(), () => {
      clearInterval(F), N.forEach((z) => z.unsubscribe()), E === null || E === void 0 || E.unobserve(R);
    };
  }, [X]), m5.useLayoutEffect(() => {
    if (W.current)
      iv0(J, X, W.current, Z.customBackground, Z.borderColor, Z.borderWidth);
  }, [...Object.values(Z)]), oX.jsx(oX.Fragment, { children: oX.jsxs("div", { style: { position: "relative", width: "100%", height: "100%" }, children: [oX.jsx("canvas", { ref: W, onContextMenu: (G) => {
    G.preventDefault(), G.stopPropagation();
  }, style: { display: "block", width: "100%", height: "100%" } }), oX.jsx(qw1, { plugin: J, canvas: Y, color: $ })] }) });
}, sv0 = _g.memo(Nw1, (Z, J) => iL(Z, J));
async function iv0(Z, J, $, X, Y, Q) {
  let W = n0.create("Render Screenshot", async (K) => {
    if (!J)
      return;
    let G = await J.getPreview(K);
    if (!G)
      return;
    let H = $.getContext("2d");
    if (!H)
      return;
    let { canvas: N, width: q, height: U } = G, F = $.clientWidth, E = $.clientHeight;
    $.width = F, $.height = E, H.clearRect(0, 0, F, E);
    let R = av0(q, U, F, E);
    if (X)
      H.fillStyle = X, H.fillRect(R.x, R.y, R.width, R.height);
    else if (J.values.transparent)
      for (let D = 0;D < R.width; D += 13)
        for (let A = 0;A < R.height; A += 13) {
          H.fillStyle = (D + A) % 2 ? "#ffffff" : "#bfbfbf";
          let B = R.x + D, T = R.y + A, w = D + 13 > R.width ? R.width - D : 13, V = A + 13 > R.height ? R.height - A : 13;
          H.fillRect(B, T, w, V);
        }
    if (H.drawImage(N, R.x, R.y, R.width, R.height), Y && Q) {
      let z = Q;
      H.rect(R.x, R.y, R.width, R.height), H.rect(R.x + z, R.y + z, R.width - 2 * z, R.height - 2 * z), H.fillStyle = Y, H.fill("evenodd");
    }
  });
  return Z.runTask(W, { useOverlay: !0 });
}
function qw1({ plugin: Z, canvas: J, color: $ = "rgba(255, 87, 45, 0.75)" }) {
  var X;
  let Y = Z.helpers.viewportScreenshot, Q = sW(Y === null || Y === void 0 ? void 0 : Y.behaviors.values), W = sW(Y === null || Y === void 0 ? void 0 : Y.behaviors.cropParams), K = sW(Y === null || Y === void 0 ? void 0 : Y.behaviors.relativeCrop), G = m5.useRef({ x: 0, y: 0, width: 0, height: 0 });
  sW((Q === null || Q === void 0 ? void 0 : Q.resolution.name) === "viewport" ? (X = Z.canvas3d) === null || X === void 0 ? void 0 : X.resized : void 0);
  let [H, N] = _g.useState(""), [q, U] = m5.useState([0, 0]), [F, E] = m5.useState([0, 0]);
  if (!Y || !J || !K)
    return null;
  let { width: R, height: z } = Y.getSizeAndViewport(), D = av0(R, z, J.clientWidth, J.clientHeight), A = {
    x: D.x + Math.floor(D.width * K.x),
    y: D.y + Math.floor(D.height * K.y),
    width: Math.ceil(D.width * K.width),
    height: Math.ceil(D.height * K.height)
  }, B = ov0(A), T = ov0(D);
  if (H === "move")
    B.l += F[0] - q[0], B.r += F[0] - q[0], B.t += F[1] - q[1], B.b += F[1] - q[1];
  else if (H) {
    if (H.indexOf("left") >= 0)
      B.l += F[0] - q[0];
    else if (H.indexOf("right") >= 0)
      B.r += F[0] - q[0];
    if (H.indexOf("top") >= 0)
      B.t += F[1] - q[1];
    else if (H.indexOf("bottom") >= 0)
      B.b += F[1] - q[1];
  }
  if (B.l > B.r) {
    let i = B.l;
    B.l = B.r, B.r = i;
  }
  if (B.t > B.b) {
    let i = B.t;
    B.t = B.b, B.b = i;
  }
  let w = 40;
  B.l = Math.min(T.r - w, Math.max(T.l, B.l)), B.r = Math.max(T.l + w, Math.min(T.r, B.r)), B.t = Math.min(T.b - w, Math.max(T.t, B.t)), B.b = Math.max(T.t + w, Math.min(T.b, B.b)), A.x = B.l, A.y = B.t, A.width = B.r - B.l + 1, A.height = B.b - B.t + 1, G.current = A;
  let V = (i) => {
    i.preventDefault(), E([i.pageX, i.pageY]);
  }, P = (i) => {
    i.preventDefault();
    let r = i.touches[0];
    E([r.pageX, r.pageY]);
  }, I = (i) => {
    i.preventDefault(), N(i.currentTarget.getAttribute("data-drag"));
    let r = i.touches[0], Y0 = [r.pageX, r.pageY];
    U(Y0), E(Y0), window.addEventListener("touchend", v), window.addEventListener("touchmove", P);
  }, S = (i) => {
    i.preventDefault(), N(i.currentTarget.getAttribute("data-drag"));
    let r = [i.pageX, i.pageY];
    U(r), E(r), window.addEventListener("mouseup", f), window.addEventListener("mousemove", V);
  }, f = () => {
    window.removeEventListener("mouseup", f), window.removeEventListener("mousemove", V), h();
  }, v = () => {
    window.removeEventListener("touchend", v), window.removeEventListener("touchmove", P), h();
  };
  function h() {
    let i = G.current;
    if (W === null || W === void 0 ? void 0 : W.auto)
      Y === null || Y === void 0 || Y.behaviors.cropParams.next({ ...W, auto: !1 });
    Y === null || Y === void 0 || Y.behaviors.relativeCrop.next({
      x: (i.x - D.x) / D.width,
      y: (i.y - D.y) / D.height,
      width: i.width / D.width,
      height: i.height / D.height
    }), N("");
    let r = [0, 0];
    U(r), E(r);
  }
  let x = (i) => {
    i.preventDefault(), i.stopPropagation();
  }, b = 4, g = `3px solid ${$}`, m = "transparent";
  return oX.jsxs(oX.Fragment, { children: [oX.jsx("div", { "data-drag": "move", style: { position: "absolute", left: A.x, top: A.y, width: A.width, height: A.height, border: g, cursor: "move" }, onMouseDown: S, onTouchStart: I, draggable: !1, onContextMenu: x }), oX.jsx("div", { "data-drag": "left", style: { position: "absolute", left: A.x - b, top: A.y + b, width: 4 * b, height: A.height - b, background: m, cursor: "w-resize" }, onMouseDown: S, onTouchStart: I, draggable: !1, onContextMenu: x }), oX.jsx("div", { "data-drag": "right", style: { position: "absolute", left: B.r - 2 * b, top: A.y, width: 4 * b, height: A.height - b, background: m, cursor: "w-resize" }, onMouseDown: S, onTouchStart: I, draggable: !1, onContextMenu: x }), oX.jsx("div", { "data-drag": "top", style: { position: "absolute", left: A.x - b, top: A.y - b, width: A.width + 2 * b, height: 4 * b, background: m, cursor: "n-resize" }, onMouseDown: S, onTouchStart: I, draggable: !1, onContextMenu: x }), oX.jsx("div", { "data-drag": "bottom", style: { position: "absolute", left: A.x - b, top: B.b - 2 * b, width: A.width + 2 * b, height: 4 * b, background: m, cursor: "n-resize" }, onMouseDown: S, onTouchStart: I, draggable: !1, onContextMenu: x }), oX.jsx("div", { "data-drag": "top, left", style: { position: "absolute", left: B.l - b, top: B.t - b, width: 4 * b, height: 4 * b, background: m, cursor: "nw-resize" }, onMouseDown: S, onTouchStart: I, draggable: !1, onContextMenu: x }), oX.jsx("div", { "data-drag": "bottom, right", style: { position: "absolute", left: B.r - 2 * b, top: B.b - 2 * b, width: 4 * b, height: 4 * b, background: m, cursor: "nw-resize" }, onMouseDown: S, onTouchStart: I, draggable: !1, onContextMenu: x }), oX.jsx("div", { "data-drag": "top, right", style: { position: "absolute", left: B.r - 2 * b, top: B.t - b, width: 4 * b, height: 4 * b, background: m, cursor: "ne-resize" }, onMouseDown: S, onTouchStart: I, draggable: !1, onContextMenu: x }), oX.jsx("div", { "data-drag": "bottom, left", style: { position: "absolute", left: B.l - b, top: B.b - 2 * b, width: 4 * b, height: 4 * b, background: m, cursor: "ne-resize" }, onMouseDown: S, onTouchStart: I, draggable: !1, onContextMenu: x })] });
}
function ov0(Z) {
  return { l: Z.x, t: Z.y, r: Z.x + Z.width - 1, b: Z.y + Z.height - 1 };
}
function av0(Z, J, $, X) {
  let Y = Z / J, Q = $ / X;
  if (Y <= Q) {
    let W = X * Y;
    return { x: Math.round(($ - W) / 2), y: 0, width: Math.round(W), height: X };
  } else {
    let W = $ / Y;
    return { x: 0, y: Math.round((X - W) / 2), width: $, height: Math.round(W) };
  }
}

// node_modules/molstar/lib/mol-plugin-ui/viewport/screenshot.js
var Vg = t2(J7(), 1);

// node_modules/molstar/lib/mol-util/camera.js
function Fw1(Z, J) {
  if (Z === "orthographic")
    return 1 / (2 * Math.tan(J / 2));
  else
    return 1 / (2 * Math.sin(J / 2));
}
function rv0(Z, J, $, X) {
  let Y = M.sub(M(), J, Z), Q = Fw1($, X) || 1;
  return M.scaleAndAdd(Y, Z, Y, 1 / Q);
}

// node_modules/molstar/lib/mol-plugin-ui/viewport/screenshot.js
class s80 extends I8 {
  constructor() {
    super(...arguments);
    this.state = {
      showPreview: !0,
      isDisabled: !1
    }, this.download = () => {
      var Z;
      (Z = this.plugin.helpers.viewportScreenshot) === null || Z === void 0 || Z.download(), this.props.close();
    }, this.copy = async () => {
      var Z;
      try {
        await ((Z = this.plugin.helpers.viewportScreenshot) === null || Z === void 0 ? void 0 : Z.copyToClipboard()), h1.Toast.Show(this.plugin, {
          message: "Copied to clipboard.",
          title: "Screenshot",
          timeoutMs: 1500
        });
      } catch (J) {
        return this.copyImg();
      }
    }, this.copyImg = async () => {
      var Z;
      let J = await ((Z = this.plugin.helpers.viewportScreenshot) === null || Z === void 0 ? void 0 : Z.getImageDataUri());
      this.setState({ imageData: J });
    }, this.open = (Z) => {
      if (!Z.target.files || !Z.target.files[0])
        return;
      h1.State.Snapshots.OpenFile(this.plugin, { file: Z.target.files[0] });
    };
  }
  componentDidMount() {
    this.subscribe(this.plugin.state.data.behaviors.isUpdating, (Z) => {
      this.setState({ isDisabled: Z });
    });
  }
  componentWillUnmount() {
    super.componentWillUnmount(), this.setState({ imageData: void 0 });
  }
  render() {
    var Z;
    let J = !!((Z = navigator.clipboard) === null || Z === void 0 ? void 0 : Z.write);
    return N9.jsxs("div", { children: [this.state.showPreview && N9.jsxs("div", { className: "msp-image-preview", children: [N9.jsx(sv0, { plugin: this.plugin }), N9.jsx(Ew1, { plugin: this.plugin })] }), N9.jsxs("div", { className: "msp-flex-row", children: [!this.state.imageData && N9.jsx(Z8, { icon: yV0, onClick: J ? this.copy : this.copyImg, disabled: this.state.isDisabled, children: "Copy" }), this.state.imageData && N9.jsx(Z8, { onClick: () => this.setState({ imageData: void 0 }), disabled: this.state.isDisabled, children: "Clear" }), N9.jsx(Z8, { icon: PI, onClick: this.download, disabled: this.state.isDisabled, children: "Download" })] }), this.state.imageData && N9.jsxs("div", { className: "msp-row msp-copy-image-wrapper", children: [N9.jsx("div", { children: "Right click below + Copy Image" }), N9.jsx("img", { src: this.state.imageData, style: { width: "100%", height: 32, display: "block" } })] }), N9.jsx(Rw1, { plugin: this.plugin, isDisabled: this.state.isDisabled }), N9.jsxs(g$, { header: "State", children: [N9.jsx(Dg, { onAction: this.props.close }), N9.jsx(g$, { header: "Save Options", initiallyExpanded: !1, noOffset: !0, children: N9.jsx(Mg, {}) })] }), N9.jsx(g$, { header: "Camera", children: N9.jsx(Lw1, { plugin: this.plugin }) })] });
  }
}
function HP(Z) {
  return `${Z === null || Z === void 0 ? void 0 : Z.map((J) => bO(J, 2)).join(", ")}`;
}
function E4({ title: Z, children: J }) {
  return N9.jsxs("div", { className: "msp-control-row", children: [N9.jsx("span", { className: "msp-control-row-label", children: Z }), N9.jsx("div", { className: "msp-control-row-text", style: { fontSize: "0.85rem", overflow: "hidden", whiteSpace: "nowrap" }, children: J })] });
}
function Uw1(Z) {
  if (!Z)
    return;
  return rv0(Z.target, Z.position, Z.mode, Z.fov);
}
function Lw1({ plugin: Z }) {
  var J, $, X, Y, Q, W;
  let [, K] = Vg.useState({});
  Vg.useEffect(() => {
    var q;
    let U = (q = Z.canvas3d) === null || q === void 0 ? void 0 : q.didDraw.subscribe(() => K({}));
    return () => U === null || U === void 0 ? void 0 : U.unsubscribe();
  }, [Z]);
  let G = (J = Z.canvas3d) === null || J === void 0 ? void 0 : J.camera.state, H = Uw1(G), N = M.sub(M(), ($ = G === null || G === void 0 ? void 0 : G.target) !== null && $ !== void 0 ? $ : M.origin, (X = G === null || G === void 0 ? void 0 : G.position) !== null && X !== void 0 ? X : M.origin);
  return M.normalize(N, N), N9.jsxs("div", { children: [N9.jsx(E4, { title: "Position", children: HP(G === null || G === void 0 ? void 0 : G.position) }), N9.jsx(E4, { title: "FoV Norm. Pos.", children: HP(H) }), N9.jsx(E4, { title: "Target", children: HP(G === null || G === void 0 ? void 0 : G.target) }), N9.jsx(E4, { title: "Direction", children: HP(N) }), N9.jsx(E4, { title: "Up", children: HP(G === null || G === void 0 ? void 0 : G.up) }), N9.jsx(E4, { title: "Distance", children: bO(M.distance((Y = G === null || G === void 0 ? void 0 : G.position) !== null && Y !== void 0 ? Y : M.origin, (Q = G === null || G === void 0 ? void 0 : G.target) !== null && Q !== void 0 ? Q : M.origin), 2) }), N9.jsx(E4, { title: "Radius", children: bO((W = G === null || G === void 0 ? void 0 : G.radius) !== null && W !== void 0 ? W : 0, 2) }), N9.jsx(Z8, { onClick: () => {
    if (!navigator.clipboard)
      return;
    let q = `{
    position: [${H === null || H === void 0 ? void 0 : H.map((U) => bO(U, 2)).join(", ")}],
    target: [${G === null || G === void 0 ? void 0 : G.target.map((U) => bO(U, 2)).join(", ")}],
    up: [${G === null || G === void 0 ? void 0 : G.up.map((U) => bO(U, 2)).join(", ")}],
}`;
    navigator.clipboard.writeText(q);
  }, style: { marginTop: 1 }, title: "Copy JSON usable in MolViewSpec, uses FoV Normalized Position", children: "Copy MVS JSON" })] });
}
function Rw1({ plugin: Z, isDisabled: J }) {
  let $ = Z.helpers.viewportScreenshot, X = sW($ === null || $ === void 0 ? void 0 : $.behaviors.values);
  if (!$)
    return null;
  return N9.jsx(iZ, { params: $.params, values: X, onChangeValues: (Y) => $.behaviors.values.next(Y), isDisabled: J });
}
function Ew1({ plugin: Z }) {
  let J = Z.helpers.viewportScreenshot, $ = sW(J === null || J === void 0 ? void 0 : J.behaviors.cropParams);
  if (sW(J === null || J === void 0 ? void 0 : J.behaviors.relativeCrop), !J || !$)
    return null;
  return N9.jsxs("div", { style: { width: "100%", height: "24px", marginTop: "8px" }, children: [N9.jsx(D7, { icon: dV0, title: "Auto-crop", inline: !0, isSelected: $.auto, style: { background: "transparent", float: "left", width: "auto", height: "24px", lineHeight: "24px" }, toggle: () => J.toggleAutocrop(), label: "Auto-crop " + ($.auto ? "On" : "Off") }), !$.auto && N9.jsx(Z8, { icon: gV0, title: "Crop", style: { background: "transparent", float: "right", height: "24px", lineHeight: "24px", width: "24px", padding: "0" }, onClick: () => J.autocrop() }), !$.auto && !J.isFullFrame && N9.jsx(Z8, { icon: mV0, title: "Reset Crop", style: { background: "transparent", float: "right", height: "24px", lineHeight: "24px", width: "24px", padding: "0" }, onClick: () => J.resetCrop() })] });
}

// node_modules/molstar/lib/mol-plugin-ui/viewport/simple-settings.js
var O4 = t2(PZ(), 1);

// node_modules/molstar/lib/mol-util/param-mapping.js
function tv0(Z) {
  return ({ values: J, update: $, apply: X }) => ({
    params: typeof Z.params === "function" ? Z.params : (Y) => Z.params,
    getTarget: Z.target,
    getValues: J,
    update(Y, Q) {
      let W = Z.target(Q);
      return WQ(W, (K) => $(Y, K, Q));
    },
    apply: X ? X : () => {}
  });
}

// node_modules/molstar/lib/mol-plugin-ui/viewport/simple-settings.js
class a80 extends I8 {
  componentDidMount() {
    if (!this.plugin.canvas3d)
      return;
    this.subscribe(this.plugin.events.canvas3d.settingsUpdated, () => this.forceUpdate()), this.subscribe(this.plugin.canvas3d.camera.stateChanged.pipe(bQ(500, void 0, { leading: !0, trailing: !0 })), (Z) => {
      if (Z.radiusMax !== void 0 || Z.radius !== void 0)
        this.forceUpdate();
    });
  }
  render() {
    if (!this.plugin.canvas3d)
      return null;
    return O4.jsxs(O4.Fragment, { children: [O4.jsx(z10, { mapping: zw1 }), O4.jsx(gB, {})] });
  }
}
var NP = {
  sequence: "Sequence",
  log: "Log",
  left: "Left Panel",
  right: "Right Panel"
}, Ow1 = {
  animate: J$.trackball.params.animate,
  camera: J$.camera,
  background: j.Group({
    color: j.Color(i0(16579577), { label: "Background", description: "Custom background color" }),
    transparent: j.Boolean(!1),
    style: J$.postprocessing.params.background
  }, { pivot: "color" }),
  lighting: j.Group({
    occlusion: J$.postprocessing.params.occlusion,
    shadow: J$.postprocessing.params.shadow,
    outline: J$.postprocessing.params.outline,
    dof: J$.postprocessing.params.dof,
    fog: J$.cameraFog
  }, { isFlat: !0 }),
  clipping: j.Group({
    ...J$.cameraClipping.params
  }, { pivot: "radius" }),
  layout: j.MultiSelect([], j.objectToOptions(NP)),
  advanced: j.Group({
    illumination: J$.illumination,
    multiSample: J$.multiSample,
    hiZ: J$.hiZ,
    sharpening: J$.postprocessing.params.sharpening,
    bloom: J$.postprocessing.params.bloom,
    resolutionMode: a3.Params.resolutionMode,
    pixelScale: a3.Params.pixelScale,
    transparency: a3.Params.transparency
  })
}, zw1 = tv0({
  params: (Z) => {
    var J;
    let $ = j.clone(Ow1), X = (J = Z.spec.components) === null || J === void 0 ? void 0 : J.controls;
    if (X) {
      let Q = [];
      if (X.top !== "none")
        Q.push(["sequence", NP.sequence]);
      if (X.bottom !== "none")
        Q.push(["log", NP.log]);
      if (X.left !== "none")
        Q.push(["left", NP.left]);
      if (X.right !== "none")
        Q.push(["right", NP.right]);
      $.layout.options = Q;
    }
    let Y = Z.config.get(W8.Background.Styles) || [];
    if (Y.length > 0)
      Object.assign($.background.params.style, {
        presets: W$(Y),
        isFlat: !1
      });
    return $;
  },
  target(Z) {
    var J, $, X;
    let Y = (J = Z.spec.components) === null || J === void 0 ? void 0 : J.controls, Q = Z.layout.state.regionState, W = [];
    if (Q.top !== "hidden" && (!Y || Y.top !== "none"))
      W.push("sequence");
    if (Q.bottom !== "hidden" && (!Y || Y.bottom !== "none"))
      W.push("log");
    if (Q.left !== "hidden" && (!Y || Y.left !== "none"))
      W.push("left");
    if (Q.right !== "hidden" && (!Y || Y.right !== "none"))
      W.push("right");
    let { pixelScale: K, transparency: G, resolutionMode: H } = ($ = Z.canvas3dContext) === null || $ === void 0 ? void 0 : $.props;
    return { canvas: (X = Z.canvas3d) === null || X === void 0 ? void 0 : X.props, layout: W, resolutionMode: H, pixelScale: K, transparency: G };
  }
})({
  values(Z, J) {
    let { canvas: $ } = Z, X = $.renderer;
    return {
      layout: Z.layout,
      animate: $.trackball.animate,
      camera: $.camera,
      background: {
        color: X.backgroundColor,
        transparent: $.transparentBackground,
        style: $.postprocessing.background
      },
      lighting: {
        occlusion: $.postprocessing.occlusion,
        shadow: $.postprocessing.shadow,
        outline: $.postprocessing.outline,
        dof: $.postprocessing.dof,
        fog: $.cameraFog
      },
      clipping: {
        ...$.cameraClipping
      },
      advanced: {
        illumination: $.illumination,
        multiSample: $.multiSample,
        hiZ: $.hiZ,
        sharpening: $.postprocessing.sharpening,
        bloom: $.postprocessing.bloom,
        resolutionMode: Z.resolutionMode,
        pixelScale: Z.pixelScale,
        transparency: Z.transparency
      }
    };
  },
  update(Z, J) {
    let $ = J.canvas;
    $.trackball.animate = Z.animate, $.camera = Z.camera, $.transparentBackground = Z.background.transparent, $.renderer.backgroundColor = Z.background.color, $.postprocessing.occlusion = Z.lighting.occlusion, $.postprocessing.shadow = Z.lighting.shadow, $.postprocessing.outline = Z.lighting.outline, $.postprocessing.background = Z.background.style, $.cameraFog = Z.lighting.fog, $.cameraClipping = {
      radius: Z.clipping.radius,
      far: Z.clipping.far,
      minNear: Z.clipping.minNear
    }, $.illumination = Z.advanced.illumination, $.multiSample = Z.advanced.multiSample, $.hiZ = Z.advanced.hiZ, $.postprocessing.sharpening = Z.advanced.sharpening, $.postprocessing.bloom = Z.advanced.bloom, $.postprocessing.dof = Z.lighting.dof, J.layout = Z.layout, J.resolutionMode = Z.advanced.resolutionMode, J.pixelScale = Z.advanced.pixelScale, J.transparency = Z.advanced.transparency;
  },
  async apply(Z, J) {
    var $;
    await h1.Canvas3D.SetSettings(J, { settings: Z.canvas });
    let X = Z.layout.indexOf("left") < 0, Y = WQ(J.layout.state, (Q) => {
      Q.regionState.top = Z.layout.indexOf("sequence") >= 0 ? "full" : "hidden", Q.regionState.bottom = Z.layout.indexOf("log") >= 0 ? "full" : "hidden", Q.regionState.left = X ? "hidden" : J.behaviors.layout.leftPanelTabName.value === "none" ? "collapsed" : "full", Q.regionState.right = Z.layout.indexOf("right") >= 0 ? "full" : "hidden";
    });
    if (await h1.Layout.Update(J, { state: Y }), X)
      h1.State.SetCurrentObject(J, { state: J.state.data, ref: D8.RootRef });
    ($ = J.canvas3dContext) === null || $ === void 0 || $.setProps({
      resolutionMode: Z.resolutionMode,
      pixelScale: Z.pixelScale,
      transparency: Z.transparency
    });
  }
});

// node_modules/molstar/lib/mol-plugin-ui/viewport.js
class r80 extends I8 {
  constructor() {
    super(...arguments);
    this.allCollapsedState = {
      isSettingsExpanded: !1,
      isScreenshotExpanded: !1
    }, this.state = {
      ...this.allCollapsedState,
      isCameraResetEnabled: !0
    }, this.resetCamera = () => {
      h1.Camera.Reset(this.plugin, {});
    }, this.toggleSettingsExpanded = this.toggle("isSettingsExpanded"), this.toggleScreenshotExpanded = this.toggle("isScreenshotExpanded"), this.toggleControls = () => {
      h1.Layout.Update(this.plugin, { state: { showControls: !this.plugin.layout.state.showControls } });
    }, this.toggleExpanded = () => {
      h1.Layout.Update(this.plugin, {
        state: {
          isExpanded: !this.plugin.layout.state.isExpanded,
          expandToFullscreen: !1
        }
      });
    }, this.toggleFullscreen = () => {
      h1.Layout.Update(this.plugin, {
        state: {
          expandToFullscreen: !this.plugin.layout.state.expandToFullscreen
        }
      });
    }, this.toggleXR = () => {
      if (this.plugin.canvas3d)
        if (this.plugin.canvas3d.xr.isPresenting.value)
          this.plugin.canvas3d.xr.end();
        else
          this.plugin.canvas3d.xr.request();
    }, this.toggleIllumination = () => {
      if (!this.plugin.canvas3d)
        return;
      h1.Canvas3D.SetSettings(this.plugin, {
        settings: {
          illumination: {
            ...this.plugin.canvas3d.props.illumination,
            enabled: !this.plugin.canvas3d.props.illumination.enabled
          }
        }
      });
    }, this.setSettings = (Z) => {
      h1.Canvas3D.SetSettings(this.plugin, { settings: { [Z.name]: Z.value } });
    }, this.setLayout = (Z) => {
      h1.Layout.Update(this.plugin, { state: { [Z.name]: Z.value } });
    }, this.screenshot = () => {
      var Z;
      (Z = this.plugin.helpers.viewportScreenshot) === null || Z === void 0 || Z.download();
    }, this.enableCameraReset = (Z) => {
      this.setState((J) => ({ ...J, isCameraResetEnabled: Z }));
    };
  }
  toggle(Z) {
    return (J) => {
      this.setState(($) => ({ ...$, ...this.allCollapsedState, [Z]: !this.state[Z] })), J === null || J === void 0 || J.currentTarget.blur();
    };
  }
  componentDidMount() {
    if (this.subscribe(this.plugin.events.canvas3d.settingsUpdated, () => this.forceUpdate()), this.subscribe(this.plugin.layout.events.updated, () => this.forceUpdate()), this.plugin.canvas3d)
      this.subscribe(this.plugin.canvas3d.camera.stateChanged.pipe(bQ(500, void 0, { leading: !0, trailing: !0 })), (Z) => this.enableCameraReset(Z.radius !== 0 && Z.radiusMax !== 0)), this.subscribe(this.plugin.canvas3d.xr.isSupported, () => this.forceUpdate()), this.subscribe(this.plugin.canvas3d.xr.isPresenting, () => this.forceUpdate());
  }
  icon(Z, J, $, X = !0, Y = !1) {
    return q9.jsx(o2, { svg: Z, toggleState: X, onClick: J, title: $, style: { background: "transparent" }, disabled: Y });
  }
  render() {
    var Z, J, $;
    let X = this.plugin.config.get(W8.Viewport.ShowXR), Y = !!((Z = this.plugin.canvas3d) === null || Z === void 0 ? void 0 : Z.xr.isSupported.value), Q = !!((J = this.plugin.canvas3d) === null || J === void 0 ? void 0 : J.xr.isPresenting.value), W = X === "always" || X === "auto" && Y, K = !Y ? "Augmented/Virtual Reality unavailable" : Q ? "Exit XR" : "Enter XR", G = this.plugin.layout.state;
    return q9.jsxs("div", { className: "msp-viewport-controls", children: [q9.jsxs("div", { className: "msp-viewport-controls-buttons", children: [this.plugin.config.get(W8.Viewport.ShowReset) && q9.jsxs("div", { className: "msp-hover-box-wrapper", children: [q9.jsx("div", { className: "msp-semi-transparent-background" }), this.icon(PV0, this.resetCamera, "Reset Zoom"), q9.jsx("div", { className: "msp-hover-box-body", children: q9.jsxs("div", { className: "msp-flex-column", children: [q9.jsx("div", { className: "msp-flex-row", children: q9.jsx(Z8, { onClick: () => this.resetCamera(), disabled: !this.state.isCameraResetEnabled, title: "Set camera zoom to fit the visible scene into view", children: "Reset Zoom" }) }), q9.jsx("div", { className: "msp-flex-row", children: q9.jsx(Z8, { onClick: () => h1.Camera.OrientAxes(this.plugin), disabled: !this.state.isCameraResetEnabled, title: "Align principal component axes of the loaded structures to the screen axes (“lay flat”)", children: "Orient Axes" }) }), q9.jsx("div", { className: "msp-flex-row", children: q9.jsx(Z8, { onClick: () => h1.Camera.ResetAxes(this.plugin), disabled: !this.state.isCameraResetEnabled, title: "Align Cartesian axes to the screen axes", children: "Reset Axes" }) })] }) }), q9.jsx("div", { className: "msp-hover-box-spacer" })] }), this.plugin.config.get(W8.Viewport.ShowScreenshotControls) && q9.jsxs("div", { children: [q9.jsx("div", { className: "msp-semi-transparent-background" }), this.icon(SV0, this.toggleScreenshotExpanded, "Screenshot / State Snapshot", this.state.isScreenshotExpanded)] }), q9.jsxs("div", { children: [q9.jsx("div", { className: "msp-semi-transparent-background" }), this.plugin.config.get(W8.Viewport.ShowControls) && this.icon(kV0, this.toggleControls, "Toggle Controls Panel", this.plugin.layout.state.showControls), this.plugin.config.get(W8.Viewport.ShowExpand) && q9.jsxs("div", { className: "msp-hover-box-wrapper", children: [this.icon(pV0, this.toggleExpanded, "Toggle Expanded Viewport", this.plugin.layout.state.isExpanded), q9.jsx("div", { className: "msp-hover-box-body", children: q9.jsx("div", { className: "msp-flex-column", children: q9.jsx("div", { className: "msp-flex-row", children: q9.jsx(Z8, { onClick: this.toggleFullscreen, children: G.expandToFullscreen ? "Exit Fullscreen" : "Fullscreen" }) }) }) }), q9.jsx("div", { className: "msp-hover-box-spacer" })] }), !this.plugin.config.get(W8.Viewport.ShowExpand) && this.plugin.config.get(W8.Viewport.ShowToggleFullscreen) && this.icon(CV0, this.toggleFullscreen, "Toggle Full Screen", this.plugin.layout.state.expandToFullscreen), this.plugin.config.get(W8.Viewport.ShowSettings) && this.icon(lX, this.toggleSettingsExpanded, "Settings / Controls Info", this.state.isSettingsExpanded), this.plugin.config.get(W8.Viewport.ShowIllumination) && this.icon(iV0, this.toggleIllumination, "Illumination", (($ = this.plugin.canvas3d) === null || $ === void 0 ? void 0 : $.props.illumination.enabled) || !1), W && this.icon(oV0, this.toggleXR, K, Q, !Y)] }), this.plugin.config.get(W8.Viewport.ShowSelectionMode) && q9.jsxs("div", { children: [q9.jsx("div", { className: "msp-semi-transparent-background" }), q9.jsx(q4, {})] })] }), this.state.isScreenshotExpanded && q9.jsx("div", { className: "msp-viewport-controls-panel", children: q9.jsx(zQ, { header: "Screenshot / State", title: "Click to close.", initialExpanded: !0, hideExpander: !0, hideOffset: !0, onHeaderClick: this.toggleScreenshotExpanded, topRightIcon: cW, noTopMargin: !0, childrenClassName: "msp-viewport-controls-panel-controls", children: q9.jsx(s80, { close: this.toggleScreenshotExpanded }) }) }), this.state.isSettingsExpanded && q9.jsx("div", { className: "msp-viewport-controls-panel", children: q9.jsx(zQ, { header: "Settings / Controls Info", title: "Click to close.", initialExpanded: !0, hideExpander: !0, hideOffset: !0, onHeaderClick: this.toggleSettingsExpanded, topRightIcon: cW, noTopMargin: !0, childrenClassName: "msp-viewport-controls-panel-controls", children: q9.jsx(a80, {}) }) })] });
  }
}
var Dw1 = () => q9.jsx("a", { className: "msp-logo", href: "https://molstar.org", target: "_blank" }), ev0 = () => q9.jsx(o80, { logo: Dw1 });

// node_modules/molstar/lib/mol-plugin-ui/plugin.js
function ZS0({ plugin: Z }) {
  if (Z.isInitialized)
    return xZ.jsx(DQ.Provider, { value: Z, children: xZ.jsx(t80, {}) });
  return xZ.jsx(Mw1, { plugin: Z });
}
function Mw1({ plugin: Z }) {
  let [J, $] = z4.useState({ kind: "pending" });
  if (z4.useEffect(() => {
    $({ kind: "pending" });
    let X = !0;
    return Z.initialized.then(() => {
      if (X)
        $({ kind: "initialized" });
    }).catch((Y) => {
      if (X)
        $({ kind: "error", message: `${Y}` });
    }), () => {
      X = !1;
    };
  }, [Z]), J.kind === "pending")
    return null;
  if (J.kind === "error")
    return xZ.jsx("div", { className: "msp-plugin", children: xZ.jsxs("div", { className: "msp-plugin-init-error", children: ["Initialization error: ", J.message] }) });
  return xZ.jsx(DQ.Provider, { value: Z, children: xZ.jsx(t80, {}) });
}
class t80 extends I8 {
  constructor() {
    super(...arguments);
    this.onDrop = (Z) => {
      Z.preventDefault();
      let J = [];
      if (Z.dataTransfer.items)
        for (let X = 0;X < Z.dataTransfer.items.length; X++) {
          if (Z.dataTransfer.items[X].kind !== "file")
            continue;
          let Y = Z.dataTransfer.items[X].getAsFile();
          if (Y)
            J.push(Y);
        }
      else
        for (let X = 0;X < Z.dataTransfer.files.length; X++) {
          let Y = Z.dataTransfer.files[X];
          if (Y)
            J.push(Y);
        }
      let $ = J.filter((X) => {
        let Y = X.name.toLowerCase();
        return Y.endsWith(".molx") || Y.endsWith(".molj");
      });
      if ($.length > 0)
        h1.State.Snapshots.OpenFile(this.plugin, { file: $[0] });
      else
        this.plugin.runTask(this.plugin.state.data.applyAction(wI, {
          files: J.map((X) => E6.File(X)),
          format: { name: "auto", params: {} },
          visuals: !0
        }));
    }, this.onDragOver = (Z) => {
      Z.preventDefault();
    }, this.showDragOverlay = new G$(!1), this.onDragEnter = (Z) => {
      let J = !1;
      if (Z.dataTransfer.items && Z.dataTransfer.items.length > 0)
        for (let $ = 0;$ < Z.dataTransfer.items.length; $++) {
          if (Z.dataTransfer.items[$].kind !== "file")
            continue;
          J = !0;
          break;
        }
      else
        for (let $ = 0;$ < Z.dataTransfer.types.length; $++) {
          if (Z.dataTransfer.types[$] !== "Files")
            continue;
          J = !0;
          break;
        }
      if (J)
        this.showDragOverlay.next(!0);
    };
  }
  componentDidMount() {
    this.subscribe(this.plugin.layout.events.updated, () => this.forceUpdate());
  }
  region(Z, J) {
    return xZ.jsx("div", { className: `msp-layout-region msp-layout-${Z}`, children: xZ.jsx("div", { className: "msp-layout-static", children: J ? xZ.jsx(J, {}) : null }) });
  }
  get layoutVisibilityClassName() {
    var Z, J;
    let $ = this.plugin.layout.state, X = (J = (Z = this.plugin.spec.components) === null || Z === void 0 ? void 0 : Z.controls) !== null && J !== void 0 ? J : {}, Y = [];
    if (X.top === "none" || !$.showControls || $.regionState.top === "hidden")
      Y.push("msp-layout-hide-top");
    if (X.left === "none" || !$.showControls || $.regionState.left === "hidden")
      Y.push("msp-layout-hide-left");
    else if ($.regionState.left === "collapsed")
      Y.push("msp-layout-collapse-left");
    if (X.right === "none" || !$.showControls || $.regionState.right === "hidden")
      Y.push("msp-layout-hide-right");
    if (X.bottom === "none" || !$.showControls || $.regionState.bottom === "hidden")
      Y.push("msp-layout-hide-bottom");
    return Y.join(" ");
  }
  get layoutClassName() {
    let Z = this.plugin.layout.state, J = ["msp-plugin-content"];
    if (Z.isExpanded)
      J.push("msp-layout-expanded");
    else
      J.push("msp-layout-standard", `msp-layout-standard-${Z.controlsDisplay}`);
    return J.join(" ");
  }
  render() {
    var Z, J, $, X, Y, Q, W;
    let K = this.plugin.layout.state, G = ((Z = this.plugin.spec.components) === null || Z === void 0 ? void 0 : Z.controls) || {}, H = (($ = (J = this.plugin.spec.components) === null || J === void 0 ? void 0 : J.viewport) === null || $ === void 0 ? void 0 : $.view) || $S0, N = ((Y = (X = this.plugin.spec.components) === null || X === void 0 ? void 0 : X.sequenceViewer) === null || Y === void 0 ? void 0 : Y.view) || l80;
    return xZ.jsx("div", { className: "msp-plugin", children: xZ.jsxs("div", { className: this.layoutClassName, onDragEnter: this.onDragEnter, children: [xZ.jsxs("div", { className: this.layoutVisibilityClassName, children: [this.region("main", H), K.showControls && G.top !== "none" && this.region("top", G.top || N), K.showControls && G.left !== "none" && this.region("left", G.left || h80), K.showControls && G.right !== "none" && this.region("right", G.right || JS0), K.showControls && G.bottom !== "none" && this.region("bottom", G.bottom || XS0)] }), !((Q = this.plugin.spec.components) === null || Q === void 0 ? void 0 : Q.hideTaskOverlay) && xZ.jsx(cv0, {}), !((W = this.plugin.spec.components) === null || W === void 0 ? void 0 : W.disableDragOverlay) && xZ.jsx(Bw1, { plugin: this.plugin, showDragOverlay: this.showDragOverlay })] }) });
  }
}
function Aw1(Z, J, $) {
  Z.preventDefault(), Z.stopPropagation(), $.next(!1);
  let X = [];
  if (Z.dataTransfer.items)
    for (let Y = 0;Y < Z.dataTransfer.items.length; Y++) {
      if (Z.dataTransfer.items[Y].kind !== "file")
        continue;
      let Q = Z.dataTransfer.items[Y].getAsFile();
      if (Q)
        X.push(Q);
    }
  else
    for (let Y = 0;Y < Z.dataTransfer.files.length; Y++) {
      let Q = Z.dataTransfer.files[Y];
      if (Q)
        X.push(Q);
    }
  J.managers.dragAndDrop.handle(X);
}
function Bw1({ plugin: Z, showDragOverlay: J }) {
  let $ = sW(J), X = (Y) => {
    Y.dataTransfer.dropEffect = "copy", Y.preventDefault(), Y.stopPropagation();
  };
  return xZ.jsx("div", { className: "msp-drag-drop-overlay", style: { display: $ ? "flex" : "none" }, onDragEnter: X, onDragOver: X, onDragLeave: () => J.next(!1), onDrop: (Y) => Aw1(Y, Z, J), children: "Load File(s)" });
}

class JS0 extends I8 {
  render() {
    var Z;
    let J = ((Z = this.plugin.spec.components) === null || Z === void 0 ? void 0 : Z.structureTools) || v80;
    return xZ.jsx("div", { className: "msp-scrollable-container", children: xZ.jsx(J, {}) });
  }
}

class $S0 extends I8 {
  render() {
    var Z, J, $, X, Y, Q;
    let W = ((J = (Z = this.plugin.spec.components) === null || Z === void 0 ? void 0 : Z.viewport) === null || J === void 0 ? void 0 : J.controls) || r80, K = ((X = ($ = this.plugin.spec.components) === null || $ === void 0 ? void 0 : $.selectionTools) === null || X === void 0 ? void 0 : X.controls) || C80, G = ((Q = (Y = this.plugin.spec.components) === null || Y === void 0 ? void 0 : Y.viewport) === null || Q === void 0 ? void 0 : Q.snapshotDescription) || Tv0;
    return xZ.jsxs(xZ.Fragment, { children: [xZ.jsx(ev0, {}), xZ.jsxs("div", { className: "msp-viewport-top-left-controls", children: [xZ.jsx(P80, {}), xZ.jsx(V80, {}), xZ.jsx(I80, {}), xZ.jsx(G, {})] }), xZ.jsx(K, {}), xZ.jsx(W, {}), xZ.jsx(pv0, {}), xZ.jsxs("div", { className: "msp-highlight-toast-wrapper", children: [xZ.jsx(k80, {}), xZ.jsx(i80, {})] })] });
  }
}

class XS0 extends I8 {
  constructor() {
    super(...arguments);
    this.wrapper = z4.createRef(), this.state = { entries: this.plugin.log.entries };
  }
  componentDidMount() {
    this.subscribe(this.plugin.events.log, () => this.setState({ entries: this.plugin.log.entries }));
  }
  componentDidUpdate() {
    this.scrollToBottom();
  }
  scrollToBottom() {
    let Z = this.wrapper.current;
    if (Z)
      Z.scrollTop = Z.scrollHeight - Z.clientHeight - 1;
  }
  render() {
    let J = this.state.entries, $ = J.size, X = [];
    for (let Y = Math.max(0, $ - 10), Q = 0;Y < $; Y++) {
      let W = J.get(Y);
      X.push(xZ.jsxs("li", { children: [xZ.jsx("div", { className: "msp-log-entry-badge msp-log-entry-" + W.type }), xZ.jsx("div", { className: "msp-log-timestamp", children: jW0(W.timestamp) }), xZ.jsx("div", { className: "msp-log-entry", children: W.message })] }, Q++));
    }
    return xZ.jsx("div", { ref: this.wrapper, className: "msp-log", style: { position: "absolute", top: "0", right: "0", bottom: "0", left: "0", overflowY: "auto" }, children: xZ.jsx("ul", { className: "msp-list-unstyled", children: X }) });
  }
}

// node_modules/molstar/lib/mol-model-props/common/custom-property.js
var qP;
(function(Z) {

  class J {
    constructor() {
      this.providers = o$().asMutable(), this.defaultAutoAttachValues = /* @__PURE__ */ new Map;
    }
    getParams($) {
      let X = {}, Y = [], Q = [];
      if ($) {
        let W = this.providers.values();
        while (!0) {
          let K = W.next();
          if (K.done)
            break;
          let G = K.value;
          if (!G.isApplicable($))
            continue;
          if (!G.isHidden) {
            if (Y.push([G.descriptor.name, G.label]), this.defaultAutoAttachValues.get(G.descriptor.name))
              Q.push(G.descriptor.name);
          }
          X[G.descriptor.name] = j.Group({
            ...G.getParams($)
          }, { label: G.label, isHidden: G.isHidden });
        }
      }
      return {
        autoAttach: j.MultiSelect(Q, Y),
        properties: j.Group(X, { isFlat: !0 })
      };
    }
    setDefaultAutoAttach($, X) {
      this.defaultAutoAttachValues.set($, X);
    }
    get($) {
      if (!this.providers.get($))
        throw new Error(`Custom property '${$}' is not registered.`);
      return this.providers.get($);
    }
    register($, X) {
      this.providers.set($.descriptor.name, $), this.defaultAutoAttachValues.set($.descriptor.name, X);
    }
    unregister($) {
      this.providers.delete($), this.defaultAutoAttachValues.delete($);
    }
  }
  Z.Registry = J;
})(qP || (qP = {}));

// node_modules/molstar/lib/mol-plugin-state/builder/data.js
class e80 {
  get dataState() {
    return this.plugin.state.data;
  }
  rawData(Z, J) {
    return this.dataState.build().toRoot().apply(Xr, Z, J).commit({ revertOnError: !0 });
  }
  download(Z, J) {
    return this.dataState.build().toRoot().apply(Jr, Z, J).commit({ revertOnError: !0 });
  }
  downloadBlob(Z, J) {
    return this.dataState.build().toRoot().apply($r, Z, J).commit({ revertOnError: !0 });
  }
  async readFile(Z, J) {
    var $, X, Y;
    let Q = await this.dataState.build().toRoot().apply(Yr, Z, J).commit({ revertOnError: !0 }), W = BU((Y = (X = ($ = Z.file) === null || $ === void 0 ? void 0 : $.file) === null || X === void 0 ? void 0 : X.name) !== null && Y !== void 0 ? Y : "");
    return { data: Q, fileInfo: W };
  }
  constructor(Z) {
    this.plugin = Z;
  }
}

// node_modules/molstar/lib/mol-plugin-state/builder/structure/representation.js
class Z60 {
  get dataState() {
    return this.plugin.state.data;
  }
  resolveProvider(Z) {
    var J;
    return typeof Z === "string" ? (J = hY[Z]) !== null && J !== void 0 ? J : VM(this._providers, ($) => $.id === Z) : Z;
  }
  hasPreset(Z) {
    for (let J of this._providers)
      if (!J.isApplicable || J.isApplicable(Z, this.plugin))
        return !0;
    return !1;
  }
  get providers() {
    return this._providers;
  }
  getPresets(Z) {
    if (!Z)
      return this.providers;
    let J = [];
    for (let $ of this._providers) {
      if ($.isApplicable && !$.isApplicable(Z, this.plugin))
        continue;
      J.push($);
    }
    return J;
  }
  getPresetSelect(Z) {
    let J = [];
    for (let $ of this._providers) {
      if (Z && $.isApplicable && !$.isApplicable(Z, this.plugin))
        continue;
      J.push([$.id, $.display.name, $.display.group]);
    }
    return j.Select("auto", J);
  }
  getPresetsWithOptions(Z) {
    let J = [], $ = Object.create(null);
    for (let X of this._providers) {
      if (X.isApplicable && !X.isApplicable(Z, this.plugin))
        continue;
      J.push([X.id, X.display.name]), $[X.id] = X.params ? j.Group(X.params(Z, this.plugin)) : j.EmptyGroup();
    }
    if (J.length === 0)
      return j.MappedStatic("", { "": j.EmptyGroup() });
    return j.MappedStatic(J[0][0], $, { options: J });
  }
  registerPreset(Z) {
    if (this.providerMap.has(Z.id))
      throw new Error(`Representation provider with id '${Z.id}' already registered.`);
    this._providers.push(Z), this.providerMap.set(Z.id, Z);
  }
  unregisterPreset(Z) {
    this.providerMap.delete(Z.id), ZH(this._providers, Z);
  }
  applyPreset(Z, J, $) {
    var X;
    let Y = this.resolveProvider(J);
    if (!Y)
      return;
    let Q = this.plugin.state.data, W = X7.resolveAndCheck(Q, Z);
    if (!W) {
      if (!aL)
        console.warn("Applying structure repr. provider to bad cell.");
      return;
    }
    let K = ((X = Y.params) === null || X === void 0 ? void 0 : X.call(Y, W.obj, this.plugin)) || {}, G = $ || (Y.params ? j.getDefaultValues(K) : {}), H = this.plugin.config.get(W8.Structure.DefaultRepresentationPresetParams);
    G = j.merge(K, H, G);
    let N = n0.create(`${Y.display.name}`, () => Y.apply(W, G, this.plugin));
    return this.plugin.runTask(N);
  }
  async addRepresentation(Z, J, $) {
    let X = this.dataState.build(), Y = this.buildRepresentation(X, Z, J, $);
    if (!Y)
      return;
    return await X.commit(), Y;
  }
  buildRepresentation(Z, J, $, X) {
    var Y, Q;
    if (!J)
      return;
    let W = (Q = (Y = X7.resolveAndCheck(this.dataState, J)) === null || Y === void 0 ? void 0 : Y.obj) === null || Q === void 0 ? void 0 : Q.data;
    if (!W)
      return;
    let K = UE(this.plugin, W, $);
    return (X === null || X === void 0 ? void 0 : X.tag) ? Z.to(J).applyOrUpdateTagged(X.tag, lA, K, { state: X === null || X === void 0 ? void 0 : X.initialState }).selector : Z.to(J).apply(lA, K, { state: X === null || X === void 0 ? void 0 : X.initialState }).selector;
  }
  constructor(Z) {
    this.plugin = Z, this._providers = [], this.providerMap = /* @__PURE__ */ new Map, this.defaultProvider = hY.auto, B7(hY, (J) => this.registerPreset(J));
  }
}

// node_modules/molstar/lib/mol-plugin-state/builder/structure/hierarchy-preset.js
function CE(Z) {
  return Z;
}
(function(Z) {
  Z.CommonParams = (J, $) => ({
    modelProperties: j.Optional(j.Group(T1.getParamDefinition(H1.Model.CustomModelProperties, void 0, $))),
    structureProperties: j.Optional(j.Group(T1.getParamDefinition(H1.Model.CustomStructureProperties, void 0, $))),
    representationPreset: j.Optional(j.Text("auto"))
  });
})(CE || (CE = {}));
var Ig = CE.CommonParams, ww1 = (Z, J) => ({
  model: j.Optional(j.Group(T1.getParamDefinition(H1.Model.ModelFromTrajectory, Z, J))),
  showUnitcell: j.Optional(j.Boolean(!1)),
  structure: j.Optional(Nq.getParams(void 0, "assembly").type),
  representationPresetParams: j.Optional(j.Group(KX.CommonParams)),
  ...Ig(Z, J)
}), YS0 = CE({
  id: "preset-trajectory-default",
  display: {
    name: "Default (Assembly)",
    group: "Preset",
    description: "Shows the first assembly or, if that is unavailable, the first model."
  },
  isApplicable: (Z) => {
    return !0;
  },
  params: ww1,
  async apply(Z, J, $) {
    let X = $.builders.structure, Y = await X.createModel(Z, J.model), Q = await X.insertModelProperties(Y, J.modelProperties), W = await X.createStructure(Q || Y, J.structure), K = await X.insertStructureProperties(W, J.structureProperties), G = J.showUnitcell === void 0 || !!J.showUnitcell ? await X.tryCreateUnitcell(Q, void 0, { isHidden: !0 }) : void 0, H = J.representationPreset || $.config.get(W8.Structure.DefaultRepresentationPreset) || hY.auto.id, N = await $.builders.structure.representation.applyPreset(K, H, J.representationPresetParams);
    return {
      model: Y,
      modelProperties: Q,
      unitcell: G,
      structure: W,
      structureProperties: K,
      representation: N
    };
  }
}), jw1 = (Z, J) => ({
  useDefaultIfSingleModel: j.Optional(j.Boolean(!1)),
  representationPresetParams: j.Optional(j.Group(KX.CommonParams)),
  ...Ig(Z, J)
}), Tw1 = CE({
  id: "preset-trajectory-all-models",
  display: {
    name: "All Models",
    group: "Preset",
    description: "Shows all models; colored by trajectory-index."
  },
  isApplicable: (Z) => {
    return Z.data.frameCount > 1;
  },
  params: jw1,
  async apply(Z, J, $) {
    var X, Y;
    let Q = (Y = (X = X7.resolveAndCheck($.state.data, Z)) === null || X === void 0 ? void 0 : X.obj) === null || Y === void 0 ? void 0 : Y.data;
    if (!Q)
      return {};
    if (Q.frameCount === 1 && J.useDefaultIfSingleModel)
      return YS0.apply(Z, J, $);
    let W = $.builders.structure, K = [], G = [];
    for (let H = 0;H < Q.frameCount; H++) {
      let N = await W.createModel(Z, { modelIndex: H }), q = await W.insertModelProperties(N, J.modelProperties, { isCollapsed: !0 }), U = await W.createStructure(q || N, { name: "model", params: {} }), F = await W.insertStructureProperties(U, J.structureProperties);
      K.push(N), G.push(U);
      let E = U.obj ? kt(U.obj.data, { elementCountFactor: Q.frameCount }) : "medium", R = J.representationPreset || $.config.get(W8.Structure.DefaultRepresentationPreset) || hY.auto.id;
      await W.representation.applyPreset(F, R, { theme: { globalName: "trajectory-index" }, quality: E });
    }
    return { models: K, structures: G };
  }
}), QS0 = (Z, J) => ({
  model: j.Optional(j.Group(T1.getParamDefinition(H1.Model.ModelFromTrajectory, Z, J))),
  ...Ig(Z, J)
});
async function WS0(Z, J, $, X) {
  let Y = X.builders.structure, Q = await Y.createModel(J, $.model), W = await Y.insertModelProperties(Q, $.modelProperties), K = await Y.createStructure(W || Q, {
    name: "symmetry",
    params: Z
  }), G = await Y.insertStructureProperties(K, $.structureProperties), H = await Y.tryCreateUnitcell(W, void 0, { isHidden: !1 }), N = $.representationPreset || X.config.get(W8.Structure.DefaultRepresentationPreset) || hY.auto.id, q = await X.builders.structure.representation.applyPreset(G, N, { theme: { globalName: Z.theme } });
  return {
    model: Q,
    modelProperties: W,
    unitcell: H,
    structure: K,
    structureProperties: G,
    representation: q
  };
}
var _w1 = CE({
  id: "preset-trajectory-unitcell",
  display: {
    name: "Unit Cell",
    group: "Preset",
    description: "Shows the fully populated unit cell."
  },
  isApplicable: (Z) => {
    return O2.hasCrystalSymmetry(Z.data.representative);
  },
  params: QS0,
  async apply(Z, J, $) {
    return await WS0({ ijkMin: M.create(0, 0, 0), ijkMax: M.create(0, 0, 0) }, Z, J, $);
  }
}), Vw1 = CE({
  id: "preset-trajectory-supercell",
  display: {
    name: "Super Cell",
    group: "Preset",
    description: "Shows the super cell, i.e. the central unit cell and all adjacent unit cells."
  },
  isApplicable: (Z) => {
    return O2.hasCrystalSymmetry(Z.data.representative);
  },
  params: QS0,
  async apply(Z, J, $) {
    return await WS0({ ijkMin: M.create(-1, -1, -1), ijkMax: M.create(1, 1, 1), theme: "operator-hkl" }, Z, J, $);
  }
}), Iw1 = (Z, J) => ({
  model: j.Optional(j.Group(T1.getParamDefinition(H1.Model.ModelFromTrajectory, Z, J))),
  ...Ig(Z, J)
}), Pw1 = CE({
  id: "preset-trajectory-crystal-contacts",
  display: {
    name: "Crystal Contacts",
    group: "Preset",
    description: "Showsasymetric unit and chains from neighbours within 5 Å, i.e., symmetry mates."
  },
  isApplicable: (Z) => {
    return O2.hasCrystalSymmetry(Z.data.representative);
  },
  params: Iw1,
  async apply(Z, J, $) {
    let X = $.builders.structure, Y = await X.createModel(Z, J.model), Q = await X.insertModelProperties(Y, J.modelProperties), W = await X.createStructure(Q || Y, {
      name: "symmetry-mates",
      params: { radius: 5 }
    }), K = await X.insertStructureProperties(W, J.structureProperties), G = await X.tryCreateUnitcell(Q, void 0, { isHidden: !0 }), H = J.representationPreset || $.config.get(W8.Structure.DefaultRepresentationPreset) || hY.auto.id, N = await $.builders.structure.representation.applyPreset(K, H, { theme: { globalName: "operator-name", carbonColor: "operator-name", focus: { name: "element-symbol", params: { carbonColor: { name: "operator-name", params: MA.defaultValues } } } } });
    return {
      model: Y,
      modelProperties: Q,
      unitcell: G,
      structure: W,
      structureProperties: K,
      representation: N
    };
  }
}), Pg = {
  default: YS0,
  "all-models": Tw1,
  unitcell: _w1,
  supercell: Vw1,
  crystalContacts: Pw1
};

// node_modules/molstar/lib/mol-plugin-state/builder/structure/hierarchy.js
class J60 {
  resolveProvider(Z) {
    var J;
    return typeof Z === "string" ? (J = Pg[Z]) !== null && J !== void 0 ? J : VM(this._providers, ($) => $.id === Z) : Z;
  }
  hasPreset(Z) {
    for (let J of this._providers)
      if (!J.isApplicable || J.isApplicable(Z, this.plugin))
        return !0;
    return !1;
  }
  get providers() {
    return this._providers;
  }
  getPresets(Z) {
    if (!Z)
      return this.providers;
    let J = [];
    for (let $ of this._providers) {
      if ($.isApplicable && !$.isApplicable(Z, this.plugin))
        continue;
      J.push($);
    }
    return J;
  }
  getPresetSelect(Z) {
    let J = [];
    for (let $ of this._providers) {
      if (Z && $.isApplicable && !$.isApplicable(Z, this.plugin))
        continue;
      J.push([$.id, $.display.name]);
    }
    return j.Select("auto", J);
  }
  getPresetsWithOptions(Z) {
    let J = [], $ = Object.create(null);
    for (let X of this._providers) {
      if (X.isApplicable && !X.isApplicable(Z, this.plugin))
        continue;
      J.push([X.id, X.display.name]), $[X.id] = X.params ? j.Group(X.params(Z, this.plugin)) : j.EmptyGroup();
    }
    if (J.length === 0)
      return j.MappedStatic("", { "": j.EmptyGroup() });
    return j.MappedStatic(J[0][0], $, { options: J });
  }
  registerPreset(Z) {
    if (this.providerMap.has(Z.id))
      throw new Error(`Hierarchy provider with id '${Z.id}' already registered.`);
    this._providers.push(Z), this.providerMap.set(Z.id, Z);
  }
  unregisterPreset(Z) {
    this.providerMap.delete(Z.id), ZH(this._providers, Z);
  }
  applyPreset(Z, J, $) {
    let X = this.resolveProvider(J);
    if (!X)
      return;
    let Y = this.plugin.state.data, Q = X7.resolveAndCheck(Y, Z);
    if (!Q) {
      if (!aL)
        console.warn("Applying hierarchy preset provider to bad cell.");
      return;
    }
    let W = $ || (X.params ? j.getDefaultValues(X.params(Q.obj, this.plugin)) : {}), K = n0.create(`${X.display.name}`, () => X.apply(Q, W, this.plugin));
    return this.plugin.runTask(K);
  }
  constructor(Z) {
    this.plugin = Z, this._providers = [], this.providerMap = /* @__PURE__ */ new Map, this.defaultProvider = Pg.default, B7(Pg, (J) => this.registerPreset(J));
  }
}

// node_modules/molstar/lib/mol-plugin-state/builder/structure.js
class $60 {
  get dataState() {
    return this.plugin.state.data;
  }
  async parseTrajectoryData(Z, J) {
    let $ = typeof J === "string" ? this.plugin.dataFormats.get(J) : J;
    if (!$)
      throw new Error(`'${J}' is not a supported data format.`);
    let { trajectory: X } = await $.parse(this.plugin, Z);
    return X;
  }
  parseTrajectoryBlob(Z, J) {
    return this.dataState.build().to(Z).apply(H1.Data.ParseBlob, J, { state: { isGhost: !0 } }).apply(H1.Model.TrajectoryFromBlob, void 0).commit({ revertOnError: !0 });
  }
  parseTrajectory(Z, J) {
    let $ = X7.resolveAndCheck(this.dataState, Z);
    if (!$)
      throw new Error("Invalid data cell.");
    if (D0.Data.Blob.is($.obj))
      return this.parseTrajectoryBlob(Z, J);
    else
      return this.parseTrajectoryData(Z, J);
  }
  createModel(Z, J, $) {
    return this.dataState.build().to(Z).apply(H1.Model.ModelFromTrajectory, J || { modelIndex: 0 }, { state: $ }).commit({ revertOnError: !0 });
  }
  insertModelProperties(Z, J, $) {
    return this.dataState.build().to(Z).apply(H1.Model.CustomModelProperties, J, { state: $ }).commit({ revertOnError: !0 });
  }
  tryCreateUnitcell(Z, J, $) {
    var X, Y, Q;
    let W = this.dataState, K = (Y = (X = X7.resolveAndCheck(W, Z)) === null || X === void 0 ? void 0 : X.obj) === null || Y === void 0 ? void 0 : Y.data;
    if (!K)
      return;
    let G = (Q = T9.Provider.get(K)) === null || Q === void 0 ? void 0 : Q.spacegroup.cell;
    if (d7.isZero(G))
      return;
    return W.build().to(Z).apply(H1.Representation.ModelUnitcell3D, J, { state: $ }).commit({ revertOnError: !0 });
  }
  createStructure(Z, J, $, X) {
    var Y;
    let Q = this.dataState;
    if (!J) {
      let K = X7.resolveAndCheck(Q, Z);
      if (K) {
        let G = T9.Provider.get((Y = K.obj) === null || Y === void 0 ? void 0 : Y.data);
        if (!G || (G === null || G === void 0 ? void 0 : G.assemblies.length) === 0)
          J = { name: "model", params: {} };
      }
    }
    return Q.build().to(Z).apply(H1.Model.StructureFromModel, { type: J || { name: "assembly", params: {} } }, { state: $, tags: X }).commit({ revertOnError: !0 });
  }
  insertStructureProperties(Z, J) {
    return this.dataState.build().to(Z).apply(H1.Model.CustomStructureProperties, J).commit({ revertOnError: !0 });
  }
  isComponentTransform(Z) {
    return Z.transform.transformer === H1.Model.StructureComponent;
  }
  async tryCreateComponent(Z, J, $, X) {
    var Y, Q;
    let W = this.dataState, K = W.build().to(Z), G = `structure-component-${$}`, H = K.applyOrUpdateTagged(G, H1.Model.StructureComponent, J, {
      tags: X ? [...X, G] : [G]
    });
    await H.commit();
    let N = H.selector;
    if (!N.isOk || ((Q = (Y = N.cell) === null || Y === void 0 ? void 0 : Y.obj) === null || Q === void 0 ? void 0 : Q.data.elementCount) === 0) {
      await W.build().delete(N.ref).commit();
      return;
    }
    return N;
  }
  tryCreateComponentFromExpression(Z, J, $, X) {
    return this.tryCreateComponent(Z, {
      type: { name: "expression", params: J },
      nullIfEmpty: !0,
      label: ((X === null || X === void 0 ? void 0 : X.label) || "").trim()
    }, $, X === null || X === void 0 ? void 0 : X.tags);
  }
  tryCreateComponentStatic(Z, J, $) {
    return this.tryCreateComponent(Z, {
      type: { name: "static", params: J },
      nullIfEmpty: !0,
      label: (($ === null || $ === void 0 ? void 0 : $.label) || "").trim()
    }, `static-${J}`, $ === null || $ === void 0 ? void 0 : $.tags);
  }
  tryCreateComponentFromSelection(Z, J, $, X) {
    return this.plugin.runTask(n0.create("Query Component", async (Y) => {
      var Q, W;
      let { label: K, tags: G } = X || {};
      K = (K || "").trim();
      let H = (W = (Q = X7.resolveAndCheck(this.dataState, Z)) === null || Q === void 0 ? void 0 : Q.obj) === null || W === void 0 ? void 0 : W.data;
      if (!H)
        return;
      let N = J.referencesCurrent ? {
        type: {
          name: "bundle",
          params: W0.Bundle.fromSelection(await J.getSelection(this.plugin, Y, H))
        },
        nullIfEmpty: !0,
        label: K || J.label
      } : {
        type: { name: "expression", params: J.expression },
        nullIfEmpty: !0,
        label: K || J.label
      };
      if (J.ensureCustomProperties)
        await J.ensureCustomProperties({ runtime: Y, assetManager: this.plugin.managers.asset, errorContext: this.plugin.errorContext }, H);
      return this.tryCreateComponent(Z, N, $, G);
    }));
  }
  constructor(Z) {
    this.plugin = Z, this.hierarchy = new J60(this.plugin), this.representation = new Z60(this.plugin);
  }
}

// node_modules/molstar/lib/mol-model-formats/volume/property.js
var X60;
(function(Z) {
  function J($) {
    let { name: X } = $;
    return {
      descriptor: $,
      get(Y) {
        return Y._propertyData[X];
      },
      set(Y, Q) {
        Y.customProperties.add($), Y._propertyData[X] = Q;
      }
    };
  }
  Z.create = J;
})(X60 || (X60 = {}));
var FP;
(function(Z) {
  Z.Descriptor = {
    name: "recommended_iso_value"
  }, Z.Provider = X60.create(Z.Descriptor);
})(FP || (FP = {}));

// node_modules/molstar/lib/mol-plugin-state/formats/volume.js
var iB = "Volume";
async function UP(Z, J) {
  if (!J)
    return;
  let { entryId: $ } = J;
  if (!$ || !$.toLowerCase().startsWith("emd"))
    return;
  return Z.runTask(n0.create("Try Set Recommended IsoValue", async (X) => {
    try {
      let Y = await ps(Z, X, $);
      FP.Provider.set(J, Q1.IsoValue.absolute(Y));
    } catch (Y) {
      console.warn(Y);
    }
  }));
}
function KS0(Z) {
  let J = FP.Provider.get(Z);
  if (!J)
    return;
  if (J.kind === "relative")
    return J;
  return Q1.adjustedIsoValue(Z, J.absoluteValue, "absolute");
}
async function Y60(Z, J) {
  let $ = {}, X = J.volume.data && KS0(J.volume.data);
  if (X)
    $.isoValue = X;
  return [await Z.build().to(J.volume).apply(H1.Representation.VolumeRepresentation3D, IU(Z, J.volume.data, {
    type: "isosurface",
    typeParams: $
  })).commit()];
}
var Cw1 = cX({
  label: "CCP4/MRC/MAP",
  description: "CCP4/MRC/MAP",
  category: iB,
  binaryExtensions: ["ccp4", "mrc", "map"],
  parse: async (Z, J, $) => {
    let X = Z.build().to(J).apply(H1.Data.ParseCcp4, {}, { state: { isGhost: !0 } }), Y = X.apply(H1.Volume.VolumeFromCcp4, { entryId: $ === null || $ === void 0 ? void 0 : $.entryId });
    return await X.commit({ revertOnError: !0 }), await UP(Z, Y.selector.data), { format: X.selector, volume: Y.selector };
  },
  visuals: Y60
}), kw1 = cX({
  label: "DSN6/BRIX",
  description: "DSN6/BRIX",
  category: iB,
  binaryExtensions: ["dsn6", "brix"],
  parse: async (Z, J, $) => {
    let X = Z.build().to(J).apply(H1.Data.ParseDsn6, {}, { state: { isGhost: !0 } }), Y = X.apply(H1.Volume.VolumeFromDsn6, { entryId: $ === null || $ === void 0 ? void 0 : $.entryId });
    return await X.commit({ revertOnError: !0 }), await UP(Z, Y.selector.data), { format: X.selector, volume: Y.selector };
  },
  visuals: Y60
}), vw1 = cX({
  label: "DX",
  description: "DX",
  category: iB,
  stringExtensions: ["dx"],
  binaryExtensions: ["dxbin"],
  parse: async (Z, J, $) => {
    let Y = Z.build().to(J).apply(H1.Data.ParseDx, {}, { state: { isGhost: !0 } }).apply(H1.Volume.VolumeFromDx, { entryId: $ === null || $ === void 0 ? void 0 : $.entryId });
    return await Y.commit({ revertOnError: !0 }), await UP(Z, Y.selector.data), { volume: Y.selector };
  },
  visuals: Y60
}), Sw1 = cX({
  label: "Cube",
  description: "Cube",
  category: iB,
  stringExtensions: ["cub", "cube"],
  parse: async (Z, J, $) => {
    let X = Z.build().to(J).apply(H1.Data.ParseCube, {}, { state: { isGhost: !0 } }), Y = X.apply(H1.Volume.VolumeFromCube, { entryId: $ === null || $ === void 0 ? void 0 : $.entryId }), Q = X.apply(H1.Model.TrajectoryFromCube, void 0, { state: { isGhost: !0 } }).apply(H1.Model.ModelFromTrajectory).apply(H1.Model.StructureFromModel);
    return await X.commit({ revertOnError: !0 }), await UP(Z, Y.selector.data), { format: X.selector, volume: Y.selector, structure: Q.selector };
  },
  visuals: async (Z, J) => {
    var $, X;
    let Y = Z.build(), Q = [], W = (X = ($ = J.volume.cell) === null || $ === void 0 ? void 0 : $.obj) === null || X === void 0 ? void 0 : X.data;
    if (W && Q1.isOrbitals(W)) {
      let H = Y.to(J.volume).apply(H1.Representation.VolumeRepresentation3D, IU(Z, W, {
        type: "isosurface",
        typeParams: { isoValue: Q1.IsoValue.relative(1), alpha: 0.4 },
        color: "uniform",
        colorParams: { value: c2.blue }
      })), N = Y.to(J.volume).apply(H1.Representation.VolumeRepresentation3D, IU(Z, W, {
        type: "isosurface",
        typeParams: { isoValue: Q1.IsoValue.relative(-1), alpha: 0.4 },
        color: "uniform",
        colorParams: { value: c2.red }
      }));
      Q.push(H.selector, N.selector);
    } else {
      let H = Y.to(J.volume).apply(H1.Representation.VolumeRepresentation3D, IU(Z, W, {
        type: "isosurface",
        typeParams: { isoValue: Q1.IsoValue.relative(2), alpha: 0.4 },
        color: "uniform",
        colorParams: { value: c2.grey }
      }));
      Q.push(H.selector);
    }
    let K = await Z.builders.structure.representation.applyPreset(J.structure, "auto");
    await Y.commit();
    let G = [];
    return B7(K === null || K === void 0 ? void 0 : K.representations, (H) => {
      if (H)
        G.push(H);
    }), [...Q, ...G];
  }
}), fw1 = cX({
  label: "DensityServer CIF",
  description: "DensityServer CIF",
  category: iB,
  stringExtensions: ["cif"],
  binaryExtensions: ["bcif"],
  isApplicable: (Z, J) => {
    return OB(Z, J) === "dscif" ? !0 : !1;
  },
  parse: async (Z, J, $) => {
    var X;
    let Y = await Z.build().to(J).apply(H1.Data.ParseCif).commit(), Q = Z.build().to(Y), W = Y.obj.data.blocks;
    if (W.length === 0)
      throw new Error("no data blocks");
    let K = [], G = 0;
    for (let H of W) {
      if (H.header.toUpperCase() === "SERVER")
        continue;
      let N = Array.isArray($ === null || $ === void 0 ? void 0 : $.entryId) ? $ === null || $ === void 0 ? void 0 : $.entryId[G] : $ === null || $ === void 0 ? void 0 : $.entryId;
      if (((X = H.categories.volume_data_3d_info) === null || X === void 0 ? void 0 : X.rowCount) > 0)
        K.push(Q.apply(H1.Volume.VolumeFromDensityServerCif, { blockHeader: H.header, entryId: N }).selector), G++;
    }
    await Q.commit();
    for (let H of K)
      await UP(Z, H.data);
    return { volumes: K };
  },
  visuals: async (Z, J) => {
    let { volumes: $ } = J, X = Z.build(), Y = [];
    if ($.length > 0) {
      let Q = $[0].data && KS0($[0].data) || Q1.IsoValue.relative(1.5);
      Y[0] = X.to($[0]).apply(H1.Representation.VolumeRepresentation3D, l3.getDefaultParamsStatic(Z, "isosurface", { isoValue: Q, alpha: 1 }, "uniform", { value: c2.teal })).selector;
    }
    if ($.length > 1) {
      let Q = l3.getDefaultParamsStatic(Z, "isosurface", { isoValue: Q1.IsoValue.relative(3), alpha: 0.3 }, "uniform", { value: c2.green }), W = l3.getDefaultParamsStatic(Z, "isosurface", { isoValue: Q1.IsoValue.relative(-3), alpha: 0.3 }, "uniform", { value: c2.red });
      Y[Y.length] = X.to($[1]).apply(H1.Representation.VolumeRepresentation3D, Q).selector, Y[Y.length] = X.to($[1]).apply(H1.Representation.VolumeRepresentation3D, W).selector;
    }
    return await X.commit(), Y;
  }
}), hw1 = cX({
  label: "Segmentation CIF",
  description: "Segmentation CIF",
  category: iB,
  stringExtensions: ["cif"],
  binaryExtensions: ["bcif"],
  isApplicable: (Z, J) => {
    return OB(Z, J) === "segcif" ? !0 : !1;
  },
  parse: async (Z, J) => {
    var $;
    let X = await Z.build().to(J).apply(H1.Data.ParseCif).commit(), Y = Z.build().to(X), Q = X.obj.data.blocks;
    if (Q.length === 0)
      throw new Error("no data blocks");
    let W = [];
    for (let K of Q) {
      if (K.header.toUpperCase() === "SERVER")
        continue;
      if ((($ = K.categories.volume_data_3d_info) === null || $ === void 0 ? void 0 : $.rowCount) > 0)
        W.push(Y.apply(H1.Volume.VolumeFromSegmentationCif, { blockHeader: K.header }).selector);
    }
    return await Y.commit(), { volumes: W };
  },
  visuals: async (Z, J) => {
    let { volumes: $ } = J, X = Z.build(), Y = [];
    if ($.length > 0) {
      if (Q1.Segmentation.get($[0].data))
        Y[Y.length] = X.to($[0]).apply(H1.Representation.VolumeRepresentation3D, l3.getDefaultParams(Z, "segment", $[0].data, { alpha: 1, instanceGranularity: !0 }, "volume-segment", {})).selector;
    }
    return await X.commit(), Y;
  }
}), GS0 = [
  ["ccp4", Cw1],
  ["dsn6", kw1],
  ["cube", Sw1],
  ["dx", vw1],
  ["dscif", fw1],
  ["segcif", hw1]
];

// node_modules/molstar/lib/mol-plugin-state/formats/shape.js
var bw1 = "Shape", xw1 = cX({
  label: "PLY",
  description: "PLY",
  category: bw1,
  stringExtensions: ["ply"],
  parse: async (Z, J) => {
    let $ = Z.state.data.build().to(J).apply(H1.Data.ParsePly, {}, { state: { isGhost: !0 } }), X = $.apply(H1.Model.ShapeFromPly);
    return await $.commit(), { format: $.selector, shape: X.selector };
  },
  visuals(Z, J) {
    return Z.state.data.build().to(J.shape).apply(H1.Representation.ShapeRepresentation3D).commit();
  }
}), HS0 = [
  ["ply", xw1]
];

// node_modules/molstar/lib/mol-plugin-state/formats/registry.js
class Q60 {
  get types() {
    return this._list.map((Z) => [Z.name, Z.provider.label]);
  }
  get extensions() {
    if (this._extensions)
      return this._extensions;
    let Z = /* @__PURE__ */ new Set;
    return this._list.forEach(({ provider: J }) => {
      var $, X;
      ($ = J.stringExtensions) === null || $ === void 0 || $.forEach((Y) => Z.add(Y)), (X = J.binaryExtensions) === null || X === void 0 || X.forEach((Y) => Z.add(Y));
    }), this._extensions = Z, Z;
  }
  get binaryExtensions() {
    if (this._binaryExtensions)
      return this._binaryExtensions;
    let Z = /* @__PURE__ */ new Set;
    return this._list.forEach(({ provider: J }) => {
      var $;
      return ($ = J.binaryExtensions) === null || $ === void 0 ? void 0 : $.forEach((X) => Z.add(X));
    }), this._binaryExtensions = Z, Z;
  }
  get options() {
    if (this._options)
      return this._options;
    let Z = [];
    return this._list.forEach(({ name: J, provider: $ }) => Z.push([J, $.label, $.category || ""])), this._options = Z, Z;
  }
  constructor() {
    this._list = [], this._map = /* @__PURE__ */ new Map, this._extensions = void 0, this._binaryExtensions = void 0, this._options = void 0;
    for (let [Z, J] of GS0)
      this.add(Z, J);
    for (let [Z, J] of EV0)
      this.add(Z, J);
    for (let [Z, J] of OV0)
      this.add(Z, J);
    for (let [Z, J] of HS0)
      this.add(Z, J);
    for (let [Z, J] of Qy)
      this.add(Z, J);
  }
  _clear() {
    this._extensions = void 0, this._binaryExtensions = void 0, this._options = void 0;
  }
  add(Z, J) {
    this._clear(), this._list.push({ name: Z, provider: J }), this._map.set(Z, J);
  }
  remove(Z) {
    this._clear(), this._list.splice(this._list.findIndex((J) => J.name === Z), 1), this._map.delete(Z);
  }
  auto(Z, J) {
    var $, X;
    for (let Y = 0, Q = this.list.length;Y < Q; ++Y) {
      let W = this._list[Y].provider, K = !1;
      if (($ = W.binaryExtensions) === null || $ === void 0 ? void 0 : $.includes(Z.ext))
        K = !0;
      else if ((X = W.stringExtensions) === null || X === void 0 ? void 0 : X.includes(Z.ext))
        K = !0;
      if (K && (!W.isApplicable || W.isApplicable(Z, J.data)))
        return W;
    }
    return;
  }
  get(Z) {
    if (this._map.has(Z))
      return this._map.get(Z);
    else
      throw new Error(`unknown data format name '${Z}'`);
  }
  get list() {
    return this._list;
  }
}

// node_modules/molstar/lib/mol-plugin-state/manager/animation.js
class W60 extends pX {
  get isEmpty() {
    return this._animations.length === 0;
  }
  get current() {
    return this._current;
  }
  get animations() {
    return this._animations;
  }
  get isAnimatingStateTransition() {
    return this._current.anim.name === "built-in.animate-state-snapshot-transition";
  }
  triggerUpdate() {
    this.events.updated.next(void 0);
  }
  triggerApply() {
    this.events.applied.next(void 0);
  }
  getParams() {
    if (!this._params)
      this._params = {
        current: j.Select(this._animations[0] && this._animations[0].name, this._animations.map((Z) => [Z.name, Z.display.name]), { label: "Animation" })
      };
    return this._params;
  }
  updateParams(Z) {
    if (this.isEmpty)
      return;
    this.updateState({ params: { ...this.state.params, ...Z } });
    let J = this.map.get(this.state.params.current), $ = J.params(this.context);
    this._current = {
      anim: J,
      params: $,
      paramValues: j.getDefaultValues($),
      state: {},
      startedTime: -1,
      lastTime: 0
    }, this.triggerUpdate();
  }
  updateCurrentParams(Z) {
    if (this.isEmpty)
      return;
    this._current.paramValues = { ...this._current.paramValues, ...Z }, this.triggerUpdate();
  }
  register(Z) {
    if (this.map.has(Z.name)) {
      this.context.log.error(`Animation '${Z.name}' is already registered.`);
      return;
    }
    if (this._params = void 0, this.map.set(Z.name, Z), this._animations.push(Z), this._animations.length === 1)
      this.updateParams({ current: Z.name });
    else
      this.triggerUpdate();
  }
  async play(Z, J) {
    if (await this.stop(), !this.map.has(Z.name))
      this.register(Z);
    this.updateParams({ current: Z.name }), this.updateCurrentParams(J), await this.start();
  }
  async tick(Z, J, $) {
    if (this.currentTime = Z, this.isStopped)
      return;
    if (J || $)
      await this.applyFrame($);
    else
      this.applyAsync();
  }
  async start() {
    if (this.updateState({ animationState: "playing" }), !this.context.behaviors.state.isAnimating.value)
      this.context.behaviors.state.isAnimating.next(!0);
    this.triggerUpdate();
    let Z = this._current.anim, J = this._current.anim.initialState(this._current.paramValues, this.context);
    if (Z.setup) {
      let $ = await Z.setup(this._current.paramValues, J, this.context);
      if ($)
        J = $;
    }
    this._current.lastTime = 0, this._current.startedTime = -1, this._current.state = J, this.isStopped = !1;
  }
  async stop() {
    if (this.isStopped = !0, this.state.animationState !== "stopped") {
      let Z = this._current.anim;
      if (Z.teardown)
        await Z.teardown(this._current.paramValues, this._current.state, this.context);
      this.updateState({ animationState: "stopped" }), this.triggerUpdate();
    }
    if (this.context.behaviors.state.isAnimating.value)
      this.context.behaviors.state.isAnimating.next(!1);
  }
  stopStateTransitionAnimation() {
    if (!this.isAnimatingStateTransition)
      return;
    return this.stop();
  }
  get isAnimating() {
    return this.state.animationState === "playing";
  }
  async applyAsync() {
    if (this.isApplying)
      return;
    this.isApplying = !0;
    try {
      await this.applyFrame();
    } finally {
      this.isApplying = !1;
    }
  }
  async applyFrame(Z) {
    let J = this.currentTime;
    if (this._current.startedTime < 0)
      this._current.startedTime = J;
    let $ = await this._current.anim.apply(this._current.state, { lastApplied: this._current.lastTime, current: J - this._current.startedTime, animation: Z }, { params: this._current.paramValues, plugin: this.context });
    if ($.kind === "finished")
      this.stop();
    else if ($.kind === "next")
      this._current.state = $.state, this._current.lastTime = J - this._current.startedTime;
    this.triggerApply();
  }
  getSnapshot() {
    if (!this.current)
      return { state: this.state };
    return {
      state: this.state,
      current: {
        paramValues: this._current.paramValues,
        state: this._current.anim.stateSerialization ? this._current.anim.stateSerialization.toJSON(this._current.state) : this._current.state
      }
    };
  }
  setSnapshot(Z) {
    if (this.isEmpty)
      return;
    if (this.updateState({ animationState: Z.state.animationState }), this.updateParams(Z.state.params), Z.current) {
      if (this.current.paramValues = Z.current.paramValues, this.current.state = this._current.anim.stateSerialization ? this._current.anim.stateSerialization.fromJSON(Z.current.state) : Z.current.state, this.triggerUpdate(), this.state.animationState === "playing")
        this.resume();
    }
  }
  async resume() {
    this._current.lastTime = 0, this._current.startedTime = -1;
    let Z = this._current.anim;
    if (!this.context.behaviors.state.isAnimating.value)
      this.context.behaviors.state.isAnimating.next(!0);
    if (Z.setup)
      await Z.setup(this._current.paramValues, this._current.state, this.context);
    this.isStopped = !1;
  }
  constructor(Z) {
    super({ params: { current: "" }, animationState: "stopped" });
    this.context = Z, this.map = /* @__PURE__ */ new Map, this._animations = [], this.currentTime = 0, this._params = void 0, this.events = {
      updated: this.ev(),
      applied: this.ev()
    }, this.isStopped = !0, this.isApplying = !1;
  }
}

// node_modules/molstar/lib/mol-plugin-state/manager/focus-camera/focus-first-residue.js
function NS0(Z, J, $) {
  let X = $[0], Y = $[1], Q = $[2], W = -X * J[0] - Y * J[1] - Q * J[2], K = Z[0], G = Z[1], H = Z[2];
  return (X * K + Y * G + Q * H + W) / Math.sqrt(X * X + Y * Y + Q * Q);
}
function yw1(Z, J, $, X) {
  let Y = NS0(Z, J, X);
  return {
    aroundX: NS0(Z, J, $) < 0,
    aroundY: Y < 0
  };
}
function qS0(Z, J, $) {
  if (!Z.canvas3d)
    return;
  let { origin: X, dirA: Y, dirB: Q, dirC: W } = $.principalAxes.boxAxes, K = M.clone(Y), G = M.clone(W);
  if ($.positionToFlip) {
    let { aroundX: N, aroundY: q } = yw1($.positionToFlip, X, K, Q);
    if (N)
      M.negate(G, G), M.negate(K, K);
    if (q)
      M.negate(G, G);
  }
  let H = M.scale(M(), X, -100);
  if (M.dot(H, K) <= 0)
    M.negate(G, G);
  if (M.dot(M.unitY, G) <= 0)
    M.negate(K, K);
  return Z.canvas3d.camera.getFocus(X, J, K, G, O6.createDefaultSnapshot());
}

// node_modules/molstar/lib/mol-plugin-state/manager/focus-camera/focus-object.js
function US0(Z, J) {
  var $, X;
  if (!Z.canvas3d)
    return;
  let Y = ($ = J.targets) === null || $ === void 0 ? void 0 : $.map((W) => {
    var K, G, H;
    let N = W.targetRef !== void 0 ? K60(Z, W.targetRef) : FS0(Z);
    if (!N)
      return;
    let q = (K = W.radius) !== null && K !== void 0 ? K : N.radius * ((G = W.radiusFactor) !== null && G !== void 0 ? G : 1) + ((H = W.extraRadius) !== null && H !== void 0 ? H : 0);
    return C0.create(N.center, q);
  }).filter((W) => W !== void 0), Q = Y && Y.length > 0 ? G60(Y) : FS0(Z);
  return mw1(Z.canvas3d.camera, {
    center: Q.center,
    radius: Math.max(Q.radius, (X = J.minRadius) !== null && X !== void 0 ? X : 0),
    up: J.up,
    direction: J.direction
  });
}
var gw1 = M();
function mw1(Z, J) {
  var $, X;
  let Y = J.center, Q = Math.max(J.radius, 0.01), W = ($ = J.direction) !== null && $ !== void 0 ? $ : M.sub(M(), Z.target, Z.position), K = M.orthogonalize(M(), W, (X = J.up) !== null && X !== void 0 ? X : Z.up), G = Z.getTargetDistance(Q), H = M.setMagnitude(gw1, W, G), N = M.sub(M(), Y, H);
  return { target: Y, position: N, up: K, radius: Q };
}
function K60(Z, J) {
  let $ = LS0([], Z, J);
  if ($.length === 0)
    return;
  if ($.length === 1)
    return $[0];
  return G60($);
}
function LS0(Z, J, $) {
  let X = J.state.data.cells.get($), Y = dw1(J, X);
  if (Y)
    Z.push(...Y);
  else
    J.state.data.tree.children.get($).forEach((W) => LS0(Z, J, W));
  return Z;
}
function dw1(Z, J) {
  var $, X;
  let Y = J === null || J === void 0 ? void 0 : J.obj;
  if (!Y)
    return;
  if (!Y.data) {
    console.warn("Focus: no data");
    return;
  }
  if (Y.data instanceof s0) {
    let Q = f2.getDecorated(Z.state.data, J.transform.ref), W = (X = ($ = Q === null || Q === void 0 ? void 0 : Q.obj) === null || $ === void 0 ? void 0 : $.data) !== null && X !== void 0 ? X : Y === null || Y === void 0 ? void 0 : Y.data, K = d2.getBoundingSphere(s0.Loci(W));
    return K ? [K] : [];
  } else if (D0.isRepresentation3D(Y)) {
    let Q = [];
    for (let W of Y.data.repr.renderObjects) {
      let K = W.values.boundingSphere.ref.value;
      if (K.radius > 0)
        Q.push(K);
    }
    return Q;
  }
  return;
}
function FS0(Z) {
  let $ = pw1(Z, !1).map((X) => X.values.boundingSphere.ref.value).filter((X) => X.radius > 0);
  return G60($);
}
function pw1(Z, J) {
  let $ = Array.from(Z.state.data.cells.values()).filter((Y) => Y.obj && D0.isRepresentation3D(Y.obj));
  if (!J)
    $ = $.filter((Y) => !Y.state.isHidden);
  return $.flatMap((Y) => Y.obj.data.repr.renderObjects);
}
var kU = void 0;
function G60(Z) {
  kU !== null && kU !== void 0 || (kU = new $J("98")), kU.reset();
  for (let J of Z)
    kU.includeSphere(J);
  kU.finishedIncludeStep();
  for (let J of Z)
    kU.radiusSphere(J);
  return kU.getSphere();
}

// node_modules/molstar/lib/mol-plugin-state/manager/focus-camera/orient-axes.js
var uw1 = 3, bq = {
  identity: h2.create(1, 0, 0, 0, 1, 0, 0, 0, 1),
  rotX90: h2.create(1, 0, 0, 0, 0, 1, 0, -1, 0),
  rotY90: h2.create(0, 0, -1, 0, 1, 0, 1, 0, 0),
  rotZ90: h2.create(0, 1, 0, -1, 0, 0, 0, 0, 1),
  rotX270: h2.create(1, 0, 0, 0, 0, -1, 0, 1, 0),
  rotY270: h2.create(0, 0, 1, 0, 1, 0, -1, 0, 0),
  rotZ270: h2.create(0, -1, 0, 1, 0, 0, 0, 0, 1),
  rotX180: h2.create(1, 0, 0, 0, -1, 0, 0, 0, -1),
  rotY180: h2.create(-1, 0, 0, 0, 1, 0, 0, 0, -1),
  rotZ180: h2.create(-1, 0, 0, 0, -1, 0, 0, 0, 1)
};
function RS0(Z, J) {
  let $ = lw1(Z, uw1);
  return cw1($, J);
}
function cw1(Z, J) {
  if (Z.length === 0)
    return console.warn("Skipping PCA, no atoms"), { rotation: bq.identity, origin: M.zero() };
  let $ = HY.calculateMomentsAxes(Z), X = HY.calculateNormalizedAxes($), Y = sw1(X.dirA, X.dirB, X.dirC);
  aw1(Y);
  let Q = J ? nw1(Y, J) : iw1(Z, Y, $.origin);
  return h2.mul(Y, Q, Y), { rotation: Y, origin: X.origin };
}
function lw1(Z, J) {
  let $;
  if ($ = H60(Z, { onlyTrace: !0 }), $.length >= 3 * J)
    return $;
  if ($ = H60(Z, { skipHydrogens: !0, skipWater: !0 }), $.length >= 3 * J)
    return $;
  return $ = H60(Z, {}), $;
}
function H60(Z, J) {
  let { onlyTrace: $, skipHydrogens: X, skipWater: Y } = J, { x: Q, y: W, z: K, type_symbol: G, label_comp_id: H } = w1.atom, N = [];
  for (let q of Z) {
    let U = W0.Location.create(q);
    for (let F of q.units) {
      U.unit = F;
      let E = $ ? F.polymerElements : F.elements;
      for (let R = 0;R < E.length; R++) {
        if (U.element = E[R], X && G(U) === "H")
          continue;
        if (Y && H(U) === "HOH")
          continue;
        N.push(Q(U), W(U), K(U));
      }
    }
  }
  return N;
}
function nw1(Z, J) {
  let $ = bq.identity, X = 0, Y = h2();
  for (let Q of [bq.identity, bq.rotX180, bq.rotY180, bq.rotZ180]) {
    let W = h2.innerProduct(h2.mul(Y, Q, Z), J);
    if (W > X)
      $ = Q, X = W;
  }
  return $;
}
function iw1(Z, J, $) {
  let X = M.create(h2.getValue(J, 0, 0), h2.getValue(J, 0, 1), h2.getValue(J, 0, 2)), Y = M.create(h2.getValue(J, 1, 0), h2.getValue(J, 1, 1), h2.getValue(J, 1, 2)), Q = M.create(h2.getValue(J, 2, 0), h2.getValue(J, 2, 1), h2.getValue(J, 2, 2)), W = Math.floor(Z.length / 3), K = M(), G = 0, H = 0, N = 0;
  for (let F = 0;F < W; F++)
    M.fromArray(K, Z, 3 * F), M.sub(K, K, $), G += F * M.dot(K, X), H += F * M.dot(K, Y), N += ow1(F, W) * M.dot(K, Q);
  let q = N < 0, U = q ? G + H < 0 : G - H < 0;
  if (U && q)
    return bq.rotY180;
  else if (q)
    return bq.rotX180;
  else if (U)
    return bq.rotZ180;
  else
    return bq.identity;
}
function ow1(Z, J) {
  let $ = Math.floor(J / 2);
  if (Z < $)
    if (J % 2)
      return $ - Z;
    else
      return $ - Z - 1;
  else
    return Z - $;
}
function sw1(Z, J, $) {
  let X = h2();
  return h2.setValue(X, 0, 0, Z[0]), h2.setValue(X, 0, 1, Z[1]), h2.setValue(X, 0, 2, Z[2]), h2.setValue(X, 1, 0, J[0]), h2.setValue(X, 1, 1, J[1]), h2.setValue(X, 1, 2, J[2]), h2.setValue(X, 2, 0, $[0]), h2.setValue(X, 2, 1, $[1]), h2.setValue(X, 2, 2, $[2]), X;
}
function aw1(Z) {
  if (h2.determinant(Z) < 0)
    h2.setValue(Z, 2, 0, -h2.getValue(Z, 2, 0)), h2.setValue(Z, 2, 1, -h2.getValue(Z, 2, 1)), h2.setValue(Z, 2, 2, -h2.getValue(Z, 2, 2));
}
function N60(Z, J) {
  let $ = h2.invert(h2(), J), X = M.distance(Z.position, Z.target), Y = M.transformMat3(M(), M.create(0, 0, X), $), Q = M.transformMat3(M(), M.create(0, 1, 0), $), W = M.add(M(), Z.target, Y);
  return { ...Z, position: W, up: Q };
}

// node_modules/molstar/lib/mol-plugin-state/manager/camera.js
var Cg = {
  minRadius: 1,
  extraRadius: 4,
  durationMs: 250
};

class q60 {
  transformedLoci(Z) {
    var J, $;
    if (W0.Loci.is(Z)) {
      let X = ($ = (J = this.plugin.helpers.substructureParent.get(Z.structure)) === null || J === void 0 ? void 0 : J.obj) === null || $ === void 0 ? void 0 : $.data;
      if (X)
        Z = W0.Loci.remap(Z, X);
    }
    return Z;
  }
  focusRenderObjects(Z, J) {
    if (!Z)
      return;
    let $ = [];
    for (let X of Z) {
      let Y = X.values.boundingSphere.ref.value;
      if (Y.radius === 0)
        continue;
      $.push(Y);
    }
    this.focusSpheres($, (X) => X, J);
  }
  focusLoci(Z, J) {
    let $;
    if (Array.isArray(Z) && Z.length > 1) {
      let X = [];
      for (let Y of Z) {
        let Q = d2.getBoundingSphere(this.transformedLoci(Y));
        if (Q)
          X.push(Q);
      }
      if (X.length === 0)
        return;
      this.boundaryHelper.reset();
      for (let Y of X)
        this.boundaryHelper.includeSphere(Y);
      this.boundaryHelper.finishedIncludeStep();
      for (let Y of X)
        this.boundaryHelper.radiusSphere(Y);
      $ = this.boundaryHelper.getSphere();
    } else if (Array.isArray(Z)) {
      if (Z.length === 0)
        return;
      $ = d2.getBoundingSphere(this.transformedLoci(Z[0]));
    } else
      $ = d2.getBoundingSphere(this.transformedLoci(Z));
    if ($)
      this.focusSphere($, J);
  }
  focusSpheres(Z, J, $) {
    let X = [];
    for (let Y of Z) {
      let Q = J(Y);
      if (Q)
        X.push(Q);
    }
    if (X.length === 0)
      return;
    if (X.length === 1)
      return this.focusSphere(X[0], $);
    this.boundaryHelper.reset();
    for (let Y of X)
      this.boundaryHelper.includeSphere(Y);
    this.boundaryHelper.finishedIncludeStep();
    for (let Y of X)
      this.boundaryHelper.radiusSphere(Y);
    this.focusSphere(this.boundaryHelper.getSphere(), $);
  }
  focusSphere(Z, J) {
    var $;
    let { canvas3d: X } = this.plugin;
    if (!X)
      return;
    let { extraRadius: Y, minRadius: Q, durationMs: W } = { ...Cg, ...J }, K = Math.max(Z.radius + Y, Q);
    if (J === null || J === void 0 ? void 0 : J.principalAxes) {
      let G = qS0(this.plugin, K, J);
      ($ = this.plugin.canvas3d) === null || $ === void 0 || $.requestCameraReset({ durationMs: W, snapshot: G });
    } else {
      let G = X.camera.getFocus(Z.center, K);
      X.requestCameraReset({ durationMs: W, snapshot: G });
    }
  }
  focusObject(Z) {
    var J, $, X;
    if (!this.plugin.canvas3d)
      return;
    let Y = US0(this.plugin, {
      ...Z,
      targets: (J = Z.targets) === null || J === void 0 ? void 0 : J.map((Q) => {
        var W;
        return { ...Q, extraRadius: (W = Q.extraRadius) !== null && W !== void 0 ? W : Cg.extraRadius };
      }),
      minRadius: ($ = Z.minRadius) !== null && $ !== void 0 ? $ : Cg.minRadius
    });
    this.plugin.canvas3d.requestCameraReset({ snapshot: Y, durationMs: (X = Z.durationMs) !== null && X !== void 0 ? X : Cg.durationMs });
  }
  orientAxes(Z, J) {
    if (!this.plugin.canvas3d)
      return;
    if (!Z)
      Z = this.plugin.state.data.selectQ((W) => W.ofType(D0.Molecule.Structure)).filter((W) => W.obj && !W.transform.transformer.definition.isDecorator && !W.obj.data.parent).map((W) => {
        var K;
        return (K = W.obj) === null || K === void 0 ? void 0 : K.data;
      }).filter((W) => !!W);
    let { rotation: $ } = RS0(Z), X = N60(this.plugin.canvas3d.camera.getSnapshot(), $);
    this.setSnapshot(X, J);
  }
  resetAxes(Z) {
    if (!this.plugin.canvas3d)
      return;
    let J = N60(this.plugin.canvas3d.camera.getSnapshot(), h2.Identity);
    this.setSnapshot(J, Z);
  }
  setSnapshot(Z, J) {
    var $;
    ($ = this.plugin.canvas3d) === null || $ === void 0 || $.requestCameraReset({ snapshot: Z, durationMs: J });
  }
  reset(Z, J) {
    var $;
    ($ = this.plugin.canvas3d) === null || $ === void 0 || $.requestCameraReset({ snapshot: Z, durationMs: J });
  }
  constructor(Z) {
    this.plugin = Z, this.boundaryHelper = new $J("98");
  }
}

// node_modules/molstar/lib/mol-plugin-state/manager/loci-label.js
class F60 {
  clearProviders() {
    this.providers = [], this.isDirty = !0, this.showLabels();
  }
  addProvider(Z) {
    this.providers.push(Z), this.providers.sort((J, $) => ($.priority || 0) - (J.priority || 0)), this.isDirty = !0, this.showLabels();
  }
  removeProvider(Z) {
    this.providers = this.providers.filter((J) => J !== Z), this.isDirty = !0, this.showLabels();
  }
  mark(Z, J) {
    let $ = this.locis.findIndex((X) => V2.Loci.areEqual(Z, X));
    if ($ === -1 && J === x2.Highlight)
      this.locis.push(Z), this.isDirty = !0;
    else if ($ !== -1 && J === x2.RemoveHighlight)
      XR(this.locis, $), this.isDirty = !0;
  }
  showLabels() {
    this.ctx.behaviors.labels.highlight.next({ labels: this.getLabels() });
  }
  getLabels() {
    if (this.isDirty) {
      this.groupedLabels.clear(), this.labels.length = 0;
      for (let Z of this.providers)
        for (let J of this.locis) {
          if (d2.isEmpty(J.loci))
            continue;
          let $ = Z.label(J.loci, J.repr);
          if ($) {
            let X = Z.group ? Z.group($) : $.toString(), Y = this.groupedLabels.get(X);
            if (Y)
              Y.push($);
            else
              this.groupedLabels.set(X, [$]);
          }
        }
      this.labels.length = 0, this.groupedLabels.forEach((Z, J) => {
        let $ = Z.length, X = $ > 1 && Z[0] !== Z[1] ? J : Z[0];
        this.labels.push($ === 1 ? X : `${X} <small>|| × ${$}</small>`);
      }), this.isDirty = !1;
    }
    return this.labels;
  }
  constructor(Z) {
    this.ctx = Z, this.providers = [], this.locis = [], this.isDirty = !1, this.labels = [], this.groupedLabels = /* @__PURE__ */ new Map, Z.managers.interactivity.lociHighlights.addProvider((J, $, X) => {
      if (this.providers.length === 0)
        return;
      if (this.mark(J, $), !X)
        this.showLabels();
    });
  }
}

// node_modules/molstar/lib/mol-plugin-state/manager/structure/selection.js
var LP = new $J("98"), rw1 = 24;

class U60 extends pX {
  get entries() {
    return this.state.entries;
  }
  get additionsHistory() {
    return this.state.additionsHistory;
  }
  get stats() {
    if (this.state.stats)
      return this.state.stats;
    return this.state.stats = this.calcStats(), this.state.stats;
  }
  getEntry(Z) {
    let J = this.plugin.helpers.substructureParent.get(Z, !0);
    if (!J)
      return;
    let $ = J.transform.ref;
    if (!this.entries.has($)) {
      let X = new kg(W0.Loci(Z, []));
      return this.entries.set($, X), X;
    }
    return this.entries.get($);
  }
  calcStats() {
    let Z = 0, J = 0, $ = W0.Stats.create();
    this.entries.forEach((Y) => {
      let { elements: Q } = Y.selection;
      if (Q.length) {
        Z += 1;
        for (let W = 0, K = Q.length;W < K; ++W)
          J += f0.size(Q[W].indices);
        W0.Stats.add($, $, W0.Stats.ofLoci(Y.selection));
      }
    });
    let X = kz($, { countsOnly: !0 });
    return { structureCount: Z, elementCount: J, label: X };
  }
  add(Z) {
    if (!W0.Loci.is(Z))
      return !1;
    let J = this.getEntry(Z.structure);
    if (!J)
      return !1;
    let $ = J.selection;
    return J.selection = W0.Loci.union(J.selection, Z), this.tryAddHistory(Z), this.referenceLoci = Z, this.events.loci.add.next(Z), !W0.Loci.areEqual($, J.selection);
  }
  remove(Z) {
    if (!W0.Loci.is(Z))
      return !1;
    let J = this.getEntry(Z.structure);
    if (!J)
      return !1;
    let $ = J.selection;
    return J.selection = W0.Loci.subtract(J.selection, Z), this.referenceLoci = Z, this.events.loci.remove.next(Z), !W0.Loci.areEqual($, J.selection);
  }
  intersect(Z) {
    if (!W0.Loci.is(Z))
      return !1;
    let J = this.getEntry(Z.structure);
    if (!J)
      return !1;
    let $ = J.selection;
    return J.selection = W0.Loci.intersect(J.selection, Z), this.referenceLoci = Z, !W0.Loci.areEqual($, J.selection);
  }
  set(Z) {
    if (!W0.Loci.is(Z))
      return !1;
    let J = this.getEntry(Z.structure);
    if (!J)
      return !1;
    let $ = J.selection;
    return J.selection = Z, this.tryAddHistory(Z), this.referenceLoci = void 0, !W0.Loci.areEqual($, J.selection);
  }
  modifyHistory(Z, J, $, X = !1) {
    let Y = this.additionsHistory, Q = Y.indexOf(Z);
    if (Q < 0)
      return;
    let W = void 0;
    switch (J) {
      case "remove":
        XR(Y, Q);
        break;
      case "up":
        W = Q - 1;
        break;
      case "down":
        W = Q + 1;
        break;
    }
    if (W !== void 0) {
      let K = $ ? Math.min(Y.length, $) : Y.length;
      while (!0) {
        if (W = W % K, W < 0)
          W += K;
        if (!X || Y[Q].loci.structure === Y[W].loci.structure) {
          let G = Y[Q];
          Y[Q] = Y[W], Y[W] = G;
          break;
        } else
          W += J === "up" ? -1 : 1;
      }
    }
    this.events.additionsHistoryUpdated.next(void 0);
  }
  tryAddHistory(Z) {
    if (d2.isEmpty(Z))
      return;
    let J = 0, $ = void 0;
    for (let Q of this.additionsHistory) {
      if (d2.areEqual(Q.loci, Z)) {
        $ = Q;
        break;
      }
      J++;
    }
    if ($) {
      XR(this.additionsHistory, J), this.additionsHistory.unshift($), this.events.additionsHistoryUpdated.next(void 0);
      return;
    }
    let X = W0.Stats.ofLoci(Z), Y = kz(X, { reverse: !0 });
    if (this.additionsHistory.unshift({ id: R6.create22(), loci: Z, label: Y }), this.additionsHistory.length > rw1)
      this.additionsHistory.pop();
    this.events.additionsHistoryUpdated.next(void 0);
  }
  clearHistory() {
    if (this.state.additionsHistory.length !== 0)
      this.state.additionsHistory = [], this.events.additionsHistoryUpdated.next(void 0);
  }
  clearHistoryForStructure(Z) {
    let J = [];
    for (let $ of this.state.additionsHistory)
      if ($.loci.structure.root === Z.root)
        J.push($);
    for (let $ of J)
      this.modifyHistory($, "remove");
    if (J.length !== 0)
      this.events.additionsHistoryUpdated.next(void 0);
  }
  onRemove(Z, J) {
    var $;
    if (this.entries.has(Z)) {
      if (this.entries.delete(Z), J === null || J === void 0 ? void 0 : J.data)
        this.clearHistoryForStructure(J.data);
      if ((($ = this.referenceLoci) === null || $ === void 0 ? void 0 : $.structure) === (J === null || J === void 0 ? void 0 : J.data))
        this.referenceLoci = void 0;
      this.state.stats = void 0, this.events.changed.next(void 0);
    }
  }
  onUpdate(Z, J, $) {
    var X, Y, Q, W;
    if (J === $ || (J === null || J === void 0 ? void 0 : J.data) === $.data)
      return;
    let K = this.plugin.helpers.substructureParent.get($.data, !0);
    if (!K)
      return;
    if (Z !== K.transform.ref)
      return;
    if (!this.entries.has(Z))
      return;
    let G = (Y = (X = this.plugin.helpers.substructureParent.get($.data)) === null || X === void 0 ? void 0 : X.obj) === null || Y === void 0 ? void 0 : Y.data;
    if (!G)
      return;
    if (!(J === null || J === void 0 ? void 0 : J.data) || s0.areUnitIdsAndIndicesEqual(J.data, $.data)) {
      if (this.entries.set(Z, ew1(this.entries.get(Z), G)), ((Q = this.referenceLoci) === null || Q === void 0 ? void 0 : Q.structure.root) === G.root)
        this.referenceLoci = W0.Loci.remap(this.referenceLoci, G);
      let H = !1;
      for (let N of this.state.additionsHistory)
        if (N.loci.structure.root === G.root)
          N.loci = W0.Loci.remap(N.loci, G), H = !0;
      if (H)
        this.events.additionsHistoryUpdated.next(void 0);
    } else {
      if (this.entries.set(Z, new kg(W0.Loci(G, []))), ((W = this.referenceLoci) === null || W === void 0 ? void 0 : W.structure.root) === G.root)
        this.referenceLoci = void 0;
      this.clearHistoryForStructure(G), this.state.stats = void 0, this.events.changed.next(void 0);
    }
  }
  clear() {
    let Z = this.entries.keys(), J = [];
    while (!0) {
      let $ = Z.next();
      if ($.done)
        break;
      let X = this.entries.get($.value);
      if (!W0.Loci.isEmpty(X.selection))
        J.push(X.selection);
      X.selection = W0.Loci(X.selection.structure, []);
    }
    return this.referenceLoci = void 0, this.state.stats = void 0, this.events.changed.next(void 0), this.events.loci.clear.next(void 0), this.clearHistory(), J;
  }
  getLoci(Z) {
    let J = this.getEntry(Z);
    if (!J)
      return G8;
    return J.selection;
  }
  getStructure(Z) {
    let J = this.getEntry(Z);
    if (!J)
      return;
    return J.structure;
  }
  structureHasSelection(Z) {
    var J, $;
    let X = ($ = (J = Z.cell) === null || J === void 0 ? void 0 : J.obj) === null || $ === void 0 ? void 0 : $.data;
    if (!X)
      return !1;
    let Y = this.getEntry(X);
    return !!Y && !W0.Loci.isEmpty(Y.selection);
  }
  has(Z) {
    if (W0.Loci.is(Z)) {
      let J = this.getEntry(Z.structure);
      if (J)
        return W0.Loci.isSubset(J.selection, Z);
    }
    return !1;
  }
  tryGetRange(Z) {
    if (!W0.Loci.is(Z))
      return;
    if (!this.getEntry(Z.structure))
      return;
    return L60(this.referenceLoci, Z);
  }
  elementCount() {
    let Z = 0;
    return this.entries.forEach((J) => {
      Z += W0.Loci.size(J.selection);
    }), Z;
  }
  getBoundary() {
    let Z = M.create(Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE), J = M.create(-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE);
    LP.reset();
    let $ = [];
    this.entries.forEach((X) => {
      let Y = X.selection;
      if (!W0.Loci.isEmpty(Y))
        $.push(W0.Loci.getBoundary(Y));
    });
    for (let X = 0, Y = $.length;X < Y; ++X) {
      let { box: Q, sphere: W } = $[X];
      M.min(Z, Z, Q.min), M.max(J, J, Q.max), LP.includePositionRadius(W.center, W.radius);
    }
    LP.finishedIncludeStep();
    for (let X = 0, Y = $.length;X < Y; ++X) {
      let { sphere: Q } = $[X];
      LP.radiusPositionRadius(Q.center, Q.radius);
    }
    return { box: { min: Z, max: J }, sphere: LP.getSphere() };
  }
  getPrincipalAxes() {
    let Z = IM(this.entries.values());
    return W0.Loci.getPrincipalAxesMany(Z.map((J) => J.selection));
  }
  modify(Z, J) {
    let $ = !1;
    switch (Z) {
      case "add":
        $ = this.add(J);
        break;
      case "remove":
        $ = this.remove(J);
        break;
      case "intersect":
        $ = this.intersect(J);
        break;
      case "set":
        $ = this.set(J);
        break;
    }
    if ($)
      this.state.stats = void 0, this.events.changed.next(void 0);
  }
  get applicableStructures() {
    return this.plugin.managers.structure.hierarchy.selection.structures.filter((Z) => !!Z.cell.obj).map((Z) => Z.cell.obj.data);
  }
  triggerInteraction(Z, J, $ = !0) {
    switch (Z) {
      case "add":
        this.plugin.managers.interactivity.lociSelects.select({ loci: J }, $);
        break;
      case "remove":
        this.plugin.managers.interactivity.lociSelects.deselect({ loci: J }, $);
        break;
      case "intersect":
        this.plugin.managers.interactivity.lociSelects.selectJoin({ loci: J }, $);
        break;
      case "set":
        this.plugin.managers.interactivity.lociSelects.selectOnly({ loci: J }, $);
        break;
    }
  }
  fromLoci(Z, J, $ = !0) {
    this.triggerInteraction(Z, J, $);
  }
  fromCompiledQuery(Z, J, $ = !0) {
    for (let X of this.applicableStructures) {
      let Y = J(new C9(X));
      this.triggerInteraction(Z, f1.toLociWithSourceUnits(Y), $);
    }
  }
  fromSelectionQuery(Z, J, $ = !0) {
    this.plugin.runTask(n0.create("Structure Selection", async (X) => {
      for (let Y of this.applicableStructures) {
        let Q = await J.getSelection(this.plugin, X, Y);
        this.triggerInteraction(Z, f1.toLociWithSourceUnits(Q), $);
      }
    }));
  }
  fromSelections(Z) {
    var J;
    let $ = X7.resolveAndCheck(this.plugin.state.data, Z);
    if (!$ || !$.obj)
      return;
    if (!D0.Molecule.Structure.Selections.is($.obj)) {
      console.warn("fromSelections applied to wrong object type.", $.obj);
      return;
    }
    this.clear();
    for (let X of (J = $.obj) === null || J === void 0 ? void 0 : J.data)
      this.fromLoci("set", X.loci);
  }
  getSnapshot() {
    let Z = [];
    return this.entries.forEach((J, $) => {
      Z.push({
        ref: $,
        bundle: W0.Bundle.fromLoci(J.selection)
      });
    }), { entries: Z };
  }
  setSnapshot(Z) {
    var J, $;
    this.entries.clear();
    for (let { ref: X, bundle: Y } of Z.entries) {
      let Q = ($ = (J = this.plugin.state.data.select(f2.Generators.byRef(X))[0]) === null || J === void 0 ? void 0 : J.obj) === null || $ === void 0 ? void 0 : $.data;
      if (!Q)
        continue;
      let W = W0.Bundle.toLoci(Y, Q);
      this.fromLoci("set", W, !1);
    }
  }
  constructor(Z) {
    super({ entries: /* @__PURE__ */ new Map, additionsHistory: [], stats: tw1() });
    this.plugin = Z, this.events = {
      changed: this.ev(),
      additionsHistoryUpdated: this.ev(),
      loci: {
        add: this.ev(),
        remove: this.ev(),
        clear: this.ev()
      }
    }, Z.helpers.substructureParent.events.removed.subscribe((J) => this.onRemove(J.ref, J.obj)), Z.helpers.substructureParent.events.updated.subscribe((J) => this.onUpdate(J.ref, J.oldObj, J.obj));
  }
}
function tw1() {
  return { structureCount: 0, elementCount: 0, label: "Nothing Selected" };
}

class kg {
  get selection() {
    return this._selection;
  }
  set selection(Z) {
    this._selection = Z, this._structure = void 0;
  }
  get structure() {
    if (this._structure)
      return this._structure;
    if (d2.isEmpty(this._selection))
      this._structure = void 0;
    else
      this._structure = W0.Loci.toStructure(this._selection);
    return this._structure;
  }
  constructor(Z) {
    this._structure = void 0, this._selection = Z;
  }
}
function ew1(Z, J) {
  return new kg(W0.Loci.remap(Z.selection, J));
}
function L60(Z, J) {
  if (!W0.Loci.is(Z))
    return;
  if (!W0.Loci.is(J))
    return;
  if (Z.structure !== J.structure)
    return;
  if (J.elements.length !== 1)
    return;
  let $ = J.elements[0];
  if (!$)
    return;
  let X;
  for (let Y of Z.elements)
    if ($.unit === Y.unit) {
      X = Y;
      break;
    }
  if (!X)
    return;
  if ($.unit !== X.unit)
    return;
  return Zj1(J.structure, X, $);
}
function Zj1(Z, J, $) {
  let X = Math.min(f0.min(J.indices), f0.min($.indices)), Y = Math.max(f0.max(J.indices), f0.max($.indices));
  return W0.Loci(Z, [{
    unit: J.unit,
    indices: f0.ofRange(X, Y)
  }]);
}

// node_modules/molstar/lib/mol-plugin-state/manager/structure/focus.js
var Jj1 = 8;

class R60 extends pX {
  get current() {
    return this.state.current;
  }
  get history() {
    return this.state.history;
  }
  tryAddHistory(Z) {
    if (W0.Loci.isEmpty(Z.loci))
      return;
    let J = 0, $ = void 0;
    for (let X of this.state.history) {
      if (W0.Loci.areEqual(X.loci, Z.loci)) {
        $ = X;
        break;
      }
      J++;
    }
    if ($) {
      XR(this.state.history, J), this.state.history.unshift(Z), this.events.historyUpdated.next(void 0);
      return;
    }
    if (this.state.history.unshift(Z), this.state.history.length > Jj1)
      this.state.history.pop();
    this.events.historyUpdated.next(void 0);
  }
  set(Z) {
    if (this.tryAddHistory(Z), !this.state.current || !W0.Loci.areEqual(this.state.current.loci, Z.loci))
      this.state.current = Z, this.behaviors.current.next(Z);
  }
  tryGetRange(Z) {
    return L60(this.referenceLoci, Z);
  }
  setFromLoci(Z) {
    let J = d2.normalize(Z);
    if (!W0.Loci.is(J) || W0.Loci.isEmpty(J)) {
      this.clear();
      return;
    }
    this.set({ loci: J, label: c3(J, { reverse: !0, hidePrefix: !0, htmlStyling: !1 }) }), this.referenceLoci = J;
  }
  addFromLoci(Z) {
    let J = this.state.current && W0.Loci.is(Z) && Z.structure === this.state.current.loci.structure ? W0.Loci.union(Z, this.state.current.loci) : Z;
    this.setFromLoci(J);
    let $ = d2.normalize(Z);
    this.referenceLoci = W0.Loci.is($) ? $ : void 0;
  }
  toggleFromLoci(Z) {
    var J;
    let { kind: $, loci: X } = $j1((J = this.state.current) === null || J === void 0 ? void 0 : J.loci, Z);
    this.setFromLoci(X);
    let Y = d2.normalize(Z);
    this.referenceLoci = W0.Loci.is(Y) && $ !== "subtract" ? Y : void 0;
  }
  extendFromLoci(Z) {
    var J;
    let $ = (J = this.tryGetRange(Z)) !== null && J !== void 0 ? J : Z;
    this.toggleFromLoci($);
  }
  clear() {
    if (this.state.current)
      this.state.current = void 0, this.behaviors.current.next(void 0);
    this.referenceLoci = void 0;
  }
  getSnapshot() {
    if (!this.current)
      return {};
    let Z = this.plugin.helpers.substructureParent.get(this.current.loci.structure), J = Z === null || Z === void 0 ? void 0 : Z.transform.ref;
    if (!J)
      return {};
    return {
      current: {
        label: this.current.label,
        ref: J,
        bundle: W0.Bundle.fromLoci(this.current.loci),
        category: this.current.category
      }
    };
  }
  setSnapshot(Z) {
    var J, $;
    if (!Z.current) {
      this.clear();
      return;
    }
    let { label: X, ref: Y, bundle: Q, category: W } = Z.current, K = ($ = (J = this.plugin.state.data.select(f2.Generators.byRef(Y))[0]) === null || J === void 0 ? void 0 : J.obj) === null || $ === void 0 ? void 0 : $.data;
    if (!K)
      return;
    let G = W0.Bundle.toLoci(Q, K);
    this.set({ label: X, loci: G, category: W });
  }
  constructor(Z) {
    super({ history: [] });
    this.plugin = Z, this.events = {
      historyUpdated: this.ev()
    }, this.behaviors = {
      current: this.ev.behavior(void 0)
    }, Z.state.data.events.object.removed.subscribe(({ obj: $ }) => {
      var X;
      if (!D0.Molecule.Structure.is($))
        return;
      if (((X = this.current) === null || X === void 0 ? void 0 : X.loci.structure) === $.data)
        this.clear();
      let Y = [];
      for (let Q of this.history)
        if (Q.loci.structure === $.data)
          Y.push(Q);
      if (Y.length !== this.history.length)
        this.history.length = 0, this.history.push(...Y), this.events.historyUpdated.next(void 0);
    });
    let J = C0();
    Z.state.data.events.object.updated.subscribe(({ oldData: $, obj: X, action: Y }) => {
      var Q;
      if (!D0.Molecule.Structure.is(X))
        return;
      if ($ === X.data)
        return;
      if (Y === "in-place") {
        let W = this.state.current, K = X.data;
        if (W && W.loci.structure === $) {
          let G = W0.Loci.remap(W.loci, K);
          this.state.current = { ...W, loci: G }, this.behaviors.current.next(this.state.current), d2.getBoundingSphere(G, J);
          let H = (Q = this.plugin.canvas3d) === null || Q === void 0 ? void 0 : Q.camera, N = H.getTargetDistance(J.radius + 4);
          if (M.distance(H.target, J.center) > J.radius || N > H.viewport.height / H.zoom)
            this.plugin.managers.camera.focusSphere(J, { durationMs: 0 });
        }
      }
    });
  }
}
function $j1(Z, J) {
  if (Z && W0.Loci.is(J) && J.structure === Z.structure)
    if (W0.Loci.isSubset(Z, J))
      return { kind: "subtract", loci: W0.Loci.subtract(Z, J) };
    else
      return { kind: "add", loci: W0.Loci.union(J, Z) };
  else
    return { kind: "new", loci: J };
}

// node_modules/molstar/lib/mol-plugin-state/manager/markdown-extensions.js
var Xj1 = [
  {
    name: "center-camera",
    execute: ({ event: Z, args: J, manager: $ }) => {
      if (Z !== "click")
        return;
      if ("center-camera" in J)
        $.plugin.managers.camera.reset();
    }
  },
  {
    name: "apply-snapshot",
    execute: ({ event: Z, args: J, manager: $ }) => {
      if (Z !== "click")
        return;
      let X = J["apply-snapshot"];
      if (!X)
        return;
      $.plugin.managers.snapshot.applyKey(X);
    }
  },
  {
    name: "next-snapshot",
    execute: ({ event: Z, args: J, manager: $ }) => {
      if (Z !== "click" || !("next-snapshot" in J))
        return;
      let X = +J["next-snapshot"] || 1;
      if (!X)
        return;
      if (X < 0)
        X = -1;
      else
        X = 1;
      $.plugin.managers.snapshot.applyNext(X);
    }
  },
  {
    name: "focus-refs",
    execute: ({ event: Z, args: J, manager: $ }) => {
      if (Z !== "click")
        return;
      let X = E60(J["focus-refs"]);
      if (!(X === null || X === void 0 ? void 0 : X.length))
        return;
      let Y = $.findCells(X);
      if (!Y.length)
        return;
      let Q = ES0($.plugin, Y);
      if (!Q.length)
        return;
      let W = Q.map((K) => K60($.plugin, K.transform.ref)).filter((K) => !!K);
      if (!W.length)
        return;
      $.plugin.managers.camera.focusSpheres(W, (K) => K, { extraRadius: 3 });
    }
  },
  {
    name: "highlight-refs",
    execute: ({ event: Z, args: J, manager: $ }) => {
      var X;
      let Y = E60(J["highlight-refs"]);
      if (!(Y === null || Y === void 0 ? void 0 : Y.length))
        return;
      if (Z === "mouse-leave" && Y.length) {
        $.plugin.managers.interactivity.lociHighlights.clearHighlights();
        return;
      } else if (Z === "mouse-enter") {
        let Q = $.findCells(Y);
        for (let W of ES0($.plugin, Q)) {
          if (!((X = W.obj) === null || X === void 0 ? void 0 : X.data))
            continue;
          let { repr: K } = W.obj.data;
          for (let G of K.getAllLoci())
            $.plugin.managers.interactivity.lociHighlights.highlight({ loci: G, repr: K }, !1);
        }
      }
    }
  },
  {
    name: "query",
    execute: ({ event: Z, args: J, manager: $ }) => {
      var X;
      let Y = J.query;
      if (!(Y === null || Y === void 0 ? void 0 : Y.length))
        return;
      let Q = J.lang || "mol-script", W = E60(J.action || "highlight"), K = parseFloat(J["focus-radius"] || "3");
      if (Z === "mouse-leave") {
        if (W.includes("highlight"))
          $.plugin.managers.interactivity.lociHighlights.clearHighlights();
        return;
      }
      let G;
      try {
        G = cZ.toQuery({
          language: Q,
          expression: Y
        });
      } catch (N) {
        console.warn(`Failed to parse query '${Y}' (${Q})`, N);
        return;
      }
      let H = $.plugin.state.data.selectQ((N) => N.rootsOfType(D0.Molecule.Structure));
      if (Z === "mouse-enter") {
        if (!W.includes("focus"))
          return;
        $.plugin.managers.interactivity.lociHighlights.clearHighlights();
        for (let N of H) {
          if (!((X = N.obj) === null || X === void 0 ? void 0 : X.data))
            continue;
          let q = G(new C9(N.obj.data)), U = f1.toLociWithSourceUnits(q);
          $.plugin.managers.interactivity.lociHighlights.highlight({
            loci: U
          }, !1);
        }
      }
      if (Z === "click") {
        if (!W.includes("focus"))
          return;
        let q = H.map((U) => f2.getDecorated($.plugin.state.data, U.transform.ref)).map((U) => {
          var F;
          if (!((F = U.obj) === null || F === void 0 ? void 0 : F.data))
            return;
          let E = G(new C9(U.obj.data));
          if (f1.isEmpty(E))
            return;
          let R = f1.toLociWithSourceUnits(E);
          return W0.Loci.getBoundary(R).sphere;
        }).filter((U) => !!U);
        if (q.length)
          $.plugin.managers.camera.focusSpheres(q, (U) => U, { extraRadius: K });
      }
    }
  },
  {
    name: "play-audio",
    execute: ({ event: Z, args: J, manager: $ }) => {
      if (Z !== "click")
        return;
      let X = J["play-audio"];
      if (!(X === null || X === void 0 ? void 0 : X.length))
        return;
      $.audio.play(X);
    }
  },
  {
    name: "toggle-audio",
    execute: ({ event: Z, args: J, manager: $ }) => {
      if (Z !== "click" || !("toggle-audio" in J))
        return;
      let X = J["toggle-audio"];
      $.audio.play(X, { toggle: !0 });
    }
  },
  {
    name: "pause-audio",
    execute: ({ event: Z, args: J, manager: $ }) => {
      if (Z !== "click" || !("pause-audio" in J))
        return;
      $.audio.pause();
    }
  },
  {
    name: "stop-audio",
    execute: ({ event: Z, args: J, manager: $ }) => {
      if (Z !== "click" || !("stop-audio" in J))
        return;
      $.audio.stop();
    }
  },
  {
    name: "dispose-audio",
    execute: ({ event: Z, args: J, manager: $ }) => {
      if (Z !== "click" || !("dispose-audio" in J))
        return;
      $.audio.dispose();
    }
  },
  {
    name: "play-transition",
    execute: ({ event: Z, args: J, manager: $ }) => {
      if (Z !== "click" || !("play-transition" in J))
        return;
      $.plugin.managers.animation.play(qE, {});
    }
  },
  {
    name: "play-snapshots",
    execute: ({ event: Z, args: J, manager: $ }) => {
      if (Z !== "click" || !("play-snapshots" in J))
        return;
      $.plugin.managers.snapshot.play({ restart: !0 });
    }
  },
  {
    name: "stop-animation",
    execute: ({ event: Z, args: J, manager: $ }) => {
      if (Z !== "click" || !("stop-animation" in J))
        return;
      $.plugin.managers.snapshot.stop();
    }
  }
];

class O60 {
  registerArgsParser(Z, J, $) {
    this.removeArgsParser(Z), this.argsParsers.push([Z, J, $]), this.argsParsers.sort((X, Y) => Y[1] - X[1]);
  }
  removeArgsParser(Z) {
    let J = this.argsParsers.findIndex(($) => $[0] === Z);
    if (J >= 0)
      this.argsParsers.splice(J, 1);
  }
  parseArgs(Z) {
    for (let [, , J] of this.argsParsers) {
      let $ = J(Z);
      if ($)
        return $;
    }
    return;
  }
  registerRefResolver(Z, J) {
    this.refResolvers[Z] = J;
  }
  removeRefResolver(Z) {
    delete this.refResolvers[Z];
  }
  registerUriResolver(Z, J) {
    this.uriResolvers[Z] = J;
  }
  removeUriResolver(Z) {
    delete this.uriResolvers[Z];
  }
  registerExtension(Z) {
    let J = this.extension.findIndex(($) => $.name === Z.name);
    if (J >= 0)
      this.extension[J] = Z;
    else
      this.extension.push(Z);
  }
  removeExtension(Z) {
    let J = this.extension.findIndex(($) => $.name === Z);
    if (J >= 0)
      this.extension.splice(J, 1);
  }
  _tryRender(Z, J) {
    var $;
    try {
      return ($ = Z.reactRenderFn) === null || $ === void 0 ? void 0 : $.call(Z, J);
    } catch (X) {
      return console.error(`Failed to render markdown extension '${Z.name}'`, X), null;
    }
  }
  tryRender(Z, J) {
    let $ = { args: Z, manager: this };
    for (let X of this.extension) {
      let Y = this._tryRender(X, $);
      if (Y)
        return Y;
    }
    for (let X of J) {
      let Y = this._tryRender(X, $);
      if (Y)
        return Y;
    }
    return null;
  }
  tryExecute(Z, J) {
    var $;
    let X = { event: Z, args: J, manager: this };
    for (let Y of this.extension)
      try {
        ($ = Y.execute) === null || $ === void 0 || $.call(Y, X);
      } catch (Q) {
        console.error(`Failed to execute markdown extension '${Y.name}'`, Q);
      }
  }
  tryResolveUri(Z) {
    for (let J of Object.values(this.uriResolvers)) {
      let $ = J(this.plugin, Z);
      if ($)
        return $;
    }
  }
  findCells(Z) {
    let J = /* @__PURE__ */ new Set, $ = [];
    for (let X of Object.values(this.refResolvers))
      for (let Y of X(this.plugin, Z))
        if (Y && !J.has(Y.transform.ref))
          J.add(Y.transform.ref), $.push(Y);
    return $;
  }
  resolveAudioPlayer() {
    if (this.state.audioPlayer.value)
      return this.state.audioPlayer.value;
    let Z = document.createElement("audio");
    return Z.controls = !0, Z.preload = "auto", Z.style.width = "100%", Z.style.height = "32px", this.state.audioPlayer.next(Z), Z;
  }
  get audioPlayer() {
    return this.state.audioPlayer.value;
  }
  constructor(Z) {
    this.plugin = Z, this.state = {
      audioPlayer: new G$(null)
    }, this.extension = [], this.refResolvers = {
      default: (J, $) => $.map((X) => J.state.data.cells.get(X)).filter((X) => !!X)
    }, this.uriResolvers = {}, this.argsParsers = [
      ["default", 100, Yj1]
    ], this.audio = {
      play: async (J, $) => {
        try {
          let X = this.resolveAudioPlayer(), Y = !1;
          if (J === null || J === void 0 ? void 0 : J.trim()) {
            let Q = this.tryResolveUri(J), W = J;
            if (typeof (Q === null || Q === void 0 ? void 0 : Q.then) === "function")
              W = await Q;
            else if (Q)
              W = Q;
            if (Y = X.src !== W, Y)
              X.src = W, X.load();
          }
          if (!Y && ($ === null || $ === void 0 ? void 0 : $.toggle))
            if (X.paused)
              await X.play();
            else
              X.pause();
          else
            X.currentTime = 0, await X.play();
        } catch (X) {
          console.error("Failed to play audio", X);
        }
      },
      pause: () => {
        var J;
        (J = this.audioPlayer) === null || J === void 0 || J.pause();
      },
      stop: () => {
        if (!this.audioPlayer)
          return;
        this.audioPlayer.pause(), this.audioPlayer.currentTime = 0;
      },
      dispose: () => {
        if (this.audioPlayer)
          this.audioPlayer.pause(), this.audioPlayer.currentTime = 0, this.state.audioPlayer.next(null);
      }
    };
    for (let J of Xj1)
      this.registerExtension(J);
  }
}
function E60(Z) {
  var J;
  return (J = Z === null || Z === void 0 ? void 0 : Z.split(",").map(($) => $.trim()).filter(($) => $.length > 0)) !== null && J !== void 0 ? J : [];
}
function ES0(Z, J) {
  if (!J.length)
    return [];
  return Z.state.data.selectQ(($) => $.byValue(...J).subtree().filter((X) => D0.isRepresentation3D(X.obj)));
}
function Yj1(Z) {
  if (!(Z === null || Z === void 0 ? void 0 : Z.startsWith("!")))
    return;
  let J = decodeURIComponent(Z.substring(1)).split("&").map(($) => $.trim()).filter(($) => $.length > 0).map(($) => $.split("=", 2).map((X) => X.trim()));
  if (J.length === 0)
    return;
  return Object.fromEntries(J);
}

// node_modules/molstar/lib/mol-plugin/layout.js
var Qj1 = [
  ["full", "Full"],
  ["collapsed", "Collapsed"],
  ["hidden", "Hidden"]
], z60 = [
  ["full", "Full"],
  ["hidden", "Hidden"]
], Wj1 = {
  isExpanded: j.Boolean(!1),
  showControls: j.Boolean(!0),
  regionState: j.Group({
    left: j.Select("full", Qj1),
    top: j.Select("full", z60),
    right: j.Select("full", z60),
    bottom: j.Select("full", z60)
  }),
  controlsDisplay: j.Value("outside", { isHidden: !0 }),
  expandToFullscreen: j.Boolean(!1)
};

class D60 extends pX {
  updateProps(Z) {
    let J = !!this.state.isExpanded;
    if (this.updateState(Z), this.root && typeof Z.isExpanded === "boolean" && Z.isExpanded !== J)
      this.handleExpand();
    if (this.state.expandToFullscreen) {
      let $ = document.getElementsByTagName("body")[0];
      if ($)
        this.tryRequestFullscreen($);
    } else if (document.fullscreenElement)
      this.tryExitFullscreen();
    this.events.updated.next(void 0);
  }
  setProps(Z) {
    this.updateState(Z);
  }
  setRoot(Z) {
    if (this.root = Z, this.state.isExpanded)
      this.handleExpand();
  }
  getScrollElement() {
    if (document.scrollingElement)
      return document.scrollingElement;
    if (document.documentElement)
      return document.documentElement;
    return document.body;
  }
  async tryRequestFullscreen(Z) {
    if (document.fullscreenElement)
      return;
    try {
      await Z.requestFullscreen();
    } catch (J) {
      console.error(J);
    }
  }
  async tryExitFullscreen() {
    if (!document.fullscreenElement)
      return;
    try {
      await document.exitFullscreen();
    } catch (Z) {
      console.error(Z);
    }
  }
  handleExpand() {
    try {
      let Z = document.getElementsByTagName("body")[0], J = document.getElementsByTagName("head")[0];
      if (!Z || !J || !this.root)
        return;
      if (this.state.isExpanded) {
        let $ = J.children, X = [], Y = !1;
        for (let H = 0;H < $.length; H++)
          if ($[H] === this.expandedViewport)
            Y = !0;
          else if (($[H].name || "").toLowerCase() === "viewport")
            X.push($[H]);
        for (let H of X)
          J.removeChild(H);
        if (!Y)
          J.appendChild(this.expandedViewport);
        let Q = Z.style, W = this.getScrollElement(), K = W.scrollLeft, G = W.scrollTop;
        this.rootState = {
          top: Q.top,
          bottom: Q.bottom,
          right: Q.right,
          left: Q.left,
          scrollTop: G,
          scrollLeft: K,
          position: Q.position,
          overflow: Q.overflow,
          viewports: X,
          zIndex: this.root.style.zIndex,
          width: Q.width,
          height: Q.height,
          maxWidth: Q.maxWidth,
          maxHeight: Q.maxHeight,
          margin: Q.margin,
          marginLeft: Q.marginLeft,
          marginRight: Q.marginRight,
          marginTop: Q.marginTop,
          marginBottom: Q.marginBottom
        }, Q.overflow = "hidden", Q.position = "fixed", Q.top = "0", Q.bottom = "0", Q.right = "0", Q.left = "0", Q.width = "100%", Q.height = "100%", Q.maxWidth = "100%", Q.maxHeight = "100%", Q.margin = "0", Q.marginLeft = "0", Q.marginRight = "0", Q.marginTop = "0", Q.marginBottom = "0";
      } else {
        let $ = J.children;
        for (let X = 0;X < $.length; X++)
          if ($[X] === this.expandedViewport) {
            J.removeChild(this.expandedViewport);
            break;
          }
        if (this.state.expandToFullscreen && document.fullscreenElement)
          document.exitFullscreen();
        if (this.rootState) {
          let X = this.rootState;
          for (let W of X.viewports)
            J.appendChild(W);
          let Y = Z.style;
          Y.top = X.top, Y.bottom = X.bottom, Y.left = X.left, Y.right = X.right, Y.width = X.width, Y.height = X.height, Y.maxWidth = X.maxWidth, Y.maxHeight = X.maxHeight, Y.margin = X.margin, Y.marginLeft = X.marginLeft, Y.marginRight = X.marginRight, Y.marginTop = X.marginTop, Y.marginBottom = X.marginBottom, Y.position = X.position, Y.overflow = X.overflow || "";
          let Q = this.getScrollElement();
          Q.scrollTop = X.scrollTop, Q.scrollLeft = X.scrollLeft, this.rootState = void 0, this.root.style.zIndex = X.zIndex;
        }
      }
    } catch (Z) {
      this.context.log.error("Layout change error, you might have to reload the page."), console.error("Layout change error, you might have to reload the page.", Z);
    }
  }
  dispose() {
    super.dispose(), document.removeEventListener("fullscreenchange", this.fullscreenChangeHandler), document.removeEventListener("webkitfullscreenchange", this.fullscreenChangeHandler);
  }
  constructor(Z) {
    super({ ...j.getDefaultValues(Wj1), ...Z.spec.layout && Z.spec.layout.initial });
    if (this.context = Z, this.events = {
      updated: this.ev()
    }, this.rootState = void 0, this.fullscreenChangeHandler = () => {
      if (!document.fullscreenElement)
        this.updateProps({ expandToFullscreen: !1 });
    }, document.addEventListener("fullscreenchange", this.fullscreenChangeHandler), document.addEventListener("webkitfullscreenchange", this.fullscreenChangeHandler), h1.Layout.Update.subscribe(Z, (J) => this.updateProps(J.state)), typeof document !== "undefined")
      this.expandedViewport = document.createElement("meta"), this.expandedViewport.name = "viewport", this.expandedViewport.content = "width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0";
  }
}

// node_modules/molstar/lib/mol-repr/structure/visual/util/bond.js
var A60 = {
  includeTypes: j.MultiSelect(uO(s1.Names), j.objectToOptions(s1.Names)),
  excludeTypes: j.MultiSelect([], j.objectToOptions(s1.Names)),
  ignoreHydrogens: j.Boolean(!1),
  ignoreHydrogensVariant: j.Select("all", j.arrayToOptions(["all", "non-polar"])),
  aromaticBonds: j.Boolean(!0, { description: "Display aromatic bonds with dashes" }),
  multipleBonds: j.Select("symmetric", j.arrayToOptions(["off", "symmetric", "offset"]))
}, VC8 = j.getDefaultValues(A60), oB = {
  ...hK,
  ...A60,
  adjustCylinderLength: j.Boolean(!1, { description: "Shorten cylinders to reduce overlap with spheres. Useful for for transparent bonds. Not working well with aromatic bonds." })
}, IC8 = j.getDefaultValues(oB), sB = {
  ...b00,
  ...A60
}, PC8 = j.getDefaultValues(sB);
function aB(Z, J, $) {
  return !s1.is(Z, $) || s1.is(J, $);
}
function vg(Z, J, $) {
  let { elements: X, bonds: Y } = J, { a: Q, b: W, edgeProps: K } = Y, { flags: G } = K, { ignoreHydrogens: H, ignoreHydrogensVariant: N, includeTypes: q, excludeTypes: U } = $, F = s1.fromNames(q), E = s1.fromNames(U), R = s1.isAll(F) && s1.Flag.None === E, { child: z } = Z, D = z === null || z === void 0 ? void 0 : z.unitMap.get(J.id);
  if (z && !D)
    throw new Error("expected childUnit to exist if child exists");
  if (R && !H && !z)
    return;
  return (A) => {
    let B = Q[A], T = W[A];
    if (!!D && !X1.has(D.elements, X[B]))
      return !0;
    if (!R && aB(F, E, G[A]))
      return !0;
    if (!H)
      return !1;
    if (pW(Z, J, X[B], N) || pW(Z, J, X[T], N))
      return !0;
    return !1;
  };
}
function Sg(Z, J) {
  let $ = Z.interUnitBonds, { edges: X } = $, { ignoreHydrogens: Y, ignoreHydrogensVariant: Q, includeTypes: W, excludeTypes: K } = J, G = s1.fromNames(W), H = s1.fromNames(K), N = s1.isAll(G) && s1.Flag.None === H, { child: q } = Z;
  if (N && !Y && !q)
    return;
  return (U) => {
    if (q) {
      let F = X[U], E = q.unitMap.get(F.unitA);
      if (!E)
        return !0;
      let z = Z.unitMap.get(F.unitA).elements[F.indexA];
      if (!X1.has(E.elements, z))
        return !0;
    }
    if (Y) {
      let F = X[U], E = Z.unitMap.get(F.unitA), R = Z.unitMap.get(F.unitB);
      if (pW(Z, E, E.elements[F.indexA], Q) || pW(Z, R, R.elements[F.indexB], Q))
        return !0;
    }
    if (!N) {
      if (aB(G, H, X[U].props.flag))
        return !0;
    }
    return !1;
  };
}
function vU(Z, J) {
  if (j0.Traits.is(Z.traits, j0.Trait.Water))
    return !J.ignoreHydrogens || J.ignoreHydrogensVariant === "non-polar";
  return !0;
}
function T$(Z, J) {
  for (let { units: $ } of Z.unitSymmetryGroups)
    if (j0.isAtomic($[0]) && vU($[0], J))
      return !0;
  return !1;
}
var rW;
(function(Z) {
  function J(Y, Q) {
    let { group: W, structure: K } = Y, G = W.units[0], H = j0.isAtomic(G) ? G.bonds.edgeCount * 2 : 0, N = W.units.length, q = $2.Location(K, void 0, void 0, K, void 0, void 0), U = (F, E) => {
      let R = W.units[E];
      return q.aUnit = R, q.bUnit = R, q.aIndex = R.bonds.a[F], q.bIndex = R.bonds.b[F], q;
    };
    if (Q === null || Q === void 0 ? void 0 : Q.includeLocation2) {
      let F = $2.Location(K, void 0, void 0, K, void 0, void 0);
      return X6(H, N, 1, U, !1, () => !1, (R, z) => {
        let D = W.units[z];
        return F.aUnit = D, F.bUnit = D, F.aIndex = D.bonds.b[R], F.bIndex = D.bonds.a[R], F;
      });
    }
    return X6(H, N, 1, U);
  }
  Z.fromGroup = J;
  function $(Y, Q) {
    let W = Y.interUnitBonds.edgeCount, K = 1, G = $2.Location(Y, void 0, void 0, Y, void 0, void 0), H = (N) => {
      let q = Y.interUnitBonds.edges[N];
      return G.aUnit = Y.unitMap.get(q.unitA), G.aIndex = q.indexA, G.bUnit = Y.unitMap.get(q.unitB), G.bIndex = q.indexB, G;
    };
    if (Q === null || Q === void 0 ? void 0 : Q.includeLocation2) {
      let N = $2.Location(Y, void 0, void 0, Y, void 0, void 0);
      return X6(W, 1, 1, H, !0, () => !1, (U) => {
        let F = Y.interUnitBonds.edges[U];
        return N.aUnit = Y.unitMap.get(F.unitB), N.aIndex = F.indexB, N.bUnit = Y.unitMap.get(F.unitA), N.bIndex = F.indexA, N;
      });
    }
    return X6(W, 1, 1, H, !0);
  }
  Z.fromStructure = $;
  function X(Y, Q) {
    let { bondCount: W, unitIndex: K, unitGroupIndex: G, unitEdgeIndex: H } = Y.intraUnitBondMapping, N = W, q = 1, U = $2.Location(Y, void 0, void 0, Y, void 0, void 0), F = (E) => {
      let z = Y.unitSymmetryGroups[K[E]].units[G[E]], D = H[E];
      return U.aUnit = z, U.bUnit = z, U.aIndex = z.bonds.a[D], U.bIndex = z.bonds.b[D], U;
    };
    if (Q === null || Q === void 0 ? void 0 : Q.includeLocation2) {
      let E = $2.Location(Y, void 0, void 0, Y, void 0, void 0);
      return X6(N, 1, 1, F, !0, () => !1, (z) => {
        let A = Y.unitSymmetryGroups[K[z]].units[G[z]], B = H[z];
        return E.aUnit = A, E.bUnit = A, E.aIndex = A.bonds.b[B], E.bIndex = A.bonds.a[B], E;
      });
    }
    return X6(N, 1, 1, F, !0);
  }
  Z.fromStructureGroups = X;
})(rW || (rW = {}));
function rB(Z, J, $) {
  let { objectId: X, instanceId: Y, groupId: Q } = Z;
  if ($ === X) {
    let { structure: W, group: K } = J, G = K.units[Y];
    if (Q === K7.Null) {
      let H = f0.ofRange(0, G.elements.length);
      return W0.Loci(W.target, [{ unit: G, indices: H }]);
    } else if (j0.isAtomic(G)) {
      let { target: H } = W, N = G.bonds.a[Q], q = G.bonds.b[Q];
      return $2.Loci(H, [
        $2.Location(H, G, N, H, G, q),
        $2.Location(H, G, q, H, G, N)
      ]);
    }
  }
  return G8;
}
function RP(Z, J, $, X) {
  let Y = !1;
  if ($2.isLoci(Z)) {
    let { structure: Q, group: W } = J;
    if (!s0.areEquivalent(Z.structure, Q))
      return !1;
    let K = W.units[0];
    if (!j0.isAtomic(K))
      return !1;
    let G = K.bonds.edgeCount * 2;
    for (let H of Z.bonds) {
      if (H.aUnit !== H.bUnit)
        continue;
      let N = W.unitIndexMap.get(H.aUnit.id);
      if (N !== void 0) {
        let q = K.bonds.getDirectedEdgeIndex(H.aIndex, H.bIndex);
        if (q !== -1) {
          if ($(k0.ofSingleton(N * G + q)))
            Y = !0;
        }
      }
    }
  } else if (W0.Loci.is(Z)) {
    let { structure: Q, group: W } = J;
    if (!s0.areEquivalent(Z.structure, Q))
      return !1;
    let K = W.units[0];
    if (!j0.isAtomic(K))
      return !1;
    let G = K.bonds.edgeCount * 2;
    for (let H of Z.elements) {
      let N = W.unitIndexMap.get(H.unit.id);
      if (N !== void 0) {
        let { offset: q, b: U } = K.bonds;
        f0.forEach(H.indices, (F) => {
          for (let E = q[F], R = q[F + 1];E < R; E++)
            if (!X || f0.has(H.indices, U[E])) {
              if ($(k0.ofSingleton(N * G + E)))
                Y = !0;
            }
        });
      }
    }
  }
  return Y;
}
function EP(Z, J, $) {
  let { objectId: X, groupId: Y } = Z;
  if ($ === X) {
    let { target: Q } = J;
    if (Y === K7.Null)
      return s0.Loci(Q);
    else {
      let W = J.interUnitBonds.edges[Y], K = J.unitMap.get(W.unitA), G = J.unitMap.get(W.unitB);
      return $2.Loci(Q, [
        $2.Location(Q, K, W.indexA, Q, G, W.indexB),
        $2.Location(Q, G, W.indexB, Q, K, W.indexA)
      ]);
    }
  }
  return G8;
}
var M60 = /* @__PURE__ */ new Map;
function OP(Z, J, $, X) {
  let Y = !1;
  if ($2.isLoci(Z)) {
    if (!s0.areEquivalent(Z.structure, J))
      return !1;
    for (let Q of Z.bonds) {
      let W = J.interUnitBonds.getBondIndexFromLocation(Q);
      if (W !== -1) {
        if ($(k0.ofSingleton(W)))
          Y = !0;
      }
    }
  } else if (W0.Loci.is(Z)) {
    if (!s0.areEquivalent(Z.structure, J))
      return !1;
    if (X && Z.elements.length === 1)
      return !1;
    for (let Q of Z.elements)
      M60.set(Q.unit.id, Q.indices);
    for (let Q of Z.elements) {
      let { unit: W } = Q;
      if (!j0.isAtomic(W))
        continue;
      for (let K of J.interUnitBonds.getConnectedUnits(W.id)) {
        let G = M60.get(K.unitB);
        if (!X || G)
          f0.forEach(Q.indices, (H) => {
            if (!K.connectedIndices.includes(H))
              return;
            for (let N of K.getEdges(H))
              if (!X || G && f0.has(G, N.indexB)) {
                let q = J.interUnitBonds.getEdgeIndex(H, W.id, N.indexB, K.unitB);
                if ($(k0.ofSingleton(q)))
                  Y = !0;
              }
          });
      }
    }
    M60.clear();
  }
  return Y;
}
function zP(Z, J, $) {
  let { objectId: X, groupId: Y } = Z;
  if ($ === X) {
    let Q = J.intraUnitBondMapping;
    return rB({
      objectId: X,
      instanceId: Q.unitGroupIndex[Y],
      groupId: Q.unitEdgeIndex[Y]
    }, {
      structure: J,
      group: J.unitSymmetryGroups[Q.unitIndex[Y]]
    }, $);
  }
  return G8;
}
function DP(Z, J, $, X) {
  let { unitGroupOffset: Y } = J.intraUnitBondMapping, Q = !1;
  if ($2.isLoci(Z)) {
    if (!s0.areEquivalent(Z.structure, J))
      return !1;
    for (let W of Z.bonds) {
      if (W.aUnit !== W.bUnit)
        continue;
      let K = J.unitSymmetryGroupsIndexMap.get(W.aUnit.id), G = J.unitSymmetryGroups[K], H = G.units[0];
      if (!j0.isAtomic(H))
        continue;
      let N = Y[K], q = H.bonds.edgeCount * 2, U = G.unitIndexMap.get(W.aUnit.id);
      if (U !== void 0) {
        let F = H.bonds.getDirectedEdgeIndex(W.aIndex, W.bIndex);
        if (F !== -1) {
          if ($(k0.ofSingleton(U * q + F + N)))
            Q = !0;
        }
      }
    }
  } else if (W0.Loci.is(Z)) {
    if (!s0.areEquivalent(Z.structure, J))
      return !1;
    for (let W of Z.elements) {
      let K = J.unitSymmetryGroupsIndexMap.get(W.unit.id), G = J.unitSymmetryGroups[K], H = G.units[0];
      if (!j0.isAtomic(H))
        continue;
      let N = Y[K], q = H.bonds.edgeCount * 2, U = G.unitIndexMap.get(W.unit.id);
      if (U !== void 0) {
        let { offset: F, b: E } = H.bonds;
        f0.forEach(W.indices, (R) => {
          for (let z = F[R], D = F[R + 1];z < D; z++)
            if (!X || f0.has(W.indices, E[z])) {
              if ($(k0.ofSingleton(U * q + z + N)))
                Q = !0;
            }
        });
      }
    }
  }
  return Q;
}

// node_modules/molstar/lib/mol-repr/structure/visual/bond-intra-unit-cylinder.js
var B60 = s1.is;
function w60(Z, J, $, X) {
  let { elements: Y, bonds: Q } = Z, { edgeCount: W, a: K, b: G, edgeProps: H, offset: N } = Q, { order: q, flags: U } = H, { sizeFactor: F, sizeAspectRatio: E, adjustCylinderLength: R, aromaticBonds: z, includeTypes: D, excludeTypes: A, multipleBonds: B } = X, T = B === "off", w = B === "symmetric", V = s1.fromNames(D), P = s1.fromNames(A), I = aB(V, P, s1.Flag.Computed), S = M(), f = M(), v = Z.conformation, h, x = W0.Location.create(J, Z), b = $2.Location(J, Z, void 0, J, Z, void 0), { child: g } = J;
  if (X.includeParent && g) {
    let l = g.unitMap.get(Z.id);
    if (!l)
      throw new Error("expected childUnit to exist");
    h = (u) => {
      let G0 = Y[K[u]], F0 = Y[G[u]];
      return X1.has(l.elements, G0) && !X1.has(l.elements, F0);
    };
  }
  let m = (l) => {
    return b.aIndex = K[l], b.bIndex = G[l], $.size.size(b) * F;
  }, i = (l) => {
    return x.element = Y[K[l]], $.size.size(x) * F;
  }, r = (l) => {
    return x.element = Y[G[l]], $.size.size(x) * F;
  }, { elementRingIndices: Y0, elementAromaticRingIndices: c } = Z.rings, n = z ? Z.resonance.delocalizedTriplets : void 0;
  return {
    linkCount: W * 2,
    referencePosition: (l) => {
      let u = K[l], G0 = G[l], F0 = n === null || n === void 0 ? void 0 : n.getThirdElement(u, G0);
      if (F0 !== void 0)
        return v.invariantPosition(Y[F0], S);
      if (u > G0)
        [u, G0] = [G0, u];
      if (N[u + 1] - N[u] === 1)
        [u, G0] = [G0, u];
      let t = c.get(u) || Y0.get(u), Z0 = 0;
      for (let U0 = N[u], a = N[u + 1];U0 < a; ++U0) {
        let Q0 = G[U0];
        if (Q0 !== G0 && Q0 !== u)
          if (t) {
            let $0 = c.get(Q0) || Y0.get(Q0);
            if (!$0)
              continue;
            let R0 = CM(t, $0);
            if (R0 > Z0)
              Z0 = R0, v.invariantPosition(Y[Q0], S);
          } else
            return v.invariantPosition(Y[Q0], S);
      }
      return Z0 > 0 ? S : null;
    },
    position: (l, u, G0, F0) => {
      if (v.invariantPosition(Y[K[G0]], l), v.invariantPosition(Y[G[G0]], u), F0 && R) {
        let t = i(G0), Z0 = r(G0), U0 = Math.min(t, Z0) * E, a = Math.sqrt(Math.max(0, t * t - U0 * U0)) - 0.05, Q0 = Math.sqrt(Math.max(0, Z0 * Z0 - U0 * U0)) - 0.05;
        if (a <= 0.01 && Q0 <= 0.01)
          return;
        M.normalize(f, M.sub(f, u, l)), M.scaleAndAdd(l, l, f, a), M.scaleAndAdd(u, u, f, -Q0);
      }
    },
    style: (l) => {
      let u = q[l], G0 = U[l];
      if (B60(G0, s1.Flag.MetallicCoordination) || B60(G0, s1.Flag.HydrogenBond))
        return j2.Dashed;
      else if (u === 3)
        return T ? j2.Solid : w ? j2.Triple : j2.OffsetTriple;
      else if (z) {
        let F0 = K[l], t = G[l], Z0 = c.get(F0), U0 = c.get(t), a = Z0 && U0 ? CM(Z0, U0) : 0;
        if (B60(G0, s1.Flag.Aromatic) || a && !I)
          if (a === 2)
            return j2.MirroredAromatic;
          else
            return j2.Aromatic;
      }
      return u !== 2 || T ? j2.Solid : w ? j2.Double : j2.OffsetDouble;
    },
    radius: (l) => {
      return m(l) * E;
    },
    ignore: vg(J, Z, X),
    stub: h
  };
}
function Kj1(Z, J, $, X, Y, Q) {
  if (!j0.isAtomic(J))
    return T7.createEmpty(Q);
  if (!vU(J, Y))
    return T7.createEmpty(Q);
  if (!J.bonds.edgeCount)
    return T7.createEmpty(Q);
  let { child: W } = $, K = W === null || W === void 0 ? void 0 : W.unitMap.get(J.id);
  if (W && !K)
    return T7.createEmpty(Q);
  let G = w60(J, $, X, Y), { cylinders: H, boundingSphere: N } = EI(Z, G, Y, Q);
  if (N)
    H.setBoundingSphere(N);
  else if (H.cylinderCount > 0) {
    let q = C0.expand(C0(), (K !== null && K !== void 0 ? K : J).boundary.sphere, 1 * Y.sizeFactor);
    H.setBoundingSphere(q);
  }
  return H;
}
function Gj1(Z, J, $, X, Y, Q) {
  if (!j0.isAtomic(J))
    return n1.createEmpty(Q);
  if (!vU(J, Y))
    return n1.createEmpty(Q);
  if (!J.bonds.edgeCount)
    return n1.createEmpty(Q);
  let { child: W } = $, K = W === null || W === void 0 ? void 0 : W.unitMap.get(J.id);
  if (W && !K)
    return n1.createEmpty(Q);
  let G = w60(J, $, X, Y), { mesh: H, boundingSphere: N } = uW(Z, G, Y, Q);
  if (N)
    H.setBoundingSphere(N);
  else if (H.triangleCount > 0) {
    let q = C0.expand(C0(), (K !== null && K !== void 0 ? K : J).boundary.sphere, 1 * Y.sizeFactor);
    H.setBoundingSphere(q);
  }
  return H;
}
var tB = {
  ...nZ,
  ...UB,
  ...oB,
  sizeFactor: j.Numeric(0.3, { min: 0, max: 10, step: 0.01 }),
  sizeAspectRatio: j.Numeric(0.6666666666666666, { min: 0, max: 3, step: 0.01 }),
  tryUseImpostor: j.Boolean(!0),
  includeParent: j.Boolean(!1)
};
function fg(Z, J, $, X) {
  return $.tryUseImpostor && YE(X) ? Hj1(Z) : Nj1(Z);
}
function Hj1(Z) {
  return LB({
    defaultProps: j.getDefaultValues(tB),
    createGeometry: Kj1,
    createLocationIterator: (J, $) => rW.fromGroup(J, { includeLocation2: $.colorMode === "interpolate" }),
    getLoci: rB,
    eachLocation: RP,
    setUpdateState: (J, $, X, Y, Q, W, K) => {
      if (J.createGeometry = $.sizeFactor !== X.sizeFactor || $.sizeAspectRatio !== X.sizeAspectRatio || $.linkScale !== X.linkScale || $.linkSpacing !== X.linkSpacing || $.ignoreHydrogens !== X.ignoreHydrogens || $.ignoreHydrogensVariant !== X.ignoreHydrogensVariant || $.linkCap !== X.linkCap || $.aromaticScale !== X.aromaticScale || $.aromaticSpacing !== X.aromaticSpacing || $.aromaticDashCount !== X.aromaticDashCount || $.dashCount !== X.dashCount || $.dashScale !== X.dashScale || $.dashCap !== X.dashCap || $.stubCap !== X.stubCap || !b7($.includeTypes, X.includeTypes) || !b7($.excludeTypes, X.excludeTypes) || $.adjustCylinderLength !== X.adjustCylinderLength || $.aromaticBonds !== X.aromaticBonds || $.multipleBonds !== X.multipleBonds || $.adjustCylinderLength && !J9.areEqual(Y.size, Q.size), $.colorMode !== X.colorMode)
        J.createGeometry = !0, J.updateTransform = !0, J.updateColor = !0;
      let G = W.group.units[0], H = K.group.units[0];
      if (j0.isAtomic(G) && j0.isAtomic(H)) {
        if (!lJ.areEqual(G.bonds, H.bonds))
          J.createGeometry = !0, J.updateTransform = !0, J.updateColor = !0, J.updateSize = !0;
      }
    },
    mustRecreate: (J, $, X) => {
      return !$.tryUseImpostor || !X;
    }
  }, Z);
}
function Nj1(Z) {
  return A9({
    defaultProps: j.getDefaultValues(tB),
    createGeometry: Gj1,
    createLocationIterator: (J) => rW.fromGroup(J),
    getLoci: rB,
    eachLocation: RP,
    setUpdateState: (J, $, X, Y, Q, W, K) => {
      J.createGeometry = $.sizeFactor !== X.sizeFactor || $.sizeAspectRatio !== X.sizeAspectRatio || $.radialSegments !== X.radialSegments || $.linkScale !== X.linkScale || $.linkSpacing !== X.linkSpacing || $.ignoreHydrogens !== X.ignoreHydrogens || $.ignoreHydrogensVariant !== X.ignoreHydrogensVariant || $.linkCap !== X.linkCap || $.aromaticScale !== X.aromaticScale || $.aromaticSpacing !== X.aromaticSpacing || $.aromaticDashCount !== X.aromaticDashCount || $.dashCount !== X.dashCount || $.dashScale !== X.dashScale || $.dashCap !== X.dashCap || $.stubCap !== X.stubCap || !b7($.includeTypes, X.includeTypes) || !b7($.excludeTypes, X.excludeTypes) || $.adjustCylinderLength !== X.adjustCylinderLength || $.aromaticBonds !== X.aromaticBonds || $.multipleBonds !== X.multipleBonds;
      let G = W.group.units[0], H = K.group.units[0];
      if (j0.isAtomic(G) && j0.isAtomic(H)) {
        if (!lJ.areEqual(G.bonds, H.bonds))
          J.createGeometry = !0, J.updateTransform = !0, J.updateColor = !0, J.updateSize = !0;
      }
    },
    mustRecreate: (J, $, X) => {
      return $.tryUseImpostor && !!X;
    }
  }, Z);
}
function OS0(Z, J, $) {
  let X = [], { bondCount: Y, unitIndex: Q, unitEdgeIndex: W, unitGroupIndex: K } = Z.intraUnitBondMapping, { child: G } = Z;
  for (let H of Z.unitSymmetryGroups) {
    let N = H.units[0], q = G === null || G === void 0 ? void 0 : G.unitMap.get(N.id), U = j0.isAtomic(N) && !(G && !q) ? w60(N, Z, J, $) : Zy;
    X.push({ group: H, props: U });
  }
  return {
    linkCount: Y,
    referencePosition: (H) => {
      let { group: N, props: q } = X[Q[H]];
      if (!q.referencePosition)
        return null;
      let U = q.referencePosition(W[H]);
      if (!U)
        return null;
      let F = N.units[K[H]];
      return M.transformMat4(U, U, F.conformation.operator.matrix), U;
    },
    position: (H, N, q, U) => {
      let { group: F, props: E } = X[Q[q]];
      E.position(H, N, W[q], U);
      let R = F.units[K[q]];
      M.transformMat4(H, H, R.conformation.operator.matrix), M.transformMat4(N, N, R.conformation.operator.matrix);
    },
    style: (H) => {
      let { props: N } = X[Q[H]];
      return N.style ? N.style(W[H]) : j2.Solid;
    },
    radius: (H) => {
      let { props: N } = X[Q[H]];
      return N.radius(W[H]);
    },
    ignore: (H) => {
      let { props: N } = X[Q[H]];
      return N.ignore ? N.ignore(W[H]) : !1;
    },
    stub: (H) => {
      let { props: N } = X[Q[H]];
      return N.stub ? N.stub(W[H]) : !1;
    }
  };
}
function qj1(Z, J, $, X, Y) {
  if (!T$(J, X))
    return T7.createEmpty(Y);
  if (!J.intraUnitBondMapping.bondCount)
    return T7.createEmpty(Y);
  let Q = OS0(J, $, X), { cylinders: W, boundingSphere: K } = EI(Z, Q, X, Y);
  if (K)
    W.setBoundingSphere(K);
  else if (W.cylinderCount > 0) {
    let { child: G } = J, H = C0.expand(C0(), (G !== null && G !== void 0 ? G : J).boundary.sphere, 1 * X.sizeFactor);
    W.setBoundingSphere(H);
  }
  return W;
}
function Fj1(Z, J, $, X, Y) {
  if (!T$(J, X))
    return n1.createEmpty(Y);
  if (!J.intraUnitBondMapping.bondCount)
    return n1.createEmpty(Y);
  let Q = OS0(J, $, X), { mesh: W, boundingSphere: K } = uW(Z, Q, X, Y);
  if (K)
    W.setBoundingSphere(K);
  else if (W.triangleCount > 0) {
    let { child: G } = J, H = C0.expand(C0(), (G !== null && G !== void 0 ? G : J).boundary.sphere, 1 * X.sizeFactor);
    W.setBoundingSphere(H);
  }
  return W;
}
var zS0 = {
  ...tQ,
  ...rx,
  ...oB,
  sizeFactor: j.Numeric(0.3, { min: 0, max: 10, step: 0.01 }),
  sizeAspectRatio: j.Numeric(0.6666666666666666, { min: 0, max: 3, step: 0.01 }),
  tryUseImpostor: j.Boolean(!0),
  includeParent: j.Boolean(!1)
};
function hg(Z, J, $, X) {
  return $.tryUseImpostor && X && X.extensions.fragDepth ? Uj1(Z) : Lj1(Z);
}
function Uj1(Z) {
  return tx({
    defaultProps: j.getDefaultValues(zS0),
    createGeometry: qj1,
    createLocationIterator: (J, $) => {
      return !T$(J, $) ? pN : rW.fromStructureGroups(J, { includeLocation2: $.colorMode === "interpolate" });
    },
    getLoci: zP,
    eachLocation: DP,
    setUpdateState: (J, $, X, Y, Q, W, K) => {
      if (J.createGeometry = $.sizeFactor !== X.sizeFactor || $.sizeAspectRatio !== X.sizeAspectRatio || $.linkScale !== X.linkScale || $.linkSpacing !== X.linkSpacing || $.ignoreHydrogens !== X.ignoreHydrogens || $.ignoreHydrogensVariant !== X.ignoreHydrogensVariant || $.linkCap !== X.linkCap || $.aromaticScale !== X.aromaticScale || $.aromaticSpacing !== X.aromaticSpacing || $.aromaticDashCount !== X.aromaticDashCount || $.dashCount !== X.dashCount || $.dashScale !== X.dashScale || $.dashCap !== X.dashCap || $.stubCap !== X.stubCap || !b7($.includeTypes, X.includeTypes) || !b7($.excludeTypes, X.excludeTypes) || $.adjustCylinderLength !== X.adjustCylinderLength || $.multipleBonds !== X.multipleBonds, $.colorMode !== X.colorMode)
        J.createGeometry = !0, J.updateTransform = !0, J.updateColor = !0;
      if (T$(W, $) && W.interUnitBonds !== K.interUnitBonds)
        J.createGeometry = !0, J.updateTransform = !0, J.updateColor = !0, J.updateSize = !0;
    },
    mustRecreate: (J, $, X) => {
      return !$.tryUseImpostor || !X;
    }
  }, Z);
}
function Lj1(Z) {
  return D$({
    defaultProps: j.getDefaultValues(zS0),
    createGeometry: Fj1,
    createLocationIterator: (J, $) => {
      return !T$(J, $) ? pN : rW.fromStructureGroups(J);
    },
    getLoci: zP,
    eachLocation: DP,
    setUpdateState: (J, $, X, Y, Q, W, K) => {
      if (J.createGeometry = $.sizeFactor !== X.sizeFactor || $.sizeAspectRatio !== X.sizeAspectRatio || $.radialSegments !== X.radialSegments || $.linkScale !== X.linkScale || $.linkSpacing !== X.linkSpacing || $.ignoreHydrogens !== X.ignoreHydrogens || $.ignoreHydrogensVariant !== X.ignoreHydrogensVariant || $.linkCap !== X.linkCap || $.aromaticScale !== X.aromaticScale || $.aromaticSpacing !== X.aromaticSpacing || $.aromaticDashCount !== X.aromaticDashCount || $.dashCount !== X.dashCount || $.dashScale !== X.dashScale || $.dashCap !== X.dashCap || $.stubCap !== X.stubCap || !b7($.includeTypes, X.includeTypes) || !b7($.excludeTypes, X.excludeTypes) || $.adjustCylinderLength !== X.adjustCylinderLength || $.multipleBonds !== X.multipleBonds || $.adjustCylinderLength && !J9.areEqual(Y.size, Q.size), T$(W, $) && W.interUnitBonds !== K.interUnitBonds)
        J.createGeometry = !0, J.updateTransform = !0, J.updateColor = !0, J.updateSize = !0;
    },
    mustRecreate: (J, $, X) => {
      return $.tryUseImpostor && !!X;
    }
  }, Z);
}

// node_modules/molstar/lib/mol-repr/structure/visual/bond-inter-unit-cylinder.js
var j60 = new $2.ElementBondIterator;
function DS0(Z, J, $, X) {
  j60.setElement(J, $, X);
  while (j60.hasNext) {
    let Y = j60.move();
    return Y.otherUnit.conformation.position(Y.otherUnit.elements[Y.otherIndex], Z), Z;
  }
  return null;
}
var MS0 = M();
function AS0(Z, J, $) {
  let X = W0.Location.create(Z), Y = $2.Location(Z, void 0, void 0, Z, void 0, void 0), Q = Z.interUnitBonds, { edgeCount: W, edges: K } = Q, { sizeFactor: G, sizeAspectRatio: H, adjustCylinderLength: N, aromaticBonds: q, multipleBonds: U } = $, F = U === "off", E = U === "symmetric", R = M(), z, { child: D } = Z;
  if ($.includeParent && D)
    z = (w) => {
      let V = K[w], P = D.unitMap.get(V.unitA), I = D.unitMap.get(V.unitB), f = Z.unitMap.get(V.unitA).elements[V.indexA], h = Z.unitMap.get(V.unitB).elements[V.indexB];
      return P && X1.has(P.elements, f) && (!I || !X1.has(I.elements, h));
    };
  let A = (w) => {
    let V = K[w];
    return Y.aUnit = Z.unitMap.get(V.unitA), Y.aIndex = V.indexA, Y.bUnit = Z.unitMap.get(V.unitB), Y.bIndex = V.indexB, J.size.size(Y) * G;
  }, B = (w) => {
    let V = K[w];
    return X.unit = Z.unitMap.get(V.unitA), X.element = X.unit.elements[V.indexA], J.size.size(X) * G;
  }, T = (w) => {
    let V = K[w];
    return X.unit = Z.unitMap.get(V.unitB), X.element = X.unit.elements[V.indexB], J.size.size(X) * G;
  };
  return {
    linkCount: W,
    referencePosition: (w) => {
      let V = K[w], P, I, S, f;
      if (V.unitA < V.unitB)
        P = Z.unitMap.get(V.unitA), I = Z.unitMap.get(V.unitB), S = V.indexA, f = V.indexB;
      else if (V.unitA > V.unitB)
        P = Z.unitMap.get(V.unitB), I = Z.unitMap.get(V.unitA), S = V.indexB, f = V.indexA;
      else
        throw new Error("same units in createInterUnitBondCylinderMesh");
      return DS0(MS0, Z, P, S) || DS0(MS0, Z, I, f);
    },
    position: (w, V, P, I) => {
      let S = K[P], f = Z.unitMap.get(S.unitA), v = Z.unitMap.get(S.unitB);
      if (f.conformation.position(f.elements[S.indexA], w), v.conformation.position(v.elements[S.indexB], V), I && N) {
        let h = B(P), x = T(P), b = Math.min(h, x) * H, g = Math.sqrt(Math.max(0, h * h - b * b)) - 0.05, m = Math.sqrt(Math.max(0, x * x - b * b)) - 0.05;
        if (g <= 0.01 && m <= 0.01)
          return;
        M.normalize(R, M.sub(R, V, w)), M.scaleAndAdd(w, w, R, g), M.scaleAndAdd(V, V, R, -m);
      }
    },
    style: (w) => {
      let V = K[w].props.order, P = r7.create(K[w].props.flag);
      if (s1.is(P, s1.Flag.MetallicCoordination) || s1.is(P, s1.Flag.HydrogenBond))
        return j2.Dashed;
      else if (V === 3)
        return F ? j2.Solid : E ? j2.Triple : j2.OffsetTriple;
      else if (q && s1.is(P, s1.Flag.Aromatic))
        return j2.Aromatic;
      return V !== 2 || F ? j2.Solid : E ? j2.Double : j2.OffsetDouble;
    },
    radius: (w) => {
      return A(w) * H;
    },
    ignore: Sg(Z, $),
    stub: z
  };
}
function Rj1(Z, J, $, X, Y) {
  if (!T$(J, X))
    return T7.createEmpty(Y);
  if (!J.interUnitBonds.edgeCount)
    return T7.createEmpty(Y);
  let Q = AS0(J, $, X), { cylinders: W, boundingSphere: K } = EI(Z, Q, X, Y);
  if (K)
    W.setBoundingSphere(K);
  else if (W.cylinderCount > 0) {
    let { child: G } = J, H = C0.expand(C0(), (G !== null && G !== void 0 ? G : J).boundary.sphere, 1 * X.sizeFactor);
    W.setBoundingSphere(H);
  }
  return W;
}
function Ej1(Z, J, $, X, Y) {
  if (!T$(J, X))
    return n1.createEmpty(Y);
  if (!J.interUnitBonds.edgeCount)
    return n1.createEmpty(Y);
  let Q = AS0(J, $, X), { mesh: W, boundingSphere: K } = uW(Z, Q, X, Y);
  if (K)
    W.setBoundingSphere(K);
  else if (W.triangleCount > 0) {
    let { child: G } = J, H = C0.expand(C0(), (G !== null && G !== void 0 ? G : J).boundary.sphere, 1 * X.sizeFactor);
    W.setBoundingSphere(H);
  }
  return W;
}
var eB = {
  ...tQ,
  ...rx,
  ...oB,
  sizeFactor: j.Numeric(0.3, { min: 0, max: 10, step: 0.01 }),
  sizeAspectRatio: j.Numeric(0.6666666666666666, { min: 0, max: 3, step: 0.01 }),
  tryUseImpostor: j.Boolean(!0),
  includeParent: j.Boolean(!1)
};
function bg(Z, J, $, X) {
  return $.tryUseImpostor && YE(X) ? Oj1(Z) : zj1(Z);
}
function Oj1(Z) {
  return tx({
    defaultProps: j.getDefaultValues(eB),
    createGeometry: Rj1,
    createLocationIterator: (J, $) => {
      return !T$(J, $) ? pN : rW.fromStructure(J, { includeLocation2: $.colorMode === "interpolate" });
    },
    getLoci: EP,
    eachLocation: OP,
    setUpdateState: (J, $, X, Y, Q, W, K) => {
      if (J.createGeometry = $.sizeFactor !== X.sizeFactor || $.sizeAspectRatio !== X.sizeAspectRatio || $.linkScale !== X.linkScale || $.linkSpacing !== X.linkSpacing || $.ignoreHydrogens !== X.ignoreHydrogens || $.ignoreHydrogensVariant !== X.ignoreHydrogensVariant || $.linkCap !== X.linkCap || $.aromaticScale !== X.aromaticScale || $.aromaticSpacing !== X.aromaticSpacing || $.aromaticDashCount !== X.aromaticDashCount || $.dashCount !== X.dashCount || $.dashScale !== X.dashScale || $.dashCap !== X.dashCap || $.stubCap !== X.stubCap || !b7($.includeTypes, X.includeTypes) || !b7($.excludeTypes, X.excludeTypes) || $.adjustCylinderLength !== X.adjustCylinderLength || $.multipleBonds !== X.multipleBonds, $.colorMode !== X.colorMode)
        J.createGeometry = !0, J.updateTransform = !0, J.updateColor = !0;
      if (T$(W, $) && W.interUnitBonds !== K.interUnitBonds)
        J.createGeometry = !0, J.updateTransform = !0, J.updateColor = !0, J.updateSize = !0;
    },
    mustRecreate: (J, $, X) => {
      return !$.tryUseImpostor || !X;
    }
  }, Z);
}
function zj1(Z) {
  return D$({
    defaultProps: j.getDefaultValues(eB),
    createGeometry: Ej1,
    createLocationIterator: (J, $) => {
      return !T$(J, $) ? pN : rW.fromStructure(J);
    },
    getLoci: EP,
    eachLocation: OP,
    setUpdateState: (J, $, X, Y, Q, W, K) => {
      if (J.createGeometry = $.sizeFactor !== X.sizeFactor || $.sizeAspectRatio !== X.sizeAspectRatio || $.radialSegments !== X.radialSegments || $.linkScale !== X.linkScale || $.linkSpacing !== X.linkSpacing || $.ignoreHydrogens !== X.ignoreHydrogens || $.ignoreHydrogensVariant !== X.ignoreHydrogensVariant || $.linkCap !== X.linkCap || $.aromaticScale !== X.aromaticScale || $.aromaticSpacing !== X.aromaticSpacing || $.aromaticDashCount !== X.aromaticDashCount || $.dashCount !== X.dashCount || $.dashScale !== X.dashScale || $.dashCap !== X.dashCap || $.stubCap !== X.stubCap || !b7($.includeTypes, X.includeTypes) || !b7($.excludeTypes, X.excludeTypes) || $.adjustCylinderLength !== X.adjustCylinderLength || $.multipleBonds !== X.multipleBonds || $.adjustCylinderLength && !J9.areEqual(Y.size, Q.size), T$(W, $) && W.interUnitBonds !== K.interUnitBonds)
        J.createGeometry = !0, J.updateTransform = !0, J.updateColor = !0, J.updateSize = !0;
    },
    mustRecreate: (J, $, X) => {
      return $.tryUseImpostor && !!X;
    }
  }, Z);
}

// node_modules/molstar/lib/mol-repr/structure/visual/util/element.js
var Zw = M.add;
function tW(Z, J, $) {
  let { ignoreHydrogens: X, ignoreHydrogensVariant: Y, traceOnly: Q } = $, W = j0.isCoarse(J), { child: K } = Z, G = K === null || K === void 0 ? void 0 : K.unitMap.get(J.id);
  if (K && !G)
    throw new Error("expected childUnit to exist if child exists");
  if (!K && !X && !Q)
    return;
  return (H) => {
    return !!G && !X1.has(G.elements, H) || !W && X && pW(Z, J, H, Y) || Q && !dx(J, H);
  };
}
function BS0(Z, J, $, X, Y, Q) {
  let { child: W } = $, K = W === null || W === void 0 ? void 0 : W.unitMap.get(J.id);
  if (W && !K)
    return n1.createEmpty(Q);
  let { detail: G, sizeFactor: H, stride: N } = Y, { elements: q, conformation: U } = J, F = q.length, E = F * _5(G), R = v1.createState(E, E / 2, Q), z = M(), D = tW($, J, Y), A = W0.Location.create($, J), B = X.size.size, T = M(), w = 0, V = 0;
  for (let f = 0;f < F; f++) {
    if (N && f % N !== 0)
      continue;
    if (D && D(q[f]))
      continue;
    U.invariantPosition(q[f], z), Zw(T, T, z), V += 1, A.element = q[f];
    let v = B(A);
    if (v > w)
      w = v;
    R.currentGroup = f, g8(R, z, v * H, G);
  }
  let P = v1.getMesh(R);
  if (V === 0)
    return P;
  let I;
  M.scale(T, T, 1 / V);
  let S = Q ? C0.clone(Q.boundingSphere) : void 0;
  if (S && M.distance(T, S.center) / S.radius < 0.1)
    I = S;
  else
    I = C0.expand(C0(), (K !== null && K !== void 0 ? K : J).boundary.sphere, w * H + 0.05);
  return P.setBoundingSphere(I), P;
}
function wS0(Z, J, $, X, Y, Q) {
  let { child: W } = $, K = W === null || W === void 0 ? void 0 : W.unitMap.get(J.id);
  if (W && !K)
    return R$.createEmpty(Q);
  let { sizeFactor: G, stride: H } = Y, { elements: N, conformation: q } = J, U = N.length, F = wH.create(U, U / 2, Q), E = M(), R = tW($, J, Y), z = W0.Location.create($, J), D = X.size.size, A = M(), B = 0, T = 0;
  if (H && H > 1 || R || X.size.granularity !== "uniform")
    for (let I = 0;I < U; I++) {
      if (H && I % H !== 0)
        continue;
      if (R && R(N[I]))
        continue;
      q.invariantPosition(N[I], E), F.add(E[0], E[1], E[2], I), Zw(A, A, E), T += 1, z.element = N[I];
      let S = D(z);
      if (S > B)
        B = S;
    }
  else {
    for (let I = 0;I < U; I++)
      q.invariantPosition(N[I], E), F.add(E[0], E[1], E[2], I), Zw(A, A, E);
    T = U, B = D(z);
  }
  let w = F.getSpheres();
  if (T === 0)
    return w;
  let V;
  M.scale(A, A, 1 / T);
  let P = Q ? C0.clone(Q.boundingSphere) : void 0;
  if (P && M.distance(A, P.center) / P.radius < 0.1)
    V = P;
  else
    V = C0.expand(C0(), (K !== null && K !== void 0 ? K : J).boundary.sphere, B * G + 0.05);
  return w.setBoundingSphere(V), w;
}
function FX(Z, J, $) {
  let X = !1;
  if (!W0.Loci.is(Z))
    return !1;
  let { structure: Y, group: Q } = J;
  if (!s0.areEquivalent(Z.structure, Y))
    return !1;
  let W = Q.elements.length, { unitIndexMap: K } = Q;
  for (let G of Z.elements) {
    let H = K.get(G.unit.id);
    if (H !== void 0) {
      let N = H * W;
      if (k0.is(G.indices)) {
        let q = N + k0.start(G.indices), U = N + k0.end(G.indices);
        if ($(k0.ofBounds(q, U)))
          X = !0;
      } else
        for (let q = 0, U = G.indices.length;q < U; q++) {
          let F = G.indices[q], E = q + 1;
          while (E < U && G.indices[E] === F)
            E++;
          q = E - 1;
          let R = G.indices[q];
          X = $(k0.ofRange(N + F, N + R)) || X;
        }
    }
  }
  return X;
}
function UX(Z, J, $) {
  let { objectId: X, instanceId: Y, groupId: Q } = Z;
  if ($ === X) {
    let { structure: W, group: K } = J, G = K.units[Y], H = Q === K7.Null ? f0.ofRange(0, G.elements.length) : f0.ofSingleton(Q);
    return W0.Loci(W.target, [{ unit: G, indices: H }]);
  }
  return G8;
}
function jS0(Z, J, $, X, Y) {
  let { child: Q } = J, { detail: W, sizeFactor: K, stride: G } = X, { getSerialIndex: H } = J.serialMapping, q = J.elementCount * _5(W), U = v1.createState(q, q / 2, Y), F = $.size.size, E = M(), R = 0, z = 0;
  for (let T of J.units) {
    let w = Q === null || Q === void 0 ? void 0 : Q.unitMap.get(T.id);
    if (Q && !w)
      continue;
    let { elements: V, conformation: P } = T, I = V.length, S = M(), f = tW(J, T, X), v = W0.Location.create(J, T);
    for (let h = 0;h < I; h++) {
      let x = V[h];
      if (G && h % G !== 0)
        continue;
      if (f && f(x))
        continue;
      P.position(x, S), Zw(E, E, S), z += 1, v.element = x;
      let b = F(v);
      if (b > R)
        R = b;
      U.currentGroup = H(T, x), g8(U, S, b * K, W);
    }
  }
  let D = v1.getMesh(U);
  if (z === 0)
    return D;
  let A;
  M.scale(E, E, 1 / z);
  let B = Y ? C0.clone(Y.boundingSphere) : void 0;
  if (B && M.distance(E, B.center) / B.radius < 1)
    A = B;
  else
    A = C0.expand(C0(), (Q !== null && Q !== void 0 ? Q : J).boundary.sphere, R * K + 0.05);
  return D.setBoundingSphere(A), D;
}
function TS0(Z, J, $, X, Y) {
  let { child: Q } = J, { sizeFactor: W, stride: K } = X, { getSerialIndex: G } = J.serialMapping, H = J.elementCount, N = wH.create(H, H / 2, Y), q = $.size.size, U = M(), F = 0, E = 0;
  for (let A of J.units) {
    let B = Q === null || Q === void 0 ? void 0 : Q.unitMap.get(A.id);
    if (Q && !B)
      continue;
    let { elements: T, conformation: w } = A, V = T.length, P = M(), I = tW(J, A, X), S = W0.Location.create(J, A);
    if (K && K > 1 || I || $.size.granularity !== "uniform")
      for (let f = 0;f < V; f++) {
        let v = T[f];
        if (K && f % K !== 0)
          continue;
        if (I && I(v))
          continue;
        w.position(v, P), N.add(P[0], P[1], P[2], G(A, v)), Zw(U, U, P), E += 1, S.element = v;
        let h = q(S);
        if (h > F)
          F = h;
      }
    else {
      for (let f = 0;f < V; f++) {
        let v = T[f];
        w.position(v, P), N.add(P[0], P[1], P[2], G(A, v)), Zw(U, U, P);
      }
      E += V, F = q(S);
    }
  }
  let R = N.getSpheres();
  if (E === 0)
    return R;
  let z;
  M.scale(U, U, 1 / E);
  let D = Y ? C0.clone(Y.boundingSphere) : void 0;
  if (D && M.distance(U, D.center) / D.radius < 1)
    z = D;
  else
    z = C0.expand(C0(), (Q !== null && Q !== void 0 ? Q : J).boundary.sphere, F * W + 0.05);
  return R.setBoundingSphere(z), R;
}
function LX(Z, J, $) {
  let X = !1;
  if (!W0.Loci.is(Z))
    return !1;
  if (!s0.areEquivalent(Z.structure, J))
    return !1;
  let { cumulativeUnitElementCount: Y } = J.serialMapping;
  for (let Q of Z.elements) {
    let W = J.unitIndexMap.get(Q.unit.id);
    if (W !== void 0)
      if (k0.is(Q.indices)) {
        let K = Y[W] + k0.start(Q.indices), G = Y[W] + k0.end(Q.indices);
        if ($(k0.ofBounds(K, G)))
          X = !0;
      } else
        for (let K = 0, G = Q.indices.length;K < G; K++) {
          let H = Y[W] + Q.indices[K];
          if ($(k0.ofSingleton(H)))
            X = !0;
        }
  }
  return X;
}
function RX(Z, J, $) {
  let { objectId: X, groupId: Y } = Z;
  if ($ === X)
    if (Y === K7.Null)
      return s0.Loci(J);
    else {
      let { unitIndices: Q, cumulativeUnitElementCount: W } = J.serialMapping, K = Q[Y], G = J.units[K], H = Y - W[K], N = f0.ofSingleton(H);
      return W0.Loci(J, [{ unit: G, indices: N }]);
    }
  return G8;
}
var _9;
(function(Z) {
  function J(X) {
    let { group: Y, structure: Q } = X, W = Y.elements.length, K = Y.units.length, G = W0.Location.create(Q);
    return X6(W, K, 1, (N, q) => {
      let U = Y.units[q];
      return G.unit = U, G.element = U.elements[N], G;
    });
  }
  Z.fromGroup = J;
  function $(X) {
    let { units: Y, elementCount: Q } = X, W = Q, K = 1, { unitIndices: G, elementIndices: H } = X.serialMapping, N = W0.Location.create(X);
    return X6(W, 1, 1, (U) => {
      return N.unit = Y[G[U]], N.element = H[U], N;
    }, !0);
  }
  Z.fromStructure = $;
})(_9 || (_9 = {}));

// node_modules/molstar/lib/mol-repr/structure/visual/element-sphere.js
var _S0 = {
  sizeFactor: j.Numeric(1, { min: 0, max: 10, step: 0.1 }),
  detail: j.Numeric(0, { min: 0, max: 3, step: 1 }, q1.CustomQualityParamInfo),
  ignoreHydrogens: j.Boolean(!1),
  ignoreHydrogensVariant: j.Select("all", j.arrayToOptions(["all", "non-polar"])),
  traceOnly: j.Boolean(!1),
  tryUseImpostor: j.Boolean(!0),
  stride: j.Numeric(1, { min: 1, max: 100, step: 1 })
}, Jw = {
  ...nZ,
  ...qB,
  ..._S0
};
function xg(Z, J, $, X) {
  return $.tryUseImpostor && WB(X) ? Dj1(Z) : Mj1(Z);
}
function Dj1(Z) {
  return FB({
    defaultProps: j.getDefaultValues(Jw),
    createGeometry: wS0,
    createLocationIterator: _9.fromGroup,
    getLoci: UX,
    eachLocation: FX,
    setUpdateState: (J, $, X) => {
      J.createGeometry = $.ignoreHydrogens !== X.ignoreHydrogens || $.ignoreHydrogensVariant !== X.ignoreHydrogensVariant || $.traceOnly !== X.traceOnly || $.stride !== X.stride;
    },
    mustRecreate: (J, $, X) => {
      return !$.tryUseImpostor || !X;
    }
  }, Z);
}
function Mj1(Z) {
  return A9({
    defaultProps: j.getDefaultValues(Jw),
    createGeometry: BS0,
    createLocationIterator: _9.fromGroup,
    getLoci: UX,
    eachLocation: FX,
    setUpdateState: (J, $, X) => {
      J.createGeometry = $.sizeFactor !== X.sizeFactor || $.detail !== X.detail || $.ignoreHydrogens !== X.ignoreHydrogens || $.ignoreHydrogensVariant !== X.ignoreHydrogensVariant || $.traceOnly !== X.traceOnly || $.stride !== X.stride;
    },
    mustRecreate: (J, $, X) => {
      return $.tryUseImpostor && !!X;
    }
  }, Z);
}
var VS0 = {
  ...tQ,
  ...B_0,
  ..._S0
};
function yg(Z, J, $, X) {
  return $.tryUseImpostor && X && X.extensions.fragDepth && X.extensions.textureFloat ? Aj1(Z) : Bj1(Z);
}
function Aj1(Z) {
  return w_0({
    defaultProps: j.getDefaultValues(VS0),
    createGeometry: TS0,
    createLocationIterator: _9.fromStructure,
    getLoci: RX,
    eachLocation: LX,
    setUpdateState: (J, $, X) => {
      J.createGeometry = $.ignoreHydrogens !== X.ignoreHydrogens || $.ignoreHydrogensVariant !== X.ignoreHydrogensVariant || $.traceOnly !== X.traceOnly || $.stride !== X.stride;
    },
    mustRecreate: (J, $, X) => {
      return !$.tryUseImpostor || !X;
    }
  }, Z);
}
function Bj1(Z) {
  return D$({
    defaultProps: j.getDefaultValues(VS0),
    createGeometry: jS0,
    createLocationIterator: _9.fromStructure,
    getLoci: RX,
    eachLocation: LX,
    setUpdateState: (J, $, X) => {
      J.createGeometry = $.sizeFactor !== X.sizeFactor || $.detail !== X.detail || $.ignoreHydrogens !== X.ignoreHydrogens || $.ignoreHydrogensVariant !== X.ignoreHydrogensVariant || $.traceOnly !== X.traceOnly || $.stride !== X.stride;
    },
    mustRecreate: (J, $, X) => {
      return $.tryUseImpostor && !!X;
    }
  }, Z);
}

// node_modules/molstar/lib/mol-repr/structure/representation/ball-and-stick.js
var IS0 = {
  "element-sphere": (Z, J) => _Z("Element sphere", Z, J, xg),
  "intra-bond": (Z, J) => _Z("Intra-unit bond cylinder", Z, J, fg),
  "inter-bond": (Z, J) => M9("Inter-unit bond cylinder", Z, J, bg),
  "structure-element-sphere": (Z, J) => M9("Structure element sphere", Z, J, yg),
  "structure-intra-bond": (Z, J) => M9("Structure intra-unit bond cylinder", Z, J, hg)
}, PS0 = {
  ...Jw,
  traceOnly: j.Boolean(!1, { isHidden: !0 }),
  ...tB,
  ...eB,
  includeParent: j.Boolean(!1),
  unitKinds: zU(["atomic"]),
  sizeFactor: j.Numeric(0.15, { min: 0.01, max: 10, step: 0.01 }),
  sizeAspectRatio: j.Numeric(0.6666666666666666, { min: 0.01, max: 3, step: 0.01 }),
  visuals: j.MultiSelect(["element-sphere", "intra-bond", "inter-bond"], j.objectToOptions(IS0)),
  bumpFrequency: j.Numeric(0, { min: 0, max: 10, step: 0.1 }, q1.ShadingCategory),
  density: j.Numeric(0.1, { min: 0, max: 1, step: 0.01 }, q1.ShadingCategory)
};
function wj1(Z, J) {
  let $ = PS0;
  if (s0.getSize(J) >= s0.Size.Huge)
    $ = j.clone($), $.visuals.defaultValue = ["element-sphere", "intra-bond"];
  else if (J.unitSymmetryGroups.length > 5000)
    $ = j.clone($), $.visuals.defaultValue = ["structure-element-sphere", "structure-intra-bond"];
  return $;
}
function jj1(Z, J) {
  return V2.createMulti("Ball & Stick", Z, J, lZ, IS0);
}
var CS0 = v9({
  name: "ball-and-stick",
  label: "Ball & Stick",
  description: "Displays atoms as spheres and bonds as cylinders.",
  factory: jj1,
  getParams: wj1,
  defaultValues: j.getDefaultValues(PS0),
  defaultColorTheme: { name: "element-symbol" },
  defaultSizeTheme: { name: "physical" },
  isApplicable: (Z) => Z.elementCount > 0,
  getData: (Z, J) => {
    return J.includeParent ? Z.asParent() : Z;
  },
  mustRecreate: (Z, J) => {
    return Z.includeParent !== J.includeParent;
  }
});

// node_modules/molstar/lib/mol-repr/structure/visual/carbohydrate-link-cylinder.js
function Tj1(Z, J, $, X, Y) {
  let { links: Q, elements: W } = J.carbohydrates, { linkSizeFactor: K } = X, G = W0.Location.create(J), H = {
    linkCount: Q.length,
    position: (U, F, E) => {
      let R = Q[E];
      M.copy(U, W[R.carbohydrateIndexA].geometry.center), M.copy(F, W[R.carbohydrateIndexB].geometry.center);
    },
    radius: (U) => {
      let F = Q[U], E = W[F.carbohydrateIndexA], R = E.unit.rings.all[E.ringIndex];
      return G.unit = E.unit, G.element = E.unit.elements[R[0]], $.size.size(G) * K;
    }
  }, { mesh: N, boundingSphere: q } = uW(Z, H, X, Y);
  if (q)
    N.setBoundingSphere(q);
  else if (N.triangleCount > 0) {
    let U = C0.expand(C0(), J.boundary.sphere, 1 * K);
    N.setBoundingSphere(U);
  }
  return N;
}
var _60 = {
  ...nZ,
  ...hK,
  linkSizeFactor: j.Numeric(0.3, { min: 0, max: 3, step: 0.01 })
};
function kS0(Z) {
  return D$({
    defaultProps: j.getDefaultValues(_60),
    createGeometry: Tj1,
    createLocationIterator: _j1,
    getLoci: Vj1,
    eachLocation: Ij1,
    setUpdateState: (J, $, X) => {
      J.createGeometry = $.linkSizeFactor !== X.linkSizeFactor || $.radialSegments !== X.radialSegments || $.linkCap !== X.linkCap;
    }
  }, Z);
}
function _j1(Z) {
  let { elements: J, links: $ } = Z.carbohydrates, X = $.length, Y = 1, Q = W0.Location.create(Z);
  return X6(X, 1, 1, (K) => {
    let G = $[K], H = J[G.carbohydrateIndexA], N = H.unit.rings.all[H.ringIndex];
    return Q.unit = H.unit, Q.element = H.unit.elements[N[0]], Q;
  }, !0);
}
function Vj1(Z, J, $) {
  let { objectId: X, groupId: Y } = Z;
  if ($ === X)
    if (Y === K7.Null)
      return s0.Loci(J);
    else {
      let { links: Q, elements: W } = J.carbohydrates, K = Q[Y], G = W[K.carbohydrateIndexA], H = W[K.carbohydrateIndexB];
      return W0.Loci.union(QE(J, G.unit, G.residueIndex, G.altId), QE(J, H.unit, H.residueIndex, H.altId));
    }
  return G8;
}
var T60 = /* @__PURE__ */ new Set;
function Ij1(Z, J, $) {
  let X = !1;
  if (!W0.Loci.is(Z))
    return !1;
  if (!s0.areEquivalent(Z.structure, J))
    return !1;
  let { getLinkIndices: Y } = J.carbohydrates;
  for (let { unit: Q, indices: W } of Z.elements) {
    if (!j0.isAtomic(Q))
      continue;
    T60.clear(), f0.forEach(W, (K) => {
      let G = Y(Q, Q.elements[K]);
      for (let H = 0, N = G.length;H < N; ++H)
        if (!T60.has(G[H])) {
          if (T60.add(G[H]), $(k0.ofSingleton(G[H])))
            X = !0;
        }
    });
  }
  return X;
}

// node_modules/molstar/lib/mol-geo/primitive/pyramid.js
var Pj1 = M.create(0, 0, -0.5), Cj1 = M.create(0, 0, 0.5), kE = M(), vE = M(), gg = M(), vS0 = M();
function kj1(Z) {
  let J = Z.length / 3, X = (J === 3 ? 1 : J === 4 ? 2 : J) + J, Y = J === 4 ? J * 3 + 4 : X * 3, Q = RH(X, Y);
  for (let W = 0;W < J; ++W) {
    let K = (W + 1) % J;
    M.set(kE, Z[W * 3], Z[W * 3 + 1], -0.5), M.set(vE, Z[K * 3], Z[K * 3 + 1], -0.5), Q.add(kE, vE, Cj1);
  }
  if (J === 3)
    M.set(kE, Z[0], Z[1], -0.5), M.set(vE, Z[3], Z[4], -0.5), M.set(gg, Z[6], Z[7], -0.5), Q.add(gg, vE, kE);
  else if (J === 4)
    M.set(kE, Z[0], Z[1], -0.5), M.set(vE, Z[3], Z[4], -0.5), M.set(gg, Z[6], Z[7], -0.5), M.set(vS0, Z[9], Z[10], -0.5), Q.addQuad(vS0, gg, vE, kE);
  else
    for (let W = 0;W < J; ++W) {
      let K = (W + 1) % J;
      M.set(kE, Z[W * 3], Z[W * 3 + 1], -0.5), M.set(vE, Z[K * 3], Z[K * 3 + 1], -0.5), Q.add(Pj1, vE, kE);
    }
  return Q.getPrimitive();
}
var V60;
function SS0() {
  if (!V60)
    V60 = kj1(hW(8, !0));
  return V60;
}
var I60;
function fS0() {
  if (!I60) {
    let Z = hW(8, !0), J = new Float32Array(30);
    for (let X = 0;X < 8; ++X)
      J[X * 3] = Z[X * 3], J[X * 3 + 1] = Z[X * 3 + 1], J[X * 3 + 2] = -0.5;
    J[24] = 0, J[25] = 0, J[26] = -0.5, J[27] = 0, J[28] = 0, J[29] = 0.5, I60 = Dz(J, [
      0,
      1,
      8,
      1,
      2,
      8,
      4,
      5,
      8,
      5,
      6,
      8,
      2,
      3,
      9,
      3,
      4,
      9,
      6,
      7,
      9,
      7,
      0,
      9
    ]);
  }
  return I60;
}

// node_modules/molstar/lib/mol-geo/primitive/star.js
var vj1 = {
  pointCount: 5,
  outerRadius: 1,
  innerRadius: 0.5,
  thickness: 0.3
}, P60 = M.zero(), C60 = M.zero(), k60 = M.zero(), MP = M.zero(), v60 = M.zero();
function hS0(Z) {
  let { outerRadius: J, innerRadius: $, thickness: X, pointCount: Y } = { ...vj1, ...Z }, Q = Y * 2 * 2, W = RH(Q), K = new Float32Array(Y * 2), G = new Float32Array(Y * 2);
  for (let H = 0;H < Y; ++H) {
    let N = H * 2, q = H * 2 + 1, U = (N + 1) / Y * Math.PI, F = (q + 1) / Y * Math.PI;
    G[N] = Math.cos(U) * J, G[q] = Math.sin(U) * J, K[N] = Math.cos(F) * $, K[q] = Math.sin(F) * $;
  }
  M.set(P60, 0, 0, X / 2), M.set(C60, 0, 0, -X / 2);
  for (let H = 0;H < Y; ++H) {
    let N = (H + 1) % Y;
    M.set(k60, G[H * 2], G[H * 2 + 1], 0), M.set(MP, K[H * 2], K[H * 2 + 1], 0), M.set(v60, G[N * 2], G[N * 2 + 1], 0), W.add(P60, k60, MP), W.add(MP, k60, C60), W.add(P60, MP, v60), W.add(v60, MP, C60);
  }
  return W.getPrimitive();
}

// node_modules/molstar/lib/mol-geo/primitive/octahedron.js
var h60 = [
  0.5,
  0,
  0,
  -0.5,
  0,
  0,
  0,
  0.5,
  0,
  0,
  -0.5,
  0,
  0,
  0,
  0.5,
  0,
  0,
  -0.5
], Sj1 = [
  0,
  2,
  4,
  0,
  4,
  3,
  0,
  3,
  5,
  0,
  5,
  2,
  1,
  2,
  5,
  1,
  5,
  3,
  1,
  3,
  4,
  1,
  4,
  2
], fj1 = [
  0,
  2,
  4,
  0,
  4,
  3,
  1,
  2,
  5,
  1,
  5,
  3
], hj1 = [
  0,
  2,
  1,
  3,
  2,
  1,
  3,
  0,
  0,
  4,
  1,
  4,
  2,
  4,
  3,
  4,
  0,
  5,
  1,
  5,
  2,
  5,
  3,
  5
], S60;
function bS0() {
  if (!S60)
    S60 = Dz(h60, Sj1);
  return S60;
}
var f60;
function xS0() {
  if (!f60)
    f60 = Dz(h60, fj1);
  return f60;
}
var Lv8 = uN(h60, hj1);

// node_modules/molstar/lib/mol-repr/structure/visual/carbohydrate-symbol-mesh.js
var U8 = e.identity(), SU = M(), yS0 = M(), bj1 = 1.612, gS0 = zA(), mS0 = hE0(), xj1 = SS0(), dS0 = fS0(), yj1 = hS0({ outerRadius: 1, innerRadius: 0.5, thickness: 0.5, pointCount: 5 }), gj1 = bS0(), pS0 = xS0(), uS0 = _40(), mj1 = V40(), dj1 = I40(), pj1 = P40(), uj1 = C40();
function cj1(Z, J, $, X, Y) {
  let Q = v1.createState(256, 128, Y), { detail: W, sizeFactor: K } = X, G = J.carbohydrates, H = G.elements.length, N = W0.Location.create(J);
  for (let q = 0;q < H; ++q) {
    let U = G.elements[q], F = U.unit.rings.all[U.ringIndex], E = fH0(U.component.type, F.length);
    N.unit = U.unit, N.element = U.unit.elements[F[0]];
    let R = $.size.size(N), z = R * K, D = R * K * bj1, { center: A, normal: B, direction: T } = U.geometry;
    switch (M.add(yS0, A, T), e.targetTo(U8, A, yS0, B), e.setTranslation(U8, A), Q.currentGroup = q * 2, E) {
      case R9.FilledSphere:
        g8(Q, A, z, W);
        break;
      case R9.FilledCube:
        e.scaleUniformly(U8, U8, D), v1.addPrimitive(Q, U8, gS0);
        break;
      case R9.CrossedCube:
        e.scaleUniformly(U8, U8, D), v1.addPrimitive(Q, U8, mS0), e.mul(U8, U8, e.rotZ90X180), Q.currentGroup += 1, v1.addPrimitive(Q, U8, mS0);
        break;
      case R9.FilledCone:
        e.scaleUniformly(U8, U8, D * 1.2), v1.addPrimitive(Q, U8, xj1);
        break;
      case R9.DevidedCone:
        e.scaleUniformly(U8, U8, D * 1.2), v1.addPrimitive(Q, U8, dS0), e.mul(U8, U8, e.rotZ90), Q.currentGroup += 1, v1.addPrimitive(Q, U8, dS0);
        break;
      case R9.FlatBox:
        e.mul(U8, U8, e.rotZY90), e.scale(U8, U8, M.set(SU, D, D, D / 2)), v1.addPrimitive(Q, U8, gS0);
        break;
      case R9.FilledStar:
        e.scaleUniformly(U8, U8, D), e.mul(U8, U8, e.rotZY90), v1.addPrimitive(Q, U8, yj1);
        break;
      case R9.FilledDiamond:
        e.mul(U8, U8, e.rotZY90), e.scale(U8, U8, M.set(SU, D * 1.4, D * 1.4, D * 1.4)), v1.addPrimitive(Q, U8, gj1);
        break;
      case R9.DividedDiamond:
        e.mul(U8, U8, e.rotZY90), e.scale(U8, U8, M.set(SU, D * 1.4, D * 1.4, D * 1.4)), v1.addPrimitive(Q, U8, pS0), e.mul(U8, U8, e.rotY90), Q.currentGroup += 1, v1.addPrimitive(Q, U8, pS0);
        break;
      case R9.FlatDiamond:
        e.mul(U8, U8, e.rotZY90), e.scale(U8, U8, M.set(SU, D, D / 2, D / 2)), v1.addPrimitive(Q, U8, uS0);
        break;
      case R9.DiamondPrism:
        e.mul(U8, U8, e.rotZY90), e.scale(U8, U8, M.set(SU, D, D, D / 2)), v1.addPrimitive(Q, U8, uS0);
        break;
      case R9.PentagonalPrism:
      case R9.Pentagon:
        e.mul(U8, U8, e.rotZY90), e.scale(U8, U8, M.set(SU, D, D, D / 2)), v1.addPrimitive(Q, U8, mj1);
        break;
      case R9.HexagonalPrism:
        e.mul(U8, U8, e.rotZY90), e.scale(U8, U8, M.set(SU, D, D, D / 2)), v1.addPrimitive(Q, U8, dj1);
        break;
      case R9.HeptagonalPrism:
        e.mul(U8, U8, e.rotZY90), e.scale(U8, U8, M.set(SU, D, D, D / 2)), v1.addPrimitive(Q, U8, uj1);
        break;
      case R9.FlatHexagon:
      default:
        e.mul(U8, U8, e.rotZYZ90), e.scale(U8, U8, M.set(SU, D / 1.5, D, D / 2)), v1.addPrimitive(Q, U8, pj1);
        break;
    }
  }
  return v1.getMesh(Q);
}
var x60 = {
  ...tQ,
  detail: j.Numeric(0, { min: 0, max: 3, step: 1 }, q1.CustomQualityParamInfo),
  sizeFactor: j.Numeric(1.75, { min: 0, max: 10, step: 0.01 })
};
function cS0(Z) {
  return D$({
    defaultProps: j.getDefaultValues(x60),
    createGeometry: cj1,
    createLocationIterator: lj1,
    getLoci: nj1,
    eachLocation: ij1,
    setUpdateState: (J, $, X) => {
      J.createGeometry = $.sizeFactor !== X.sizeFactor || $.detail !== X.detail;
    }
  }, Z);
}
function lj1(Z) {
  let J = Z.carbohydrates.elements, $ = J.length * 2, X = 1, Y = W0.Location.create(Z);
  function Q(K, G) {
    let H = J[Math.floor(K / 2)], N = H.unit.rings.all[H.ringIndex];
    return Y.unit = H.unit, Y.element = H.unit.elements[N[0]], Y;
  }
  function W(K, G) {
    return K % 2 === 1;
  }
  return X6($, 1, 1, Q, !0, W);
}
function nj1(Z, J, $) {
  let { objectId: X, groupId: Y } = Z;
  if ($ === X)
    if (Y === K7.Null)
      return s0.Loci(J);
    else {
      let Q = J.carbohydrates.elements[Math.floor(Y / 2)];
      return QE(J, Q.unit, Q.residueIndex, Q.altId);
    }
  return G8;
}
var b60 = /* @__PURE__ */ new Set;
function ij1(Z, J, $) {
  let { getElementIndices: X } = J.carbohydrates, Y = !1;
  if (!W0.Loci.is(Z))
    return !1;
  if (!s0.areEquivalent(Z.structure, J))
    return !1;
  for (let { unit: Q, indices: W } of Z.elements) {
    if (!j0.isAtomic(Q))
      continue;
    b60.clear(), f0.forEach(W, (K) => {
      let G = X(Q, Q.elements[K]);
      for (let H = 0, N = G.length;H < N; ++H)
        if (!b60.has(G[H])) {
          if (b60.add(G[H]), $(k0.ofSingleton(G[H] * 2)))
            Y = !0;
        }
    });
  }
  return Y;
}

// node_modules/molstar/lib/mol-repr/structure/visual/carbohydrate-terminal-link-cylinder.js
function oj1(Z, J, $, X, Y) {
  let { terminalLinks: Q, elements: W } = J.carbohydrates, { terminalLinkSizeFactor: K } = X, G = W0.Location.create(J), H = {
    linkCount: Q.length,
    position: (U, F, E) => {
      let R = Q[E];
      if (R.fromCarbohydrate)
        M.copy(U, W[R.carbohydrateIndex].geometry.center), R.elementUnit.conformation.position(R.elementUnit.elements[R.elementIndex], F);
      else
        R.elementUnit.conformation.position(R.elementUnit.elements[R.elementIndex], U), M.copy(F, W[R.carbohydrateIndex].geometry.center);
    },
    radius: (U) => {
      let F = Q[U];
      if (F.fromCarbohydrate) {
        let E = W[F.carbohydrateIndex], R = E.unit.rings.all[E.ringIndex];
        G.unit = E.unit, G.element = E.unit.elements[R[0]];
      } else
        G.unit = F.elementUnit, G.element = F.elementUnit.elements[F.elementIndex];
      return $.size.size(G) * K;
    },
    style: (U) => {
      let F = Q[U], E = F.elementUnit.elements[F.elementIndex], R = M5(F.elementUnit.model.atomicHierarchy.atoms.type_symbol.value(E));
      return BR.has(R) ? j2.Dashed : j2.Solid;
    }
  }, { mesh: N, boundingSphere: q } = uW(Z, H, X, Y);
  if (q)
    N.setBoundingSphere(q);
  else if (N.triangleCount > 0) {
    let U = C0.expand(C0(), J.boundary.sphere, 1 * K);
    N.setBoundingSphere(U);
  }
  return N;
}
var g60 = {
  ...nZ,
  ...hK,
  terminalLinkSizeFactor: j.Numeric(0.2, { min: 0, max: 3, step: 0.01 })
};
function lS0(Z) {
  return D$({
    defaultProps: j.getDefaultValues(g60),
    createGeometry: oj1,
    createLocationIterator: sj1,
    getLoci: aj1,
    eachLocation: rj1,
    setUpdateState: (J, $, X) => {
      J.createGeometry = $.terminalLinkSizeFactor !== X.terminalLinkSizeFactor || $.radialSegments !== X.radialSegments || $.linkCap !== X.linkCap;
    }
  }, Z);
}
function sj1(Z) {
  let { elements: J, terminalLinks: $ } = Z.carbohydrates, X = $.length, Y = 1, Q = W0.Location.create(Z);
  return X6(X, 1, 1, (K) => {
    let G = $[K];
    if (G.fromCarbohydrate) {
      let H = J[G.carbohydrateIndex], N = H.unit.rings.all[H.ringIndex];
      Q.unit = H.unit, Q.element = H.unit.elements[N[0]];
    } else
      Q.unit = G.elementUnit, Q.element = G.elementUnit.elements[G.elementIndex];
    return Q;
  }, !0);
}
function aj1(Z, J, $) {
  let { objectId: X, groupId: Y } = Z;
  if ($ === X)
    if (Y === K7.Null)
      return s0.Loci(J);
    else {
      let { terminalLinks: Q, elements: W } = J.carbohydrates, K = Q[Y], G = W[K.carbohydrateIndex];
      return W0.Loci.union(QE(J, G.unit, G.residueIndex, G.altId), O_0(J, K.elementUnit, K.elementUnit.elements[K.elementIndex]));
    }
  return G8;
}
var y60 = /* @__PURE__ */ new Set;
function rj1(Z, J, $) {
  let X = !1;
  if (!W0.Loci.is(Z))
    return !1;
  if (!s0.areEquivalent(Z.structure, J))
    return !1;
  let { getTerminalLinkIndices: Y } = J.carbohydrates;
  for (let { unit: Q, indices: W } of Z.elements) {
    if (!j0.isAtomic(Q))
      continue;
    y60.clear(), f0.forEach(W, (K) => {
      let G = Y(Q, Q.elements[K]);
      for (let H = 0, N = G.length;H < N; ++H)
        if (!y60.has(G[H])) {
          if (y60.add(G[H]), $(k0.ofSingleton(G[H])))
            X = !0;
        }
    });
  }
  return X;
}

// node_modules/molstar/lib/mol-repr/structure/representation/carbohydrate.js
var nS0 = {
  "carbohydrate-symbol": (Z, J) => M9("Carbohydrate symbol mesh", Z, J, cS0),
  "carbohydrate-link": (Z, J) => M9("Carbohydrate link cylinder", Z, J, kS0),
  "carbohydrate-terminal-link": (Z, J) => M9("Carbohydrate terminal link cylinder", Z, J, lS0)
}, iS0 = {
  ...x60,
  ..._60,
  ...g60,
  visuals: j.MultiSelect(["carbohydrate-symbol", "carbohydrate-link", "carbohydrate-terminal-link"], j.objectToOptions(nS0)),
  bumpFrequency: j.Numeric(0, { min: 0, max: 10, step: 0.1 }, q1.ShadingCategory),
  density: j.Numeric(0.2, { min: 0, max: 1, step: 0.01 }, q1.ShadingCategory)
};
function tj1(Z, J) {
  return iS0;
}
function ej1(Z, J) {
  return V2.createMulti("Carbohydrate", Z, J, lZ, nS0);
}
var oS0 = v9({
  name: "carbohydrate",
  label: "Carbohydrate",
  description: "Displays carbohydrate symbols (3D SNFG).",
  factory: ej1,
  getParams: tj1,
  defaultValues: j.getDefaultValues(iS0),
  defaultColorTheme: { name: "carbohydrate-symbol" },
  defaultSizeTheme: { name: "uniform" },
  isApplicable: (Z) => {
    return Z.models.some((J) => O2.hasCarbohydrate(J));
  }
});

// node_modules/molstar/lib/mol-repr/structure/visual/util/polymer/backbone.js
function m60(Z, J) {
  switch (Z.kind) {
    case j0.Kind.Atomic:
      return ZT1(Z, J);
    case j0.Kind.Spheres:
    case j0.Kind.Gaussians:
      return JT1(Z, J);
  }
}
function ZT1(Z, J) {
  let $ = Z.model.atomicRanges.cyclicPolymerMap, X = XZ.transientSegments(D4(Z), Z.elements), Y = b2.transientSegments(Z.model.atomicHierarchy.residueAtomSegments, Z.elements), Q = Z.model.atomicHierarchy.derived.residue.traceElementIndex, { moleculeType: W } = Z.model.atomicHierarchy.derived.residue, K = -1, G = -1, H = !0, N = -1, q = 0;
  while (X.hasNext) {
    H = !0, N = q, Y.setSegment(X.move());
    while (Y.hasNext) {
      if (H) {
        let F = Y.move().index;
        if (++q, !Y.hasNext)
          continue;
        H = !1, G = F;
      }
      let U = Y.move().index;
      K = G, G = U, J(Q[K], Q[G], q - 1, q, W[K]), ++q;
    }
    if ($.has(G))
      K = G, G = $.get(K), J(Q[K], Q[G], q - 1, N, W[K]);
  }
}
function JT1(Z, J) {
  let $ = XZ.transientSegments(D4(Z), Z.elements), { elements: X } = Z, Y = !0, Q = 0;
  while ($.hasNext) {
    Y = !0;
    let W = $.move(), K = W.start, G = W.end;
    for (let H = K, N = G;H < N; ++H) {
      if (Y) {
        if (++H, ++Q, H > N)
          continue;
        Y = !1;
      }
      J(X[H - 1], X[H], Q - 1, Q, 0), ++Q;
    }
  }
}
function d60(Z, J) {
  switch (Z.kind) {
    case j0.Kind.Atomic:
      return $T1(Z, J);
    case j0.Kind.Spheres:
    case j0.Kind.Gaussians:
      return XT1(Z, J);
  }
}
function $T1(Z, J) {
  let $ = XZ.transientSegments(D4(Z), Z.elements), X = b2.transientSegments(Z.model.atomicHierarchy.residueAtomSegments, Z.elements), Y = Z.model.atomicHierarchy.derived.residue.traceElementIndex, Q = 0;
  while ($.hasNext) {
    X.setSegment($.move());
    while (X.hasNext) {
      let W = X.move().index;
      J(Y[W], Q), ++Q;
    }
  }
}
function XT1(Z, J) {
  let $ = XZ.transientSegments(D4(Z), Z.elements), { elements: X } = Z, Y = 0;
  while ($.hasNext) {
    let Q = $.move(), W = Q.start, K = Q.end;
    for (let G = W, H = K;G < H; ++G)
      J(X[G], Y), ++Y;
  }
}
// node_modules/molstar/lib/mol-repr/structure/visual/util/polymer/gap-iterator.js
function sS0(Z, J) {
  switch (J.kind) {
    case j0.Kind.Atomic:
      return new rS0(Z, J);
    case j0.Kind.Spheres:
    case j0.Kind.Gaussians:
      return new tS0(Z, J);
  }
}
function aS0(Z, J) {
  return {
    centerA: W0.Location.create(Z, J),
    centerB: W0.Location.create(Z, J)
  };
}

class rS0 {
  move() {
    let { elements: Z, residueIndex: J } = this.unit, $ = this.gapIt.move();
    return this.value.centerA.element = this.traceElementIndex[J[Z[$.start]]], this.value.centerB.element = this.traceElementIndex[J[Z[$.end - 1]]], this.hasNext = this.gapIt.hasNext, this.value;
  }
  constructor(Z, J) {
    this.unit = J, this.hasNext = !1, this.traceElementIndex = J.model.atomicHierarchy.derived.residue.traceElementIndex, this.gapIt = XZ.transientSegments(p60(J), J.elements), this.value = aS0(Z, J), this.hasNext = this.gapIt.hasNext;
  }
}

class tS0 {
  move() {
    let Z = this.gapIt.move();
    return this.value.centerA.element = this.unit.elements[Z.start], this.value.centerB.element = this.unit.elements[Z.end - 1], this.hasNext = this.gapIt.hasNext, this.value;
  }
  constructor(Z, J) {
    this.unit = J, this.hasNext = !1, this.gapIt = XZ.transientSegments(p60(J), J.elements), this.value = aS0(Z, J), this.hasNext = this.gapIt.hasNext;
  }
}
// node_modules/molstar/lib/mol-model-props/computed/helix-orientation/helix-orientation.js
function eS0(Z) {
  let { x: J, y: $, z: X } = Z.atomicConformation, { polymerType: Y, traceElementIndex: Q } = Z.atomicHierarchy.derived.residue, W = Y.length, K = f0.ofBounds(0, Z.atomicConformation.atomId.rowCount), G = XZ.transientSegments(Z.atomicRanges.polymerRanges, K), H = b2.transientSegments(Z.atomicHierarchy.residueAtomSegments, K), N = new Float32Array(W * 3), q = new Float32Array(W * 3), U = 0, F = -1, E = -1, R = M(), z = M(), D = M(), A = M(), B = M(), T = M(), w = M(), V = M(), P = M(), I = M(), S = M(), f = M(), v = M(), h = M();
  while (G.hasNext) {
    let x = G.move();
    H.setSegment(x), U = -1, E = -1;
    while (H.hasNext) {
      U += 1;
      let { index: Y0 } = H.move();
      if (U === 0)
        E = Y0;
      F = Y0 - 2;
      let c = F * 3;
      M.copy(R, z), M.copy(z, D), M.copy(D, A);
      let n = Q[Y0];
      if (M.set(A, J[n], $[n], X[n]), U < 3)
        continue;
      M.sub(B, z, R), M.sub(T, D, z), M.sub(w, A, D), M.sub(S, B, T), M.sub(f, T, w), M.cross(v, S, f), M.normalize(v, v), M.toArray(v, q, c);
      let l = Math.cos(M.angle(S, f)), u = M.magnitude(S), G0 = M.magnitude(f), F0 = Math.sqrt(G0 * u) / Math.max(2, 2 * (1 - l));
      M.scale(V, S, F0 / u), M.sub(V, z, V), M.toArray(V, N, c), M.scale(P, f, F0 / G0), M.sub(P, D, P), M.toArray(P, N, c + 3), M.copy(h, v);
    }
    let b = E * 3;
    M.fromArray(V, N, b + 3), M.fromArray(P, N, b + 6), M.normalize(v, M.sub(v, V, P));
    let g = Q[E];
    M.set(R, J[g], $[g], X[g]), M.copy(I, R), M.projectPointOnVector(I, I, v, V), M.toArray(I, N, b);
    let m = F + 2, i = m * 3;
    M.fromArray(V, N, i - 3), M.fromArray(P, N, i - 6), M.normalize(v, M.sub(v, V, P));
    let r = Q[m];
    M.set(R, J[r], $[r], X[r]), M.copy(I, R), M.projectPointOnVector(I, I, v, V), M.toArray(I, N, i);
  }
  return {
    centers: N
  };
}

// node_modules/molstar/lib/mol-model-props/computed/helix-orientation.js
var AP = j3.createProvider({
  label: "Helix Orientation",
  descriptor: p7({
    name: "molstar_helix_orientation"
  }),
  type: "dynamic",
  defaultParams: {},
  getParams: () => ({}),
  isApplicable: (Z) => !0,
  obtain: async (Z, J) => {
    return { value: eS0(J) };
  }
});

// node_modules/molstar/lib/mol-repr/structure/visual/util/polymer/trace-iterator.js
function dH(Z) {
  return m2.is(Z, m2.Flag.Helix);
}
function YT1(Z) {
  return m2.is(Z, m2.Flag.Beta);
}
function $w(Z, J, $ = {}) {
  switch (Z.kind) {
    case j0.Kind.Atomic:
      return new Jf0(Z, J, $);
    case j0.Kind.Spheres:
    case j0.Kind.Gaussians:
      return new $f0(Z, J);
  }
}
var pg = m2.create(m2.Flag.NA);
function Zf0(Z, J) {
  return {
    center: W0.Location.create(Z, J),
    centerPrev: W0.Location.create(Z, J),
    centerNext: W0.Location.create(Z, J),
    first: !1,
    last: !1,
    initial: !1,
    final: !1,
    secStrucFirst: !1,
    secStrucLast: !1,
    secStrucType: pg,
    moleculeType: e2.Unknown,
    coarseBackboneFirst: !1,
    coarseBackboneLast: !1,
    p0: M(),
    p1: M(),
    p2: M(),
    p3: M(),
    p4: M(),
    d12: M(),
    d23: M()
  };
}
var M4;
(function(Z) {
  Z[Z.nextPolymer = 0] = "nextPolymer", Z[Z.nextResidue = 1] = "nextResidue";
})(M4 || (M4 = {}));
var l8 = M(), mg = M(), dg = M();

class Jf0 {
  atomicPos(Z, J) {
    if (J !== -1)
      Z[0] = this.atomicConformation.x[J], Z[1] = this.atomicConformation.y[J], Z[2] = this.atomicConformation.z[J];
  }
  pos(Z, J, $) {
    let X = this.traceElementIndex[J];
    if (this.helixOrientationCenters && dH($))
      M.fromArray(Z, this.helixOrientationCenters, J * 3);
    else
      this.atomicPos(Z, X);
  }
  updateResidueSegmentRange(Z) {
    let { index: J } = this.residueAtomSegments;
    this.residueSegmentMin = J[this.polymerRanges[Z.index * 2]], this.residueSegmentMax = J[this.polymerRanges[Z.index * 2 + 1]];
  }
  getResidueIndex(Z) {
    if (Z < this.residueSegmentMin) {
      let J = this.cyclicPolymerMap.get(this.residueSegmentMin);
      if (J !== void 0)
        Z = J - (this.residueSegmentMin - Z - 1);
      else
        Z = this.residueSegmentMin;
    } else if (Z > this.residueSegmentMax) {
      let J = this.cyclicPolymerMap.get(this.residueSegmentMax);
      if (J !== void 0)
        Z = J + (Z - this.residueSegmentMax - 1);
      else
        Z = this.residueSegmentMax;
    }
    return Z;
  }
  getSecStruc(Z) {
    if (this.secondaryStructure) {
      let { type: J, getIndex: $ } = this.secondaryStructure, X = J[$(Z)];
      return dH(X) ? m2.Flag.Helix : X;
    } else
      return pg;
  }
  setControlPoint(Z, J, $, X, Y) {
    if (YT1(Y) || this.helixOrientationCenters && dH(Y))
      M.scale(Z, M.add(Z, J, M.add(Z, X, M.add(Z, $, $))), 0.25);
    else
      M.copy(Z, $);
  }
  setFromToVector(Z, J, $) {
    if (this.helixOrientationCenters && dH($))
      M.set(Z, 1, 0, 0);
    else
      this.atomicPos(mg, this.directionFromElementIndex[J]), this.atomicPos(dg, this.directionToElementIndex[J]), M.sub(Z, dg, mg);
  }
  setDirection(Z, J, $, X) {
    M.matchDirection(mg, J, $), M.matchDirection(dg, X, $), M.scale(Z, M.add(Z, mg, M.add(Z, dg, M.add(Z, $, $))), 0.25);
  }
  move() {
    let { residueIt: Z, polymerIt: J, value: $ } = this;
    if (this.state === M4.nextPolymer) {
      while (J.hasNext)
        if (this.polymerSegment = J.move(), Z.setSegment(this.polymerSegment), this.updateResidueSegmentRange(this.polymerSegment), Z.hasNext) {
          this.state = M4.nextResidue;
          let X = this.residueAtomSegments.index[this.unit.elements[this.polymerSegment.start]], Y = this.getResidueIndex(X - 1);
          this.currSecStrucType = X === Y ? pg : this.getSecStruc(Y), this.nextSecStrucType = this.getSecStruc(X), this.currCoarseBackbone = this.directionFromElementIndex[Y] === -1 || this.directionToElementIndex[Y] === -1, this.nextCoarseBackbone = this.directionFromElementIndex[X] === -1 || this.directionToElementIndex[X] === -1;
          break;
        }
    }
    if (this.state === M4.nextResidue) {
      let { index: X } = Z.move(), Y = this.getResidueIndex(X - 3), Q = this.getResidueIndex(X - 2), W = this.getResidueIndex(X - 1), K = this.getResidueIndex(X + 1), G = this.getResidueIndex(X + 2), H = this.getResidueIndex(X + 3);
      this.prevSecStrucType = this.getSecStruc(W), this.currSecStrucType = this.getSecStruc(X), this.nextSecStrucType = X === K ? pg : this.getSecStruc(K), this.prevCoarseBackbone = this.currCoarseBackbone, this.currCoarseBackbone = this.nextCoarseBackbone, this.nextCoarseBackbone = this.directionFromElementIndex[K] === -1 || this.directionToElementIndex[K] === -1, $.secStrucType = this.currSecStrucType, $.secStrucFirst = this.prevSecStrucType !== this.currSecStrucType, $.secStrucLast = this.currSecStrucType !== this.nextSecStrucType, $.coarseBackboneFirst = this.prevCoarseBackbone !== this.currCoarseBackbone, $.coarseBackboneLast = this.currCoarseBackbone !== this.nextCoarseBackbone, $.first = X === this.residueSegmentMin, $.last = X === this.residueSegmentMax, $.moleculeType = this.moleculeType[X], $.initial = X === W, $.final = X === K, $.centerPrev.element = this.traceElementIndex[W], $.center.element = this.traceElementIndex[X], $.centerNext.element = this.traceElementIndex[K];
      let N = this.getSecStruc(Y), q = this.getSecStruc(Q), U = this.getSecStruc(W), F = this.getSecStruc(X), E = this.getSecStruc(K), R = this.getSecStruc(G), z = this.getSecStruc(H);
      this.pos(this.p0, Y, N), this.pos(this.p1, Q, q), this.pos(this.p2, W, U), this.pos(this.p3, X, F), this.pos(this.p4, K, E), this.pos(this.p5, G, R), this.pos(this.p6, H, z);
      let D = dH(N), A = dH(q), B = dH(U), T = dH(F), w = dH(E), V = dH(R), P = dH(z);
      if (this.helixOrientationCenters && !(T && $.secStrucFirst && $.secStrucLast)) {
        if (T !== B) {
          if (T)
            M.copy(this.p0, this.p3), M.copy(this.p1, this.p3), M.copy(this.p2, this.p3);
          else if (B)
            M.scale(l8, M.sub(l8, this.p2, this.p3), 2), M.add(this.p2, this.p3, l8), M.add(this.p1, this.p2, l8), M.add(this.p0, this.p1, l8);
        } else if (T !== A) {
          if (T)
            M.copy(this.p0, this.p2), M.copy(this.p1, this.p2);
          else if (A)
            M.scale(l8, M.sub(l8, this.p1, this.p2), 2), M.add(this.p1, this.p2, l8), M.add(this.p0, this.p1, l8);
        } else if (T !== D) {
          if (T)
            M.copy(this.p0, this.p1);
          else if (D)
            M.scale(l8, M.sub(l8, this.p0, this.p1), 2), M.add(this.p0, this.p1, l8);
        }
        if (T !== w) {
          if (T)
            M.copy(this.p4, this.p3), M.copy(this.p5, this.p3), M.copy(this.p6, this.p3);
          else if (w)
            M.scale(l8, M.sub(l8, this.p4, this.p3), 2), M.add(this.p4, this.p3, l8), M.add(this.p5, this.p4, l8), M.add(this.p6, this.p5, l8);
        } else if (T !== V) {
          if (T)
            M.copy(this.p5, this.p4), M.copy(this.p6, this.p4);
          else if (V)
            M.scale(l8, M.sub(l8, this.p5, this.p4), 2), M.add(this.p5, this.p4, l8), M.add(this.p6, this.p5, l8);
        } else if (T !== P) {
          if (T)
            M.copy(this.p6, this.p5);
          else if (P)
            M.scale(l8, M.sub(l8, this.p6, this.p5), 2), M.add(this.p6, this.p5, l8);
        }
      }
      if (this.currCoarseBackbone)
        M.triangleNormal(this.d01, this.p1, this.p2, this.p3), M.triangleNormal(this.d12, this.p2, this.p3, this.p4), M.triangleNormal(this.d23, this.p3, this.p4, this.p5), M.triangleNormal(this.d34, this.p4, this.p5, this.p6);
      else
        this.setFromToVector(this.d01, W, U), this.setFromToVector(this.d12, X, F), this.setFromToVector(this.d23, K, E), this.setFromToVector(this.d34, G, R);
      let I = T && this.helixOrientationCenters, S = 1.5;
      if (X === W || F !== U && I)
        M.setMagnitude(l8, M.sub(l8, this.p3, this.p4), S), M.add(this.p2, this.p3, l8), M.add(this.p1, this.p2, l8), M.add(this.p0, this.p1, l8);
      else if (W === Q || F !== q && I)
        M.setMagnitude(l8, M.sub(l8, this.p2, this.p3), S), M.add(this.p1, this.p2, l8), M.add(this.p0, this.p1, l8);
      else if (Q === Y || F !== N && I)
        M.setMagnitude(l8, M.sub(l8, this.p1, this.p2), S), M.add(this.p0, this.p1, l8);
      if (X === K || F !== E && I)
        M.setMagnitude(l8, M.sub(l8, this.p3, this.p2), S), M.add(this.p4, this.p3, l8), M.add(this.p5, this.p4, l8), M.add(this.p6, this.p5, l8);
      else if (K === G || F !== R && I)
        M.setMagnitude(l8, M.sub(l8, this.p4, this.p3), S), M.add(this.p5, this.p4, l8), M.add(this.p6, this.p5, l8);
      else if (G === H || F !== z && I)
        M.setMagnitude(l8, M.sub(l8, this.p5, this.p4), S), M.add(this.p6, this.p5, l8);
      if (this.setControlPoint($.p0, this.p0, this.p1, this.p2, q), this.setControlPoint($.p1, this.p1, this.p2, this.p3, U), this.setControlPoint($.p2, this.p2, this.p3, this.p4, F), this.setControlPoint($.p3, this.p3, this.p4, this.p5, E), this.setControlPoint($.p4, this.p4, this.p5, this.p6, R), this.setDirection($.d12, this.d01, this.d12, this.d23), this.setDirection($.d23, this.d12, this.d23, this.d34), !Z.hasNext)
        this.state = M4.nextPolymer;
    }
    return this.hasNext = Z.hasNext || J.hasNext, this.value;
  }
  constructor(Z, J, $ = {}) {
    var X;
    if (this.unit = Z, this.state = M4.nextPolymer, this.p0 = M(), this.p1 = M(), this.p2 = M(), this.p3 = M(), this.p4 = M(), this.p5 = M(), this.p6 = M(), this.d01 = M(), this.d12 = M(), this.d23 = M(), this.d34 = M(), this.hasNext = !1, this.atomicConformation = Z.model.atomicConformation, this.residueAtomSegments = Z.model.atomicHierarchy.residueAtomSegments, this.polymerRanges = Z.model.atomicRanges.polymerRanges, this.traceElementIndex = Z.model.atomicHierarchy.derived.residue.traceElementIndex, this.directionFromElementIndex = Z.model.atomicHierarchy.derived.residue.directionFromElementIndex, this.directionToElementIndex = Z.model.atomicHierarchy.derived.residue.directionToElementIndex, this.moleculeType = Z.model.atomicHierarchy.derived.residue.moleculeType, this.cyclicPolymerMap = Z.model.atomicRanges.cyclicPolymerMap, this.polymerIt = XZ.transientSegments(this.polymerRanges, Z.elements), this.residueIt = b2.transientSegments(this.residueAtomSegments, Z.elements), this.value = Zf0(J, Z), this.hasNext = this.residueIt.hasNext && this.polymerIt.hasNext, !$.ignoreSecondaryStructure)
      this.secondaryStructure = (X = $X.get(J).value) === null || X === void 0 ? void 0 : X.get(Z.invariantId);
    if ($.useHelixOrientation) {
      let Y = AP.get(Z.model).value;
      if (!Y)
        throw new Error("missing helix-orientation");
      this.helixOrientationCenters = Y.centers;
    }
  }
}
var A4;
(function(Z) {
  Z[Z.nextPolymer = 0] = "nextPolymer", Z[Z.nextElement = 1] = "nextElement";
})(A4 || (A4 = {}));

class $f0 {
  getElementIndex(Z) {
    return Math.min(Math.max(this.polymerSegment.start, Z), this.polymerSegment.end - 1);
  }
  pos(Z, J) {
    let $ = this.unit.elements[J];
    Z[0] = this.conformation.x[$], Z[1] = this.conformation.y[$], Z[2] = this.conformation.z[$];
  }
  move() {
    if (this.state === A4.nextPolymer) {
      while (this.polymerIt.hasNext)
        if (this.polymerSegment = this.polymerIt.move(), this.elementIndex = this.polymerSegment.start, this.elementIndex < this.polymerSegment.end) {
          this.state = A4.nextElement;
          break;
        }
    }
    if (this.state === A4.nextElement) {
      let Z = this.getElementIndex(this.elementIndex - 2), J = this.getElementIndex(this.elementIndex - 1), $ = this.getElementIndex(this.elementIndex + 1), X = this.getElementIndex(this.elementIndex + 2);
      this.value.centerPrev.element = this.value.center.unit.elements[J], this.value.center.element = this.value.center.unit.elements[this.elementIndex], this.value.centerNext.element = this.value.center.unit.elements[$], this.pos(this.value.p0, Z), this.pos(this.value.p1, J), this.pos(this.value.p2, this.elementIndex), this.pos(this.value.p3, $), this.pos(this.value.p4, X);
      let Y = 0.5;
      if (this.elementIndex === J)
        M.scale(l8, M.sub(l8, this.value.p2, this.value.p3), Y), M.add(this.value.p1, this.value.p2, l8), M.add(this.value.p0, this.value.p1, l8);
      else if (J === Z)
        M.scale(l8, M.sub(l8, this.value.p1, this.value.p2), Y), M.add(this.value.p0, this.value.p1, l8);
      if (this.elementIndex === $)
        M.scale(l8, M.sub(l8, this.value.p2, this.value.p1), Y), M.add(this.value.p3, this.value.p2, l8), M.add(this.value.p4, this.value.p3, l8);
      else if ($ === X)
        M.scale(l8, M.sub(l8, this.value.p3, this.value.p2), Y), M.add(this.value.p4, this.value.p3, l8);
      if (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 = A4.nextPolymer;
    }
    return this.hasNext = this.elementIndex + 1 < this.polymerSegment.end || this.polymerIt.hasNext, this.elementIndex += 1, this.value;
  }
  constructor(Z, J) {
    switch (this.unit = Z, this.state = A4.nextPolymer, this.hasNext = !1, this.polymerIt = XZ.transientSegments(D4(Z), Z.elements), this.value = Zf0(J, Z), M.set(this.value.d12, 1, 0, 0), M.set(this.value.d23, 1, 0, 0), Z.kind) {
      case j0.Kind.Spheres:
        this.conformation = Z.model.coarseConformation.spheres;
        break;
      case j0.Kind.Gaussians:
        this.conformation = Z.model.coarseConformation.gaussians;
        break;
    }
    this.hasNext = this.polymerIt.hasNext;
  }
}
// node_modules/molstar/lib/mol-repr/structure/visual/util/polymer/curve-segment.js
var B4 = M.fromArray, Qw = M.toArray, o60 = M.normalize, QT1 = M.sub, Xw = M.spline, WT1 = M.slerp, Xf0 = M.copy, Yf0 = M.cross, u60 = M.orthogonalize, KT1 = M.matchDirection, GT1 = M.scale, Qf0 = M.add;
function Ww(Z) {
  let J = Z + 1, $ = J * 3;
  return {
    curvePoints: new Float32Array($),
    tangentVectors: new Float32Array($),
    normalVectors: new Float32Array($),
    binormalVectors: new Float32Array($),
    widthValues: new Float32Array(J),
    heightValues: new Float32Array(J),
    linearSegments: Z
  };
}
function Kw(Z, J, $, X) {
  HT1(Z, J, $, X), qT1(Z, J);
}
var c60 = M(), l60 = M(), n60 = M();
function HT1(Z, J, $, X) {
  let { curvePoints: Y, tangentVectors: Q, linearSegments: W } = Z, { p0: K, p1: G, p2: H, p3: N, p4: q, secStrucFirst: U, secStrucLast: F } = J, E = 1 - X, R = U ? 0.5 : $, z = F ? 0.5 : $;
  for (let D = 0;D <= W; ++D) {
    let A = D * 1 / W;
    if (A < E) {
      let B = pZ(R, $, A);
      Xw(n60, K, G, H, N, A + X, B), Xw(c60, K, G, H, N, A + X + 0.01, R), Xw(l60, K, G, H, N, A + X - 0.01, R);
    } else {
      let B = pZ($, z, A);
      Xw(n60, G, H, N, q, A - E, B), Xw(c60, G, H, N, q, A - E + 0.01, B), Xw(l60, G, H, N, q, A - E - 0.01, B);
    }
    Qw(n60, Y, D * 3), o60(SE, QT1(SE, c60, l60)), Qw(SE, Q, D * 3);
  }
}
var NT1 = M(), SE = M(), pH = M(), Yw = M(), BP = M(), Wf0 = M(), Kf0 = M(), Gf0 = M(), i60 = M(), ug = M();
function qT1(Z, J) {
  let { curvePoints: $, tangentVectors: X, normalVectors: Y, binormalVectors: Q } = Z, { d12: W, d23: K } = J, G = $.length / 3;
  B4(Kf0, X, 0), B4(Gf0, X, (G - 1) * 3), u60(i60, Kf0, W), u60(ug, Gf0, K), KT1(ug, ug, i60), Xf0(BP, i60);
  let H = G - 1;
  for (let N = 0;N < G; ++N) {
    let q = MS(0, H, N) * H, U = N === 0 ? 0 : 1 / (G - q);
    B4(SE, X, N * 3), u60(pH, SE, WT1(NT1, BP, ug, U)), Qw(pH, Y, N * 3), Xf0(BP, pH), o60(Yw, Yf0(Yw, SE, pH)), Qw(Yw, Q, N * 3);
  }
  for (let N = 1;N < H; ++N)
    B4(BP, Y, (N - 1) * 3), B4(pH, Y, N * 3), B4(Wf0, Y, (N + 1) * 3), GT1(pH, Qf0(pH, BP, Qf0(pH, Wf0, pH)), 0.3333333333333333), Qw(pH, Y, N * 3), B4(SE, X, N * 3), o60(Yw, Yf0(Yw, SE, pH)), Qw(Yw, Q, N * 3);
}
function wP(Z, J, $, X, Y, Q, W, K) {
  let { widthValues: G, heightValues: H, linearSegments: N } = Z, q = 1 - K;
  for (let U = 0;U <= N; ++U) {
    let F = U * 1 / N;
    if (F < q)
      G[U] = pZ(J, $, F + K), H[U] = pZ(Y, Q, F + K);
    else
      G[U] = pZ($, X, F - q), H[U] = pZ(Q, W, F - q);
  }
}

// node_modules/molstar/lib/mol-repr/structure/visual/util/polymer.js
var lg = 0.5, Nf0 = 0.9, w4 = 0.5, j4 = 0.3, Gw = 2;
function D4(Z) {
  switch (Z.kind) {
    case j0.Kind.Atomic:
      return Z.model.atomicRanges.polymerRanges;
    case j0.Kind.Spheres:
      return Z.model.coarseHierarchy.spheres.polymerRanges;
    case j0.Kind.Gaussians:
      return Z.model.coarseHierarchy.gaussians.polymerRanges;
  }
}
function p60(Z) {
  switch (Z.kind) {
    case j0.Kind.Atomic:
      return Z.model.atomicRanges.gapRanges;
    case j0.Kind.Spheres:
      return Z.model.coarseHierarchy.spheres.gapRanges;
    case j0.Kind.Gaussians:
      return Z.model.coarseHierarchy.gaussians.gapRanges;
  }
}
var d5;
(function(Z) {
  function J($, X) {
    let { group: Y, structure: Q } = $, W = Y.units[0].polymerElements, K = W.length, G = Y.units.length, H = W0.Location.create(Q), N = (F, E) => {
      let R = Y.units[E];
      return H.unit = R, H.element = W[F], H;
    }, q = !!(X === null || X === void 0 ? void 0 : X.asSecondary);
    function U(F, E) {
      return q;
    }
    return X6(K, G, 1, N, !1, U);
  }
  Z.fromGroup = J;
})(d5 || (d5 = {}));
var cg;
(function(Z) {
  function J($, X) {
    let { group: Y, structure: Q } = $, W = Y.units[0].gapElements, K = W.length, G = Y.units.length, H = W0.Location.create(Q), N = (F, E) => {
      let R = Y.units[E];
      return H.unit = R, H.element = W[F], H;
    }, q = !!(X === null || X === void 0 ? void 0 : X.asSecondary);
    function U(F, E) {
      return q;
    }
    return X6(K, G, 1, N, !1, U);
  }
  Z.fromGroup = J;
})(cg || (cg = {}));
function KG(Z, J, $) {
  let { objectId: X, instanceId: Y, groupId: Q } = Z;
  if ($ === X) {
    let { structure: W, group: K } = J, G = K.units[Y];
    if (Q === K7.Null) {
      let H = f0.ofRange(0, G.elements.length);
      return W0.Loci(W.target, [{ unit: G, indices: H }]);
    } else if (j0.isAtomic(G))
      return mx(W, G, G.polymerElements[Q]);
    else {
      let { elements: H } = G, N = G.polymerElements[Q], q = f0.indexOf(H, N);
      if (q !== -1) {
        let U = f0.ofSingleton(q);
        return W0.Loci(W, [{ unit: G, indices: U }]);
      }
    }
  }
  return G8;
}
function Hf0(Z, J, $, X, Y, Q) {
  let W = -1, K = -1;
  for (let H = Y;H <= Q; H++) {
    let N = $[H];
    if (N < 0)
      continue;
    if (W = f0.indexOf(J, N), W >= 0) {
      K = H;
      break;
    }
  }
  if (W < 0)
    return !1;
  let G = W;
  for (let H = Q;H > K; H--) {
    let N = $[H];
    if (N < 0)
      continue;
    let q = f0.indexOf(J, N);
    if (q >= 0) {
      G = q;
      break;
    }
  }
  return X(k0.ofRange(Z + W, Z + G));
}
function s60(Z, J, $, X, Y) {
  let Q = !1, { elements: W } = Y.unit, { traceElementIndex: K } = Y.unit.model.atomicHierarchy.derived.residue, { index: G } = Y.unit.model.atomicHierarchy.residueAtomSegments, H = $(Y.unit);
  if (k0.is(Y.indices))
    if (k0.start(Y.indices) === 0 && k0.end(Y.indices) === Y.unit.elements.length)
      Q = X(k0.ofBounds(Z, Z + J)) || Q;
    else {
      let N = G[W[k0.min(Y.indices)]], q = G[W[k0.max(Y.indices)]];
      Q = Hf0(Z, H, K, X, N, q) || Q;
    }
  else {
    let { indices: N } = Y;
    for (let q = 0, U = N.length;q < U; q++) {
      let F = G[W[N[q]]], E = F, R = q + 1;
      while (R < U) {
        let z = G[W[N[R]]];
        if (z - E > 1)
          break;
        E = z, R++;
      }
      q = R - 1, Q = Hf0(Z, H, K, X, F, E) || Q;
    }
  }
  return Q;
}
function FT1(Z) {
  return Z.polymerElements;
}
function GG(Z, J, $) {
  let X = !1;
  if (!W0.Loci.is(Z))
    return !1;
  let { structure: Y, group: Q } = J;
  if (!s0.areEquivalent(Z.structure, Y))
    return !1;
  let W = Q.units[0].polymerElements.length;
  for (let K of Z.elements) {
    if (!Q.unitIndexMap.has(K.unit.id))
      continue;
    let G = Q.unitIndexMap.get(K.unit.id) * W;
    if (j0.isAtomic(K.unit))
      X = s60(G, W, FT1, $, K) || X;
    else if (k0.is(K.indices)) {
      let H = G + k0.start(K.indices), N = G + k0.end(K.indices);
      X = $(k0.ofBounds(H, N)) || X;
    } else
      for (let H = 0, N = K.indices.length;H < N; H++) {
        let q = K.indices[H], U = H + 1;
        while (U < N && K.indices[U] === q)
          U++;
        H = U - 1;
        let F = K.indices[H];
        X = $(k0.ofRange(G + q, G + F)) || X;
      }
  }
  return X;
}
function qf0(Z, J, $) {
  let { objectId: X, instanceId: Y, groupId: Q } = Z;
  if ($ === X) {
    let { structure: W, group: K } = J, G = K.units[Y], H = f0.indexOf(G.elements, G.gapElements[Q]), N = f0.indexOf(G.elements, G.gapElements[Q % 2 ? Q - 1 : Q + 1]);
    if (H !== -1 && N !== -1)
      return $2.Loci(W, [
        $2.Location(W, G, H, W, G, N),
        $2.Location(W, G, N, W, G, H)
      ]);
  }
  return G8;
}
function Ff0(Z, J, $) {
  let X = !1;
  if ($2.isLoci(Z)) {
    let { structure: Y, group: Q } = J;
    if (!s0.areRootsEquivalent(Z.structure, Y))
      return !1;
    Z = $2.remapLoci(Z, Y);
    let W = Q.units[0].gapElements.length;
    for (let K of Z.bonds) {
      let G = Q.unitIndexMap.get(K.aUnit.id);
      if (G !== void 0) {
        let H = f0.indexOf(K.aUnit.gapElements, K.aUnit.elements[K.aIndex]), N = f0.indexOf(K.bUnit.gapElements, K.bUnit.elements[K.bIndex]);
        if (H !== -1 && N !== -1) {
          if ($(k0.ofSingleton(G * W + H)))
            X = !0;
        }
      }
    }
  } else if (W0.Loci.is(Z)) {
    let { structure: Y, group: Q } = J;
    if (!s0.areRootsEquivalent(Z.structure, Y))
      return !1;
    Z = W0.Loci.remap(Z, Y);
    let W = Q.units[0].gapElements.length;
    for (let K of Z.elements) {
      let G = Q.unitIndexMap.get(K.unit.id);
      if (G !== void 0)
        f0.forEach(K.indices, (H) => {
          let N = f0.indexOf(K.unit.gapElements, K.unit.elements[H]);
          if (N !== -1) {
            if ($(k0.ofSingleton(G * W + N)))
              X = !0;
            if (f0.getAt(K.unit.gapElements, N + 1) === K.unit.elements[H]) {
              if ($(k0.ofSingleton(G * W + N + 1)))
                X = !0;
            }
          }
        });
    }
  }
  return X;
}

// node_modules/molstar/lib/mol-repr/structure/visual/util/nucleotide.js
var p5;
(function(Z) {
  function J($) {
    let { group: X, structure: Y } = $, Q = X.units[0], W = j0.isAtomic(Q) ? Q.nucleotideElements : [], K = W.length, G = X.units.length, H = W0.Location.create(Y);
    return X6(K, G, 1, (q, U) => {
      let F = X.units[U];
      return H.unit = F, H.element = W[q], H;
    });
  }
  Z.fromGroup = J;
})(p5 || (p5 = {}));
function HG(Z, J, $) {
  let { objectId: X, instanceId: Y, groupId: Q } = Z;
  if ($ === X) {
    let { structure: W, group: K } = J, G = K.units[Y];
    if (j0.isAtomic(G))
      if (Q === K7.Null) {
        let H = k0.ofRange(0, G.elements.length);
        return W0.Loci(W.target, [{ unit: G, indices: H }]);
      } else
        return mx(W, G, G.nucleotideElements[Q]);
  }
  return G8;
}
function UT1(Z) {
  return Z.nucleotideElements;
}
function NG(Z, J, $) {
  let X = !1;
  if (!W0.Loci.is(Z))
    return !1;
  let { structure: Y, group: Q } = J;
  if (!s0.areEquivalent(Z.structure, Y))
    return !1;
  let W = Q.units[0];
  if (!j0.isAtomic(W))
    return !1;
  let { nucleotideElements: K } = W, G = K.length;
  for (let H of Z.elements) {
    if (!j0.isAtomic(H.unit))
      continue;
    if (!Q.unitIndexMap.has(H.unit.id))
      continue;
    let N = Q.unitIndexMap.get(H.unit.id) * G;
    if (j0.isAtomic(H.unit))
      X = s60(N, G, UT1, $, H) || X;
  }
  return X;
}
var LT1 = M(), RT1 = M();
function qG(Z, J) {
  let { model: $, conformation: X } = Z, { residueAtomSegments: Y, atoms: Q, index: W } = $.atomicHierarchy, { label_comp_id: K } = Q, G = K.value(Y.offsets[J]), H = eH0(G), N = ZN0(G);
  if (!H && !N) {
    let q = W.findAtomOnResidue(J, "C4"), U = W.findAtomOnResidue(J, "N9");
    if (q !== -1 && U !== -1 && M.distance(X.invariantPosition(q, LT1), X.invariantPosition(U, RT1)) < 1.6)
      H = !0;
    else
      N = !0;
  }
  return { isPurine: H, isPyrimidine: N };
}
function FG() {
  return {
    trace: -1,
    N1: -1,
    C2: -1,
    N3: -1,
    C4: -1,
    C5: -1,
    C6: -1,
    N7: -1,
    C8: -1,
    N9: -1,
    C1_1: -1,
    C2_1: -1,
    C3_1: -1,
    C4_1: -1,
    O4_1: -1
  };
}
function UG(Z, J, $) {
  let X = J.model.atomicHierarchy.index, { traceElementIndex: Y } = J.model.atomicHierarchy.derived.residue;
  if (Z.trace = Y[$], Z.N1 = X.findAtomOnResidue($, "N1"), Z.C2 = X.findAtomOnResidue($, "C2"), Z.N3 = X.findAtomOnResidue($, "N3"), Z.C4 = X.findAtomOnResidue($, "C4"), Z.C5 = X.findAtomOnResidue($, "C5"), Z.C5 === -1)
    Z.C5 = X.findAtomOnResidue($, "N5");
  if (Z.C6 = X.findAtomOnResidue($, "C6"), Z.N7 = X.findAtomOnResidue($, "N7"), Z.N7 === -1)
    Z.N7 = X.findAtomOnResidue($, "C7");
  return Z.C8 = X.findAtomOnResidue($, "C8"), Z.N9 = X.findAtomOnResidue($, "N9"), Z;
}
function xq(Z) {
  return Z.trace !== -1 && Z.N1 !== -1 && Z.C2 !== -1 && Z.N3 !== -1 && Z.C4 !== -1 && Z.C5 !== -1 && Z.C6 !== -1 && Z.N7 !== -1 && Z.C8 !== -1 && Z.N9 !== -1;
}
function LG(Z, J, $) {
  let X = J.model.atomicHierarchy.index, { traceElementIndex: Y } = J.model.atomicHierarchy.derived.residue;
  if (Z.trace = Y[$], Z.N1 = X.findAtomOnResidue($, "N1"), Z.N1 === -1)
    Z.N1 = X.findAtomOnResidue($, "C1");
  return Z.C2 = X.findAtomOnResidue($, "C2"), Z.N3 = X.findAtomOnResidue($, "N3"), Z.C4 = X.findAtomOnResidue($, "C4"), Z.C5 = X.findAtomOnResidue($, "C5"), Z.C6 = X.findAtomOnResidue($, "C6"), Z;
}
function yq(Z) {
  return Z.trace !== -1 && Z.N1 !== -1 && Z.C2 !== -1 && Z.N3 !== -1 && Z.C4 !== -1 && Z.C5 !== -1 && Z.C6 !== -1;
}
function fE(Z, J, $) {
  let X = J.model.atomicHierarchy.index, { traceElementIndex: Y } = J.model.atomicHierarchy.derived.residue;
  return Z.trace = Y[$], Z.C1_1 = X.findAtomOnResidue($, "C1'"), Z.C2_1 = X.findAtomOnResidue($, "C2'"), Z.C3_1 = X.findAtomOnResidue($, "C3'"), Z.C4_1 = X.findAtomOnResidue($, "C4'"), Z.O4_1 = X.findAtomOnResidue($, "O4'"), Z;
}
function hE(Z) {
  return Z.trace !== -1 && Z.C1_1 !== -1 && Z.C2_1 !== -1 && Z.C3_1 !== -1 && Z.C4_1 !== -1 && Z.O4_1 !== -1;
}

// node_modules/molstar/lib/mol-repr/structure/visual/nucleotide-block-mesh.js
var ng = M(), a60 = M(), Uf0 = M(), Lf0 = M(), Rf0 = M(), Ef0 = M(), ig = M(), r60 = M(), t60 = M(), Of0 = M(), jP = e.identity(), ET1 = M(), zf0 = zA(), Df0 = {
  sizeFactor: j.Numeric(0.2, { min: 0, max: 10, step: 0.01 }),
  thicknessFactor: j.Numeric(1, { min: 0, max: 2, step: 0.01 }),
  radialSegments: j.Numeric(16, { min: 2, max: 56, step: 2 }, q1.CustomQualityParamInfo)
}, Rf8 = j.getDefaultValues(Df0);
function OT1(Z, J, $, X, Y, Q) {
  if (!j0.isAtomic(J))
    return n1.createEmpty(Q);
  let W = J.nucleotideElements.length;
  if (!W)
    return n1.createEmpty(Q);
  let { sizeFactor: K, thicknessFactor: G, radialSegments: H } = Y, N = W * (zf0.vertices.length / 3 + H * 2), q = v1.createState(N, N / 4, Q), { elements: U, model: F, conformation: E } = J, { chainAtomSegments: R, residueAtomSegments: z } = F.atomicHierarchy, { moleculeType: D } = F.atomicHierarchy.derived.residue, A = b2.transientSegments(R, U), B = b2.transientSegments(z, U), T = 1 * K, w = 4.5, V = G * K * 2, P = { radiusTop: T, radiusBottom: T, radialSegments: H, bottomCap: !0 }, I = 0;
  while (A.hasNext) {
    B.setSegment(A.move());
    while (B.hasNext) {
      let { index: v } = B.move();
      if (XJ(D[v])) {
        let h = FG(), x = -1, b = -1, g = -1, m = -1, i = -1, r = 4.5, { isPurine: Y0, isPyrimidine: c } = qG(J, v);
        if (Y0)
          r = 4.5, UG(h, J, v), x = h.N1, b = h.C4, g = h.C6, m = h.C2, i = h.N9;
        else if (c)
          r = 3, LG(h, J, v), x = h.N3, b = h.C6, g = h.C4, m = h.C2, i = h.N1;
        if (i !== -1 && h.trace !== -1) {
          if (E.invariantPosition(i, Rf0), E.invariantPosition(h.trace, Ef0), q.currentGroup = I, q6(q, Rf0, Ef0, 1, P), x !== -1 && b !== -1 && g !== -1 && m !== -1)
            E.invariantPosition(x, ng), E.invariantPosition(b, a60), E.invariantPosition(g, Uf0), E.invariantPosition(m, Lf0), M.normalize(ig, M.sub(ig, a60, ng)), M.normalize(r60, M.sub(r60, Lf0, Uf0)), M.normalize(t60, M.cross(t60, ig, r60)), e.targetTo(jP, ng, a60, t60), M.scaleAndAdd(Of0, ng, ig, r / 2 - 0.2), e.scale(jP, jP, M.set(ET1, w, V, r)), e.setTranslation(jP, Of0), v1.addPrimitive(q, jP, zf0);
        }
        ++I;
      }
    }
  }
  let S = v1.getMesh(q), f = C0.expand(C0(), J.boundary.sphere, T);
  return S.setBoundingSphere(f), S;
}
var e60 = {
  ...nZ,
  ...Df0
};
function Mf0(Z) {
  return A9({
    defaultProps: j.getDefaultValues(e60),
    createGeometry: OT1,
    createLocationIterator: p5.fromGroup,
    getLoci: HG,
    eachLocation: NG,
    setUpdateState: (J, $, X) => {
      J.createGeometry = $.sizeFactor !== X.sizeFactor || $.thicknessFactor !== X.thicknessFactor || $.radialSegments !== X.radialSegments;
    }
  }, Z);
}

// node_modules/molstar/lib/mol-repr/structure/visual/nucleotide-ring-mesh.js
var og = M(), bE = M(), sg = M(), ag = M(), Hw = M(), Nw = M(), rg = M(), Af0 = M(), Bf0 = M(), tg = M(), xE = M(), Tf0 = {
  sizeFactor: j.Numeric(0.2, { min: 0, max: 10, step: 0.01 }),
  thicknessFactor: j.Numeric(1, { min: 0, max: 2, step: 0.01 }),
  radialSegments: j.Numeric(16, { min: 2, max: 56, step: 2 }, q1.CustomQualityParamInfo),
  detail: j.Numeric(0, { min: 0, max: 3, step: 1 }, q1.CustomQualityParamInfo)
}, Cf8 = j.getDefaultValues(Tf0), eg = new Float32Array(54), zT1 = new Uint32Array([0, 1, 2, 3, 4, 5, 6, 7, 16, 17, 14, 15, 12, 13, 8, 9, 10, 11, 0, 1]), DT1 = new Uint32Array([8, 12, 14, 16, 6, 4, 2, 0, 10]), MT1 = new Uint32Array([9, 11, 1, 3, 5, 7, 17, 15, 13]), Zm = new Float32Array(36), AT1 = new Uint32Array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 0, 1]), BT1 = new Uint32Array([0, 10, 8, 6, 4, 2]), wT1 = new Uint32Array([1, 3, 5, 7, 9, 11]), wf0 = M();
function jf0(Z, J, ...$) {
  for (let X = 0, Y = $.length;X < Y; ++X) {
    let Q = $[X];
    M.toArray(M.add(wf0, Q, J), Z, X * 2 * 3), M.toArray(M.sub(wf0, Q, J), Z, (X * 2 + 1) * 3);
  }
}
function jT1(Z, J, $, X, Y, Q) {
  if (!j0.isAtomic(J))
    return n1.createEmpty(Q);
  let W = J.nucleotideElements.length;
  if (!W)
    return n1.createEmpty(Q);
  let { sizeFactor: K, thicknessFactor: G, radialSegments: H, detail: N } = Y, q = W * (26 + H * 2), U = v1.createState(q, q / 4, Q), { elements: F, model: E, conformation: R } = J, { chainAtomSegments: z, residueAtomSegments: D } = E.atomicHierarchy, { moleculeType: A } = E.atomicHierarchy.derived.residue, B = b2.transientSegments(z, F), T = b2.transientSegments(D, F), w = 1 * K, V = G * K, P = { radiusTop: w, radiusBottom: w, radialSegments: H }, I = 0;
  while (B.hasNext) {
    T.setSegment(B.move());
    while (T.hasNext) {
      let { index: v } = T.move();
      if (XJ(A[v])) {
        let h = FG();
        U.currentGroup = I;
        let { isPurine: x, isPyrimidine: b } = qG(J, v);
        if (x) {
          if (UG(h, J, v), h.N9 !== -1 && h.trace !== -1)
            R.invariantPosition(h.N9, tg), R.invariantPosition(h.trace, og), U.currentGroup = I, q6(U, tg, og, 1, P), g8(U, tg, w, N);
          if (xq(h))
            R.invariantPosition(h.N1, bE), R.invariantPosition(h.C2, sg), R.invariantPosition(h.N3, ag), R.invariantPosition(h.C4, Hw), R.invariantPosition(h.C5, Nw), R.invariantPosition(h.C6, rg), R.invariantPosition(h.N7, Af0), R.invariantPosition(h.C8, Bf0), M.triangleNormal(xE, bE, Hw, Nw), M.scale(xE, xE, V), jf0(eg, xE, bE, sg, ag, Hw, Nw, rg, Af0, Bf0, tg), v1.addTriangleStrip(U, eg, zT1), v1.addTriangleFan(U, eg, DT1), v1.addTriangleFan(U, eg, MT1);
        } else if (b) {
          if (LG(h, J, v), h.N1 !== -1 && h.trace !== -1)
            R.invariantPosition(h.N1, bE), R.invariantPosition(h.trace, og), U.currentGroup = I, q6(U, bE, og, 1, P), g8(U, bE, w, N);
          if (yq(h))
            R.invariantPosition(h.C2, sg), R.invariantPosition(h.N3, ag), R.invariantPosition(h.C4, Hw), R.invariantPosition(h.C5, Nw), R.invariantPosition(h.C6, rg), M.triangleNormal(xE, bE, Hw, Nw), M.scale(xE, xE, V), jf0(Zm, xE, bE, sg, ag, Hw, Nw, rg), v1.addTriangleStrip(U, Zm, AT1), v1.addTriangleFan(U, Zm, BT1), v1.addTriangleFan(U, Zm, wT1);
        }
        ++I;
      }
    }
  }
  let S = v1.getMesh(U), f = C0.expand(C0(), J.boundary.sphere, w);
  return S.setBoundingSphere(f), S;
}
var ZZ0 = {
  ...nZ,
  ...Tf0
};
function _f0(Z) {
  return A9({
    defaultProps: j.getDefaultValues(ZZ0),
    createGeometry: jT1,
    createLocationIterator: p5.fromGroup,
    getLoci: HG,
    eachLocation: NG,
    setUpdateState: (J, $, X) => {
      J.createGeometry = $.sizeFactor !== X.sizeFactor || $.thicknessFactor !== X.thicknessFactor || $.radialSegments !== X.radialSegments;
    }
  }, Z);
}

// node_modules/molstar/lib/mol-repr/structure/visual/nucleotide-atomic-ring-fill.js
var qw = M(), Jm = M(), $m = M(), Fw = M(), Uw = M(), Xm = M(), Vf0 = M(), If0 = M(), Pf0 = M(), Ym = M(), JZ0 = M(), Qm = M(), Wm = M(), $Z0 = M(), Lw = M(), yY = M(), Rw = M(), kf0 = {
  sizeFactor: j.Numeric(0.2, { min: 0, max: 10, step: 0.01 }),
  thicknessFactor: j.Numeric(1, { min: 0, max: 2, step: 0.01 })
}, pf8 = j.getDefaultValues(kf0), Km = new Float32Array(54), TT1 = new Uint32Array([0, 1, 2, 3, 4, 5, 6, 7, 16, 17, 14, 15, 12, 13, 8, 9, 10, 11, 0, 1]), _T1 = new Uint32Array([8, 12, 14, 16, 6, 4, 2, 0, 10]), VT1 = new Uint32Array([9, 11, 1, 3, 5, 7, 17, 15, 13]), Gm = new Float32Array(36), IT1 = new Uint32Array([2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 2, 3]), PT1 = new Uint32Array([0, 10, 8, 6, 4, 2, 10]), CT1 = new Uint32Array([1, 3, 5, 7, 9, 11, 3]), Hm = new Float32Array(36), kT1 = new Uint32Array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 0, 1]), vT1 = new Uint32Array([0, 10, 8, 6, 4, 2]), ST1 = new Uint32Array([1, 3, 5, 7, 9, 11]), Cf0 = M();
function XZ0(Z, J, ...$) {
  for (let X = 0, Y = $.length;X < Y; ++X) {
    let Q = $[X];
    M.toArray(M.add(Cf0, Q, J), Z, X * 2 * 3), M.toArray(M.sub(Cf0, Q, J), Z, (X * 2 + 1) * 3);
  }
}
function fT1(Z, J, $, X, Y, Q) {
  if (!j0.isAtomic(J))
    return n1.createEmpty(Q);
  let W = J.nucleotideElements.length;
  if (!W)
    return n1.createEmpty(Q);
  let { sizeFactor: K, thicknessFactor: G } = Y, H = W * 25, N = v1.createState(H, H / 4, Q), { elements: q, model: U, conformation: F } = J, { chainAtomSegments: E, residueAtomSegments: R } = U.atomicHierarchy, { moleculeType: z } = U.atomicHierarchy.derived.residue, D = b2.transientSegments(E, q), A = b2.transientSegments(R, q), B = K * G, T = 0;
  while (D.hasNext) {
    A.setSegment(D.move());
    while (A.hasNext) {
      let { index: P } = A.move();
      if (XJ(z[P])) {
        let I = FG();
        if (N.currentGroup = T, fE(I, J, P), hE(I))
          F.invariantPosition(I.C1_1, Ym), F.invariantPosition(I.C2_1, JZ0), F.invariantPosition(I.C3_1, Qm), F.invariantPosition(I.C4_1, Wm), F.invariantPosition(I.O4_1, $Z0), M.triangleNormal(yY, Qm, Wm, Ym), M.scale(Lw, M.add(Lw, $Z0, M.add(Lw, Wm, M.add(Lw, Qm, M.add(Lw, Ym, JZ0)))), 0.2), M.scale(Rw, yY, B), XZ0(Gm, Rw, Lw, Qm, Wm, $Z0, Ym, JZ0), v1.addTriangleStrip(N, Gm, IT1), v1.addTriangleFanWithNormal(N, Gm, PT1, yY), M.negate(yY, yY), v1.addTriangleFanWithNormal(N, Gm, CT1, yY);
        let { isPurine: S, isPyrimidine: f } = qG(J, P);
        if (S) {
          if (UG(I, J, P), xq(I))
            F.invariantPosition(I.N1, qw), F.invariantPosition(I.C2, Jm), F.invariantPosition(I.N3, $m), F.invariantPosition(I.C4, Fw), F.invariantPosition(I.C5, Uw), F.invariantPosition(I.C6, Xm), F.invariantPosition(I.N7, Vf0), F.invariantPosition(I.C8, If0), F.invariantPosition(I.N9, Pf0), M.triangleNormal(yY, qw, Fw, Uw), M.scale(Rw, yY, B), XZ0(Km, Rw, qw, Jm, $m, Fw, Uw, Xm, Vf0, If0, Pf0), v1.addTriangleStrip(N, Km, TT1), v1.addTriangleFanWithNormal(N, Km, _T1, yY), M.negate(yY, yY), v1.addTriangleFanWithNormal(N, Km, VT1, yY);
        } else if (f) {
          if (LG(I, J, P), yq(I))
            F.invariantPosition(I.N1, qw), F.invariantPosition(I.C2, Jm), F.invariantPosition(I.N3, $m), F.invariantPosition(I.C4, Fw), F.invariantPosition(I.C5, Uw), F.invariantPosition(I.C6, Xm), M.triangleNormal(yY, qw, Fw, Uw), M.scale(Rw, yY, B), XZ0(Hm, Rw, qw, Jm, $m, Fw, Uw, Xm), v1.addTriangleStrip(N, Hm, kT1), v1.addTriangleFanWithNormal(N, Hm, vT1, yY), M.negate(yY, yY), v1.addTriangleFanWithNormal(N, Hm, ST1, yY);
        }
        ++T;
      }
    }
  }
  let w = v1.getMesh(N), V = C0.expand(C0(), J.boundary.sphere, B);
  return w.setBoundingSphere(V), w;
}
var YZ0 = {
  ...nZ,
  ...kf0
};
function vf0(Z) {
  return A9({
    defaultProps: j.getDefaultValues(YZ0),
    createGeometry: fT1,
    createLocationIterator: p5.fromGroup,
    getLoci: HG,
    eachLocation: NG,
    setUpdateState: (J, $, X) => {
      J.createGeometry = $.sizeFactor !== X.sizeFactor || $.thicknessFactor !== X.thicknessFactor;
    }
  }, Z);
}

// node_modules/molstar/lib/mol-repr/structure/visual/nucleotide-atomic-bond.js
var gY = M(), Z7 = M(), EX = M(), OX = M(), xJ = M(), yJ = M(), zX = M(), gq = M(), mq = M(), _$ = M(), V$ = M(), dq = M(), u5 = M(), pq = M(), uq = M(), Nm = {
  ...nZ,
  ...UB,
  sizeFactor: j.Numeric(0.3, { min: 0, max: 10, step: 0.01 }),
  radialSegments: j.Numeric(16, { min: 2, max: 56, step: 2 }, q1.CustomQualityParamInfo),
  tryUseImpostor: j.Boolean(!0)
};
function Sf0(Z, J, $, X) {
  return $.tryUseImpostor && YE(X) ? bT1(Z) : yT1(Z);
}
function hT1(Z, J, $, X, Y, Q) {
  if (!j0.isAtomic(J))
    return T7.createEmpty(Q);
  let W = J.nucleotideElements.length;
  if (!W)
    return T7.createEmpty(Q);
  let K = W * 15, G = HE.create(K, K / 4, Q), { elements: H, model: N, conformation: q } = J, { chainAtomSegments: U, residueAtomSegments: F } = N.atomicHierarchy, { moleculeType: E } = N.atomicHierarchy.derived.residue, R = b2.transientSegments(U, H), z = b2.transientSegments(F, H), D = 0, A = 2;
  while (R.hasNext) {
    z.setSegment(R.move());
    while (z.hasNext) {
      let { index: w } = z.move();
      if (XJ(E[w])) {
        let V = FG();
        if (fE(V, J, w), hE(V))
          q.invariantPosition(V.C1_1, V$), q.invariantPosition(V.C2_1, dq), q.invariantPosition(V.C3_1, u5), q.invariantPosition(V.C4_1, pq), q.invariantPosition(V.O4_1, uq), q.invariantPosition(V.trace, gY), G.add(u5[0], u5[1], u5[2], gY[0], gY[1], gY[2], 1, !0, !0, A, D), G.add(u5[0], u5[1], u5[2], pq[0], pq[1], pq[2], 1, !0, !0, A, D), G.add(pq[0], pq[1], pq[2], uq[0], uq[1], uq[2], 1, !0, !0, A, D), G.add(uq[0], uq[1], uq[2], V$[0], V$[1], V$[2], 1, !0, !0, A, D), G.add(V$[0], V$[1], V$[2], dq[0], dq[1], dq[2], 1, !0, !0, A, D), G.add(dq[0], dq[1], dq[2], u5[0], u5[1], u5[2], 1, !0, !0, A, D);
        let { isPurine: P, isPyrimidine: I } = qG(J, w);
        if (P) {
          if (UG(V, J, w), V.C1_1 !== -1 && V.N9 !== -1)
            q.invariantPosition(V.C1_1, V$), q.invariantPosition(V.N9, _$), G.add(_$[0], _$[1], _$[2], V$[0], V$[1], V$[2], 1, !0, !0, A, D);
          else if (V.N9 !== -1 && V.trace !== -1)
            q.invariantPosition(V.N9, _$), q.invariantPosition(V.trace, gY), G.add(_$[0], _$[1], _$[2], gY[0], gY[1], gY[2], 1, !0, !0, A, D);
          if (xq(V))
            q.invariantPosition(V.N1, Z7), q.invariantPosition(V.C2, EX), q.invariantPosition(V.N3, OX), q.invariantPosition(V.C4, xJ), q.invariantPosition(V.C5, yJ), q.invariantPosition(V.C6, zX), q.invariantPosition(V.N7, gq), q.invariantPosition(V.C8, mq), q.invariantPosition(V.N9, _$), G.add(_$[0], _$[1], _$[2], mq[0], mq[1], mq[2], 1, !0, !0, A, D), G.add(mq[0], mq[1], mq[2], gq[0], gq[1], gq[2], 1, !0, !0, A, D), G.add(gq[0], gq[1], gq[2], yJ[0], yJ[1], yJ[2], 1, !0, !0, A, D), G.add(yJ[0], yJ[1], yJ[2], zX[0], zX[1], zX[2], 1, !0, !0, A, D), G.add(zX[0], zX[1], zX[2], Z7[0], Z7[1], Z7[2], 1, !0, !0, A, D), G.add(Z7[0], Z7[1], Z7[2], EX[0], EX[1], EX[2], 1, !0, !0, A, D), G.add(EX[0], EX[1], EX[2], OX[0], OX[1], OX[2], 1, !0, !0, A, D), G.add(OX[0], OX[1], OX[2], xJ[0], xJ[1], xJ[2], 1, !0, !0, A, D), G.add(xJ[0], xJ[1], xJ[2], yJ[0], yJ[1], yJ[2], 1, !0, !0, A, D), G.add(xJ[0], xJ[1], xJ[2], _$[0], _$[1], _$[2], 1, !0, !0, A, D);
        } else if (I) {
          if (LG(V, J, w), V.C1_1 !== -1 && V.N1 !== -1)
            q.invariantPosition(V.N1, Z7), q.invariantPosition(V.C1_1, V$), G.add(Z7[0], Z7[1], Z7[2], V$[0], V$[1], V$[2], 1, !0, !0, A, D);
          else if (V.N1 !== -1 && V.trace !== -1)
            q.invariantPosition(V.N1, Z7), q.invariantPosition(V.trace, gY), G.add(Z7[0], Z7[1], Z7[2], gY[0], gY[1], gY[2], 1, !0, !0, A, D);
          if (yq(V))
            q.invariantPosition(V.N1, Z7), q.invariantPosition(V.C2, EX), q.invariantPosition(V.N3, OX), q.invariantPosition(V.C4, xJ), q.invariantPosition(V.C5, yJ), q.invariantPosition(V.C6, zX), G.add(Z7[0], Z7[1], Z7[2], zX[0], zX[1], zX[2], 1, !0, !0, A, D), G.add(zX[0], zX[1], zX[2], yJ[0], yJ[1], yJ[2], 1, !0, !0, A, D), G.add(yJ[0], yJ[1], yJ[2], xJ[0], xJ[1], xJ[2], 1, !0, !0, A, D), G.add(xJ[0], xJ[1], xJ[2], OX[0], OX[1], OX[2], 1, !0, !0, A, D), G.add(OX[0], OX[1], OX[2], EX[0], EX[1], EX[2], 1, !0, !0, A, D), G.add(EX[0], EX[1], EX[2], Z7[0], Z7[1], Z7[2], 1, !0, !0, A, D);
        }
        ++D;
      }
    }
  }
  let B = G.getCylinders(), T = C0.expand(C0(), J.boundary.sphere, 1 * Y.sizeFactor);
  return B.setBoundingSphere(T), B;
}
function bT1(Z) {
  return LB({
    defaultProps: j.getDefaultValues(Nm),
    createGeometry: hT1,
    createLocationIterator: p5.fromGroup,
    getLoci: HG,
    eachLocation: NG,
    setUpdateState: (J, $, X) => {
      J.createGeometry = $.sizeFactor !== X.sizeFactor;
    },
    mustRecreate: (J, $, X) => {
      return !$.tryUseImpostor || !X;
    }
  }, Z);
}
function xT1(Z, J, $, X, Y, Q) {
  if (!j0.isAtomic(J))
    return n1.createEmpty(Q);
  let W = J.nucleotideElements.length;
  if (!W)
    return n1.createEmpty(Q);
  let { sizeFactor: K, radialSegments: G } = Y, H = W * (G * 15), N = v1.createState(H, H / 4, Q), { elements: q, model: U, conformation: F } = J, { chainAtomSegments: E, residueAtomSegments: R } = U.atomicHierarchy, { moleculeType: z } = U.atomicHierarchy.derived.residue, D = b2.transientSegments(E, q), A = b2.transientSegments(R, q), B = { radiusTop: 1 * K, radiusBottom: 1 * K, radialSegments: G }, T = 0;
  while (D.hasNext) {
    A.setSegment(D.move());
    while (A.hasNext) {
      let { index: P } = A.move();
      if (XJ(z[P])) {
        let I = FG();
        if (N.currentGroup = T, fE(I, J, P), hE(I))
          F.invariantPosition(I.C1_1, V$), F.invariantPosition(I.C2_1, dq), F.invariantPosition(I.C3_1, u5), F.invariantPosition(I.C4_1, pq), F.invariantPosition(I.O4_1, uq), F.invariantPosition(I.trace, gY), q6(N, u5, gY, 1, B), q6(N, u5, pq, 1, B), q6(N, pq, uq, 1, B), q6(N, uq, V$, 1, B), q6(N, V$, dq, 1, B), q6(N, dq, u5, 1, B);
        let { isPurine: S, isPyrimidine: f } = qG(J, P);
        if (S) {
          if (UG(I, J, P), I.C1_1 !== -1 && I.N9 !== -1)
            F.invariantPosition(I.C1_1, V$), F.invariantPosition(I.N9, _$), q6(N, _$, V$, 1, B);
          else if (I.N9 !== -1 && I.trace !== -1)
            F.invariantPosition(I.N9, _$), F.invariantPosition(I.trace, gY), q6(N, _$, gY, 1, B);
          if (xq(I))
            F.invariantPosition(I.N1, Z7), F.invariantPosition(I.C2, EX), F.invariantPosition(I.N3, OX), F.invariantPosition(I.C4, xJ), F.invariantPosition(I.C5, yJ), F.invariantPosition(I.C6, zX), F.invariantPosition(I.N7, gq), F.invariantPosition(I.C8, mq), F.invariantPosition(I.N9, _$), q6(N, _$, mq, 1, B), q6(N, mq, gq, 1, B), q6(N, gq, yJ, 1, B), q6(N, yJ, zX, 1, B), q6(N, zX, Z7, 1, B), q6(N, Z7, EX, 1, B), q6(N, EX, OX, 1, B), q6(N, OX, xJ, 1, B), q6(N, xJ, yJ, 1, B), q6(N, xJ, _$, 1, B);
        } else if (f) {
          if (LG(I, J, P), I.C1_1 !== -1 && I.N1 !== -1)
            F.invariantPosition(I.N1, Z7), F.invariantPosition(I.C1_1, V$), q6(N, Z7, V$, 1, B);
          else if (I.N1 !== -1 && I.trace !== -1)
            F.invariantPosition(I.N1, Z7), F.invariantPosition(I.trace, gY), q6(N, Z7, gY, 1, B);
          if (yq(I))
            F.invariantPosition(I.N1, Z7), F.invariantPosition(I.C2, EX), F.invariantPosition(I.N3, OX), F.invariantPosition(I.C4, xJ), F.invariantPosition(I.C5, yJ), F.invariantPosition(I.C6, zX), q6(N, Z7, zX, 1, B), q6(N, zX, yJ, 1, B), q6(N, yJ, xJ, 1, B), q6(N, xJ, OX, 1, B), q6(N, OX, EX, 1, B), q6(N, EX, Z7, 1, B);
        }
        ++T;
      }
    }
  }
  let w = v1.getMesh(N), V = C0.expand(C0(), J.boundary.sphere, 1 * Y.sizeFactor);
  return w.setBoundingSphere(V), w;
}
function yT1(Z) {
  return A9({
    defaultProps: j.getDefaultValues(Nm),
    createGeometry: xT1,
    createLocationIterator: p5.fromGroup,
    getLoci: HG,
    eachLocation: NG,
    setUpdateState: (J, $, X) => {
      J.createGeometry = $.sizeFactor !== X.sizeFactor || $.radialSegments !== X.radialSegments;
    },
    mustRecreate: (J, $, X) => {
      return $.tryUseImpostor && !!X;
    }
  }, Z);
}

// node_modules/molstar/lib/mol-repr/structure/visual/nucleotide-atomic-element.js
var Ew = M(), RG = M(), EG = M(), OG = M(), zG = M(), dK = M(), DG = M(), Ow = M(), zw = M(), Dw = M(), Mw = M(), Aw = M(), Bw = M(), ww = M(), jw = M(), qm = {
  ...nZ,
  ...qB,
  sizeFactor: j.Numeric(0.3, { min: 0, max: 10, step: 0.01 }),
  detail: j.Numeric(0, { min: 0, max: 3, step: 1 }, q1.CustomQualityParamInfo),
  tryUseImpostor: j.Boolean(!0)
};
function ff0(Z, J, $, X) {
  return $.tryUseImpostor && WB(X) ? mT1(Z) : pT1(Z);
}
function gT1(Z, J, $, X, Y, Q) {
  if (!j0.isAtomic(J))
    return R$.createEmpty(Q);
  let W = J.nucleotideElements.length;
  if (!W)
    return R$.createEmpty(Q);
  let K = W * 15, G = wH.create(K, K / 4, Q), { elements: H, model: N, conformation: q } = J, { chainAtomSegments: U, residueAtomSegments: F } = N.atomicHierarchy, { moleculeType: E } = N.atomicHierarchy.derived.residue, R = b2.transientSegments(U, H), z = b2.transientSegments(F, H), D = 0;
  while (R.hasNext) {
    z.setSegment(R.move());
    while (z.hasNext) {
      let { index: T } = z.move();
      if (XJ(E[T])) {
        let w = FG();
        if (fE(w, J, T), hE(w))
          q.invariantPosition(w.C1_1, Mw), q.invariantPosition(w.C2_1, Aw), q.invariantPosition(w.C3_1, Bw), q.invariantPosition(w.C4_1, ww), q.invariantPosition(w.O4_1, jw), q.invariantPosition(w.trace, Ew), G.add(Ew[0], Ew[1], Ew[2], D), G.add(Bw[0], Bw[1], Bw[2], D), G.add(ww[0], ww[1], ww[2], D), G.add(jw[0], jw[1], jw[2], D), G.add(Mw[0], Mw[1], Mw[2], D), G.add(Aw[0], Aw[1], Aw[2], D);
        let { isPurine: V, isPyrimidine: P } = qG(J, T);
        if (V) {
          if (UG(w, J, T), xq(w))
            q.invariantPosition(w.N1, RG), q.invariantPosition(w.C2, EG), q.invariantPosition(w.N3, OG), q.invariantPosition(w.C4, zG), q.invariantPosition(w.C5, dK), q.invariantPosition(w.C6, DG), q.invariantPosition(w.N7, Ow), q.invariantPosition(w.C8, zw), q.invariantPosition(w.N9, Dw), G.add(Dw[0], Dw[1], Dw[2], D), G.add(zw[0], zw[1], zw[2], D), G.add(Ow[0], Ow[1], Ow[2], D), G.add(dK[0], dK[1], dK[2], D), G.add(DG[0], DG[1], DG[2], D), G.add(RG[0], RG[1], RG[2], D), G.add(EG[0], EG[1], EG[2], D), G.add(OG[0], OG[1], OG[2], D), G.add(zG[0], zG[1], zG[2], D);
        } else if (P) {
          if (LG(w, J, T), yq(w))
            q.invariantPosition(w.N1, RG), q.invariantPosition(w.C2, EG), q.invariantPosition(w.N3, OG), q.invariantPosition(w.C4, zG), q.invariantPosition(w.C5, dK), q.invariantPosition(w.C6, DG), G.add(RG[0], RG[1], RG[2], D), G.add(DG[0], DG[1], DG[2], D), G.add(dK[0], dK[1], dK[2], D), G.add(zG[0], zG[1], zG[2], D), G.add(OG[0], OG[1], OG[2], D), G.add(EG[0], EG[1], EG[2], D);
        }
        ++D;
      }
    }
  }
  let A = G.getSpheres(), B = C0.expand(C0(), J.boundary.sphere, 1 * Y.sizeFactor);
  return A.setBoundingSphere(B), A;
}
function mT1(Z) {
  return FB({
    defaultProps: j.getDefaultValues(qm),
    createGeometry: gT1,
    createLocationIterator: p5.fromGroup,
    getLoci: HG,
    eachLocation: NG,
    setUpdateState: (J, $, X) => {
      J.createGeometry = $.sizeFactor !== X.sizeFactor;
    },
    mustRecreate: (J, $, X) => {
      return !$.tryUseImpostor || !X;
    }
  }, Z);
}
function dT1(Z, J, $, X, Y, Q) {
  if (!j0.isAtomic(J))
    return n1.createEmpty(Q);
  let W = J.nucleotideElements.length;
  if (!W)
    return n1.createEmpty(Q);
  let { sizeFactor: K, detail: G } = Y, H = W * _5(G), N = v1.createState(H, H / 2, Q), { elements: q, model: U, conformation: F } = J, { chainAtomSegments: E, residueAtomSegments: R } = U.atomicHierarchy, { moleculeType: z } = U.atomicHierarchy.derived.residue, D = b2.transientSegments(E, q), A = b2.transientSegments(R, q), B = 1 * K, T = 0;
  while (D.hasNext) {
    A.setSegment(D.move());
    while (A.hasNext) {
      let { index: P } = A.move();
      if (XJ(z[P])) {
        let I = FG();
        if (N.currentGroup = T, fE(I, J, P), hE(I))
          F.invariantPosition(I.C1_1, Mw), F.invariantPosition(I.C2_1, Aw), F.invariantPosition(I.C3_1, Bw), F.invariantPosition(I.C4_1, ww), F.invariantPosition(I.O4_1, jw), F.invariantPosition(I.trace, Ew), g8(N, Ew, B, G), g8(N, ww, B, G), g8(N, jw, B, G), g8(N, Mw, B, G), g8(N, Aw, B, G), g8(N, Bw, B, G);
        let { isPurine: S, isPyrimidine: f } = qG(J, P);
        if (S) {
          if (UG(I, J, P), xq(I))
            F.invariantPosition(I.N1, RG), F.invariantPosition(I.C2, EG), F.invariantPosition(I.N3, OG), F.invariantPosition(I.C4, zG), F.invariantPosition(I.C5, dK), F.invariantPosition(I.C6, DG), F.invariantPosition(I.N7, Ow), F.invariantPosition(I.C8, zw), F.invariantPosition(I.N9, Dw), g8(N, zw, B, G), g8(N, Ow, B, G), g8(N, dK, B, G), g8(N, DG, B, G), g8(N, RG, B, G), g8(N, EG, B, G), g8(N, OG, B, G), g8(N, zG, B, G), g8(N, dK, B, G), g8(N, Dw, B, G);
        } else if (f) {
          if (LG(I, J, P), yq(I))
            F.invariantPosition(I.N1, RG), F.invariantPosition(I.C2, EG), F.invariantPosition(I.N3, OG), F.invariantPosition(I.C4, zG), F.invariantPosition(I.C5, dK), F.invariantPosition(I.C6, DG), g8(N, DG, B, G), g8(N, dK, B, G), g8(N, zG, B, G), g8(N, OG, B, G), g8(N, EG, B, G), g8(N, RG, B, G);
        }
        ++T;
      }
    }
  }
  let w = v1.getMesh(N), V = C0.expand(C0(), J.boundary.sphere, 1 * Y.sizeFactor);
  return w.setBoundingSphere(V), w;
}
function pT1(Z) {
  return A9({
    defaultProps: j.getDefaultValues(qm),
    createGeometry: dT1,
    createLocationIterator: p5.fromGroup,
    getLoci: HG,
    eachLocation: NG,
    setUpdateState: (J, $, X) => {
      J.createGeometry = $.sizeFactor !== X.sizeFactor || $.detail !== X.detail;
    },
    mustRecreate: (J, $, X) => {
      return $.tryUseImpostor && !!X;
    }
  }, Z);
}

// node_modules/molstar/lib/mol-geo/primitive/wedge.js
var T4 = M.zero(), Tw = M.zero(), _4 = M.zero(), hf0 = M.zero(), DX = hW(3, !1);
function uT1() {
  let Z = RH(8);
  for (let J = 0;J < 3; ++J) {
    let $ = (J + 1) % 3;
    M.set(T4, DX[J * 3], DX[J * 3 + 1], -0.5), M.set(Tw, DX[$ * 3], DX[$ * 3 + 1], -0.5), M.set(_4, DX[$ * 3], DX[$ * 3 + 1], 0.5), M.set(hf0, DX[J * 3], DX[J * 3 + 1], 0.5), Z.add(T4, Tw, _4), Z.add(_4, hf0, T4);
  }
  return M.set(T4, DX[0], DX[1], -0.5), M.set(Tw, DX[3], DX[4], -0.5), M.set(_4, DX[6], DX[7], -0.5), Z.add(_4, Tw, T4), M.set(T4, DX[0], DX[1], 0.5), M.set(Tw, DX[3], DX[4], 0.5), M.set(_4, DX[6], DX[7], 0.5), Z.add(T4, Tw, _4), Z.getPrimitive();
}
var QZ0;
function bf0() {
  if (!QZ0)
    QZ0 = uT1();
  return QZ0;
}

// node_modules/molstar/lib/mol-repr/structure/visual/polymer-direction-wedge.js
var V4 = e.identity(), cT1 = M.zero(), xf0 = M.zero(), yf0 = M.zero(), WZ0 = M.zero(), lT1 = 4, nT1 = 4, iT1 = 6, oT1 = bf0(), gf0 = {
  sizeFactor: j.Numeric(0.2, { min: 0, max: 10, step: 0.01 })
}, yh8 = j.getDefaultValues(gf0);
function sT1(Z, J, $, X, Y, Q) {
  let W = J.polymerElements.length;
  if (!W)
    return n1.createEmpty(Q);
  let { sizeFactor: K } = Y, G = W * 24, H = v1.createState(G, G / 10, Q), q = Ww(1), { normalVectors: U, binormalVectors: F } = q, E = 0, R = $w(J, $);
  while (R.hasNext) {
    let A = R.move();
    H.currentGroup = E;
    let B = XJ(A.moleculeType), T = m2.is(A.secStrucType, m2.Flag.Beta);
    if (Kw(q, A, B || T ? 0.5 : 0.9, B ? 0.3 : 0.5), T && !A.secStrucLast || !T) {
      let P = X.size.size(A.center) * K, I = lT1 * P, S = nT1 * P, f = iT1 * P, v = B ? F : U;
      M.fromArray(xf0, v, 0), M.fromArray(yf0, v, 3), M.normalize(WZ0, M.add(WZ0, xf0, yf0)), e.targetTo(V4, A.p3, A.p1, WZ0), e.mul(V4, V4, e.rotY90Z180), e.scale(V4, V4, M.set(cT1, f, S, I)), e.setTranslation(V4, A.p2), v1.addPrimitive(H, V4, oT1);
    }
    ++E;
  }
  let z = v1.getMesh(H), D = C0.expand(C0(), J.boundary.sphere, 1 * Y.sizeFactor);
  return z.setBoundingSphere(D), z;
}
var KZ0 = {
  ...nZ,
  ...gf0
};
function mf0(Z) {
  return A9({
    defaultProps: j.getDefaultValues(KZ0),
    createGeometry: sT1,
    createLocationIterator: (J) => d5.fromGroup(J),
    getLoci: KG,
    eachLocation: GG,
    setUpdateState: (J, $, X) => {
      J.createGeometry = $.sizeFactor !== X.sizeFactor;
    }
  }, Z);
}

// node_modules/molstar/lib/mol-repr/structure/visual/polymer-gap-cylinder.js
var GZ0 = 10, df0 = {
  sizeFactor: j.Numeric(0.2, { min: 0, max: 10, step: 0.01 }),
  radialSegments: j.Numeric(16, { min: 2, max: 56, step: 2 }, q1.CustomQualityParamInfo)
}, sh8 = j.getDefaultValues(df0);
function aT1(Z, J, $, X, Y, Q) {
  let W = J.gapElements.length;
  if (!W)
    return n1.createEmpty(Q);
  let { sizeFactor: K, radialSegments: G } = Y, H = GZ0 * G * 2 * W * 2, N = v1.createState(H, H / 10, Q), q = M(), U = M(), F = {
    radiusTop: 1,
    radiusBottom: 1,
    topCap: !0,
    bottomCap: !0,
    radialSegments: G
  }, E = 0, R = sS0($, J);
  while (R.hasNext) {
    let { centerA: A, centerB: B } = R.move();
    if (A.element === B.element)
      ;
    else
      J.conformation.invariantPosition(A.element, q), J.conformation.invariantPosition(B.element, U), F.radiusTop = F.radiusBottom = X.size.size(A) * K, N.currentGroup = E, jz(N, q, U, 0.5, GZ0, !1, F), F.radiusTop = F.radiusBottom = X.size.size(B) * K, N.currentGroup = E + 1, jz(N, U, q, 0.5, GZ0, !1, F);
    E += 2;
  }
  let z = v1.getMesh(N), D = C0.expand(C0(), J.boundary.sphere, 1 * Y.sizeFactor);
  return z.setBoundingSphere(D), z;
}
var I4 = {
  ...nZ,
  ...df0
};
function _w(Z) {
  return A9({
    defaultProps: j.getDefaultValues(I4),
    createGeometry: aT1,
    createLocationIterator: (J) => cg.fromGroup(J, { asSecondary: !0 }),
    getLoci: qf0,
    eachLocation: Ff0,
    setUpdateState: (J, $, X) => {
      J.createGeometry = $.sizeFactor !== X.sizeFactor || $.radialSegments !== X.radialSegments;
    }
  }, Z);
}

// node_modules/molstar/lib/mol-geo/geometry/mesh/builder/sheet.js
var kZ = M(), B9 = M(), rT1 = M(), pK = M(), cq = M(), Fm = M(), Um = M(), TP = M(), uH = M(), lq = M(), HZ0 = M(), yE = M(), gE = M(), mE = M(), dE = M(), MG = M.fromArray, Vw = M.scale, AG = M.add, fU = M.sub, tT1 = M.magnitude, pf0 = M.negate, NZ0 = M.copy, uf0 = M.cross, eT1 = M.set, h9 = B1.add3, Z_1 = B1.add;
function Lm(Z, J, $, X, Y, Q, W, K, G) {
  let { vertices: H, normals: N, indices: q } = J, U = H.elementCount;
  if (MG(kZ, X, Z), Vw(Um, kZ, W), Vw(Fm, kZ, K), MG(B9, Y, Z), Vw(pK, B9, Q), uf0(lq, B9, kZ), MG(uH, $, Z), AG(yE, AG(yE, uH, pK), Fm), fU(gE, AG(gE, uH, pK), Um), fU(mE, fU(mE, uH, pK), Um), AG(dE, fU(dE, uH, pK), Fm), W < K)
    h9(H, dE[0], dE[1], dE[2]), h9(H, mE[0], mE[1], mE[2]), h9(H, gE[0], gE[1], gE[2]), h9(H, yE[0], yE[1], yE[2]), NZ0(cq, Fm);
  else
    h9(H, yE[0], yE[1], yE[2]), h9(H, gE[0], gE[1], gE[2]), h9(H, mE[0], mE[1], mE[2]), h9(H, dE[0], dE[1], dE[2]), NZ0(cq, Um);
  if (G) {
    for (let F = 0;F < 4; ++F)
      h9(N, -lq[0], -lq[1], -lq[2]);
    h9(q, U, U + 1, U + 2), h9(q, U + 2, U + 3, U);
  } else {
    for (let F = 0;F < 4; ++F)
      h9(N, lq[0], lq[1], lq[2]);
    h9(q, U + 2, U + 1, U), h9(q, U, U + 3, U + 2);
  }
}
function Iw(Z, J, $, X, Y, Q, W, K, G, H) {
  let { currentGroup: N, vertices: q, normals: U, indices: F, groups: E } = Z, R = q.elementCount, z = 0;
  if (K > 0)
    MG(kZ, J, 0), MG(B9, J, Y * 3), z = K / tT1(fU(rT1, B9, kZ));
  else
    eT1(TP, 0, 0, 0);
  for (let A = 0;A <= Y; ++A) {
    let B = Q[A], T = W[A], w = K === 0 ? T : K * (1 - A / Y), V = A * 3;
    if (MG(cq, $, V), Vw(cq, cq, w), MG(pK, X, V), Vw(pK, pK, B), K > 0)
      MG(kZ, $, V), MG(B9, X, V), Vw(TP, uf0(TP, kZ, B9), z);
    MG(uH, J, V), MG(lq, $, V), MG(HZ0, X, V), AG(kZ, AG(kZ, uH, pK), cq), AG(B9, lq, TP), h9(q, kZ[0], kZ[1], kZ[2]), h9(U, B9[0], B9[1], B9[2]), AG(kZ, fU(kZ, uH, pK), cq), h9(q, kZ[0], kZ[1], kZ[2]), h9(U, B9[0], B9[1], B9[2]), pf0(B9, HZ0), h9(q, kZ[0], kZ[1], kZ[2]), h9(U, B9[0], B9[1], B9[2]), fU(kZ, fU(kZ, uH, pK), cq), h9(q, kZ[0], kZ[1], kZ[2]), h9(U, B9[0], B9[1], B9[2]), AG(B9, pf0(B9, lq), TP), h9(q, kZ[0], kZ[1], kZ[2]), h9(U, B9[0], B9[1], B9[2]), fU(kZ, AG(kZ, uH, pK), cq), h9(q, kZ[0], kZ[1], kZ[2]), h9(U, B9[0], B9[1], B9[2]), NZ0(B9, HZ0), h9(q, kZ[0], kZ[1], kZ[2]), h9(U, B9[0], B9[1], B9[2]), AG(kZ, AG(kZ, uH, pK), cq), h9(q, kZ[0], kZ[1], kZ[2]), h9(U, B9[0], B9[1], B9[2]);
  }
  for (let A = 0;A < Y; ++A) {
    for (let B = 0;B < 2; B++)
      h9(F, R + A * 8 + 2 * B, R + (A + 1) * 8 + 2 * B + 1, R + A * 8 + 2 * B + 1), h9(F, R + A * 8 + 2 * B, R + (A + 1) * 8 + 2 * B, R + (A + 1) * 8 + 2 * B + 1);
    for (let B = 2;B < 4; B++)
      h9(F, R + A * 8 + 2 * B, R + (A + 1) * 8 + 2 * B, R + A * 8 + 2 * B + 1), h9(F, R + (A + 1) * 8 + 2 * B, R + (A + 1) * 8 + 2 * B + 1, R + A * 8 + 2 * B + 1);
  }
  if (G) {
    let A = Q[0], B = W[0], T = K === 0 ? B : K;
    Lm(0, Z, J, $, X, A, T, T, !1);
  } else if (K > 0) {
    let A = Q[0], B = W[0];
    Lm(0, Z, J, $, X, A, K, -B, !1), Lm(0, Z, J, $, X, A, -K, B, !1);
  }
  if (H && K === 0) {
    let A = Q[Y], B = W[Y];
    Lm(Y * 3, Z, J, $, X, A, B, B, !0);
  }
  let D = (Y + 1) * 8 + (G ? 4 : K > 0 ? 8 : 0) + (H && K === 0 ? 4 : 0);
  for (let A = 0, B = D;A < B; ++A)
    Z_1(E, N);
}

// node_modules/molstar/lib/mol-geo/geometry/mesh/builder/tube.js
var DJ = M(), Rm = M(), d$ = M(), eW = M(), MX = M(), mY = M();
function Em(Z, J, $, X, Y) {
  Z[0] = J[0] * X + $[0] * Y, Z[1] = J[1] * X + $[1] * Y, Z[2] = J[2] * X + $[2] * Y;
}
function Pw(Z, J, $, X, Y, Q) {
  Z[0] = J[0] * Y + $[0] * Q + X[0], Z[1] = J[1] * Y + $[1] * Q + X[1], Z[2] = J[2] * Y + $[2] * Q + X[2];
}
var hU = M.fromArray, cf0 = M.normalize, qZ0 = M.scaleAndAdd, FZ0 = M.cross, J_1 = M.slerp, $_1 = M.dot, X_1 = M.unitX, KW = B1.add3, UZ0 = /* @__PURE__ */ new Map;
function Y_1(Z, J) {
  let $ = J ? 1 : 0, X = ZJ(Z, $);
  if (!UZ0.has(X)) {
    let Y = [], Q = [];
    for (let W = 0;W < Z; ++W) {
      let K = (W * 2 + $) / Z * Math.PI;
      Y[W] = Math.cos(K), Q[W] = Math.sin(K);
    }
    UZ0.set(X, { cos: Y, sin: Q });
  }
  return UZ0.get(X);
}
function _P(Z, J, $, X, Y, Q, W, K, G, H, N, q = !1) {
  let { currentGroup: U, vertices: F, normals: E, indices: R, groups: z } = Z, D = F.elementCount, { cos: A, sin: B } = Y_1(Q, N === "rounded"), T = Math.round(Q / 4), w = T * 3, V = q && Y && (G || H), P, I = V && G && H;
  if (I)
    P = Y / 2;
  for (let v = 0;v <= Y; ++v) {
    let h = v * 3;
    hU(MX, $, h), hU(mY, X, h), hU(eW, J, h);
    let x = W[v], b = K[v], g;
    if (V) {
      let i = I ? v <= P : G;
      if (I)
        g = Math.max(Number.EPSILON, Math.sqrt(1 - Math.pow((i ? P - v : v - P) / P, 2)));
      else
        g = Math.max(Number.EPSILON, Math.sqrt(1 - Math.pow((i ? Y - v : v) / Y, 2)));
      x *= g, b *= g, FZ0(Rm, i ? mY : MX, i ? MX : mY), cf0(Rm, Rm);
    }
    let m = N === "rounded" && b > x;
    for (let i = 0;i < Q; ++i) {
      if (m) {
        Pw(d$, MX, mY, eW, x * A[i], x * B[i]);
        let r = $_1(mY, X_1) < 0 ? i < T || i >= w ? b - x : -b + x : i >= T && i < w ? -b + x : b - x;
        if (qZ0(d$, d$, MX, r), i === T || i === T - 1)
          Em(DJ, MX, mY, 0, 1);
        else if (i === w || i === w - 1)
          Em(DJ, MX, mY, 0, -1);
        else
          Em(DJ, MX, mY, A[i], B[i]);
      } else
        Pw(d$, MX, mY, eW, b * A[i], x * B[i]), Em(DJ, MX, mY, x * A[i], b * B[i]);
      if (cf0(DJ, DJ), KW(F, d$[0], d$[1], d$[2]), V)
        J_1(DJ, Rm, DJ, g);
      KW(E, DJ[0], DJ[1], DJ[2]);
    }
  }
  let S = Math.round(Q / 2);
  for (let v = 0;v < Y; ++v) {
    for (let h = 0;h < S; ++h)
      KW(R, D + v * Q + (h + 1) % Q, D + (v + 1) * Q + (h + 1) % Q, D + v * Q + h), KW(R, D + (v + 1) * Q + (h + 1) % Q, D + (v + 1) * Q + h, D + v * Q + h);
    for (let h = S;h < Q; ++h)
      KW(R, D + v * Q + (h + 1) % Q, D + (v + 1) * Q + h, D + v * Q + h), KW(R, D + (v + 1) * Q + (h + 1) % Q, D + (v + 1) * Q + h, D + v * Q + (h + 1) % Q);
  }
  if (G) {
    let h = F.elementCount;
    hU(MX, $, 0), hU(mY, X, 0), hU(eW, J, 0), FZ0(DJ, mY, MX), KW(F, eW[0], eW[1], eW[2]), KW(E, DJ[0], DJ[1], DJ[2]);
    let x = V ? 0 : W[0], b = V ? 0 : K[0], g = N === "rounded" && b > x;
    if (g)
      b -= x;
    D = F.elementCount;
    for (let m = 0;m < Q; ++m) {
      if (g)
        Pw(d$, MX, mY, eW, x * A[m], x * B[m]), qZ0(d$, d$, MX, m < T || m >= w ? b : -b);
      else
        Pw(d$, MX, mY, eW, b * A[m], x * B[m]);
      KW(F, d$[0], d$[1], d$[2]), KW(E, DJ[0], DJ[1], DJ[2]), KW(R, D + (m + 1) % Q, D + m, h);
    }
  }
  if (H) {
    let v = Y * 3, h = F.elementCount;
    hU(MX, $, v), hU(mY, X, v), hU(eW, J, v), FZ0(DJ, MX, mY), KW(F, eW[0], eW[1], eW[2]), KW(E, DJ[0], DJ[1], DJ[2]);
    let x = V ? 0 : W[Y], b = V ? 0 : K[Y], g = N === "rounded" && b > x;
    if (g)
      b -= x;
    D = F.elementCount;
    for (let m = 0;m < Q; ++m) {
      if (g)
        Pw(d$, MX, mY, eW, x * A[m], x * B[m]), qZ0(d$, d$, MX, m < T || m >= w ? b : -b);
      else
        Pw(d$, MX, mY, eW, b * A[m], x * B[m]);
      KW(F, d$[0], d$[1], d$[2]), KW(E, DJ[0], DJ[1], DJ[2]), KW(R, D + m, D + (m + 1) % Q, h);
    }
  }
  let f = (Y + 1) * Q + (G ? Q + 1 : 0) + (H ? Q + 1 : 0);
  B1.addRepeat(z, f, U);
}

// node_modules/molstar/lib/mol-geo/geometry/mesh/builder/ribbon.js
var bU = M.fromArray, Q_1 = M.magnitude, LZ0 = M.sub, lf0 = M.add, RZ0 = M.scale, W_1 = M.negate, K_1 = M.copy, G_1 = M.cross, BG = B1.add3, H_1 = B1.add, AX = M(), dY = M(), N_1 = M(), EZ0 = M(), P4 = M(), nf0 = M(), VP = M(), q_1 = M(), OZ0 = M();
function Cw(Z, J, $, X, Y, Q, W, K) {
  let { currentGroup: G, vertices: H, normals: N, indices: q, groups: U } = Z, F = H.elementCount, E = 0;
  if (K > 0)
    bU(AX, J, 0), bU(dY, J, Y * 3), E = K / Q_1(LZ0(N_1, dY, AX));
  for (let z = 0;z <= Y; ++z) {
    let D = Q[z], A = W[z], B = K === 0 ? A : K * (1 - z / Y), T = z * 3;
    if (bU(P4, $, T), RZ0(P4, P4, B), bU(EZ0, X, T), RZ0(EZ0, EZ0, D), K > 0)
      bU(AX, $, T), bU(dY, X, T), RZ0(nf0, G_1(nf0, AX, dY), E);
    bU(VP, J, T), bU(q_1, $, T), bU(OZ0, X, T), lf0(AX, VP, P4), W_1(dY, OZ0), BG(H, AX[0], AX[1], AX[2]), BG(N, dY[0], dY[1], dY[2]), LZ0(AX, VP, P4), BG(H, AX[0], AX[1], AX[2]), BG(N, dY[0], dY[1], dY[2]), lf0(AX, VP, P4), K_1(dY, OZ0), BG(H, AX[0], AX[1], AX[2]), BG(N, dY[0], dY[1], dY[2]), LZ0(AX, VP, P4), BG(H, AX[0], AX[1], AX[2]), BG(N, dY[0], dY[1], dY[2]);
  }
  for (let z = 0;z < Y; ++z)
    BG(q, F + z * 4, F + (z + 1) * 4 + 1, F + z * 4 + 1), BG(q, F + z * 4, F + (z + 1) * 4, F + (z + 1) * 4 + 1), BG(q, F + z * 4 + 2 + 1, F + (z + 1) * 4 + 2 + 1, F + z * 4 + 2), BG(q, F + z * 4 + 2, F + (z + 1) * 4 + 2 + 1, F + (z + 1) * 4 + 2);
  let R = (Y + 1) * 4;
  for (let z = 0, D = R;z < D; ++z)
    H_1(U, G);
}

// node_modules/molstar/lib/mol-repr/structure/visual/polymer-trace-mesh.js
var if0 = {
  sizeFactor: j.Numeric(0.2, { min: 0, max: 10, step: 0.01 }),
  aspectRatio: j.Numeric(5, { min: 0.1, max: 10, step: 0.1 }),
  arrowFactor: j.Numeric(1.5, { min: 0, max: 3, step: 0.1 }, { description: "Size factor for sheet arrows" }),
  tubularHelices: j.Boolean(!1, { description: "Draw alpha helices as tubes" }),
  roundCap: j.Boolean(!1, { description: "Draw round caps on tubular alpha helices" }),
  helixProfile: j.Select("elliptical", j.arrayToOptions(["elliptical", "rounded", "square"]), { description: "Protein helix trace profile" }),
  nucleicProfile: j.Select("square", j.arrayToOptions(["elliptical", "rounded", "square"]), { description: "Nucleic strand trace profile" }),
  detail: j.Numeric(0, { min: 0, max: 3, step: 1 }, q1.CustomQualityParamInfo),
  linearSegments: j.Numeric(8, { min: 1, max: 48, step: 1 }, q1.CustomQualityParamInfo),
  radialSegments: j.Numeric(16, { min: 2, max: 56, step: 2 }, q1.CustomQualityParamInfo)
}, Ab8 = j.getDefaultValues(if0), c5 = M();
function F_1(Z, J, $, X, Y, Q) {
  let W = J.polymerElements.length;
  if (!W)
    return n1.createEmpty(Q);
  let { sizeFactor: K, detail: G, linearSegments: H, radialSegments: N, aspectRatio: q, arrowFactor: U, tubularHelices: F, roundCap: E, helixProfile: R, nucleicProfile: z } = Y, D = H * N * W + (N + 1) * W * 2, A = v1.createState(D, D / 10, Q), B = j0.isCoarse(J), T = Ww(H), { curvePoints: w, normalVectors: V, binormalVectors: P, widthValues: I, heightValues: S } = T, f = 0, v = $w(J, $, { ignoreSecondaryStructure: !1, useHelixOrientation: F });
  while (v.hasNext) {
    let b = v.move();
    A.currentGroup = f;
    let g = XJ(b.moleculeType), m = m2.is(b.secStrucType, m2.Flag.Beta), i = m2.is(b.secStrucType, m2.Flag.Helix), r = i && !F ? Nf0 : lg, Y0 = g ? j4 : w4;
    Kw(T, b, r, Y0);
    let c = X.size.size(b.centerPrev) * K, n = X.size.size(b.center) * K, l = X.size.size(b.centerNext) * K;
    if (B)
      c *= q / 2, n *= q / 2, l *= q / 2;
    let u = b.secStrucFirst || b.coarseBackboneFirst || b.first, G0 = b.secStrucLast || b.coarseBackboneLast || b.last, F0 = i && F && E, t = H;
    if (b.initial) {
      t = Math.max(Math.round(H * Y0), 1);
      let Z0 = H - t;
      w.copyWithin(0, Z0 * 3), P.copyWithin(0, Z0 * 3), V.copyWithin(0, Z0 * 3), M.fromArray(c5, w, 3), M.normalize(c5, M.sub(c5, b.p2, c5)), M.scaleAndAdd(c5, b.p2, c5, n * Gw), M.toArray(c5, w, 0);
    } else if (b.final)
      t = Math.max(Math.round(H * (1 - Y0)), 1), M.fromArray(c5, w, t * 3 - 3), M.normalize(c5, M.sub(c5, b.p2, c5)), M.scaleAndAdd(c5, b.p2, c5, n * Gw), M.toArray(c5, w, t * 3);
    if (b.initial === !0 && b.final === !0)
      g8(A, b.p2, n * 2, G);
    else if (m) {
      let Z0 = c * q, U0 = n * q, a = l * q, Q0 = b.secStrucLast ? U0 * U : 0;
      if (wP(T, c, n, l, Z0, U0, a, Y0), N === 2)
        Cw(A, w, V, P, t, I, S, Q0);
      else
        Iw(A, w, V, P, t, I, S, Q0, u, G0);
    } else {
      let Z0, U0, a;
      if (i)
        if (F)
          c *= q * 1.5, n *= q * 1.5, l *= q * 1.5, Z0 = c, U0 = n, a = l;
        else
          Z0 = c * q, U0 = n * q, a = l * q;
      else if (g)
        Z0 = c * q, U0 = n * q, a = l * q;
      else
        Z0 = c, U0 = n, a = l;
      wP(T, c, n, l, Z0, U0, a, Y0);
      let [Q0, $0] = g ? [P, V] : [V, P];
      if (g)
        for (let X0 = 0, E0 = Q0.length;X0 < E0; X0++)
          Q0[X0] *= -1;
      let R0 = g ? z : R;
      if (N === 2)
        if (g)
          Cw(A, w, Q0, $0, t, S, I, 0);
        else
          Cw(A, w, Q0, $0, t, I, S, 0);
      else if (N === 4)
        Iw(A, w, Q0, $0, t, I, S, 0, u, G0);
      else if (U0 === n)
        _P(A, w, Q0, $0, t, N, I, S, u, G0, "elliptical", F0);
      else if (R0 === "square")
        Iw(A, w, Q0, $0, t, I, S, 0, u, G0);
      else
        _P(A, w, Q0, $0, t, N, I, S, u, G0, R0);
    }
    ++f;
  }
  let h = v1.getMesh(A), x = C0.expand(C0(), J.boundary.sphere, 1 * Y.sizeFactor);
  return h.setBoundingSphere(x), h;
}
var zZ0 = {
  ...nZ,
  ...if0
};
function of0(Z) {
  return A9({
    defaultProps: j.getDefaultValues(zZ0),
    createGeometry: F_1,
    createLocationIterator: (J) => d5.fromGroup(J, { asSecondary: !0 }),
    getLoci: KG,
    eachLocation: GG,
    setUpdateState: (J, $, X, Y, Q, W, K) => {
      J.createGeometry = $.sizeFactor !== X.sizeFactor || $.tubularHelices !== X.tubularHelices || $.roundCap !== X.roundCap || $.detail !== X.detail || $.linearSegments !== X.linearSegments || $.radialSegments !== X.radialSegments || $.aspectRatio !== X.aspectRatio || $.arrowFactor !== X.arrowFactor || $.helixProfile !== X.helixProfile || $.nucleicProfile !== X.nucleicProfile;
      let G = $X.get(W.structure).version;
      if (J.info.secondaryStructureHash !== G) {
        if (J.info.secondaryStructureHash !== void 0)
          J.createGeometry = !0;
        J.info.secondaryStructureHash = G;
      }
    },
    initUpdateState: (J, $, X, Y) => {
      let Q = $X.get(Y.structure).version;
      J.info.secondaryStructureHash = Q;
    }
  }, Z);
}

// node_modules/molstar/lib/mol-repr/structure/representation/cartoon.js
var sf0 = {
  "polymer-trace": (Z, J) => _Z("Polymer trace mesh", Z, J, of0),
  "polymer-gap": (Z, J) => _Z("Polymer gap cylinder", Z, J, _w),
  "nucleotide-block": (Z, J) => _Z("Nucleotide block mesh", Z, J, Mf0),
  "nucleotide-ring": (Z, J) => _Z("Nucleotide ring mesh", Z, J, _f0),
  "nucleotide-atomic-ring-fill": (Z, J) => _Z("Nucleotide atomic ring fill", Z, J, vf0),
  "nucleotide-atomic-bond": (Z, J) => _Z("Nucleotide atomic bond", Z, J, Sf0),
  "nucleotide-atomic-element": (Z, J) => _Z("Nucleotide atomic element", Z, J, ff0),
  "direction-wedge": (Z, J) => _Z("Polymer direction wedge", Z, J, mf0)
}, af0 = {
  ...zZ0,
  ...I4,
  ...e60,
  ...ZZ0,
  ...Nm,
  ...qm,
  ...YZ0,
  ...KZ0,
  sizeFactor: j.Numeric(0.2, { min: 0, max: 10, step: 0.01 }),
  visuals: j.MultiSelect(["polymer-trace", "polymer-gap", "nucleotide-ring", "nucleotide-atomic-ring-fill", "nucleotide-atomic-bond", "nucleotide-atomic-element"], j.objectToOptions(sf0)),
  bumpFrequency: j.Numeric(2, { min: 0, max: 10, step: 0.1 }, q1.ShadingCategory),
  density: j.Numeric(0.1, { min: 0, max: 1, step: 0.01 }, q1.ShadingCategory),
  colorMode: j.Select("default", j.arrayToOptions(["default", "interpolate"]), { ...q1.ShadingCategory, isHidden: !0 })
};
function U_1(Z, J) {
  let $ = j.clone(af0), X = !1, Y = !1;
  if (J.units.forEach((Q) => {
    if (!X && j0.isAtomic(Q) && Q.nucleotideElements.length)
      X = !0;
    if (!Y && Q.gapElements.length)
      Y = !0;
  }), $.visuals.defaultValue = ["polymer-trace"], X)
    $.visuals.defaultValue.push("nucleotide-ring");
  if (Y)
    $.visuals.defaultValue.push("polymer-gap");
  return $;
}
function L_1(Z, J) {
  return V2.createMulti("Cartoon", Z, J, lZ, sf0);
}
var rf0 = v9({
  name: "cartoon",
  label: "Cartoon",
  description: "Displays ribbons, planks, tubes smoothly following the trace atoms of polymers.",
  factory: L_1,
  getParams: U_1,
  defaultValues: j.getDefaultValues(af0),
  defaultColorTheme: { name: "chain-id" },
  defaultSizeTheme: { name: "uniform" },
  isApplicable: (Z) => Z.polymerResidueCount > 0,
  ensureCustomProperties: {
    attach: async (Z, J) => {
      await $X.attach(Z, J, void 0, !0);
      for (let $ of J.models)
        await AP.attach(Z, $, void 0, !0);
    },
    detach: (Z) => {
      $X.ref(Z, !1);
      for (let J of Z.models)
        AP.ref(J, !1);
    }
  }
});

// node_modules/molstar/lib/mol-repr/structure/visual/ellipsoid-mesh.js
var tf0 = M.add;
function R_1(Z, J, $, X, Y, Q) {
  let { child: W } = $, K = W === null || W === void 0 ? void 0 : W.unitMap.get(J.id);
  if (W && !K)
    return n1.createEmpty(Q);
  let { detail: G, sizeFactor: H } = Y, { elements: N, model: q } = J, U = N.length, F = U * _5(G), E = v1.createState(F, F / 2, Q), R = vW.Provider.get(q);
  if (!R)
    return n1.createEmpty(Q);
  let z = M(), D = h2(), A = M(), B = M(), T = M(), { elementToAnsiotrop: w, data: V } = R, { U: P } = V, I = V._schema.U.space, S = J.conformation, f = W0.Location.create($);
  f.unit = J;
  let v = tW($, J, Y), h = M(), x = 0;
  for (let i = 0;i < U; i++) {
    let r = N[i], Y0 = w[r];
    if (Y0 === -1)
      continue;
    if (v && v(N[i]))
      continue;
    f.element = r, S.invariantPosition(r, z), tf0(h, h, z), x += 1, E.currentGroup = i, M8.toMat3(D, I, P.value(Y0)), h2.symmtricFromLower(D, D), h2.symmetricEigenvalues(A, D), h2.eigenvector(B, D, A[1]), h2.eigenvector(T, D, A[2]);
    for (let c = 0;c < 3; ++c)
      A[c] = H * 1.5958 * Math.sqrt(Math.abs(A[c]));
    if (dZ(A[0], A[1], u8) && dZ(A[1], A[2], u8))
      g8(E, z, A[0], G);
    else
      fz(E, z, T, B, A, G);
  }
  let b = v1.getMesh(E);
  if (x === 0)
    return b;
  let g;
  M.scale(h, h, 1 / x);
  let m = Q ? C0.clone(Q.boundingSphere) : void 0;
  if (m && M.distance(h, m.center) / m.radius < 0.1)
    g = m;
  else
    g = C0.expand(C0(), (K !== null && K !== void 0 ? K : J).boundary.sphere, 1 * H * 2);
  return b.setBoundingSphere(g), b;
}
var DZ0 = {
  ...nZ,
  sizeFactor: j.Numeric(1, { min: 0, max: 10, step: 0.1 }),
  detail: j.Numeric(0, { min: 0, max: 3, step: 1 }, q1.CustomQualityParamInfo),
  ignoreHydrogens: j.Boolean(!1),
  ignoreHydrogensVariant: j.Select("all", j.arrayToOptions(["all", "non-polar"])),
  traceOnly: j.Boolean(!1)
};
function ef0(Z) {
  return A9({
    defaultProps: j.getDefaultValues(DZ0),
    createGeometry: R_1,
    createLocationIterator: _9.fromGroup,
    getLoci: UX,
    eachLocation: FX,
    setUpdateState: (J, $, X) => {
      J.createGeometry = $.sizeFactor !== X.sizeFactor || $.detail !== X.detail || $.ignoreHydrogens !== X.ignoreHydrogens;
    }
  }, Z);
}
function E_1(Z, J, $, X, Y) {
  let { child: Q } = J, { detail: W, sizeFactor: K } = X, { getSerialIndex: G } = J.serialMapping, N = J.elementCount * _5(W), q = v1.createState(N, N / 2, Y), U = M(), F = h2(), E = M(), R = M(), z = M(), D = M(), A = 0;
  for (let V of J.units) {
    let P = Q === null || Q === void 0 ? void 0 : Q.unitMap.get(V.id);
    if (Q && !P)
      return n1.createEmpty(Y);
    let { elements: I, model: S } = V, f = I.length, v = vW.Provider.get(S);
    if (!v)
      return n1.createEmpty(Y);
    let h = tW(J, V, X), { elementToAnsiotrop: x, data: b } = v, { U: g } = b, m = b._schema.U.space, i = V.conformation, r = W0.Location.create(J);
    r.unit = V;
    for (let Y0 = 0;Y0 < f; Y0++) {
      let c = I[Y0], n = x[c];
      if (n === -1)
        continue;
      if (h && h(I[Y0]))
        continue;
      r.element = c, i.position(c, U), tf0(D, D, U), A += 1, q.currentGroup = G(V, I[Y0]), M8.toMat3(F, m, g.value(n)), h2.symmtricFromLower(F, F), h2.symmetricEigenvalues(E, F), h2.eigenvector(R, F, E[1]), h2.eigenvector(z, F, E[2]);
      for (let l = 0;l < 3; ++l)
        E[l] = K * 1.5958 * Math.sqrt(Math.abs(E[l]));
      if (dZ(E[0], E[1], u8) && dZ(E[1], E[2], u8))
        g8(q, U, E[0], W);
      else
        fz(q, U, z, R, E, W);
    }
  }
  let B = v1.getMesh(q);
  if (A === 0)
    return B;
  let T;
  M.scale(D, D, 1 / A);
  let w = Y ? C0.clone(Y.boundingSphere) : void 0;
  if (w && M.distance(D, w.center) / w.radius < 1)
    T = w;
  else
    T = C0.expand(C0(), (Q !== null && Q !== void 0 ? Q : J).boundary.sphere, 1 * K * 2);
  return B.setBoundingSphere(T), B;
}
var O_1 = {
  ...tQ,
  sizeFactor: j.Numeric(1, { min: 0, max: 10, step: 0.1 }),
  detail: j.Numeric(0, { min: 0, max: 3, step: 1 }, q1.CustomQualityParamInfo),
  ignoreHydrogens: j.Boolean(!1),
  ignoreHydrogensVariant: j.Select("all", j.arrayToOptions(["all", "non-polar"])),
  traceOnly: j.Boolean(!1)
};
function Zh0(Z) {
  return D$({
    defaultProps: j.getDefaultValues(O_1),
    createGeometry: E_1,
    createLocationIterator: _9.fromStructure,
    getLoci: RX,
    eachLocation: LX,
    setUpdateState: (J, $, X) => {
      J.createGeometry = $.sizeFactor !== X.sizeFactor || $.detail !== X.detail || $.ignoreHydrogens !== X.ignoreHydrogens;
    }
  }, Z);
}

// node_modules/molstar/lib/mol-repr/structure/representation/ellipsoid.js
var Jh0 = {
  "ellipsoid-mesh": (Z, J) => _Z("Ellipsoid Mesh", Z, J, ef0),
  "intra-bond": (Z, J) => _Z("Intra-unit bond cylinder", Z, J, fg),
  "inter-bond": (Z, J) => M9("Inter-unit bond cylinder", Z, J, bg),
  "structure-ellipsoid-mesh": (Z, J) => M9("Structure Ellipsoid Mesh", Z, J, Zh0),
  "structure-intra-bond": (Z, J) => M9("Structure intra-unit bond cylinder", Z, J, hg)
}, $h0 = {
  ...DZ0,
  ...tB,
  ...eB,
  includeParent: j.Boolean(!1),
  adjustCylinderLength: j.Boolean(!1, { isHidden: !0 }),
  unitKinds: zU(["atomic"]),
  sizeFactor: j.Numeric(1, { min: 0.01, max: 10, step: 0.01 }),
  sizeAspectRatio: j.Numeric(0.1, { min: 0.01, max: 3, step: 0.01 }),
  linkCap: j.Boolean(!0),
  visuals: j.MultiSelect(["ellipsoid-mesh", "intra-bond", "inter-bond"], j.objectToOptions(Jh0)),
  bumpFrequency: j.Numeric(0, { min: 0, max: 10, step: 0.1 }, q1.ShadingCategory)
};
function z_1(Z, J) {
  let $ = $h0;
  if (s0.getSize(J) >= s0.Size.Huge)
    $ = j.clone($), $.visuals.defaultValue = ["ellipsoid-mesh", "intra-bond"];
  else if (J.unitSymmetryGroups.length > 5000)
    $ = j.clone($), $.visuals.defaultValue = ["structure-ellipsoid-mesh", "structure-intra-bond"];
  return $;
}
function D_1(Z, J) {
  return V2.createMulti("Ellipsoid", Z, J, lZ, Jh0);
}
var Xh0 = v9({
  name: "ellipsoid",
  label: "Ellipsoid",
  description: "Displays anisotropic displacement ellipsoids of atomic elements plus bonds as cylinders.",
  factory: D_1,
  getParams: z_1,
  defaultValues: j.getDefaultValues($h0),
  defaultColorTheme: { name: "element-symbol" },
  defaultSizeTheme: { name: "uniform" },
  isApplicable: (Z) => Z.elementCount > 0 && Z.models.some((J) => vW.Provider.isApplicable(J)),
  getData: (Z, J) => {
    return J.includeParent ? Z.asParent() : Z;
  },
  mustRecreate: (Z, J) => {
    return Z.includeParent !== J.includeParent;
  }
});

// node_modules/molstar/lib/mol-gl/shader/gaussian-density.vert.js
var Yh0 = `
precision highp float;

attribute vec3 aPosition;
attribute float aRadius;

varying vec3 vPosition;
varying float vRadiusSqInv;

#if defined(dCalcType_groupId)
    attribute float aGroup;
    varying float vGroup;
#endif

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

void main() {
    vRadiusSqInv = 1.0 / (aRadius * aRadius);
    #if defined(dCalcType_groupId)
        vGroup = aGroup;
    #endif
    gl_PointSize = ceil(((aRadius * 3.0) / uResolution) + uResolution);
    vPosition = (aPosition - uBboxMin) / uResolution;
    gl_Position = vec4(((aPosition - uBboxMin) / uBboxSize) * 2.0 - 1.0, 1.0);
}
`;

// node_modules/molstar/lib/mol-gl/shader/gaussian-density.frag.js
var Qh0 = `
precision highp float;

varying vec3 vPosition;
varying float vRadiusSqInv;
#if defined(dCalcType_groupId)
    #if defined(dGridTexType_2d)
        precision highp sampler2D;
        uniform sampler2D tMinDistanceTex;
        uniform vec3 uGridTexDim;
    #elif defined(dGridTexType_3d)
        precision highp sampler3D;
        uniform sampler3D tMinDistanceTex;
    #endif
    varying float vGroup;
#endif

#include common

uniform vec3 uGridDim;
uniform vec2 uGridTexScale;
uniform float uCurrentSlice;
uniform float uCurrentX;
uniform float uCurrentY;
uniform float uAlpha;
uniform float uResolution;
uniform float uRadiusFactorInv;

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) * uResolution;

    #if defined(dCalcType_density)
        float density = exp(-uAlpha * ((dist * dist) * vRadiusSqInv));
        gl_FragColor.a = density * uRadiusFactorInv;
    #elif defined(dCalcType_minDistance)
        gl_FragColor.a = 1.0 - dist * uRadiusFactorInv;
    #elif defined(dCalcType_groupId)
        #if defined(dGridTexType_2d)
            float minDistance = 1.0 - texture2D(tMinDistanceTex, (gl_FragCoord.xy) / (uGridTexDim.xy / uGridTexScale)).a;
        #elif defined(dGridTexType_3d)
            float minDistance = 1.0 - texelFetch(tMinDistanceTex, ivec3(gl_FragCoord.xy, uCurrentSlice), 0).a;
        #endif
        if (dist * uRadiusFactorInv > minDistance + uResolution * 0.05)
            discard;
        gl_FragColor.rgb = packIntToRGB(vGroup);
    #endif
}
`;

// node_modules/molstar/lib/mol-math/geometry/gaussian-density/gpu.js
var M_1 = {
  drawCount: zZ("number"),
  instanceCount: zZ("number"),
  aRadius: a6("float32", 1, 0),
  aPosition: a6("float32", 3, 0),
  aGroup: a6("float32", 1, 0),
  uCurrentSlice: _0("f"),
  uCurrentX: _0("f"),
  uCurrentY: _0("f"),
  uBboxMin: _0("v3", "material"),
  uBboxSize: _0("v3", "material"),
  uGridDim: _0("v3", "material"),
  uGridTexDim: _0("v3", "material"),
  uGridTexScale: _0("v2", "material"),
  uAlpha: _0("f", "material"),
  uResolution: _0("f", "material"),
  uRadiusFactorInv: _0("f", "material"),
  tMinDistanceTex: o1("texture", "rgba", "float", "nearest", "material"),
  dGridTexType: p1("string", ["2d", "3d"]),
  dCalcType: p1("string", ["density", "minDistance", "groupId"])
}, nq = "gaussian-density";
function Wh0(Z) {
  if (!Z.namedFramebuffers[nq])
    Z.namedFramebuffers[nq] = Z.resources.framebuffer();
  return Z.namedFramebuffers[nq];
}
function Kh0(Z, J, $, X, Y, Q) {
  let W = `${nq}-${Z}`;
  if (!J.namedTextures[W])
    J.namedTextures[W] = J.resources.texture($, X, Y, Q);
  return J.namedTextures[W];
}
function MZ0(Z, J, $, X, Y, Q) {
  return Z.isWebGL2 ? A_1(Z, J, $, X, Y, Q) : Om(Z, J, $, X, !1, Y, Q);
}
function Om(Z, J, $, X, Y, Q, W) {
  if (K1)
    Z.timer.mark("GaussianDensityTexture2d");
  let K = w_1(Z, J, $, X, Y, Q, W);
  if (K1)
    Z.timer.markEnd("GaussianDensityTexture2d");
  return Gh0(K);
}
function A_1(Z, J, $, X, Y, Q) {
  if (K1)
    Z.timer.mark("GaussianDensityTexture3d");
  let W = j_1(Z, J, $, X, Y, Q);
  if (K1)
    Z.timer.markEnd("GaussianDensityTexture3d");
  return Gh0(W);
}
function Gh0({ texture: Z, scale: J, bbox: $, gridDim: X, gridTexDim: Y, gridDataDim: Q, gridTexScale: W, radiusFactor: K, resolution: G, maxRadius: H }) {
  return { transform: B_1(J, $), texture: Z, bbox: $, gridDim: X, gridTexDim: Y, gridDataDim: Q, gridTexScale: W, radiusFactor: K, resolution: G, maxRadius: H };
}
function B_1(Z, J) {
  let $ = e.identity();
  return e.fromScaling($, Z), e.setTranslation($, J.min), $;
}
function w_1(Z, J, $, X, Y, Q, W) {
  let { gl: K, resources: G, state: H, extensions: { colorBufferFloat: N, textureFloat: q, colorBufferHalfFloat: U, textureHalfFloat: F, blendMinMax: E } } = Z, { smoothness: R, resolution: z } = Q, { drawCount: D, positions: A, radii: B, groups: T, scale: w, expandedBox: V, dim: P, maxRadius: I } = Hh0(J, $, X, Q), [S, f, v] = P, { texDimX: h, texDimY: x, texCols: b, powerOfTwoSize: g } = __1(P), m = M.create(h, x, 0), i = h0.create(h / g, x / g), r = I * 2, Y0 = Y ? g : h, c = Y ? g : x, n = Kh0("min-dist-2d", Z, "image-uint8", "rgba", "ubyte", "nearest");
  n.define(Y0, c);
  let l = Nh0(Z, D, A, B, T, n, V, P, m, i, R, z, r), { uCurrentSlice: u, uCurrentX: G0, uCurrentY: F0 } = l.values, t = Wh0(Z);
  if (t.bind(), qh0(Z), !W)
    W = U && F ? G.texture("image-float16", "rgba", "fp16", "linear") : N && q ? G.texture("image-float32", "rgba", "float", "linear") : G.texture("image-uint8", "rgba", "ubyte", "linear");
  W.define(Y0, c);
  function Z0(U0, a) {
    if (H.currentRenderItemId = -1, U0.attachFramebuffer(t, 0), a)
      H.viewport(0, 0, Y0, c), H.scissor(0, 0, Y0, c), K.clear(K.COLOR_BUFFER_BIT);
    C.update(F0, 0);
    let Q0 = 0, $0 = 0, R0 = 0;
    for (let X0 = 0;X0 < v; ++X0) {
      if (Q0 >= b)
        Q0 -= b, $0 += f, R0 = 0, C.update(F0, $0);
      C.update(G0, R0), C.update(u, X0), H.viewport(R0, $0, S, f), H.scissor(R0, $0, S, f), l.render(), ++Q0, R0 += S;
    }
    K.flush();
  }
  if (Uh0(Z, l), Z0(W, !0), E)
    Fh0(Z, l), Z0(n, !0), Lh0(Z, l), Z0(W, !1);
  return { texture: W, scale: w, bbox: V, gridDim: P, gridTexDim: m, gridDataDim: P, gridTexScale: i, radiusFactor: r, resolution: z, maxRadius: I };
}
function j_1(Z, J, $, X, Y, Q) {
  let { gl: W, resources: K, state: G, extensions: { colorBufferFloat: H, textureFloat: N, colorBufferHalfFloat: q, textureHalfFloat: U } } = Z, { smoothness: F, resolution: E } = Y, { drawCount: R, positions: z, radii: D, groups: A, scale: B, expandedBox: T, dim: w, maxRadius: V } = Hh0(J, $, X, Y), [P, I, S] = w, f = Kh0("min-dist-3d", Z, "volume-uint8", "rgba", "ubyte", "nearest");
  f.define(P, I, S);
  let v = h0.create(1, 1), h = V * 2, x = Nh0(Z, R, z, D, A, f, T, w, w, v, F, E, h), { uCurrentSlice: b } = x.values, g = Wh0(Z);
  if (g.bind(), qh0(Z), G.viewport(0, 0, P, I), G.scissor(0, 0, P, I), !Q)
    Q = q && U ? K.texture("volume-float16", "rgba", "fp16", "linear") : H && N ? K.texture("volume-float32", "rgba", "float", "linear") : K.texture("volume-uint8", "rgba", "ubyte", "linear");
  Q.define(P, I, S);
  function m(i, r) {
    G.currentRenderItemId = -1;
    for (let Y0 = 0;Y0 < S; ++Y0) {
      if (C.update(b, Y0), i.attachFramebuffer(g, 0, Y0), r)
        W.clear(W.COLOR_BUFFER_BIT);
      x.render();
    }
    W.flush();
  }
  return Uh0(Z, x), m(Q, !0), Fh0(Z, x), m(f, !0), Lh0(Z, x), m(Q, !1), { texture: Q, scale: B, bbox: T, gridDim: w, gridTexDim: w, gridDataDim: w, gridTexScale: v, radiusFactor: h, resolution: E, maxRadius: V };
}
function Hh0(Z, J, $, X) {
  let { resolution: Y, radiusOffset: Q } = X, W = 1 / Y, { indices: K, x: G, y: H, z: N, id: q } = Z, U = f0.size(K), F = new Float32Array(U * 3), E = new Float32Array(U), R = new Float32Array(U), z = 0;
  for (let V = 0;V < U; ++V) {
    let P = f0.getAt(K, V);
    F[V * 3] = G[P], F[V * 3 + 1] = H[P], F[V * 3 + 2] = N[P];
    let I = $(P) + Q;
    if (z < I)
      z = I;
    E[V] = I, R[V] = q ? q[V] : V;
  }
  let D = z * 2 + Y * 4, A = t1.expand(t1(), J, M.create(D, D, D)), B = t1.scale(t1(), A, W), T = t1.size(M(), B);
  M.ceil(T, T);
  let w = M.create(Y, Y, Y);
  return { drawCount: U, positions: F, radii: E, groups: R, scale: w, expandedBox: A, dim: T, maxRadius: z };
}
function Nh0(Z, J, $, X, Y, Q, W, K, G, H, N, q, U) {
  if (Z.namedComputeRenderables[nq]) {
    let F = M.sub(M(), W.max, W.min), E = Z.namedComputeRenderables[nq].values;
    C.updateIfChanged(E.drawCount, J), C.updateIfChanged(E.instanceCount, 1), C.update(E.aRadius, X), C.update(E.aPosition, $), C.update(E.aGroup, Y), C.updateIfChanged(E.uCurrentSlice, 0), C.updateIfChanged(E.uCurrentX, 0), C.updateIfChanged(E.uCurrentY, 0), C.update(E.uBboxMin, W.min), C.update(E.uBboxSize, F), C.update(E.uGridDim, K), C.update(E.uGridTexDim, G), C.update(E.uGridTexScale, H), C.updateIfChanged(E.uAlpha, N), C.updateIfChanged(E.uResolution, q), C.updateIfChanged(E.uRadiusFactorInv, 1 / U), C.update(E.tMinDistanceTex, Q), C.updateIfChanged(E.dGridTexType, Q.getDepth() > 0 ? "3d" : "2d"), C.updateIfChanged(E.dCalcType, "density"), Z.namedComputeRenderables[nq].update();
  } else
    Z.namedComputeRenderables[nq] = T_1(Z, J, $, X, Y, Q, W, K, G, H, N, q, U);
  return Z.namedComputeRenderables[nq];
}
function T_1(Z, J, $, X, Y, Q, W, K, G, H, N, q, U) {
  let F = M.sub(M(), W.max, W.min), E = {
    drawCount: C.create(J),
    instanceCount: C.create(1),
    aRadius: C.create(X),
    aPosition: C.create($),
    aGroup: C.create(Y),
    uCurrentSlice: C.create(0),
    uCurrentX: C.create(0),
    uCurrentY: C.create(0),
    uBboxMin: C.create(W.min),
    uBboxSize: C.create(F),
    uGridDim: C.create(K),
    uGridTexDim: C.create(G),
    uGridTexScale: C.create(H),
    uAlpha: C.create(N),
    uResolution: C.create(q),
    uRadiusFactorInv: C.create(1 / U),
    tMinDistanceTex: C.create(Q),
    dGridTexType: C.create(Q.getDepth() > 0 ? "3d" : "2d"),
    dCalcType: C.create("density")
  }, R = { ...M_1 }, z = v8(nq, Yh0, Qh0), D = t8(Z, "points", z, R, E);
  return e8(D, E);
}
function qh0(Z) {
  let { gl: J, state: $ } = Z;
  $.disable(J.CULL_FACE), $.enable(J.BLEND), $.disable(J.DEPTH_TEST), $.enable(J.SCISSOR_TEST), $.depthMask(!1), $.clearColor(0, 0, 0, 0);
}
function Fh0(Z, J) {
  let { gl: $, state: X } = Z;
  if (C.update(J.values.dCalcType, "minDistance"), J.update(), X.colorMask(!1, !1, !1, !0), X.blendFunc($.ONE, $.ONE), !Z.extensions.blendMinMax)
    throw new Error("GPU gaussian surface calculation requires EXT_blend_minmax");
  X.blendEquation(Z.extensions.blendMinMax.MAX);
}
function Uh0(Z, J) {
  let { gl: $, state: X } = Z;
  C.update(J.values.dCalcType, "density"), J.update(), X.colorMask(!1, !1, !1, !0), X.blendFunc($.ONE, $.ONE), X.blendEquation($.FUNC_ADD);
}
function Lh0(Z, J) {
  let { gl: $, state: X } = Z;
  C.update(J.values.dCalcType, "groupId"), J.update(), X.colorMask(!0, !0, !0, !1), X.blendFunc($.ONE, $.ZERO), X.blendEquation($.FUNC_ADD);
}
function __1(Z) {
  let J = Z[0] * Z[1] * Z[2], $ = Math.sqrt(J), X = Math.pow(2, Math.ceil(Math.log($) / Math.log(2))), Y = 0, Q = Z[1], W = 1, K = Z[2];
  if (X < Z[0] * Z[2])
    K = Math.floor(X / Z[0]), W = Math.ceil(Z[2] / K), Y = K * Z[0], Q *= W;
  else
    Y = Z[0] * Z[2];
  return { texDimX: Y, texDimY: Q, texRows: W, texCols: K, powerOfTwoSize: Q < X ? X : X * 2 };
}

// node_modules/molstar/lib/mol-math/geometry/gaussian-density/cpu.js
async function AZ0(Z, J, $, X, Y) {
  let { resolution: Q, radiusOffset: W, smoothness: K } = Y, G = 1 / Q, { indices: H, x: N, y: q, z: U, id: F } = J, E = f0.size(H), R = new Float32Array(E), z = 0;
  for (let t = 0;t < E; ++t) {
    let Z0 = X(f0.getAt(H, t)) + W;
    if (z < Z0)
      z = Z0;
    R[t] = Z0;
  }
  let D = z * 2 + Q, A = t1.expand(t1(), $, M.create(D, D, D)), B = A.min, T = t1.scale(t1(), A, G), w = t1.size(M(), T);
  M.ceil(w, w);
  let V = M8.Space(w, [0, 1, 2], Float32Array), P = V.create(), I = M8.create(V, P), S = V.create();
  S.fill(-1);
  let f = M8.create(V, S), [v, h, x] = w, b = x, g = h, m = b * g, i = UR(w[0], B[0], Q), r = UR(w[1], B[1], Q), Y0 = UR(w[2], B[2], Q), c = V.create(), n = K, l = Math.ceil(1e5 / (Math.pow(Math.pow(z, 3), 3) * G));
  function u(t, Z0) {
    for (let U0 = t;U0 < Z0; ++U0) {
      let a = f0.getAt(H, U0), Q0 = N[a], $0 = q[a], R0 = U[a], X0 = R[U0], V0 = 1 / (X0 * X0), u0 = X0 * 2, N0 = u0 * u0, q0 = Math.ceil(u0 * G), A0 = Math.floor(G * (Q0 - B[0])), S0 = Math.floor(G * ($0 - B[1])), a0 = Math.floor(G * (R0 - B[2])), D1 = Math.max(0, A0 - q0), Y1 = Math.max(0, S0 - q0), u1 = Math.max(0, a0 - q0), b0 = Math.min(v, A0 + q0 + 2), x0 = Math.min(h, S0 + q0 + 2), m0 = Math.min(x, a0 + q0 + 2);
      for (let e0 = D1;e0 < b0; ++e0) {
        let p = i[e0] - Q0, J0 = e0 * m;
        for (let T0 = Y1;T0 < x0; ++T0) {
          let o0 = r[T0] - $0, y0 = p * p + o0 * o0, $1 = T0 * b + J0;
          for (let F1 = u1;F1 < m0; ++F1) {
            let A1 = Y0[F1] - R0, P1 = y0 + A1 * A1;
            if (P1 <= N0) {
              let S1 = zj0(-n * (P1 * V0)), _1 = F1 + $1;
              if (P[_1] += S1, S1 > c[_1])
                c[_1] = S1, S[_1] = F ? F[U0] : U0;
            }
          }
        }
      }
    }
  }
  async function G0() {
    for (let t = 0;t < E; t += l)
      if (u(t, Math.min(t + l, E)), Z.shouldUpdate)
        await Z.update({ message: "filling density grid", current: t, max: E });
  }
  await G0();
  let F0 = e.identity();
  return e.fromScaling(F0, M.create(Q, Q, Q)), e.setTranslation(F0, A.min), { field: I, idField: f, transform: F0, radiusFactor: 1, resolution: Q, maxRadius: z };
}

// node_modules/molstar/lib/mol-repr/structure/visual/util/gaussian.js
var pE = {
  resolution: j.Numeric(1, { min: 0.1, max: 20, step: 0.1 }, { description: "Grid resolution/cell spacing.", ...q1.CustomQualityParamInfo }),
  radiusOffset: j.Numeric(0, { min: 0, max: 10, step: 0.1 }, { description: "Extra/offset radius added to the atoms/coarse elements for gaussian calculation. Useful to create coarse, low resolution surfaces." }),
  smoothness: j.Numeric(1.5, { min: 0.5, max: 2.5, step: 0.1 }, { description: "Smoothness of the gausian surface, lower is smoother." }),
  ...cz
}, px8 = j.getDefaultValues(pE);
function Rh0(Z, J) {
  let $ = Z.maxTextureSize / 3;
  return $ * $ / Math.max(1, J ? J.units.length / 16 : 1);
}
function zm(Z, J, $, X) {
  let { position: Y, boundary: Q, radius: W } = KB(Z, J, $, X), K = jq(Q.box, X);
  return n0.create("Gaussian Density", async (G) => {
    return await AZ0(G, Y, Q.box, W, K);
  });
}
function Eh0(Z, J, $, X, Y, Q) {
  let { position: W, boundary: K, radius: G } = KB(Z, J, $, X), H = jq(K.box, X, Rh0(Y, Z));
  return MZ0(Y, W, K.box, G, H, Q);
}
function Oh0(Z, J, $, X, Y, Q, W) {
  let { position: K, boundary: G, radius: H } = KB(Z, J, $, Y), N = jq(G.box, Y, Rh0(Q, Z));
  return Om(Q, K, G.box, H, X, N, W);
}
function zh0(Z, J, $) {
  let { position: X, boundary: Y, radius: Q } = GB(Z, J, $), W = jq(Y.box, $);
  return n0.create("Gaussian Density", async (K) => {
    return await AZ0(K, X, Y.box, Q, W);
  });
}
function Dh0(Z, J, $, X, Y) {
  let { position: Q, boundary: W, radius: K } = GB(Z, J, $), G = jq(W.box, $);
  return MZ0(X, Q, W.box, K, G, Y);
}
function Mh0(Z, J, $, X, Y, Q) {
  let { box: W } = Z.lookup3d.boundary, { position: K, boundary: G, radius: H } = GB(Z, J, X), N = jq(G.box, X);
  return Om(Y, K, W, H, $, N, Q);
}

// node_modules/molstar/lib/mol-repr/structure/visual/gaussian-surface-mesh.js
var Ah0 = {
  ...pE,
  ...Ph,
  ignoreHydrogens: j.Boolean(!1),
  ignoreHydrogensVariant: j.Select("all", j.arrayToOptions(["all", "non-polar"])),
  tryUseGpu: j.Boolean(!0),
  includeParent: j.Boolean(!1, { isHidden: !0 })
}, Dm = {
  ...nZ,
  ...g_0,
  ...Ah0
}, Bh0 = {
  ...tQ,
  ...C_0,
  ...Ah0
};
function wh0(Z) {
  return Z.extensions.colorBufferFloat && Z.extensions.textureFloat && Z.extensions.textureFloatLinear && Z.extensions.blendMinMax && Z.extensions.drawBuffers;
}
function vw(Z, J, $) {
  if (J.resolution > 1)
    return !1;
  let X = $.maxTextureSize / 3, { areaCells: Y, maxAreaCells: Q } = f00(Z.boundary.box, J.resolution, X * X);
  return Y < Q;
}
function jh0(Z, J, $, X) {
  if ($.tryUseGpu && X && wh0(X) && vw(J, $, X))
    return v_1(Z);
  return I_1(Z);
}
function Th0(Z, J, $, X) {
  if ($.tryUseGpu && X && wh0(X) && vw(J, $, X))
    return f_1(Z);
  return C_1(Z);
}
async function V_1(Z, J, $, X, Y, Q) {
  let { smoothness: W } = Y, { transform: K, field: G, idField: H, radiusFactor: N, resolution: q, maxRadius: U } = await zm($, J, X.size, Y).runInContext(Z.runtime), F = {
    isoLevel: Math.exp(-W) / N,
    scalarField: G,
    idField: H
  }, E = await Fq(F, Q).runAsChild(Z.runtime);
  if (E.meta.resolution = q, n1.transform(E, K), Z.webgl && !Z.webgl.isWebGL2)
    n1.uniformTriangleGroup(E), C.updateIfChanged(E.varyingGroup, !1);
  else
    C.updateIfChanged(E.varyingGroup, !0);
  let R = C0.expand(C0(), J.boundary.sphere, U);
  return E.setBoundingSphere(R), E;
}
function I_1(Z) {
  return A9({
    defaultProps: j.getDefaultValues(Dm),
    createGeometry: V_1,
    createLocationIterator: _9.fromGroup,
    getLoci: UX,
    eachLocation: FX,
    setUpdateState: (J, $, X) => {
      if ($.resolution !== X.resolution)
        J.createGeometry = !0;
      if ($.radiusOffset !== X.radiusOffset)
        J.createGeometry = !0;
      if ($.smoothness !== X.smoothness)
        J.createGeometry = !0;
      if ($.ignoreHydrogens !== X.ignoreHydrogens)
        J.createGeometry = !0;
      if ($.ignoreHydrogensVariant !== X.ignoreHydrogensVariant)
        J.createGeometry = !0;
      if ($.traceOnly !== X.traceOnly)
        J.createGeometry = !0;
      if ($.includeParent !== X.includeParent)
        J.createGeometry = !0;
      if ($.smoothColors.name !== X.smoothColors.name)
        J.updateColor = !0;
      else if ($.smoothColors.name === "on" && X.smoothColors.name === "on") {
        if ($.smoothColors.params.resolutionFactor !== X.smoothColors.params.resolutionFactor)
          J.updateColor = !0;
        if ($.smoothColors.params.sampleStride !== X.smoothColors.params.sampleStride)
          J.updateColor = !0;
      }
    },
    mustRecreate: (J, $, X) => {
      return $.tryUseGpu && !!X && vw(J.structure, $, X);
    },
    processValues: (J, $, X, Y, Q) => {
      let { resolution: W, colorTexture: K } = $.meta, G = FQ(X.smoothColors, Y.color.preferSmoothing, W);
      if (G)
        bA(J, G.resolution, G.stride, Q, K), $.meta.colorTexture = J.tColorGrid.ref.value;
    },
    dispose: (J) => {
      var $;
      ($ = J.meta.colorTexture) === null || $ === void 0 || $.destroy();
    }
  }, Z);
}
async function P_1(Z, J, $, X, Y) {
  let { smoothness: Q } = X, { transform: W, field: K, idField: G, radiusFactor: H, resolution: N, maxRadius: q } = await zh0(J, $.size, X).runInContext(Z.runtime), U = {
    isoLevel: Math.exp(-Q) / H,
    scalarField: K,
    idField: G
  }, F = await Fq(U, Y).runAsChild(Z.runtime);
  if (F.meta.resolution = N, n1.transform(F, W), Z.webgl && !Z.webgl.isWebGL2)
    n1.uniformTriangleGroup(F), C.updateIfChanged(F.varyingGroup, !1);
  else
    C.updateIfChanged(F.varyingGroup, !0);
  let E = C0.expand(C0(), J.boundary.sphere, q);
  return F.setBoundingSphere(E), F;
}
function C_1(Z) {
  return D$({
    defaultProps: j.getDefaultValues(Bh0),
    createGeometry: P_1,
    createLocationIterator: _9.fromStructure,
    getLoci: RX,
    eachLocation: LX,
    setUpdateState: (J, $, X) => {
      if ($.resolution !== X.resolution)
        J.createGeometry = !0;
      if ($.radiusOffset !== X.radiusOffset)
        J.createGeometry = !0;
      if ($.smoothness !== X.smoothness)
        J.createGeometry = !0;
      if ($.ignoreHydrogens !== X.ignoreHydrogens)
        J.createGeometry = !0;
      if ($.ignoreHydrogensVariant !== X.ignoreHydrogensVariant)
        J.createGeometry = !0;
      if ($.traceOnly !== X.traceOnly)
        J.createGeometry = !0;
      if ($.smoothColors.name !== X.smoothColors.name)
        J.updateColor = !0;
      else if ($.smoothColors.name === "on" && X.smoothColors.name === "on") {
        if ($.smoothColors.params.resolutionFactor !== X.smoothColors.params.resolutionFactor)
          J.updateColor = !0;
        if ($.smoothColors.params.sampleStride !== X.smoothColors.params.sampleStride)
          J.updateColor = !0;
      }
    },
    mustRecreate: (J, $, X) => {
      return $.tryUseGpu && !!X && vw(J, $, X);
    },
    processValues: (J, $, X, Y, Q) => {
      let { resolution: W, colorTexture: K } = $.meta, G = FQ(X.smoothColors, Y.color.preferSmoothing, W);
      if (G)
        bA(J, G.resolution, G.stride, Q, K), $.meta.colorTexture = J.tColorGrid.ref.value;
    },
    dispose: (J) => {
      var $;
      ($ = J.meta.colorTexture) === null || $ === void 0 || $.destroy();
    }
  }, Z);
}
var kw = "gaussian-surface";
function k_1(Z, J, $, X, Y, Q) {
  let { webgl: W } = Z;
  if (!W)
    throw new Error("webgl context required to create gaussian surface texture-mesh");
  let { namedTextures: K, resources: G, extensions: { colorBufferFloat: H, textureFloat: N, colorBufferHalfFloat: q, textureHalfFloat: U } } = W;
  if (!K[kw])
    K[kw] = q && U ? G.texture("image-float16", "rgba", "fp16", "linear") : H && N ? G.texture("image-float32", "rgba", "float", "linear") : G.texture("image-uint8", "rgba", "ubyte", "linear");
  let F = M.create(0, 1, 2), E = J.elements.length, R = (D) => {
    if (K1)
      W.timer.mark("createGaussianSurfaceTextureMesh");
    let A = Oh0($, J, X.size, !0, Y, W, K[kw]), B = Math.exp(-Y.smoothness) / A.radiusFactor, T = D === null || D === void 0 ? void 0 : D.doubleBuffer.get(), w = xz(W, A.texture, A.gridDim, A.gridTexDim, A.gridDataDim, A.gridTexScale, A.transform, B, !1, !0, F, !0, T === null || T === void 0 ? void 0 : T.vertex, T === null || T === void 0 ? void 0 : T.group, T === null || T === void 0 ? void 0 : T.normal);
    if (K1)
      W.timer.markEnd("createGaussianSurfaceTextureMesh");
    let V = C0.expand(C0(), J.boundary.sphere, A.maxRadius), P = iJ.create(w.vertexCount, E, w.vertexTexture, w.groupTexture, w.normalTexture, V, D);
    return P.meta.resolution = A.resolution, P;
  }, z = R(Q);
  return z.meta.webgl = W, z.meta.reset = () => {
    R(z);
  }, z;
}
function v_1(Z) {
  return m_0({
    defaultProps: j.getDefaultValues(Dm),
    createGeometry: k_1,
    createLocationIterator: _9.fromGroup,
    getLoci: UX,
    eachLocation: FX,
    setUpdateState: (J, $, X) => {
      if ($.resolution !== X.resolution)
        J.createGeometry = !0;
      if ($.radiusOffset !== X.radiusOffset)
        J.createGeometry = !0;
      if ($.smoothness !== X.smoothness)
        J.createGeometry = !0;
      if ($.ignoreHydrogens !== X.ignoreHydrogens)
        J.createGeometry = !0;
      if ($.ignoreHydrogensVariant !== X.ignoreHydrogensVariant)
        J.createGeometry = !0;
      if ($.traceOnly !== X.traceOnly)
        J.createGeometry = !0;
      if ($.includeParent !== X.includeParent)
        J.createGeometry = !0;
      if ($.smoothColors.name !== X.smoothColors.name)
        J.updateColor = !0;
      else if ($.smoothColors.name === "on" && X.smoothColors.name === "on") {
        if ($.smoothColors.params.resolutionFactor !== X.smoothColors.params.resolutionFactor)
          J.updateColor = !0;
        if ($.smoothColors.params.sampleStride !== X.smoothColors.params.sampleStride)
          J.updateColor = !0;
      }
    },
    mustRecreate: (J, $, X) => {
      return !$.tryUseGpu || !X || !vw(J.structure, $, X);
    },
    processValues: (J, $, X, Y, Q) => {
      let { resolution: W, colorTexture: K } = $.meta, G = FQ(X.smoothColors, Y.color.preferSmoothing, W);
      if (G && Q)
        St(J, G.resolution, G.stride, Q, K), $.meta.colorTexture = J.tColorGrid.ref.value;
    },
    dispose: (J) => {
      var $;
      J.vertexTexture.ref.value.destroy(), J.groupTexture.ref.value.destroy(), J.normalTexture.ref.value.destroy(), J.doubleBuffer.destroy(), ($ = J.meta.colorTexture) === null || $ === void 0 || $.destroy();
    }
  }, Z);
}
function S_1(Z, J, $, X, Y) {
  let { webgl: Q } = Z;
  if (!Q)
    throw new Error("webgl context required to create structure gaussian surface texture-mesh");
  let { namedTextures: W, resources: K, extensions: { colorBufferFloat: G, textureFloat: H, colorBufferHalfFloat: N, textureHalfFloat: q } } = Q;
  if (!W[kw])
    W[kw] = N && q ? K.texture("image-float16", "rgba", "fp16", "linear") : G && H ? K.texture("image-float32", "rgba", "float", "linear") : K.texture("image-uint8", "rgba", "ubyte", "linear");
  let U = M.create(0, 1, 2), F = J.elementCount, E = (z) => {
    if (K1)
      Q.timer.mark("createStructureGaussianSurfaceTextureMesh");
    let D = Mh0(J, $.size, !0, X, Q, W[kw]), A = Math.exp(-X.smoothness) / D.radiusFactor, B = z === null || z === void 0 ? void 0 : z.doubleBuffer.get(), T = xz(Q, D.texture, D.gridDim, D.gridTexDim, D.gridDataDim, D.gridTexScale, D.transform, A, !1, !0, U, !0, B === null || B === void 0 ? void 0 : B.vertex, B === null || B === void 0 ? void 0 : B.group, B === null || B === void 0 ? void 0 : B.normal);
    if (K1)
      Q.timer.markEnd("createStructureGaussianSurfaceTextureMesh");
    let w = C0.expand(C0(), J.boundary.sphere, D.maxRadius), V = iJ.create(T.vertexCount, F, T.vertexTexture, T.groupTexture, T.normalTexture, w, z);
    return V.meta.resolution = D.resolution, V;
  }, R = E(Y);
  return R.meta.webgl = Q, R.meta.reset = () => {
    E(R);
  }, R;
}
function f_1(Z) {
  return k_0({
    defaultProps: j.getDefaultValues(Bh0),
    createGeometry: S_1,
    createLocationIterator: _9.fromStructure,
    getLoci: RX,
    eachLocation: LX,
    setUpdateState: (J, $, X) => {
      if ($.resolution !== X.resolution)
        J.createGeometry = !0;
      if ($.radiusOffset !== X.radiusOffset)
        J.createGeometry = !0;
      if ($.smoothness !== X.smoothness)
        J.createGeometry = !0;
      if ($.ignoreHydrogens !== X.ignoreHydrogens)
        J.createGeometry = !0;
      if ($.ignoreHydrogensVariant !== X.ignoreHydrogensVariant)
        J.createGeometry = !0;
      if ($.traceOnly !== X.traceOnly)
        J.createGeometry = !0;
      if ($.includeParent !== X.includeParent)
        J.createGeometry = !0;
      if ($.smoothColors.name !== X.smoothColors.name)
        J.updateColor = !0;
      else if ($.smoothColors.name === "on" && X.smoothColors.name === "on") {
        if ($.smoothColors.params.resolutionFactor !== X.smoothColors.params.resolutionFactor)
          J.updateColor = !0;
        if ($.smoothColors.params.sampleStride !== X.smoothColors.params.sampleStride)
          J.updateColor = !0;
      }
    },
    mustRecreate: (J, $, X) => {
      return !$.tryUseGpu || !X || !vw(J, $, X);
    },
    processValues: (J, $, X, Y, Q) => {
      let { resolution: W, colorTexture: K } = $.meta, G = FQ(X.smoothColors, Y.color.preferSmoothing, W);
      if (G && Q)
        St(J, G.resolution, G.stride, Q, K), $.meta.colorTexture = J.tColorGrid.ref.value;
    },
    dispose: (J) => {
      var $;
      J.vertexTexture.ref.value.destroy(), J.groupTexture.ref.value.destroy(), J.normalTexture.ref.value.destroy(), J.doubleBuffer.destroy(), ($ = J.meta.colorTexture) === null || $ === void 0 || $.destroy();
    }
  }, Z);
}

// node_modules/molstar/lib/mol-repr/structure/visual/gaussian-surface-wireframe.js
async function h_1(Z, J, $, X, Y, Q) {
  let { smoothness: W } = Y, { transform: K, field: G, idField: H, maxRadius: N } = await zm($, J, X.size, Y).runInContext(Z.runtime), q = {
    isoLevel: Math.exp(-W),
    scalarField: G,
    idField: H
  }, U = await nA(q, Q).runAsChild(Z.runtime);
  f6.transform(U, K);
  let F = C0.expand(C0(), J.boundary.sphere, N);
  return U.setBoundingSphere(F), U;
}
var BZ0 = {
  ...KE,
  ...pE,
  sizeFactor: j.Numeric(3, { min: 0, max: 10, step: 0.1 }),
  lineSizeAttenuation: j.Boolean(!1),
  ignoreHydrogens: j.Boolean(!1),
  ignoreHydrogensVariant: j.Select("all", j.arrayToOptions(["all", "non-polar"])),
  includeParent: j.Boolean(!1, { isHidden: !0 })
};
function _h0(Z) {
  return GE({
    defaultProps: j.getDefaultValues(BZ0),
    createGeometry: h_1,
    createLocationIterator: _9.fromGroup,
    getLoci: UX,
    eachLocation: FX,
    setUpdateState: (J, $, X) => {
      if ($.resolution !== X.resolution)
        J.createGeometry = !0;
      if ($.radiusOffset !== X.radiusOffset)
        J.createGeometry = !0;
      if ($.smoothness !== X.smoothness)
        J.createGeometry = !0;
      if ($.ignoreHydrogens !== X.ignoreHydrogens)
        J.createGeometry = !0;
      if ($.ignoreHydrogensVariant !== X.ignoreHydrogensVariant)
        J.createGeometry = !0;
      if ($.traceOnly !== X.traceOnly)
        J.createGeometry = !0;
      if ($.includeParent !== X.includeParent)
        J.createGeometry = !0;
    }
  }, Z);
}

// node_modules/molstar/lib/mol-repr/structure/representation/gaussian-surface.js
var Vh0 = {
  "gaussian-surface-mesh": (Z, J) => _Z("Gaussian surface mesh", Z, J, jh0),
  "structure-gaussian-surface-mesh": (Z, J) => M9("Structure-Gaussian surface mesh", Z, J, Th0),
  "gaussian-surface-wireframe": (Z, J) => _Z("Gaussian surface wireframe", Z, J, _h0)
}, Ih0 = {
  ...Dm,
  ...BZ0,
  visuals: j.MultiSelect(["gaussian-surface-mesh"], j.objectToOptions(Vh0)),
  bumpFrequency: j.Numeric(1, { min: 0, max: 10, step: 0.1 }, q1.ShadingCategory),
  density: j.Numeric(0.5, { min: 0, max: 1, step: 0.01 }, q1.ShadingCategory)
};
function b_1(Z, J) {
  return Ih0;
}
function x_1(Z, J) {
  return V2.createMulti("Gaussian Surface", Z, J, lZ, Vh0);
}
var Ph0 = v9({
  name: "gaussian-surface",
  label: "Gaussian Surface",
  description: "Displays a gaussian molecular surface.",
  factory: x_1,
  getParams: b_1,
  defaultValues: j.getDefaultValues(Ih0),
  defaultColorTheme: { name: "chain-id" },
  defaultSizeTheme: { name: "physical" },
  isApplicable: (Z) => Z.elementCount > 0
});

// node_modules/molstar/lib/mol-repr/structure/visual/label-text.js
var wZ0 = {
  ...__0,
  background: j.Boolean(!1),
  backgroundMargin: j.Numeric(0, { min: 0, max: 1, step: 0.01 }),
  backgroundColor: j.Color(c2.black),
  backgroundOpacity: j.Numeric(0.5, { min: 0, max: 1, step: 0.01 }),
  borderWidth: j.Numeric(0.25, { min: 0, max: 0.5, step: 0.01 }),
  level: j.Select("residue", [["chain", "Chain"], ["residue", "Residue"], ["element", "Element"]], { isEssential: !0 }),
  ignoreHydrogens: j.Boolean(!1),
  ignoreHydrogensVariant: j.Select("all", j.arrayToOptions(["all", "non-polar"])),
  chainScale: j.Numeric(10, { min: 0, max: 20, step: 0.1 }),
  residueScale: j.Numeric(1, { min: 0, max: 20, step: 0.1 }),
  elementScale: j.Numeric(0.5, { min: 0, max: 20, step: 0.1 })
};
function Ch0(Z) {
  return V_0({
    defaultProps: j.getDefaultValues(wZ0),
    createGeometry: y_1,
    createLocationIterator: _9.fromStructure,
    getLoci: RX,
    eachLocation: LX,
    setUpdateState: (J, $, X) => {
      J.createGeometry = $.level !== X.level || $.level === "chain" && $.chainScale !== X.chainScale || $.level === "residue" && $.residueScale !== X.residueScale || $.level === "element" && $.elementScale !== X.elementScale || $.ignoreHydrogens !== X.ignoreHydrogens || $.ignoreHydrogensVariant !== X.ignoreHydrogensVariant;
    }
  }, Z);
}
function y_1(Z, J, $, X, Y) {
  switch (X.level) {
    case "chain":
      return g_1(Z, J, $, X, Y);
    case "residue":
      return m_1(Z, J, $, X, Y);
    case "element":
      return d_1(Z, J, $, X, Y);
  }
}
var wG = M(), IP = new $J("98");
function g_1(Z, J, $, X, Y) {
  let Q = W0.Location.create(J), { units: W, serialMapping: K } = J, { auth_asym_id: G, label_asym_id: H } = w1.chain, { cumulativeUnitElementCount: N } = K, q = W.length, { chainScale: U } = X, F = iQ.create(X, q, q / 2, Y);
  for (let E = 0, R = W.length;E < R; ++E) {
    let z = W[E];
    Q.unit = z, Q.element = z.elements[0];
    let { center: D, radius: A } = z.lookup3d.boundary.sphere;
    M.transformMat4(wG, D, z.conformation.operator.matrix);
    let B = G(Q), T = H(Q), w = B === T ? T : `${T} [${B}]`;
    F.add(w, wG[0], wG[1], wG[2], A, U, N[E]);
  }
  return F.getText();
}
function m_1(Z, J, $, X, Y) {
  let Q = W0.Location.create(J), { units: W, serialMapping: K } = J, { label_comp_id: G } = w1.atom, { auth_seq_id: H } = w1.residue, { cumulativeUnitElementCount: N } = K, q = J.polymerResidueCount * 2, { residueScale: U } = X, F = iQ.create(X, q, q / 2, Y);
  for (let E = 0, R = W.length;E < R; ++E) {
    let z = W[E], D = z.conformation, { elements: A } = z;
    Q.unit = z, Q.element = z.elements[0];
    let B = z.model.atomicHierarchy.residueAtomSegments.index, T = N[E], w = 0, V = A.length;
    while (w < V) {
      let P = w, I = B[A[w]];
      w++;
      while (w < V && B[A[w]] === I)
        w++;
      IP.reset();
      for (let b = P;b < w; b++)
        D.position(A[b], wG), IP.includePosition(wG);
      IP.finishedIncludeStep();
      for (let b = P;b < w; b++)
        D.position(A[b], wG), IP.radiusPosition(wG);
      Q.element = A[P];
      let { center: S, radius: f } = IP.getSphere(), v = H(Q), x = `${G(Q)} ${v}`;
      F.add(x, S[0], S[1], S[2], f, U, T + P);
    }
  }
  return F.getText();
}
function d_1(Z, J, $, X, Y) {
  let Q = W0.Location.create(J), { units: W, serialMapping: K } = J, { label_atom_id: G, label_alt_id: H } = w1.atom, { cumulativeUnitElementCount: N } = K, q = $.size, U = J.elementCount, { elementScale: F } = X, E = iQ.create(X, U, U / 2, Y);
  for (let R = 0, z = W.length;R < z; ++R) {
    let D = W[R], A = D.conformation, { elements: B } = D;
    Q.unit = D;
    let T = N[R], w = tW(J, D, { ...X, traceOnly: !1 });
    for (let V = 0, P = B.length;V < P; V++) {
      if (w && w(B[V]))
        continue;
      Q.element = B[V], A.position(Q.element, wG);
      let I = G(Q), S = H(Q), f = S ? `${I}%${S}` : I;
      E.add(f, wG[0], wG[1], wG[2], q.size(Q), F, T + V);
    }
  }
  return E.getText();
}

// node_modules/molstar/lib/mol-repr/structure/representation/label.js
var kh0 = {
  "label-text": (Z, J) => M9("Label text", Z, J, Ch0)
}, vh0 = {
  ...wZ0,
  visuals: j.MultiSelect(["label-text"], j.objectToOptions(kh0))
};
function p_1(Z, J) {
  return vh0;
}
function u_1(Z, J) {
  let $ = V2.createMulti("Label", Z, J, lZ, kh0);
  return $.setState({ pickable: !1, markerActions: x2.None }), $;
}
var Sh0 = v9({
  name: "label",
  label: "Label",
  description: "Displays labels.",
  factory: u_1,
  getParams: p_1,
  defaultValues: j.getDefaultValues(vh0),
  defaultColorTheme: { name: "uniform" },
  defaultSizeTheme: { name: "physical" },
  isApplicable: (Z) => Z.elementCount > 0
});

// node_modules/molstar/lib/mol-math/geometry/molecular-surface.js
function c_1(Z, J) {
  if (Z[0] = Z[1] = Z[2] = 1, J[0] !== 0)
    Z[0] = (J[1] + J[2]) / -J[0];
  else if (J[1] !== 0)
    Z[1] = (J[0] + J[2]) / -J[1];
  else if (J[2] !== 0)
    Z[2] = (J[0] + J[1]) / -J[2];
  return Z;
}
function l_1(Z) {
  let J = 0, $ = 2 * Math.PI / Z, X = new Float32Array(Z), Y = new Float32Array(Z);
  for (let Q = 0;Q < Z; Q++)
    X[Q] = Math.cos(J), Y[Q] = Math.sin(J), J += $;
  return { cosTable: X, sinTable: Y };
}
var PP = {
  probeRadius: j.Numeric(1.4, { min: 0, max: 10, step: 0.1 }, { description: "Radius of the probe tracing the molecular surface." }),
  resolution: j.Numeric(0.5, { min: 0.01, max: 20, step: 0.01 }, { description: "Grid resolution/cell spacing." }),
  probePositions: j.Numeric(36, { min: 12, max: 90, step: 1 }, { description: "Number of positions tested for probe target intersection." })
}, oy8 = j.getDefaultValues(PP);
async function fh0(Z, J, $, X, Y, Q) {
  let W = -1;
  function K(Y1, u1, b0, x0, m0) {
    if (W !== -1) {
      let e0 = W;
      if (e0 !== x0 && e0 !== m0 && G(e0, Y1, u1, b0))
        return e0;
      else
        W = -1;
    }
    for (let e0 = 0, p = f.count;e0 < p; ++e0) {
      let J0 = f0.getAt(v, f.indices[e0]);
      if (J0 !== x0 && J0 !== m0 && G(J0, Y1, u1, b0))
        return W = J0, J0;
    }
    return -1;
  }
  function G(Y1, u1, b0, x0) {
    let m0 = m[Y1], e0 = h[Y1] - u1, p = x[Y1] - b0, J0 = b[Y1] - x0;
    return e0 * e0 + p * p + J0 * J0 < m0 * m0;
  }
  function H(Y1, u1) {
    for (let b0 = Y1;b0 < u1; ++b0) {
      let x0 = f0.getAt(v, b0), m0 = h[x0], e0 = x[x0], p = b[x0], J0 = m[x0], T0 = J0 * J0, o0 = P > 0;
      S.find(m0, e0, p, J0);
      let y0 = Math.ceil(J0 * w) + P, $1 = Math.floor(w * (m0 - c)), F1 = Math.floor(w * (e0 - n)), A1 = Math.floor(w * (p - l)), P1 = Math.max(0, $1 - y0), S1 = Math.max(0, F1 - y0), _1 = Math.max(0, A1 - y0), a1 = Math.min(F0, $1 + y0 + 2), U2 = Math.min(t, F1 + y0 + 2), G2 = Math.min(Z0, A1 + y0 + 2);
      for (let P2 = P1;P2 < a1; ++P2) {
        let v2 = u0[P2] - m0, O8 = P2 * Q0;
        for (let n8 = S1;n8 < U2; ++n8) {
          let z6 = N0[n8] - e0, L8 = v2 * v2 + z6 * z6, R8 = n8 * U0 + O8;
          for (let w0 = _1;w0 < G2; ++w0) {
            let P0 = q0[w0] - p, l0 = L8 + P0 * P0;
            if (o0 || l0 < T0) {
              let z1 = w0 + R8, J2 = Math.sqrt(l0), N2 = J0 / J2, X8 = v2 * N2 + m0, c0 = z6 * N2 + e0, M1 = P0 * N2 + p, g1 = K(X8, c0, M1, x0, -1);
              if (l0 < T0) {
                if (E0[z1] < 0)
                  E0[z1] *= -1;
                if (g1 === -1) {
                  let l2 = J0 - J2;
                  if (l2 < E0[z1])
                    E0[z1] = l2, V0[z1] = g[b0];
                }
              } else if (o0 && g1 === -1) {
                let l2 = J0 - J2;
                if (l2 > E0[z1])
                  E0[z1] = l2;
              }
            }
          }
        }
      }
    }
  }
  async function N() {
    for (let Y1 = 0;Y1 < i; Y1 += A0)
      if (H(Y1, Math.min(Y1 + A0, i)), Z.shouldUpdate)
        await Z.update({ message: "projecting points", current: Y1, max: i });
  }
  let q = M(), U = M(), F = M(), E = M();
  function R(Y1, u1) {
    let b0 = m[Y1], x0 = m[u1], m0 = q[0] = h[u1] - h[Y1], e0 = q[1] = x[u1] - x[Y1], p = q[2] = b[u1] - b[Y1], J0 = m0 * m0 + e0 * e0 + p * p, T0 = Math.sqrt(J0), o0 = (b0 * b0 + T0 * T0 - x0 * x0) / (2 * b0 * T0), y0 = b0 * o0;
    M.normalize(q, q), c_1(F, q), M.normalize(F, F), M.cross(E, q, F), M.normalize(E, E);
    let $1 = Math.sqrt(b0 * b0 - y0 * y0);
    M.scale(F, F, $1), M.scale(E, E, $1), M.scale(q, q, y0), U[0] = q[0] + h[Y1], U[1] = q[1] + x[Y1], U[2] = q[2] + b[Y1], W = -1;
    for (let F1 = 0;F1 < T; ++F1) {
      let A1 = $0[F1], P1 = R0[F1], S1 = U[0] + A1 * F[0] + P1 * E[0], _1 = U[1] + A1 * F[1] + P1 * E[1], a1 = U[2] + A1 * F[2] + P1 * E[2];
      if (K(S1, _1, a1, Y1, u1) === -1) {
        let U2 = Math.floor(w * (S1 - c)), G2 = Math.floor(w * (_1 - n)), P2 = Math.floor(w * (a1 - l)), v2 = Math.max(0, U2 - V), O8 = Math.max(0, G2 - V), n8 = Math.max(0, P2 - V), z6 = Math.min(F0, U2 + V + 2), L8 = Math.min(t, G2 + V + 2), R8 = Math.min(Z0, P2 + V + 2);
        for (let w0 = v2;w0 < z6; ++w0) {
          let P0 = S1 - u0[w0], l0 = w0 * Q0;
          for (let z1 = O8;z1 < L8; ++z1) {
            let J2 = _1 - N0[z1], N2 = P0 * P0 + J2 * J2, X8 = z1 * U0 + l0;
            for (let c0 = n8;c0 < R8; ++c0) {
              let M1 = a1 - q0[c0], g1 = N2 + M1 * M1, l2 = c0 + X8, d8 = E0[l2];
              if (d8 > 0 && g1 < d8 * d8) {
                E0[l2] = Math.sqrt(g1);
                let I1 = P0 * q[0] + J2 * q[1] + M1 * q[2];
                V0[l2] = g[f0.indexOf(v, I1 < 0 ? u1 : Y1)];
              }
            }
          }
        }
      }
    }
  }
  function z(Y1, u1) {
    for (let b0 = Y1;b0 < u1; ++b0) {
      let x0 = f0.getAt(v, b0);
      S.find(h[x0], x[x0], b[x0], m[x0]);
      for (let m0 = 0, e0 = f.count;m0 < e0; ++m0) {
        let p = f0.getAt(v, f.indices[m0]);
        if (x0 < p)
          R(x0, p);
      }
    }
  }
  async function D() {
    for (let Y1 = 0;Y1 < i; Y1 += A0)
      if (z(Y1, Math.min(Y1 + A0, i)), Z.shouldUpdate)
        await Z.update({ message: "projecting torii", current: Y1, max: i });
  }
  let { resolution: A, probeRadius: B, probePositions: T } = Q, w = 1 / A, V = 2 + Math.floor(B * w), P = B < A * 2 ? 1 : 0, I = M.create(X, X, X);
  M.scale(I, I, 2);
  let S = TW(J, $, I), f = S.result;
  if (Y === null)
    Y = S.boundary.box;
  let { indices: v, x: h, y: x, z: b, id: g, radius: m } = J, i = f0.size(v), r = X + A, Y0 = t1.expand(t1(), Y, M.create(r, r, r)), [c, n, l] = Y0.min, u = t1.scale(t1(), Y0, w), G0 = t1.size(M(), u);
  M.ceil(G0, G0);
  let [F0, t, Z0] = G0, U0 = Z0, a = t, Q0 = U0 * a, { cosTable: $0, sinTable: R0 } = l_1(T), X0 = M8.Space(G0, [0, 1, 2], Float32Array), E0 = X0.create(), V0 = X0.create();
  E0.fill(-1001), V0.fill(-1);
  let u0 = UR(F0, c, A), N0 = UR(t, n, A), q0 = UR(Z0, l, A), A0 = Math.ceil(1e5 / (Math.pow(Math.pow(X, 3), 3) * w));
  await N(), await D();
  let S0 = M8.create(X0, E0), a0 = M8.create(X0, V0), D1 = e.identity();
  return e.fromScaling(D1, M.create(A, A, A)), e.setTranslation(D1, Y0.min), { field: S0, idField: a0, transform: D1, resolution: A, maxRadius: X };
}

// node_modules/molstar/lib/mol-repr/structure/visual/util/molecular-surface.js
var Mm = {
  ...PP,
  resolution: { ...PP.resolution, ...q1.CustomQualityParamInfo },
  probePositions: { ...PP.probePositions, ...q1.CustomQualityParamInfo }
};
function n_1(Z, J, $, X) {
  let { probeRadius: Y } = X, { position: Q, boundary: W, radius: K } = KB(Z, J, $, X), { indices: G } = Q, H = f0.size(G), N = new Float32Array(f0.end(G)), q = 0;
  for (let U = 0;U < H; ++U) {
    let F = f0.getAt(G, U), E = K(F);
    if (q < E)
      q = E;
    N[F] = E + Y;
  }
  return { position: { ...Q, radius: N }, boundary: W, maxRadius: q };
}
function Am(Z, J, $, X) {
  let { position: Y, boundary: Q, maxRadius: W } = n_1(Z, J, $, X), K = jq(Q.box, X);
  return n0.create("Molecular Surface", async (G) => {
    return await bh0(G, Y, Q, W, Q.box, K);
  });
}
function i_1(Z, J, $) {
  let { probeRadius: X } = $, { position: Y, boundary: Q, radius: W } = GB(Z, J, $), { indices: K } = Y, G = f0.size(K), H = new Float32Array(f0.end(K)), N = 0;
  for (let q = 0;q < G; ++q) {
    let U = f0.getAt(K, q), F = W(U);
    if (N < F)
      N = F;
    H[U] = F + X;
  }
  return { position: { ...Y, radius: H }, boundary: Q, maxRadius: N };
}
function hh0(Z, J, $) {
  let { position: X, boundary: Y, maxRadius: Q } = i_1(Z, J, $), W = jq(Y.box, $);
  return n0.create("Molecular Surface", async (K) => {
    return await bh0(K, X, Y, Q, Y.box, W);
  });
}
async function bh0(Z, J, $, X, Y, Q) {
  return fh0(Z, J, $, X, Y, Q);
}

// node_modules/molstar/lib/mol-repr/structure/visual/molecular-surface-mesh.js
var Bm = {
  ...nZ,
  ...Mm,
  ...cz,
  ...Ph
};
async function o_1(Z, J, $, X, Y, Q) {
  let { transform: W, field: K, idField: G, resolution: H, maxRadius: N } = await Am($, J, X.size, Y).runInContext(Z.runtime), q = {
    isoLevel: Y.probeRadius,
    scalarField: K,
    idField: G
  }, U = await Fq(q, Q).runAsChild(Z.runtime);
  if (Y.includeParent) {
    let E = Math.ceil(2 / Y.resolution);
    n1.smoothEdges(U, { iterations: E, maxNewEdgeLength: Math.sqrt(2) });
  }
  if (n1.transform(U, W), Z.webgl && !Z.webgl.isWebGL2)
    n1.uniformTriangleGroup(U), C.updateIfChanged(U.varyingGroup, !1);
  else
    C.updateIfChanged(U.varyingGroup, !0);
  let F = C0.expand(C0(), J.boundary.sphere, N);
  return U.setBoundingSphere(F), U.meta.resolution = H, U;
}
function xh0(Z) {
  return A9({
    defaultProps: j.getDefaultValues(Bm),
    createGeometry: o_1,
    createLocationIterator: _9.fromGroup,
    getLoci: UX,
    eachLocation: FX,
    setUpdateState: (J, $, X) => {
      if ($.resolution !== X.resolution)
        J.createGeometry = !0;
      if ($.probeRadius !== X.probeRadius)
        J.createGeometry = !0;
      if ($.probePositions !== X.probePositions)
        J.createGeometry = !0;
      if ($.ignoreHydrogens !== X.ignoreHydrogens)
        J.createGeometry = !0;
      if ($.ignoreHydrogensVariant !== X.ignoreHydrogensVariant)
        J.createGeometry = !0;
      if ($.traceOnly !== X.traceOnly)
        J.createGeometry = !0;
      if ($.includeParent !== X.includeParent)
        J.createGeometry = !0;
      if ($.smoothColors.name !== X.smoothColors.name)
        J.updateColor = !0;
      else if ($.smoothColors.name === "on" && X.smoothColors.name === "on") {
        if ($.smoothColors.params.resolutionFactor !== X.smoothColors.params.resolutionFactor)
          J.updateColor = !0;
        if ($.smoothColors.params.sampleStride !== X.smoothColors.params.sampleStride)
          J.updateColor = !0;
      }
    },
    processValues: (J, $, X, Y, Q) => {
      let { resolution: W, colorTexture: K } = $.meta, G = FQ(X.smoothColors, Y.color.preferSmoothing, W);
      if (G)
        bA(J, G.resolution, G.stride, Q, K), $.meta.colorTexture = J.tColorGrid.ref.value;
    },
    dispose: (J) => {
      var $;
      ($ = J.meta.colorTexture) === null || $ === void 0 || $.destroy();
    }
  }, Z);
}
async function s_1(Z, J, $, X, Y) {
  let { transform: Q, field: W, idField: K, resolution: G, maxRadius: H } = await hh0(J, $.size, X).runInContext(Z.runtime), N = {
    isoLevel: X.probeRadius,
    scalarField: W,
    idField: K
  }, q = await Fq(N, Y).runAsChild(Z.runtime);
  if (X.includeParent) {
    let F = Math.ceil(2 / X.resolution);
    n1.smoothEdges(q, { iterations: F, maxNewEdgeLength: Math.sqrt(2) });
  }
  if (n1.transform(q, Q), Z.webgl && !Z.webgl.isWebGL2)
    n1.uniformTriangleGroup(q), C.updateIfChanged(q.varyingGroup, !1);
  else
    C.updateIfChanged(q.varyingGroup, !0);
  let U = C0.expand(C0(), J.boundary.sphere, H);
  return q.setBoundingSphere(U), q.meta.resolution = G, q;
}
function yh0(Z) {
  return D$({
    defaultProps: j.getDefaultValues(Bm),
    createGeometry: s_1,
    createLocationIterator: _9.fromStructure,
    getLoci: RX,
    eachLocation: LX,
    setUpdateState: (J, $, X) => {
      if ($.resolution !== X.resolution)
        J.createGeometry = !0;
      if ($.probeRadius !== X.probeRadius)
        J.createGeometry = !0;
      if ($.probePositions !== X.probePositions)
        J.createGeometry = !0;
      if ($.ignoreHydrogens !== X.ignoreHydrogens)
        J.createGeometry = !0;
      if ($.ignoreHydrogensVariant !== X.ignoreHydrogensVariant)
        J.createGeometry = !0;
      if ($.traceOnly !== X.traceOnly)
        J.createGeometry = !0;
      if ($.includeParent !== X.includeParent)
        J.createGeometry = !0;
      if ($.smoothColors.name !== X.smoothColors.name)
        J.updateColor = !0;
      else if ($.smoothColors.name === "on" && X.smoothColors.name === "on") {
        if ($.smoothColors.params.resolutionFactor !== X.smoothColors.params.resolutionFactor)
          J.updateColor = !0;
        if ($.smoothColors.params.sampleStride !== X.smoothColors.params.sampleStride)
          J.updateColor = !0;
      }
    },
    processValues: (J, $, X, Y, Q) => {
      let { resolution: W, colorTexture: K } = $.meta, G = FQ(X.smoothColors, Y.color.preferSmoothing, W);
      if (G)
        bA(J, G.resolution, G.stride, Q, K), $.meta.colorTexture = J.tColorGrid.ref.value;
    },
    dispose: (J) => {
      var $;
      ($ = J.meta.colorTexture) === null || $ === void 0 || $.destroy();
    }
  }, Z);
}

// node_modules/molstar/lib/mol-repr/structure/visual/molecular-surface-wireframe.js
var jZ0 = {
  ...KE,
  ...Mm,
  ...cz,
  sizeFactor: j.Numeric(1.5, { min: 0, max: 10, step: 0.1 })
};
async function a_1(Z, J, $, X, Y, Q) {
  let { transform: W, field: K, idField: G, maxRadius: H } = await Am($, J, X.size, Y).runInContext(Z.runtime), N = {
    isoLevel: Y.probeRadius,
    scalarField: K,
    idField: G
  }, q = await nA(N, Q).runAsChild(Z.runtime);
  f6.transform(q, W);
  let U = C0.expand(C0(), J.boundary.sphere, H);
  return q.setBoundingSphere(U), q;
}
function gh0(Z) {
  return GE({
    defaultProps: j.getDefaultValues(jZ0),
    createGeometry: a_1,
    createLocationIterator: _9.fromGroup,
    getLoci: UX,
    eachLocation: FX,
    setUpdateState: (J, $, X) => {
      if ($.resolution !== X.resolution)
        J.createGeometry = !0;
      if ($.probeRadius !== X.probeRadius)
        J.createGeometry = !0;
      if ($.probePositions !== X.probePositions)
        J.createGeometry = !0;
      if ($.ignoreHydrogens !== X.ignoreHydrogens)
        J.createGeometry = !0;
      if ($.ignoreHydrogensVariant !== X.ignoreHydrogensVariant)
        J.createGeometry = !0;
      if ($.includeParent !== X.includeParent)
        J.createGeometry = !0;
    }
  }, Z);
}

// node_modules/molstar/lib/mol-repr/structure/representation/molecular-surface.js
var mh0 = {
  "molecular-surface-mesh": (Z, J) => _Z("Molecular surface mesh", Z, J, xh0),
  "structure-molecular-surface-mesh": (Z, J) => M9("Structure Molecular surface mesh", Z, J, yh0),
  "molecular-surface-wireframe": (Z, J) => _Z("Molecular surface wireframe", Z, J, gh0)
}, dh0 = {
  ...Bm,
  ...jZ0,
  visuals: j.MultiSelect(["molecular-surface-mesh"], j.objectToOptions(mh0)),
  bumpFrequency: j.Numeric(1, { min: 0, max: 10, step: 0.1 }, q1.ShadingCategory),
  density: j.Numeric(0.5, { min: 0, max: 1, step: 0.01 }, q1.ShadingCategory)
};
function r_1(Z, J) {
  return dh0;
}
function t_1(Z, J) {
  return V2.createMulti("Molecular Surface", Z, J, lZ, mh0);
}
var ph0 = v9({
  name: "molecular-surface",
  label: "Molecular Surface",
  description: "Displays a molecular surface.",
  factory: t_1,
  getParams: r_1,
  defaultValues: j.getDefaultValues(dh0),
  defaultColorTheme: { name: "chain-id" },
  defaultSizeTheme: { name: "physical" },
  isApplicable: (Z) => Z.elementCount > 0
});

// node_modules/molstar/lib/mol-repr/structure/visual/orientation-ellipsoid-mesh.js
var TZ0 = {
  ...nZ,
  sizeFactor: j.Numeric(1, { min: 0, max: 2, step: 0.1 }),
  detail: j.Numeric(0, { min: 0, max: 3, step: 1 }, q1.CustomQualityParamInfo)
};
function uh0(Z) {
  return A9({
    defaultProps: j.getDefaultValues(TZ0),
    createGeometry: ZV1,
    createLocationIterator: JV1,
    getLoci: $V1,
    eachLocation: XV1,
    setUpdateState: (J, $, X) => {
      J.createGeometry = $.sizeFactor !== X.sizeFactor || $.detail !== X.detail;
    }
  }, Z);
}
function e_1(Z) {
  if (j0.Traits.is(Z.traits, j0.Trait.MultiChain))
    return !1;
  if (j0.Traits.is(Z.traits, j0.Trait.Partitioned))
    return !1;
  if (j0.isCoarse(Z))
    return !0;
  if (Z.elements.length === 0)
    return !1;
  Z.model.atomicHierarchy.derived.residue.moleculeType;
  let J = Z.residueIndex[Z.elements[0]], $ = Z.model.atomicHierarchy.derived.residue.moleculeType[J];
  if ($ === e2.Ion)
    return !1;
  if ($ === e2.Water)
    return !1;
  return !0;
}
function ZV1(Z, J, $, X, Y, Q) {
  if (!e_1(J))
    return n1.createEmpty(Q);
  let { detail: W, sizeFactor: K } = Y, G = 256, H = v1.createState(G, G / 2, Q), N = J.principalAxes.boxAxes, { origin: q, dirA: U, dirB: F } = N, E = m7.size(M(), N);
  M.scale(E, E, K / 2);
  let R = M.create(E[2], E[1], E[0]);
  H.currentGroup = 0, fz(H, q, U, F, R, W + 1);
  let z = v1.getMesh(H), D = C0.expand(C0(), J.boundary.sphere, 1 * Y.sizeFactor);
  return z.setBoundingSphere(D), z;
}
function JV1(Z) {
  let { group: J, structure: $ } = Z, X = 1, Y = J.units.length, Q = W0.Location.create($);
  return X6(1, Y, 1, (K, G) => {
    let H = J.units[G];
    return Q.unit = H, Q.element = H.elements[K], Q;
  });
}
function $V1(Z, J, $) {
  let { objectId: X, instanceId: Y } = Z;
  if ($ === X) {
    let { structure: Q, group: W } = J, K = W.units[Y], G = f0.ofBounds(0, K.elements.length);
    return W0.Loci(Q, [{ unit: K, indices: G }]);
  }
  return G8;
}
function XV1(Z, J, $) {
  let X = !1;
  if (!W0.Loci.is(Z))
    return !1;
  let { structure: Y, group: Q } = J;
  if (!s0.areEquivalent(Z.structure, Y))
    return !1;
  let W = Q.elements.length;
  for (let K of Z.elements) {
    let G = Q.unitIndexMap.get(K.unit.id);
    if (G !== void 0) {
      if (f0.size(K.indices) === W) {
        if ($(k0.ofSingleton(G)))
          X = !0;
      }
    }
  }
  return X;
}

// node_modules/molstar/lib/mol-repr/structure/representation/orientation.js
var ch0 = {
  "orientation-ellipsoid-mesh": (Z, J) => _Z("Orientation ellipsoid mesh", Z, J, uh0)
}, lh0 = {
  ...TZ0,
  visuals: j.MultiSelect(["orientation-ellipsoid-mesh"], j.objectToOptions(ch0)),
  bumpFrequency: j.Numeric(1, { min: 0, max: 10, step: 0.1 }, q1.ShadingCategory)
};
function YV1(Z, J) {
  return lh0;
}
function QV1(Z, J) {
  return V2.createMulti("Orientation", Z, J, lZ, ch0);
}
var nh0 = v9({
  name: "orientation",
  label: "Orientation",
  description: "Displays orientation ellipsoids for polymer chains.",
  factory: QV1,
  getParams: YV1,
  defaultValues: j.getDefaultValues(lh0),
  defaultColorTheme: { name: "chain-id" },
  defaultSizeTheme: { name: "uniform" },
  isApplicable: (Z) => Z.elementCount > 0
});

// node_modules/molstar/lib/mol-repr/structure/visual/element-point.js
var wm = M.add, CP = {
  ...h_0,
  pointSizeAttenuation: j.Boolean(!1),
  ignoreHydrogens: j.Boolean(!1),
  ignoreHydrogensVariant: j.Select("all", j.arrayToOptions(["all", "non-polar"])),
  traceOnly: j.Boolean(!1),
  stride: j.Numeric(1, { min: 1, max: 100, step: 1 })
};
function WV1(Z, J, $, X, Y, Q) {
  let { child: W } = $, K = W === null || W === void 0 ? void 0 : W.unitMap.get(J.id);
  if (W && !K)
    return YX.createEmpty(Q);
  let { stride: G } = Y, H = J.elements, N = H.length, q = yz.create(N, N / 10, Q), U = M(), F = J.conformation, E = tW($, J, Y), R = M(), z = 0;
  if (G && G > 1 || E)
    for (let T = 0;T < N; ++T) {
      if (G && T % G !== 0)
        continue;
      if (E && E(H[T]))
        continue;
      F.invariantPosition(H[T], U), wm(R, R, U), z += 1, q.add(U[0], U[1], U[2], T);
    }
  else
    for (let T = 0;T < N; ++T)
      F.invariantPosition(H[T], U), wm(R, R, U), z += 1, q.add(U[0], U[1], U[2], T);
  let D = q.getPoints();
  if (z === 0)
    return D;
  let A;
  M.scale(R, R, 1 / z);
  let B = Q ? C0.clone(Q.boundingSphere) : void 0;
  if (B && M.distance(R, B.center) / B.radius < 0.1)
    A = B;
  else
    A = C0.expand(C0(), (K !== null && K !== void 0 ? K : J).boundary.sphere, 1 * Y.sizeFactor);
  return D.setBoundingSphere(A), D;
}
function jm(Z) {
  return b_0({
    defaultProps: j.getDefaultValues(CP),
    createGeometry: WV1,
    createLocationIterator: _9.fromGroup,
    getLoci: UX,
    eachLocation: FX,
    setUpdateState: (J, $, X) => {
      J.createGeometry = $.ignoreHydrogens !== X.ignoreHydrogens || $.ignoreHydrogensVariant !== X.ignoreHydrogensVariant || $.traceOnly !== X.traceOnly || $.stride !== X.stride;
    }
  }, Z);
}
function KV1(Z, J, $, X, Y) {
  let { child: Q } = J, { stride: W } = X, { getSerialIndex: K } = J.serialMapping, G = J.elementCount, H = yz.create(G, G / 2, Y), N = M(), q = 0;
  for (let R of J.units) {
    let z = Q === null || Q === void 0 ? void 0 : Q.unitMap.get(R.id);
    if (Q && !z)
      return YX.createEmpty(Y);
    let { elements: D, conformation: A } = R, B = D.length, T = M(), w = tW(J, R, X);
    if (W && W > 1 || w)
      for (let V = 0;V < B; V++) {
        let P = D[V];
        if (W && V % W !== 0)
          continue;
        if (w && w(P))
          continue;
        A.position(P, T), H.add(T[0], T[1], T[2], K(R, P)), wm(N, N, T), q += 1;
      }
    else {
      for (let V = 0;V < B; V++) {
        let P = D[V];
        A.position(P, T), H.add(T[0], T[1], T[2], K(R, P)), wm(N, N, T);
      }
      q += B;
    }
  }
  let U = H.getPoints();
  if (q === 0)
    return U;
  let F;
  M.scale(N, N, 1 / q);
  let E = Y ? C0.clone(Y.boundingSphere) : void 0;
  if (E && M.distance(N, E.center) / E.radius < 1)
    F = E;
  else
    F = C0.expand(C0(), (Q !== null && Q !== void 0 ? Q : J).boundary.sphere, 1 * X.sizeFactor);
  return U.setBoundingSphere(F), U;
}
var GV1 = {
  ...j_0,
  pointSizeAttenuation: j.Boolean(!1),
  ignoreHydrogens: j.Boolean(!1),
  ignoreHydrogensVariant: j.Select("all", j.arrayToOptions(["all", "non-polar"])),
  traceOnly: j.Boolean(!1),
  stride: j.Numeric(1, { min: 1, max: 100, step: 1 })
};
function Tm(Z) {
  return T_0({
    defaultProps: j.getDefaultValues(GV1),
    createGeometry: KV1,
    createLocationIterator: _9.fromStructure,
    getLoci: RX,
    eachLocation: LX,
    setUpdateState: (J, $, X) => {
      J.createGeometry = $.ignoreHydrogens !== X.ignoreHydrogens || $.ignoreHydrogensVariant !== X.ignoreHydrogensVariant || $.traceOnly !== X.traceOnly || $.stride !== X.stride;
    }
  }, Z);
}

// node_modules/molstar/lib/mol-repr/structure/representation/point.js
var ih0 = {
  "element-point": (Z, J) => _Z("Element points", Z, J, jm),
  "structure-element-point": (Z, J) => M9("Structure element points", Z, J, Tm)
}, oh0 = {
  ...CP,
  density: j.Numeric(0.1, { min: 0, max: 1, step: 0.01 }, q1.ShadingCategory),
  visuals: j.MultiSelect(["element-point"], j.objectToOptions(ih0))
};
function HV1(Z, J) {
  let $ = oh0;
  if (J.unitSymmetryGroups.length > 5000)
    $ = j.clone($), $.visuals.defaultValue = ["structure-element-point"];
  return $;
}
function NV1(Z, J) {
  return V2.createMulti("Point", Z, J, lZ, ih0);
}
var sh0 = v9({
  name: "point",
  label: "Point",
  description: "Displays elements (atoms, coarse spheres) as points.",
  factory: NV1,
  getParams: HV1,
  defaultValues: j.getDefaultValues(oh0),
  defaultColorTheme: { name: "element-symbol" },
  defaultSizeTheme: { name: "uniform" },
  isApplicable: (Z) => Z.elementCount > 0
});

// node_modules/molstar/lib/mol-repr/structure/visual/polymer-tube-mesh.js
var ah0 = {
  sizeFactor: j.Numeric(0.2, { min: 0, max: 10, step: 0.01 }),
  detail: j.Numeric(0, { min: 0, max: 3, step: 1 }, q1.CustomQualityParamInfo),
  linearSegments: j.Numeric(8, { min: 1, max: 48, step: 1 }, q1.CustomQualityParamInfo),
  radialSegments: j.Numeric(16, { min: 2, max: 56, step: 2 }, q1.CustomQualityParamInfo)
}, Im8 = j.getDefaultValues(ah0), l5 = M();
function qV1(Z, J, $, X, Y, Q) {
  let W = J.polymerElements.length;
  if (!W)
    return n1.createEmpty(Q);
  let { sizeFactor: K, detail: G, linearSegments: H, radialSegments: N } = Y, q = H * N * W + (N + 1) * W * 2, U = v1.createState(q, q / 10, Q), F = Ww(H), { curvePoints: E, normalVectors: R, binormalVectors: z, widthValues: D, heightValues: A } = F, B = 0, T = $w(J, $, { ignoreSecondaryStructure: !0 });
  while (T.hasNext) {
    let P = T.move();
    U.currentGroup = B;
    let S = XJ(P.moleculeType) ? j4 : w4;
    Kw(F, P, lg, S);
    let f = P.coarseBackboneFirst || P.first, v = P.coarseBackboneLast || P.last, h = X.size.size(P.centerPrev) * K, x = X.size.size(P.center) * K, b = X.size.size(P.centerNext) * K;
    wP(F, h, x, b, h, x, b, S);
    let g = H;
    if (P.initial) {
      g = Math.max(Math.round(H * S), 1);
      let m = H - g;
      E.copyWithin(0, m * 3), z.copyWithin(0, m * 3), R.copyWithin(0, m * 3), D.copyWithin(0, m * 3), A.copyWithin(0, m * 3), M.fromArray(l5, E, 3), M.normalize(l5, M.sub(l5, P.p2, l5)), M.scaleAndAdd(l5, P.p2, l5, x * Gw), M.toArray(l5, E, 0);
    } else if (P.final)
      g = Math.max(Math.round(H * (1 - S)), 1), M.fromArray(l5, E, g * 3 - 3), M.normalize(l5, M.sub(l5, P.p2, l5)), M.scaleAndAdd(l5, P.p2, l5, x * Gw), M.toArray(l5, E, g * 3);
    if (P.initial === !0 && P.final === !0)
      g8(U, P.p2, x * 2, G);
    else if (N === 2)
      Cw(U, E, R, z, g, D, A, 0);
    else if (N === 4)
      Iw(U, E, R, z, g, D, A, 0, f, v);
    else
      _P(U, E, R, z, g, N, D, A, f, v, "elliptical");
    ++B;
  }
  let w = v1.getMesh(U), V = C0.expand(C0(), J.boundary.sphere, 1 * Y.sizeFactor);
  return w.setBoundingSphere(V), w;
}
var _Z0 = {
  ...nZ,
  ...ah0
};
function rh0(Z) {
  return A9({
    defaultProps: j.getDefaultValues(_Z0),
    createGeometry: qV1,
    createLocationIterator: (J) => d5.fromGroup(J, { asSecondary: !0 }),
    getLoci: KG,
    eachLocation: GG,
    setUpdateState: (J, $, X) => {
      J.createGeometry = $.sizeFactor !== X.sizeFactor || $.detail !== X.detail || $.linearSegments !== X.linearSegments || $.radialSegments !== X.radialSegments;
    }
  }, Z);
}

// node_modules/molstar/lib/mol-repr/structure/representation/putty.js
var th0 = {
  "polymer-tube": (Z, J) => _Z("Polymer tube mesh", Z, J, rh0),
  "polymer-gap": (Z, J) => _Z("Polymer gap cylinder", Z, J, _w)
}, eh0 = {
  ..._Z0,
  ...I4,
  sizeFactor: j.Numeric(0.2, { min: 0, max: 10, step: 0.01 }),
  visuals: j.MultiSelect(["polymer-tube", "polymer-gap"], j.objectToOptions(th0)),
  bumpFrequency: j.Numeric(2, { min: 0, max: 10, step: 0.1 }, q1.ShadingCategory),
  density: j.Numeric(0.1, { min: 0, max: 1, step: 0.01 }, q1.ShadingCategory)
};
function FV1(Z, J) {
  let $ = j.clone(eh0), X = !1, Y = !1;
  if (J.units.forEach((Q) => {
    if (!X && j0.isAtomic(Q) && Q.nucleotideElements.length)
      X = !0;
    if (!Y && Q.gapElements.length)
      Y = !0;
  }), $.visuals.defaultValue = ["polymer-tube"], Y)
    $.visuals.defaultValue.push("polymer-gap");
  return $;
}
function UV1(Z, J) {
  return V2.createMulti("Putty", Z, J, lZ, th0);
}
var Zb0 = v9({
  name: "putty",
  label: "Putty",
  description: "Displays a tube smoothly following the trace atoms of polymers.",
  factory: UV1,
  getParams: FV1,
  defaultValues: j.getDefaultValues(eh0),
  defaultColorTheme: { name: "chain-id" },
  defaultSizeTheme: { name: "uncertainty" },
  isApplicable: (Z) => Z.polymerResidueCount > 0
});

// node_modules/molstar/lib/mol-repr/structure/representation/spacefill.js
var Jb0 = {
  "element-sphere": (Z, J) => _Z("Sphere mesh/impostor", Z, J, xg),
  "structure-element-sphere": (Z, J) => M9("Structure sphere mesh/impostor", Z, J, yg)
}, VZ0 = {
  ...Jw,
  bumpFrequency: j.Numeric(1, { min: 0, max: 10, step: 0.1 }, q1.ShadingCategory),
  density: j.Numeric(0.5, { min: 0, max: 1, step: 0.01 }, q1.ShadingCategory),
  visuals: j.MultiSelect(["element-sphere"], j.objectToOptions(Jb0))
}, _m;
function LV1(Z, J) {
  let $ = VZ0;
  if (J.isCoarseGrained) {
    if (!_m)
      _m = j.clone(VZ0), _m.sizeFactor.defaultValue = 2;
    $ = _m;
  }
  if (J.unitSymmetryGroups.length > 5000)
    $ = j.clone($), $.visuals.defaultValue = ["structure-element-sphere"];
  return $;
}
function RV1(Z, J) {
  return V2.createMulti("Spacefill", Z, J, lZ, Jb0);
}
var $b0 = v9({
  name: "spacefill",
  label: "Spacefill",
  description: "Displays atomic/coarse elements as spheres.",
  factory: RV1,
  getParams: LV1,
  defaultValues: j.getDefaultValues(VZ0),
  defaultColorTheme: { name: "element-symbol" },
  defaultSizeTheme: { name: "physical" },
  isApplicable: (Z) => Z.elementCount > 0
});

// node_modules/molstar/lib/mol-repr/structure/visual/bond-intra-unit-line.js
var IZ0 = s1.is;
function Xb0(Z, J, $, X) {
  let Y = W0.Location.create(J, Z), Q = Z.elements, W = Z.bonds, { edgeCount: K, a: G, b: H, edgeProps: N, offset: q } = W, { order: U, flags: F } = N, { sizeFactor: E, aromaticBonds: R, includeTypes: z, excludeTypes: D, multipleBonds: A } = X, B = A === "off", T = A === "symmetric", w = s1.fromNames(z), V = s1.fromNames(D), P = aB(w, V, s1.Flag.Computed), I = M(), S = Z.conformation, { elementRingIndices: f, elementAromaticRingIndices: v } = Z.rings, h = R ? Z.resonance.delocalizedTriplets : void 0;
  return {
    linkCount: K * 2,
    referencePosition: (x) => {
      let b = G[x], g = H[x], m = h === null || h === void 0 ? void 0 : h.getThirdElement(b, g);
      if (m !== void 0)
        return S.invariantPosition(Q[m], I);
      if (b > g)
        [b, g] = [g, b];
      if (q[b + 1] - q[b] === 1)
        [b, g] = [g, b];
      let i = v.get(b) || f.get(b), r = 0;
      for (let Y0 = q[b], c = q[b + 1];Y0 < c; ++Y0) {
        let n = H[Y0];
        if (n !== g && n !== b)
          if (i) {
            let l = v.get(n) || f.get(n);
            if (!l)
              continue;
            let u = CM(i, l);
            if (u > r)
              r = u, S.invariantPosition(Q[n], I);
          } else
            return S.invariantPosition(Q[n], I);
      }
      return r > 0 ? I : null;
    },
    position: (x, b, g, m) => {
      S.invariantPosition(Q[G[g]], x), S.invariantPosition(Q[H[g]], b);
    },
    style: (x) => {
      let b = U[x], g = F[x];
      if (IZ0(g, s1.Flag.MetallicCoordination) || IZ0(g, s1.Flag.HydrogenBond))
        return j2.Dashed;
      else if (b === 3)
        return B ? j2.Solid : T ? j2.Triple : j2.OffsetTriple;
      else if (R) {
        let m = G[x], i = H[x], r = v.get(m), Y0 = v.get(i), c = r && Y0 ? CM(r, Y0) : 0;
        if (IZ0(g, s1.Flag.Aromatic) || c && !P)
          if (c === 2)
            return j2.MirroredAromatic;
          else
            return j2.Aromatic;
      }
      return b !== 2 || B ? j2.Solid : T ? j2.Double : j2.OffsetDouble;
    },
    radius: (x) => {
      Y.element = Q[G[x]];
      let b = $.size.size(Y);
      Y.element = Q[H[x]];
      let g = $.size.size(Y);
      return Math.min(b, g) * E;
    },
    ignore: vg(J, Z, X)
  };
}
function EV1(Z, J, $, X, Y, Q) {
  if (!j0.isAtomic(J))
    return f6.createEmpty(Q);
  if (!vU(J, Y))
    return f6.createEmpty(Q);
  if (!J.bonds.edgeCount)
    return f6.createEmpty(Q);
  let { child: W } = $, K = W === null || W === void 0 ? void 0 : W.unitMap.get(J.id);
  if (W && !K)
    return f6.createEmpty(Q);
  let G = Xb0(J, $, X, Y), { lines: H, boundingSphere: N } = OI(Z, G, Y, Q);
  if (N)
    H.setBoundingSphere(N);
  else if (H.lineCount > 0) {
    let q = C0.expand(C0(), (K !== null && K !== void 0 ? K : J).boundary.sphere, 1 * Y.sizeFactor);
    H.setBoundingSphere(q);
  }
  return H;
}
var PZ0 = {
  ...KE,
  ...sB,
  includeParent: j.Boolean(!1)
};
function Yb0(Z) {
  return GE({
    defaultProps: j.getDefaultValues(PZ0),
    createGeometry: EV1,
    createLocationIterator: (J) => rW.fromGroup(J),
    getLoci: rB,
    eachLocation: RP,
    setUpdateState: (J, $, X, Y, Q, W, K) => {
      J.createGeometry = $.sizeFactor !== X.sizeFactor || $.linkScale !== X.linkScale || $.linkSpacing !== X.linkSpacing || $.aromaticDashCount !== X.aromaticDashCount || $.dashCount !== X.dashCount || $.ignoreHydrogens !== X.ignoreHydrogens || $.ignoreHydrogensVariant !== X.ignoreHydrogensVariant || !b7($.includeTypes, X.includeTypes) || !b7($.excludeTypes, X.excludeTypes) || $.aromaticBonds !== X.aromaticBonds || $.multipleBonds !== X.multipleBonds;
      let G = W.group.units[0], H = K.group.units[0];
      if (j0.isAtomic(G) && j0.isAtomic(H)) {
        if (!lJ.areEqual(G.bonds, H.bonds))
          J.createGeometry = !0, J.updateTransform = !0, J.updateColor = !0, J.updateSize = !0;
      }
    }
  }, Z);
}
function OV1(Z, J, $) {
  let X = [], { bondCount: Y, unitIndex: Q, unitEdgeIndex: W, unitGroupIndex: K } = Z.intraUnitBondMapping, { child: G } = Z;
  for (let H of Z.unitSymmetryGroups) {
    let N = H.units[0], q = G === null || G === void 0 ? void 0 : G.unitMap.get(N.id), U = j0.isAtomic(N) && !(G && !q) ? Xb0(N, Z, J, $) : Zy;
    X.push({ group: H, props: U });
  }
  return {
    linkCount: Y,
    referencePosition: (H) => {
      let { group: N, props: q } = X[Q[H]];
      if (!q.referencePosition)
        return null;
      let U = q.referencePosition(W[H]);
      if (!U)
        return null;
      let F = N.units[K[H]];
      return M.transformMat4(U, U, F.conformation.operator.matrix), U;
    },
    position: (H, N, q, U) => {
      let { group: F, props: E } = X[Q[q]];
      E.position(H, N, W[q], U);
      let R = F.units[K[q]];
      M.transformMat4(H, H, R.conformation.operator.matrix), M.transformMat4(N, N, R.conformation.operator.matrix);
    },
    style: (H) => {
      let { props: N } = X[Q[H]];
      return N.style ? N.style(W[H]) : j2.Solid;
    },
    radius: (H) => {
      let { props: N } = X[Q[H]];
      return N.radius(W[H]);
    },
    ignore: (H) => {
      let { props: N } = X[Q[H]];
      return N.ignore ? N.ignore(W[H]) : !1;
    },
    stub: (H) => {
      let { props: N } = X[Q[H]];
      return N.stub ? N.stub(W[H]) : !1;
    }
  };
}
function zV1(Z, J, $, X, Y) {
  if (!T$(J, X))
    return f6.createEmpty(Y);
  if (!J.intraUnitBondMapping.bondCount)
    return f6.createEmpty(Y);
  let Q = OV1(J, $, X), { lines: W, boundingSphere: K } = OI(Z, Q, X, Y);
  if (K)
    W.setBoundingSphere(K);
  else if (W.lineCount > 0) {
    let { child: G } = J, H = C0.expand(C0(), (G !== null && G !== void 0 ? G : J).boundary.sphere, 1 * X.sizeFactor);
    W.setBoundingSphere(H);
  }
  return W;
}
var DV1 = {
  ...HB,
  ...sB,
  includeParent: j.Boolean(!1)
};
function Qb0(Z) {
  return NB({
    defaultProps: j.getDefaultValues(DV1),
    createGeometry: zV1,
    createLocationIterator: (J, $) => {
      return !T$(J, $) ? pN : rW.fromStructureGroups(J);
    },
    getLoci: zP,
    eachLocation: DP,
    setUpdateState: (J, $, X, Y, Q, W, K) => {
      if (J.createGeometry = $.sizeFactor !== X.sizeFactor || $.linkScale !== X.linkScale || $.linkSpacing !== X.linkSpacing || $.aromaticDashCount !== X.aromaticDashCount || $.dashCount !== X.dashCount || $.ignoreHydrogens !== X.ignoreHydrogens || $.ignoreHydrogensVariant !== X.ignoreHydrogensVariant || !b7($.includeTypes, X.includeTypes) || !b7($.excludeTypes, X.excludeTypes) || $.multipleBonds !== X.multipleBonds, T$(W, $) && W.interUnitBonds !== K.interUnitBonds)
        J.createGeometry = !0, J.updateTransform = !0, J.updateColor = !0, J.updateSize = !0;
    }
  }, Z);
}

// node_modules/molstar/lib/mol-repr/structure/visual/bond-inter-unit-line.js
var CZ0 = new $2.ElementBondIterator;
function Wb0(Z, J, $, X) {
  CZ0.setElement(J, $, X);
  while (CZ0.hasNext) {
    let Y = CZ0.move();
    return Y.otherUnit.conformation.position(Y.otherUnit.elements[Y.otherIndex], Z), Z;
  }
  return null;
}
function MV1(Z, J, $) {
  let X = Z.interUnitBonds, { edgeCount: Y, edges: Q } = X, { sizeFactor: W, aromaticBonds: K, multipleBonds: G } = $, H = G === "off", N = G === "symmetric", q = M(), U = W0.Location.create();
  return {
    linkCount: Y,
    referencePosition: (F) => {
      let E = Q[F], R, z, D, A;
      if (E.unitA < E.unitB)
        R = Z.unitMap.get(E.unitA), z = Z.unitMap.get(E.unitB), D = E.indexA, A = E.indexB;
      else if (E.unitA > E.unitB)
        R = Z.unitMap.get(E.unitB), z = Z.unitMap.get(E.unitA), D = E.indexB, A = E.indexA;
      else
        throw new Error("same units in createInterUnitBondLines");
      return Wb0(q, Z, R, D) || Wb0(q, Z, z, A);
    },
    position: (F, E, R, z) => {
      let D = Q[R], A = Z.unitMap.get(D.unitA), B = Z.unitMap.get(D.unitB);
      A.conformation.position(A.elements[D.indexA], F), B.conformation.position(B.elements[D.indexB], E);
    },
    style: (F) => {
      let E = Q[F].props.order, R = r7.create(Q[F].props.flag);
      if (s1.is(R, s1.Flag.MetallicCoordination) || s1.is(R, s1.Flag.HydrogenBond))
        return j2.Dashed;
      else if (E === 3)
        return H ? j2.Solid : N ? j2.Triple : j2.OffsetTriple;
      else if (K && s1.is(R, s1.Flag.Aromatic))
        return j2.Aromatic;
      return E !== 2 || H ? j2.Solid : N ? j2.Double : j2.OffsetDouble;
    },
    radius: (F) => {
      let E = Q[F];
      U.structure = Z, U.unit = Z.unitMap.get(E.unitA), U.element = U.unit.elements[E.indexA];
      let R = J.size.size(U);
      U.unit = Z.unitMap.get(E.unitB), U.element = U.unit.elements[E.indexB];
      let z = J.size.size(U);
      return Math.min(R, z) * W;
    },
    ignore: Sg(Z, $)
  };
}
function AV1(Z, J, $, X, Y) {
  if (!T$(J, X))
    return f6.createEmpty(Y);
  if (!J.interUnitBonds.edgeCount)
    return f6.createEmpty(Y);
  let Q = MV1(J, $, X), { lines: W, boundingSphere: K } = OI(Z, Q, X, Y);
  if (K)
    W.setBoundingSphere(K);
  else if (W.lineCount > 0) {
    let { child: G } = J, H = C0.expand(C0(), (G !== null && G !== void 0 ? G : J).boundary.sphere, 1 * X.sizeFactor);
    W.setBoundingSphere(H);
  }
  return W;
}
var kZ0 = {
  ...HB,
  ...sB,
  includeParent: j.Boolean(!1)
};
function Kb0(Z) {
  return NB({
    defaultProps: j.getDefaultValues(kZ0),
    createGeometry: AV1,
    createLocationIterator: (J, $) => {
      return !T$(J, $) ? pN : rW.fromStructure(J);
    },
    getLoci: EP,
    eachLocation: OP,
    setUpdateState: (J, $, X, Y, Q, W, K) => {
      if (J.createGeometry = $.sizeFactor !== X.sizeFactor || $.linkScale !== X.linkScale || $.linkSpacing !== X.linkSpacing || $.aromaticDashCount !== X.aromaticDashCount || $.dashCount !== X.dashCount || $.ignoreHydrogens !== X.ignoreHydrogens || $.ignoreHydrogensVariant !== X.ignoreHydrogensVariant || !b7($.includeTypes, X.includeTypes) || !b7($.excludeTypes, X.excludeTypes) || $.multipleBonds !== X.multipleBonds, T$(W, $) && W.interUnitBonds !== K.interUnitBonds)
        J.createGeometry = !0, J.updateTransform = !0, J.updateColor = !0, J.updateSize = !0;
    }
  }, Z);
}

// node_modules/molstar/lib/mol-repr/structure/visual/element-cross.js
var Gb0 = M.add, jG = M.scaleAndAdd, Vm = M.unitX, Im = M.unitY, Pm = M.unitZ, vZ0 = {
  ...KE,
  lineSizeAttenuation: j.Boolean(!1),
  ignoreHydrogens: j.Boolean(!1),
  ignoreHydrogensVariant: j.Select("all", j.arrayToOptions(["all", "non-polar"])),
  traceOnly: j.Boolean(!1),
  crosses: j.Select("lone", j.arrayToOptions(["lone", "all"])),
  crossSize: j.Numeric(0.35, { min: 0, max: 2, step: 0.01 })
};
function BV1(Z, J, $, X, Y, Q) {
  let { child: W } = $;
  if (W && !W.unitMap.get(J.id))
    return f6.createEmpty(Q);
  let K = J.elements, G = K.length, H = L$.create(G, G / 10, Q), N = M(), q = M(), U = M(), F = J.conformation, E = tW($, J, Y), R = Y.crossSize / 2, z = Y.crosses === "lone", D = M(), A = 0;
  for (let V = 0;V < G; ++V) {
    if (E && E(K[V]))
      continue;
    if (z && j0.isAtomic(J) && vU(J, Y) && mW($, J, V) !== 0)
      continue;
    F.invariantPosition(K[V], N), Gb0(D, D, N), A += 1, jG(q, N, Vm, R), jG(U, N, Vm, -R), H.add(q[0], q[1], q[2], U[0], U[1], U[2], V), jG(q, N, Im, R), jG(U, N, Im, -R), H.add(q[0], q[1], q[2], U[0], U[1], U[2], V), jG(q, N, Pm, R), jG(U, N, Pm, -R), H.add(q[0], q[1], q[2], U[0], U[1], U[2], V);
  }
  let B = H.getLines();
  if (A === 0)
    return B;
  let T;
  M.scale(D, D, 1 / A);
  let w = Q ? C0.clone(Q.boundingSphere) : void 0;
  if (w && M.distance(D, w.center) / w.radius < 0.1)
    T = w;
  else
    T = C0.expand(C0(), J.boundary.sphere, 1 * Y.sizeFactor);
  return B.setBoundingSphere(T), B;
}
function Hb0(Z) {
  return GE({
    defaultProps: j.getDefaultValues(vZ0),
    createGeometry: BV1,
    createLocationIterator: _9.fromGroup,
    getLoci: UX,
    eachLocation: FX,
    setUpdateState: (J, $, X) => {
      J.createGeometry = $.ignoreHydrogens !== X.ignoreHydrogens || $.ignoreHydrogensVariant !== X.ignoreHydrogensVariant || $.traceOnly !== X.traceOnly || $.crosses !== X.crosses || $.crossSize !== X.crossSize;
    }
  }, Z);
}
function wV1(Z, J, $, X, Y) {
  let { child: Q } = J, { getSerialIndex: W } = J.serialMapping, K = J.elementCount, G = L$.create(K, K / 2, Y), H = M(), N = M(), q = M(), U = X.crossSize / 2, F = X.crosses === "lone", E = M(), R = 0;
  for (let B of J.units) {
    let T = Q === null || Q === void 0 ? void 0 : Q.unitMap.get(B.id);
    if (Q && !T)
      return f6.createEmpty(Y);
    let { elements: w, conformation: V } = B, P = w.length, I = tW(J, B, X);
    for (let S = 0;S < P; S++) {
      if (I && I(w[S]))
        continue;
      if (F && j0.isAtomic(B) && vU(B, X) && mW(J, B, S) !== 0)
        continue;
      V.position(w[S], H), Gb0(E, E, H), R += 1;
      let f = W(B, w[S]);
      jG(N, H, Vm, U), jG(q, H, Vm, -U), G.add(N[0], N[1], N[2], q[0], q[1], q[2], f), jG(N, H, Im, U), jG(q, H, Im, -U), G.add(N[0], N[1], N[2], q[0], q[1], q[2], f), jG(N, H, Pm, U), jG(q, H, Pm, -U), G.add(N[0], N[1], N[2], q[0], q[1], q[2], f);
    }
  }
  let z = G.getLines();
  if (R === 0)
    return z;
  let D;
  M.scale(E, E, 1 / R);
  let A = Y ? C0.clone(Y.boundingSphere) : void 0;
  if (A && M.distance(E, A.center) / A.radius < 1)
    D = A;
  else
    D = C0.expand(C0(), (Q !== null && Q !== void 0 ? Q : J).boundary.sphere, 1 * X.sizeFactor);
  return z.setBoundingSphere(D), z;
}
var jV1 = {
  ...HB,
  lineSizeAttenuation: j.Boolean(!1),
  ignoreHydrogens: j.Boolean(!1),
  ignoreHydrogensVariant: j.Select("all", j.arrayToOptions(["all", "non-polar"])),
  traceOnly: j.Boolean(!1),
  crosses: j.Select("lone", j.arrayToOptions(["lone", "all"])),
  crossSize: j.Numeric(0.35, { min: 0, max: 2, step: 0.01 })
};
function Nb0(Z) {
  return NB({
    defaultProps: j.getDefaultValues(jV1),
    createGeometry: wV1,
    createLocationIterator: _9.fromStructure,
    getLoci: RX,
    eachLocation: LX,
    setUpdateState: (J, $, X) => {
      J.createGeometry = $.ignoreHydrogens !== X.ignoreHydrogens || $.ignoreHydrogensVariant !== X.ignoreHydrogensVariant || $.traceOnly !== X.traceOnly || $.crosses !== X.crosses || $.crossSize !== X.crossSize;
    }
  }, Z);
}

// node_modules/molstar/lib/mol-repr/structure/representation/line.js
var qb0 = {
  "intra-bond": (Z, J) => _Z("Intra-unit bond line", Z, J, Yb0),
  "inter-bond": (Z, J) => M9("Inter-unit bond line", Z, J, Kb0),
  "element-point": (Z, J) => _Z("Points", Z, J, jm),
  "element-cross": (Z, J) => _Z("Crosses", Z, J, Hb0),
  "structure-intra-bond": (Z, J) => M9("Structure intra-unit bond line", Z, J, Qb0),
  "structure-element-point": (Z, J) => M9("Structure element points", Z, J, Tm),
  "structure-element-cross": (Z, J) => M9("Structure element crosses", Z, J, Nb0)
}, Fb0 = {
  ...PZ0,
  ...kZ0,
  ...CP,
  ...vZ0,
  pointStyle: j.Select("circle", j.objectToOptions(YX.StyleTypes)),
  multipleBonds: j.Select("offset", j.arrayToOptions(["off", "symmetric", "offset"])),
  includeParent: j.Boolean(!1),
  sizeFactor: j.Numeric(2, { min: 0.01, max: 10, step: 0.01 }),
  unitKinds: zU(["atomic"]),
  visuals: j.MultiSelect(["intra-bond", "inter-bond", "element-point", "element-cross"], j.objectToOptions(qb0)),
  density: j.Numeric(0.1, { min: 0, max: 1, step: 0.01 }, q1.ShadingCategory)
};
function TV1(Z, J) {
  let $ = Fb0;
  if (s0.getSize(J) >= s0.Size.Huge)
    $ = j.clone($), $.visuals.defaultValue = ["intra-bond", "element-point", "element-cross"];
  else if (J.unitSymmetryGroups.length > 5000)
    $ = j.clone($), $.visuals.defaultValue = ["structure-intra-bond", "structure-element-point", "structure-element-cross"];
  return $;
}
function _V1(Z, J) {
  return V2.createMulti("Line", Z, J, lZ, qb0);
}
var Ub0 = v9({
  name: "line",
  label: "Line",
  description: "Displays bonds as lines and atoms as points or croses.",
  factory: _V1,
  getParams: TV1,
  defaultValues: j.getDefaultValues(Fb0),
  defaultColorTheme: { name: "element-symbol" },
  defaultSizeTheme: { name: "uniform" },
  isApplicable: (Z) => Z.elementCount > 0,
  getData: (Z, J) => {
    return J.includeParent ? Z.asParent() : Z;
  },
  mustRecreate: (Z, J) => {
    return Z.includeParent !== J.includeParent;
  }
});

// node_modules/molstar/lib/mol-repr/structure/visual/gaussian-density-volume.js
function VV1(Z, J, $, X, Y) {
  let { webgl: Q } = Z;
  if (!Q)
    throw new Error("GaussianDensityVolume requires `webgl`");
  let W = M.create(0, 1, 2), K = { min: 0, max: 1, mean: 0.04, sigma: 0.01 }, G = (N) => {
    let q = N ? N.gridTexture.ref.value : void 0, U = Dh0(J, $.size, X, Q, q), { transform: F, texture: E, bbox: R, gridDim: z } = U, D = e.mul(e(), F, e.fromScaling(e(), z)), A = e.getScaling(M(), F), B = gX.create(R, z, F, D, A, E, K, !0, W, "byte", N), T = C0.expand(C0(), J.boundary.sphere, U.maxRadius);
    return B.setBoundingSphere(T), B;
  }, H = G(Y);
  return H.meta.reset = () => {
    G(H);
  }, H;
}
var SZ0 = {
  ...I_0,
  ...pE,
  ignoreHydrogens: j.Boolean(!1),
  ignoreHydrogensVariant: j.Select("all", j.arrayToOptions(["all", "non-polar"])),
  includeParent: j.Boolean(!1, { isHidden: !0 })
};
function Lb0(Z) {
  return P_0({
    defaultProps: j.getDefaultValues(SZ0),
    createGeometry: VV1,
    createLocationIterator: _9.fromStructure,
    getLoci: RX,
    eachLocation: LX,
    setUpdateState: (J, $, X) => {
      if ($.resolution !== X.resolution)
        J.createGeometry = !0;
      if ($.radiusOffset !== X.radiusOffset)
        J.createGeometry = !0;
      if ($.smoothness !== X.smoothness)
        J.createGeometry = !0;
      if ($.ignoreHydrogens !== X.ignoreHydrogens)
        J.createGeometry = !0;
      if ($.ignoreHydrogensVariant !== X.ignoreHydrogensVariant)
        J.createGeometry = !0;
      if ($.traceOnly !== X.traceOnly)
        J.createGeometry = !0;
      if ($.includeParent !== X.includeParent)
        J.createGeometry = !0;
    },
    dispose: (J) => {
      J.gridTexture.ref.value.destroy();
    }
  }, Z);
}
function IV1(Z, J, $, X, Y, Q) {
  let { webgl: W } = Z;
  if (!W)
    throw new Error("GaussianDensityVolume requires `webgl`");
  let K = M.create(0, 1, 2), G = { min: 0, max: 1, mean: 0.04, sigma: 0.01 }, H = (q) => {
    let U = q ? q.gridTexture.ref.value : void 0, F = Eh0($, J, X.size, Y, W, U), { transform: E, texture: R, bbox: z, gridDim: D } = F, A = e.mul(e(), E, e.fromScaling(e(), D)), B = e.getScaling(M(), E), T = gX.create(z, D, E, A, B, R, G, !0, K, "byte", q), w = C0.expand(C0(), J.boundary.sphere, F.maxRadius);
    return T.setBoundingSphere(w), T;
  }, N = H(Q);
  return N.meta.reset = () => {
    H(N);
  }, N;
}
var PV1 = {
  ...x_0,
  ...pE,
  ignoreHydrogens: j.Boolean(!1),
  ignoreHydrogensVariant: j.Select("all", j.arrayToOptions(["all", "non-polar"])),
  includeParent: j.Boolean(!1, { isHidden: !0 })
};
function Rb0(Z) {
  return y_0({
    defaultProps: j.getDefaultValues(PV1),
    createGeometry: IV1,
    createLocationIterator: _9.fromGroup,
    getLoci: UX,
    eachLocation: FX,
    setUpdateState: (J, $, X) => {
      if ($.resolution !== X.resolution)
        J.createGeometry = !0;
      if ($.radiusOffset !== X.radiusOffset)
        J.createGeometry = !0;
      if ($.smoothness !== X.smoothness)
        J.createGeometry = !0;
      if ($.ignoreHydrogens !== X.ignoreHydrogens)
        J.createGeometry = !0;
      if ($.ignoreHydrogensVariant !== X.ignoreHydrogensVariant)
        J.createGeometry = !0;
      if ($.traceOnly !== X.traceOnly)
        J.createGeometry = !0;
      if ($.includeParent !== X.includeParent)
        J.createGeometry = !0;
    },
    dispose: (J) => {
      J.gridTexture.ref.value.destroy();
    }
  }, Z);
}

// node_modules/molstar/lib/mol-repr/structure/representation/gaussian-volume.js
var Eb0 = {
  "gaussian-volume": (Z, J) => M9("Gaussian volume", Z, J, Lb0),
  "units-gaussian-volume": (Z, J) => _Z("Units-Gaussian volume", Z, J, Rb0)
}, Ob0 = {
  ...SZ0,
  jumpLength: j.Numeric(4, { min: 0, max: 20, step: 0.1 }),
  visuals: j.MultiSelect(["gaussian-volume"], j.objectToOptions(Eb0))
};
function CV1(Z, J) {
  return Ob0;
}
function kV1(Z, J) {
  return V2.createMulti("Gaussian Volume", Z, J, lZ, Eb0);
}
var zb0 = v9({
  name: "gaussian-volume",
  label: "Gaussian Volume",
  description: "Displays a gaussian molecular density using direct volume rendering.",
  factory: kV1,
  getParams: CV1,
  defaultValues: j.getDefaultValues(Ob0),
  defaultColorTheme: { name: "chain-id" },
  defaultSizeTheme: { name: "physical" },
  isApplicable: (Z) => Z.elementCount > 0
});

// node_modules/molstar/lib/mol-repr/structure/visual/polymer-backbone-cylinder.js
var vV1 = M.scale, SV1 = M.add, fV1 = M.sub, Cm = {
  ...nZ,
  ...UB,
  sizeFactor: j.Numeric(0.3, { min: 0, max: 10, step: 0.01 }),
  radialSegments: j.Numeric(16, { min: 2, max: 56, step: 2 }, q1.CustomQualityParamInfo),
  tryUseImpostor: j.Boolean(!0)
};
function Db0(Z, J, $, X) {
  return $.tryUseImpostor && YE(X) ? bV1(Z) : yV1(Z);
}
function hV1(Z, J, $, X, Y, Q) {
  let W = J.polymerElements.length;
  if (!W)
    return T7.createEmpty(Q);
  let K = W * 2, G = HE.create(K, K / 4, Q), H = J.conformation, N = M(), q = M(), U = M();
  m60(J, function(z, D, A, B, T) {
    H.invariantPosition(z, N), H.invariantPosition(D, q);
    let V = XJ(T) ? j4 : w4;
    SV1(U, N, vV1(U, fV1(U, q, N), V)), G.add(N[0], N[1], N[2], U[0], U[1], U[2], 1, !1, !1, 2, A), G.add(U[0], U[1], U[2], q[0], q[1], q[2], 1, !1, !1, 2, B);
  });
  let E = G.getCylinders(), R = C0.expand(C0(), J.boundary.sphere, 1 * Y.sizeFactor);
  return E.setBoundingSphere(R), E;
}
function bV1(Z) {
  return LB({
    defaultProps: j.getDefaultValues(Cm),
    createGeometry: hV1,
    createLocationIterator: (J) => d5.fromGroup(J),
    getLoci: KG,
    eachLocation: GG,
    setUpdateState: (J, $, X) => {},
    mustRecreate: (J, $, X) => {
      return !$.tryUseImpostor || !X;
    }
  }, Z);
}
function xV1(Z, J, $, X, Y, Q) {
  let W = J.polymerElements.length;
  if (!W)
    return n1.createEmpty(Q);
  let { radialSegments: K, sizeFactor: G } = Y, H = K * 2 * W * 2, N = v1.createState(H, H / 10, Q), q = J.conformation, U = M(), F = M(), E = { radiusTop: 1, radiusBottom: 1, radialSegments: K }, R = W0.Location.create($, J), z = W0.Location.create($, J);
  m60(J, function(T, w, V, P, I) {
    R.element = T, z.element = w, q.invariantPosition(R.element, U), q.invariantPosition(z.element, F);
    let f = XJ(I) ? j4 : w4;
    E.radiusTop = E.radiusBottom = X.size.size(R) * G, N.currentGroup = V, q6(N, U, F, f, E), E.radiusTop = E.radiusBottom = X.size.size(z) * G, N.currentGroup = P, q6(N, F, U, 1 - f, E);
  });
  let A = v1.getMesh(N), B = C0.expand(C0(), J.boundary.sphere, 1 * Y.sizeFactor);
  return A.setBoundingSphere(B), A;
}
function yV1(Z) {
  return A9({
    defaultProps: j.getDefaultValues(Cm),
    createGeometry: xV1,
    createLocationIterator: (J) => d5.fromGroup(J),
    getLoci: KG,
    eachLocation: GG,
    setUpdateState: (J, $, X) => {
      J.createGeometry = $.sizeFactor !== X.sizeFactor || $.radialSegments !== X.radialSegments;
    },
    mustRecreate: (J, $, X) => {
      return $.tryUseImpostor && !!X;
    }
  }, Z);
}

// node_modules/molstar/lib/mol-repr/structure/visual/polymer-backbone-sphere.js
var km = {
  ...nZ,
  ...qB,
  sizeFactor: j.Numeric(0.3, { min: 0, max: 10, step: 0.01 }),
  detail: j.Numeric(0, { min: 0, max: 3, step: 1 }, q1.CustomQualityParamInfo),
  tryUseImpostor: j.Boolean(!0)
};
function Mb0(Z, J, $, X) {
  return $.tryUseImpostor && WB(X) ? mV1(Z) : pV1(Z);
}
function gV1(Z, J, $, X, Y, Q) {
  let W = J.polymerElements.length;
  if (!W)
    return R$.createEmpty(Q);
  let K = wH.create(W, W / 2, Q), G = J.conformation, H = M();
  d60(J, (F, E) => {
    G.invariantPosition(F, H), K.add(H[0], H[1], H[2], E);
  });
  let q = K.getSpheres(), U = C0.expand(C0(), J.boundary.sphere, 1 * Y.sizeFactor);
  return q.setBoundingSphere(U), q;
}
function mV1(Z) {
  return FB({
    defaultProps: j.getDefaultValues(km),
    createGeometry: gV1,
    createLocationIterator: (J) => d5.fromGroup(J),
    getLoci: KG,
    eachLocation: GG,
    setUpdateState: (J, $, X) => {},
    mustRecreate: (J, $, X) => {
      return !$.tryUseImpostor || !X;
    }
  }, Z);
}
function dV1(Z, J, $, X, Y, Q) {
  let W = J.polymerElements.length;
  if (!W)
    return n1.createEmpty(Q);
  let { detail: K, sizeFactor: G } = Y, H = W * _5(K), N = v1.createState(H, H / 2, Q), q = J.conformation, U = M(), F = W0.Location.create($, J);
  d60(J, (D, A) => {
    F.element = D, q.invariantPosition(F.element, U), N.currentGroup = A, g8(N, U, X.size.size(F) * G, K);
  });
  let R = v1.getMesh(N), z = C0.expand(C0(), J.boundary.sphere, 1 * Y.sizeFactor);
  return R.setBoundingSphere(z), R;
}
function pV1(Z) {
  return A9({
    defaultProps: j.getDefaultValues(km),
    createGeometry: dV1,
    createLocationIterator: (J) => d5.fromGroup(J),
    getLoci: KG,
    eachLocation: GG,
    setUpdateState: (J, $, X) => {
      J.createGeometry = $.sizeFactor !== X.sizeFactor || $.detail !== X.detail;
    },
    mustRecreate: (J, $, X) => {
      return $.tryUseImpostor && !!X;
    }
  }, Z);
}

// node_modules/molstar/lib/mol-repr/structure/representation/backbone.js
var Ab0 = {
  "polymer-backbone-cylinder": (Z, J) => _Z("Polymer backbone cylinder", Z, J, Db0),
  "polymer-backbone-sphere": (Z, J) => _Z("Polymer backbone sphere", Z, J, Mb0),
  "polymer-gap": (Z, J) => _Z("Polymer gap cylinder", Z, J, _w)
}, Bb0 = {
  ...km,
  ...Cm,
  ...I4,
  sizeAspectRatio: j.Numeric(1, { min: 0.1, max: 3, step: 0.1 }),
  visuals: j.MultiSelect(["polymer-backbone-cylinder", "polymer-backbone-sphere", "polymer-gap"], j.objectToOptions(Ab0)),
  bumpFrequency: j.Numeric(0, { min: 0, max: 10, step: 0.1 }, q1.ShadingCategory),
  density: j.Numeric(0.1, { min: 0, max: 1, step: 0.01 }, q1.ShadingCategory),
  colorMode: j.Select("default", j.arrayToOptions(["default", "interpolate"]), { ...q1.ShadingCategory, isHidden: !0 })
};
function uV1(Z, J) {
  let $ = j.clone(Bb0), X = !1;
  if (J.units.forEach((Y) => {
    if (!X && Y.gapElements.length)
      X = !0;
  }), $.visuals.defaultValue = ["polymer-backbone-cylinder", "polymer-backbone-sphere"], X)
    $.visuals.defaultValue.push("polymer-gap");
  return $;
}
function cV1(Z, J) {
  return V2.createMulti("Backbone", Z, J, lZ, Ab0);
}
var wb0 = v9({
  name: "backbone",
  label: "Backbone",
  description: "Displays polymer backbone with cylinders and spheres.",
  factory: cV1,
  getParams: uV1,
  defaultValues: j.getDefaultValues(Bb0),
  defaultColorTheme: { name: "chain-id" },
  defaultSizeTheme: { name: "uniform" },
  isApplicable: (Z) => Z.polymerResidueCount > 0
});

// node_modules/molstar/lib/mol-repr/structure/visual/plane-image.js
var lV1 = M.set, nV1 = M.transformMat4, iV1 = M.squaredDistance, fZ0 = {
  ...v_0,
  interpolation: j.Select("nearest", j.objectToOptions(yh)),
  imageResolution: j.Numeric(0.5, { min: 0.01, max: 20, step: 0.01 }, { description: "Grid resolution/cell spacing.", ...q1.CustomQualityParamInfo }),
  mode: j.Select("frame", j.arrayToOptions(["frame", "plane"]), { description: "Frame: slice through the structure along arbitrary axes in any step size. Plane: an arbitrary plane defined by point and normal." }),
  offset: j.Numeric(0, { min: -1, max: 1, step: 0.01 }, { isEssential: !0, immediateUpdate: !0, hideIf: (Z) => Z.mode !== "frame", description: "Relative offset from center." }),
  axis: j.Select("c", j.arrayToOptions(["a", "b", "c"]), { isEssential: !0, hideIf: (Z) => Z.mode !== "frame" }),
  rotation: j.Group({
    axis: j.Vec3(M.create(1, 0, 0), {}, { description: "Axis of rotation" }),
    angle: j.Numeric(0, { min: -180, max: 180, step: 1 }, { immediateUpdate: !0, description: "Axis rotation angle in Degrees" })
  }, { isExpanded: !0, hideIf: (Z) => Z.mode !== "frame" }),
  plane: j.Group({
    point: j.Vec3(M.create(0, 0, 0), {}, { description: "Plane point" }),
    normal: j.Vec3(M.create(1, 0, 0), {}, { description: "Plane normal" })
  }, { isExpanded: !0, hideIf: (Z) => Z.mode !== "plane" }),
  extent: j.Select("frame", j.arrayToOptions(["frame", "sphere"]), { description: "Extent of the plane, either box (frame) or sphere." }),
  margin: j.Numeric(4, { min: 0, max: 50, step: 1 }, { immediateUpdate: !0, description: "Margin around the structure in Angstrom" }),
  frame: j.Select("principalAxes", j.arrayToOptions(["principalAxes", "boundingBox"])),
  antialias: j.Boolean(!0, { description: "Antialiasing of structure edges." }),
  cutout: j.Boolean(!1, { description: "Cutout the structure from the image." }),
  defaultColor: j.Color(i0(13421772), { description: "Default color for parts of the image that are not covered by the color theme." }),
  includeParent: j.Boolean(!1, { description: "Show parent structure (but within extent of this structure)." })
};
function jb0(Z) {
  return S_0({
    defaultProps: j.getDefaultValues(fZ0),
    createGeometry: sV1,
    createLocationIterator: _9.fromStructure,
    getLoci: RX,
    eachLocation: LX,
    setUpdateState: (J, $, X, Y, Q) => {
      J.createGeometry = $.imageResolution !== X.imageResolution || $.mode !== X.mode || $.margin !== X.margin || $.frame !== X.frame || $.extent !== X.extent || !M.equals($.rotation.axis, X.rotation.axis) || $.rotation.angle !== X.rotation.angle || $.offset !== X.offset || $.axis !== X.axis || !M.equals($.plane.point, X.plane.point) || !M.equals($.plane.normal, X.plane.normal) || $.antialias !== X.antialias || $.cutout !== X.cutout || $.defaultColor !== X.defaultColor || !oJ.areEqual(Y.color, Q.color) || !J9.areEqual(Y.size, Q.size);
    }
  }, Z);
}
function oV1(Z, J) {
  let { mode: $, axis: X, frame: Y, extent: Q, margin: W, rotation: K, plane: G, includeParent: H } = J;
  if (H && Z.child)
    Z = Z.child;
  let N = M(), q = M(), U = M(), F = M(), E = M(), R = M(), z = 0, D = 0, A = 0, B, T, w;
  if (Y === "principalAxes") {
    let I = s0.getPrincipalAxes(Z).boxAxes;
    [z, D, A] = m7.size(M(), I), B = I.dirA, T = I.dirB, w = I.dirC, M.copy(R, I.origin);
  } else
    [z, D, A] = t1.size(M(), Z.boundary.box), B = M.create(1, 0, 0), T = M.create(0, 1, 0), w = M.create(0, 0, 1), M.copy(R, Z.boundary.sphere.center);
  if (M.set(q, z, D, A), X === "c")
    M.set(N, z, D, A), M.copy(U, B), M.copy(F, T), M.copy(E, w);
  else if (X === "b")
    M.set(N, z, A, D), M.copy(U, B), M.copy(E, T), M.copy(F, w);
  else
    M.set(N, D, A, z), M.copy(E, B), M.copy(U, T), M.copy(F, w);
  if (K.angle !== 0) {
    let I = M();
    M.scaleAndAdd(I, I, B, K.axis[0]), M.scaleAndAdd(I, I, T, K.axis[1]), M.scaleAndAdd(I, I, w, K.axis[2]), M.normalize(I, I);
    let S = e.fromRotation(e(), _8(K.angle), I);
    M.transformDirection(U, U, S), M.transformDirection(F, F, S), M.transformDirection(E, E, S);
  }
  if (Q === "sphere" || K.angle !== 0) {
    let I = Z.boundary.sphere.radius * 2, S = M.magnitude(t1.size(M(), t1.fromSphere3D(t1(), Z.boundary.sphere)));
    if (M.set(N, S, S, I), Q === "sphere")
      M.set(q, I, I, I);
  }
  M.addScalar(N, N, W * 2), M.addScalar(q, q, W * 2);
  let V = k8.identity();
  if (Y === "principalAxes")
    k8.fromBasis(V, M.normalize(M(), B), M.normalize(M(), T), M.normalize(M(), w));
  if ($ === "plane") {
    if (M.copy(R, G.point), M.copy(E, G.normal), M.cross(U, E, M.unitX), M.dot(U, U) < u8)
      M.cross(U, E, M.unitY);
    M.normalize(U, U), M.cross(F, E, U), M.normalize(F, F);
  }
  let P = {
    type: Q === "sphere" ? 2 : 3,
    center: R,
    scale: q,
    rotation: V,
    transform: e.identity()
  };
  return { size: N, major: U, minor: F, normal: E, center: R, trim: P };
}
function sV1(Z, J, $, X, Y) {
  let { imageResolution: Q, offset: W, antialias: K, cutout: G, defaultColor: H } = X, N = 1 / Q, q = "color" in $.color && $.color.color ? $.color.color : () => i0(16777215), { size: U, major: F, minor: E, normal: R, center: z, trim: D } = oV1(J, X), A = M.create(U[0], U[1], 1), B = M.setMagnitude(M(), R, U[2] / 2), T = Math.floor(U[1] * N), w = Math.floor(U[0] * N), V = e.identity(), P = M(), I = M();
  M.add(P, z, F), e.targetTo(V, z, P, E), M.scaleAndAdd(I, z, B, W), e.setTranslation(V, I), e.mul(V, V, e.rotY90), e.scale(V, V, A);
  let { getSerialIndex: S } = J.serialMapping, f = $.color.granularity.startsWith("vertex"), v = tZ.fromNormalAndCoplanarPoint(tZ(), M.normalize(M(), R), I), h = e.invert(e(), V), x = b$(M(), M()), b = W0.Location.create(J), { units: g } = J, m = 0;
  for (let Z0 = 0, U0 = g.length;Z0 < U0; ++Z0) {
    let { elements: a } = g[Z0];
    b.unit = g[Z0];
    for (let Q0 = 0, $0 = a.length;Q0 < $0; ++Q0) {
      b.element = a[Q0];
      let R0 = $.size.size(b);
      if (R0 > m)
        m = R0;
    }
  }
  let i = new Uint8Array(T * w * 4), r = new Uint8Array(T * w * 4), Y0 = new Float32Array(T * w);
  Y0.fill(Number.MAX_VALUE);
  let c = M(), n = M(), l = M();
  if (f) {
    let Z0 = 0;
    for (let U0 = 0;U0 < w; ++U0)
      for (let a = 0;a < T; ++a) {
        let Q0 = x8(a + 0.5, 0, T - 1) / T - 0.5, $0 = x8(U0 + 0.5, 0, w - 1) / w - 0.5;
        M.set(P, $0, -Q0, 0), M.transformMat4(P, P, V), M.copy(x.position, P);
        let R0 = q(x, !1);
        i0.toArray(R0, i, Z0), i[Z0 + 3] = G ? 0 : 255, Z0 += 4;
      }
  } else
    for (let Z0 = 0, U0 = T * w * 4;Z0 < U0; Z0 += 4)
      i0.toArray(H, i, Z0), i[Z0 + 3] = G ? 0 : 255;
  for (let Z0 = 0, U0 = g.length;Z0 < U0; ++Z0) {
    let a = g[Z0], { elements: Q0, conformation: $0 } = a;
    b.unit = g[Z0];
    for (let R0 = 0, X0 = Q0.length;R0 < X0; ++R0) {
      let E0 = Q0[R0];
      b.element = E0, $0.position(E0, c);
      let V0 = tZ.distanceToPoint(v, c);
      if (Math.abs(V0) > m)
        continue;
      let u0 = $.size.size(b);
      if (Math.abs(V0) > u0)
        continue;
      let N0 = Math.cos(Math.abs(V0) / u0), q0 = K ? Q * N0 : 0, A0 = u0 + q0 / 2, S0 = A0 * A0;
      M.scaleAndAdd(n, c, v.normal, -V0), M.transformMat4(l, n, h), M.addScalar(l, l, 0.5);
      let a0 = Math.floor(l[0] * w), D1 = T - Math.ceil(l[1] * T), Y1 = Math.ceil(u0 * N), u1 = Math.max(0, a0 - Y1), b0 = Math.max(0, D1 - Y1), x0 = Math.min(w, a0 + Y1 + 2), m0 = Math.min(T, D1 + Y1 + 2);
      M.copy(x.position, n);
      let e0 = f ? H : q(b, !1), p = S(b.unit, b.element);
      for (let J0 = u1;J0 < x0; ++J0)
        for (let T0 = b0;T0 < m0; ++T0) {
          let o0 = x8(J0 + 0.5, 0, w - 1) / w - 0.5, y0 = x8(T0 + 0.5, 0, T - 1) / T - 0.5;
          lV1(P, o0, -y0, 0), nV1(P, P, V);
          let $1 = iV1(P, c);
          if ($1 > S0)
            continue;
          let F1 = J0 * T + T0;
          if ($1 < Y0[F1]) {
            let A1 = F1 * 4, P1 = Math.sqrt($1) - u0 + q0 / 2, S1 = P1 > 0 ? 1 - P1 / q0 : 1;
            if (f) {
              if (S1 === 1)
                Y0[F1] = $1;
              else if (G) {
                if (r[A1] !== 0 || r[A1 + 1] !== 0 || r[A1 + 2] !== 0)
                  S1 = 1;
              }
            } else if (S1 === 1)
              Y0[F1] = $1, i0.toArray(e0, i, A1);
            else if (G) {
              if (i0.toArray(e0, i, A1), r[A1] !== 0 || r[A1 + 1] !== 0 || r[A1 + 2] !== 0)
                S1 = 1;
            } else
              i0.toArray(i0.interpolate(i0.fromArray(i, A1), e0, S1), i, A1);
            if (UH(p, r, A1), r[A1 + 3] = K ? Math.round(255 * S1) : 255, G)
              i[F1 * 4 + 3] = K ? Math.round(255 * S1) : 255;
          }
        }
    }
  }
  let u = { width: T, height: w, array: i, flipY: !0 }, G0 = { width: T, height: w, array: r, flipY: !0 }, F0 = { width: 1, height: 1, array: new Float32Array(1), flipY: !0 }, t = new Float32Array([
    -0.5,
    0.5,
    0,
    0.5,
    0.5,
    0,
    -0.5,
    -0.5,
    0,
    0.5,
    -0.5,
    0
  ]);
  return SW(V, t, 0, 4), VY.create(u, t, G0, F0, D, -1, Y);
}

// node_modules/molstar/lib/mol-repr/structure/representation/plane.js
var Tb0 = {
  "plane-image": (Z, J) => M9("Plane image", Z, J, jb0)
}, _b0 = {
  ...fZ0,
  visuals: j.MultiSelect(["plane-image"], j.objectToOptions(Tb0))
};
function aV1(Z, J) {
  return _b0;
}
function rV1(Z, J) {
  return V2.createMulti("Plane", Z, J, lZ, Tb0);
}
var Vb0 = v9({
  name: "plane",
  label: "Plane",
  description: "Displays planes.",
  factory: rV1,
  getParams: aV1,
  defaultValues: j.getDefaultValues(_b0),
  defaultColorTheme: { name: "element-symbol" },
  defaultSizeTheme: { name: "physical" },
  isApplicable: (Z) => Z.elementCount > 0,
  getData: (Z, J) => {
    return J.includeParent ? Z.asParent() : Z;
  },
  mustRecreate: (Z, J) => {
    return Z.includeParent !== J.includeParent;
  }
});

// node_modules/molstar/lib/mol-repr/structure/registry.js
class Sw extends xV {
  constructor() {
    super();
    B7(Sw.BuiltIn, (Z, J) => {
      if (Z.name !== J)
        throw new Error(`Fix BuiltInStructureRepresentations to have matching names. ${Z.name} ${J}`);
      this.add(Z);
    });
  }
}
(function(Z) {
  Z.BuiltIn = {
    cartoon: rf0,
    backbone: wb0,
    "ball-and-stick": CS0,
    carbohydrate: oS0,
    ellipsoid: Xh0,
    "gaussian-surface": Ph0,
    "gaussian-volume": zb0,
    label: Sh0,
    line: Ub0,
    "molecular-surface": ph0,
    orientation: nh0,
    plane: Vb0,
    point: sh0,
    putty: Zb0,
    spacefill: $b0
  };
})(Sw || (Sw = {}));

// node_modules/molstar/lib/mol-plugin/animation-loop.js
var tV1 = 33.333333333333336;

class hZ0 {
  get isAnimating() {
    return this._isAnimating;
  }
  async tick(Z, J) {
    var $, X;
    if (await this.plugin.managers.animation.tick(Z, J === null || J === void 0 ? void 0 : J.isSynchronous, J === null || J === void 0 ? void 0 : J.animation), ($ = this.plugin.canvas3d) === null || $ === void 0 || $.tick(Z, J), K1) {
      let Y = (X = this.plugin.canvas3d) === null || X === void 0 ? void 0 : X.webgl.timer.resolve();
      if (Y)
        for (let Q of Y)
          qV([Q]);
    }
  }
  resetTime(Z) {
    var J;
    (J = this.plugin.canvas3d) === null || J === void 0 || J.resetTime(Z);
  }
  start(Z) {
    var J, $;
    if ((J = this.plugin.canvas3d) === null || J === void 0 || J.resume(), this._isAnimating = !0, this.resetTime(0), this.properTimeT = 0, this.lastTickT = m6(), Z === null || Z === void 0 ? void 0 : Z.immediate)
      this.frame();
    else
      this.currentFrame = ($ = this.plugin.canvas3d) === null || $ === void 0 ? void 0 : $.requestAnimationFrame(this.frame);
  }
  stop(Z) {
    var J, $;
    if (this._isAnimating = !1, this.currentFrame !== void 0)
      (J = this.plugin.canvas3d) === null || J === void 0 || J.cancelAnimationFrame(this.currentFrame), this.currentFrame = void 0;
    if (Z === null || Z === void 0 ? void 0 : Z.noDraw)
      ($ = this.plugin.canvas3d) === null || $ === void 0 || $.pause(Z === null || Z === void 0 ? void 0 : Z.noDraw);
  }
  constructor(Z) {
    this.plugin = Z, this.lastTickT = 0, this.properTimeT = 0, this.currentFrame = void 0, this._isAnimating = !1, this.frame = (J, $) => {
      var X;
      let Y = m6(), Q = Y - this.lastTickT;
      if (this.lastTickT = Y, this.properTimeT += Math.min(Q, tV1), this.tick(this.properTimeT, { xrFrame: $ }), this._isAnimating)
        this.currentFrame = (X = this.plugin.canvas3d) === null || X === void 0 ? void 0 : X.requestAnimationFrame(this.frame);
    };
  }
}

// node_modules/molstar/lib/mol-plugin/util/substructure-parent-helper.js
class bZ0 {
  getDecorator(Z) {
    let J = this.plugin.state.data.tree, $ = J.children.get(Z);
    if ($.size !== 1)
      return Z;
    let X = $.first();
    if (X && J.transforms.get(X).transformer.definition.isDecorator)
      return this.getDecorator(X);
    return Z;
  }
  get(Z, J = !1) {
    let $ = this.root.get(Z);
    if (!$)
      return;
    if (J)
      return this.plugin.state.data.cells.get($.ref);
    return this.plugin.state.data.cells.get(this.getDecorator($.ref));
  }
  addMapping(Z, J, $) {
    if (!D0.Molecule.Structure.is($))
      return !1;
    if (this.tracked.set(J, $.data), this.root.has($.data)) {
      let X = this.root.get($.data);
      X.count++;
    } else {
      let X = Z.select(f2.Generators.byRef(J).rootOfType([D0.Molecule.Structure]))[0];
      if (!X)
        this.root.set($.data, { ref: J, count: 1 });
      else
        this.root.set($.data, { ref: X.transform.ref, count: 1 });
    }
    return !0;
  }
  removeMapping(Z) {
    if (!this.tracked.has(Z))
      return !1;
    let J = this.tracked.get(Z);
    this.tracked.delete(Z);
    let $ = this.root.get(J);
    if ($.count > 1)
      $.count--;
    else
      this.root.delete(J);
    return !0;
  }
  updateMapping(Z, J, $, X) {
    if (!D0.Molecule.Structure.is(X))
      return !1;
    return this.removeMapping(J), this.addMapping(Z, J, X), !0;
  }
  dispose() {
    this.ev.dispose();
  }
  constructor(Z) {
    this.plugin = Z, this.ev = xQ.create(), this.events = {
      updated: this.ev(),
      removed: this.ev()
    }, this.root = /* @__PURE__ */ new Map, this.tracked = /* @__PURE__ */ new Map, Z.state.data.events.object.created.subscribe((J) => {
      this.addMapping(J.state, J.ref, J.obj);
    }), Z.state.data.events.object.removed.subscribe((J) => {
      if (this.removeMapping(J.ref))
        this.events.removed.next({ ref: J.ref, obj: J.obj });
    }), Z.state.data.events.object.updated.subscribe((J) => {
      if (this.updateMapping(J.state, J.ref, J.oldObj, J.obj))
        this.events.updated.next({ ref: J.ref, oldObj: J.oldObj, obj: J.obj });
    });
  }
}

// node_modules/molstar/lib/mol-plugin/util/task-manager.js
class kP {
  constructor() {
    this.ev = xQ.create(), this.id = 0, this.runningTasks = /* @__PURE__ */ new Set, this.abortRequests = /* @__PURE__ */ new Map, this.options = /* @__PURE__ */ new Map, this.currentContext = [], this.events = {
      progress: this.ev(),
      finished: this.ev()
    };
  }
  tryGetAbortTaskId(Z) {
    if (this.abortRequests.has(Z.progress.taskId))
      return Z.progress.taskId;
    for (let J of Z.children) {
      let $ = this.tryGetAbortTaskId(J);
      if ($ !== void 0)
        return $;
    }
    return;
  }
  track(Z, J) {
    return ($) => {
      var X;
      if ($.canAbort && $.requestAbort) {
        let Q = this.tryGetAbortTaskId($.root);
        if (Q !== void 0)
          $.requestAbort(this.abortRequests.get(Q));
      }
      let Y = m6() - $.root.progress.startedTime;
      this.events.progress.next({
        id: Z,
        useOverlay: (X = this.options.get(J)) === null || X === void 0 ? void 0 : X.useOverlay,
        level: Y < 250 ? "none" : "background",
        progress: $
      });
    };
  }
  async run(Z, J) {
    let $ = this.id++, X;
    if ((J === null || J === void 0 ? void 0 : J.createNewContext) || this.currentContext.length === 0)
      X = { ctx: JK0(Z, this.track($, Z.id), 100), refCount: 1 };
    else
      X = this.currentContext[this.currentContext.length - 1], X.refCount++;
    try {
      return this.options.set(Z.id, { useOverlay: !!(J === null || J === void 0 ? void 0 : J.useOverlay) }), this.runningTasks.add(Z.id), await IS(X.ctx, Z);
    } finally {
      if (this.options.delete(Z.id), this.runningTasks.delete(Z.id), this.events.finished.next({ id: $ }), this.abortRequests.delete(Z.id), X.refCount--, X.refCount === 0)
        ZH(this.currentContext, X);
    }
  }
  requestAbortAll(Z) {
    this.runningTasks.forEach((J) => this.abortRequests.set(J, Z));
  }
  requestAbort(Z, J) {
    let $ = typeof Z === "number" ? Z : Z.root.progress.taskId;
    this.abortRequests.set($, J);
  }
  dispose() {
    this.ev.dispose();
  }
}
(function(Z) {
  function J(X) {
    return new Promise((Y) => setTimeout(Y, X));
  }
  function $(X) {
    return n0.create("Test", async (Y) => {
      let Q = 0;
      while (Q < X) {
        if (await J(100 + Math.random() * 200), Y.shouldUpdate)
          await Y.update({ message: "Step " + Q, current: Q, max: X, isIndeterminate: !1 });
        Q++;
      }
    });
  }
  Z.testTask = $;
})(kP || (kP = {}));

// node_modules/molstar/lib/mol-plugin/util/toast.js
class xZ0 extends pX {
  findByKey(Z) {
    return this.state.entries.find((J) => !!J && J.key === Z);
  }
  show(Z) {
    let J = this.state.entries, $ = void 0, X = ++this.serialId, Y;
    if (Z.key && ($ = this.findByKey(Z.key))) {
      if ($.timeout !== void 0)
        clearTimeout($.timeout);
      Y = $.serialNumber, J = J.remove($.id);
    } else
      Y = ++this.serialNumber;
    if ($ = {
      id: X,
      serialNumber: Y,
      key: Z.key,
      title: Z.title,
      message: Z.message,
      timeout: this.timeout(X, Z.timeoutMs),
      hide: () => this.hideId(X)
    }, this.updateState({ entries: J.set(X, $) }))
      this.events.changed.next(void 0);
  }
  timeout(Z, J) {
    if (J === void 0)
      return;
    if (J < 0)
      J = 500;
    return setTimeout(() => {
      let $ = this.state.entries.get(Z);
      $.timeout = void 0, this.hide($);
    }, J);
  }
  hideId(Z) {
    this.hide(this.state.entries.get(Z));
  }
  hide(Z) {
    if (!Z)
      return;
    if (Z.timeout !== void 0)
      clearTimeout(Z.timeout);
    if (Z.hide = void 0, this.updateState({ entries: this.state.entries.delete(Z.id) }))
      this.events.changed.next(void 0);
  }
  constructor(Z) {
    super({ entries: o$() });
    this.events = {
      changed: this.ev()
    }, this.serialNumber = 0, this.serialId = 0, h1.Toast.Show.subscribe(Z, (J) => this.show(J)), h1.Toast.Hide.subscribe(Z, (J) => this.hide(this.findByKey(J.key)));
  }
}

// node_modules/molstar/lib/mol-plugin/util/viewport-screenshot.js
function eV1() {
  let Z = document.createElement("canvas");
  if (Z.getContext && Z.getContext("2d"))
    return Z.toDataURL("image/webp").indexOf("data:image/webp") === 0;
  else
    return !1;
}

class yZ0 extends Oq {
  createParams() {
    let Z = 8192;
    if (this.plugin.canvas3d) {
      let { webgl: J } = this.plugin.canvas3d;
      Z = Math.floor(Math.min(J.maxRenderbufferSize, J.maxTextureSize) / 2);
    }
    return {
      resolution: j.MappedStatic("viewport", {
        viewport: j.Group({}),
        hd: j.Group({}),
        "full-hd": j.Group({}),
        "ultra-hd": j.Group({}),
        custom: j.Group({
          width: j.Numeric(1920, { min: 128, max: Z, step: 1 }),
          height: j.Numeric(1080, { min: 128, max: Z, step: 1 })
        }, { isFlat: !0 })
      }, {
        options: [
          ["viewport", "Viewport"],
          ["hd", "HD (1280 x 720)"],
          ["full-hd", "Full HD (1920 x 1080)"],
          ["ultra-hd", "Ultra HD (3840 x 2160)"],
          ["custom", "Custom"]
        ]
      }),
      format: j.MappedStatic("png", {
        png: j.Group({}),
        webp: j.Group({
          quality: j.Numeric(0.9, { min: 0, max: 1, step: 0.01 })
        }),
        jpeg: j.Group({
          quality: j.Numeric(0.9, { min: 0, max: 1, step: 0.01 })
        })
      }, {
        options: [
          ["png", "PNG"],
          ["jpeg", "JPEG"],
          ...eV1() ? [["webp", "WebP"]] : []
        ]
      }),
      transparent: j.Boolean(!1),
      axes: ZE.axes,
      illumination: j.Group({
        extraIterations: j.Numeric(1, { min: 0, max: 5, step: 1 }),
        targetIterationTimeMs: j.Numeric(300, { min: 100, max: 3000, step: 10 })
      })
    };
  }
  get params() {
    if (this._params)
      return this._params;
    return this._params = this.createParams();
  }
  get values() {
    return this.behaviors.values.value;
  }
  get cropParams() {
    return this.behaviors.cropParams.value;
  }
  get relativeCrop() {
    return this.behaviors.relativeCrop.value;
  }
  getCanvasSize() {
    var Z, J;
    return {
      width: ((Z = this.plugin.canvas3d) === null || Z === void 0 ? void 0 : Z.webgl.gl.drawingBufferWidth) || 0,
      height: ((J = this.plugin.canvas3d) === null || J === void 0 ? void 0 : J.webgl.gl.drawingBufferHeight) || 0
    };
  }
  getSize() {
    let Z = this.values;
    switch (Z.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: Z.resolution.params.width, height: Z.resolution.params.height };
    }
  }
  getPostprocessingProps() {
    let Z = this.plugin.canvas3d, J = Z.props.postprocessing.occlusion;
    return {
      ...Z.props.postprocessing,
      occlusion: J.name === "on" ? { name: "on", params: { ...J.params, samples: 128, resolutionScale: Z.webgl.pixelRatio, transparentThreshold: 1 } } : J
    };
  }
  getIlluminationProps(Z) {
    let $ = this.plugin.canvas3d.props.illumination, { extraIterations: X, targetIterationTimeMs: Y } = this.values.illumination;
    return {
      ...$,
      enabled: Z ? !1 : $.enabled,
      maxIterations: Math.ceil(Math.log2(Math.pow(2, $.maxIterations + X) * $.rendersPerFrame[1])),
      targetFps: 1000 / Y,
      denoiseThreshold: [$.denoiseThreshold[0], $.denoiseThreshold[0]],
      rendersPerFrame: [1, 1]
    };
  }
  createPass(Z) {
    let J = this.plugin.canvas3d, { colorBufferFloat: $, textureFloat: X } = J.webgl.extensions;
    return J.getImagePass({
      transparentBackground: this.values.transparent,
      cameraHelper: { axes: this.values.axes },
      multiSample: {
        ...J.props.multiSample,
        mode: Z ? "off" : "on",
        sampleLevel: $ && X ? 4 : 2,
        reuseOcclusion: !1
      },
      postprocessing: this.getPostprocessingProps(),
      marking: { ...J.props.marking },
      illumination: this.getIlluminationProps(Z)
    });
  }
  get previewPass() {
    return this._previewPass || (this._previewPass = this.createPass(!0));
  }
  get imagePass() {
    if (this._imagePass) {
      let Z = this.plugin.canvas3d;
      return this._imagePass.setProps({
        cameraHelper: { axes: this.values.axes },
        transparentBackground: this.values.transparent,
        postprocessing: this.getPostprocessingProps(),
        marking: { ...Z.props.marking },
        illumination: this.getIlluminationProps(!1)
      }), this._imagePass;
    }
    return this._imagePass = this.createPass(!1);
  }
  getFilename(Z) {
    if (typeof Z !== "string")
      Z = this.extension;
    let J = this.plugin.state.data.select(f2.Generators.rootsOfType(D0.Molecule.Model)).map((Y) => Y.obj.data), $ = /* @__PURE__ */ new Set;
    return J.forEach((Y) => $.add(Y.entryId.toUpperCase())), `${uZ.toArray($).join("-") || "molstar-image"}${Z}`;
  }
  resetCrop() {
    this.behaviors.relativeCrop.next({ x: 0, y: 0, width: 1, height: 1 });
  }
  toggleAutocrop() {
    if (this.cropParams.auto)
      this.behaviors.cropParams.next({ ...this.cropParams, auto: !1 }), this.resetCrop();
    else
      this.behaviors.cropParams.next({ ...this.cropParams, auto: !0 });
  }
  get isFullFrame() {
    let Z = this.relativeCrop;
    return dZ(Z.x, 0, 0.00001) && dZ(Z.y, 0, 0.00001) && dZ(Z.width, 1, 0.00001) && dZ(Z.height, 1, 0.00001);
  }
  autocrop(Z = this.cropParams.relativePadding) {
    let { data: J, width: $, height: X } = this.previewData.image, Y = this.previewData.transparent, Q = Y ? this.previewData.background : 4278190080 | this.previewData.background, W = $, K = 0, G = X, H = 0;
    for (let F = 0;F < X; F++) {
      let E = F * $;
      for (let R = 0;R < $; R++) {
        let z = 4 * (E + R);
        if (Y) {
          if (J[z + 3] === 0)
            continue;
        } else if ((J[z] << 16 | J[z + 1] << 8 | J[z + 2] | J[z + 3] << 24) === Q)
          continue;
        if (R < W)
          W = R;
        if (R > K)
          K = R;
        if (F < G)
          G = F;
        if (F > H)
          H = F;
      }
    }
    if (W > K) {
      let F = W;
      W = K, K = F;
    }
    if (G > H) {
      let F = G;
      G = H, H = F;
    }
    let N = K - W + 1, q = H - G + 1;
    W -= Z * N, K += Z * N, G -= Z * q, H += Z * q;
    let U = {
      x: Math.max(0, W / $),
      y: Math.max(0, G / X),
      width: Math.min(1, (K - W + 1) / $),
      height: Math.min(1, (H - G + 1) / X)
    };
    this.behaviors.relativeCrop.next(U);
  }
  async getPreview(Z, J = 320) {
    let { width: $, height: X } = this.getSize();
    if ($ <= 0 || X <= 0)
      return;
    let Y = $ / X, Q = 0, W = 0;
    if (Y > 1)
      Q = J, W = Math.round(J / Y);
    else
      W = J, Q = Math.round(J * Y);
    let K = this.plugin.canvas3d.props;
    this.previewPass.setProps({
      cameraHelper: { axes: this.values.axes },
      transparentBackground: this.values.transparent,
      postprocessing: K.postprocessing,
      marking: K.marking
    });
    let G = await this.previewPass.getImageData(Z, Q, W), H = this.previewCanvas;
    H.width = G.width, H.height = G.height, this.previewData.image = G, this.previewData.background = K.renderer.backgroundColor, this.previewData.transparent = this.values.transparent;
    let N = H.getContext("2d");
    if (!N)
      throw new Error("Could not create canvas 2d context");
    if (N.putImageData(G, 0, 0), this.cropParams.auto)
      this.autocrop();
    return this.events.previewed.next(void 0), { canvas: H, width: Q, height: W };
  }
  getSizeAndViewport() {
    let { width: Z, height: J } = this.getSize(), $ = this.relativeCrop, X = {
      x: Math.floor($.x * Z),
      y: Math.floor($.y * J),
      width: Math.ceil($.width * Z),
      height: Math.ceil($.height * J)
    };
    if (X.width + X.x > Z)
      X.width = Z - X.x;
    if (X.height + X.y > J)
      X.height = J - X.y;
    return { width: Z, height: J, viewport: X };
  }
  async draw(Z) {
    let { width: J, height: $, viewport: X } = this.getSizeAndViewport();
    if (J <= 0 || $ <= 0)
      return;
    this.plugin.animationLoop.stop({ noDraw: !0 });
    try {
      await Z.update("Rendering image...");
      let Y = this.imagePass;
      await Y.updateBackground();
      let Q = await Y.getImageData(Z, J, $, X);
      await Z.update("Encoding image...");
      let W = this.canvas;
      W.width = Q.width, W.height = Q.height;
      let K = W.getContext("2d");
      if (!K)
        throw new Error("Could not create canvas 2d context");
      K.putImageData(Q, 0, 0);
    } finally {
      this.plugin.animationLoop.start({ immediate: !0 });
    }
    return;
  }
  copyToClipboardTask() {
    let Z = navigator.clipboard;
    if (!(Z === null || Z === void 0 ? void 0 : Z.write)) {
      this.plugin.log.error("clipboard.write not supported!");
      return;
    }
    return n0.create("Copy Image", async (J) => {
      await this.draw(J), await J.update("Converting image...");
      let $ = this.mimeType, X = await HI(this.canvas, $, this.quality), Y = new ClipboardItem({ [$]: X });
      await Z.write([Y]), this.plugin.log.message("Image copied to clipboard.");
    });
  }
  get mimeType() {
    var Z, J;
    return `image/${(J = (Z = this.values.format) === null || Z === void 0 ? void 0 : Z.name) !== null && J !== void 0 ? J : "png"}`;
  }
  get extension() {
    var Z, J, $;
    switch ((Z = this.values.format) === null || Z === void 0 ? void 0 : Z.name) {
      case "jpeg":
        return ".jpg";
      default:
        return `.${($ = (J = this.values.format) === null || J === void 0 ? void 0 : J.name) !== null && $ !== void 0 ? $ : "png"}`;
    }
  }
  get quality() {
    var Z, J, $, X;
    switch ((Z = this.values.format) === null || Z === void 0 ? void 0 : Z.name) {
      case "webp":
      case "jpeg":
        return (X = ($ = (J = this.values.format) === null || J === void 0 ? void 0 : J.params) === null || $ === void 0 ? void 0 : $.quality) !== null && X !== void 0 ? X : 0.9;
      default:
        return;
    }
  }
  getImageDataUri() {
    return this.plugin.runTask(n0.create("Generate Image", async (Z) => {
      return await this.draw(Z), await Z.update("Converting image..."), this.canvas.toDataURL(this.mimeType);
    }));
  }
  copyToClipboard() {
    let Z = this.copyToClipboardTask();
    if (!Z)
      return;
    return this.plugin.runTask(Z);
  }
  downloadTask(Z) {
    return n0.create("Download Image", async (J) => {
      await this.draw(J), await J.update("Downloading image...");
      let $ = await HI(this.canvas, this.mimeType, this.quality);
      jx($, Z !== null && Z !== void 0 ? Z : this.getFilename(this.extension));
    });
  }
  download(Z) {
    return this.plugin.runTask(this.downloadTask(Z), { useOverlay: !0 });
  }
  constructor(Z) {
    super();
    this.plugin = Z, this._params = void 0, this.behaviors = {
      values: this.ev.behavior({
        transparent: this.params.transparent.defaultValue,
        format: { name: "png", params: {} },
        axes: { name: "off", params: {} },
        resolution: this.params.resolution.defaultValue,
        illumination: this.params.illumination.defaultValue
      }),
      cropParams: this.ev.behavior({ auto: !0, relativePadding: 0.1 }),
      relativeCrop: this.ev.behavior({ x: 0, y: 0, width: 1, height: 1 })
    }, this.events = {
      previewed: this.ev()
    }, this.canvas = function() {
      return document.createElement("canvas");
    }(), this.previewCanvas = function() {
      return document.createElement("canvas");
    }(), this.previewData = {
      image: { data: new Uint8ClampedArray(1), width: 1, height: 0 },
      background: i0(0),
      transparent: !1
    };
  }
}

// node_modules/molstar/lib/mol-plugin-state/manager/drag-and-drop.js
class gZ0 {
  addHandler(Z, J) {
    let $ = this.handlers.findIndex((X) => X[0] === Z);
    if ($ < 0)
      this.handlers.push([Z, J]);
    else
      this.handlers[$][1] = J;
  }
  removeHandler(Z) {
    let J = this.handlers.findIndex(($) => $[0] === Z);
    if (J >= 0)
      this.handlers.splice(J, 1);
  }
  async handle(Z) {
    for (let J = this.handlers.length - 1;J >= 0; J--) {
      let $ = this.handlers[J][1];
      if (await $(Z, this.plugin))
        return;
    }
    ZI1(this.plugin, Z);
  }
  dispose() {
    this.handlers.length = 0;
  }
  constructor(Z) {
    this.plugin = Z, this.handlers = [];
  }
}
function ZI1(Z, J) {
  let $ = J.filter((X) => {
    let Y = X.name.toLowerCase();
    return Y.endsWith(".molx") || Y.endsWith(".molj");
  });
  if ($.length > 0)
    h1.State.Snapshots.OpenFile(Z, { file: $[0] });
  else
    Z.runTask(Z.state.data.applyAction(wI, {
      files: J.map((X) => E6.File(X)),
      format: { name: "auto", params: {} },
      visuals: !0
    }));
}

// node_modules/molstar/lib/mol-util/error-context.js
class mZ0 {
  constructor() {
    this.errors = Object.create(null);
  }
  get(Z) {
    var J;
    return (J = this.errors[Z]) !== null && J !== void 0 ? J : [];
  }
  add(Z, J) {
    if (Z in this.errors && Array.isArray(this.errors[Z]))
      this.errors[Z].push(J);
    else
      this.errors[Z] = [J];
  }
  clear(Z) {
    delete this.errors[Z];
  }
}

// node_modules/molstar/lib/mol-plugin/container.js
class dZ0 {
  mount(Z) {
    var J;
    if (this.parent.parentElement !== Z)
      (J = this.parent.parentElement) === null || J === void 0 || J.removeChild(this.parent);
    Z.appendChild(this.parent);
  }
  unmount() {
    var Z;
    (Z = this.parent.parentElement) === null || Z === void 0 || Z.removeChild(this.parent);
  }
  constructor(Z) {
    this.options = Z;
    let J = document.createElement("div");
    Object.assign(J.style, {
      position: "absolute",
      left: 0,
      top: 0,
      right: 0,
      bottom: 0,
      "-webkit-user-select": "none",
      "user-select": "none",
      "-webkit-tap-highlight-color": "rgba(0,0,0,0)",
      "-webkit-touch-callout": "none",
      "touch-action": "manipulation"
    });
    let $ = Z === null || Z === void 0 ? void 0 : Z.canvas;
    if (!$)
      $ = document.createElement("canvas"), J.appendChild($);
    this.canvas = $, this.parent = J;
  }
}

// node_modules/molstar/lib/mol-plugin/context.js
class pZ0 {
  get isInitialized() {
    return this._isInitialized;
  }
  build() {
    return this.state.data.build();
  }
  async initViewerAsync(Z, J, $) {
    return this._initViewer(Z, J, $);
  }
  async initContainerAsync(Z) {
    return this._initContainer(Z);
  }
  async mountAsync(Z, J) {
    return this._mount(Z, J);
  }
  _initContainer(Z) {
    var J, $;
    if (this.container)
      return !0;
    let X = new dZ0({
      checkeredCanvasBackground: Z === null || Z === void 0 ? void 0 : Z.checkeredCanvasBackground,
      canvas: (J = Z === null || Z === void 0 ? void 0 : Z.canvas3dContext) === null || J === void 0 ? void 0 : J.canvas
    });
    if (!this._initViewer(X.canvas, X.parent, Z === null || Z === void 0 ? void 0 : Z.canvas3dContext))
      return !1;
    if (Z === null || Z === void 0 ? void 0 : Z.checkeredCanvasBackground)
      ($ = this.canvas3d) === null || $ === void 0 || $.setProps({ checkeredTransparentBackground: !0 });
    return this.container = X, !0;
  }
  _mount(Z, J) {
    var $;
    if (this.disposed)
      throw new Error("Cannot mount a disposed context");
    if (!this._initContainer(J))
      return !1;
    return ($ = this.container) === null || $ === void 0 || $.mount(Z), this.handleResize(), !0;
  }
  unmount() {
    var Z;
    (Z = this.container) === null || Z === void 0 || Z.unmount();
  }
  _initViewer(Z, J, $) {
    var X, Y, Q, W, K, G;
    try {
      if (this.layout.setRoot(J), this.spec.layout && this.spec.layout.initial)
        this.layout.setProps(this.spec.layout.initial);
      if (!$)
        $ = a3.fromCanvas(Z, this.managers.asset, {
          antialias: !((X = this.config.get(W8.General.DisableAntialiasing)) !== null && X !== void 0 ? X : !1),
          preserveDrawingBuffer: !((Y = this.config.get(W8.General.DisablePreserveDrawingBuffer)) !== null && Y !== void 0 ? Y : !1),
          preferWebGl1: this.config.get(W8.General.PreferWebGl1) || !1,
          failIfMajorPerformanceCaveat: !((Q = this.config.get(W8.General.AllowMajorPerformanceCaveat)) !== null && Q !== void 0 ? Q : !1),
          powerPreference: this.config.get(W8.General.PowerPreference) || "high-performance",
          handleResize: this.handleResize
        }, {
          pixelScale: this.config.get(W8.General.PixelScale) || 1,
          pickScale: this.config.get(W8.General.PickScale) || 0.25,
          transparency: this.config.get(W8.General.Transparency) || "wboit",
          resolutionMode: this.config.get(W8.General.ResolutionMode) || "auto"
        });
      this.canvas3dContext = $, this.canvas3d = Bx.create(this.canvas3dContext), this.canvas3dInit.next(!0);
      let H = this.spec.canvas3d, N = i0(16579577);
      if (!H)
        (W = this.canvas3d) === null || W === void 0 || W.setProps({ renderer: { backgroundColor: N } });
      else {
        if (((K = H.renderer) === null || K === void 0 ? void 0 : K.backgroundColor) === void 0)
          H = WQ(H, (q) => {
            if (q.renderer)
              q.renderer.backgroundColor = N;
            else
              q.renderer = { backgroundColor: N };
          });
        (G = this.canvas3d) === null || G === void 0 || G.setProps(H);
      }
      return this.animationLoop.start(), this.helpers.viewportScreenshot = new yZ0(this), this.subs.push(this.canvas3d.interaction.click.subscribe((q) => this.behaviors.interaction.click.next(q))), this.subs.push(this.canvas3d.interaction.drag.subscribe((q) => this.behaviors.interaction.drag.next(q))), this.subs.push(this.canvas3d.interaction.hover.subscribe((q) => this.behaviors.interaction.hover.next(q))), this.subs.push(this.canvas3d.input.resize.pipe(QR(50), bQ(100, void 0, { leading: !1, trailing: !0 })).subscribe(() => this.handleResize())), this.subs.push(this.canvas3d.input.keyDown.subscribe((q) => this.behaviors.interaction.key.next(q))), this.subs.push(this.canvas3d.input.keyUp.subscribe((q) => this.behaviors.interaction.keyReleased.next(q))), this.subs.push(this.canvas3d.xr.isPresenting.subscribe((q) => this.log.info(`WebXR ${q ? "enabled" : "disabled"}`))), this.subs.push(this.canvas3d.xr.requestFailed.subscribe((q) => this.log.error(`WebXR request failed: ${q}`))), this.subs.push(this.layout.events.updated.subscribe(() => requestAnimationFrame(() => this.handleResize()))), this.handleResize(), rG.setImmediate(() => this.initCanvas3dPromiseCallbacks[0]()), !0;
    } catch (H) {
      return this.log.error("" + H), console.error(H), rG.setImmediate(() => this.initCanvas3dPromiseCallbacks[1](H)), !1;
    }
  }
  get isBusy() {
    return this.behaviors.state.isAnimating.value || this.behaviors.state.isUpdating.value;
  }
  get selectionMode() {
    return this.behaviors.interaction.selectionMode.value;
  }
  set selectionMode(Z) {
    this.behaviors.interaction.selectionMode.next(Z);
  }
  dataTransaction(Z, J) {
    return this.runTask(this.state.data.transaction(Z, J));
  }
  clear(Z = !1) {
    var J;
    if (Z)
      (J = this.canvas3d) === null || J === void 0 || J.setProps(GI);
    return h1.State.RemoveObject(this, { state: this.state.data, ref: D8.RootRef });
  }
  dispose(Z) {
    var J, $;
    if (this.disposed)
      return;
    for (let X of this.subs)
      X.unsubscribe();
    if (this.subs = [], this.layout.dispose(), this.managers.markdownExtensions.audio.dispose(), this.animationLoop.stop(), this.commands.dispose(), (J = this.canvas3d) === null || J === void 0 || J.dispose(), !(Z === null || Z === void 0 ? void 0 : Z.doNotDisposeCanvas3DContext))
      ($ = this.canvas3dContext) === null || $ === void 0 || $.dispose(Z);
    this.ev.dispose(), this.state.dispose(), this.helpers.substructureParent.dispose(), B7(this.managers, (X) => {
      var Y;
      return (Y = X === null || X === void 0 ? void 0 : X.dispose) === null || Y === void 0 ? void 0 : Y.call(X);
    }), B7(this.managers.structure, (X) => {
      var Y;
      return (Y = X === null || X === void 0 ? void 0 : X.dispose) === null || Y === void 0 ? void 0 : Y.call(X);
    }), B7(this.managers.volume, (X) => {
      var Y;
      return (Y = X === null || X === void 0 ? void 0 : X.dispose) === null || Y === void 0 ? void 0 : Y.call(X);
    }), this.unmount(), this.container = void 0, this.customState = {}, this.disposed = !0;
  }
  initBehaviorEvents() {
    this.subs.push(O5(this.state.data.behaviors.isUpdating, this.state.behaviors.behaviors.isUpdating).subscribe((Q) => {
      if (this.behaviors.state.isUpdating.value !== Q)
        this.behaviors.state.isUpdating.next(Q);
    }));
    let Z = this.config.get(W8.General.IsBusyTimeoutMs) || 750, J = this.behaviors.state.isBusy, $ = void 0, X = () => {
      if (!J.value)
        J.next(!0);
    }, Y = () => {
      if ($ !== void 0)
        clearTimeout($);
      $ = void 0;
    };
    this.subs.push(O5(this.behaviors.state.isUpdating, this.behaviors.state.isAnimating).subscribe((Q) => {
      let W = this.behaviors.state.isUpdating.value, K = this.behaviors.state.isAnimating.value;
      if (W || K) {
        if (!J.value)
          Y(), $ = setTimeout(X, Z);
      } else
        Y(), J.next(!1);
    })), this.subs.push(this.behaviors.interaction.selectionMode.subscribe((Q) => {
      var W;
      if (!Q)
        (W = this.managers.interactivity) === null || W === void 0 || W.lociSelects.deselectAll();
    }));
  }
  initBuiltInBehavior() {
    DI.State.registerDefault(this), DI.Representation.registerDefault(this), DI.Camera.registerDefault(this), DI.Misc.registerDefault(this), this.subs.push(O5(this.state.data.events.log, this.state.behaviors.events.log).subscribe((Z) => this.events.log.next(Z)));
  }
  async initBehaviors() {
    let Z = this.state.behaviors.build();
    for (let J of Object.keys(i8.Categories))
      Z.toRoot().apply(i8.CreateCategory, { label: i8.Categories[J] }, { ref: J, state: { isLocked: !0 } });
    for (let J of this.spec.behaviors) {
      if (i8.getCategoryId(J.transformer) !== "custom-props")
        continue;
      Z.to(i8.getCategoryId(J.transformer)).apply(J.transformer, J.defaultParams, { ref: J.transformer.id });
    }
    await this.runTask(this.state.behaviors.updateTree(Z, { doNotUpdateCurrent: !0, doNotLogTiming: !0 })), Z = this.state.behaviors.build();
    for (let J of this.spec.behaviors) {
      if (i8.getCategoryId(J.transformer) === "custom-props")
        continue;
      Z.to(i8.getCategoryId(J.transformer)).apply(J.transformer, J.defaultParams, { ref: J.transformer.id });
    }
    await this.runTask(this.state.behaviors.updateTree(Z, { doNotUpdateCurrent: !0, doNotLogTiming: !0 }));
  }
  initCustomFormats() {
    if (!this.spec.customFormats)
      return;
    for (let Z of this.spec.customFormats)
      this.dataFormats.add(Z[0], Z[1]);
  }
  initAnimations() {
    if (!this.spec.animations)
      return;
    for (let Z of this.spec.animations)
      this.managers.animation.register(Z);
  }
  initDataActions() {
    if (!this.spec.actions)
      return;
    for (let Z of this.spec.actions)
      this.state.data.actions.add(Z.action);
  }
  async init() {
    try {
      if (this.subs.push(this.events.log.subscribe((Z) => this.log.entries = this.log.entries.push(Z))), this.initCustomFormats(), this.initBehaviorEvents(), this.initBuiltInBehavior(), this.managers.interactivity = new yH(this), this.managers.lociLabels = new F60(this), this.builders.structure = new $60(this), this.initAnimations(), this.initDataActions(), await this.initBehaviors(), this.log.message(`Mol* Plugin ${wx} [${Cj0.toLocaleString()}]`), !aL)
        this.log.message("Development mode enabled");
      if (y2)
        this.log.message("Debug mode enabled");
      this._isInitialized = !0, this.initializedPromiseCallbacks[0]();
    } catch (Z) {
      throw this.initializedPromiseCallbacks[1](Z), Z;
    }
  }
  constructor(Z) {
    var J;
    this.spec = Z, this.runTask = ($, X) => this.managers.task.run($, X), this.resolveTask = ($) => {
      if (!$)
        return;
      if (n0.is($))
        return this.runTask($);
      return $;
    }, this.subs = [], this.initCanvas3dPromiseCallbacks = [() => {}, () => {}], this._isInitialized = !1, this.initializedPromiseCallbacks = [() => {}, () => {}], this.disposed = !1, this.container = void 0, this.ev = xQ.create(), this.config = new ms(this.spec.config), this.state = new uX(this), this.commands = new us, this.canvas3dInit = this.ev.behavior(!1), this.behaviors = {
      state: {
        isAnimating: this.ev.behavior(!1),
        isUpdating: this.ev.behavior(!1),
        isBusy: this.ev.behavior(!1)
      },
      interaction: {
        hover: this.ev.behavior({ current: V2.Loci.Empty, modifiers: hJ.None, buttons: 0, button: 0 }),
        click: this.ev.behavior({ current: V2.Loci.Empty, modifiers: hJ.None, buttons: 0, button: 0 }),
        drag: this.ev.behavior({ current: V2.Loci.Empty, modifiers: hJ.None, buttons: 0, button: 0, pageStart: h0(), pageEnd: h0() }),
        key: this.ev.behavior(Le),
        keyReleased: this.ev.behavior(Le),
        selectionMode: this.ev.behavior(!1)
      },
      labels: {
        highlight: this.ev.behavior({ labels: [] })
      },
      layout: {
        leftPanelTabName: this.ev.behavior("root")
      },
      canvas3d: {
        initialized: this.canvas3dInit.pipe(fN(($) => !!$), Pi(1))
      }
    }, this.canvas3dInitialized = new Promise(($, X) => {
      this.initCanvas3dPromiseCallbacks = [$, X];
    }), this.initialized = new Promise(($, X) => {
      this.initializedPromiseCallbacks = [$, X];
    }), this.layout = new D60(this), this.animationLoop = new hZ0(this), this.representation = {
      structure: {
        registry: new Sw,
        themes: { colorThemeRegistry: oJ.createRegistry(), sizeThemeRegistry: J9.createRegistry() }
      },
      volume: {
        registry: new sR,
        themes: { colorThemeRegistry: oJ.createRegistry(), sizeThemeRegistry: J9.createRegistry() }
      }
    }, this.query = {
      structure: {
        registry: new _t
      }
    }, this.dataFormats = new Q60, this.builders = {
      data: new e80(this),
      structure: void 0
    }, this.helpers = {
      substructureParent: new bZ0(this),
      viewportScreenshot: void 0
    }, this.managers = {
      structure: {
        hierarchy: new kq(this),
        component: new XG(this),
        measurement: new V20(this),
        selection: new U60(this),
        focus: new R60(this)
      },
      volume: {
        hierarchy: new F4(this)
      },
      interactivity: void 0,
      camera: new q60(this),
      animation: new W60(this),
      snapshot: new EQ(this),
      lociLabels: void 0,
      toast: new xZ0(this),
      asset: new Oi,
      task: new kP,
      markdownExtensions: new O60(this),
      dragAndDrop: new gZ0(this)
    }, this.events = {
      log: this.ev(),
      task: this.managers.task.events,
      canvas3d: {
        settingsUpdated: this.ev()
      }
    }, this.customModelProperties = new qP.Registry, this.customStructureProperties = new qP.Registry, this.customStructureControls = /* @__PURE__ */ new Map, this.customImportControls = /* @__PURE__ */ new Map, this.genericRepresentationControls = /* @__PURE__ */ new Map, this.errorContext = new mZ0, this.customState = Object.create(null), this.handleResize = () => {
      var $, X;
      let Y = ($ = this.canvas3dContext) === null || $ === void 0 ? void 0 : $.canvas, Q = this.layout.root;
      if (Q && Y)
        kj0(Y, Q, this.canvas3dContext.pixelScale), this.canvas3dContext.syncPixelScale(), (X = this.canvas3d) === null || X === void 0 || X.requestResize();
    }, this.log = {
      entries: jN(),
      entry: ($) => this.events.log.next($),
      error: ($) => this.events.log.next(E3.error($)),
      message: ($) => this.events.log.next(E3.message($)),
      info: ($) => this.events.log.next(E3.info($)),
      warn: ($) => this.events.log.next(E3.warning($))
    }, this.fetch = R_, mH0((J = this.config.get(W8.Structure.SaccharideCompIdMapType)) !== null && J !== void 0 ? J : "default");
  }
}

// node_modules/molstar/lib/mol-plugin-ui/context.js
class uZ0 extends pZ0 {
  initCustomParamEditors() {
    if (!this.spec.customParamEditors)
      return;
    for (let [Z, J] of this.spec.customParamEditors)
      this.customParamEditors.set(Z.id, J);
  }
  dispose(Z) {
    super.dispose(Z), this.layout.dispose();
  }
  constructor(Z) {
    super(Z);
    this.spec = Z, this.customParamEditors = /* @__PURE__ */ new Map, this.customUIState = {}, this.initCustomParamEditors();
  }
}

// node_modules/molstar/lib/mol-plugin-ui/index.js
async function Pb0(Z) {
  let { spec: J, target: $, onBeforeUIRender: X, render: Y } = Z, Q = new uZ0(J || Ty());
  if (await Q.init(), X)
    await X(Q);
  Y(Ib0.createElement(ZS0, { plugin: Q }), $);
  try {
    await Q.canvas3dInitialized;
  } catch (W) {}
  return Q;
}

// node_modules/molstar/lib/mol-plugin-ui/react18.js
var Cb0 = t2(gc(), 1);
function kb0(Z, J) {
  Cb0.createRoot(J).render(Z);
}

// node_modules/molstar/lib/extensions/model-archive/quality-assessment/prop.js
var uE;
(function(Z) {
  let J = {
    value: {
      local: [],
      localMap: /* @__PURE__ */ new Map,
      localMetrics: /* @__PURE__ */ new Map
    }
  };
  function $(G, H) {
    if (!G || !S6.is(G.sourceData))
      return !1;
    let { db: N } = G.sourceData.data, q = N.ma_qa_metric.id.isDefined && N.ma_qa_metric_local.ordinal_id.isDefined;
    if (H && q) {
      let U = H.toLowerCase();
      for (let F = 0, E = N.ma_qa_metric._rowCount;F < E; F++) {
        if (N.ma_qa_metric.mode.value(F) !== "local")
          continue;
        if (N.ma_qa_metric.name.value(F).toLowerCase().includes(U))
          return !0;
      }
      return !1;
    } else
      return q;
  }
  Z.isApplicable = $;
  function X(G, H) {
    var N, q;
    if (!G)
      return j.Select(void 0, [], { label: "Metric", isHidden: !0 });
    let U = (N = C4.get(G).value) === null || N === void 0 ? void 0 : N.local;
    if (!U)
      return j.Select(void 0, [], { label: "Metric", isHidden: !0 });
    let F = U.filter((E) => E.kind === H).map((E) => [E.id, `${E.name} (${E.type})`]);
    return j.Select((q = F[0]) === null || q === void 0 ? void 0 : q[0], F, { label: "Metric " });
  }
  Z.getLocalOptions = X;
  async function Y(G, H, N) {
    var q, U;
    if (!H || !S6.is(H.sourceData))
      return J;
    let { ma_qa_metric: F, ma_qa_metric_local: E } = H.sourceData.data.db, { model_id: R, label_asym_id: z, label_seq_id: D, metric_id: A, metric_value: B } = E, { index: T } = H.atomicHierarchy, w = [], V = /* @__PURE__ */ new Map, P = /* @__PURE__ */ new Map, I = /* @__PURE__ */ new Map;
    for (let f = 0, v = F._rowCount;f < v; f++) {
      if (F.mode.value(f) !== "local")
        continue;
      let h = F.id.value(f), x = F.name.value(f), b = F.type.value(f), g = /* @__PURE__ */ new Map, m = b.toLowerCase().includes("plddt"), i = b.replace(/\s/g, "").includes("[0,1]"), r;
      if (i)
        r = [0, 1];
      else if (m)
        r = [0, 100];
      let Y0, c = x.toLowerCase();
      if (c.includes("plddt"))
        Y0 = "pLDDT";
      else if (c.includes("qmean"))
        Y0 = "qmean";
      if (!Y0 && m)
        Y0 = "pLDDT";
      if (!Y0 && i)
        Y0 = "qmean";
      let n = { id: h, kind: Y0, type: b, name: x, domain: r, valueRange: [Number.MAX_VALUE, -Number.MAX_VALUE], values: g };
      if (V.set(h, n), w.push(n), P.has(x)) {
        console.warn(`local ma_qa_metric with name '${x}' already added`);
        continue;
      }
      P.set(x, g), I.set(h, x);
    }
    let S = {
      label_entity_id: "",
      label_asym_id: "",
      label_seq_id: 0,
      pdbx_PDB_ins_code: void 0
    };
    for (let f = 0, v = E._rowCount;f < v; f++) {
      if (R.value(f) !== H.modelNum)
        continue;
      let h = z.value(f), x = T.findEntity(h);
      S.label_entity_id = H.entities.data.id.value(x), S.label_asym_id = h, S.label_seq_id = D.value(f);
      let b = T.findResidueLabel(S);
      if (b >= 0) {
        let g = V.get(A.value(f));
        if (!g)
          continue;
        let m = B.value(f), i = g.valueRange;
        if (m < i[0])
          i[0] = m;
        if (m > i[1])
          i[1] = m;
        g.values.set(b, m);
      }
    }
    return {
      value: {
        local: Array.from(V.values()),
        localMap: V,
        pLDDT: (q = w.find((f) => f.kind === "pLDDT")) === null || q === void 0 ? void 0 : q.values,
        qmean: (U = w.find((f) => f.kind === "qmean")) === null || U === void 0 ? void 0 : U.values,
        localMetrics: P
      }
    };
  }
  Z.obtain = Y;
  let Q = {
    ma_qa_metric: Q6.ma_qa_metric,
    ma_qa_metric_local_pairwise: Q6.ma_qa_metric_local_pairwise
  };
  function W(G) {
    let { ma_qa_metric: H, ma_qa_metric_local_pairwise: N } = HQ(Q, G), q = [];
    if (N._rowCount === 0)
      return q;
    for (let U = 0, F = H._rowCount;U < F; U++) {
      if (H.mode.value(U) !== "local-pairwise")
        continue;
      let E = H.id.value(U), R = H.name.value(U);
      if (!R.toLowerCase().includes("pae"))
        continue;
      q.push({ id: E, name: R });
    }
    return q;
  }
  Z.findModelArchiveCIFPAEMetrics = W;
  function K(G, H, N) {
    let q = HQ(Q, H);
    if (!q.ma_qa_metric_local_pairwise._rowCount)
      return;
    let { ma_qa_metric: U, ma_qa_metric_local_pairwise: F } = q, { model_id: E, label_asym_id_1: R, label_seq_id_1: z, label_asym_id_2: D, label_seq_id_2: A, metric_id: B, metric_value: T } = q.ma_qa_metric_local_pairwise, { index: w } = G.atomicHierarchy, V;
    for (let v = 0, h = U._rowCount;v < h; v++) {
      if (U.mode.value(v) !== "local-pairwise")
        continue;
      let x = U.id.value(v);
      if (x !== N)
        continue;
      let b = U.name.value(v);
      V = {
        id: x,
        name: b,
        residueRange: [Number.MAX_SAFE_INTEGER, Number.MIN_SAFE_INTEGER],
        valueRange: [Number.MAX_VALUE, -Number.MAX_VALUE],
        values: {}
      };
    }
    if (!V)
      return;
    let { values: P, residueRange: I, valueRange: S } = V, f = {
      label_entity_id: "",
      label_asym_id: "",
      label_seq_id: 0,
      pdbx_PDB_ins_code: void 0
    };
    for (let v = 0, h = F._rowCount;v < h; v++) {
      if (E.value(v) !== G.modelNum || B.value(v) !== N)
        continue;
      let x = R.value(v), b = w.findEntity(x);
      f.label_entity_id = G.entities.data.id.value(b), f.label_asym_id = x, f.label_seq_id = z.value(v);
      let g = w.findResidueLabel(f);
      if (g < 0)
        continue;
      x = D.value(v), b = w.findEntity(x), f.label_entity_id = G.entities.data.id.value(b), f.label_asym_id = x, f.label_seq_id = A.value(v);
      let m = w.findResidueLabel(f);
      if (g < 0)
        continue;
      let i = P[g];
      if (!i)
        i = {}, P[g] = i;
      let r = T.value(v);
      if (i[m] = r, g < I[0])
        I[0] = g;
      if (m < I[0])
        I[0] = m;
      if (g > I[1])
        I[1] = g;
      if (m > I[1])
        I[1] = m;
      if (r < S[0])
        S[0] = r;
      if (r > S[1])
        S[1] = r;
    }
    return V;
  }
  Z.pairwiseMetricFromModelArchiveCIF = K, Z.symbols = {
    pLDDT: NH.Dynamic(lM("ma", "quality-assessment.pLDDT", r0.Num), (G) => {
      var H, N;
      let { unit: q, element: U } = G.element;
      if (!j0.isAtomic(q))
        return -1;
      let F = C4.get(q.model).value;
      return (N = (H = F === null || F === void 0 ? void 0 : F.pLDDT) === null || H === void 0 ? void 0 : H.get(q.model.atomicHierarchy.residueAtomSegments.index[U])) !== null && N !== void 0 ? N : -1;
    }),
    qmean: NH.Dynamic(lM("ma", "quality-assessment.qmean", r0.Num), (G) => {
      var H, N;
      let { unit: q, element: U } = G.element;
      if (!j0.isAtomic(q))
        return -1;
      let F = C4.get(q.model).value;
      return (N = (H = F === null || F === void 0 ? void 0 : F.qmean) === null || H === void 0 ? void 0 : H.get(q.model.atomicHierarchy.residueAtomSegments.index[U])) !== null && N !== void 0 ? N : -1;
    })
  };
})(uE || (uE = {}));
var cZ0 = {}, C4 = j3.createProvider({
  label: "QualityAssessment",
  descriptor: p7({
    name: "ma_quality_assessment",
    symbols: uE.symbols
  }),
  type: "static",
  defaultParams: cZ0,
  getParams: (Z) => cZ0,
  isApplicable: (Z) => uE.isApplicable(Z),
  obtain: async (Z, J, $) => {
    let X = { ...j.getDefaultValues(cZ0), ...$ };
    return await uE.obtain(Z, J, X);
  }
});

// node_modules/molstar/lib/extensions/model-archive/quality-assessment/color/plddt.js
var vP = i0(11184810), JI1 = {
  "No Score": vP,
  "Very Low": i0(16743749),
  Low: i0(16767763),
  Confident: i0(6671347),
  "Very High": i0(21462)
}, $I1 = ZX(Object.entries(JI1));
function vb0(Z) {
  var J;
  return {
    metricId: uE.getLocalOptions((J = Z.structure) === null || J === void 0 ? void 0 : J.models[0], "pLDDT")
  };
}
function Sb0(Z, J) {
  let $ = () => vP;
  if (Z.structure) {
    let X = W0.Location.create(Z.structure.root), Y = (Q) => {
      var W, K;
      let { unit: G, element: H } = Q;
      if (!j0.isAtomic(G))
        return vP;
      let N = C4.get(G.model).value, q = (K = (W = N === null || N === void 0 ? void 0 : N.localMap.get(J.metricId)) === null || W === void 0 ? void 0 : W.values) !== null && K !== void 0 ? K : N === null || N === void 0 ? void 0 : N.pLDDT, U = q === null || q === void 0 ? void 0 : q.get(G.model.atomicHierarchy.residueAtomSegments.index[H]);
      if (typeof U !== "number")
        U = G.model.atomicConformation.B_iso_or_equiv.value(H);
      if (U < 0)
        return vP;
      else if (U <= 50)
        return i0(16743749);
      else if (U <= 70)
        return i0(16767763);
      else if (U <= 90)
        return i0(6671347);
      else
        return i0(21462);
    };
    $ = (Q) => {
      if (W0.Location.is(Q))
        return Y(Q);
      else if ($2.isLocation(Q))
        return X.unit = Q.aUnit, X.element = Q.aUnit.elements[Q.aIndex], Y(X);
      return vP;
    };
  }
  return {
    factory: Sb0,
    granularity: "group",
    preferSmoothing: !0,
    color: $,
    props: J,
    description: "Assigns residue colors according to the pLDDT Confidence score. If no Model Archive quality assessment score is available, the B-factor value is used instead.",
    legend: $I1
  };
}
var fb0 = {
  name: "plddt-confidence",
  label: "pLDDT Confidence",
  category: $8.Validation,
  factory: Sb0,
  getParams: vb0,
  defaultValues: j.getDefaultValues(vb0({})),
  isApplicable: (Z) => {
    var J;
    return !!((J = Z.structure) === null || J === void 0 ? void 0 : J.models.some(($) => uE.isApplicable($, "pLDDT") || $.atomicConformation.B_iso_or_equiv.isDefined && !O2.isExperimental($)));
  },
  ensureCustomProperties: {
    attach: async (Z, J) => {
      if (J.structure)
        for (let $ of J.structure.models)
          await C4.attach(Z, $, void 0, !0);
    },
    detach: async (Z) => {
      if (Z.structure)
        for (let J of Z.structure.models)
          C4.ref(J, !1);
    }
  }
};

// src/utils.ts
var hb0 = (Z) => {
  let J = new ArrayBuffer(8);
  return new DataView(J).setFloat64(0, Z, !0), J;
};

// src/MolstarCustomComponent.tsx
var u6 = { plugin: null, structures: [], representations: [], loadingPlugin: !1, loadingPdb: !1 };
function XI1(Z) {
  let J = async () => {
    if (u6.loadingPlugin || u6.plugin)
      return;
    let T = document.getElementById(Z.divName);
    u6.loadingPlugin = !0;
    let w = await Pb0({
      target: T,
      render: kb0,
      spec: {
        ...Ty(),
        layout: {
          initial: {
            showControls: Z.showControls,
            controlsDisplay: "landscape",
            regionState: {
              top: "full",
              left: "hidden",
              bottom: "hidden",
              right: "full"
            }
          }
        },
        components: {
          remoteState: "none"
        },
        config: [
          [W8.VolumeStreaming.Enabled, !0],
          [W8.Viewport.ShowExpand, !1],
          [W8.Viewport.ShowToggleFullscreen, !0],
          [W8.Viewport.ShowAnimation, !1],
          [W8.Viewport.ShowXR, !1],
          [W8.Viewport.ShowControls, !0],
          [W8.Viewport.ShowSettings, !0],
          [W8.Viewport.ShowSelectionMode, !0]
        ]
      }
    });
    if (w.representation.structure.themes.colorThemeRegistry.add(fb0), Z.selectionMode)
      w.selectionMode = !0, w.canvas3d?.interaction.click.subscribe(async (V) => {
        $(w);
      }), w.behaviors.interaction.click.subscribe(async (V) => {
        $(w);
      });
    w.behaviors.canvas3d.initialized.subscribe((V) => {
      if (V) {
        let P = w.canvas3d?.attribs.trackball.bindings.scrollZoom.triggers[0].modifiers;
        if (P)
          P.control = !0;
        w.canvas3dContext.input.noScroll = !1, T.addEventListener("wheel", (I) => {
          if (I.ctrlKey)
            I.preventDefault();
        }, !1);
      }
    }), u6.plugin = w, u6.loadingPlugin = !1, W(Z.structures);
  }, $ = (T) => {
    let w = T.managers.structure.selection.state.entries.entries().next().value;
    if (!w || !w[1].selection.elements[0]) {
      Z.updateStreamlitComponentValue({
        sequenceSelections: []
      });
      return;
    }
    let V = [];
    for (let P = 0;P < w[1].selection.elements.length; P++) {
      let I;
      if (typeof w[1].selection.elements[P].indices === "number") {
        let x = new Int32Array(hb0(w[1].selection.elements[P].indices)), b = x[0], g = x[1] - 1;
        I = q([b, g]);
      } else
        I = Array.from(w[1].selection.elements[P].indices);
      I = I.map((x) => w[1].selection.elements[P].unit.elements[x]);
      let S = D(T, I.map((x) => x + 1), w[1].selection.elements[P].unit.chainGroupId, 0), f = f1.unionStructure(S), v = "?", h = [];
      s0.eachAtomicHierarchyElement(f, {
        residue: (x) => h.push(w1.residue.auth_seq_id(x)),
        chain: (x) => v = w1.chain.auth_asym_id(x)
      }), V.push({
        chainId: v,
        residues: h
      });
    }
    Z.updateStreamlitComponentValue({
      sequenceSelections: V
    });
  }, X = (T) => {
    return T.map((P) => P.trim()).filter((P) => P !== "").map((P) => {
      let I = /([A-Z]+)(\d+)(-\d+)?/, S = P.match(I);
      if (S) {
        let f = parseInt(S[2]);
        return {
          chainId: S[1],
          residues: q([f, S[3] ? parseInt(S[3].slice(1)) : f])
        };
      } else
        throw new Error(`Invalid format for selection: ${P}`);
    });
  }, Y = async (T, w) => {
    if (!u6.plugin)
      return;
    if (!T || T.length === 0)
      return;
    let V = X(T);
    for (let P of V) {
      let I = z(u6.plugin, P.chainId, P.residues, w), S = f1.toLociWithSourceUnits(I);
      u6.plugin.managers.structure.selection.fromLoci("add", S);
    }
    Z.updateStreamlitComponentValue({
      sequenceSelections: V
    });
  }, Q = async () => {
    if (u6.loadingPdb)
      return;
    for (let T of u6.structures)
      if (T) {
        let w = u6.plugin.build();
        w.delete(T), await w.commit();
      }
    u6.structures = [], u6.representations = [];
  }, W = async (T) => {
    if (u6.loadingPdb)
      return;
    u6.loadingPdb = !0;
    try {
      u6.representations = new Array(T.length).fill([]), u6.structures = new Array(T.length).fill(null), console.log("MolStar loading structures", T);
      for (let w = 0;w < T.length; w++) {
        let V = T[w];
        if (await H(V, w), Z.contigs[w] && Z.contigs[w].length > 0)
          await N(w), U(w), R(w), F(w);
        if ("highlighted_selections" in T[w])
          Y(T[w].highlighted_selections, w);
        if ("chains" in T[w])
          await A(T[w].chains, w);
      }
    } finally {
      u6.loadingPdb = !1;
    }
  }, K = (T) => {
    return T.includes("http");
  }, G = (T, w, V) => {
    if (T === "uniform")
      return {
        color: T,
        colorParams: {
          ...w,
          ...{
            value: i0(w?.value ? parseInt(w.value, 16) : 16777215)
          }
        }
      };
    else if (T === "chain-id")
      return {
        color: T,
        colorParams: {
          ...w,
          ...{
            palette: { name: "colors", params: { list: { colors: RJ(w?.palette || "pastel-1").list } } }
          }
        }
      };
    else if (T === "plddt") {
      let P = {
        label: (I) => {
          if (W0.Loci.is(I)) {
            let S = W0.Loci.getFirstLocation(I);
            if (!S)
              return;
            return `pLDDT: ${w1.atom.B_iso_or_equiv(S)}`;
          }
          return "";
        }
      };
      return V.managers.lociLabels.addProvider(P), {
        color: "plddt-confidence"
      };
    }
    return { color: T, colorParams: w };
  }, H = async (T, w) => {
    let V = u6.plugin;
    if (!V)
      return;
    if (u6.structures && u6.structures[w]) {
      let h = V.build();
      h.delete(u6.structures[w]), await h.commit();
    }
    let P, I;
    if (K(T.pdb))
      if (P = await V.builders.data.download({
        url: E6.Url(T.pdb),
        isBinary: !1
      }, { state: { isGhost: !0 } }), T.pdb.includes(".pdb"))
        I = await V.builders.structure.parseTrajectory(P, "pdb");
      else
        I = await V.builders.structure.parseTrajectory(P, "mmcif");
    else if (T.pdb.includes("loop_"))
      P = await V.builders.data.rawData({
        data: T.pdb
      }), I = await V.builders.structure.parseTrajectory(P, "mmcif");
    else {
      let h = [];
      if (T.chains)
        for (let g = 0;g < T.chains.length; g++) {
          let m = T.chains[g];
          if (m.label) {
            let i = `COMPND    MOL_ID: ${g + 1};
COMPND   2 MOLECULE: ${m.label};
COMPND   3 CHAIN: ${m.chain_id};`;
            h.push(i);
          }
        }
      let b = h.join(`
`) + `
` + T.pdb;
      P = await V.builders.data.rawData({
        data: b
      }), I = await V.builders.structure.parseTrajectory(P, "pdb");
    }
    let S = await V.builders.structure.createModel(I), f = await V.builders.structure.createStructure(S, { name: "model", params: {} }), v = await V.builders.structure.tryCreateComponentStatic(f, "polymer");
    if (v && T.representation_type) {
      let h = T.representation_type.split("+");
      for (let x of h) {
        let b = await V.builders.structure.representation.addRepresentation(v, {
          type: x,
          ...G(T.color, T.color_params, V)
        });
        u6.representations[w].push(b);
      }
    }
    if (u6.structures[w] = f, T.representation_type) {
      let h = ["ligand", "nucleic", "lipid", "branched", "non-standard", "coarse"];
      for (let x of h) {
        let b = await V.builders.structure.tryCreateComponentStatic(f, x);
        if (b)
          V.builders.structure.representation.addRepresentation(b, {
            type: "ball-and-stick"
          });
        if (x === "branched") {
          if (b)
            V.builders.structure.representation.addRepresentation(b, {
              type: "carbohydrate"
            });
        }
      }
    }
    return [S, f, v];
  }, N = async (T) => {
    if (!u6.plugin || !u6.structures || !u6.representations)
      return;
    let w = u6.plugin.state.data.build(), V = [];
    Z.contigs[T].forEach((P, I) => {
      let S = Array.from(new Array(P.length), (v, h) => h + P.out_res_start), f = oF.fromSelection(z(u6.plugin, P.out_res_chain, S, T));
      V.push({ bundle: f, color: i0.fromHexString(P.color.replace("#", "0x")), clear: !1 });
    }), u6.representations[T].map((P) => w.to(P).apply(H1.Representation.OverpaintStructureRepresentation3DFromBundle, { layers: V })), await w.commit();
  }, q = (T) => {
    let w = T[0], V = T[T.length - 1] - w + 1;
    return Array.from(new Array(V), (I, S) => S + w);
  }, U = (T) => {
    if (!u6.plugin)
      return;
    let w = Z.contigs[T].filter((f) => f.type === "fixed").flatMap((f) => [f.out_res_start, f.out_res_end]), V = Z.contigs[T].filter((f) => f.type === "fixed").flatMap((f) => [
      f.input_res_chain + f.input_res_start,
      f.input_res_chain + f.input_res_end
    ]), P = Z.contigs[T].filter((f) => f.type === "fixed").flatMap((f) => [f.out_res_chain, f.out_res_chain]), I = Z.contigs[T].filter((f) => f.type === "fixed").flatMap((f) => [i0.fromHexString(f.color.replace("#", "0x")), i0(16777215)]), S = Z.contigs[T].filter((f) => f.type === "fixed").flatMap((f) => [i0(16777215), i0.fromHexString(f.color.replace("#", "0x"))]);
    w.forEach((f, v) => {
      let h = z(u6.plugin, P[v], [f], T, !0), x = f1.toLociWithSourceUnits(h), b = {
        labelParams: {
          customText: V[v]
        },
        visualParams: {
          scaleByRadius: !1,
          sizeFactor: 1,
          textSize: 2,
          textColor: I[v],
          borderColor: S[v],
          offsetZ: 2
        }
      };
      u6.plugin.managers.structure.measurement.addLabel(x, b);
    });
  }, F = (T) => {
    if (!u6.plugin)
      return;
    let w = Z.contigs[T].filter((I) => I.type === "fixed").flatMap((I) => [I.out_res_start, I.out_res_end]), V = Z.contigs[T].filter((I) => I.type === "fixed").flatMap((I) => [I.out_res_chain, I.out_res_chain]), P = Z.contigs[T].filter((I) => I.type === "fixed").flatMap((I) => [
      i0.fromHexString(I.color.replace("#", "0x")),
      i0.fromHexString(I.color.replace("#", "0x"))
    ]);
    for (let I = 1;I < w.length - 1; I += 2) {
      let S = f1.toLociWithSourceUnits(z(u6.plugin, V[I], [w[I]], T, !0)), f = f1.toLociWithSourceUnits(z(u6.plugin, V[I + 1], [w[I + 1]], T, !0)), v = {
        visualParams: {
          customText: " ",
          scaleByRadius: !1,
          sizeFactor: 1,
          linesColor: P[I],
          dashLength: 0.2
        }
      };
      u6.plugin.managers.structure.measurement.addDistance(S, f, v);
    }
  }, E = (T, w, V) => {
    if (!u6.plugin)
      return;
    let P = z(u6.plugin, T, w, V), I = f1.toLociWithSourceUnits(P);
    u6.plugin.managers.interactivity.lociHighlights.highlightOnly({ loci: I });
  }, R = (T) => {
    if (!u6.plugin)
      return;
    Z.contigs[T].filter((V) => V.type === "generated").forEach((V, P) => {
      if (V.length === 0)
        return;
      let I = Math.ceil((V.out_res_start + V.out_res_end) / 2), S = z(u6.plugin, V.out_res_chain, [I], T, !0), f = f1.toLociWithSourceUnits(S), h = {
        labelParams: {
          customText: `${V.length}`
        },
        visualParams: {
          scaleByRadius: !1,
          sizeFactor: 1,
          textSize: 3,
          textColor: i0(0),
          borderColor: i0.fromHexString(V.color.replace("#", "0x")),
          offsetZ: 2
        }
      };
      u6.plugin.managers.structure.measurement.addLabel(f, h);
    });
  }, z = (T, w, V, P, I = !1) => {
    let S = {
      "chain-test": L0.core.rel.eq([L0.struct.atomProperty.macromolecular.auth_asym_id(), w]),
      "residue-test": L0.core.set.has([L0.set(...V), L0.struct.atomProperty.macromolecular.auth_seq_id()]),
      "group-by": L0.struct.atomProperty.macromolecular.residueKey()
    };
    if (I)
      S["atom-test"] = L0.core.set.has([
        L0.core.type.set(["C", "N", "CA", "O"].map(L0.atomName)),
        L0.ammp("label_atom_id")
      ]);
    let f = L0.struct.generator.atomGroups(S);
    return cZ.getStructureSelection(f, T.managers.structure.hierarchy.current.structures[P].cell.obj.data);
  }, D = (T, w, V, P) => {
    let I = V !== void 0 ? w.map((f) => f + V) : w, S = L0.struct.generator.atomGroups({
      "atom-test": L0.core.set.has([L0.set(...I), L0.struct.atomProperty.macromolecular.id()])
    });
    return cZ.getStructureSelection(S, T.managers.structure.hierarchy.current.structures[P].cell.obj.data);
  }, A = async (T, w) => {
    if (!u6.plugin || !T)
      return;
    for (let V of T) {
      let P = u6.plugin.state.data.build(), I = P.to(u6.structures[w]).apply(H1.Misc.CreateGroup, { label: `chain_${V.chain_id}_${w}` }, { ref: `chain_${V.chain_id}_${w}` }), S;
      if (V.residues && V.residues.length > 0)
        S = L0.struct.generator.atomGroups({
          "chain-test": L0.core.rel.eq([L0.struct.atomProperty.macromolecular.auth_asym_id(), V.chain_id]),
          "residue-test": L0.core.set.has([L0.set(...V.residues), L0.struct.atomProperty.macromolecular.auth_seq_id()]),
          "group-by": L0.struct.atomProperty.macromolecular.residueKey()
        });
      else
        S = L0.struct.generator.atomGroups({
          "chain-test": L0.core.rel.eq([L0.struct.atomProperty.macromolecular.auth_asym_id(), V.chain_id])
        });
      let f = L0.struct.modifier.wholeResidues({ 0: S }), v = I.apply(H1.Model.StructureSelectionFromExpression, { expression: f }), h = V.representation_type.split("+");
      for (let x of h)
        v.apply(H1.Representation.StructureRepresentation3D, UE(u6.plugin, u6.structures[w].data, {
          type: x,
          size: "physical",
          sizeParams: { scale: 1.05 },
          ...G(V.color, V.color_params, u6.plugin)
        }));
      await P.commit();
    }
  };
  xU.useEffect(() => {
    J(), console.log("CONTIGS", Z.contigs);
  }, []), xU.useEffect(() => {
    if (!Z.highlightedContig)
      return;
    E(Z.highlightedContig.out_res_chain, q([Z.highlightedContig.out_res_start, Z.highlightedContig.out_res_end]), Z.highlightedContig.structureIdx);
  }, [Z.highlightedContig]);
  let B = xU.default.useRef([]);
  return xU.useEffect(() => {
    let T = (P) => P.map(({ highlighted_selections: I, ...S }) => S), w = JSON.stringify(T(B.current)), V = JSON.stringify(T(Z.structures));
    if (w !== V)
      (async () => {
        await Q(), W(Z.structures);
      })(), B.current = Z.structures.map(({ highlighted_selections: I, ...S }) => S);
  }, [Z.structures]), xU.useEffect(() => {
    if (Z.forceReload)
      (async () => {
        await Q(), W(Z.structures);
      })();
  }, [Z.forceReload]), /* @__PURE__ */ xU.default.createElement(xU.default.Fragment, null);
}
var vm = XI1;

// src/StreamlitWrapper.tsx
function YI1(Z, J, $ = 100) {
  if (!J)
    return Z;
  let X = Z.match(/^(\d+)(px)?$/);
  if (X)
    return `${parseInt(X[1]) - $}px`;
  return `calc(${Z} - ${$}px)`;
}

class bb0 extends Hn {
  constructor(Z) {
    super(Z);
    this.state = { highlightedContig: null, currentComponentState: null, isFullscreen: !1 }, this.setHighlightedContig = this.setHighlightedContig.bind(this), this.updateStreamlitComponentValue = this.updateStreamlitComponentValue.bind(this), this.handleFullscreenChange = this.handleFullscreenChange.bind(this);
  }
  componentDidMount() {
    document.addEventListener("fullscreenchange", this.handleFullscreenChange), document.addEventListener("webkitfullscreenchange", this.handleFullscreenChange), setTimeout(() => {
      U5.setFrameHeight();
    }, 100);
  }
  componentWillUnmount() {
    document.removeEventListener("fullscreenchange", this.handleFullscreenChange), document.removeEventListener("webkitfullscreenchange", this.handleFullscreenChange);
  }
  handleFullscreenChange = () => {
    let Z = !!(document.fullscreenElement || document.webkitFullscreenElement);
    if (this.setState({ isFullscreen: Z }), !Z)
      setTimeout(() => {
        U5.setFrameHeight();
      }, 100);
  };
  setHighlightedContig = (Z, J) => {
    this.setState(($) => {
      return {
        ...$,
        highlightedContig: {
          ...Z,
          structureIdx: J
        }
      };
    });
  };
  updateStreamlitComponentValue = (Z) => {
    this.setState((J) => {
      if (J?.currentComponentState) {
        let $ = JSON.stringify(J.currentComponentState), X = JSON.stringify(Z);
        if ($ !== X)
          U5.setComponentValue(X);
      }
      return {
        ...J,
        currentComponentState: Z
      };
    });
  };
  render = () => {
    let Z = JSON.parse(this.props.args.structures), $ = `molstar-wrapper-${this.props.args.key}`, X = this.props.args.showControls, Y = this.props.args.selectionMode, Q = this.props.args.forceReload ?? !1, W = this.props.args.height, K = 100, G = YI1(W, Y, 100), H = this.props.args.width, N = this.state.isFullscreen ? "100%" : H, q = [];
    return Z.forEach((U) => q.push(U.contigs ?? [])), /* @__PURE__ */ cH.default.createElement(cH.default.Fragment, null, /* @__PURE__ */ cH.default.createElement("div", {
      id: $,
      style: { height: G, width: N }
    }, /* @__PURE__ */ cH.default.createElement(vm, {
      structures: Z,
      divName: $,
      showControls: X,
      contigs: q,
      highlightedContig: this.state.highlightedContig,
      selectionMode: Y,
      updateStreamlitComponentValue: this.updateStreamlitComponentValue,
      forceReload: Q
    })), !this.state.isFullscreen && q.map((U, F) => {
      if (U.length > 0)
        return /* @__PURE__ */ cH.default.createElement("div", {
          style: { color: "black", width: "80%", position: "relative" },
          key: F
        }, "Contigs: ", U.map((E, R) => {
          let z = `${E.input_res_chain}${E.input_res_start}-${E.input_res_end} `;
          if (E.type === "fixed")
            return /* @__PURE__ */ cH.default.createElement("span", {
              style: { color: E.color },
              onMouseOver: () => this.setHighlightedContig(E, F),
              key: R
            }, z);
          return /* @__PURE__ */ cH.default.createElement(cH.default.Fragment, {
            key: R
          });
        }));
      return /* @__PURE__ */ cH.default.createElement(cH.default.Fragment, {
        key: F
      });
    }));
  };
}
var xb0 = Nn(bb0);

// src/index.tsx
var mb0 = document.getElementById("root"), yb0 = gb0.createRoot(mb0);
if (mb0?.classList?.contains("molstar_notebook")) {
  let Z = window.STRUCTURES, J = [];
  Z.forEach((X) => J.push(X.contigs ?? []));
  let $ = (X) => {};
  yb0.render(/* @__PURE__ */ fw.default.createElement("div", {
    id: "molstar_root"
  }, /* @__PURE__ */ fw.default.createElement(vm, {
    structures: Z,
    divName: "molstar_root",
    contigs: J,
    highlightedContig: null,
    selectionMode: !1,
    showControls: !1,
    updateStreamlitComponentValue: $
  })));
} else
  yb0.render(/* @__PURE__ */ fw.default.createElement(fw.default.StrictMode, null, /* @__PURE__ */ fw.default.createElement(xb0, null)));
